Commit 055f2fb95921b71ad19be1a1309edde5b8b19079

Authored by 房远帅
1 parent 177fc2e8

楚江ERP:订货单-审核完善

@@ -12,6 +12,7 @@ import com.lframework.xingyun.sc.service.customer.CorePersonnelHistoryService; @@ -12,6 +12,7 @@ import com.lframework.xingyun.sc.service.customer.CorePersonnelHistoryService;
12 import com.lframework.xingyun.sc.service.customer.CustomerCreditHistoryService; 12 import com.lframework.xingyun.sc.service.customer.CustomerCreditHistoryService;
13 import com.lframework.xingyun.sc.service.customer.CustomerCreditService; 13 import com.lframework.xingyun.sc.service.customer.CustomerCreditService;
14 import com.lframework.xingyun.sc.service.customer.CustomerDevelopPlanService; 14 import com.lframework.xingyun.sc.service.customer.CustomerDevelopPlanService;
  15 +import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService;
15 import com.lframework.xingyun.sc.vo.customer.credit.QueryCorePersonnelHistoryVo; 16 import com.lframework.xingyun.sc.vo.customer.credit.QueryCorePersonnelHistoryVo;
16 import com.lframework.xingyun.sc.vo.customer.credit.UpdateCustomerCreditVo; 17 import com.lframework.xingyun.sc.vo.customer.credit.UpdateCustomerCreditVo;
17 import lombok.extern.slf4j.Slf4j; 18 import lombok.extern.slf4j.Slf4j;
@@ -45,6 +46,8 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic @@ -45,6 +46,8 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
45 private RedisHandler redisHandler; 46 private RedisHandler redisHandler;
46 @Resource 47 @Resource
47 private ContractDistributorStandardService contractDistributorStandardService; 48 private ContractDistributorStandardService contractDistributorStandardService;
  49 + @Resource
  50 + private PurchaseOrderInfoService purchaseOrderInfoService;
48 51
49 52
50 /** 53 /**
@@ -87,6 +90,9 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic @@ -87,6 +90,9 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
87 case "STANDARD_CONTRACT": 90 case "STANDARD_CONTRACT":
88 handleStandardContractAuditData(flowStatus, businessId); 91 handleStandardContractAuditData(flowStatus, businessId);
89 break; 92 break;
  93 + case "PURCHASE_ORDER":
  94 + handlePurchaseOrderData(flowStatus, businessId);
  95 + break;
90 default: 96 default:
91 break; 97 break;
92 } 98 }
@@ -136,6 +142,22 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic @@ -136,6 +142,22 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
136 } 142 }
137 143
138 /** 144 /**
  145 + * 订货单业务数据处理
  146 + *
  147 + * @param businessId 业务ID
  148 + */
  149 + private void handlePurchaseOrderData(String flowStatus, String businessId) {
  150 + if (FlowInstanceStatus.APPROVE_PASS.getCode().equals(flowStatus)
  151 + || FlowInstanceStatus.FINISH.getCode().equals(flowStatus)) {
  152 + purchaseOrderInfoService.updateStatus(businessId, "PASS");
  153 + } else if (FlowInstanceStatus.REVOKE.getCode().equals(flowStatus)
  154 + || FlowInstanceStatus.REFUSE.getCode().equals(flowStatus)
  155 + || FlowInstanceStatus.TERMINATION.getCode().equals(flowStatus)) {
  156 + purchaseOrderInfoService.updateStatus(businessId, "REFUSE");
  157 + }
  158 + }
  159 +
  160 + /**
139 * 客户资信业务数据处理 161 * 客户资信业务数据处理
140 * 162 *
141 * @param businessId 业务ID 163 * @param businessId 业务ID
@@ -7,7 +7,9 @@ import com.lframework.starter.web.core.annotations.oplog.OpLog; @@ -7,7 +7,9 @@ import com.lframework.starter.web.core.annotations.oplog.OpLog;
7 import com.lframework.starter.web.core.utils.JsonUtil; 7 import com.lframework.starter.web.core.utils.JsonUtil;
8 import com.lframework.starter.web.inner.components.oplog.OtherOpLogType; 8 import com.lframework.starter.web.inner.components.oplog.OtherOpLogType;
9 import com.lframework.xingyun.sc.service.customer.CustomerCreditService; 9 import com.lframework.xingyun.sc.service.customer.CustomerCreditService;
  10 +import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService;
10 import com.lframework.xingyun.sc.vo.customer.credit.*; 11 import com.lframework.xingyun.sc.vo.customer.credit.*;
  12 +import com.lframework.xingyun.sc.vo.order.UpdatePurchaseOrderInfoVo;
11 import org.springframework.stereotype.Service; 13 import org.springframework.stereotype.Service;
12 import org.springframework.transaction.annotation.Transactional; 14 import org.springframework.transaction.annotation.Transactional;
13 15
@@ -19,6 +21,8 @@ public class FlowTaskServiceImpl implements FlowTaskService { @@ -19,6 +21,8 @@ public class FlowTaskServiceImpl implements FlowTaskService {
19 21
20 @Resource 22 @Resource
21 private CustomerCreditService customerCreditService; 23 private CustomerCreditService customerCreditService;
  24 + @Resource
  25 + private PurchaseOrderInfoService purchaseOrderInfoService;
22 26
23 27
24 @OpLog(type = OtherOpLogType.class, name = "修改客户资信,ID:{}", params = {"#id"}) 28 @OpLog(type = OtherOpLogType.class, name = "修改客户资信,ID:{}", params = {"#id"})
@@ -39,4 +43,20 @@ public class FlowTaskServiceImpl implements FlowTaskService { @@ -39,4 +43,20 @@ public class FlowTaskServiceImpl implements FlowTaskService {
39 e.printStackTrace(); 43 e.printStackTrace();
40 } 44 }
41 } 45 }
  46 +
  47 + @OpLog(type = OtherOpLogType.class, name = "修改订货单,ID:{}", params = {"#id"})
  48 + @Transactional(rollbackFor = Exception.class)
  49 + @Override
  50 + public void updatePurchaseOrderByMap(Map<String, Object> map) {
  51 + try {
  52 + // 创建 ObjectMapper 实例
  53 + ObjectMapper objectMapper = new ObjectMapper();
  54 + //先将 Map 序列化为 JSON 字符串,再反序列化为目标对象
  55 + String json = objectMapper.writeValueAsString(map);
  56 + UpdatePurchaseOrderInfoVo updatePurchaseOrderInfoVo = JsonUtil.parseObject(json, UpdatePurchaseOrderInfoVo.class);
  57 + purchaseOrderInfoService.updateNoFlowInstance(updatePurchaseOrderInfoVo);
  58 + } catch (JsonProcessingException e) {
  59 + e.printStackTrace();
  60 + }
  61 + }
42 } 62 }
@@ -3,6 +3,7 @@ package com.lframework.xingyun.sc.impl.order; @@ -3,6 +3,7 @@ package com.lframework.xingyun.sc.impl.order;
3 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; 3 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
4 import com.baomidou.mybatisplus.core.toolkit.Wrappers; 4 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
5 import com.github.pagehelper.PageInfo; 5 import com.github.pagehelper.PageInfo;
  6 +import com.lframework.starter.bpm.service.FlowInstanceWrapperService;
6 import com.lframework.starter.web.core.impl.BaseMpServiceImpl; 7 import com.lframework.starter.web.core.impl.BaseMpServiceImpl;
7 import com.lframework.starter.web.core.utils.PageResultUtil; 8 import com.lframework.starter.web.core.utils.PageResultUtil;
8 import com.lframework.starter.web.core.components.resp.PageResult; 9 import com.lframework.starter.web.core.components.resp.PageResult;
@@ -25,20 +26,23 @@ import com.lframework.xingyun.sc.service.order.PurchaseOrderLineService; @@ -25,20 +26,23 @@ import com.lframework.xingyun.sc.service.order.PurchaseOrderLineService;
25 import com.lframework.xingyun.sc.vo.customer.credit.QueryCustomerCreditVo; 26 import com.lframework.xingyun.sc.vo.customer.credit.QueryCustomerCreditVo;
26 import com.lframework.xingyun.sc.vo.order.*; 27 import com.lframework.xingyun.sc.vo.order.*;
27 import org.apache.commons.collections.CollectionUtils; 28 import org.apache.commons.collections.CollectionUtils;
  29 +import org.apache.commons.lang3.StringUtils;
28 import org.springframework.transaction.annotation.Transactional; 30 import org.springframework.transaction.annotation.Transactional;
29 import org.springframework.stereotype.Service; 31 import org.springframework.stereotype.Service;
30 32
31 import javax.annotation.Resource; 33 import javax.annotation.Resource;
32 -import java.util.Collection;  
33 import java.util.List; 34 import java.util.List;
34 35
35 @Service 36 @Service
36 public class PurchaseOrderInfoServiceImpl extends BaseMpServiceImpl<PurchaseOrderInfoMapper, PurchaseOrderInfo> implements PurchaseOrderInfoService { 37 public class PurchaseOrderInfoServiceImpl extends BaseMpServiceImpl<PurchaseOrderInfoMapper, PurchaseOrderInfo> implements PurchaseOrderInfoService {
  38 + private static final String BPM_FLAG = "PURCHASE_ORDER";
37 39
38 @Resource 40 @Resource
39 private PurchaseOrderLineService purchaseOrderLineService; 41 private PurchaseOrderLineService purchaseOrderLineService;
40 @Resource 42 @Resource
41 private CustomerCreditService customerCreditService; 43 private CustomerCreditService customerCreditService;
  44 + @Resource
  45 + private FlowInstanceWrapperService flowInstanceWrapperService;
42 46
43 @Override 47 @Override
44 public PageResult<PurchaseOrderInfo> query(Integer pageIndex, Integer pageSize, QueryPurchaseOrderInfoVo vo) { 48 public PageResult<PurchaseOrderInfo> query(Integer pageIndex, Integer pageSize, QueryPurchaseOrderInfoVo vo) {
@@ -160,6 +164,8 @@ public class PurchaseOrderInfoServiceImpl extends BaseMpServiceImpl<PurchaseOrde @@ -160,6 +164,8 @@ public class PurchaseOrderInfoServiceImpl extends BaseMpServiceImpl<PurchaseOrde
160 purchaseOrderLineService.create(createPurchaseOrderLineVo); 164 purchaseOrderLineService.create(createPurchaseOrderLineVo);
161 } 165 }
162 } 166 }
  167 + //开启审核
  168 + flowInstanceWrapperService.startInstance(BPM_FLAG, data.getId(), BPM_FLAG, data);
163 169
164 return data.getId(); 170 return data.getId();
165 } 171 }
@@ -193,7 +199,7 @@ public class PurchaseOrderInfoServiceImpl extends BaseMpServiceImpl<PurchaseOrde @@ -193,7 +199,7 @@ public class PurchaseOrderInfoServiceImpl extends BaseMpServiceImpl<PurchaseOrde
193 .set(PurchaseOrderInfo::getPackaging, StringUtil.isBlank(vo.getPackaging()) ? null : vo.getPackaging()) 199 .set(PurchaseOrderInfo::getPackaging, StringUtil.isBlank(vo.getPackaging()) ? null : vo.getPackaging())
194 .set(PurchaseOrderInfo::getRemarks, StringUtil.isBlank(vo.getRemarks()) ? null : vo.getRemarks()) 200 .set(PurchaseOrderInfo::getRemarks, StringUtil.isBlank(vo.getRemarks()) ? null : vo.getRemarks())
195 .set(PurchaseOrderInfo::getStatus, StringUtil.isBlank(vo.getStatus()) ? null : vo.getStatus()) 201 .set(PurchaseOrderInfo::getStatus, StringUtil.isBlank(vo.getStatus()) ? null : vo.getStatus())
196 - .set(PurchaseOrderInfo::getExamineStatus, StringUtil.isBlank(vo.getExamineStatus()) ? null : vo.getExamineStatus()) 202 + .set(PurchaseOrderInfo::getExamineStatus, "AUDIT")//审核中
197 .set(PurchaseOrderInfo::getProductionProcess, StringUtil.isBlank(vo.getProductionProcess()) ? null : vo.getProductionProcess()) 203 .set(PurchaseOrderInfo::getProductionProcess, StringUtil.isBlank(vo.getProductionProcess()) ? null : vo.getProductionProcess())
198 .set(PurchaseOrderInfo::getDeptId, StringUtil.isBlank(vo.getDeptId()) ? null : vo.getDeptId()) 204 .set(PurchaseOrderInfo::getDeptId, StringUtil.isBlank(vo.getDeptId()) ? null : vo.getDeptId())
199 .set(PurchaseOrderInfo::getWorkshopId, StringUtil.isBlank(vo.getWorkshopId()) ? null : vo.getWorkshopId()) 205 .set(PurchaseOrderInfo::getWorkshopId, StringUtil.isBlank(vo.getWorkshopId()) ? null : vo.getWorkshopId())
@@ -212,6 +218,8 @@ public class PurchaseOrderInfoServiceImpl extends BaseMpServiceImpl<PurchaseOrde @@ -212,6 +218,8 @@ public class PurchaseOrderInfoServiceImpl extends BaseMpServiceImpl<PurchaseOrde
212 218
213 OpLogUtil.setVariable("id", data.getId()); 219 OpLogUtil.setVariable("id", data.getId());
214 OpLogUtil.setExtra(vo); 220 OpLogUtil.setExtra(vo);
  221 + //开启审核
  222 + flowInstanceWrapperService.startInstance(BPM_FLAG, data.getId(), BPM_FLAG, data);
215 } 223 }
216 224
217 @OpLog(type = OtherOpLogType.class, name = "删除订货单表,ID:{}", params = {"#id"}) 225 @OpLog(type = OtherOpLogType.class, name = "删除订货单表,ID:{}", params = {"#id"})
@@ -222,6 +230,66 @@ public class PurchaseOrderInfoServiceImpl extends BaseMpServiceImpl<PurchaseOrde @@ -222,6 +230,66 @@ public class PurchaseOrderInfoServiceImpl extends BaseMpServiceImpl<PurchaseOrde
222 getBaseMapper().deleteById(id); 230 getBaseMapper().deleteById(id);
223 } 231 }
224 232
  233 + @OpLog(type = OtherOpLogType.class, name = "更新不走审核,ID:{}", params = {"#id"})
  234 + @Transactional(rollbackFor = Exception.class)
  235 + @Override
  236 + public void updateNoFlowInstance(UpdatePurchaseOrderInfoVo vo) {
  237 + PurchaseOrderInfo data = getBaseMapper().selectById(vo.getId());
  238 + if (ObjectUtil.isNull(data)) {
  239 + throw new DefaultClientException("订货单表不存在!");
  240 + }
  241 +
  242 + LambdaUpdateWrapper<PurchaseOrderInfo> updateWrapper = Wrappers.lambdaUpdate(PurchaseOrderInfo.class)
  243 + .set(PurchaseOrderInfo::getPriceListNo, StringUtil.isBlank(vo.getPriceListNo()) ? null : vo.getPriceListNo())
  244 + .set(PurchaseOrderInfo::getExecutionStandard, StringUtil.isBlank(vo.getExecutionStandard()) ? null : vo.getExecutionStandard())
  245 + .set(PurchaseOrderInfo::getInvoicingStatus, StringUtil.isBlank(vo.getInvoicingStatus()) ? null : vo.getInvoicingStatus())
  246 + .set(PurchaseOrderInfo::getShippingCost, StringUtil.isBlank(vo.getShippingCost()) ? null : vo.getShippingCost())
  247 + .set(PurchaseOrderInfo::getPieceWeightHeader, StringUtil.isBlank(vo.getPieceWeightHeader()) ? null : vo.getPieceWeightHeader())
  248 + .set(PurchaseOrderInfo::getSurface, StringUtil.isBlank(vo.getSurface()) ? null : vo.getSurface())
  249 + .set(PurchaseOrderInfo::getTolerance, StringUtil.isBlank(vo.getTolerance()) ? null : vo.getTolerance())
  250 + .set(PurchaseOrderInfo::getPerformance, StringUtil.isBlank(vo.getPerformance()) ? null : vo.getPerformance())
  251 + .set(PurchaseOrderInfo::getElement, StringUtil.isBlank(vo.getElement()) ? null : vo.getElement())
  252 + .set(PurchaseOrderInfo::getPackaging, StringUtil.isBlank(vo.getPackaging()) ? null : vo.getPackaging())
  253 + .set(PurchaseOrderInfo::getRemarks, StringUtil.isBlank(vo.getRemarks()) ? null : vo.getRemarks())
  254 + .set(PurchaseOrderInfo::getProductionProcess, StringUtil.isBlank(vo.getProductionProcess()) ? null : vo.getProductionProcess())
  255 + .eq(PurchaseOrderInfo::getId, vo.getId());
  256 +
  257 + getBaseMapper().update(updateWrapper);
  258 +
  259 + //更新订货单表物料行
  260 + List<UpdatePurchaseOrderLineVo> updatePurchaseOrderLineVoList = vo.getUpdatePurchaseOrderLineVoList();
  261 + if (CollectionUtils.isNotEmpty(updatePurchaseOrderLineVoList)) {
  262 + for (UpdatePurchaseOrderLineVo updatePurchaseOrderLineVo : updatePurchaseOrderLineVoList) {
  263 + purchaseOrderLineService.update(updatePurchaseOrderLineVo);
  264 + }
  265 + }
  266 +
  267 + OpLogUtil.setVariable("id", data.getId());
  268 + OpLogUtil.setExtra(vo);
  269 +
  270 + }
  271 +
  272 + @OpLog(type = OtherOpLogType.class, name = "更新审核状态,ID:{}", params = {"#id"})
  273 + @Transactional(rollbackFor = Exception.class)
  274 + @Override
  275 + public void updateStatus(String id, String status) {
  276 + if (StringUtils.isBlank(id) || StringUtils.isBlank(status)) {
  277 + return;
  278 + }
  279 + if ("PASS".equals(status)) {
  280 + LambdaUpdateWrapper<PurchaseOrderInfo> updateWrapper = Wrappers.lambdaUpdate(PurchaseOrderInfo.class)
  281 + .set(PurchaseOrderInfo::getExamineStatus, status)
  282 + .set(PurchaseOrderInfo::getStatus, "ISSUED")//已下发
  283 + .eq(PurchaseOrderInfo::getId, id);
  284 + getBaseMapper().update(updateWrapper);
  285 + } else {
  286 + LambdaUpdateWrapper<PurchaseOrderInfo> updateWrapper = Wrappers.lambdaUpdate(PurchaseOrderInfo.class)
  287 + .set(PurchaseOrderInfo::getExamineStatus, status)
  288 + .eq(PurchaseOrderInfo::getId, id);
  289 + getBaseMapper().update(updateWrapper);
  290 + }
  291 + }
  292 +
225 @Override 293 @Override
226 public void cleanCacheByKey(Serializable key) { 294 public void cleanCacheByKey(Serializable key) {
227 295
@@ -52,4 +52,19 @@ public interface PurchaseOrderInfoService extends BaseMpService<PurchaseOrderInf @@ -52,4 +52,19 @@ public interface PurchaseOrderInfoService extends BaseMpService<PurchaseOrderInf
52 * @return 52 * @return
53 */ 53 */
54 void deleteById(String id); 54 void deleteById(String id);
  55 +
  56 + /**
  57 + * 根据主键ID更新状态
  58 + *
  59 + * @param id 主键ID
  60 + * @param status 审核状态
  61 + */
  62 + void updateStatus(String id, String status);
  63 +
  64 + /**
  65 + * 更新不走审核
  66 + *
  67 + * @param vo 更新数据
  68 + */
  69 + void updateNoFlowInstance(UpdatePurchaseOrderInfoVo vo);
55 } 70 }