|
@@ -16,10 +16,7 @@ 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;
|
|
import com.abi.qms.platform.dao.vo.result.ListRoleVO;
|
|
import com.abi.qms.platform.dao.vo.result.ListRoleVO;
|
|
-import com.abi.qms.platform.dto.req.AddInspectionCaseReq;
|
|
|
|
-import com.abi.qms.platform.dto.req.EditInspectionCaseReq;
|
|
|
|
-import com.abi.qms.platform.dto.req.GetBoxCodeReq;
|
|
|
|
-import com.abi.qms.platform.dto.req.PageListInspectionCaseReq;
|
|
|
|
|
|
+import com.abi.qms.platform.dto.req.*;
|
|
import com.abi.qms.platform.dto.res.*;
|
|
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;
|
|
@@ -29,8 +26,10 @@ 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.Wrapper;
|
|
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 io.swagger.models.auth.In;
|
|
import jodd.util.StringUtil;
|
|
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;
|
|
@@ -70,7 +69,6 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
|
|
private FlowQueryService flowQueryService;
|
|
private FlowQueryService flowQueryService;
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 新增案件
|
|
* 新增案件
|
|
*
|
|
*
|
|
@@ -99,12 +97,16 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
|
|
}
|
|
}
|
|
|
|
|
|
//查看编号是否存在
|
|
//查看编号是否存在
|
|
- QueryWrapper<InspectionCase> inspectionCaseQueryWrapper = new QueryWrapper<>();
|
|
|
|
- inspectionCaseQueryWrapper.eq("case_number", caseNumber);
|
|
|
|
- inspectionCaseQueryWrapper.eq("is_delete", 0);
|
|
|
|
- List<InspectionCase> inspectionCaseList = inspectionCaseMapper.selectList(inspectionCaseQueryWrapper);
|
|
|
|
|
|
+ QueryWrapper<InspectionCase> inspectionCaseQW = new QueryWrapper<>();
|
|
|
|
+ inspectionCaseQW.eq("case_number", caseNumber);
|
|
|
|
+ List<InspectionCase> inspectionCaseList = inspectionCaseMapper.selectList(inspectionCaseQW);
|
|
AssertUtil.isEmpty(inspectionCaseList, "当前编号已存在!");
|
|
AssertUtil.isEmpty(inspectionCaseList, "当前编号已存在!");
|
|
|
|
|
|
|
|
+ //查看案件名称是否存在
|
|
|
|
+ inspectionCaseQW.clear();
|
|
|
|
+ inspectionCaseQW.eq("case_name", addReq.getCaseName());
|
|
|
|
+ inspectionCaseList = inspectionCaseMapper.selectList(inspectionCaseQW);
|
|
|
|
+ AssertUtil.isEmpty(inspectionCaseList, "当前名称已占用!");
|
|
|
|
|
|
//============保存案件============
|
|
//============保存案件============
|
|
|
|
|
|
@@ -153,7 +155,7 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
|
|
|
|
|
|
List<InspectionCaseFlow> inspectionCaseFlowList = flowList.stream().map(s -> {
|
|
List<InspectionCaseFlow> inspectionCaseFlowList = flowList.stream().map(s -> {
|
|
InspectionCaseFlow inspectionCaseFlow = new InspectionCaseFlow();
|
|
InspectionCaseFlow inspectionCaseFlow = new InspectionCaseFlow();
|
|
- BeanUtil.copyProperties(s,inspectionCaseFlow);
|
|
|
|
|
|
+ BeanUtil.copyProperties(s, inspectionCaseFlow);
|
|
inspectionCaseFlow.setInspectionCaseId(inspectionCase.getId());
|
|
inspectionCaseFlow.setInspectionCaseId(inspectionCase.getId());
|
|
return inspectionCaseFlow;
|
|
return inspectionCaseFlow;
|
|
}).collect(Collectors.toList());
|
|
}).collect(Collectors.toList());
|
|
@@ -161,7 +163,6 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
|
|
inspectionCaseFlowMapper.insertBatch(inspectionCaseFlowList);
|
|
inspectionCaseFlowMapper.insertBatch(inspectionCaseFlowList);
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -276,7 +277,7 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
|
|
//保存新信息
|
|
//保存新信息
|
|
List<InspectionCaseFlow> inspectionCaseFlowList = flowList.stream().map(s -> {
|
|
List<InspectionCaseFlow> inspectionCaseFlowList = flowList.stream().map(s -> {
|
|
InspectionCaseFlow inspectionCaseFlow = new InspectionCaseFlow();
|
|
InspectionCaseFlow inspectionCaseFlow = new InspectionCaseFlow();
|
|
- BeanUtil.copyProperties(s,inspectionCaseFlow);
|
|
|
|
|
|
+ BeanUtil.copyProperties(s, inspectionCaseFlow);
|
|
inspectionCaseFlow.setInspectionCaseId(inspectionCase.getId());
|
|
inspectionCaseFlow.setInspectionCaseId(inspectionCase.getId());
|
|
return inspectionCaseFlow;
|
|
return inspectionCaseFlow;
|
|
}).collect(Collectors.toList());
|
|
}).collect(Collectors.toList());
|
|
@@ -333,9 +334,134 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
|
|
return getInspectionCaseInfoRes;
|
|
return getInspectionCaseInfoRes;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 根据 编号或名称 模糊查询
|
|
|
|
+ *
|
|
|
|
+ * @param numOrName 编号或名称
|
|
|
|
+ * @return 案件信息
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public QueryCaseLikeNumOrNameRes queryCaseLikeNumOrName(final String numOrName) {
|
|
|
|
+ //模糊查询
|
|
|
|
+ QueryWrapper<InspectionCase> caseQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ caseQueryWrapper.like("case_number", numOrName).or().like("case_name", numOrName);
|
|
|
|
+ List<InspectionCase> inspectionCases = inspectionCaseMapper.selectList(caseQueryWrapper);
|
|
|
|
+ if (CollectionUtil.isEmpty(inspectionCases)) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ QueryCaseLikeNumOrNameRes res = new QueryCaseLikeNumOrNameRes();
|
|
|
|
+ //类型转换
|
|
|
|
+ List<QueryCaseLikeNumOrNameRes.CaseBean> caseBeanList = inspectionCases.stream().map(s -> {
|
|
|
|
+ QueryCaseLikeNumOrNameRes.CaseBean caseBean = new QueryCaseLikeNumOrNameRes.CaseBean();
|
|
|
|
+ caseBean.setCaseId(s.getId());
|
|
|
|
+ caseBean.setCaseNum(s.getCaseNumber());
|
|
|
|
+ caseBean.setCaseName(s.getCaseName());
|
|
|
|
+ return caseBean;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ res.setCaseInfoList(caseBeanList);
|
|
|
|
+
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 关联到已有案件
|
|
|
|
+ *
|
|
|
|
+ * @param req 请求
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public void associatedWithCase(AssociatedWithCaseReq req) {
|
|
|
|
+
|
|
|
|
+ Long caseId = req.getCaseId();
|
|
|
|
+ String boxCode = req.getBoxCode();
|
|
|
|
+ List<AssociatedWithCaseReq.FlowBean> reqFlowList = req.getFlowList();
|
|
|
|
+ //验证指定案件是否存在
|
|
|
|
+ InspectionCase inspectionCase = inspectionCaseMapper.selectById(caseId);
|
|
|
|
+ AssertUtil.isNull(inspectionCase, "指定案件不存在或已被删除!");
|
|
|
|
+
|
|
|
|
+ //验证SKU是否一致
|
|
|
|
+ String skuCode = inspectionCase.getSkuCode();
|
|
|
|
+ AssertUtil.isMeets(req.getSkuCode(), s -> StrUtil.equals(s, skuCode), "当前箱码与指定案件SKU不一致!");
|
|
|
|
+
|
|
|
|
+ //验证当前箱码是否已经存在
|
|
|
|
+ QueryWrapper<InspectionCaseBoxCode> boxCodeQW = new QueryWrapper<>();
|
|
|
|
+ boxCodeQW.eq("inspection_case_id", caseId);
|
|
|
|
+ List<InspectionCaseBoxCode> caseBoxCodes = inspectionCaseBoxCodeMapper.selectList(boxCodeQW);
|
|
|
|
+ long count = caseBoxCodes.stream().filter(s -> StrUtil.equals(s.getBoxCode(), boxCode)).count();
|
|
|
|
+ AssertUtil.isMeets(count, x -> x >= 0L, "指定案件已经关联当前箱码!");
|
|
|
|
+
|
|
|
|
+ //验证当前箱码是否与案件流向一致
|
|
|
|
+ QueryWrapper<InspectionCaseFlow> flowQW = new QueryWrapper<>();
|
|
|
|
+ flowQW.eq("inspection_case_id", caseId);
|
|
|
|
+ List<InspectionCaseFlow> flowList = inspectionCaseFlowMapper.selectList(flowQW);
|
|
|
|
+ //当前案件流向节点
|
|
|
|
+ List<Long> nodeIds = flowList.stream()
|
|
|
|
+ .map(InspectionCaseFlow::getNodeId)
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ //请求流向节点
|
|
|
|
+ List<Long> reqNodeIds = reqFlowList.stream()
|
|
|
|
+ .map(AssociatedWithCaseReq.FlowBean::getNodeId)
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //节点数量是否一致
|
|
|
|
+ AssertUtil.isMeets(reqNodeIds.size(), size -> size == nodeIds.size(), "当前箱码与案件流向不一致!");
|
|
|
|
+ //节点是否相同
|
|
|
|
+ AssertUtil.isMeets(reqNodeIds, s -> CollectionUtil.containsAll(s, nodeIds), "当前箱码与案件流向不一致!");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //当前案件最小出库时间
|
|
|
|
+ LocalDateTime outStorageTime = flowList.stream()
|
|
|
|
+ .filter(s -> Objects.nonNull(s.getOutStorageTime()))
|
|
|
|
+ .min(Comparator.comparing(InspectionCaseFlow::getOutStorageTime))
|
|
|
|
+ .get()
|
|
|
|
+ .getOutStorageTime();
|
|
|
|
+
|
|
|
|
+ //请求流向最小出库时间
|
|
|
|
+ LocalDateTime resOutStorageTime = reqFlowList.stream()
|
|
|
|
+ .filter(s -> Objects.nonNull(s.getOutStorageTime()))
|
|
|
|
+ .min(Comparator.comparing(AssociatedWithCaseReq.FlowBean::getOutStorageTime))
|
|
|
|
+ .get()
|
|
|
|
+ .getOutStorageTime();
|
|
|
|
+
|
|
|
|
+ //判断是否为同一批货 出库时间是否一致
|
|
|
|
+ AssertUtil.isMeets(resOutStorageTime, s -> s.compareTo(outStorageTime) == 0, "当前箱码与案件流向不一致!");
|
|
|
|
+
|
|
|
|
+ //修改案件信息
|
|
|
|
+ Long boxCodeCount = inspectionCase.getBoxCodeCount();
|
|
|
|
+ inspectionCase.setBoxCodeCount(++boxCodeCount);
|
|
|
|
+ inspectionCaseMapper.updateById(inspectionCase);
|
|
|
|
+ //添加箱码
|
|
|
|
+ InspectionCaseBoxCode entity = new InspectionCaseBoxCode();
|
|
|
|
+ entity.setBoxCode(boxCode);
|
|
|
|
+ entity.setInspectionCaseId(caseId);
|
|
|
|
+ inspectionCaseBoxCodeMapper.insert(entity);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询涉案箱码列表
|
|
|
|
+ *
|
|
|
|
+ * @param caseId 案件ID
|
|
|
|
+ * @return 涉案箱码列表
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public GetCaseBoxCodeListRes getBoxCodeListByCaseId(final Long caseId) {
|
|
|
|
+ QueryWrapper<InspectionCaseBoxCode> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.eq("inspection_case_id", caseId);
|
|
|
|
+ List<InspectionCaseBoxCode> caseBoxCodes = inspectionCaseBoxCodeMapper.selectList(queryWrapper);
|
|
|
|
+ AssertUtil.isNotEmpty(caseBoxCodes, "未查询到指定案件涉案箱码!");
|
|
|
|
+ List<GetCaseBoxCodeListRes.BoxCodeBean> boxCodeBeans = PojoConverterUtils.copyList(caseBoxCodes, GetCaseBoxCodeListRes.BoxCodeBean.class);
|
|
|
|
+ GetCaseBoxCodeListRes res = new GetCaseBoxCodeListRes();
|
|
|
|
+ res.setBoxCodeList(boxCodeBeans);
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* 查询箱码对应流向信息
|
|
* 查询箱码对应流向信息
|
|
|
|
+ *
|
|
* @param boxCodeList 箱码列表
|
|
* @param boxCodeList 箱码列表
|
|
* @return 对应流向信息列表
|
|
* @return 对应流向信息列表
|
|
*/
|
|
*/
|
|
@@ -381,7 +507,7 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
|
|
//判断流向是否一致
|
|
//判断流向是否一致
|
|
//获取当前流向信息
|
|
//获取当前流向信息
|
|
List<GetBoxCodeRes.FlowBean> flowList = res.getFlowList();
|
|
List<GetBoxCodeRes.FlowBean> flowList = res.getFlowList();
|
|
- LocalDateTime outStorageTime = flowList.stream().filter(s->Objects.nonNull(s.getOutStorageTime())).min(Comparator.comparing(GetBoxCodeRes.FlowBean::getOutStorageTime)).get().getOutStorageTime();
|
|
|
|
|
|
+ LocalDateTime outStorageTime = flowList.stream().filter(s -> Objects.nonNull(s.getOutStorageTime())).min(Comparator.comparing(GetBoxCodeRes.FlowBean::getOutStorageTime)).get().getOutStorageTime();
|
|
boolean outStorageTimeAdd = outStorageTimeSet.add(outStorageTime);
|
|
boolean outStorageTimeAdd = outStorageTimeSet.add(outStorageTime);
|
|
|
|
|
|
//获取当前所以流向节点ID
|
|
//获取当前所以流向节点ID
|
|
@@ -389,10 +515,16 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
|
|
//如果firstFlowNodeIdList 为空 则赋值
|
|
//如果firstFlowNodeIdList 为空 则赋值
|
|
if (CollectionUtil.isEmpty(firstFlowNodeIdList)) {
|
|
if (CollectionUtil.isEmpty(firstFlowNodeIdList)) {
|
|
firstFlowNodeIdList.addAll(nodeIds);
|
|
firstFlowNodeIdList.addAll(nodeIds);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ //先判断节点数量
|
|
|
|
+ if (firstFlowNodeIdList.size() != nodeIds.size()) {
|
|
|
|
+ flowErrBoxCode.add(boxCode);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
+
|
|
//判断节点信息和时间信息是否一致
|
|
//判断节点信息和时间信息是否一致
|
|
- if (!CollectionUtil.containsAll(firstFlowNodeIdList, nodeIds) || !outStorageTimeAdd) {
|
|
|
|
|
|
+ if (!CollectionUtil.containsAll(firstFlowNodeIdList, nodeIds) || outStorageTimeAdd) {
|
|
flowErrBoxCode.add(boxCode);
|
|
flowErrBoxCode.add(boxCode);
|
|
}
|
|
}
|
|
}
|
|
}
|