|
@@ -1,15 +1,24 @@
|
|
|
package com.abi.qms.platform.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.map.MapUtil;
|
|
|
+import com.abi.qms.platform.dao.enums.FlowQueryTypeEnum;
|
|
|
+import com.abi.qms.platform.dao.enums.FlowStatusEnum;
|
|
|
+import com.abi.qms.platform.dao.enums.ReqChannelTypeEnum;
|
|
|
+import com.abi.qms.platform.dto.req.AddFlowQueryRecordReq;
|
|
|
import com.abi.qms.platform.dto.req.GetBoxCodeReq;
|
|
|
import com.abi.qms.platform.dto.res.GetBoxCodeRes;
|
|
|
+import com.abi.qms.platform.dto.res.ListQrFormatRes;
|
|
|
+import com.abi.qms.platform.infrastructure.util.AssertUtil;
|
|
|
import com.abi.qms.platform.service.FlowQueryService;
|
|
|
+import com.abi.qms.platform.service.IFlowQueryRecordService;
|
|
|
+import com.abi.task.common.utils.PojoConverterUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.LinkedList;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 箱码垛码查询 Service业务层处理
|
|
@@ -20,16 +29,44 @@ import java.util.List;
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
public class FlowQueryServiceImpl implements FlowQueryService {
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IFlowQueryRecordService flowQueryRecordService;
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 箱码查询
|
|
|
* TODO 测试使用,待流向查询接口完成后,根据实际情况调整结构
|
|
|
*/
|
|
|
@Override
|
|
|
- public GetBoxCodeRes boxCode(GetBoxCodeReq getBoxCodeReq) {
|
|
|
+ public GetBoxCodeRes boxCode(GetBoxCodeReq req) {
|
|
|
+ Integer queryType = req.getQueryType();
|
|
|
+ GetBoxCodeRes res = null;
|
|
|
+ //箱码查询
|
|
|
+ if(FlowQueryTypeEnum.BOX_CODE.is(queryType)){
|
|
|
+ String boxCode = req.getBoxCode();
|
|
|
+ res= this.getFlowInfoByBoxCode(boxCode);
|
|
|
+ }
|
|
|
+
|
|
|
+ AssertUtil.isNull(res,"为查询到流向信息!");
|
|
|
+ //保存查询记录
|
|
|
+ this.saveQueryRecord(res, req);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询流向信息
|
|
|
+ * @param boxCode 箱码
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public GetBoxCodeRes getFlowInfoByBoxCode(String boxCode){
|
|
|
GetBoxCodeRes res = new GetBoxCodeRes();
|
|
|
|
|
|
GetBoxCodeRes.SkuBean sku = new GetBoxCodeRes.SkuBean()
|
|
|
- .setBrandCode(320258L)
|
|
|
+ .setBrandCode("01AAHF")
|
|
|
.setBrandName("百威")
|
|
|
.setSkuId("000000000000025000")
|
|
|
.setSkuName("百威9.7度500ML1X18纸箱听装-温州版")
|
|
@@ -90,7 +127,7 @@ public class FlowQueryServiceImpl implements FlowQueryService {
|
|
|
Collections.reverse(flowList);
|
|
|
|
|
|
GetBoxCodeRes.BoxStackBean boxStack = new GetBoxCodeRes.BoxStackBean()
|
|
|
- .setBoxCode(getBoxCodeReq.getBoxCode())
|
|
|
+ .setBoxCode(boxCode)
|
|
|
.setInvisibleCode("adb25416313")
|
|
|
.setOriginalStackCode("200700048457ADB2")
|
|
|
.setOriginalStackTime(LocalDateTime.of(2020, 12, 26, 11, 12, 38))
|
|
@@ -98,13 +135,76 @@ public class FlowQueryServiceImpl implements FlowQueryService {
|
|
|
.setNewestStackTime(LocalDateTime.of(2021, 1, 1, 11, 12, 38));
|
|
|
|
|
|
|
|
|
-
|
|
|
res.setSku(sku);
|
|
|
res.setInspectionCase(inspectionCase);
|
|
|
res.setFlowList(flowList);
|
|
|
res.setBoxStack(boxStack);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- return res;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存查询记录
|
|
|
+ *
|
|
|
+ * @param res 查询结果
|
|
|
+ * @param req 查询请求
|
|
|
+ */
|
|
|
+ private void saveQueryRecord(GetBoxCodeRes res, GetBoxCodeReq req) {
|
|
|
+
|
|
|
+ //判断流向状态
|
|
|
+ Map<Integer, GetBoxCodeRes.FlowBean> abnormalNodeMap = res.getFlowList()
|
|
|
+ .stream()
|
|
|
+ .filter(s -> !(s.getNodeStatus().equals(1)))
|
|
|
+ .collect(Collectors.toMap(GetBoxCodeRes.FlowBean::getAbnormalType, flowBean -> flowBean));
|
|
|
+
|
|
|
+
|
|
|
+ FlowStatusEnum flowStatus = MapUtil.isEmpty(abnormalNodeMap) ? FlowStatusEnum.ABNORMAL : FlowStatusEnum.NORMAL;
|
|
|
+
|
|
|
+ //查询类型
|
|
|
+ Integer queryType = req.getQueryType();
|
|
|
+ AddFlowQueryRecordReq addReq = new AddFlowQueryRecordReq(flowStatus.getCode(), queryType);
|
|
|
+
|
|
|
+ // 箱码 查询类型为箱码时必传
|
|
|
+ addReq.setBoxCode(req.getBoxCode());
|
|
|
+ addReq.setTrayCode("");
|
|
|
+
|
|
|
+ //品牌
|
|
|
+ addReq.setBrandCode(res.getSku().getBrandCode());
|
|
|
+ addReq.setBrandName(res.getSku().getBrandName());
|
|
|
+
|
|
|
+ //sku
|
|
|
+ addReq.setSkuCode(res.getSku().getSkuId());
|
|
|
+
|
|
|
+ //后台查询
|
|
|
+ addReq.setQueryPlatform(ReqChannelTypeEnum.BACKSTAGE.getCode());
|
|
|
+
|
|
|
+ //后台查询没有地址
|
|
|
+ addReq.setQueryAddress("");
|
|
|
+
|
|
|
+ //abnormalNodeIn
|
|
|
+ GetBoxCodeRes.FlowBean abnormalNodeIn = abnormalNodeMap.get(1);
|
|
|
+ if(Objects.nonNull(abnormalNodeIn)){
|
|
|
+ addReq.setAbnormalInNodeCode(abnormalNodeIn.getNodeId());
|
|
|
+ addReq.setAbnormalInNodeName(abnormalNodeIn.getNodeName());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //abnormalNodeOut
|
|
|
+ GetBoxCodeRes.FlowBean abnormalNodeOut = abnormalNodeMap.get(2);
|
|
|
+ if(Objects.nonNull(abnormalNodeOut)) {
|
|
|
+ addReq.setAbnormalOutNodeCode(abnormalNodeOut.getNodeId());
|
|
|
+ addReq.setAbnormalOutNodeName(abnormalNodeOut.getNodeName());
|
|
|
+ }
|
|
|
+
|
|
|
+ //流向信息列表
|
|
|
+ List<GetBoxCodeRes.FlowBean> flowList = res.getFlowList();
|
|
|
+ List<AddFlowQueryRecordReq.FlowBean> flowBeans = PojoConverterUtils.copyList(flowList, AddFlowQueryRecordReq.FlowBean.class);
|
|
|
+ addReq.setFlowList(flowBeans);
|
|
|
+
|
|
|
+ flowQueryRecordService.addFlowQueryRecord(addReq);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|