|
@@ -7,9 +7,11 @@ import cn.hutool.core.map.MapUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import com.abi.qms.platform.dao.entity.InspectionCase;
|
|
import com.abi.qms.platform.dao.entity.InspectionCase;
|
|
import com.abi.qms.platform.dao.entity.InspectionCaseBoxCode;
|
|
import com.abi.qms.platform.dao.entity.InspectionCaseBoxCode;
|
|
|
|
+import com.abi.qms.platform.dao.entity.InspectionCaseFlow;
|
|
import com.abi.qms.platform.dao.enums.CaseNumberGenerateStrategyEnum;
|
|
import com.abi.qms.platform.dao.enums.CaseNumberGenerateStrategyEnum;
|
|
import com.abi.qms.platform.dao.enums.ReqChannelTypeEnum;
|
|
import com.abi.qms.platform.dao.enums.ReqChannelTypeEnum;
|
|
import com.abi.qms.platform.dao.mapper.InspectionCaseBoxCodeMapper;
|
|
import com.abi.qms.platform.dao.mapper.InspectionCaseBoxCodeMapper;
|
|
|
|
+import com.abi.qms.platform.dao.mapper.InspectionCaseFlowMapper;
|
|
import com.abi.qms.platform.dao.mapper.InspectionCaseMapper;
|
|
import com.abi.qms.platform.dao.mapper.InspectionCaseMapper;
|
|
import com.abi.qms.platform.dao.vo.result.InspectionCaseDetailVO;
|
|
import com.abi.qms.platform.dao.vo.result.InspectionCaseDetailVO;
|
|
import com.abi.qms.platform.dao.vo.result.ListInspectionCaseVO;
|
|
import com.abi.qms.platform.dao.vo.result.ListInspectionCaseVO;
|
|
@@ -18,19 +20,18 @@ import com.abi.qms.platform.dto.req.AddInspectionCaseReq;
|
|
import com.abi.qms.platform.dto.req.EditInspectionCaseReq;
|
|
import com.abi.qms.platform.dto.req.EditInspectionCaseReq;
|
|
import com.abi.qms.platform.dto.req.GetBoxCodeReq;
|
|
import com.abi.qms.platform.dto.req.GetBoxCodeReq;
|
|
import com.abi.qms.platform.dto.req.PageListInspectionCaseReq;
|
|
import com.abi.qms.platform.dto.req.PageListInspectionCaseReq;
|
|
-import com.abi.qms.platform.dto.res.GetBoxCodeRes;
|
|
|
|
-import com.abi.qms.platform.dto.res.GetInspectionCaseInfoRes;
|
|
|
|
-import com.abi.qms.platform.dto.res.ListRoleRes;
|
|
|
|
-import com.abi.qms.platform.dto.res.PageListInspectionCaseRes;
|
|
|
|
|
|
+import com.abi.qms.platform.dto.res.*;
|
|
import com.abi.qms.platform.infrastructure.util.AssertUtil;
|
|
import com.abi.qms.platform.infrastructure.util.AssertUtil;
|
|
import com.abi.qms.platform.infrastructure.util.PageUtil;
|
|
import com.abi.qms.platform.infrastructure.util.PageUtil;
|
|
import com.abi.qms.platform.service.FlowQueryService;
|
|
import com.abi.qms.platform.service.FlowQueryService;
|
|
import com.abi.qms.platform.service.IInspectionCaseService;
|
|
import com.abi.qms.platform.service.IInspectionCaseService;
|
|
|
|
+import com.abi.qms.platform.service.InspectionCaseFlowService;
|
|
import com.abi.qms.platform.service.InspectionCaseNumberService;
|
|
import com.abi.qms.platform.service.InspectionCaseNumberService;
|
|
import com.abi.task.common.api.exception.BusinessException;
|
|
import com.abi.task.common.api.exception.BusinessException;
|
|
import com.abi.task.common.utils.PojoConverterUtils;
|
|
import com.abi.task.common.utils.PojoConverterUtils;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import jodd.util.StringUtil;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -59,12 +60,17 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
|
|
@Autowired
|
|
@Autowired
|
|
private InspectionCaseBoxCodeMapper inspectionCaseBoxCodeMapper;
|
|
private InspectionCaseBoxCodeMapper inspectionCaseBoxCodeMapper;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private InspectionCaseFlowMapper inspectionCaseFlowMapper;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private InspectionCaseNumberService caseNumberService;
|
|
private InspectionCaseNumberService caseNumberService;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private FlowQueryService flowQueryService;
|
|
private FlowQueryService flowQueryService;
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 新增案件
|
|
* 新增案件
|
|
*
|
|
*
|
|
@@ -77,8 +83,12 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
|
|
//============先校验箱码============
|
|
//============先校验箱码============
|
|
List<AddInspectionCaseReq.BoxCode> involvedBoxCodes = addReq.getInvolvedBoxCodes();
|
|
List<AddInspectionCaseReq.BoxCode> involvedBoxCodes = addReq.getInvolvedBoxCodes();
|
|
List<String> boxCodeStrList = involvedBoxCodes.stream().map(AddInspectionCaseReq.BoxCode::getBoxCode).collect(Collectors.toList());
|
|
List<String> boxCodeStrList = involvedBoxCodes.stream().map(AddInspectionCaseReq.BoxCode::getBoxCode).collect(Collectors.toList());
|
|
- //校验箱码信息 校验通过返回箱码对应流向信息
|
|
|
|
- Map flowInfo = this.validatedBoxCode(boxCodeStrList);
|
|
|
|
|
|
+ //查询箱码流向信息
|
|
|
|
+ List<GetBoxCodeRes> flowInfoByBoxCodeList = this.getFlowInfoByBoxCodeList(boxCodeStrList);
|
|
|
|
+ //校验箱码信息
|
|
|
|
+ this.validatedBoxCode(flowInfoByBoxCodeList, addReq.getSkuCode());
|
|
|
|
+ //流向信息
|
|
|
|
+ List<GetBoxCodeRes.FlowBean> flowList = flowInfoByBoxCodeList.get(0).getFlowList();
|
|
|
|
|
|
//============案件编号============
|
|
//============案件编号============
|
|
String caseNumber = addReq.getCaseNumber();
|
|
String caseNumber = addReq.getCaseNumber();
|
|
@@ -95,22 +105,37 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
|
|
List<InspectionCase> inspectionCaseList = inspectionCaseMapper.selectList(inspectionCaseQueryWrapper);
|
|
List<InspectionCase> inspectionCaseList = inspectionCaseMapper.selectList(inspectionCaseQueryWrapper);
|
|
AssertUtil.isEmpty(inspectionCaseList, "当前编号已存在!");
|
|
AssertUtil.isEmpty(inspectionCaseList, "当前编号已存在!");
|
|
|
|
|
|
|
|
+
|
|
//============保存案件============
|
|
//============保存案件============
|
|
|
|
|
|
InspectionCase inspectionCase = new InspectionCase();
|
|
InspectionCase inspectionCase = new InspectionCase();
|
|
- //TODO 设置流入 流出经销商 从 flowInfo 中取出
|
|
|
|
- inspectionCase.setOutAgencyCode("T0001");
|
|
|
|
- inspectionCase.setOutAgencyName("T_京城XXX超市");
|
|
|
|
- inspectionCase.setInAgencyCode("T0002");
|
|
|
|
- inspectionCase.setInAgencyName("T_京城XXX便利店");
|
|
|
|
-
|
|
|
|
BeanUtil.copyProperties(addReq, inspectionCase);
|
|
BeanUtil.copyProperties(addReq, inspectionCase);
|
|
|
|
+ //流出经销商 从 flowInfo 中取出
|
|
|
|
+ GetBoxCodeRes.FlowBean outAgencyFlowBean = flowList.stream()
|
|
|
|
+ .filter(s -> s.getAbnormalType().equals(2))
|
|
|
|
+ .min(Comparator.comparing(GetBoxCodeRes.FlowBean::getOutStorageTime))
|
|
|
|
+ .orElseThrow(() -> new BusinessException("没有流出异常节点"));
|
|
|
|
+
|
|
|
|
+ inspectionCase.setOutAgencyCode(outAgencyFlowBean.getNodeId().toString());
|
|
|
|
+ inspectionCase.setOutAgencyName(outAgencyFlowBean.getNodeName());
|
|
|
|
+
|
|
|
|
+ // 设置流入 经销商 从 flowInfo 中取出
|
|
|
|
+ GetBoxCodeRes.FlowBean inAgencyflowBean = flowList.stream()
|
|
|
|
+ .filter(s -> s.getAbnormalType().equals(1))
|
|
|
|
+ .max(Comparator.comparing(GetBoxCodeRes.FlowBean::getInStorageTime))
|
|
|
|
+ .orElseThrow(() -> new BusinessException("没有流入异常节点"));
|
|
|
|
+
|
|
|
|
+ inspectionCase.setInAgencyCode(inAgencyflowBean.getNodeId().toString());
|
|
|
|
+ inspectionCase.setInAgencyName(inAgencyflowBean.getNodeName());
|
|
|
|
+ //流货数量
|
|
inspectionCase.setBoxCodeCount((long) addReq.getInvolvedBoxCodes().size());
|
|
inspectionCase.setBoxCodeCount((long) addReq.getInvolvedBoxCodes().size());
|
|
|
|
+ //案件名称
|
|
inspectionCase.setCaseNumber(caseNumber);
|
|
inspectionCase.setCaseNumber(caseNumber);
|
|
//设置渠道=>后台
|
|
//设置渠道=>后台
|
|
inspectionCase.setChannel(ReqChannelTypeEnum.BACKSTAGE.getCode());
|
|
inspectionCase.setChannel(ReqChannelTypeEnum.BACKSTAGE.getCode());
|
|
inspectionCaseMapper.insert(inspectionCase);
|
|
inspectionCaseMapper.insert(inspectionCase);
|
|
|
|
|
|
|
|
+
|
|
//============保存涉案箱码============
|
|
//============保存涉案箱码============
|
|
//转换类型
|
|
//转换类型
|
|
List<InspectionCaseBoxCode> inspectionCaseBoxCodeList = involvedBoxCodes.stream()
|
|
List<InspectionCaseBoxCode> inspectionCaseBoxCodeList = involvedBoxCodes.stream()
|
|
@@ -120,12 +145,22 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
|
|
inspectionCaseBoxCode.setInspectionCaseId(inspectionCase.getId());
|
|
inspectionCaseBoxCode.setInspectionCaseId(inspectionCase.getId());
|
|
return inspectionCaseBoxCode;
|
|
return inspectionCaseBoxCode;
|
|
}).collect(Collectors.toList());
|
|
}).collect(Collectors.toList());
|
|
|
|
+ //批量保存
|
|
|
|
+ inspectionCaseBoxCodeMapper.insertBatch(inspectionCaseBoxCodeList);
|
|
|
|
+
|
|
|
|
|
|
//============保存【案件-流向】关联============
|
|
//============保存【案件-流向】关联============
|
|
|
|
|
|
|
|
+ List<InspectionCaseFlow> inspectionCaseFlowList = flowList.stream().map(s -> {
|
|
|
|
+ InspectionCaseFlow inspectionCaseFlow = new InspectionCaseFlow();
|
|
|
|
+ BeanUtil.copyProperties(s,inspectionCaseFlow);
|
|
|
|
+ inspectionCaseFlow.setInspectionCaseId(inspectionCase.getId());
|
|
|
|
+ return inspectionCaseFlow;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ inspectionCaseFlowMapper.insertBatch(inspectionCaseFlowList);
|
|
|
|
+
|
|
|
|
|
|
- //批量保存
|
|
|
|
- inspectionCaseBoxCodeMapper.insertBatch(inspectionCaseBoxCodeList);
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -174,27 +209,41 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
|
|
public void editInspectionCase(EditInspectionCaseReq editReq) {
|
|
public void editInspectionCase(EditInspectionCaseReq editReq) {
|
|
|
|
|
|
final Long caseId = editReq.getId();
|
|
final Long caseId = editReq.getId();
|
|
|
|
+
|
|
|
|
+ InspectionCase inspectionCase = inspectionCaseMapper.selectById(caseId);
|
|
//============校验箱码============
|
|
//============校验箱码============
|
|
//涉案箱码
|
|
//涉案箱码
|
|
List<EditInspectionCaseReq.BoxCode> involvedBoxCodes = editReq.getInvolvedBoxCodes();
|
|
List<EditInspectionCaseReq.BoxCode> involvedBoxCodes = editReq.getInvolvedBoxCodes();
|
|
List<String> boxCodeStrList = involvedBoxCodes.stream().map(EditInspectionCaseReq.BoxCode::getBoxCode).collect(Collectors.toList());
|
|
List<String> boxCodeStrList = involvedBoxCodes.stream().map(EditInspectionCaseReq.BoxCode::getBoxCode).collect(Collectors.toList());
|
|
- //校验箱码信息 返回箱码对应流向信息
|
|
|
|
- Map map = this.validatedBoxCode(boxCodeStrList);
|
|
|
|
-
|
|
|
|
|
|
+ //查询箱码流向信息
|
|
|
|
+ List<GetBoxCodeRes> flowInfoByBoxCodeList = this.getFlowInfoByBoxCodeList(boxCodeStrList);
|
|
|
|
+ //校验箱码信息
|
|
|
|
+ this.validatedBoxCode(flowInfoByBoxCodeList, inspectionCase.getSkuCode());
|
|
|
|
+ //流向信息
|
|
|
|
+ List<GetBoxCodeRes.FlowBean> flowList = flowInfoByBoxCodeList.get(0).getFlowList();
|
|
|
|
|
|
//============修改案件信息============
|
|
//============修改案件信息============
|
|
|
|
+ //流出经销商 从 flowInfo 中取出
|
|
|
|
+ GetBoxCodeRes.FlowBean outAgencyFlowBean = flowList.stream()
|
|
|
|
+ .filter(s -> s.getAbnormalType().equals(2))
|
|
|
|
+ .min(Comparator.comparing(GetBoxCodeRes.FlowBean::getOutStorageTime))
|
|
|
|
+ .orElseThrow(() -> new BusinessException("没有流出异常节点"));
|
|
|
|
|
|
|
|
+ inspectionCase.setOutAgencyCode(outAgencyFlowBean.getNodeId().toString());
|
|
|
|
+ inspectionCase.setOutAgencyName(outAgencyFlowBean.getNodeName());
|
|
|
|
|
|
- InspectionCase inspectionCase = new InspectionCase();
|
|
|
|
- //TODO 设置流入 流出经销商
|
|
|
|
- inspectionCase.setOutAgencyCode("Test_0001");
|
|
|
|
- inspectionCase.setOutAgencyName("Test_京城第一经销商");
|
|
|
|
- inspectionCase.setInAgencyCode("Test_0002");
|
|
|
|
- inspectionCase.setInAgencyName("Test_京城第二经销商");
|
|
|
|
|
|
+ // 设置流入 经销商 从 flowInfo 中取出
|
|
|
|
+ GetBoxCodeRes.FlowBean inAgencyflowBean = flowList.stream()
|
|
|
|
+ .filter(s -> s.getAbnormalType().equals(1))
|
|
|
|
+ .max(Comparator.comparing(GetBoxCodeRes.FlowBean::getInStorageTime))
|
|
|
|
+ .orElseThrow(() -> new BusinessException("没有流入异常节点"));
|
|
|
|
+
|
|
|
|
+ inspectionCase.setInAgencyCode(inAgencyflowBean.getNodeId().toString());
|
|
|
|
+ inspectionCase.setInAgencyName(inAgencyflowBean.getNodeName());
|
|
|
|
|
|
inspectionCase.setBoxCodeCount((long) involvedBoxCodes.size());
|
|
inspectionCase.setBoxCodeCount((long) involvedBoxCodes.size());
|
|
- inspectionCase.setId(caseId);
|
|
|
|
inspectionCase.setCaseRemark(editReq.getCaseRemark());
|
|
inspectionCase.setCaseRemark(editReq.getCaseRemark());
|
|
|
|
+
|
|
int i = inspectionCaseMapper.updateById(inspectionCase);
|
|
int i = inspectionCaseMapper.updateById(inspectionCase);
|
|
//判断当前案件是否存在 i如果大于0表示 更新成功 否则表示未找到指定数据
|
|
//判断当前案件是否存在 i如果大于0表示 更新成功 否则表示未找到指定数据
|
|
AssertUtil.isMeets(i, x -> x > 0, "当前案件已经不存在!");
|
|
AssertUtil.isMeets(i, x -> x > 0, "当前案件已经不存在!");
|
|
@@ -211,11 +260,30 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
|
|
|
|
|
|
//先删除当前案件下关联的箱码信息
|
|
//先删除当前案件下关联的箱码信息
|
|
QueryWrapper<InspectionCaseBoxCode> boxCodeDeleteWrapper = new QueryWrapper<>();
|
|
QueryWrapper<InspectionCaseBoxCode> boxCodeDeleteWrapper = new QueryWrapper<>();
|
|
- boxCodeDeleteWrapper.eq("inspection_case_id", editReq.getId());
|
|
|
|
|
|
+ boxCodeDeleteWrapper.eq("inspection_case_id", caseId);
|
|
inspectionCaseBoxCodeMapper.delete(boxCodeDeleteWrapper);
|
|
inspectionCaseBoxCodeMapper.delete(boxCodeDeleteWrapper);
|
|
//批量保存
|
|
//批量保存
|
|
inspectionCaseBoxCodeMapper.insertBatch(inspectionCaseBoxCodeList);
|
|
inspectionCaseBoxCodeMapper.insertBatch(inspectionCaseBoxCodeList);
|
|
|
|
|
|
|
|
+
|
|
|
|
+ //============修改【案件-流向】关联============
|
|
|
|
+
|
|
|
|
+ //先删除当前案件下关联流向信息
|
|
|
|
+ QueryWrapper<InspectionCaseFlow> inspectionCaseFlowQW = new QueryWrapper<>();
|
|
|
|
+ inspectionCaseFlowQW.eq("inspection_case_id", caseId);
|
|
|
|
+ inspectionCaseFlowMapper.delete(inspectionCaseFlowQW);
|
|
|
|
+
|
|
|
|
+ //保存新信息
|
|
|
|
+ List<InspectionCaseFlow> inspectionCaseFlowList = flowList.stream().map(s -> {
|
|
|
|
+ InspectionCaseFlow inspectionCaseFlow = new InspectionCaseFlow();
|
|
|
|
+ BeanUtil.copyProperties(s,inspectionCaseFlow);
|
|
|
|
+ inspectionCaseFlow.setInspectionCaseId(inspectionCase.getId());
|
|
|
|
+ return inspectionCaseFlow;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ inspectionCaseFlowMapper.insertBatch(inspectionCaseFlowList);
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -230,6 +298,9 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
|
|
inspectionCaseMapper.deleteBatchIds(Arrays.asList(ids));
|
|
inspectionCaseMapper.deleteBatchIds(Arrays.asList(ids));
|
|
//删除关联的箱码信息
|
|
//删除关联的箱码信息
|
|
inspectionCaseBoxCodeMapper.deleteBatchCaseIds(ids);
|
|
inspectionCaseBoxCodeMapper.deleteBatchCaseIds(ids);
|
|
|
|
+ //删除【案件-流向】关联信息
|
|
|
|
+ inspectionCaseFlowMapper.deleteBatchCaseIds(ids);
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -240,6 +311,7 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public GetInspectionCaseInfoRes getInspectionCaseInfo(final Long id) {
|
|
public GetInspectionCaseInfoRes getInspectionCaseInfo(final Long id) {
|
|
|
|
+ //案件信息
|
|
InspectionCaseDetailVO caseDetailVO = inspectionCaseMapper.selectInspectionCaseDetailById(id);
|
|
InspectionCaseDetailVO caseDetailVO = inspectionCaseMapper.selectInspectionCaseDetailById(id);
|
|
AssertUtil.isNull(caseDetailVO, "此案件未查询到!");
|
|
AssertUtil.isNull(caseDetailVO, "此案件未查询到!");
|
|
|
|
|
|
@@ -249,51 +321,85 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
|
|
getInspectionCaseInfoRes.setOutAgency(caseDetailVO.getOutAgencyCode() + caseDetailVO.getOutAgencyName());
|
|
getInspectionCaseInfoRes.setOutAgency(caseDetailVO.getOutAgencyCode() + caseDetailVO.getOutAgencyName());
|
|
getInspectionCaseInfoRes.setInAgency(caseDetailVO.getInAgencyCode() + caseDetailVO.getInAgencyName());
|
|
getInspectionCaseInfoRes.setInAgency(caseDetailVO.getInAgencyCode() + caseDetailVO.getInAgencyName());
|
|
|
|
|
|
|
|
+ //查询对应流向信息
|
|
|
|
+ QueryWrapper<InspectionCaseFlow> inspectionCaseFlowQW = new QueryWrapper<>();
|
|
|
|
+ inspectionCaseFlowQW.eq("inspection_case_id", id);
|
|
|
|
+ inspectionCaseFlowQW.orderByAsc("out_storage_time");
|
|
|
|
+ List<InspectionCaseFlow> inspectionCaseFlowList = inspectionCaseFlowMapper.selectList(inspectionCaseFlowQW);
|
|
|
|
+ //转换类型
|
|
|
|
+ List<GetInspectionCaseInfoRes.FlowBean> flowBeanList = PojoConverterUtils.copyList(inspectionCaseFlowList, GetInspectionCaseInfoRes.FlowBean.class);
|
|
|
|
+ getInspectionCaseInfoRes.setFlowList(flowBeanList);
|
|
|
|
+
|
|
return getInspectionCaseInfoRes;
|
|
return getInspectionCaseInfoRes;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 校验箱码
|
|
|
|
- * 1、提交箱码的SKU信息是否一致,不一致则显示错误箱码;并列出错误原因
|
|
|
|
- * 2、提交箱码的流向信息是否一致
|
|
|
|
- *
|
|
|
|
- * @param boxCodeList 提交箱码列表
|
|
|
|
- * @return 流向信息
|
|
|
|
|
|
+ * 查询箱码对应流向信息
|
|
|
|
+ * @param boxCodeList 箱码列表
|
|
|
|
+ * @return 对应流向信息列表
|
|
*/
|
|
*/
|
|
- private Map validatedBoxCode(List<String> boxCodeList) {
|
|
|
|
-
|
|
|
|
- List<GetBoxCodeRes> boxCodeResList = new ArrayList<>();
|
|
|
|
-
|
|
|
|
- Set<Long> skuIdSet = new HashSet<Long>();
|
|
|
|
- List<String> skuErrBoxCode = new ArrayList<>();
|
|
|
|
-
|
|
|
|
|
|
+ private List<GetBoxCodeRes> getFlowInfoByBoxCodeList(List<String> boxCodeList) {
|
|
|
|
+ List<GetBoxCodeRes> getBoxCodeResList = new ArrayList<>();
|
|
boxCodeList.forEach(s -> {
|
|
boxCodeList.forEach(s -> {
|
|
GetBoxCodeReq boxCodeReq = new GetBoxCodeReq(s);
|
|
GetBoxCodeReq boxCodeReq = new GetBoxCodeReq(s);
|
|
GetBoxCodeRes res = flowQueryService.boxCode(boxCodeReq);
|
|
GetBoxCodeRes res = flowQueryService.boxCode(boxCodeReq);
|
|
AssertUtil.isNull(res, "案件新增失败!箱码:" + s + ",失败原因:未查询到此箱码信息!");
|
|
AssertUtil.isNull(res, "案件新增失败!箱码:" + s + ",失败原因:未查询到此箱码信息!");
|
|
- boxCodeResList.add(res);
|
|
|
|
|
|
+ getBoxCodeResList.add(res);
|
|
|
|
+ });
|
|
|
|
+ return getBoxCodeResList;
|
|
|
|
+ }
|
|
|
|
|
|
- //判断SKU信息是否一致
|
|
|
|
- Long skuId = res.getSku().getSkuId();
|
|
|
|
- if (!skuIdSet.add(skuId)) {
|
|
|
|
- skuErrBoxCode.add(s);
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 校验箱码
|
|
|
|
+ * 1、提交箱码的SKU信息是否一致,
|
|
|
|
+ * 2、提交箱码的流向信息是否一致
|
|
|
|
+ * 不一致则显示错误箱码;并列出错误原因
|
|
|
|
+ *
|
|
|
|
+ * @param boxCodeResList 箱码信息
|
|
|
|
+ * @return 流向信息
|
|
|
|
+ */
|
|
|
|
+ private void validatedBoxCode(List<GetBoxCodeRes> boxCodeResList, String skuCode) {
|
|
|
|
|
|
|
|
+ List<String> skuErrBoxCode = new ArrayList<>();
|
|
|
|
+ List<String> flowErrBoxCode = new ArrayList<>();
|
|
|
|
|
|
- });
|
|
|
|
|
|
+ Set<LocalDateTime> outStorageTimeSet = new HashSet<LocalDateTime>();
|
|
|
|
+ List<Long> firstFlowNodeIdList = new ArrayList<>();
|
|
|
|
|
|
- AssertUtil.isEmpty(skuErrBoxCode, "案件新增失败!箱码:" + StrUtil.str(skuErrBoxCode, ";") + ",失败原因:SKU信息不一致");
|
|
|
|
|
|
+ for (GetBoxCodeRes res : boxCodeResList) {
|
|
|
|
|
|
- //TODO 查询流向信息
|
|
|
|
- //TODO 校验提交箱码所对应的SKU信息是否正确;、校验提交箱码的流向信息是否相同
|
|
|
|
- //List<String> errorBoxCodeList=new ArrayList<>();
|
|
|
|
- //校验失败 抛出异常 说明错误箱码;并列出错误原因
|
|
|
|
- //AssertUtil.isEmpty(errorBoxCodeList,"案件新增失败!箱码:XXXX;XXXXX,失败原因:SKU信息不一致/流向信息不一致");
|
|
|
|
|
|
+ //箱码
|
|
|
|
+ String boxCode = res.getBoxStack().getBoxCode();
|
|
|
|
|
|
|
|
+ //判断SKU信息是否一致
|
|
|
|
+ String skuId = res.getSku().getSkuId();
|
|
|
|
+ if (!StrUtil.equals(skuId, skuCode)) {
|
|
|
|
+ skuErrBoxCode.add(boxCode);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //判断流向是否一致
|
|
|
|
+ //获取当前流向信息
|
|
|
|
+ List<GetBoxCodeRes.FlowBean> flowList = res.getFlowList();
|
|
|
|
+ LocalDateTime outStorageTime = flowList.stream().filter(s->Objects.nonNull(s.getOutStorageTime())).min(Comparator.comparing(GetBoxCodeRes.FlowBean::getOutStorageTime)).get().getOutStorageTime();
|
|
|
|
+ boolean outStorageTimeAdd = outStorageTimeSet.add(outStorageTime);
|
|
|
|
+
|
|
|
|
+ //获取当前所以流向节点ID
|
|
|
|
+ List<Long> nodeIds = flowList.stream().map(GetBoxCodeRes.FlowBean::getNodeId).collect(Collectors.toList());
|
|
|
|
+ //如果firstFlowNodeIdList 为空 则赋值
|
|
|
|
+ if (CollectionUtil.isEmpty(firstFlowNodeIdList)) {
|
|
|
|
+ firstFlowNodeIdList.addAll(nodeIds);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ //判断节点信息和时间信息是否一致
|
|
|
|
+ if (!CollectionUtil.containsAll(firstFlowNodeIdList, nodeIds) || !outStorageTimeAdd) {
|
|
|
|
+ flowErrBoxCode.add(boxCode);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- return MapUtil.empty();
|
|
|
|
|
|
+ AssertUtil.isEmpty(skuErrBoxCode, "案件新增失败!箱码:" + CollectionUtil.join(skuErrBoxCode, ";") + ",失败原因:SKU信息不一致");
|
|
|
|
+ AssertUtil.isEmpty(flowErrBoxCode, "案件新增失败!箱码:" + CollectionUtil.join(flowErrBoxCode, ";") + ",失败原因:流向信息不一致");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|