|
@@ -1,14 +1,17 @@
|
|
|
package com.abi.qms.platform.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.map.MapUtil;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
+import com.abi.qms.platform.dao.entity.UserInfo;
|
|
|
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.infrastructure.util.UserUtil;
|
|
|
import com.abi.qms.platform.service.FlowQueryService;
|
|
|
import com.abi.qms.platform.service.IFlowQueryRecordService;
|
|
|
import com.abi.task.common.utils.PojoConverterUtils;
|
|
@@ -34,7 +37,8 @@ public class FlowQueryServiceImpl implements FlowQueryService {
|
|
|
@Autowired
|
|
|
private IFlowQueryRecordService flowQueryRecordService;
|
|
|
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private UserUtil userUtil;
|
|
|
/**
|
|
|
* 箱码查询
|
|
|
* TODO 测试使用,待流向查询接口完成后,根据实际情况调整结构
|
|
@@ -152,58 +156,69 @@ public class FlowQueryServiceImpl implements FlowQueryService {
|
|
|
* @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());
|
|
|
+ try {
|
|
|
+
|
|
|
+ //判断流向状态
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ //箱垛信息
|
|
|
+ GetBoxCodeRes.BoxStackBean boxStack = res.getBoxStack();
|
|
|
+ AddFlowQueryRecordReq.BoxStackBean boxStackBean = new AddFlowQueryRecordReq.BoxStackBean();
|
|
|
+ BeanUtil.copyProperties(boxStack,boxStackBean);
|
|
|
+ addReq.setBoxStackInfo(boxStackBean);
|
|
|
+
|
|
|
+ //流向信息列表
|
|
|
+ List<GetBoxCodeRes.FlowBean> flowList = res.getFlowList();
|
|
|
+ List<AddFlowQueryRecordReq.FlowBean> flowBeans = PojoConverterUtils.copyList(flowList, AddFlowQueryRecordReq.FlowBean.class);
|
|
|
+ addReq.setFlowList(flowBeans);
|
|
|
+
|
|
|
+ flowQueryRecordService.addFlowQueryRecord(addReq);
|
|
|
+ }catch (Exception ex){
|
|
|
+ //获取当前登录的用户
|
|
|
+ UserInfo user = userUtil.getUser();
|
|
|
+ log.error("查询流向信息记录报错失败!,查询人:【{}】,查询结果:【{}】,异常:{}",user.getUserName(),JSONUtil.toJsonStr(res),ex.getMessage());
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- //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);
|
|
|
}
|
|
|
|
|
|
|