|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package com.op.plan.service.impl;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.BigInteger;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
|
|
import java.util.concurrent.LinkedBlockingQueue;
|
|
|
|
@ -1318,37 +1319,46 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
//所有线体
|
|
|
|
|
List<ProOrder> lineList = proOrderMapper.getCanProductLine();
|
|
|
|
|
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);
|
|
|
|
|
return dto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public R autoSplitOrder(ProOrder proOrder) {
|
|
|
|
|
public AjaxResult autoSplitOrder(ProOrder proOrder) {
|
|
|
|
|
|
|
|
|
|
Date nowTime = DateUtils.getNowDate();//公共时间
|
|
|
|
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
|
|
|
|
String key = "#header.poolName";
|
|
|
|
|
proOrder.setFactoryCode(request.getHeader(key.substring(8)).replace("ds_",""));
|
|
|
|
|
proOrder.setCreateTime(nowTime);
|
|
|
|
|
String shiftId = proOrder.getShiftId();
|
|
|
|
|
//订单总量
|
|
|
|
|
proOrder.setQuantitySplit(proOrder.getQuantitySplit()==null?0L:proOrder.getQuantitySplit());
|
|
|
|
|
Long orderQua = proOrder.getQuantity()-proOrder.getQuantitySplit();
|
|
|
|
|
//有几个设备就有几个工单
|
|
|
|
|
for(int i=0;i<proOrder.getLineCodes().length;i++){
|
|
|
|
|
if(orderQua == 0L){
|
|
|
|
|
logger.info("线体产能满足生产");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
List<ProOrderWorkorder> workorders = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
proOrder.setLineCode(proOrder.getLineCodes()[i]);
|
|
|
|
|
ProLine plineInfo = proOrderWorkorderMapper.getLineProductInfo(proOrder);//线体母单产品产能和线体代码
|
|
|
|
|
if(plineInfo==null){
|
|
|
|
|
logger.error("线体"+proOrder.getLineCodes()[i]+"无法生产");
|
|
|
|
|
return R.fail("线体"+proOrder.getLineCodes()[i]+"无法生产");
|
|
|
|
|
return AjaxResult.error(642,"线体"+proOrder.getLineCodes()[i]+"无法生产");
|
|
|
|
|
}
|
|
|
|
|
Long efficiency = plineInfo.getEfficiency();
|
|
|
|
|
if(efficiency < orderQua){
|
|
|
|
@ -1365,6 +1375,7 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
proOrder.setBelongWorkOrder(belongWorkOrder);
|
|
|
|
|
proOrder.setWorkerOrder(belongWorkOrder);
|
|
|
|
|
proOrder.setParentOrder("0");
|
|
|
|
|
proOrder.setShiftId(shiftId);
|
|
|
|
|
ProOrderWorkorder pworkOrder = getWorkOrderByOrder(proOrder,proOrder);//TODO;
|
|
|
|
|
//父级
|
|
|
|
|
workorders.add(pworkOrder);
|
|
|
|
@ -1384,6 +1395,7 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
sonOrder.setWorkerOrder(sworkOrderCode);
|
|
|
|
|
sonOrder.setParentOrder(parentWorkOrder);
|
|
|
|
|
sonOrder.setQuantitySplit(sonOrder.getQuantity());
|
|
|
|
|
sonOrder.setShiftId(shiftId);
|
|
|
|
|
if(CollectionUtils.isEmpty(sonOrder.getChildren())){
|
|
|
|
|
sonOrder.setEndFlag(1);
|
|
|
|
|
}
|
|
|
|
@ -1412,7 +1424,16 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
|
|
|
|
|
/**拆批次**/
|
|
|
|
|
proOrder.setProdSpc(plineInfo.getDh());//借用字段
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<ProOrderWorkorderBatch> workorderBatches0 = getBatchList(proOrder);//TODO;
|
|
|
|
|
|
|
|
|
|
if(CollectionUtils.isEmpty(workorderBatches0)){
|
|
|
|
|
logger.error("批次太多,请检查【产品批次数量】、【产线产能】、【批次号夜班开始字母】是否设置正常。");
|
|
|
|
|
return AjaxResult.error(642,"批次太多,请检查产品批次数量是否设置正常。");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<ProOrderWorkorderBatch> workBatchs = new ArrayList<>();
|
|
|
|
|
for(int m=0;m<workorders.size();m++){
|
|
|
|
|
ProOrderWorkorder work = workorders.get(m);
|
|
|
|
@ -1440,18 +1461,12 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
|
|
|
|
|
/**pro_order_workorder_batch**/
|
|
|
|
|
if(!CollectionUtils.isEmpty(workBatchs)) {
|
|
|
|
|
|
|
|
|
|
if(workBatchs.size()>100){
|
|
|
|
|
logger.error("批次太多,请检查产品批次数量是否设置正常。");
|
|
|
|
|
return R.fail("批次太多,请检查产品批次数量是否设置正常。");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int pn = proOrderWorkorderBatchMapper.insertWorkorderBatchs(workBatchs);
|
|
|
|
|
System.out.println("pn:"+pn);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return R.ok();
|
|
|
|
|
return AjaxResult.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -1507,12 +1522,33 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
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 dayBatches = nightWorkBatchStart - dayWorkBatchStart;
|
|
|
|
|
int nigthBatches = 'Z' - nightWorkBatchStart;
|
|
|
|
|
|
|
|
|
|
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 null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取批次号集合
|
|
|
|
|
List<String> batchCodes = StringUtils.batchAutoCreate(proOrder.getFactoryCode(),
|
|
|
|
|
proOrder.getProdSpc(),
|
|
|
|
|
DateUtils.dateTime("yyyy-MM-dd",proOrder.getProductDate()),
|
|
|
|
|
proOrder.getAtrr2().substring(proOrder.getAtrr2().length()-1),
|
|
|
|
|
"0",workorderBatches.size());
|
|
|
|
|
"0",workorderBatches.size(),startZM);
|
|
|
|
|
|
|
|
|
|
for(int n=0;n<workorderBatches.size();n++){
|
|
|
|
|
workorderBatches.get(n).setBatchCode(batchCodes.get(n));
|
|
|
|
@ -1527,9 +1563,8 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
* 2、可生产产品种类最少的线体。
|
|
|
|
|
* @param proOrder
|
|
|
|
|
*/
|
|
|
|
|
protected List<String> getRecommendLines(ProOrder proOrder){
|
|
|
|
|
protected List<String> getRecommendLines(List<ProOrder> proLines,ProOrder proOrder){
|
|
|
|
|
List<String> lines = new ArrayList<>();
|
|
|
|
|
List<ProOrder> proLines = proOrderMapper.getSelectLineLevel1(proOrder);
|
|
|
|
|
//订单总量
|
|
|
|
|
proOrder.setQuantitySplit(proOrder.getQuantitySplit()==null?0L:proOrder.getQuantitySplit());
|
|
|
|
|
BigDecimal orderQuality = new BigDecimal(proOrder.getQuantity()).subtract(new BigDecimal(proOrder.getQuantitySplit()));
|
|
|
|
@ -1547,18 +1582,7 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String args[]){
|
|
|
|
|
// String arrayStr = "[[\"GX01\",\"LG1\"],[\"GX01\",\"LG2\"],[\"GX02\",\"S1\"],[\"GX02\",\"S2\"],[\"GX03\",\"HF01\"],[\"GX04\",\"SPJ01\"]]";
|
|
|
|
|
// JSONArray jsonArray = JSONArray.parseArray(arrayStr);
|
|
|
|
|
// 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);
|
|
|
|
|
char zm = 'D';
|
|
|
|
|
System.out.println(zm-'A'+1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|