辅助排产

master
zhaoxiaolin 7 months ago
parent 156ed0e831
commit ad5b9ee7a3

@ -330,8 +330,15 @@ public class ProOrderController extends BaseController {
return R.ok();
}
@GetMapping("/getCanProductLine")
public List<ProOrder> getCanProductLine() {
return proOrderService.getCanProductLine();
@PostMapping("/getCanProductLine")
public ProOrder getCanProductLine(@RequestBody ProOrder proOrder) {
return proOrderService.getCanProductLine(proOrder);
}
/**辅助排产**/
@PostMapping("/autoSplitOrder")
public R autoSplitOrder(@RequestBody ProOrder proOrder) {
return proOrderService.autoSplitOrder(proOrder);
}
}

@ -1,6 +1,8 @@
package com.op.plan.domain;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
@ -65,6 +67,78 @@ public class ProOrder extends TreeEntity {
private String productDate;
private String lineCode;
private String lineName;
private List<ProOrder> lineList;
private List<String> recommendLineList;//推荐线体
private Integer useMan;
private BigDecimal efficiency;
private String[] lineCodes;
private String routeCode;
private Integer endFlag;
private String belongWorkOrder;
public String getBelongWorkOrder() {
return belongWorkOrder;
}
public void setBelongWorkOrder(String belongWorkOrder) {
this.belongWorkOrder = belongWorkOrder;
}
public Integer getEndFlag() {
return endFlag;
}
public void setEndFlag(Integer endFlag) {
this.endFlag = endFlag;
}
public String getRouteCode() {
return routeCode;
}
public void setRouteCode(String routeCode) {
this.routeCode = routeCode;
}
public String[] getLineCodes() {
return lineCodes;
}
public void setLineCodes(String[] lineCodes) {
this.lineCodes = lineCodes;
}
public Integer getUseMan() {
return useMan;
}
public void setUseMan(Integer useMan) {
this.useMan = useMan;
}
public BigDecimal getEfficiency() {
return efficiency;
}
public void setEfficiency(BigDecimal efficiency) {
this.efficiency = efficiency;
}
public List<ProOrder> getLineList() {
return lineList;
}
public void setLineList(List<ProOrder> lineList) {
this.lineList = lineList;
}
public List<String> getRecommendLineList() {
return recommendLineList;
}
public void setRecommendLineList(List<String> recommendLineList) {
this.recommendLineList = recommendLineList;
}
public String getLineCode() {
return lineCode;

@ -238,4 +238,6 @@ public interface ProOrderMapper {
int updateCloseOrderBatchById(@Param("orderIds")String[] orderIds);
List<ProOrder> getCanProductLine();
List<ProOrder> getSelectLineLevel1(ProOrder proOrder);
}

@ -216,5 +216,11 @@ public interface ProOrderWorkorderMapper {
int updateMesReportWorkBatch(MesReportWorkBatchDTO mesReportWorkBatchDTO);
int updateCheckTaskBatch(CheckTaskBatchDTO checkTaskBatchDTO);
Long getLineProductInfo(ProOrder proOrder);
String getProcessCode(String routeCode);
int insertWorkorders(@Param("list") List<ProOrderWorkorder> workorders);
}

@ -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));
}
}

@ -207,6 +207,20 @@
where equ.equipment_type_code = 'equ_type_bzx'
and equ.del_flag = '0' and equ.equipment_status = '1'
</select>
<select id="getSelectLineLevel1" resultType="com.op.plan.domain.ProOrder">
select mlp.line_code lineCode,
mlp.use_man useMan,
mlp.efficiency efficiency,
pt.n
from mes_line_product mlp
left join (
select count(0) n,line_code
from mes_line_product where del_flag='0'
GROUP BY line_code
)pt on mlp.line_code = pt.line_code
where mlp.del_flag = '0' and product_code = #{prodCode}
order by mlp.use_man desc,pt.n desc
</select>
<insert id="insertProOrder" parameterType="ProOrder">
insert into pro_order

@ -637,6 +637,17 @@
where pow.belong_work_order = #{workorderCode} and pow.del_flag = '0'
order by pow.workorder_code_sap desc
</select>
<select id="getLineProductInfo" resultType="java.lang.Long">
select mlp.efficiency efficiency
from mes_line_product mlp
where mlp.del_flag = '0' and product_code = #{prodCode}
and mlp.line_code = #{lineCode}
</select>
<select id="getProcessCode" resultType="java.lang.String">
select prp.process_code from pro_route_process prp
left join pro_route pr on prp.route_id = pr.route_id
where pr.route_code = #{routeCode}
</select>
<insert id="createPrepareDetails">
insert into mes_prepare_detail
@ -738,6 +749,24 @@
</foreach>
</insert>
<insert id="insertWorkorders">
INSERT INTO pro_order_workorder (
workorder_id,workorder_code,order_id,order_code,product_code,
product_name,unit,quantity_split,route_code,prod_line_code,
product_date,parent_order, status,create_by,create_time,
prod_type,factory_code,end_flag,del_flag,sort_no,
belong_work_order
)VALUES
<foreach collection="list" item="d" index="index" separator=",">
(
#{d.workorderId},#{d.workorderCode},#{d.orderId},#{d.orderCode},#{d.productCode},
#{d.productName},#{d.unit},#{d.quantitySplit},#{d.routeCode},#{d.prodLineCodeArray},
#{d.productDate},#{d.parentOrder},#{d.status},#{d.createBy},#{d.createTime},
#{d.prodType}, #{d.factoryCode},#{d.endFlag},'2',#{d.sortNo},
#{d.belongWorkOrder}
)
</foreach>
</insert>
<update id="updateProOrderWorkorder" parameterType="ProOrderWorkorder">
update pro_order_workorder

Loading…
Cancel
Save