Commit a2e8a604 by yukang

自动排产

parent 0f07eb0f
...@@ -2,17 +2,22 @@ package com.baosight.hpjx.hp.sc.service; ...@@ -2,17 +2,22 @@ package com.baosight.hpjx.hp.sc.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation; import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.DdynamicEnum; import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.common.ProdOrderStatusEnum;
import com.baosight.hpjx.core.constant.CommonConstant; import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoBase; 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.domain.*;
import com.baosight.hpjx.hp.sc.tools.HPSCTools; import com.baosight.hpjx.hp.sc.tools.HPSCTools;
import com.baosight.hpjx.hp.xs.domain.Org; import com.baosight.hpjx.hp.xs.domain.Org;
import com.baosight.hpjx.hp.xs.tools.HPXSTools; 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.CommonMethod;
import com.baosight.hpjx.util.LogUtils; import com.baosight.hpjx.util.LogUtils;
import com.baosight.iplat4j.core.ei.EiConstant; import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo; import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceBase; import com.baosight.iplat4j.core.service.impl.ServiceBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -86,7 +91,7 @@ public class ServiceHPSC003B extends ServiceBase { ...@@ -86,7 +91,7 @@ public class ServiceHPSC003B extends ServiceBase {
Map parmMap = new HashMap(); Map parmMap = new HashMap();
parmMap.put("orgType","prodGroup"); parmMap.put("orgType","prodGroup");
parmMap.put("parentOrgId", factoryCode); 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) { } catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败"); LogUtils.setDetailMsg(inInfo, e, "初始化失败");
} }
...@@ -101,4 +106,56 @@ public class ServiceHPSC003B extends ServiceBase { ...@@ -101,4 +106,56 @@ public class ServiceHPSC003B extends ServiceBase {
public EiInfo query(EiInfo inInfo) { public EiInfo query(EiInfo inInfo) {
return 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 { ...@@ -226,6 +226,9 @@ public class ServiceHPSC005A extends ServiceBase {
for (String orderId : orderIds) { for (String orderId : orderIds) {
// 校验主订单是否已分派 // 校验主订单是否已分派
HPSC005 dbSc005 = HPSCTools.HpSc005.getById(Long.parseLong(orderId)); HPSC005 dbSc005 = HPSCTools.HpSc005.getById(Long.parseLong(orderId));
// 锁主单号
HPSCTools.HpSc005.lock(dbSc005.getProdOrderNo());
AssertUtils.isTrue(ProdOrderStatusEnum.ALL_ASSIGN.getCode().equals(dbSc005.getStatus()), AssertUtils.isTrue(ProdOrderStatusEnum.ALL_ASSIGN.getCode().equals(dbSc005.getStatus()),
String.format("生产订单[%s]已全部分派,不能在进行批量分派,请检查!", dbSc005.getProdOrderNo())); String.format("生产订单[%s]已全部分派,不能在进行批量分派,请检查!", dbSc005.getProdOrderNo()));
// 更新订单主表数量 // 更新订单主表数量
......
$(function () { $(function () {
IPLATUI.EFGrid = { IPLATUI.EFGrid = {
"result" : { "result": {
toolbarConfig: { toolbarConfig: {
hidden: true, // true时,不显示功能按钮,但保留setting导出按钮 hidden: true, // true时,不显示功能按钮,但保留setting导出按钮
}, },
...@@ -18,6 +18,53 @@ $(function () { ...@@ -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) { ...@@ -32,7 +79,8 @@ function deleteRow(rowNo) {
resultGrid.removeRows([rowNo]);// 刷新行号 resultGrid.removeRows([rowNo]);// 刷新行号
refreshRowNo(); refreshRowNo();
} }
let refreshRowNo =function() {
let refreshRowNo = function () {
let allRows = resultGrid.getDataItems(); let allRows = resultGrid.getDataItems();
for (let i = 0; i < allRows.length; i++) { for (let i = 0; i < allRows.length; i++) {
resultGrid.setCellValue(i, "rowNo", i); resultGrid.setCellValue(i, "rowNo", i);
...@@ -43,17 +91,4 @@ $(window).load(function () { ...@@ -43,17 +91,4 @@ $(window).load(function () {
refreshRowNo(); refreshRowNo();
}); });
/**
* 取消
*/
$('#cancel').on('click',function () {
// 关闭弹窗
parent.JSColorbox.close();
})
/**
* 确认
*/
$('#confirm').on('click',function () {
})
...@@ -10,8 +10,9 @@ ...@@ -10,8 +10,9 @@
<EF:EFRegion id="result" title="记录集"> <EF:EFRegion id="result" title="记录集">
<EF:EFGrid blockId="result" autoDraw="override"> <EF:EFGrid blockId="result" autoDraw="override">
<EF:EFColumn ename="operator" cname="操作" locked="true" enable="false" width="80" align="center"/> <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="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="projName" cname="项目名称" enable="false" width="140" align="center"/>
<EF:EFColumn ename="prdtName" cname="部件名称" enable="false" width="100" 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="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