|
|
@ -1,6 +1,7 @@
|
|
|
|
package com.op.plan.service.impl;
|
|
|
|
package com.op.plan.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
|
|
import java.math.BigInteger;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
|
import java.util.concurrent.LinkedBlockingQueue;
|
|
|
|
import java.util.concurrent.LinkedBlockingQueue;
|
|
|
@ -1318,37 +1319,46 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
//所有线体
|
|
|
|
//所有线体
|
|
|
|
List<ProOrder> lineList = proOrderMapper.getCanProductLine();
|
|
|
|
List<ProOrder> lineList = proOrderMapper.getCanProductLine();
|
|
|
|
dto.setLineList(lineList);
|
|
|
|
dto.setLineList(lineList);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<ProOrder> proLines = proOrderMapper.getSelectLineLevel1(proOrder);
|
|
|
|
|
|
|
|
BigDecimal todayPro = new BigDecimal(BigInteger.ZERO);//当日设备实际产能
|
|
|
|
|
|
|
|
for(ProOrder pLines:proLines){
|
|
|
|
|
|
|
|
todayPro = todayPro.add(pLines.getEfficiency());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(todayPro.doubleValue() < proOrder.getQuantity()){
|
|
|
|
|
|
|
|
logger.error("当日设备产能达不到订单要求");
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//推荐线体
|
|
|
|
//推荐线体
|
|
|
|
List<String> recommendLineList = getRecommendLines(proOrder);
|
|
|
|
List<String> recommendLineList = getRecommendLines(proLines,proOrder);
|
|
|
|
dto.setRecommendLineList(recommendLineList);
|
|
|
|
dto.setRecommendLineList(recommendLineList);
|
|
|
|
return dto;
|
|
|
|
return dto;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@DS("#header.poolName")
|
|
|
|
@DS("#header.poolName")
|
|
|
|
public R autoSplitOrder(ProOrder proOrder) {
|
|
|
|
public AjaxResult autoSplitOrder(ProOrder proOrder) {
|
|
|
|
|
|
|
|
|
|
|
|
Date nowTime = DateUtils.getNowDate();//公共时间
|
|
|
|
Date nowTime = DateUtils.getNowDate();//公共时间
|
|
|
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
|
|
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
|
|
|
String key = "#header.poolName";
|
|
|
|
String key = "#header.poolName";
|
|
|
|
proOrder.setFactoryCode(request.getHeader(key.substring(8)).replace("ds_",""));
|
|
|
|
proOrder.setFactoryCode(request.getHeader(key.substring(8)).replace("ds_",""));
|
|
|
|
proOrder.setCreateTime(nowTime);
|
|
|
|
proOrder.setCreateTime(nowTime);
|
|
|
|
|
|
|
|
String shiftId = proOrder.getShiftId();
|
|
|
|
//订单总量
|
|
|
|
//订单总量
|
|
|
|
proOrder.setQuantitySplit(proOrder.getQuantitySplit()==null?0L:proOrder.getQuantitySplit());
|
|
|
|
proOrder.setQuantitySplit(proOrder.getQuantitySplit()==null?0L:proOrder.getQuantitySplit());
|
|
|
|
Long orderQua = proOrder.getQuantity()-proOrder.getQuantitySplit();
|
|
|
|
Long orderQua = proOrder.getQuantity()-proOrder.getQuantitySplit();
|
|
|
|
//有几个设备就有几个工单
|
|
|
|
//有几个设备就有几个工单
|
|
|
|
for(int i=0;i<proOrder.getLineCodes().length;i++){
|
|
|
|
for(int i=0;i<proOrder.getLineCodes().length;i++){
|
|
|
|
if(orderQua == 0L){
|
|
|
|
|
|
|
|
logger.info("线体产能满足生产");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
List<ProOrderWorkorder> workorders = new ArrayList<>();
|
|
|
|
List<ProOrderWorkorder> workorders = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
proOrder.setLineCode(proOrder.getLineCodes()[i]);
|
|
|
|
proOrder.setLineCode(proOrder.getLineCodes()[i]);
|
|
|
|
ProLine plineInfo = proOrderWorkorderMapper.getLineProductInfo(proOrder);//线体母单产品产能和线体代码
|
|
|
|
ProLine plineInfo = proOrderWorkorderMapper.getLineProductInfo(proOrder);//线体母单产品产能和线体代码
|
|
|
|
if(plineInfo==null){
|
|
|
|
if(plineInfo==null){
|
|
|
|
logger.error("线体"+proOrder.getLineCodes()[i]+"无法生产");
|
|
|
|
logger.error("线体"+proOrder.getLineCodes()[i]+"无法生产,请到【线体产品管理界面进行维护】");
|
|
|
|
return R.fail("线体"+proOrder.getLineCodes()[i]+"无法生产");
|
|
|
|
return AjaxResult.error(642,"线体"+proOrder.getLineCodes()[i]+"无法生产,请到【线体产品管理界面进行维护】");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Long efficiency = plineInfo.getEfficiency();
|
|
|
|
Long efficiency = plineInfo.getEfficiency();
|
|
|
|
if(efficiency < orderQua){
|
|
|
|
if(efficiency < orderQua){
|
|
|
@ -1365,6 +1375,7 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
proOrder.setBelongWorkOrder(belongWorkOrder);
|
|
|
|
proOrder.setBelongWorkOrder(belongWorkOrder);
|
|
|
|
proOrder.setWorkerOrder(belongWorkOrder);
|
|
|
|
proOrder.setWorkerOrder(belongWorkOrder);
|
|
|
|
proOrder.setParentOrder("0");
|
|
|
|
proOrder.setParentOrder("0");
|
|
|
|
|
|
|
|
proOrder.setShiftId(shiftId);
|
|
|
|
ProOrderWorkorder pworkOrder = getWorkOrderByOrder(proOrder,proOrder);//TODO;
|
|
|
|
ProOrderWorkorder pworkOrder = getWorkOrderByOrder(proOrder,proOrder);//TODO;
|
|
|
|
//父级
|
|
|
|
//父级
|
|
|
|
workorders.add(pworkOrder);
|
|
|
|
workorders.add(pworkOrder);
|
|
|
@ -1384,6 +1395,7 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
sonOrder.setWorkerOrder(sworkOrderCode);
|
|
|
|
sonOrder.setWorkerOrder(sworkOrderCode);
|
|
|
|
sonOrder.setParentOrder(parentWorkOrder);
|
|
|
|
sonOrder.setParentOrder(parentWorkOrder);
|
|
|
|
sonOrder.setQuantitySplit(sonOrder.getQuantity());
|
|
|
|
sonOrder.setQuantitySplit(sonOrder.getQuantity());
|
|
|
|
|
|
|
|
sonOrder.setShiftId(shiftId);
|
|
|
|
if(CollectionUtils.isEmpty(sonOrder.getChildren())){
|
|
|
|
if(CollectionUtils.isEmpty(sonOrder.getChildren())){
|
|
|
|
sonOrder.setEndFlag(1);
|
|
|
|
sonOrder.setEndFlag(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1412,7 +1424,21 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
|
|
|
|
|
|
|
/**拆批次**/
|
|
|
|
/**拆批次**/
|
|
|
|
proOrder.setProdSpc(plineInfo.getDh());//借用字段
|
|
|
|
proOrder.setProdSpc(plineInfo.getDh());//借用字段
|
|
|
|
List<ProOrderWorkorderBatch> workorderBatches0 = getBatchList(proOrder);//TODO;
|
|
|
|
/**批次中的工厂代码**/
|
|
|
|
|
|
|
|
proOrder.setFactoryDh(plineInfo.getFactoryDh());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AjaxResult aResult = getBatchList(proOrder);//Done;
|
|
|
|
|
|
|
|
if(!aResult.isSuccess()){
|
|
|
|
|
|
|
|
return aResult;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<ProOrderWorkorderBatch> workorderBatches0 = (List<ProOrderWorkorderBatch>)aResult.get("data");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(CollectionUtils.isEmpty(workorderBatches0)){
|
|
|
|
|
|
|
|
logger.error("批次太多,请检查【产品批次数量】、【产线产能】、【批次号夜班开始字母】是否设置正常。");
|
|
|
|
|
|
|
|
return AjaxResult.error(642,"批次太多,请检查产品批次数量是否设置正常。");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<ProOrderWorkorderBatch> workBatchs = new ArrayList<>();
|
|
|
|
List<ProOrderWorkorderBatch> workBatchs = new ArrayList<>();
|
|
|
|
for(int m=0;m<workorders.size();m++){
|
|
|
|
for(int m=0;m<workorders.size();m++){
|
|
|
|
ProOrderWorkorder work = workorders.get(m);
|
|
|
|
ProOrderWorkorder work = workorders.get(m);
|
|
|
@ -1440,18 +1466,12 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
|
|
|
|
|
|
|
/**pro_order_workorder_batch**/
|
|
|
|
/**pro_order_workorder_batch**/
|
|
|
|
if(!CollectionUtils.isEmpty(workBatchs)) {
|
|
|
|
if(!CollectionUtils.isEmpty(workBatchs)) {
|
|
|
|
|
|
|
|
|
|
|
|
if(workBatchs.size()>100){
|
|
|
|
|
|
|
|
logger.error("批次太多,请检查产品批次数量是否设置正常。");
|
|
|
|
|
|
|
|
return R.fail("批次太多,请检查产品批次数量是否设置正常。");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int pn = proOrderWorkorderBatchMapper.insertWorkorderBatchs(workBatchs);
|
|
|
|
int pn = proOrderWorkorderBatchMapper.insertWorkorderBatchs(workBatchs);
|
|
|
|
System.out.println("pn:"+pn);
|
|
|
|
System.out.println("pn:"+pn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return R.ok();
|
|
|
|
return AjaxResult.success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -1476,12 +1496,16 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
String[][] lineCodeArray = {{gxCode,pOrder.getLineCode()}};
|
|
|
|
String[][] lineCodeArray = {{gxCode,pOrder.getLineCode()}};
|
|
|
|
workOrder.setProdLineCode(JSONArray.toJSONString(lineCodeArray));
|
|
|
|
workOrder.setProdLineCode(JSONArray.toJSONString(lineCodeArray));
|
|
|
|
workOrder.setProductDate(DateUtils.dateTime("yyyy-MM-dd",pOrder.getProductDate()));
|
|
|
|
workOrder.setProductDate(DateUtils.dateTime("yyyy-MM-dd",pOrder.getProductDate()));
|
|
|
|
//workOrder.setShiftId();
|
|
|
|
workOrder.setShiftId(pOrder.getShiftId());
|
|
|
|
workOrder.setParentOrder(proOrder.getParentOrder());
|
|
|
|
workOrder.setParentOrder(proOrder.getParentOrder());
|
|
|
|
workOrder.setStatus("w0");
|
|
|
|
workOrder.setStatus("w0");
|
|
|
|
workOrder.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
workOrder.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
workOrder.setCreateTime(pOrder.getCreateTime());
|
|
|
|
workOrder.setCreateTime(pOrder.getCreateTime());
|
|
|
|
workOrder.setProdType(proOrder.getOrderType());
|
|
|
|
if("LJ88".equals(pOrder.getOrderType())){
|
|
|
|
|
|
|
|
workOrder.setProdType("LJ01");
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
workOrder.setProdType(pOrder.getOrderType());
|
|
|
|
|
|
|
|
}
|
|
|
|
workOrder.setFactoryCode(pOrder.getFactoryCode());
|
|
|
|
workOrder.setFactoryCode(pOrder.getFactoryCode());
|
|
|
|
workOrder.setEndFlag(proOrder.getEndFlag());
|
|
|
|
workOrder.setEndFlag(proOrder.getEndFlag());
|
|
|
|
workOrder.setSortNo(pOrder.getSortNo());
|
|
|
|
workOrder.setSortNo(pOrder.getSortNo());
|
|
|
@ -1489,10 +1513,16 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//靠母单先生成批次模板
|
|
|
|
//靠母单先生成批次模板
|
|
|
|
protected List<ProOrderWorkorderBatch> getBatchList(ProOrder proOrder){
|
|
|
|
protected AjaxResult getBatchList(ProOrder proOrder){
|
|
|
|
List<ProOrderWorkorderBatch> workorderBatches = new ArrayList<>();
|
|
|
|
List<ProOrderWorkorderBatch> workorderBatches = new ArrayList<>();
|
|
|
|
Long pworkOrderQua = proOrder.getQuantitySplit();//母工单数量
|
|
|
|
Long pworkOrderQua = proOrder.getQuantitySplit();//母工单数量
|
|
|
|
BaseProduct batchQua0 = proOrderWorkorderMapper.getProductInfo(proOrder);//母单标准批次产能和几合一
|
|
|
|
BaseProduct batchQua0 = proOrderWorkorderMapper.getProductInfo(proOrder);//母单标准批次产能和几合一
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(batchQua0 == null || batchQua0.getBatchQuaStandar()==null){
|
|
|
|
|
|
|
|
logger.error("未设置最大批次数,请到【产品管理】界面进行产品的最大批次设置");
|
|
|
|
|
|
|
|
return AjaxResult.error("未设置最大批次数,请到【产品管理】界面进行产品的最大批次设置");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ProOrderWorkorderBatch workBatch = null;
|
|
|
|
ProOrderWorkorderBatch workBatch = null;
|
|
|
|
while(pworkOrderQua>0){
|
|
|
|
while(pworkOrderQua>0){
|
|
|
|
workBatch = new ProOrderWorkorderBatch();
|
|
|
|
workBatch = new ProOrderWorkorderBatch();
|
|
|
@ -1507,18 +1537,38 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
pworkOrderQua = pworkOrderQua - batchQua0.getBatchQuaStandar().longValue();
|
|
|
|
pworkOrderQua = pworkOrderQua - batchQua0.getBatchQuaStandar().longValue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> batches = proOrderWorkorderMapper.getBatchDict("batch_flag");
|
|
|
|
|
|
|
|
char dayWorkBatchStart = batches.get(0).charAt(0);
|
|
|
|
|
|
|
|
char nightWorkBatchStart = batches.get(1).charAt(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int maxBatchNum = 0;
|
|
|
|
|
|
|
|
char startZM = 'A';
|
|
|
|
|
|
|
|
if("5".equals(proOrder.getShiftId())){//白班
|
|
|
|
|
|
|
|
maxBatchNum = nightWorkBatchStart - dayWorkBatchStart;
|
|
|
|
|
|
|
|
startZM = dayWorkBatchStart;
|
|
|
|
|
|
|
|
}else if("2".equals(proOrder.getShiftId())){//夜班
|
|
|
|
|
|
|
|
maxBatchNum = 'Z' - nightWorkBatchStart;
|
|
|
|
|
|
|
|
startZM = nightWorkBatchStart;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(workorderBatches.size()>maxBatchNum){
|
|
|
|
|
|
|
|
logger.error("大于工厂字典【batch_flag】推理的的批次数");
|
|
|
|
|
|
|
|
return AjaxResult.error("大于工厂字典【batch_flag】推理的的批次数");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取批次号集合
|
|
|
|
//获取批次号集合
|
|
|
|
List<String> batchCodes = StringUtils.batchAutoCreate(proOrder.getFactoryCode(),
|
|
|
|
List<String> batchCodes = StringUtils.batchAutoCreate(proOrder.getFactoryDh(),
|
|
|
|
proOrder.getProdSpc(),
|
|
|
|
proOrder.getProdSpc(),
|
|
|
|
DateUtils.dateTime("yyyy-MM-dd",proOrder.getProductDate()),
|
|
|
|
DateUtils.dateTime("yyyy-MM-dd",proOrder.getProductDate()),
|
|
|
|
proOrder.getAtrr2().substring(proOrder.getAtrr2().length()-1),
|
|
|
|
proOrder.getAtrr2().substring(proOrder.getAtrr2().length()-1),
|
|
|
|
"0",workorderBatches.size());
|
|
|
|
"0",workorderBatches.size(),startZM);
|
|
|
|
|
|
|
|
|
|
|
|
for(int n=0;n<workorderBatches.size();n++){
|
|
|
|
for(int n=0;n<workorderBatches.size();n++){
|
|
|
|
workorderBatches.get(n).setBatchCode(batchCodes.get(n));
|
|
|
|
workorderBatches.get(n).setBatchCode(batchCodes.get(n));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return workorderBatches;
|
|
|
|
return AjaxResult.success(workorderBatches);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -1527,9 +1577,8 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
* 2、可生产产品种类最少的线体。
|
|
|
|
* 2、可生产产品种类最少的线体。
|
|
|
|
* @param proOrder
|
|
|
|
* @param proOrder
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected List<String> getRecommendLines(ProOrder proOrder){
|
|
|
|
protected List<String> getRecommendLines(List<ProOrder> proLines,ProOrder proOrder){
|
|
|
|
List<String> lines = new ArrayList<>();
|
|
|
|
List<String> lines = new ArrayList<>();
|
|
|
|
List<ProOrder> proLines = proOrderMapper.getSelectLineLevel1(proOrder);
|
|
|
|
|
|
|
|
//订单总量
|
|
|
|
//订单总量
|
|
|
|
proOrder.setQuantitySplit(proOrder.getQuantitySplit()==null?0L:proOrder.getQuantitySplit());
|
|
|
|
proOrder.setQuantitySplit(proOrder.getQuantitySplit()==null?0L:proOrder.getQuantitySplit());
|
|
|
|
BigDecimal orderQuality = new BigDecimal(proOrder.getQuantity()).subtract(new BigDecimal(proOrder.getQuantitySplit()));
|
|
|
|
BigDecimal orderQuality = new BigDecimal(proOrder.getQuantity()).subtract(new BigDecimal(proOrder.getQuantitySplit()));
|
|
|
@ -1547,18 +1596,7 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String args[]){
|
|
|
|
public static void main(String args[]){
|
|
|
|
// String arrayStr = "[[\"GX01\",\"LG1\"],[\"GX01\",\"LG2\"],[\"GX02\",\"S1\"],[\"GX02\",\"S2\"],[\"GX03\",\"HF01\"],[\"GX04\",\"SPJ01\"]]";
|
|
|
|
char zm = 'D';
|
|
|
|
// JSONArray jsonArray = JSONArray.parseArray(arrayStr);
|
|
|
|
System.out.println(zm-'A'+1);
|
|
|
|
// for(int c=0;c<jsonArray.size();c++){
|
|
|
|
|
|
|
|
// System.out.println(jsonArray.getJSONArray(c).getString(1));
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// BigDecimal a = new BigDecimal("100");
|
|
|
|
|
|
|
|
// BigDecimal b = new BigDecimal("100");
|
|
|
|
|
|
|
|
// System.out.println(a.compareTo(b));
|
|
|
|
|
|
|
|
int m=1;
|
|
|
|
|
|
|
|
while(m<3){
|
|
|
|
|
|
|
|
++m;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
System.out.println(m);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|