Commit c09f82df by yukang

增加智能排产

parent ba062c73
package com.baosight.hpjx.hp.sc.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.common.HPConstants;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.pz.tools.HPPZTools;
import com.baosight.hpjx.hp.sc.domain.HPSC005;
import com.baosight.hpjx.hp.sc.domain.HPSC006;
import com.baosight.hpjx.hp.sc.tools.HPSCTools;
import com.baosight.hpjx.hp.xs.tools.HPXSTools;
import com.baosight.hpjx.util.AssertUtils;
import com.baosight.hpjx.util.CommonMethod;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.hpjx.util.StringUtil;
import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import com.baosight.iplat4j.core.util.NumberUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
*/
public class ServiceHPSC003A extends ServiceBase {
/**
* 画面初始化.
*/
@OperationLogAnnotation(operModul = "生产下料",operType = "查询",operDesc = "初始化")
public EiInfo initLoad(EiInfo inInfo) {
try {
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.FACTORY_RECORD_BLOCK_ID), null, false);
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
return inInfo;
}
}
package com.baosight.hpjx.hp.sc.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoBase;
import com.baosight.hpjx.hp.sc.domain.*;
import com.baosight.hpjx.hp.sc.tools.HPSCTools;
import com.baosight.hpjx.hp.xs.domain.Org;
import com.baosight.hpjx.hp.xs.tools.HPXSTools;
import com.baosight.hpjx.util.CommonMethod;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import org.apache.commons.collections.CollectionUtils;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
*
*/
public class ServiceHPSC003B extends ServiceBase {
/**
* 画面初始化.
*/
@OperationLogAnnotation(operModul = "自动排产",operType = "查询",operDesc = "初始化")
public EiInfo initLoad(EiInfo inInfo) {
try {
String planInfoNo = inInfo.getString("inqu_status-0-planInfoNo");
String factoryCode = inInfo.getString("inqu_status-0-factoryCode");
String factoryName = HPXSTools.XsOrg.get(factoryCode).getOrgCname();
//找到生产计划
List<HPSC004> hpsc004List = HPSCTools.HpSc004.queryByParent(planInfoNo);
List<Long> matIds = hpsc004List.stream().map(HPSC004 :: getMatId).sorted().collect(Collectors.toList());
List<HPSC005> hpsc005List = HPSCTools.HpSc005.listByMatId(matIds);
//过滤掉已经分派的订单
List<HPSC005> hpsc005sFilter = hpsc005List.stream().filter(hpsc005 -> hpsc005.getStatus() == 0).collect(Collectors.toList());
//根据厂区找到组织
List<Map> orgList = HPXSTools.XsOrg.queryParent(factoryCode, "prodGroup");
//找对应的任务重量
Org org = new Org();
List<HPSC003C> untotalWtList = new ArrayList<>();
for (Map orgMap : orgList) {
HPSC003C hpsc003C = new HPSC003C();
String orgId = orgMap.get("orgId").toString();
Map map1 = new HashMap();
map1.put("factoryCode", factoryCode);
map1.put("orgNo", orgId);
List<HPSC005C> hpsc005CList = DaoBase.getInstance().query("HPSC005C.sumUnTotalWt",map1);
HPSC005C hpsc005C = hpsc005CList.get(0);
hpsc003C.setOrgId(orgId);
hpsc003C.setUntotalWt(hpsc005C.getUnTotalWt());
untotalWtList.add(hpsc003C);
}
List<HPSC003C> untotalWtSorted = new ArrayList<>();
untotalWtSorted = untotalWtList.stream().sorted(Comparator.comparing(HPSC003C :: getUntotalWt)).collect(Collectors.toList());
//智能分派
if (CollectionUtils.isNotEmpty(untotalWtSorted) && CollectionUtils.isNotEmpty(hpsc005sFilter)) {
//当前生产组小于分派任务,循环生产组进行分配
int untotalWtSortedSize = untotalWtSorted.size();
int hpsc005sFilterSize = hpsc005sFilter.size();
int i = 0;
int j = 0;
while (i < hpsc005sFilterSize) {
if (j + 1 > untotalWtSortedSize) {
j = 0;
}
HPSC005 hpsc005 = hpsc005sFilter.get(i);
HPSC003C hpsc003C = untotalWtSorted.get(j);
hpsc005.setOrgNo(hpsc003C.getOrgId());
hpsc005.setOrgName(HPXSTools.XsOrg.get(hpsc003C.getOrgId()).getOrgCname());
hpsc005.setFactoryCode(factoryCode);
hpsc005.setFactoryName(factoryName);
i++;
j++;
}
inInfo.addBlock(EiConstant.resultBlock).addRows(hpsc005sFilter);
}
Map parmMap = new HashMap();
parmMap.put("orgType","prodGroup");
parmMap.put("parentOrgId", factoryCode);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.GROUP_RECORD_BLOCK_ID), null, false);
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
return inInfo;
}
/**
* 查询操作.
*/
@Override
@OperationLogAnnotation(operModul = "自动排产",operType = "查询")
public EiInfo query(EiInfo inInfo) {
return inInfo;
}
}
...@@ -169,4 +169,6 @@ ...@@ -169,4 +169,6 @@
<include refid="updateRevise"/> <include refid="updateRevise"/>
WHERE PROD_TASK_NO = #prodTaskNo# WHERE PROD_TASK_NO = #prodTaskNo#
</update> </update>
</sqlMap> </sqlMap>
...@@ -212,5 +212,18 @@ ...@@ -212,5 +212,18 @@
<include refid="condition" /> <include refid="condition" />
</select> </select>
<!--根据产区和生产组找到剩余工作总量-->
<select id="sumUnTotalWt" parameterClass="java.util.HashMap"
resultClass="com.baosight.hpjx.hp.sc.domain.HPSC005C">
SELECT
COALESCE(
(SUM( T1.NUM ) - SUM( T1.COMPLETE_NUM )) * T2.UNIT_WT
, 0) AS unTotalWt
FROM
${hpjxSchema}.T_HPSC005A T1
LEFT JOIN ${hpjxSchema}.T_HPSC005 T2 ON T1.PROD_ORDER_NO = T2.PROD_ORDER_NO
WHERE
T1.ORG_NO = #orgNo#
AND T1.FACTORY_CODE = #factoryCode#
</select>
</sqlMap> </sqlMap>
...@@ -362,6 +362,21 @@ public class HPSCTools { ...@@ -362,6 +362,21 @@ public class HPSCTools {
map.put("planCompletionDate", planCompletionDate); map.put("planCompletionDate", planCompletionDate);
DaoUtils.update(HPSqlConstant.HPSC003.UPDATE_DATE, map); DaoUtils.update(HPSqlConstant.HPSC003.UPDATE_DATE, map);
} }
/**
* 查询
*
* @param id
* @return
*/
public static HPSC003 getEntityByPlanInfoNo(String planInfoNo) {
AssertUtils.isNull(planInfoNo, "生产订单号不能为空");
Map queryMap = new HashMap();
queryMap.put("planInfoNo", planInfoNo);
List<HPSC003> results = DaoBase.getInstance().query(HPSC003.QUERY, queryMap);
AssertUtils.isNull(results, String.format("生产订单号[%s]信息不存在", planInfoNo));
return results.get(0);
}
} }
/** /**
......
...@@ -112,6 +112,25 @@ public class HPXSTools { ...@@ -112,6 +112,25 @@ public class HPXSTools {
AssertUtils.isNull(results, String.format("组织[%s]不存在厂区信息", orgId)); AssertUtils.isNull(results, String.format("组织[%s]不存在厂区信息", orgId));
return results.get(0); return results.get(0);
} }
/**
* 查询
*
* @param orgId
* @return
*/
public static List<Map> queryParent(String orgId,String orgType) {
AssertUtils.isNull(orgId, "组织ID不能为空");
AssertUtils.isNull(orgType, "组织类型不能为空");
Map queryMap = new HashMap();
queryMap.put("parentOrgId", orgId);
queryMap.put("orgType", orgType);
List<Map> results = DaoBase.getInstance().query("HPXSOrg.queryGroupComboBox", queryMap);
AssertUtils.isNull(results, String.format("组织[%s]不存在父级信息", orgId));
return results;
}
} }
......
...@@ -135,99 +135,129 @@ function showUploadFile(id) { ...@@ -135,99 +135,129 @@ function showUploadFile(id) {
}); });
} }
function check(id, auditStatus,planInfoNo) { function check(id, auditStatus,planInfoNo) {
const inEiInfo = new EiInfo(); // const inEiInfo = new EiInfo();
inEiInfo.set("id", id); // inEiInfo.set("id", id);
inEiInfo.set("planInfoNo",planInfoNo); // inEiInfo.set("planInfoNo",planInfoNo);
//先判断本身是否填写 // //先判断本身是否填写
EiCommunicator.send('HPSC003', 'getInfo', inEiInfo, { // EiCommunicator.send('HPSC003', 'getInfo', inEiInfo, {
onSuccess(ei) { // onSuccess(ei) {
var model=ei.get("model"); // var model=ei.get("model");
if(!(model.planCompletionDate).trim()) { // if(!(model.planCompletionDate).trim()) {
NotificationUtil("提交失败!原因:基本信息中计划完成日期未填写", "error"); // NotificationUtil("提交失败!原因:基本信息中计划完成日期未填写", "error");
return; // return;
} else { // } else {
//提交 // //提交
//提交前先判断明细信息中的计划开始和计划结束时间是否都已经填写,只有填写了之后才能进行提交 // //提交前先判断明细信息中的计划开始和计划结束时间是否都已经填写,只有填写了之后才能进行提交
if (auditStatus == 1) { // if (auditStatus == 1) {
EiCommunicator.send('HPSC004', 'inspectDetail', inEiInfo, { // EiCommunicator.send('HPSC004', 'inspectDetail', inEiInfo, {
onSuccess(ei) { // onSuccess(ei) {
var list=ei.get("list"); // var list=ei.get("list");
if(list) { // if(list) {
var count = list[0]; // var count = list[0];
if (count > 0) { // if (count > 0) {
NotificationUtil("提交失败!原因:明细信息中有未填写的计划开始时间或计划结束时间", "error"); // NotificationUtil("提交失败!原因:明细信息中有未填写的计划开始时间或计划结束时间", "error");
} else { // } else {
EiCommunicator.send('HPSC004','queryDetail',inEiInfo,{ // EiCommunicator.send('HPSC004','queryDetail',inEiInfo,{
onSuccess(ei){ // onSuccess(ei){
var rows = ei.blocks.detail.rows; // var rows = ei.blocks.detail.rows;
var res = check_time(model,rows); // var res = check_time(model,rows);
if (!res){ // if (!res){
NotificationUtil("计划结束时间应该大于计划开始时间!", "error"); // NotificationUtil("计划结束时间应该大于计划开始时间!", "error");
} // }
else { // else {
// 提交通过,生成 // // 提交通过,生成
EiCommunicator.send('HPSC003', 'submitPlan', inEiInfo, { // EiCommunicator.send('HPSC003', 'submitPlan', inEiInfo, {
onSuccess(response) { // onSuccess(response) {
NotificationUtil(response.msg); // NotificationUtil(response.msg);
console.log(response) // console.log(response)
autoProductionschedul(); // autoProductionschedul(response.get('planInfoNo'));
resultGrid.dataSource.page(1); // resultGrid.dataSource.page(1);
}, // },
onFail(errorMessage, status, e) { // onFail(errorMessage, status, e) {
NotificationUtil("执行失败!", "error"); // NotificationUtil("执行失败!", "error");
} // }
}, // },
{ // {
async: false // async: false
} // }
); // );
} // }
//
//
} // }
}) // })
//
} // }
} else { // } else {
NotificationUtil("提交失败!未找到明细信息", "error"); // NotificationUtil("提交失败!未找到明细信息", "error");
} // }
}, // },
onFail(errorMessage, status, e) { // onFail(errorMessage, status, e) {
NotificationUtil("执行失败!", "error"); // NotificationUtil("执行失败!", "error");
} // }
}, // },
{ // {
async: false // async: false
} // }
); // );
} else { // } else {
// 撤回 // // 撤回
//
} // }
} // }
}, // },
onFail(errorMessage, status, e) { // onFail(errorMessage, status, e) {
NotificationUtil("执行失败!", "error"); // NotificationUtil("执行失败!", "error");
} // }
}, // },
{ // {
async: false // async: false
} // }
); // );
autoProductionschedul('SCJH24030700006');
} }
/** /**
* 自动排产提示 * 自动排产提示
*/ */
let autoProductionschedul = function () { let autoProductionschedul = function (planInfoNo) {
JSUtils.confirm(" 生产计划提交成功,已生成生产订单!是否自动排产? ", { JSUtils.confirm(" 生产计划提交成功,已生成生产订单!是否自动排产? ", {
ok: function () { ok: function () {
console.log('1111') JSColorbox.open({
href: "HPSC003A?methodName=initLoad&inqu_status-0-planInfoNo=" + planInfoNo,
title: "<div style='text-align: center;'>自动排产</div>",
width: "30%",
height: "40%",
callbackName: autoProductionschedulCallback
});
} }
}); });
} }
function autoProductionschedulCallback (factoryCode,planInfoNo) {
JSColorbox.close();
if (factoryCode) {
if (planInfoNo) {
JSColorbox.open({
href: "HPSC003B?methodName=initLoad&inqu_status-0-planInfoNo=" + planInfoNo +
'&inqu_status-0-factoryCode=' + factoryCode,
title: "<div style='text-align: center;'>自动排产</div>",
width: "80%",
height: "80%",
callbackName: autoProductionschedulCallback1
});
} else {
message("生产计划单号不能为空!");
return;
}
} else {
message("请选择工厂生成生产任务!");
return;
}
}
function autoProductionschedulCallback1 () {
JSColorbox.close();
}
let query = function () { let query = function () {
resultGrid.dataSource.page(1); resultGrid.dataSource.page(1);
......
$(function () {
/**
* 取消
*/
$('#cancel').on('click',function () {
// 关闭弹窗
parent.JSColorbox.setValueCallback();
})
/**
* 确认
*/
$('#confirm').on('click',function () {
var factoryCode = $('#inqu_status-0-factoryCode').val();
var planInfoNo = $('#inqu_status-0-planInfoNo').val();
parent.JSColorbox.setValueCallback(factoryCode,planInfoNo);
})
});
<!DOCTYPE html>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="EF" tagdir="/WEB-INF/tags/EF" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<EF:EFPage title="自动排产">
<EF:EFRegion id="inqu" title="选择工厂">
<EF:EFInput ename="inqu_status-0-planInfoNo" cname="生产计划单号" type="hidden"/>
<div class="row">
<EF:EFSelect cname="厂区" ename="factoryCode" blockId="inqu_status" row="0" colWidth="3" filter="contains">
<EF:EFOption label="全部" value=""/>
<EF:EFOptions blockId="factory_record_block_id" textField="textField" valueField="valueField"/>
</EF:EFSelect>
</div>
<br/>
<span style='color: red;font-size: 13px;'>请选择工厂生成生产任务!</span>
<div class="row">
<EF:EFButton ename="cancel" cname="取消" type="button" class="btn-align-right"/>
<EF:EFButton ename="confirm" cname="确认" type="button" class="btn-align-right"/>
</div>
</EF:EFRegion>
</EF:EFPage>
$(function () {
IPLATUI.EFGrid = {
"result" : {
pageable: {
pageSize: 15,
pageSizes: [15, 50, 70, 100],
}
}
}
});
/**
* 查询
*/
function query() {
resultGrid.dataSource.page(1);
}
<!DOCTYPE html>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="EF" tagdir="/WEB-INF/tags/EF" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<EF:EFPage title="生产任务">
<EF:EFRegion id="result" title="记录集">
<EF:EFGrid blockId="result" autoDraw="override">
<EF:EFColumn ename="id" cname="主键" hidden="true"/>
<EF:EFColumn ename="projName" cname="项目名称" enable="false" width="140" align="center"/>
<EF:EFColumn ename="prdtName" cname="部件名称" enable="false" width="100" align="center"/>
<EF:EFColumn ename="partName" cname="零件名称" enable="false" width="100" align="center"/>
<EF:EFColumn ename="partSpec" cname="规格" enable="false" width="100" align="center"/>
<EF:EFColumn ename="num" cname="数量" enable="false" width="100" align="right" format="{0:N0}"/>
<EF:EFColumn ename="unitWt" cname="单重(T)" enable="false" width="100" align="right" format="{0:N3}"/>
<EF:EFColumn ename="totalWt" cname="重量(T)" enable="false" width="100" align="right" format="{0:N3}"/>
<EF:EFColumn ename="remark1" cname="零件备注"/>
<EF:EFColumn ename="factoryName" cname="厂区" enable="false" width="140" align="center"/>
<EF:EFColumn ename="factoryCode" cname="厂区" enable="false" width="140" align="center" hidden="true"/>
<EF:EFColumn ename="orgName" cname="生产组" enable="false" width="140" align="center" hidden="true"/>
<EF:EFComboColumn ename="orgNo" cname="生产组" width="110" align="center" defaultValue=""
filter="contains" readonly="true">
<EF:EFOptions blockId="group_record_block_id" valueField="valueField" textField="textField"/>
</EF:EFComboColumn>
<EF:EFColumn ename="operator" cname="操作" locked="true" enable="false" width="80" align="center"/>
</EF:EFGrid>
</EF:EFRegion>
</EF:EFPage>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment