Commit a2e8a604 by yukang

自动排产

parent 0f07eb0f
......@@ -2,17 +2,22 @@ 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.ProdOrderStatusEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoBase;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
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.AssertUtils;
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 com.baosight.iplat4j.ed.util.SequenceGenerator;
import org.apache.commons.collections.CollectionUtils;
import java.math.BigDecimal;
......@@ -86,7 +91,7 @@ public class ServiceHPSC003B extends ServiceBase {
Map parmMap = new HashMap();
parmMap.put("orgType","prodGroup");
parmMap.put("parentOrgId", factoryCode);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.GROUP_RECORD_BLOCK_ID), null, false);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.GROUP_RECORD_BLOCK_ID), parmMap, false);
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
......@@ -101,4 +106,56 @@ public class ServiceHPSC003B extends ServiceBase {
public EiInfo query(EiInfo inInfo) {
return inInfo;
}
/**
* 创建任务
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "自动排产",operType = "查询")
public EiInfo autoGenerateTask(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 写入数据
for (int i = 0; i < resultRows.size(); i++) {
HPSC005 hpsc005 = new HPSC005();
hpsc005.fromMap(resultRows.get(i));
HPSC005 dbSc005 = HPSCTools.HpSc005.get(hpsc005.getProdOrderNo());
// 锁主单号
HPSCTools.HpSc005.lock(dbSc005.getProdOrderNo());
// 校验主订单是否已分派
AssertUtils.isTrue(ProdOrderStatusEnum.ALL_ASSIGN.getCode().equals(dbSc005.getStatus()),
String.format("生产订单[%s]已全部分派,不能在进行批量分派,请检查!", dbSc005.getProdOrderNo()));
// 更新订单主表数量
if (ProdOrderStatusEnum.NOT_ASSIGN.getCode().equals(dbSc005.getStatus())) {
HPSCTools.checkAssignedNum(dbSc005.getProdOrderNo(), dbSc005.getNum());
} else {
HPSCTools.checkAssignedNum2(dbSc005.getProdOrderNo(), dbSc005.getUnassignedNum());
}
// 写入子表数据
HPSC005A newSc005a = new HPSC005A();
newSc005a.setProdTaskNo(SequenceGenerator.getNextSequence(HPConstant.SequenceId.PROD_TASK_NO,
new String[]{dbSc005.getProdOrderNo()}));
newSc005a.setProdOrderNo(dbSc005.getProdOrderNo());
//区分未派单与部分派单
if (ProdOrderStatusEnum.NOT_ASSIGN.getCode().equals(dbSc005.getStatus())) {
newSc005a.setNum(dbSc005.getNum());
} else {
newSc005a.setNum(dbSc005.getUnassignedNum());
}
newSc005a.setTotalWt(newSc005a.getNum().multiply(dbSc005.getUnitWt()));
newSc005a.setOrgNo(hpsc005.getOrgNo());
newSc005a.setOrgName(hpsc005.getOrgName());
newSc005a.setFactoryCode(hpsc005.getFactoryCode());
newSc005a.setFactoryName(hpsc005.getFactoryName());
DaoUtils.insert(HPSC005A.INSERT, newSc005a);
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据进行智能分派!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "智能分派失败");
}
return inInfo;
}
}
......@@ -226,6 +226,9 @@ public class ServiceHPSC005A extends ServiceBase {
for (String orderId : orderIds) {
// 校验主订单是否已分派
HPSC005 dbSc005 = HPSCTools.HpSc005.getById(Long.parseLong(orderId));
// 锁主单号
HPSCTools.HpSc005.lock(dbSc005.getProdOrderNo());
AssertUtils.isTrue(ProdOrderStatusEnum.ALL_ASSIGN.getCode().equals(dbSc005.getStatus()),
String.format("生产订单[%s]已全部分派,不能在进行批量分派,请检查!", dbSc005.getProdOrderNo()));
// 更新订单主表数量
......
......@@ -135,87 +135,87 @@ function showUploadFile(id) {
});
}
function check(id, auditStatus,planInfoNo) {
const inEiInfo = new EiInfo();
inEiInfo.set("id", id);
inEiInfo.set("planInfoNo",planInfoNo);
//先判断本身是否填写
EiCommunicator.send('HPSC003', 'getInfo', inEiInfo, {
onSuccess(ei) {
var model=ei.get("model");
if(!(model.planCompletionDate).trim()) {
NotificationUtil("提交失败!原因:基本信息中计划完成日期未填写", "error");
return;
} else {
//提交
//提交前先判断明细信息中的计划开始和计划结束时间是否都已经填写,只有填写了之后才能进行提交
if (auditStatus == 1) {
EiCommunicator.send('HPSC004', 'inspectDetail', inEiInfo, {
onSuccess(ei) {
var list=ei.get("list");
if(list) {
var count = list[0];
if (count > 0) {
NotificationUtil("提交失败!原因:明细信息中有未填写的计划开始时间或计划结束时间", "error");
} else {
EiCommunicator.send('HPSC004','queryDetail',inEiInfo,{
onSuccess(ei){
var rows = ei.blocks.detail.rows;
var res = check_time(model,rows);
if (!res){
NotificationUtil("计划结束时间应该大于计划开始时间!", "error");
}
else {
// 提交通过,生成
EiCommunicator.send('HPSC003', 'submitPlan', inEiInfo, {
onSuccess(response) {
NotificationUtil(response.msg);
console.log(response)
autoProductionschedul(response.get('planInfoNo'));
resultGrid.dataSource.page(1);
},
onFail(errorMessage, status, e) {
NotificationUtil("执行失败!", "error");
}
},
{
async: false
}
);
}
}
})
// const inEiInfo = new EiInfo();
// inEiInfo.set("id", id);
// inEiInfo.set("planInfoNo",planInfoNo);
// //先判断本身是否填写
// EiCommunicator.send('HPSC003', 'getInfo', inEiInfo, {
// onSuccess(ei) {
// var model=ei.get("model");
// if(!(model.planCompletionDate).trim()) {
// NotificationUtil("提交失败!原因:基本信息中计划完成日期未填写", "error");
// return;
// } else {
// //提交
// //提交前先判断明细信息中的计划开始和计划结束时间是否都已经填写,只有填写了之后才能进行提交
// if (auditStatus == 1) {
// EiCommunicator.send('HPSC004', 'inspectDetail', inEiInfo, {
// onSuccess(ei) {
// var list=ei.get("list");
// if(list) {
// var count = list[0];
// if (count > 0) {
// NotificationUtil("提交失败!原因:明细信息中有未填写的计划开始时间或计划结束时间", "error");
// } else {
// EiCommunicator.send('HPSC004','queryDetail',inEiInfo,{
// onSuccess(ei){
// var rows = ei.blocks.detail.rows;
// var res = check_time(model,rows);
// if (!res){
// NotificationUtil("计划结束时间应该大于计划开始时间!", "error");
// }
// else {
// // 提交通过,生成
// EiCommunicator.send('HPSC003', 'submitPlan', inEiInfo, {
// onSuccess(response) {
// NotificationUtil(response.msg);
// console.log(response)
// autoProductionschedul(response.get('planInfoNo'));
// resultGrid.dataSource.page(1);
// },
// onFail(errorMessage, status, e) {
// NotificationUtil("执行失败!", "error");
// }
// },
// {
// async: false
// }
// );
// }
//
//
// }
// })
//
// }
// } else {
// NotificationUtil("提交失败!未找到明细信息", "error");
// }
// },
// onFail(errorMessage, status, e) {
// NotificationUtil("执行失败!", "error");
// }
// },
// {
// async: false
// }
// );
// } else {
// // 撤回
//
// }
// }
// },
// onFail(errorMessage, status, e) {
// NotificationUtil("执行失败!", "error");
// }
// },
// {
// async: false
// }
// );
}
} else {
NotificationUtil("提交失败!未找到明细信息", "error");
}
},
onFail(errorMessage, status, e) {
NotificationUtil("执行失败!", "error");
}
},
{
async: false
}
);
} else {
// 撤回
}
}
},
onFail(errorMessage, status, e) {
NotificationUtil("执行失败!", "error");
}
},
{
async: false
}
);
// autoProductionschedul('SCJH24030700006');
autoProductionschedul('SCJH24030700006');
}
/**
......@@ -228,7 +228,7 @@ let autoProductionschedul = function (planInfoNo) {
href: "HPSC003A?methodName=initLoad&inqu_status-0-planInfoNo=" + planInfoNo,
title: "<div style='text-align: center;'>自动排产</div>",
width: "30%",
height: "80%",
height: "40%",
callbackName: autoProductionschedulCallback
});
}
......@@ -242,10 +242,12 @@ function autoProductionschedulCallback (factoryCode,planInfoNo) {
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%",
width: "80%",
height: "80%",
dispaly: "flex",
callbackName: autoProductionschedulCallback1
});
$("#JSColorboxWin").css({"height": "100%"})
} else {
message("生产计划单号不能为空!");
return;
......
$(function () {
IPLATUI.EFGrid = {
"result" : {
"result": {
toolbarConfig: {
hidden: true, // true时,不显示功能按钮,但保留setting导出按钮
},
......@@ -18,6 +18,53 @@ $(function () {
}
}
/**
* 取消
*/
$('#cancel').on('click', function () {
// 关闭弹窗
parent.JSColorbox.close();
})
/**
* 确认
*/
$('#confirm').on('click', function () {
let allRows = new Array();
allRows = resultGrid.getDataItems();
console.log(allRows);
if (allRows.length > 0) {
const inEiInfo = new EiInfo();
$.each(allRows, function(index, item) {
inEiInfo.set("result-"+index+"-id",item["id"])
inEiInfo.set("result-"+index+"-prodOrderNo",item["prodOrderNo"])
inEiInfo.set("result-"+index+"-factoryName",item["factoryName"])
inEiInfo.set("result-"+index+"-factoryCode",item["factoryCode"])
inEiInfo.set("result-"+index+"-orgName",item["orgName"])
inEiInfo.set("result-"+index+"-orgNo",item["orgNo"])
})
EiCommunicator.send('HPSC003B', 'autoGenerateTask', inEiInfo, {
onSuccess(response) {
NotificationUtil(response.msg);
// 关闭弹窗
parent.JSColorbox.close();
query();
},
onFail(errorMessage, status, e) {
NotificationUtil("执行失败!", "error");
}
},
{
async: false
}
);
} else {
message("没有可以生成的计划!");
return;
}
})
});
......@@ -32,7 +79,8 @@ function deleteRow(rowNo) {
resultGrid.removeRows([rowNo]);// 刷新行号
refreshRowNo();
}
let refreshRowNo =function() {
let refreshRowNo = function () {
let allRows = resultGrid.getDataItems();
for (let i = 0; i < allRows.length; i++) {
resultGrid.setCellValue(i, "rowNo", i);
......@@ -43,17 +91,4 @@ $(window).load(function () {
refreshRowNo();
});
/**
* 取消
*/
$('#cancel').on('click',function () {
// 关闭弹窗
parent.JSColorbox.close();
})
/**
* 确认
*/
$('#confirm').on('click',function () {
})
......@@ -10,8 +10,9 @@
<EF:EFRegion id="result" title="记录集">
<EF:EFGrid blockId="result" autoDraw="override">
<EF:EFColumn ename="operator" cname="操作" locked="true" enable="false" width="80" align="center"/>
<EF:EFColumn ename="id" cname="主键" hidden="true"/>
<EF:EFColumn ename="rowNo" cname="行号" hidden="true"/>
<EF:EFColumn ename="id" cname="主键" hidden="true"/>
<EF:EFColumn ename="prodOrderNo" 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"/>
......
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