|
|
|
@ -8,6 +8,7 @@ import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
|
|
|
|
import com.op.common.core.context.SecurityContextHolder;
|
|
|
|
|
import com.op.common.core.exception.CheckedException;
|
|
|
|
|
import com.op.common.core.utils.DateUtils;
|
|
|
|
|
import com.op.common.core.utils.StringUtils;
|
|
|
|
|
import com.op.common.core.utils.uuid.IdUtils;
|
|
|
|
|
import com.op.common.core.web.domain.AjaxResult;
|
|
|
|
|
import com.op.common.log.enums.BusinessType;
|
|
|
|
@ -113,7 +114,7 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
// 将工单信息更新至数据库
|
|
|
|
|
proOrderWorkorderMapper.insertProOrderWorkorder(workOrder);
|
|
|
|
|
// 生成批次表信息并更新至数据库
|
|
|
|
|
setBatch(workBatch, splitOrderDTO.getFormFields(), workOrder.getWorkorderId(),conver);
|
|
|
|
|
setBatch(workBatch, splitOrderDTO.getFormFields(), workOrder.getWorkorderId(), conver);
|
|
|
|
|
|
|
|
|
|
// 如果存在子节点
|
|
|
|
|
if (proOrder.getChildren() != null) {
|
|
|
|
@ -213,7 +214,7 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
@Override
|
|
|
|
|
public void shopOrderSync(List<ProOrder> proOrderList) {
|
|
|
|
|
|
|
|
|
|
for (ProOrder proOrder:proOrderList) {
|
|
|
|
|
for (ProOrder proOrder : proOrderList) {
|
|
|
|
|
String shopOrder = proOrder.getOrderCode();
|
|
|
|
|
if (StringUtil.isBlank(shopOrder)) {
|
|
|
|
|
throw new CheckedException("订单号不能为空!");
|
|
|
|
@ -225,6 +226,74 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 处理表格信息
|
|
|
|
|
*
|
|
|
|
|
* @param orderList
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
@Transactional
|
|
|
|
|
public AjaxResult importOrder(List<ProOrder> orderList) {
|
|
|
|
|
// 数据校验
|
|
|
|
|
AjaxResult checkResult = checkImportOrder(orderList);
|
|
|
|
|
// 如果数据校验成功
|
|
|
|
|
if (checkResult.isSuccess()){
|
|
|
|
|
// 校验数据是否可编辑
|
|
|
|
|
boolean checkEdit = false;
|
|
|
|
|
// 反馈数据
|
|
|
|
|
StringBuilder errMsg = new StringBuilder();
|
|
|
|
|
for (int i = 0; i < orderList.size(); i++) {
|
|
|
|
|
// 当前行操作
|
|
|
|
|
boolean checkOnly = false;
|
|
|
|
|
|
|
|
|
|
List<ProOrderWorkorder> workOrderList = proOrderWorkorderMapper.selectWorkOrderByOrderCode(orderList.get(i).getOrderCode());
|
|
|
|
|
|
|
|
|
|
// 遍历查询工单是否已下达-下达则不允许编辑更新
|
|
|
|
|
for (ProOrderWorkorder workOrder : workOrderList) {
|
|
|
|
|
if (workOrder.getStatus().equals("w1")) {
|
|
|
|
|
checkEdit = true;
|
|
|
|
|
checkOnly = 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){
|
|
|
|
|
order.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
order.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
// 通过订单号code更新订单信息
|
|
|
|
|
proOrderMapper.updateProOrderByOrderCode(order);
|
|
|
|
|
}else {
|
|
|
|
|
// 不存在则创建
|
|
|
|
|
order.setId(IdUtils.fastSimpleUUID());
|
|
|
|
|
order.setOrderType(order.getProdType());
|
|
|
|
|
System.out.println(order);
|
|
|
|
|
proOrderMapper.insertProOrder(order);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return success("信息导入成功!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 如果存在不可编辑信息
|
|
|
|
|
if (checkEdit){
|
|
|
|
|
return error(500,errMsg.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return success("信息导入成功");
|
|
|
|
|
}
|
|
|
|
|
// 校验失败
|
|
|
|
|
return checkResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询订单方法(递归)
|
|
|
|
|
*
|
|
|
|
@ -313,7 +382,6 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改订单
|
|
|
|
|
*
|
|
|
|
@ -451,7 +519,7 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
* @param batchList
|
|
|
|
|
* @param workOrderId
|
|
|
|
|
*/
|
|
|
|
|
private void setBatch(ProOrderWorkorderBatch workBatch, List<Batch> batchList, String workOrderId,Long conver) {
|
|
|
|
|
private void setBatch(ProOrderWorkorderBatch workBatch, List<Batch> batchList, String workOrderId, Long conver) {
|
|
|
|
|
// 工单id
|
|
|
|
|
workBatch.setWorkorderId(workOrderId);
|
|
|
|
|
|
|
|
|
@ -462,7 +530,7 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
// 获取批次号
|
|
|
|
|
workBatch.setBatchCode(batch.getBatchCode());
|
|
|
|
|
// 获取批次数量
|
|
|
|
|
workBatch.setBatchQuantity(batch.getBatchQuantity()*conver);
|
|
|
|
|
workBatch.setBatchQuantity(batch.getBatchQuantity() * conver);
|
|
|
|
|
// 更新至数据库
|
|
|
|
|
proOrderWorkorderBatchMapper.insertProOrderWorkorderBatch(workBatch);
|
|
|
|
|
}
|
|
|
|
@ -492,5 +560,63 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 校验导入订单信息
|
|
|
|
|
*
|
|
|
|
|
* @param orderList
|
|
|
|
|
*/
|
|
|
|
|
public AjaxResult checkImportOrder(List<ProOrder> orderList) {
|
|
|
|
|
|
|
|
|
|
// 传入对象不能为空
|
|
|
|
|
if (orderList.size()==0 || StringUtils.isNull(orderList)){
|
|
|
|
|
return error(500,"导入的订单信息不能为空!信息导入失败!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 循环遍历校验数据是否为空
|
|
|
|
|
for (ProOrder proOrder : orderList) {
|
|
|
|
|
// 计划工厂
|
|
|
|
|
if (proOrder.getPlanFactoryCode().isEmpty() || proOrder.getPlanFactoryCode() == null) {
|
|
|
|
|
return error(500,"计划工厂信息不能为空!信息导入失败!");
|
|
|
|
|
}
|
|
|
|
|
// 订单号
|
|
|
|
|
if (proOrder.getOrderCode().isEmpty() || proOrder.getOrderCode() == null) {
|
|
|
|
|
return error(500,"订单号不能为空!信息导入失败!");
|
|
|
|
|
}
|
|
|
|
|
// 物料号
|
|
|
|
|
if (proOrder.getProdCode().isEmpty() || proOrder.getProdCode() == null) {
|
|
|
|
|
return error(500,"物料号不能为空!信息导入失败!");
|
|
|
|
|
}
|
|
|
|
|
// 物料名称
|
|
|
|
|
if (proOrder.getProdDesc().isEmpty() || proOrder.getProdDesc() == null) {
|
|
|
|
|
return error(500,"物料名称不能为空!信息导入失败!");
|
|
|
|
|
}
|
|
|
|
|
// 订单数量
|
|
|
|
|
if (proOrder.getQuantity() == 0 || proOrder.getProdDesc() == null) {
|
|
|
|
|
return error(500,"订单数量不能为0或空!信息导入失败!");
|
|
|
|
|
}
|
|
|
|
|
// 单位
|
|
|
|
|
if (proOrder.getUnit().isEmpty() || proOrder.getUnit() == null) {
|
|
|
|
|
return error(500,"单位不能为空!信息导入失败!");
|
|
|
|
|
}
|
|
|
|
|
// 订单拆分状态
|
|
|
|
|
if (proOrder.getStatus().isEmpty() || proOrder.getStatus() == null) {
|
|
|
|
|
return error(500,"拆分状态不能为空!信息导入失败!");
|
|
|
|
|
}
|
|
|
|
|
// 产品类型
|
|
|
|
|
if (proOrder.getProdType().isEmpty() || proOrder.getProdType() == null) {
|
|
|
|
|
return error(500,"产品类型不能为空!信息导入失败!");
|
|
|
|
|
}
|
|
|
|
|
// 计划生产日期
|
|
|
|
|
if (proOrder.getPlanProDate() == null || StringUtils.isNull(proOrder.getPlanProDate())) {
|
|
|
|
|
return error(500,"计划生产日期不能为空!信息导入失败!");
|
|
|
|
|
}
|
|
|
|
|
// 计划完成日期
|
|
|
|
|
if (proOrder.getPlanComplete() == null || StringUtils.isNull(proOrder.getPlanComplete())) {
|
|
|
|
|
return error(500,"计划完成日期不能为空!信息导入失败!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|