Commit 6865672c by 宋祥

Merge branch 'dev' of ssh://10.70.33.7:32359/smart/hp-smart into dev

parents e19ff7a6 8808e50b
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);
}
} }
/** /**
......
...@@ -200,6 +200,25 @@ public class HPXSTools { ...@@ -200,6 +200,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;
}
} }
......
$(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