Commit 012bbf8e25185168eaf33dd1d771f1d83a13e38a

Authored by 房远帅
1 parent fd958458

采购:外贸客户资信-修改、变更、审核、取消

@@ -1571,6 +1571,9 @@ CREATE TABLE `procurement_foreign_trade_credit` @@ -1571,6 +1571,9 @@ CREATE TABLE `procurement_foreign_trade_credit`
1571 `payment_method` varchar(500) NOT NULL COMMENT '付款方式', 1571 `payment_method` varchar(500) NOT NULL COMMENT '付款方式',
1572 `next_review_time` date NOT NULL COMMENT '下次评审时间', 1572 `next_review_time` date NOT NULL COMMENT '下次评审时间',
1573 `review_department` varchar(200) NOT NULL COMMENT '评审部门', 1573 `review_department` varchar(200) NOT NULL COMMENT '评审部门',
  1574 + `investigator_id` varchar(200) NOT NULL COMMENT '资信调查人ID',
  1575 + `investigator_name` varchar(200) NOT NULL COMMENT '资信调查人',
  1576 + `purchase_department` varchar(200) NOT NULL COMMENT '采购处',
1574 `status` varchar(20) DEFAULT NULL COMMENT '审核状态', 1577 `status` varchar(20) DEFAULT NULL COMMENT '审核状态',
1575 `freeze` bool DEFAULT false COMMENT '是否冻结', 1578 `freeze` bool DEFAULT false COMMENT '是否冻结',
1576 `create_by_id` varchar(32) DEFAULT NULL COMMENT '创建人ID', 1579 `create_by_id` varchar(32) DEFAULT NULL COMMENT '创建人ID',
@@ -19,7 +19,9 @@ import com.lframework.xingyun.basedata.service.workshop.WorkshopService; @@ -19,7 +19,9 @@ import com.lframework.xingyun.basedata.service.workshop.WorkshopService;
19 import com.lframework.xingyun.sc.entity.*; 19 import com.lframework.xingyun.sc.entity.*;
20 import com.lframework.xingyun.sc.enums.CustomerDevelopStatus; 20 import com.lframework.xingyun.sc.enums.CustomerDevelopStatus;
21 import com.lframework.xingyun.sc.procurement.entity.ProcurementDomesticCustomerCredit; 21 import com.lframework.xingyun.sc.procurement.entity.ProcurementDomesticCustomerCredit;
  22 +import com.lframework.xingyun.sc.procurement.entity.ProcurementForeignTradeCredit;
22 import com.lframework.xingyun.sc.procurement.service.credit.ProcurementDomesticCustomerCreditService; 23 import com.lframework.xingyun.sc.procurement.service.credit.ProcurementDomesticCustomerCreditService;
  24 +import com.lframework.xingyun.sc.procurement.service.credit.ProcurementForeignTradeCreditService;
23 import com.lframework.xingyun.sc.service.contract.ContractDistributorLineService; 25 import com.lframework.xingyun.sc.service.contract.ContractDistributorLineService;
24 import com.lframework.xingyun.sc.service.contract.ContractDistributorStandardService; 26 import com.lframework.xingyun.sc.service.contract.ContractDistributorStandardService;
25 import com.lframework.xingyun.sc.service.contract.ContractStdProcessingLineService; 27 import com.lframework.xingyun.sc.service.contract.ContractStdProcessingLineService;
@@ -147,6 +149,8 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic @@ -147,6 +149,8 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
147 private OrderDetailReportService orderDetailReportService; 149 private OrderDetailReportService orderDetailReportService;
148 @Resource 150 @Resource
149 private ProcurementDomesticCustomerCreditService procurementDomesticCustomerCreditService; 151 private ProcurementDomesticCustomerCreditService procurementDomesticCustomerCreditService;
  152 + @Resource
  153 + private ProcurementForeignTradeCreditService procurementForeignTradeCreditService;
150 154
151 155
152 156
@@ -225,6 +229,9 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic @@ -225,6 +229,9 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
225 case "CUSTOMER_CREDIT_IN": 229 case "CUSTOMER_CREDIT_IN":
226 handleResultDomesticCustomerCreditData(flowStatus, businessId); 230 handleResultDomesticCustomerCreditData(flowStatus, businessId);
227 break; 231 break;
  232 + case "CUSTOMER_CREDIT_OUT":
  233 + handleResultForeignTradeCreditData(flowStatus, businessId);
  234 + break;
228 default: 235 default:
229 break; 236 break;
230 } 237 }
@@ -1014,4 +1021,31 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic @@ -1014,4 +1021,31 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
1014 procurementDomesticCustomerCreditService.updateStatus(businessId, "REFUSE"); 1021 procurementDomesticCustomerCreditService.updateStatus(businessId, "REFUSE");
1015 } 1022 }
1016 } 1023 }
  1024 +
  1025 + //采购-外贸资信
  1026 + private void handleResultForeignTradeCreditData(String flowStatus, String businessId) {
  1027 + Object o = redisHandler.get(businessId);
  1028 + ProcurementForeignTradeCredit vo = null;
  1029 + if (o != null) {
  1030 + vo = JsonUtil.parseObject(o.toString(), ProcurementForeignTradeCredit.class);
  1031 + }
  1032 + if (FlowInstanceStatus.APPROVE_PASS.getCode().equals(flowStatus)
  1033 + || FlowInstanceStatus.FINISH.getCode().equals(flowStatus)) {
  1034 + if (vo != null) {
  1035 + vo.setStatus("PASS");
  1036 + vo.setFreeze(Boolean.FALSE);
  1037 + procurementForeignTradeCreditService.updateNoFlowInstance(vo);
  1038 + redisHandler.del(businessId);
  1039 + } else {
  1040 + procurementForeignTradeCreditService.updateStatus(businessId, "PASS");
  1041 + }
  1042 + } else if (FlowInstanceStatus.REVOKE.getCode().equals(flowStatus)
  1043 + || FlowInstanceStatus.REFUSE.getCode().equals(flowStatus)
  1044 + || FlowInstanceStatus.TERMINATION.getCode().equals(flowStatus)) {
  1045 + if (vo != null) {
  1046 + redisHandler.del(businessId);
  1047 + }
  1048 + procurementForeignTradeCreditService.updateStatus(businessId, "REFUSE");
  1049 + }
  1050 + }
1017 } 1051 }
1 package com.lframework.xingyun.sc.procurement.controller.credit; 1 package com.lframework.xingyun.sc.procurement.controller.credit;
2 2
  3 +import com.lframework.starter.common.exceptions.impl.DefaultClientException;
3 import com.lframework.starter.web.core.annotations.security.HasPermission; 4 import com.lframework.starter.web.core.annotations.security.HasPermission;
  5 +import com.lframework.starter.web.core.components.redis.RedisHandler;
4 import com.lframework.starter.web.core.components.resp.InvokeResult; 6 import com.lframework.starter.web.core.components.resp.InvokeResult;
5 import com.lframework.starter.web.core.components.resp.InvokeResultBuilder; 7 import com.lframework.starter.web.core.components.resp.InvokeResultBuilder;
6 import com.lframework.starter.web.core.components.resp.PageResult; 8 import com.lframework.starter.web.core.components.resp.PageResult;
7 import com.lframework.starter.web.core.controller.DefaultBaseController; 9 import com.lframework.starter.web.core.controller.DefaultBaseController;
  10 +import com.lframework.starter.web.core.utils.JsonUtil;
8 import com.lframework.xingyun.sc.procurement.entity.ProcurementForeignTradeCredit; 11 import com.lframework.xingyun.sc.procurement.entity.ProcurementForeignTradeCredit;
9 import com.lframework.xingyun.sc.procurement.service.credit.ProcurementForeignTradeCreditService; 12 import com.lframework.xingyun.sc.procurement.service.credit.ProcurementForeignTradeCreditService;
10 import com.lframework.xingyun.sc.procurement.vo.credit.CreateProcurementForeignTradeCreditVo; 13 import com.lframework.xingyun.sc.procurement.vo.credit.CreateProcurementForeignTradeCreditVo;
11 import com.lframework.xingyun.sc.procurement.vo.credit.QueryProcurementForeignTradeCreditVo; 14 import com.lframework.xingyun.sc.procurement.vo.credit.QueryProcurementForeignTradeCreditVo;
  15 +import com.lframework.xingyun.sc.procurement.vo.credit.UpdateProcurementForeignTradeCreditVo;
12 import io.swagger.annotations.Api; 16 import io.swagger.annotations.Api;
13 import io.swagger.annotations.ApiImplicitParam; 17 import io.swagger.annotations.ApiImplicitParam;
14 import io.swagger.annotations.ApiOperation; 18 import io.swagger.annotations.ApiOperation;
  19 +import org.springframework.beans.factory.annotation.Autowired;
15 import org.springframework.validation.annotation.Validated; 20 import org.springframework.validation.annotation.Validated;
16 import org.springframework.web.bind.annotation.*; 21 import org.springframework.web.bind.annotation.*;
17 22
@@ -27,6 +32,8 @@ public class ProcurementForeignTradeCreditController extends DefaultBaseControll @@ -27,6 +32,8 @@ public class ProcurementForeignTradeCreditController extends DefaultBaseControll
27 32
28 @Resource 33 @Resource
29 private ProcurementForeignTradeCreditService procurementForeignTradeCreditService; 34 private ProcurementForeignTradeCreditService procurementForeignTradeCreditService;
  35 + @Autowired
  36 + private RedisHandler redisHandler;
30 37
31 @ApiOperation("新增") 38 @ApiOperation("新增")
32 @HasPermission({"procure-manage:foreign-trade:add"}) 39 @HasPermission({"procure-manage:foreign-trade:add"})
@@ -46,11 +53,54 @@ public class ProcurementForeignTradeCreditController extends DefaultBaseControll @@ -46,11 +53,54 @@ public class ProcurementForeignTradeCreditController extends DefaultBaseControll
46 } 53 }
47 54
48 @ApiOperation("详情") 55 @ApiOperation("详情")
49 - @HasPermission({"procure-manage:foreign-trade:query"}) 56 + @HasPermission({"procure-manage:foreign-trade:query","procure-manage:foreign-trade:review"})
50 @ApiImplicitParam(value = "id", name = "id", paramType = "query", required = true) 57 @ApiImplicitParam(value = "id", name = "id", paramType = "query", required = true)
51 @GetMapping("/get") 58 @GetMapping("/get")
52 public InvokeResult<ProcurementForeignTradeCredit> get( 59 public InvokeResult<ProcurementForeignTradeCredit> get(
53 @NotBlank(message = "id不能为空!") String id) { 60 @NotBlank(message = "id不能为空!") String id) {
54 return InvokeResultBuilder.success(procurementForeignTradeCreditService.findById(id)); 61 return InvokeResultBuilder.success(procurementForeignTradeCreditService.findById(id));
55 } 62 }
  63 +
  64 + /**
  65 + * 修改/变更
  66 + */
  67 + @ApiOperation("修改/变更")
  68 + @HasPermission({"procure-manage:foreign-trade:modify","procure-manage:foreign-trade:approve","procure-manage:foreign-trade:change"})
  69 + @PutMapping
  70 + public InvokeResult<Void> update(@Valid @RequestBody UpdateProcurementForeignTradeCreditVo vo) {
  71 + procurementForeignTradeCreditService.update(vo);
  72 + return InvokeResultBuilder.success();
  73 + }
  74 +
  75 + /**
  76 + * 取消
  77 + */
  78 + @ApiOperation("取消")
  79 + @HasPermission({"procure-manage:foreign-trade:cancel"})
  80 + @GetMapping("/cancel")
  81 + public InvokeResult<Void> cancel(@NotBlank(message = "id不能为空!") String id,
  82 + @NotBlank(message = "status不能为空!") String status) {
  83 + procurementForeignTradeCreditService.updateStatus(id, status);
  84 + return InvokeResultBuilder.success();
  85 + }
  86 +
  87 + /**
  88 + * 根据ID查询变更审核的数据
  89 + */
  90 + @ApiOperation("根据ID查询变更审核的数据")
  91 + @ApiImplicitParam(value = "id", name = "id", paramType = "query", required = true)
  92 + @HasPermission({"procure-manage:foreign-trade:approve", "procure-manage:foreign-trade:review"})
  93 + @GetMapping("/getExamineById")
  94 + public InvokeResult<ProcurementForeignTradeCredit> getExamineById(@NotBlank(message = "id不能为空!") String id) {
  95 + Object o = redisHandler.get(id);
  96 + if (o != null) {
  97 + return InvokeResultBuilder.success(JsonUtil.parseObject(o.toString(), ProcurementForeignTradeCredit.class));
  98 + }
  99 +
  100 + ProcurementForeignTradeCredit data = procurementForeignTradeCreditService.findById(id);
  101 + if (data == null) {
  102 + throw new DefaultClientException("客户资信表不存在!");
  103 + }
  104 + return InvokeResultBuilder.success(data);
  105 + }
56 } 106 }
@@ -198,6 +198,33 @@ public class ProcurementForeignTradeCredit extends BaseEntity implements BaseDto @@ -198,6 +198,33 @@ public class ProcurementForeignTradeCredit extends BaseEntity implements BaseDto
198 private String reviewDepartment; 198 private String reviewDepartment;
199 199
200 /** 200 /**
  201 + * 资信调查人ID
  202 + */
  203 + private String investigatorId;
  204 +
  205 + /**
  206 + * 资信调查人
  207 + */
  208 + private String investigatorName;
  209 +
  210 + /**
  211 + * 采购处
  212 + */
  213 + private String purchaseDepartment;
  214 +
  215 + /**
  216 + * 采购处名称(非持久化字段)
  217 + */
  218 + @TableField(exist = false)
  219 + private String purchaseDepartmentName;
  220 +
  221 + /**
  222 + * 采购处编码(非持久化字段)
  223 + */
  224 + @TableField(exist = false)
  225 + private String purchaseDepartmentCode;
  226 +
  227 + /**
201 * 审核状态 228 * 审核状态
202 */ 229 */
203 private String status; 230 private String status;
@@ -208,6 +235,18 @@ public class ProcurementForeignTradeCredit extends BaseEntity implements BaseDto @@ -208,6 +235,18 @@ public class ProcurementForeignTradeCredit extends BaseEntity implements BaseDto
208 private Boolean freeze; 235 private Boolean freeze;
209 236
210 /** 237 /**
  238 + * 是否展示审核按钮(非持久化字段)
  239 + */
  240 + @TableField(exist = false)
  241 + private Boolean showExamine = false;
  242 +
  243 + /**
  244 + * 是否展示审核详情按钮(非持久化字段)
  245 + */
  246 + @TableField(exist = false)
  247 + private Boolean showExamineDetail;
  248 +
  249 + /**
211 * 创建人ID 250 * 创建人ID
212 */ 251 */
213 @TableField(fill = FieldFill.INSERT) 252 @TableField(fill = FieldFill.INSERT)
1 package com.lframework.xingyun.sc.procurement.impl.credit; 1 package com.lframework.xingyun.sc.procurement.impl.credit;
2 2
  3 +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
  4 +import com.baomidou.mybatisplus.core.toolkit.Wrappers;
3 import com.github.pagehelper.PageInfo; 5 import com.github.pagehelper.PageInfo;
  6 +import com.lframework.starter.bpm.dto.FlowTaskDto;
  7 +import com.lframework.starter.bpm.entity.FlowInstanceWrapper;
  8 +import com.lframework.starter.bpm.mappers.FlowTaskWrapperMapper;
  9 +import com.lframework.starter.bpm.service.FlowInstanceWrapperService;
  10 +import com.lframework.starter.bpm.vo.flow.task.QueryTodoTaskListVo;
  11 +import com.lframework.starter.common.exceptions.impl.DefaultClientException;
4 import com.lframework.starter.common.utils.Assert; 12 import com.lframework.starter.common.utils.Assert;
  13 +import com.lframework.starter.common.utils.ObjectUtil;
  14 +import com.lframework.starter.web.core.components.redis.RedisHandler;
  15 +import com.lframework.starter.web.core.components.security.SecurityUtil;
5 import com.lframework.starter.web.core.annotations.oplog.OpLog; 16 import com.lframework.starter.web.core.annotations.oplog.OpLog;
6 import com.lframework.starter.web.core.components.resp.PageResult; 17 import com.lframework.starter.web.core.components.resp.PageResult;
7 import com.lframework.starter.web.core.impl.BaseMpServiceImpl; 18 import com.lframework.starter.web.core.impl.BaseMpServiceImpl;
8 import com.lframework.starter.web.core.utils.IdUtil; 19 import com.lframework.starter.web.core.utils.IdUtil;
  20 +import com.lframework.starter.web.core.utils.JsonUtil;
9 import com.lframework.starter.web.core.utils.OpLogUtil; 21 import com.lframework.starter.web.core.utils.OpLogUtil;
10 import com.lframework.starter.web.core.utils.PageHelperUtil; 22 import com.lframework.starter.web.core.utils.PageHelperUtil;
11 import com.lframework.starter.web.core.utils.PageResultUtil; 23 import com.lframework.starter.web.core.utils.PageResultUtil;
12 import com.lframework.starter.web.inner.components.oplog.OtherOpLogType; 24 import com.lframework.starter.web.inner.components.oplog.OtherOpLogType;
  25 +import com.lframework.starter.web.inner.entity.SysUser;
13 import com.lframework.starter.web.inner.service.system.SysUserService; 26 import com.lframework.starter.web.inner.service.system.SysUserService;
14 import com.lframework.xingyun.sc.procurement.entity.ProcurementForeignTradeCredit; 27 import com.lframework.xingyun.sc.procurement.entity.ProcurementForeignTradeCredit;
15 import com.lframework.xingyun.sc.procurement.mappers.credit.ProcurementForeignTradeCreditMapper; 28 import com.lframework.xingyun.sc.procurement.mappers.credit.ProcurementForeignTradeCreditMapper;
16 import com.lframework.xingyun.sc.procurement.service.credit.ProcurementForeignTradeCreditService; 29 import com.lframework.xingyun.sc.procurement.service.credit.ProcurementForeignTradeCreditService;
17 import com.lframework.xingyun.sc.procurement.vo.credit.CreateProcurementForeignTradeCreditVo; 30 import com.lframework.xingyun.sc.procurement.vo.credit.CreateProcurementForeignTradeCreditVo;
18 import com.lframework.xingyun.sc.procurement.vo.credit.QueryProcurementForeignTradeCreditVo; 31 import com.lframework.xingyun.sc.procurement.vo.credit.QueryProcurementForeignTradeCreditVo;
  32 +import com.lframework.xingyun.sc.procurement.vo.credit.UpdateProcurementForeignTradeCreditVo;
  33 +import org.apache.commons.lang3.StringUtils;
  34 +import org.springframework.beans.factory.annotation.Autowired;
19 import org.springframework.stereotype.Service; 35 import org.springframework.stereotype.Service;
20 import org.springframework.transaction.annotation.Transactional; 36 import org.springframework.transaction.annotation.Transactional;
21 37
22 import javax.annotation.Resource; 38 import javax.annotation.Resource;
  39 +import java.util.ArrayList;
23 import java.util.List; 40 import java.util.List;
  41 +import java.util.stream.Collectors;
24 42
25 @Service 43 @Service
26 public class ProcurementForeignTradeCreditServiceImpl 44 public class ProcurementForeignTradeCreditServiceImpl
27 extends BaseMpServiceImpl<ProcurementForeignTradeCreditMapper, ProcurementForeignTradeCredit> 45 extends BaseMpServiceImpl<ProcurementForeignTradeCreditMapper, ProcurementForeignTradeCredit>
28 implements ProcurementForeignTradeCreditService { 46 implements ProcurementForeignTradeCreditService {
  47 + private static final String BPM_FLAG = "CUSTOMER_CREDIT_OUT";
29 48
30 @Resource 49 @Resource
  50 + private FlowInstanceWrapperService flowInstanceWrapperService;
  51 + @Autowired
  52 + private RedisHandler redisHandler;
  53 + @Resource
  54 + private FlowTaskWrapperMapper flowTaskWrapperMapper;
  55 + @Resource
31 private SysUserService sysUserService; 56 private SysUserService sysUserService;
32 57
33 @Override 58 @Override
34 public PageResult<ProcurementForeignTradeCredit> query(Integer pageIndex, Integer pageSize, 59 public PageResult<ProcurementForeignTradeCredit> query(Integer pageIndex, Integer pageSize,
35 - QueryProcurementForeignTradeCreditVo vo) { 60 + QueryProcurementForeignTradeCreditVo vo) {
36 Assert.greaterThanZero(pageIndex); 61 Assert.greaterThanZero(pageIndex);
37 Assert.greaterThanZero(pageSize); 62 Assert.greaterThanZero(pageSize);
38 63
39 PageHelperUtil.startPage(pageIndex, pageSize); 64 PageHelperUtil.startPage(pageIndex, pageSize);
40 List<ProcurementForeignTradeCredit> datas = this.query(vo); 65 List<ProcurementForeignTradeCredit> datas = this.query(vo);
  66 + if (org.apache.commons.collections.CollectionUtils.isNotEmpty(datas)) {
  67 + List<FlowInstanceWrapper> flowByConditionList = flowInstanceWrapperService.getFlowByBusinessIdList(
  68 + datas.stream().map(ProcurementForeignTradeCredit::getId).collect(Collectors.toList()));
  69 + if (org.apache.commons.collections.CollectionUtils.isNotEmpty(flowByConditionList)) {
  70 + List<String> idList = flowByConditionList.stream().map(FlowInstanceWrapper::getBusinessId).collect(Collectors.toList());
  71 + for (ProcurementForeignTradeCredit customerCredit : datas) {
  72 + customerCredit.setShowExamineDetail(idList.contains(customerCredit.getId()));
  73 + }
  74 + } else {
  75 + for (ProcurementForeignTradeCredit customerCredit : datas) {
  76 + customerCredit.setShowExamineDetail(false);
  77 + }
  78 + }
  79 +
  80 + List<FlowTaskDto> flowTaskList = flowTaskWrapperMapper.queryTodoList(new QueryTodoTaskListVo(), SecurityUtil.getCurrentUser().getId());
  81 + if (org.apache.commons.collections.CollectionUtils.isNotEmpty(flowTaskList)) {
  82 + List<String> ids = flowTaskList.stream().map(FlowTaskDto::getBusinessId).collect(Collectors.toList());
  83 + for (ProcurementForeignTradeCredit customerCredit : datas) {
  84 + customerCredit.setShowExamine(ids.contains(customerCredit.getId()));
  85 + }
  86 + } else {
  87 + for (ProcurementForeignTradeCredit customerCredit : datas) {
  88 + customerCredit.setShowExamine(false);
  89 + }
  90 + }
  91 + }
41 return PageResultUtil.convert(new PageInfo<>(datas)); 92 return PageResultUtil.convert(new PageInfo<>(datas));
42 } 93 }
43 94
@@ -48,16 +99,106 @@ public class ProcurementForeignTradeCreditServiceImpl @@ -48,16 +99,106 @@ public class ProcurementForeignTradeCreditServiceImpl
48 99
49 @Override 100 @Override
50 public ProcurementForeignTradeCredit findById(String id) { 101 public ProcurementForeignTradeCredit findById(String id) {
51 - return getBaseMapper().findById(id); 102 + ProcurementForeignTradeCredit customerCredit = getBaseMapper().findById(id);
  103 + if (customerCredit == null) {
  104 + return null;
  105 + }
  106 +
  107 + List<String> ids = new ArrayList<>();
  108 + ids.add(customerCredit.getId());
  109 + List<FlowInstanceWrapper> flowByBusinessIdList = flowInstanceWrapperService.getFlowByBusinessIdList(ids);
  110 + if (org.apache.commons.collections.CollectionUtils.isNotEmpty(flowByBusinessIdList)) {
  111 + List<String> collect = flowByBusinessIdList.stream().map(FlowInstanceWrapper::getBusinessId).collect(Collectors.toList());
  112 + customerCredit.setShowExamineDetail(collect.contains(customerCredit.getId()));
  113 + } else {
  114 + customerCredit.setShowExamineDetail(false);
  115 + }
  116 +
  117 + List<FlowTaskDto> flowTaskList = flowTaskWrapperMapper.queryTodoList(new QueryTodoTaskListVo(), SecurityUtil.getCurrentUser().getId());
  118 + if (org.apache.commons.collections.CollectionUtils.isNotEmpty(flowTaskList)) {
  119 + List<String> businessIds = flowTaskList.stream().map(FlowTaskDto::getBusinessId).collect(Collectors.toList());
  120 + customerCredit.setShowExamine(businessIds.contains(customerCredit.getId()));
  121 + } else {
  122 + customerCredit.setShowExamine(false);
  123 + }
  124 + return customerCredit;
52 } 125 }
53 126
54 @OpLog(type = OtherOpLogType.class, name = "新增采购外贸资信调查表,ID:{}", params = {"#id"}) 127 @OpLog(type = OtherOpLogType.class, name = "新增采购外贸资信调查表,ID:{}", params = {"#id"})
55 @Transactional(rollbackFor = Exception.class) 128 @Transactional(rollbackFor = Exception.class)
56 @Override 129 @Override
57 public String create(CreateProcurementForeignTradeCreditVo vo) { 130 public String create(CreateProcurementForeignTradeCreditVo vo) {
  131 + SysUser investigator = getInvestigator(vo.getInvestigatorId());
58 132
59 ProcurementForeignTradeCredit data = new ProcurementForeignTradeCredit(); 133 ProcurementForeignTradeCredit data = new ProcurementForeignTradeCredit();
60 data.setId(IdUtil.getId()); 134 data.setId(IdUtil.getId());
  135 + fillData(data, vo, investigator);
  136 + data.setStatus("AUDIT");
  137 + data.setFreeze(Boolean.FALSE);
  138 +
  139 + getBaseMapper().insert(data);
  140 + ProcurementForeignTradeCredit customerCredit = getBaseMapper().findById(data.getId());
  141 + flowInstanceWrapperService.startInstance(BPM_FLAG, data.getId(), BPM_FLAG, customerCredit);
  142 +
  143 + OpLogUtil.setVariable("id", data.getId());
  144 + OpLogUtil.setExtra(vo);
  145 + return data.getId();
  146 + }
  147 +
  148 + @OpLog(type = OtherOpLogType.class, name = "修改采购外贸资信调查表,ID:{}", params = {"#vo.id"})
  149 + @Transactional(rollbackFor = Exception.class)
  150 + @Override
  151 + public void update(UpdateProcurementForeignTradeCreditVo vo) {
  152 + if (ObjectUtil.isNull(vo.getId())) {
  153 + throw new DefaultClientException("资信ID不能为空!");
  154 + }
  155 +
  156 + ProcurementForeignTradeCredit data = this.findById(vo.getId());
  157 + if (ObjectUtil.isNull(data)) {
  158 + throw new DefaultClientException("采购外贸资信调查表不存在!");
  159 + }
  160 +
  161 + SysUser investigator = getInvestigator(vo.getInvestigatorId());
  162 + fillData(data, vo, investigator);
  163 + data.setStatus("AUDIT");
  164 +
  165 + if ("CHANGE".equals(vo.getType())) {
  166 + redisHandler.set(data.getId(), JsonUtil.toJsonString(data));
  167 + } else {
  168 + getBaseMapper().updateById(data);
  169 + }
  170 +
  171 + flowInstanceWrapperService.startInstance(BPM_FLAG, data.getId(), BPM_FLAG, data);
  172 + OpLogUtil.setExtra(vo);
  173 + }
  174 +
  175 + @Override
  176 + public void updateStatus(String id, String status) {
  177 + if (StringUtils.isBlank(id) || StringUtils.isBlank(status)) {
  178 + throw new DefaultClientException("资信ID、审核状态不能为空!");
  179 + }
  180 + LambdaUpdateWrapper<ProcurementForeignTradeCredit> updateWrapper = Wrappers.lambdaUpdate(ProcurementForeignTradeCredit.class)
  181 + .set(ProcurementForeignTradeCredit::getStatus, status)
  182 + .eq(ProcurementForeignTradeCredit::getId, id);
  183 + getBaseMapper().update(updateWrapper);
  184 + }
  185 +
  186 + @Override
  187 + public void updateNoFlowInstance(ProcurementForeignTradeCredit customerCredit) {
  188 + if (ObjectUtil.isNull(customerCredit.getId())) {
  189 + throw new DefaultClientException("资信ID不能为空!");
  190 + }
  191 +
  192 + ProcurementForeignTradeCredit data = this.findById(customerCredit.getId());
  193 + if (ObjectUtil.isNull(data)) {
  194 + throw new DefaultClientException("采购外贸资信调查表不存在!");
  195 + }
  196 +
  197 + getBaseMapper().updateById(customerCredit);
  198 + OpLogUtil.setExtra(data);
  199 + }
  200 +
  201 + private void fillData(ProcurementForeignTradeCredit data, CreateProcurementForeignTradeCreditVo vo, SysUser investigator) {
61 data.setUnitName(vo.getUnitName()); 202 data.setUnitName(vo.getUnitName());
62 data.setCompanyNature(vo.getCompanyNature()); 203 data.setCompanyNature(vo.getCompanyNature());
63 data.setLegalRepresentative(vo.getLegalRepresentative()); 204 data.setLegalRepresentative(vo.getLegalRepresentative());
@@ -93,13 +234,64 @@ public class ProcurementForeignTradeCreditServiceImpl @@ -93,13 +234,64 @@ public class ProcurementForeignTradeCreditServiceImpl
93 data.setPaymentMethod(vo.getPaymentMethod()); 234 data.setPaymentMethod(vo.getPaymentMethod());
94 data.setNextReviewTime(vo.getNextReviewTime()); 235 data.setNextReviewTime(vo.getNextReviewTime());
95 data.setReviewDepartment(vo.getReviewDepartment()); 236 data.setReviewDepartment(vo.getReviewDepartment());
96 -// data.setStatus("AUDIT");  
97 - data.setFreeze(Boolean.FALSE); 237 + data.setInvestigatorId(vo.getInvestigatorId());
  238 + data.setInvestigatorName(investigator.getName());
  239 + data.setPurchaseDepartment(vo.getPurchaseDepartment());
  240 + }
98 241
99 - getBaseMapper().insert(data); 242 + private void fillData(ProcurementForeignTradeCredit data, UpdateProcurementForeignTradeCreditVo vo, SysUser investigator) {
  243 + data.setId(vo.getId());
  244 + data.setUnitName(vo.getUnitName());
  245 + data.setCompanyNature(vo.getCompanyNature());
  246 + data.setLegalRepresentative(vo.getLegalRepresentative());
  247 + data.setPhoneAndFax(vo.getPhoneAndFax());
  248 + data.setRegistrationCertificateNo(vo.getRegistrationCertificateNo());
  249 + data.setAddress(vo.getAddress());
  250 + data.setDomesticBusinessPrincipal(vo.getDomesticBusinessPrincipal());
  251 + data.setPrincipalCertificateNo(vo.getPrincipalCertificateNo());
  252 + data.setEstablishedTimeAndYardScale(vo.getEstablishedTimeAndYardScale());
  253 + data.setOverallBusinessVarietiesScale(vo.getOverallBusinessVarietiesScale());
  254 + data.setExportToDomesticTime(vo.getExportToDomesticTime());
  255 + data.setExportToDomesticScaleVarieties(vo.getExportToDomesticScaleVarieties());
  256 + data.setCooperatingDomesticCompanies(vo.getCooperatingDomesticCompanies());
  257 + data.setCooperationEffect(vo.getCooperationEffect());
  258 + data.setSupplierInspection(vo.getSupplierInspection());
  259 + data.setDomesticSalesOfficeInspection(vo.getDomesticSalesOfficeInspection());
  260 + data.setGuaranteeLetter(vo.getGuaranteeLetter());
  261 + data.setContractDispute(vo.getContractDispute());
  262 + data.setInsuranceTransportMode(vo.getInsuranceTransportMode());
  263 + data.setDetentionDemurrageFee(vo.getDetentionDemurrageFee());
  264 + data.setOperationVariety(vo.getOperationVariety());
  265 + data.setOperationScale(vo.getOperationScale());
  266 + data.setPricingMode(vo.getPricingMode());
  267 + data.setSettlementMethod(vo.getSettlementMethod());
  268 + data.setWeightDifferenceAgreement(vo.getWeightDifferenceAgreement());
  269 + data.setQualityStandard(vo.getQualityStandard());
  270 + data.setSupplierCategory(vo.getSupplierCategory());
  271 + data.setSchemeOperationTime(vo.getSchemeOperationTime());
  272 + data.setSchemeOperationMode(vo.getSchemeOperationMode());
  273 + data.setSchemeOperationVariety(vo.getSchemeOperationVariety());
  274 + data.setSchemeOperationQuantity(vo.getSchemeOperationQuantity());
  275 + data.setShippingRequirement(vo.getShippingRequirement());
  276 + data.setPaymentMethod(vo.getPaymentMethod());
  277 + data.setNextReviewTime(vo.getNextReviewTime());
  278 + data.setReviewDepartment(vo.getReviewDepartment());
  279 + data.setInvestigatorId(vo.getInvestigatorId());
  280 + data.setInvestigatorName(investigator.getName());
  281 + data.setPurchaseDepartment(vo.getPurchaseDepartment());
  282 + }
100 283
101 - OpLogUtil.setVariable("id", data.getId());  
102 - OpLogUtil.setExtra(vo);  
103 - return data.getId(); 284 + /**
  285 + * 获取资信调查人。
  286 + *
  287 + * @param investigatorId 资信调查人ID
  288 + * @return 系统用户
  289 + */
  290 + private SysUser getInvestigator(String investigatorId) {
  291 + SysUser investigator = sysUserService.findById(investigatorId);
  292 + if (investigator == null) {
  293 + throw new DefaultClientException("资信调查人不存在!");
  294 + }
  295 + return investigator;
104 } 296 }
105 } 297 }
@@ -5,6 +5,7 @@ import com.lframework.starter.web.core.service.BaseMpService; @@ -5,6 +5,7 @@ import com.lframework.starter.web.core.service.BaseMpService;
5 import com.lframework.xingyun.sc.procurement.entity.ProcurementForeignTradeCredit; 5 import com.lframework.xingyun.sc.procurement.entity.ProcurementForeignTradeCredit;
6 import com.lframework.xingyun.sc.procurement.vo.credit.CreateProcurementForeignTradeCreditVo; 6 import com.lframework.xingyun.sc.procurement.vo.credit.CreateProcurementForeignTradeCreditVo;
7 import com.lframework.xingyun.sc.procurement.vo.credit.QueryProcurementForeignTradeCreditVo; 7 import com.lframework.xingyun.sc.procurement.vo.credit.QueryProcurementForeignTradeCreditVo;
  8 +import com.lframework.xingyun.sc.procurement.vo.credit.UpdateProcurementForeignTradeCreditVo;
8 9
9 import java.util.List; 10 import java.util.List;
10 11
@@ -44,4 +45,26 @@ public interface ProcurementForeignTradeCreditService extends BaseMpService<Proc @@ -44,4 +45,26 @@ public interface ProcurementForeignTradeCreditService extends BaseMpService<Proc
44 * @return ID 45 * @return ID
45 */ 46 */
46 String create(CreateProcurementForeignTradeCreditVo vo); 47 String create(CreateProcurementForeignTradeCreditVo vo);
  48 +
  49 + /**
  50 + * 修改
  51 + *
  52 + * @param vo 修改参数
  53 + */
  54 + void update(UpdateProcurementForeignTradeCreditVo vo);
  55 +
  56 + /**
  57 + * 更新审核状态
  58 + *
  59 + * @param id ID
  60 + * @param status 状态
  61 + */
  62 + void updateStatus(String id, String status);
  63 +
  64 + /**
  65 + * 修改(不走审核)
  66 + *
  67 + * @param customerCredit 客户资信
  68 + */
  69 + void updateNoFlowInstance(ProcurementForeignTradeCredit customerCredit);
47 } 70 }
@@ -187,4 +187,20 @@ public class CreateProcurementForeignTradeCreditVo implements BaseVo, Serializab @@ -187,4 +187,20 @@ public class CreateProcurementForeignTradeCreditVo implements BaseVo, Serializab
187 @NotBlank(message = "评审部门不能为空!") 187 @NotBlank(message = "评审部门不能为空!")
188 @Length(max = 200, message = "评审部门最多允许200个字符!") 188 @Length(max = 200, message = "评审部门最多允许200个字符!")
189 private String reviewDepartment; 189 private String reviewDepartment;
  190 +
  191 + /**
  192 + * 资信调查人ID
  193 + */
  194 + @ApiModelProperty(value = "资信调查人ID", required = true)
  195 + @NotBlank(message = "资信调查人ID不能为空!")
  196 + @Length(max = 200, message = "资信调查人ID内容过长!")
  197 + private String investigatorId;
  198 +
  199 + /**
  200 + * 采购处
  201 + */
  202 + @ApiModelProperty(value = "采购处", required = true)
  203 + @NotBlank(message = "采购处不能为空!")
  204 + @Length(max = 200, message = "采购处最多允许200个字符!")
  205 + private String purchaseDepartment;
190 } 206 }
@@ -21,6 +21,15 @@ public class QueryProcurementForeignTradeCreditVo extends PageVo implements Base @@ -21,6 +21,15 @@ public class QueryProcurementForeignTradeCreditVo extends PageVo implements Base
21 @ApiModelProperty("供应商分类") 21 @ApiModelProperty("供应商分类")
22 private String supplierCategory; 22 private String supplierCategory;
23 23
  24 + @ApiModelProperty("资信调查人ID")
  25 + private String investigatorId;
  26 +
  27 + @ApiModelProperty("资信调查人")
  28 + private String investigatorName;
  29 +
  30 + @ApiModelProperty("采购处")
  31 + private String purchaseDepartment;
  32 +
24 @ApiModelProperty("下次评审时间开始") 33 @ApiModelProperty("下次评审时间开始")
25 private LocalDate nextReviewTimeStart; 34 private LocalDate nextReviewTimeStart;
26 35
@@ -40,6 +40,11 @@ @@ -40,6 +40,11 @@
40 <result column="payment_method" property="paymentMethod"/> 40 <result column="payment_method" property="paymentMethod"/>
41 <result column="next_review_time" property="nextReviewTime"/> 41 <result column="next_review_time" property="nextReviewTime"/>
42 <result column="review_department" property="reviewDepartment"/> 42 <result column="review_department" property="reviewDepartment"/>
  43 + <result column="investigator_id" property="investigatorId"/>
  44 + <result column="investigator_name" property="investigatorName"/>
  45 + <result column="purchase_department" property="purchaseDepartment"/>
  46 + <result column="purchase_department_name" property="purchaseDepartmentName"/>
  47 + <result column="purchase_department_code" property="purchaseDepartmentCode"/>
43 <result column="status" property="status"/> 48 <result column="status" property="status"/>
44 <result column="freeze" property="freeze"/> 49 <result column="freeze" property="freeze"/>
45 <result column="create_by_id" property="createById"/> 50 <result column="create_by_id" property="createById"/>
@@ -88,6 +93,11 @@ @@ -88,6 +93,11 @@
88 tb.payment_method, 93 tb.payment_method,
89 tb.next_review_time, 94 tb.next_review_time,
90 tb.review_department, 95 tb.review_department,
  96 + tb.investigator_id,
  97 + tb.investigator_name,
  98 + tb.purchase_department,
  99 + sd.name AS purchase_department_name,
  100 + sd.code AS purchase_department_code,
91 tb.status, 101 tb.status,
92 tb.freeze, 102 tb.freeze,
93 tb.create_by_id, 103 tb.create_by_id,
@@ -97,6 +107,7 @@ @@ -97,6 +107,7 @@
97 tb.create_time, 107 tb.create_time,
98 tb.update_time 108 tb.update_time
99 FROM procurement_foreign_trade_credit tb 109 FROM procurement_foreign_trade_credit tb
  110 + LEFT JOIN sys_dept AS sd ON sd.id = tb.purchase_department
100 </sql> 111 </sql>
101 112
102 <select id="query" resultMap="ProcurementForeignTradeCredit"> 113 <select id="query" resultMap="ProcurementForeignTradeCredit">
@@ -109,7 +120,16 @@ @@ -109,7 +120,16 @@
109 AND tb.company_nature LIKE CONCAT('%', #{vo.companyNature}, '%') 120 AND tb.company_nature LIKE CONCAT('%', #{vo.companyNature}, '%')
110 </if> 121 </if>
111 <if test="vo.supplierCategory != null and vo.supplierCategory != ''"> 122 <if test="vo.supplierCategory != null and vo.supplierCategory != ''">
112 - AND tb.supplier_category = #{supplierCategory} 123 + AND tb.supplier_category = #{vo.supplierCategory}
  124 + </if>
  125 + <if test="vo.investigatorId != null and vo.investigatorId != ''">
  126 + AND tb.investigator_id = #{vo.investigatorId}
  127 + </if>
  128 + <if test="vo.investigatorName != null and vo.investigatorName != ''">
  129 + AND tb.investigator_name LIKE CONCAT('%', #{vo.investigatorName}, '%')
  130 + </if>
  131 + <if test="vo.purchaseDepartment != null and vo.purchaseDepartment != ''">
  132 + AND tb.purchase_department = #{vo.purchaseDepartment}
113 </if> 133 </if>
114 <if test="vo.status != null and vo.status != ''"> 134 <if test="vo.status != null and vo.status != ''">
115 AND tb.status = #{vo.status} 135 AND tb.status = #{vo.status}