|
|
|
@ -3,6 +3,7 @@ package com.op.mes.service.impl;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
|
|
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
|
|
|
|
import com.op.common.core.context.SecurityContextHolder;
|
|
|
|
|
import com.op.common.core.utils.DateUtils;
|
|
|
|
|
import com.op.common.core.utils.uuid.IdUtils;
|
|
|
|
@ -13,7 +14,6 @@ import com.op.mes.domain.dto.SplitOrderDTO;
|
|
|
|
|
import com.op.mes.domain.vo.LineAndShiftVo;
|
|
|
|
|
import com.op.mes.mapper.ProOrderWorkorderBatchMapper;
|
|
|
|
|
import com.op.mes.mapper.ProOrderWorkorderMapper;
|
|
|
|
|
import com.op.mes.mapper.ProRouteMapper;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
@ -38,8 +38,6 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
private ProOrderWorkorderMapper proOrderWorkorderMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ProOrderWorkorderBatchMapper proOrderWorkorderBatchMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ProRouteMapper proRouteMapper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取换算值
|
|
|
|
@ -82,16 +80,12 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
ProOrder product = new ProOrder();
|
|
|
|
|
BeanUtils.copyProperties(splitOrderDTO.getProduct(), product);
|
|
|
|
|
// 设置通用属性
|
|
|
|
|
ProOrderWorkorder proOrderWorkorder = setCommonWorkAttribute(product, splitOrderDTO.getProductDate(), splitOrderDTO.getProdLineCode(), splitOrderDTO.getShiftId(),splitOrderDTO.getRouteCode());
|
|
|
|
|
ProOrderWorkorder proOrderWorkorder = setCommonWorkAttribute(product, splitOrderDTO.getProductDate(), splitOrderDTO.getProdLineCode(), splitOrderDTO.getShiftId());
|
|
|
|
|
// 生成对应工单表
|
|
|
|
|
// 一级
|
|
|
|
|
ProOrderWorkorder firWorkOrder = setWorkOrder(proOrderWorkorder, product);
|
|
|
|
|
// code
|
|
|
|
|
int endCode = getEndCode(product.getId());
|
|
|
|
|
firWorkOrder.setWorkorderCode(product.getOrderCode()+"-"+endCode);
|
|
|
|
|
// 更新到数据库
|
|
|
|
|
proOrderWorkorderMapper.insertProOrderWorkorder(firWorkOrder);
|
|
|
|
|
|
|
|
|
|
// 创建通用批次表对象
|
|
|
|
|
ProOrderWorkorderBatch workBatch = setCommonBatchAttribute();
|
|
|
|
|
// 生成批次表并更新到数据库
|
|
|
|
@ -107,8 +101,6 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
// 设置父工单
|
|
|
|
|
proOrderWorkorder.setParentOrder(firWorkOrder.getWorkorderCode());
|
|
|
|
|
ProOrderWorkorder secWorkOrder = setWorkOrder(proOrderWorkorder, product);
|
|
|
|
|
// code
|
|
|
|
|
secWorkOrder.setWorkorderCode(product.getOrderCode()+"-"+(endCode+1));
|
|
|
|
|
// 更新到数据库
|
|
|
|
|
proOrderWorkorderMapper.insertProOrderWorkorder(secWorkOrder);
|
|
|
|
|
// 生成批次表并更新到数据库
|
|
|
|
@ -126,8 +118,6 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
ProOrderWorkorder thiWorkOrder = setWorkOrder(proOrderWorkorder, product);
|
|
|
|
|
// 设置为底层节点
|
|
|
|
|
thiWorkOrder.setIsEnd(1);
|
|
|
|
|
// code
|
|
|
|
|
thiWorkOrder.setWorkorderCode(product.getOrderCode()+"-"+(endCode+2));
|
|
|
|
|
// 更新到数据库
|
|
|
|
|
proOrderWorkorderMapper.insertProOrderWorkorder(thiWorkOrder);
|
|
|
|
|
// 生成批次表并更新到数据库
|
|
|
|
@ -150,13 +140,6 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
proOrderWorkorderMapper.updateProOrderWorkorder(updateWorker);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 母工单设置底层节点(只有母工单的情况下)
|
|
|
|
|
if (checkEnd == 0) {
|
|
|
|
|
firWorkOrder.setIsEnd(1);
|
|
|
|
|
// 更新到数据库
|
|
|
|
|
proOrderWorkorderMapper.updateProOrderWorkorder(firWorkOrder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return success();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -176,38 +159,33 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
// 通过订单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());
|
|
|
|
|
for (int i = 0;i < proOrderWorkorderList.size();i++){
|
|
|
|
|
// 通过设备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++) {
|
|
|
|
|
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) {
|
|
|
|
|
if (secProOrderWorkorder.size() > 0 && secProOrderWorkorder != null){
|
|
|
|
|
// 三级
|
|
|
|
|
List<ProOrderWorkorder> thiProOrderWorkorders = proOrderWorkorderMapper.selectChildWorkOrder(secProOrderWorkorder.get(0).getWorkorderCode());
|
|
|
|
|
if (thiProOrderWorkorders.size() > 0 && thiProOrderWorkorders != null) {
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
@ -250,11 +228,7 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public LineAndShiftVo getProdLineShift(String type) {
|
|
|
|
|
if (type.equals("white")){
|
|
|
|
|
LineAndShiftVo lineAndShiftVo = new LineAndShiftVo(proOrderMapper.selectProdLine(), proOrderMapper.selectProShift(),proRouteMapper.selectAllRoute());
|
|
|
|
|
return lineAndShiftVo;
|
|
|
|
|
}
|
|
|
|
|
LineAndShiftVo lineAndShiftVo = new LineAndShiftVo(proOrderMapper.selectPackageLine(), proOrderMapper.selectProShift(),proRouteMapper.selectAllRoute());
|
|
|
|
|
LineAndShiftVo lineAndShiftVo = new LineAndShiftVo(proOrderMapper.selectProdLine(), proOrderMapper.selectProShift());
|
|
|
|
|
return lineAndShiftVo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -265,7 +239,6 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
* @return 订单
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public ProOrder selectProOrderById(String id) {
|
|
|
|
|
return proOrderMapper.selectProOrderById(id);
|
|
|
|
|
}
|
|
|
|
@ -292,22 +265,20 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public int insertProOrder(ProOrder proOrder) {
|
|
|
|
|
// 获取当前时间
|
|
|
|
|
Date date = DateUtils.getNowDate();
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
|
|
|
|
|
proOrder.setId(IdUtils.fastSimpleUUID());
|
|
|
|
|
proOrder.setParentOrder("0");
|
|
|
|
|
proOrder.setStatus("o0");
|
|
|
|
|
proOrder.setOrderType(proOrder.getProdType());
|
|
|
|
|
proOrder.setOrderCode("DD"+ DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSSsss, date));
|
|
|
|
|
proOrder.setCreateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
proOrder.setCreateTime(date);
|
|
|
|
|
proOrder.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
proOrder.setUpdateTime(date);
|
|
|
|
|
proOrder.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
return proOrderMapper.insertProOrder(proOrder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int insertSapProOrder(ProOrder proOrder) {
|
|
|
|
|
return 0;
|
|
|
|
|
DynamicDataSourceContextHolder.push("op_xiaolan");// 这是数据源的key
|
|
|
|
|
proOrder.setId(IdUtils.fastSimpleUUID());
|
|
|
|
|
proOrder.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
proOrder.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
proOrder.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
return proOrderMapper.insertProOrder(proOrder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -353,16 +324,12 @@ 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) {
|
|
|
|
|
ProOrderWorkorder proOrderWorkorder = new ProOrderWorkorder();
|
|
|
|
|
// 更新者
|
|
|
|
|
proOrderWorkorder.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
// 更新时间
|
|
|
|
|
proOrderWorkorder.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
// 创建者
|
|
|
|
|
proOrderWorkorder.setCreateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
// 创建时间
|
|
|
|
|
proOrderWorkorder.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
// 工单生产日期
|
|
|
|
|
proOrderWorkorder.setProductDate(date);
|
|
|
|
|
// 产品(物料)编码
|
|
|
|
@ -378,8 +345,6 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
// TODO 产品类型(pro_type)
|
|
|
|
|
// 单据状态(1为已经下达0未下达)
|
|
|
|
|
proOrderWorkorder.setStatus("w0");
|
|
|
|
|
// 工艺编码
|
|
|
|
|
proOrderWorkorder.setRouteCode(routeCode);
|
|
|
|
|
return proOrderWorkorder;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -392,12 +357,18 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
*/
|
|
|
|
|
private ProOrderWorkorder setWorkOrder(ProOrderWorkorder proOrderWorkorder, ProOrder proOrder) {
|
|
|
|
|
// 获取当前时间
|
|
|
|
|
Date date = DateUtils.getNowDate();
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
// 订单表更新时间/更新者
|
|
|
|
|
proOrder.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
proOrder.setUpdateTime(date);
|
|
|
|
|
// 设置订单状态(只要拆了就属于已拆分)
|
|
|
|
|
proOrder.setStatus("o1");
|
|
|
|
|
// 设置订单状态
|
|
|
|
|
if (proOrder.getQuantitySplit() == null && proOrder.getQuantity() == Long.valueOf(proOrder.getAtrr1())){
|
|
|
|
|
proOrder.setStatus("o1");
|
|
|
|
|
}else if (proOrder.getQuantitySplit() != null && (proOrder.getQuantitySplit()+Long.valueOf(proOrder.getAtrr1()) == proOrder.getQuantity())){
|
|
|
|
|
proOrder.setStatus("o1");
|
|
|
|
|
}else {
|
|
|
|
|
proOrder.setStatus("o0");
|
|
|
|
|
}
|
|
|
|
|
// 更新订单表
|
|
|
|
|
proOrderMapper.updateOrder(proOrder);
|
|
|
|
|
// 生成对应的工单表
|
|
|
|
@ -413,6 +384,8 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
proOrderWorkorder.setUnit(proOrder.getUnit());
|
|
|
|
|
// 已拆分数量
|
|
|
|
|
proOrderWorkorder.setQuantitySplit(Long.valueOf(proOrder.getAtrr1()));
|
|
|
|
|
// TODO 工艺编码
|
|
|
|
|
// TODO 所有父节点
|
|
|
|
|
return proOrderWorkorder;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -423,12 +396,9 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
*/
|
|
|
|
|
private ProOrderWorkorderBatch setCommonBatchAttribute() {
|
|
|
|
|
ProOrderWorkorderBatch workBatch = new ProOrderWorkorderBatch();
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
// 更新者
|
|
|
|
|
workBatch.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
// 创建更新时间
|
|
|
|
|
workBatch.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
// 设置创建时间
|
|
|
|
|
workBatch.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
// 创建者
|
|
|
|
|
workBatch.setCreateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
// 设置单据状态(1正常)
|
|
|
|
@ -460,6 +430,22 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 转换拆分订单状态
|
|
|
|
|
*
|
|
|
|
|
* @param status
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private String changeStatus(String status) {
|
|
|
|
|
if (status.equals("o0")){
|
|
|
|
|
return "未拆分";
|
|
|
|
|
}
|
|
|
|
|
if (status.equals("o1")){
|
|
|
|
|
return "已拆分";
|
|
|
|
|
}
|
|
|
|
|
return status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取工单尾号code
|
|
|
|
|
* @param id
|
|
|
|
|