|
|
|
@ -75,90 +75,52 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
|
|
|
|
|
// 如果不重复
|
|
|
|
|
if (checkout) {
|
|
|
|
|
// 判断是否为底层节点
|
|
|
|
|
int checkEnd = 0;
|
|
|
|
|
// 创建ProOrderWorkorder对象用于数据更新减少io
|
|
|
|
|
ProOrderWorkorder updateWorker = new ProOrderWorkorder();
|
|
|
|
|
ProOrder product = new ProOrder();
|
|
|
|
|
BeanUtils.copyProperties(splitOrderDTO.getProduct(), product);
|
|
|
|
|
// 设置通用属性
|
|
|
|
|
ProOrderWorkorder proOrderWorkorder = setCommonWorkAttribute(product, splitOrderDTO.getProductDate(), splitOrderDTO.getProdLineCode(), splitOrderDTO.getShiftId(),splitOrderDTO.getRouteCode());
|
|
|
|
|
// 生成对应工单表
|
|
|
|
|
// 一级
|
|
|
|
|
ProOrderWorkorder firWorkOrder = setWorkOrder(proOrderWorkorder, product);
|
|
|
|
|
// code
|
|
|
|
|
int endCode = getEndCode(product.getId());
|
|
|
|
|
firWorkOrder.setWorkorderCode(product.getOrderCode()+"-"+endCode);
|
|
|
|
|
// 更新到数据库
|
|
|
|
|
proOrderWorkorderMapper.insertProOrderWorkorder(firWorkOrder);
|
|
|
|
|
|
|
|
|
|
// 创建通用批次表对象
|
|
|
|
|
// 创建订单对象,并将信息copy进去
|
|
|
|
|
ProOrder proOrder = new ProOrder();
|
|
|
|
|
BeanUtils.copyProperties(splitOrderDTO.getProduct(), proOrder);
|
|
|
|
|
// 设置工单通用属性
|
|
|
|
|
ProOrderWorkorder proOrderWorkorder = setCommonWorkAttribute(proOrder, splitOrderDTO.getProductDate(), splitOrderDTO.getProdLineCode(), splitOrderDTO.getShiftId(), splitOrderDTO.getRouteCode());
|
|
|
|
|
// 创建批次表通用对象
|
|
|
|
|
ProOrderWorkorderBatch workBatch = setCommonBatchAttribute();
|
|
|
|
|
// 生成批次表并更新到数据库
|
|
|
|
|
setBatch(workBatch, splitOrderDTO.getFormFields(), firWorkOrder.getWorkorderId());
|
|
|
|
|
|
|
|
|
|
// 二级
|
|
|
|
|
if (splitOrderDTO.getProduct().getChildren() != null) {
|
|
|
|
|
// 判断加1
|
|
|
|
|
checkEnd += 1;
|
|
|
|
|
|
|
|
|
|
List<ProOrderDTO> secProOrderList = splitOrderDTO.getProduct().getChildren();
|
|
|
|
|
BeanUtils.copyProperties(secProOrderList.get(0), product);
|
|
|
|
|
// 设置父工单
|
|
|
|
|
proOrderWorkorder.setParentOrder(firWorkOrder.getWorkorderCode());
|
|
|
|
|
ProOrderWorkorder secWorkOrder = setWorkOrder(proOrderWorkorder, product);
|
|
|
|
|
// code
|
|
|
|
|
secWorkOrder.setWorkorderCode(product.getOrderCode()+"-"+(endCode+1));
|
|
|
|
|
// 更新到数据库
|
|
|
|
|
proOrderWorkorderMapper.insertProOrderWorkorder(secWorkOrder);
|
|
|
|
|
// 生成批次表并更新到数据库
|
|
|
|
|
setBatch(workBatch, splitOrderDTO.getFormFields(), secWorkOrder.getWorkorderId());
|
|
|
|
|
|
|
|
|
|
// 三级
|
|
|
|
|
if (secProOrderList.get(0).getChildren() != null) {
|
|
|
|
|
// 判断加1
|
|
|
|
|
checkEnd += 1;
|
|
|
|
|
|
|
|
|
|
List<ProOrderDTO> thiProOrderList = secProOrderList.get(0).getChildren();
|
|
|
|
|
BeanUtils.copyProperties(thiProOrderList.get(0), product);
|
|
|
|
|
// 设置父工单
|
|
|
|
|
proOrderWorkorder.setParentOrder(secWorkOrder.getWorkorderCode());
|
|
|
|
|
ProOrderWorkorder thiWorkOrder = setWorkOrder(proOrderWorkorder, product);
|
|
|
|
|
// 设置为底层节点
|
|
|
|
|
thiWorkOrder.setIsEnd(1);
|
|
|
|
|
// code
|
|
|
|
|
thiWorkOrder.setWorkorderCode(product.getOrderCode()+"-"+(endCode+2));
|
|
|
|
|
// 更新到数据库
|
|
|
|
|
proOrderWorkorderMapper.insertProOrderWorkorder(thiWorkOrder);
|
|
|
|
|
// 生成批次表并更新到数据库
|
|
|
|
|
setBatch(workBatch, splitOrderDTO.getFormFields(), thiWorkOrder.getWorkorderId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 设置为底层节点
|
|
|
|
|
if (checkEnd == 1){
|
|
|
|
|
updateWorker.setWorkorderId(secWorkOrder.getWorkorderId());
|
|
|
|
|
updateWorker.setIsEnd(1);
|
|
|
|
|
proOrderWorkorderMapper.updateProOrderWorkorder(updateWorker);
|
|
|
|
|
// code
|
|
|
|
|
int endCode = getEndCode(proOrder.getId());
|
|
|
|
|
|
|
|
|
|
// 父工单code
|
|
|
|
|
StringBuilder parentOrder = new StringBuilder("0");
|
|
|
|
|
boolean run = true;
|
|
|
|
|
while (run) {
|
|
|
|
|
// 先进行当前订单拆分操作
|
|
|
|
|
// 1.设置工单信息,并更新订单信息至数据库
|
|
|
|
|
ProOrderWorkorder workOrder = setWorkOrder(proOrderWorkorder, proOrder);
|
|
|
|
|
// 2.设置工单编码
|
|
|
|
|
workOrder.setWorkorderCode(proOrder.getOrderCode() + "-" + endCode);
|
|
|
|
|
// 3.设置父工单
|
|
|
|
|
workOrder.setParentOrder(parentOrder.toString());
|
|
|
|
|
// 将工单信息更新至数据库
|
|
|
|
|
proOrderWorkorderMapper.insertProOrderWorkorder(workOrder);
|
|
|
|
|
// 生成批次表信息并更新至数据库
|
|
|
|
|
setBatch(workBatch, splitOrderDTO.getFormFields(), workOrder.getWorkorderId());
|
|
|
|
|
|
|
|
|
|
// 如果存在子节点
|
|
|
|
|
if (proOrder.getChildren() != null) {
|
|
|
|
|
ProOrderDTO newProOrder = (ProOrderDTO) proOrder.getChildren().get(0);
|
|
|
|
|
// 将child信息重新赋值给proOrder
|
|
|
|
|
BeanUtils.copyProperties(newProOrder, proOrder);
|
|
|
|
|
// 存放父工单code
|
|
|
|
|
parentOrder.delete(0, parentOrder.length());
|
|
|
|
|
parentOrder.append(workOrder.getWorkorderCode());
|
|
|
|
|
// code自增
|
|
|
|
|
endCode++;
|
|
|
|
|
} else {
|
|
|
|
|
// 设置子节点is_end字段信息
|
|
|
|
|
workOrder.setIsEnd(1);
|
|
|
|
|
// 更新数据库记录信息
|
|
|
|
|
proOrderWorkorderMapper.updateProOrderWorkorder(workOrder);
|
|
|
|
|
// 结束循环
|
|
|
|
|
run = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 设置为底层节点
|
|
|
|
|
if (checkEnd == 1){
|
|
|
|
|
updateWorker.setWorkorderId(firWorkOrder.getWorkorderId());
|
|
|
|
|
updateWorker.setIsEnd(1);
|
|
|
|
|
proOrderWorkorderMapper.updateProOrderWorkorder(updateWorker);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 母工单设置底层节点(只有母工单的情况下)
|
|
|
|
|
if (checkEnd == 0) {
|
|
|
|
|
firWorkOrder.setIsEnd(1);
|
|
|
|
|
// 更新到数据库
|
|
|
|
|
proOrderWorkorderMapper.updateProOrderWorkorder(firWorkOrder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return success();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return error(500, "批次号不能重复");
|
|
|
|
@ -175,45 +137,46 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
public AjaxResult getWorkOrderList(String id) {
|
|
|
|
|
// 通过订单id查询所有工单信息list
|
|
|
|
|
List<ProOrderWorkorder> proOrderWorkorderList = proOrderWorkorderMapper.selectFirWorkOrder(id);
|
|
|
|
|
// 母工单循环遍历
|
|
|
|
|
for (int i = 0; i < proOrderWorkorderList.size(); i++) {
|
|
|
|
|
// 通过班次id查询班次名称
|
|
|
|
|
String shiftDesc = proOrderMapper.selectShiftNameById(proOrderWorkorderList.get(i).getShiftId());
|
|
|
|
|
// 通过设备code查询出机型名称
|
|
|
|
|
String prodLineName = proOrderMapper.selectProdLineName(proOrderWorkorderList.get(i).getProdLineCode());
|
|
|
|
|
// 通过工单id查询批次号
|
|
|
|
|
List<String> batchCodeList = proOrderMapper.selectBatchCodesById(proOrderWorkorderList.get(i).getWorkorderId());
|
|
|
|
|
List<StringBuilder> batchCodes = new ArrayList<>();
|
|
|
|
|
// 格式化数据
|
|
|
|
|
for (int j = 0; j < batchCodeList.size(); j++) {
|
|
|
|
|
batchCodes.add(new StringBuilder(batchCodeList.get(j)).append(";").append("\n"));
|
|
|
|
|
}
|
|
|
|
|
// 通过母工单workorder_id查询子工单
|
|
|
|
|
// 二级
|
|
|
|
|
List<ProOrderWorkorder> secProOrderWorkorder = proOrderWorkorderMapper.selectChildWorkOrder(proOrderWorkorderList.get(i).getWorkorderCode());
|
|
|
|
|
if (secProOrderWorkorder.size() > 0 && secProOrderWorkorder != null) {
|
|
|
|
|
// 三级
|
|
|
|
|
List<ProOrderWorkorder> thiProOrderWorkorders = proOrderWorkorderMapper.selectChildWorkOrder(secProOrderWorkorder.get(0).getWorkorderCode());
|
|
|
|
|
if (thiProOrderWorkorders.size() > 0 && thiProOrderWorkorders != null) {
|
|
|
|
|
// 将三级放入二级child
|
|
|
|
|
thiProOrderWorkorders.get(0).setShiftDesc(shiftDesc);
|
|
|
|
|
thiProOrderWorkorders.get(0).setProdLineCode(prodLineName);
|
|
|
|
|
thiProOrderWorkorders.get(0).setBatchCodeList(batchCodes);
|
|
|
|
|
secProOrderWorkorder.get(0).setChildren(thiProOrderWorkorders);
|
|
|
|
|
}
|
|
|
|
|
// 将二级放入到母工单child
|
|
|
|
|
secProOrderWorkorder.get(0).setShiftDesc(shiftDesc);
|
|
|
|
|
secProOrderWorkorder.get(0).setProdLineCode(prodLineName);
|
|
|
|
|
secProOrderWorkorder.get(0).setBatchCodeList(batchCodes);
|
|
|
|
|
proOrderWorkorderList.get(i).setChildren(secProOrderWorkorder);
|
|
|
|
|
}
|
|
|
|
|
proOrderWorkorderList.get(i).setShiftDesc(shiftDesc);
|
|
|
|
|
proOrderWorkorderList.get(i).setProdLineCode(prodLineName);
|
|
|
|
|
proOrderWorkorderList.get(i).setBatchCodeList(batchCodes);
|
|
|
|
|
|
|
|
|
|
for (ProOrderWorkorder proOrderWorkorder : proOrderWorkorderList) {
|
|
|
|
|
formatProOrderWorkorder(proOrderWorkorder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return success(proOrderWorkorderList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 格式化工单信息(递归处理)
|
|
|
|
|
*
|
|
|
|
|
* @param proOrderWorkorder
|
|
|
|
|
*/
|
|
|
|
|
private void formatProOrderWorkorder(ProOrderWorkorder proOrderWorkorder) {
|
|
|
|
|
// 通过班次id查询班次名称
|
|
|
|
|
String shiftDesc = proOrderMapper.selectShiftNameById(proOrderWorkorder.getShiftId());
|
|
|
|
|
// 通过设备code查询出机型名称
|
|
|
|
|
String prodLineName = proOrderMapper.selectProdLineName(proOrderWorkorder.getProdLineCode());
|
|
|
|
|
// 通过工单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.setProdLineCode(prodLineName);
|
|
|
|
|
proOrderWorkorder.setBatchCodeList(batchCodes);
|
|
|
|
|
|
|
|
|
|
// 通过母工单workorder_id查询子工单
|
|
|
|
|
List<ProOrderWorkorder> childWorkorders = proOrderWorkorderMapper.selectChildWorkOrder(proOrderWorkorder.getWorkorderCode());
|
|
|
|
|
if (!childWorkorders.isEmpty()) {
|
|
|
|
|
for (ProOrderWorkorder childWorkorder : childWorkorders) {
|
|
|
|
|
formatProOrderWorkorder(childWorkorder); // 递归处理子工单
|
|
|
|
|
}
|
|
|
|
|
proOrderWorkorder.setChildren(childWorkorders); // 设置子工单列表
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取当前订单信息列表
|
|
|
|
|
*
|
|
|
|
@ -223,25 +186,32 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public AjaxResult getOrderList(String id) {
|
|
|
|
|
// 注意判空不为空则放入 (避免空指针)
|
|
|
|
|
// 通过母工单id查询母订单详情
|
|
|
|
|
ProOrder proOrder = proOrderMapper.selectProOrderById(id);
|
|
|
|
|
// 查询二级
|
|
|
|
|
List<ProOrder> secProOrderList = proOrderMapper.selectChildProOrderByCode(proOrder.getOrderCode());
|
|
|
|
|
if (secProOrderList != null || secProOrderList.size() > 0) {
|
|
|
|
|
// 查询三级
|
|
|
|
|
List<ProOrder> thiProOrderList = proOrderMapper.selectChildProOrderByCode(secProOrderList.get(0).getOrderCode());
|
|
|
|
|
if (thiProOrderList != null || thiProOrderList.size() > 0) {
|
|
|
|
|
// 将三级Order放入二级
|
|
|
|
|
secProOrderList.get(0).setChildren(thiProOrderList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 将二级Order放入母订单
|
|
|
|
|
proOrder.setChildren(secProOrderList);
|
|
|
|
|
// 递归查询子订单
|
|
|
|
|
recursiveQueryChildOrder(proOrder);
|
|
|
|
|
|
|
|
|
|
return success(proOrder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询订单方法(递归)
|
|
|
|
|
*
|
|
|
|
|
* @param proOrder
|
|
|
|
|
*/
|
|
|
|
|
private void recursiveQueryChildOrder(ProOrder proOrder) {
|
|
|
|
|
// 查询子订单列表
|
|
|
|
|
List<ProOrder> childOrders = proOrderMapper.selectChildProOrderByCode(proOrder.getOrderCode());
|
|
|
|
|
if (!childOrders.isEmpty()) {
|
|
|
|
|
// 递归处理子订单
|
|
|
|
|
for (ProOrder childOrder : childOrders) {
|
|
|
|
|
recursiveQueryChildOrder(childOrder);
|
|
|
|
|
}
|
|
|
|
|
// 将子订单列表设置到当前订单对象
|
|
|
|
|
proOrder.setChildren(childOrders);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取成型机
|
|
|
|
|
*
|
|
|
|
@ -250,13 +220,13 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public LineAndShiftVo getProdLineShift(String type) {
|
|
|
|
|
if (type.equals("white")){
|
|
|
|
|
if (type.equals("white")) {
|
|
|
|
|
LineAndShiftVo lineAndShiftVo = new LineAndShiftVo(proOrderMapper.selectProdLine(),
|
|
|
|
|
proOrderMapper.selectProShift(),proRouteMapper.selectAllRoute());
|
|
|
|
|
proOrderMapper.selectProShift(), proRouteMapper.selectAllRoute());
|
|
|
|
|
return lineAndShiftVo;
|
|
|
|
|
}
|
|
|
|
|
LineAndShiftVo lineAndShiftVo = new LineAndShiftVo(proOrderMapper.selectPackageLine(),
|
|
|
|
|
proOrderMapper.selectProShift(),proRouteMapper.selectAllRoute());
|
|
|
|
|
proOrderMapper.selectProShift(), proRouteMapper.selectAllRoute());
|
|
|
|
|
return lineAndShiftVo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -299,7 +269,7 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
proOrder.setParentOrder("0");
|
|
|
|
|
proOrder.setStatus("o0");
|
|
|
|
|
proOrder.setOrderType(proOrder.getProdType());
|
|
|
|
|
proOrder.setOrderCode("DD"+ DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSSsss, date));
|
|
|
|
|
proOrder.setOrderCode("DD" + DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSSsss, date));
|
|
|
|
|
proOrder.setCreateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
proOrder.setCreateTime(date);
|
|
|
|
|
proOrder.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
@ -355,7 +325,7 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
* @param proOrder
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private ProOrderWorkorder setCommonWorkAttribute(ProOrder proOrder, Date date, String proLineCode, String shiftId,String routeCode) {
|
|
|
|
|
private ProOrderWorkorder setCommonWorkAttribute(ProOrder proOrder, Date date, String proLineCode, String shiftId, String routeCode) {
|
|
|
|
|
ProOrderWorkorder proOrderWorkorder = new ProOrderWorkorder();
|
|
|
|
|
// 更新者
|
|
|
|
|
proOrderWorkorder.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
@ -382,6 +352,8 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
proOrderWorkorder.setStatus("w0");
|
|
|
|
|
// 工艺编码
|
|
|
|
|
proOrderWorkorder.setRouteCode(routeCode);
|
|
|
|
|
// 工厂编码
|
|
|
|
|
proOrderWorkorder.setFactoryCode(proOrder.getPlanFactoryCode());
|
|
|
|
|
return proOrderWorkorder;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -448,11 +420,11 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
private void setBatch(ProOrderWorkorderBatch workBatch, List<Batch> batchList, String workOrderId) {
|
|
|
|
|
// 工单id
|
|
|
|
|
workBatch.setWorkorderId(workOrderId);
|
|
|
|
|
|
|
|
|
|
// 产品类型
|
|
|
|
|
for (int i = 0; i < batchList.size(); i++) {
|
|
|
|
|
for (Batch batch : batchList) {
|
|
|
|
|
// 生成批次id
|
|
|
|
|
workBatch.setBatchId(IdUtils.fastSimpleUUID());
|
|
|
|
|
Batch batch = batchList.get(i);
|
|
|
|
|
// 获取批次号
|
|
|
|
|
workBatch.setBatchCode(batch.getBatchCode());
|
|
|
|
|
// 获取批次数量
|
|
|
|
@ -460,16 +432,30 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
// 更新至数据库
|
|
|
|
|
proOrderWorkorderBatchMapper.insertProOrderWorkorderBatch(workBatch);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// // 产品类型
|
|
|
|
|
// for (int i = 0; i < batchList.size(); i++) {
|
|
|
|
|
// // 生成批次id
|
|
|
|
|
// workBatch.setBatchId(IdUtils.fastSimpleUUID());
|
|
|
|
|
// Batch batch = batchList.get(i);
|
|
|
|
|
// // 获取批次号
|
|
|
|
|
// workBatch.setBatchCode(batch.getBatchCode());
|
|
|
|
|
// // 获取批次数量
|
|
|
|
|
// workBatch.setBatchQuantity(batch.getBatchQuantity());
|
|
|
|
|
// // 更新至数据库
|
|
|
|
|
// proOrderWorkorderBatchMapper.insertProOrderWorkorderBatch(workBatch);
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取工单尾号code
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private int getEndCode(String id){
|
|
|
|
|
private int getEndCode(String id) {
|
|
|
|
|
String workOrderCode = proOrderWorkorderMapper.selectEndWorkOrder(id);
|
|
|
|
|
if (workOrderCode == null || workOrderCode.equals("")){
|
|
|
|
|
if (workOrderCode == null || workOrderCode.equals("")) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -479,7 +465,7 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
String substring = workOrderCode.substring(hyphenIndex + 1); // 从 '-' 的下一位开始截取到字符串的末尾
|
|
|
|
|
// 将截取到的字符串转换为整数
|
|
|
|
|
int endCode = Integer.parseInt(substring);
|
|
|
|
|
return endCode+1;
|
|
|
|
|
return endCode + 1;
|
|
|
|
|
} else {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|