订单管理模块(导入逻辑变更-已有湿料计划不可更改-工单已下达不可更改)

highway
wws 1 year ago
parent 0f1d137aff
commit c41b56b0f3

@ -1,6 +1,5 @@
package com.op.plan.service.impl;
import java.sql.SQLException;
import java.util.*;
import java.util.stream.Collectors;
@ -17,15 +16,12 @@ import com.op.plan.domain.*;
import com.op.plan.domain.dto.ProOrderDTO;
import com.op.plan.domain.dto.SplitOrderDTO;
import com.op.plan.domain.vo.LineAndShiftVo;
import com.op.plan.mapper.ProOrderWorkorderBatchMapper;
import com.op.plan.mapper.ProOrderWorkorderMapper;
import com.op.plan.mapper.ProRouteMapper;
import com.op.plan.mapper.*;
import com.op.system.api.RemoteSapService;
import com.op.system.api.model.SapProOrder;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.op.plan.mapper.ProOrderMapper;
import com.op.plan.service.IProOrderService;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
@ -53,6 +49,8 @@ public class ProOrderServiceImpl implements IProOrderService {
private ProOrderWorkorderBatchMapper proOrderWorkorderBatchMapper;
@Autowired
private ProRouteMapper proRouteMapper;
@Autowired
private ProWetMaterialPlanDetailMapper proWetMaterialPlanDetailMapper;
@Autowired
private RemoteSapService remoteSapService;
@ -311,66 +309,80 @@ public class ProOrderServiceImpl implements IProOrderService {
for (int i = 0; i < orderList.size(); i++) {
// 当前行操作
boolean checkOnly = false;
boolean checkPlan = false;
List<ProOrderWorkorder> workOrderList = proOrderWorkorderMapper.selectWorkOrderByOrderCode(orderList.get(i).getOrderCode());
// 遍历查询工单是否已下达-下达则不允许编辑更新
for (ProOrderWorkorder workOrder : workOrderList) {
// 如果工单已经下达
if (workOrder.getStatus().equals("w1")) {
checkEdit = true;
checkOnly = true;
}
// 如果工单已有湿料计划
ProWetMaterialPlanDetail detail = proWetMaterialPlanDetailMapper.selectProWetMaterialPlanDetailByWorkId(workOrder.getWorkorderId());
if (detail != null){
checkEdit = true;
checkPlan = true;
}
}
// 组装工单已下达反馈信息
if (checkOnly) {
errMsg.append("第" + (i + 1) + "行:" + "订单号为:" + orderList.get(i).getOrderCode() + ",该订单下工单已下达,不允许更新;" + "<br/>");
return error(500, errMsg.toString());
} else {
// 正常插入与更新操作
for (ProOrder order : orderList) {
// 查询订单是否存在
ProOrder proOrder = proOrderMapper.selectProOrderByOrderCode(order.getOrderCode());
// 如果存在
if (proOrder != null) {
// 通过订单Code查询该订单下的所有工单id-用于删除批次表
List<ProOrderWorkorder> childWorkOrderList = proOrderWorkorderMapper.selectWorkOrderByOrderCode(proOrder.getOrderCode());
// 存在工单
if (childWorkOrderList.size() > 0){
// 将获得的工单id封装
List<String> ids = new ArrayList<>();
for (ProOrderWorkorder workOrder : childWorkOrderList) {
ids.add(workOrder.getWorkorderId());
}
String[] workorderIds = (String[])ids.toArray(new String[ids.size()]);
// 删除所有该订单下的工单
proOrderWorkorderMapper.deleteProOrderWorkorderByOrderId(proOrder.getId());
// 删除工单下的所有批次表信息
proOrderWorkorderBatchMapper.deleteProOrderWorkorderBatchByWorkorderIds(workorderIds);
}
// 更新字段
order.setStatus("o0");
order.setQuantitySplit(0L);
order.setUpdateBy(SecurityContextHolder.getUserName());
order.setUpdateTime(DateUtils.getNowDate());
// 通过订单号code更新订单信息
proOrderMapper.updateProOrderByOrderCode(order);
} else {
// 不存在则创建
order.setId(IdUtils.fastSimpleUUID());
order.setOrderType(order.getProdType());
order.setParentOrder("0");
proOrderMapper.insertProOrder(order);
}
}
}
// 组装已有湿料计划反馈信息
if (checkPlan) {
errMsg.append("第" + (i + 1) + "行:" + "订单号为:" + orderList.get(i).getOrderCode() + ",该订单下工单已有湿料计划,不允许更新;" + "<br/>");
}
}
// 如果存在不可编辑信息
if (checkEdit) {
return error(500, errMsg.toString());
}
// 正常插入与更新操作
for (ProOrder order : orderList) {
// 查询订单是否存在
ProOrder proOrder = proOrderMapper.selectProOrderByOrderCode(order.getOrderCode());
// 如果存在
if (proOrder != null) {
// 通过订单Code查询该订单下的所有工单id-用于删除批次表
List<ProOrderWorkorder> childWorkOrderList = proOrderWorkorderMapper.selectWorkOrderByOrderCode(proOrder.getOrderCode());
// 存在工单
if (childWorkOrderList.size() > 0){
// 将获得的工单id封装
List<String> ids = new ArrayList<>();
for (ProOrderWorkorder workOrder : childWorkOrderList) {
ids.add(workOrder.getWorkorderId());
}
String[] workorderIds = (String[])ids.toArray(new String[ids.size()]);
// 删除所有该订单下的工单
proOrderWorkorderMapper.deleteProOrderWorkorderByOrderId(proOrder.getId());
// 删除工单下的所有批次表信息
proOrderWorkorderBatchMapper.deleteProOrderWorkorderBatchByWorkorderIds(workorderIds);
}
// 更新字段
order.setStatus("o0");
order.setQuantitySplit(0L);
order.setUpdateBy(SecurityContextHolder.getUserName());
order.setUpdateTime(DateUtils.getNowDate());
// 通过订单号code更新订单信息
proOrderMapper.updateProOrderByOrderCode(order);
} else {
// 不存在则创建
order.setId(IdUtils.fastSimpleUUID());
order.setOrderType(order.getProdType());
order.setParentOrder("0");
proOrderMapper.insertProOrder(order);
}
}
return success("信息导入成功");
}
// 校验失败

Loading…
Cancel
Save