|
|
|
@ -1,15 +1,31 @@
|
|
|
|
|
package com.op.plan.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
|
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
|
|
import com.op.common.core.context.SecurityContextHolder;
|
|
|
|
|
import com.op.common.core.utils.DateUtils;
|
|
|
|
|
import com.op.common.core.utils.uuid.IdUtils;
|
|
|
|
|
import com.op.common.core.web.domain.AjaxResult;
|
|
|
|
|
import com.op.plan.domain.ProOrder;
|
|
|
|
|
import com.op.plan.domain.ProOrderWorkorder;
|
|
|
|
|
import com.op.plan.domain.ProRoute;
|
|
|
|
|
import com.op.plan.domain.ProShift;
|
|
|
|
|
import com.op.plan.domain.vo.CascaderDTO;
|
|
|
|
|
import com.op.plan.domain.vo.SplitProWhiteOrderVo;
|
|
|
|
|
import com.op.plan.mapper.ProOrderMapper;
|
|
|
|
|
import com.op.plan.mapper.ProOrderWorkorderMapper;
|
|
|
|
|
import com.op.plan.mapper.ProRouteMapper;
|
|
|
|
|
import com.op.plan.mapper.ProWhiteOrderMapper;
|
|
|
|
|
import com.op.plan.service.IProWhiteOrderService;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.web.context.request.RequestContextHolder;
|
|
|
|
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 白坯订单管理Service业务层处理
|
|
|
|
@ -22,6 +38,12 @@ public class ProWhiteOrderServiceImpl implements IProWhiteOrderService {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ProWhiteOrderMapper proWhiteOrderMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ProRouteMapper proRouteMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ProOrderWorkorderMapper proOrderWorkorderMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ProOrderMapper proOrderMapper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询白坯订单管理
|
|
|
|
@ -53,9 +75,89 @@ public class ProWhiteOrderServiceImpl implements IProWhiteOrderService {
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
@Transactional
|
|
|
|
|
public int insertProOrder(ProOrder proOrder) {
|
|
|
|
|
//获取当前所选工厂
|
|
|
|
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
|
|
|
|
String key = "#header.poolName";
|
|
|
|
|
String str = request.getHeader(key.substring(8));
|
|
|
|
|
int index = str.indexOf("_");
|
|
|
|
|
String factory = str.substring(index + 1);
|
|
|
|
|
|
|
|
|
|
int num = 1;
|
|
|
|
|
// 创建主订单
|
|
|
|
|
proOrder.setPlanFactoryCode(factory);
|
|
|
|
|
proOrder.setId(IdUtils.fastSimpleUUID());
|
|
|
|
|
proOrder.setParentOrder("0");
|
|
|
|
|
proOrder.setStatus("o0");
|
|
|
|
|
proOrder.setQuantitySplit(0L);
|
|
|
|
|
proOrder.setOrderType(proOrder.getProdType());
|
|
|
|
|
proOrder.setOrderCode("DD" + DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSSsss, DateUtils.getNowDate()));
|
|
|
|
|
proOrder.setCreateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
proOrder.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
return proWhiteOrderMapper.insertProOrder(proOrder);
|
|
|
|
|
proOrder.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
proOrder.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
|
|
|
|
|
// 存储主订单的Code
|
|
|
|
|
String orderCode = proOrder.getOrderCode();
|
|
|
|
|
|
|
|
|
|
// 存放物料code
|
|
|
|
|
String[] prodCodes = proOrder.getProdCode().split(",\\s*");
|
|
|
|
|
String[] prodDescs = proOrder.getProdDesc().split(",\\s*");
|
|
|
|
|
|
|
|
|
|
// 主订单插入数据库
|
|
|
|
|
proOrder.setProdCode("");
|
|
|
|
|
proOrder.setProdDesc("");
|
|
|
|
|
proWhiteOrderMapper.insertProOrder(proOrder);
|
|
|
|
|
|
|
|
|
|
System.out.println("源code---->"+proOrder.getProdCode());
|
|
|
|
|
System.out.println("源desc---->"+proOrder.getProdDesc());
|
|
|
|
|
|
|
|
|
|
System.out.println("code---------->");
|
|
|
|
|
for (String code : prodCodes) {
|
|
|
|
|
System.out.println(code);
|
|
|
|
|
}
|
|
|
|
|
System.out.println("desc----------->");
|
|
|
|
|
for (String desc : prodDescs) {
|
|
|
|
|
System.out.println(desc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
System.out.println("这里是母订单信息");
|
|
|
|
|
System.out.println("母订单code"+proOrder.getOrderCode());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println("这里是子订单信息");
|
|
|
|
|
|
|
|
|
|
// 设置子订单信息
|
|
|
|
|
for (int i = 0; i< prodCodes.length; i++){
|
|
|
|
|
|
|
|
|
|
ProOrder childProOrder = new ProOrder();
|
|
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(proOrder,childProOrder);
|
|
|
|
|
|
|
|
|
|
childProOrder.setQuantity(0L);
|
|
|
|
|
childProOrder.setQuantitySplit(0L);
|
|
|
|
|
childProOrder.setProdDesc(prodDescs[i]);
|
|
|
|
|
childProOrder.setProdCode(prodCodes[i]);
|
|
|
|
|
childProOrder.setPlanFactoryCode(factory);
|
|
|
|
|
childProOrder.setId(IdUtils.fastSimpleUUID());
|
|
|
|
|
childProOrder.setParentOrder(orderCode);
|
|
|
|
|
childProOrder.setStatus("o0");
|
|
|
|
|
childProOrder.setOrderType(proOrder.getProdType());
|
|
|
|
|
childProOrder.setOrderCode(orderCode+"-"+num++);
|
|
|
|
|
childProOrder.setCreateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
childProOrder.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
childProOrder.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
childProOrder.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
// 将子订单插入数据库
|
|
|
|
|
proWhiteOrderMapper.insertProOrder(childProOrder);
|
|
|
|
|
|
|
|
|
|
System.out.println("子订单code"+i+childProOrder.getOrderCode());
|
|
|
|
|
System.out.println("子订单parentCode"+i+childProOrder.getParentOrder());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -92,4 +194,100 @@ public class ProWhiteOrderServiceImpl implements IProWhiteOrderService {
|
|
|
|
|
return proWhiteOrderMapper.deleteProOrderById(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 通过proOrder获得拆分信息
|
|
|
|
|
* 1.获取订单信息
|
|
|
|
|
* 2.获取工单信息
|
|
|
|
|
* 3.获取班次信息
|
|
|
|
|
* 4.获取工艺信息
|
|
|
|
|
* @param proOrder
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public AjaxResult getSplitInfo(ProOrder proOrder) {
|
|
|
|
|
// 创建返回实体对象
|
|
|
|
|
SplitProWhiteOrderVo splitProWhiteOrderVo = new SplitProWhiteOrderVo();
|
|
|
|
|
|
|
|
|
|
// 获取订单信息list
|
|
|
|
|
ProOrder parentOrder = proWhiteOrderMapper.selectProOrderByParentOrder(proOrder.getParentOrder());
|
|
|
|
|
// 格式化订单信息
|
|
|
|
|
List<ProOrder> childOrderList = new ArrayList<>();
|
|
|
|
|
childOrderList.add(proOrder);
|
|
|
|
|
parentOrder.setChildren(childOrderList);
|
|
|
|
|
// 将订单信息放入返回实体
|
|
|
|
|
List<ProOrder> orderList = new ArrayList<>();
|
|
|
|
|
orderList.add(parentOrder);
|
|
|
|
|
splitProWhiteOrderVo.setProOrderList(orderList);
|
|
|
|
|
|
|
|
|
|
// 获取工单信息
|
|
|
|
|
List<ProOrderWorkorder> workOrderList = proOrderWorkorderMapper.selectWorkOrderByOrderCode(proOrder.getOrderCode());
|
|
|
|
|
for (ProOrderWorkorder workOrder : workOrderList) {
|
|
|
|
|
formatProOrderWorkorder(workOrder);
|
|
|
|
|
}
|
|
|
|
|
// 将工单信息list放入返回实体
|
|
|
|
|
if (workOrderList.size() > 0) {
|
|
|
|
|
splitProWhiteOrderVo.setProOrderWorkorderList(workOrderList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取班次信息
|
|
|
|
|
List<ProShift> shiftList = proWhiteOrderMapper.selectProShift();
|
|
|
|
|
// 将班次信息list放入返回实体
|
|
|
|
|
splitProWhiteOrderVo.setProShiftList(shiftList);
|
|
|
|
|
|
|
|
|
|
// 获取工艺信息
|
|
|
|
|
List<ProRoute> routeList = proRouteMapper.selectRouteByItemCode(proOrder.getProdCode());
|
|
|
|
|
// 将工艺信息list放入返回实体
|
|
|
|
|
splitProWhiteOrderVo.setRouteList(routeList);
|
|
|
|
|
|
|
|
|
|
return AjaxResult.success(splitProWhiteOrderVo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 格式化工单信息(递归处理)
|
|
|
|
|
*
|
|
|
|
|
* @param proOrderWorkorder
|
|
|
|
|
*/
|
|
|
|
|
private void formatProOrderWorkorder(ProOrderWorkorder proOrderWorkorder) {
|
|
|
|
|
// 通过班次id查询班次名称
|
|
|
|
|
String shiftDesc = proOrderMapper.selectShiftNameById(proOrderWorkorder.getShiftId());
|
|
|
|
|
|
|
|
|
|
StringBuilder prodLineName = new StringBuilder("");
|
|
|
|
|
StringBuilder equipCods = new StringBuilder("'");
|
|
|
|
|
JSONArray codeArray = JSONArray.parseArray(proOrderWorkorder.getProdLineCode());
|
|
|
|
|
for(int c=0;c<codeArray.size();c++){
|
|
|
|
|
equipCods.append(codeArray.getJSONArray(c).getString(1));
|
|
|
|
|
equipCods.append("','");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<String, CascaderDTO> equipMap = proOrderMapper.getEquipInfoByCodes(equipCods.substring(1));//设备字典
|
|
|
|
|
Set<String> keys = equipMap.keySet();
|
|
|
|
|
for (String key : keys) {
|
|
|
|
|
prodLineName.append(equipMap.get(key).getLabel());
|
|
|
|
|
prodLineName.append(",");
|
|
|
|
|
}
|
|
|
|
|
proOrderWorkorder.setProdLineCode(prodLineName.toString());
|
|
|
|
|
|
|
|
|
|
// 通过工单id查询批次号
|
|
|
|
|
List<String> batchCodeList = proOrderMapper.selectBatchCodesById(proOrderWorkorder.getWorkorderId());
|
|
|
|
|
List<StringBuilder> batchCodes = new ArrayList<>();
|
|
|
|
|
// 格式化数据
|
|
|
|
|
for (String batchCode : batchCodeList) {
|
|
|
|
|
batchCodes.add(new StringBuilder(batchCode).append(";").append("\n"));
|
|
|
|
|
}
|
|
|
|
|
// 将查询结果设置到当前工单对象
|
|
|
|
|
proOrderWorkorder.setShiftDesc(shiftDesc);
|
|
|
|
|
|
|
|
|
|
proOrderWorkorder.setBatchCodeList(batchCodes);
|
|
|
|
|
|
|
|
|
|
// 通过母工单workorder_id查询子工单
|
|
|
|
|
List<ProOrderWorkorder> childWorkorders = proOrderWorkorderMapper.selectChildWorkOrder(proOrderWorkorder.getWorkorderCode());
|
|
|
|
|
if (!childWorkorders.isEmpty()) {
|
|
|
|
|
for (ProOrderWorkorder childWorkorder : childWorkorders) {
|
|
|
|
|
formatProOrderWorkorder(childWorkorder); // 递归处理子工单
|
|
|
|
|
}
|
|
|
|
|
proOrderWorkorder.setChildren(childWorkorders); // 设置子工单列表
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|