|
|
|
@ -1220,15 +1220,170 @@ public class ProOrderServiceImpl implements IProOrderService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public List<ProOrder> getCanProductLine() {
|
|
|
|
|
return proOrderMapper.getCanProductLine();
|
|
|
|
|
public ProOrder getCanProductLine(ProOrder proOrder) {
|
|
|
|
|
ProOrder dto = new ProOrder();
|
|
|
|
|
//所有线体
|
|
|
|
|
List<ProOrder> lineList = proOrderMapper.getCanProductLine();
|
|
|
|
|
dto.setLineList(lineList);
|
|
|
|
|
//推荐线体
|
|
|
|
|
List<String> recommendLineList = getRecommendLines(proOrder);
|
|
|
|
|
dto.setRecommendLineList(recommendLineList);
|
|
|
|
|
return dto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public R 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);
|
|
|
|
|
// //订单总量
|
|
|
|
|
// Long orderQua = proOrder.getQuantity();
|
|
|
|
|
// //有几个设备就有几个工单
|
|
|
|
|
// for(int i=0;i<proOrder.getLineCodes().length;i++){
|
|
|
|
|
//
|
|
|
|
|
// List<ProOrderWorkorder> workorders = new ArrayList<>();
|
|
|
|
|
// List<ProOrderWorkorderBatch> workorderBatches = new ArrayList<>();
|
|
|
|
|
//
|
|
|
|
|
// proOrder.setLineCode(proOrder.getLineCodes()[i]);
|
|
|
|
|
// Long efficiency = proOrderWorkorderMapper.getLineProductInfo(proOrder);//线体产能
|
|
|
|
|
// if(efficiency==null){
|
|
|
|
|
// break;
|
|
|
|
|
// logger.error("线体"+proOrder.getLineCodes()[i]+"产能"+efficiency+"无法生产");
|
|
|
|
|
// }
|
|
|
|
|
// if(efficiency < orderQua){
|
|
|
|
|
// proOrder.setQuantitySplit(efficiency);
|
|
|
|
|
// }else{
|
|
|
|
|
// proOrder.setQuantitySplit(orderQua);
|
|
|
|
|
// }
|
|
|
|
|
// orderQua = orderQua - efficiency;//消耗订单总数量
|
|
|
|
|
// List<ProOrder> sonOrders = (List<ProOrder>)proOrder.getChildren();
|
|
|
|
|
// if(CollectionUtils.isEmpty(sonOrders)){//1层订单
|
|
|
|
|
// proOrder.setEndFlag(1);
|
|
|
|
|
// }
|
|
|
|
|
// int endCode = getEndCode(proOrder.getId());
|
|
|
|
|
// String belongWorkOrder = proOrder.getOrderCode()+"-"+endCode;
|
|
|
|
|
// proOrder.setBelongWorkOrder(belongWorkOrder);
|
|
|
|
|
// proOrder.setWorkerOrder(belongWorkOrder);
|
|
|
|
|
// proOrder.setParentOrder("0");
|
|
|
|
|
// ProOrderWorkorder pworkOrder = getWorkOrderByOrder(proOrder);//TODO;
|
|
|
|
|
// //父级
|
|
|
|
|
// workorders.add(pworkOrder);
|
|
|
|
|
//
|
|
|
|
|
// /**pro_order_workorder_batch**/
|
|
|
|
|
// String parentWorkOrder = belongWorkOrder;
|
|
|
|
|
// while(!CollectionUtils.isEmpty(sonOrders)){
|
|
|
|
|
// ProOrder sonOrder = sonOrders.get(0);
|
|
|
|
|
// sonOrder.setBelongWorkOrder(belongWorkOrder);
|
|
|
|
|
// endCode = getEndCode(proOrder.getId());
|
|
|
|
|
// String sworkOrderCode = sonOrder.getOrderCode()+"-"+endCode;
|
|
|
|
|
// sonOrder.setBelongWorkOrder(belongWorkOrder);
|
|
|
|
|
// sonOrder.setWorkerOrder(sworkOrderCode);
|
|
|
|
|
// sonOrder.setParentOrder(parentWorkOrder);
|
|
|
|
|
// sonOrders = (List<ProOrder>)sonOrder.getChildren();
|
|
|
|
|
// if(CollectionUtils.isEmpty(sonOrders)){//1层订单
|
|
|
|
|
// sonOrder.setEndFlag(1);
|
|
|
|
|
// }
|
|
|
|
|
// ProOrderWorkorder sworkOrder = getWorkOrderByOrder(sonOrder);//TODO;
|
|
|
|
|
// workorders.add(sworkOrder);
|
|
|
|
|
// parentWorkOrder = sworkOrderCode;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**pro_order_workorder**/
|
|
|
|
|
// if(!CollectionUtils.isEmpty(workorders)){
|
|
|
|
|
// int pm = proOrderWorkorderMapper.insertWorkorders(workorders);
|
|
|
|
|
// System.out.println("pm:"+pm);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// //拆批次
|
|
|
|
|
// Long pworkOrderQua = proOrder.getQuantitySplit();//工单数量
|
|
|
|
|
// ProOrderWorkorderBatch workBatch = null;
|
|
|
|
|
// int batchNum = 1;
|
|
|
|
|
// while(pworkOrderQua>0){
|
|
|
|
|
// workBatch = new ProOrderWorkorderBatch();
|
|
|
|
|
// workBatch.setBatchQuantity(0L);
|
|
|
|
|
// List<String> batchCode = StringUtils.batchAutoCreate(proOrder.getFactoryCode(),
|
|
|
|
|
// proOrder.getLineCode(),
|
|
|
|
|
// DateUtils.dateTime("yyyy-MM-dd",proOrder.getProductDate()),
|
|
|
|
|
// proOrder.getAtrr2().substring(proOrder.getAtrr2().length()-1),
|
|
|
|
|
// "0",batchNum++);
|
|
|
|
|
// workBatch.setBatchCode(batchCode);
|
|
|
|
|
// workorderBatches.add(workBatch);
|
|
|
|
|
// }
|
|
|
|
|
// /**pro_order_workorder_batch**/
|
|
|
|
|
// if(!CollectionUtils.isEmpty(workorderBatches)) {
|
|
|
|
|
// int pn = proOrderWorkorderBatchMapper.insertWorkorderBatchs(workBatch);
|
|
|
|
|
// System.out.println("pn:"+pn);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected ProOrderWorkorder getWorkOrderByOrder(ProOrder proOrder){
|
|
|
|
|
ProOrderWorkorder workOrder = new ProOrderWorkorder();
|
|
|
|
|
workOrder.setWorkorderId(IdUtils.fastSimpleUUID());
|
|
|
|
|
int endCode = getEndCode(proOrder.getId());
|
|
|
|
|
workOrder.setWorkorderCode(proOrder.getWorkerOrder());
|
|
|
|
|
workOrder.setBelongWorkOrder(proOrder.getBelongWorkOrder());
|
|
|
|
|
workOrder.setOrderId(proOrder.getId());
|
|
|
|
|
workOrder.setOrderCode(proOrder.getOrderCode());
|
|
|
|
|
workOrder.setProductCode(proOrder.getProdCode());
|
|
|
|
|
workOrder.setProductName(proOrder.getProdDesc());
|
|
|
|
|
workOrder.setUnit(proOrder.getUnit());
|
|
|
|
|
workOrder.setQuantitySplit(proOrder.getQuantitySplit());
|
|
|
|
|
workOrder.setRouteCode(proOrder.getRouteCode());
|
|
|
|
|
String gxCode = "CP";//proOrderWorkorderMapper.getProcessCode(proOrder.getRouteCode());
|
|
|
|
|
String[][] lineCodeArray = {{gxCode,proOrder.getLineCode()}};
|
|
|
|
|
workOrder.setProdLineCodeArray(lineCodeArray);
|
|
|
|
|
workOrder.setProductDate(DateUtils.dateTime("yyyy-MM-dd",proOrder.getProductDate()));
|
|
|
|
|
//workOrder.setShiftId();
|
|
|
|
|
workOrder.setParentOrder(proOrder.getParentOrder());
|
|
|
|
|
workOrder.setStatus("w0");
|
|
|
|
|
workOrder.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
|
workOrder.setCreateTime(proOrder.getCreateTime());
|
|
|
|
|
workOrder.setProdType(proOrder.getOrderType());
|
|
|
|
|
workOrder.setFactoryCode(proOrder.getFactoryCode());
|
|
|
|
|
workOrder.setEndFlag(proOrder.getEndFlag());
|
|
|
|
|
workOrder.setSortNo(proOrder.getSortNo());
|
|
|
|
|
return workOrder;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 每个线体维护可生产的产品及其对应的每天的标准产能和标准用人。
|
|
|
|
|
* 1、标准用人最少的线体。
|
|
|
|
|
* 2、可生产产品种类最少的线体。
|
|
|
|
|
* @param proOrder
|
|
|
|
|
*/
|
|
|
|
|
protected List<String> getRecommendLines(ProOrder proOrder){
|
|
|
|
|
List<String> lines = new ArrayList<>();
|
|
|
|
|
List<ProOrder> proLines = proOrderMapper.getSelectLineLevel1(proOrder);
|
|
|
|
|
//订单总量
|
|
|
|
|
BigDecimal orderQuality = new BigDecimal(proOrder.getQuantity());
|
|
|
|
|
BigDecimal consumeQuality = BigDecimal.ZERO;
|
|
|
|
|
for(ProOrder pline:proLines){
|
|
|
|
|
lines.add(pline.getLineCode());
|
|
|
|
|
consumeQuality = consumeQuality.add(pline.getEfficiency());
|
|
|
|
|
if(consumeQuality.compareTo(orderQuality)>=0){
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return lines;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|