Commit c1c9904b by liuyang

Merge branch 'dev' of http://git.pseer.com:8800/platform/hg-smart into dev-ly

parents 3beb5ae2 ee2940b9
...@@ -7,14 +7,21 @@ import java.util.HashMap; ...@@ -7,14 +7,21 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
/**
* 产品类型枚举
*
* @author:songx
* @date:2024/9/10,8:43
*/
public enum ProductTypeEnum { public enum ProductTypeEnum {
STRUCT(1,"构建"),
PART(2,"零件"); STRUCT(1, "构件"),
PART(2, "零件");
private Integer code;
private Integer code;
private String value;
private String value;
ProductTypeEnum(Integer code, String value) { ProductTypeEnum(Integer code, String value) {
this.code = code; this.code = code;
this.value = value; this.value = value;
...@@ -35,19 +42,19 @@ public enum ProductTypeEnum { ...@@ -35,19 +42,19 @@ public enum ProductTypeEnum {
block.setRows(rows); block.setRows(rows);
return block; return block;
} }
public static ProductTypeEnum getEnumByCode(Integer code){ public static ProductTypeEnum getEnumByCode(Integer code) {
for (ProductTypeEnum en : ProductTypeEnum.values()){ for (ProductTypeEnum en : ProductTypeEnum.values()) {
if(code.compareTo(en.code)==0){ if (code.compareTo(en.code) == 0) {
return en; return en;
} }
} }
return null; return null;
} }
public Integer getCode() { public Integer getCode() {
return code; return code;
} }
public void setCode(Integer code) { public void setCode(Integer code) {
this.code = code; this.code = code;
......
...@@ -57,6 +57,20 @@ public class CommonConstant { ...@@ -57,6 +57,20 @@ public class CommonConstant {
} }
/** /**
* 排序类型
*
* @author:songx
* @date:2024/1/20,15:04
*/
public static class SortType {
// 正序
public static final String ASC = "asc";
// 倒序
public static final String DESC = "desc";
}
/**
* 设备计划状态 * 设备计划状态
* *
* @author:songx * @author:songx
......
...@@ -63,84 +63,86 @@ public class ServiceHGKC008A extends ServiceBase { ...@@ -63,84 +63,86 @@ public class ServiceHGKC008A extends ServiceBase {
String receiveId = inInfo.getCellStr(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HGKC008A.FIELD_RECEIVE_ID); String receiveId = inInfo.getCellStr(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HGKC008A.FIELD_RECEIVE_ID);
//查看明细是否都删除了,都删除了得修改主表信息 //查看明细是否都删除了,都删除了得修改主表信息
HGKCTools.HgKc008A.checkMainData(ids,Long.valueOf(receiveId)); HGKCTools.HgKc008A.checkMainData(ids, Long.valueOf(receiveId));
inInfo = this.query(inInfo); inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT); inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据删除成功!"); inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据删除成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "删除失败");
}
return inInfo;
}
public EiInfo save(EiInfo inInfo){
try {
Map resultMap = EiInfoUtils.getFirstRow(inInfo,EiConstant.resultBlock);
HGKC008A hgkc008a = new HGKC008A();
hgkc008a.fromMap(resultMap);
//查询领料单
HGKC008 hgkc008 = HGKCTools.HgKc008.getById(hgkc008a.getReceiveId());
this.checkSaveData(hgkc008a,hgkc008);
this.setData(hgkc008a,hgkc008);
if(Objects.nonNull(hgkc008a.getId())&&hgkc008a.getId()!=0){
DaoUtils.update(HGKC008A.UPDATE, hgkc008a);
}else {
DaoUtils.insert(HGKC008A.INSERT, hgkc008a);
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("保存成功!");
} catch (Exception e) { } catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败"); LogUtils.setDetailMsg(inInfo, e, "删除失败");
}
return inInfo;
}
/**
* 给明细赋值
* @param hgkc008a
* @param hgkc008
*/
private void setData(HGKC008A hgkc008a, HGKC008 hgkc008) {
if(Objects.nonNull(hgkc008)){
hgkc008a.setProjCode(hgkc008.getProjCode());
hgkc008a.setProjName(hgkc008.getProjName());
hgkc008a.setWhCode(hgkc008.getWhCode());
hgkc008a.setWhName(hgkc008.getWhName());
hgkc008a.setCompanyCode(hgkc008.getCompanyCode());
hgkc008a.setCompanyName(hgkc008.getCompanyName());
if(hgkc008.getReceiveType().compareTo(HGConstant.ReceiveType.DEFAULT) == 0){
//如果明细里面有负数的,主表就是退库
if(hgkc008a.getInvQty().compareTo(BigDecimal.ZERO) < 0){
hgkc008.setReceiveType(HGConstant.ReceiveType.TK);
}else{
hgkc008.setReceiveType(HGConstant.ReceiveType.ZC);
}
DaoUtils.update(HGKC008.UPDATE_RECEIVE_TYPE, hgkc008);
}
} }
return inInfo;
} }
/** /**
* 校验保存的数据 * @param inInfo
* * @return
* @param hgkc008a */
* @param hgkc008 public EiInfo save(EiInfo inInfo) {
*/ try {
private void checkSaveData(HGKC008A hgkc008a, HGKC008 hgkc008) { HGKC008A fKc008a = MapUtils.toDaoEPBase(inInfo, HGKC008A.class);
AssertUtils.isEmpty(UserSessionUtils.getAccountCode(), "当前用户未绑定公司,无法操作数据,请联系管理员!"); //查询领料单
AssertUtils.isEmpty(UserSessionUtils.getOrgId(), "当前用户未绑定部门,无法操作数据,请联系管理员!"); HGKC008 dbKc008 = HGKCTools.HgKc008.getById(fKc008a.getReceiveId());
AssertUtils.isNull(hgkc008a.getReceiveId(), "未获取到生产领料单ID信息"); this.checkSaveData(fKc008a, dbKc008);
AssertUtils.isTrue(hgkc008a.getInvWeight().compareTo(BigDecimal.ZERO) == 0, "重量不能为0"); this.setData(fKc008a, dbKc008);
if(Objects.nonNull(hgkc008a.getId())&&hgkc008a.getId()!=0){ if (Objects.nonNull(fKc008a.getId()) && fKc008a.getId() != 0) {
if(hgkc008.getReceiveType().compareTo(HGConstant.ReceiveType.ZC) == 0){ DaoUtils.update(HGKC008A.UPDATE, fKc008a);
AssertUtils.isTrue(hgkc008a.getInvQty().compareTo(BigDecimal.ZERO) < 0, "此生产领料单为正常类型,数量不能小于0"); } else {
} DaoUtils.insert(HGKC008A.INSERT, fKc008a);
if(hgkc008.getReceiveType().compareTo(HGConstant.ReceiveType.TK) == 0){ }
AssertUtils.isTrue(hgkc008a.getInvQty().compareTo(BigDecimal.ZERO) > 0, "此生产领料单为退库类型,数量不能大于0"); inInfo.setStatus(EiConstant.STATUS_DEFAULT);
} inInfo.setMsg("保存成功!");
} } catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
/**
* 给明细赋值
*
* @param hgkc008a
* @param hgkc008
*/
private void setData(HGKC008A hgkc008a, HGKC008 hgkc008) {
if (Objects.nonNull(hgkc008)) {
hgkc008a.setProjCode(hgkc008.getProjCode());
hgkc008a.setProjName(hgkc008.getProjName());
hgkc008a.setWhCode(hgkc008.getWhCode());
hgkc008a.setWhName(hgkc008.getWhName());
hgkc008a.setCompanyCode(hgkc008.getCompanyCode());
hgkc008a.setCompanyName(hgkc008.getCompanyName());
if (hgkc008.getReceiveType().compareTo(HGConstant.ReceiveType.DEFAULT) == 0) {
//如果明细里面有负数的,主表就是退库
if (hgkc008a.getInvQty().compareTo(BigDecimal.ZERO) < 0) {
hgkc008.setReceiveType(HGConstant.ReceiveType.TK);
} else {
hgkc008.setReceiveType(HGConstant.ReceiveType.ZC);
}
DaoUtils.update(HGKC008.UPDATE_RECEIVE_TYPE, hgkc008);
}
}
}
/**
* 校验保存的数据
*
* @param fKc008a
* @param dbKc008
*/
private void checkSaveData(HGKC008A fKc008a, HGKC008 dbKc008) {
AssertUtils.isEmpty(UserSessionUtils.getAccountCode(), "当前用户未绑定公司,无法操作数据,请联系管理员!");
AssertUtils.isEmpty(UserSessionUtils.getOrgId(), "当前用户未绑定部门,无法操作数据,请联系管理员!");
AssertUtils.isNull(fKc008a.getReceiveId(), "未获取到生产领料单ID信息");
AssertUtils.isTrue(fKc008a.getInvWeight().compareTo(BigDecimal.ZERO) == 0, "重量不能为0");
if (Objects.nonNull(fKc008a.getId()) && fKc008a.getId() != 0) {
if (dbKc008.getReceiveType().compareTo(HGConstant.ReceiveType.ZC) == 0) {
AssertUtils.isTrue(fKc008a.getInvQty().compareTo(BigDecimal.ZERO) < 0, "此生产领料单为正常类型,数量不能小于0");
}
if (dbKc008.getReceiveType().compareTo(HGConstant.ReceiveType.TK) == 0) {
AssertUtils.isTrue(fKc008a.getInvQty().compareTo(BigDecimal.ZERO) > 0, "此生产领料单为退库类型,数量不能大于0");
}
}
} }
} }
......
...@@ -21,7 +21,29 @@ public class HgScSqlConstant { ...@@ -21,7 +21,29 @@ public class HgScSqlConstant {
// 修改项目名称 // 修改项目名称
public static final String UPDATE_PROJ_NAME = "HGSC001.updateProjName"; public static final String UPDATE_PROJ_NAME = "HGSC001.updateProjName";
} }
/**
*
* @author:songx
* @date:2024/9/10,10:17
*/
public static class HgSc005 {
// 修改排产状态
public static final String UPDATE_IS_SCHEDULE = "HGSC005.updateIsSchedule";
}
/**
*
* @author:songx
* @date:2024/9/10,9:59
*/
public static class HgSc005A {
// 修改计划时间
public static final String UPDATE_PLAN_DATE = "HGSC005A.updatePlanDate";
}
/** /**
* *
* @author:songx * @author:songx
......
...@@ -4,6 +4,7 @@ import com.baosight.hggp.aspect.annotation.OperationLogAnnotation; ...@@ -4,6 +4,7 @@ import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.common.DdynamicEnum; import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.core.constant.CommonConstant; import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.dao.DaoUtils; import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.hg.sc.constant.HgScSqlConstant;
import com.baosight.hggp.hg.sc.domain.HGSC005; import com.baosight.hggp.hg.sc.domain.HGSC005;
import com.baosight.hggp.hg.sc.domain.HGSC005A; import com.baosight.hggp.hg.sc.domain.HGSC005A;
import com.baosight.hggp.hg.sc.tools.HGSCTools; import com.baosight.hggp.hg.sc.tools.HGSCTools;
...@@ -125,15 +126,16 @@ public class ServiceHGSC005A extends ServiceBase { ...@@ -125,15 +126,16 @@ public class ServiceHGSC005A extends ServiceBase {
* @return * @return
*/ */
@OperationLogAnnotation(operModul = "生产计划详情", operType = "排产", operDesc = "排产") @OperationLogAnnotation(operModul = "生产计划详情", operType = "排产", operDesc = "排产")
public EiInfo scheduleEx(EiInfo inInfo) { public EiInfo scheduleAsc(EiInfo inInfo) {
try { try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo); Map queryMap = EiInfoUtils.getFirstRow(inInfo);
String planCode = MapUtils.getString(queryMap, "planCode"); String planCode = MapUtils.getString(queryMap, "planCode");
HGSC005 dbSc005 = HGSCTools.THGSC005.queryByPlanCode(planCode); HGSC005 dbSc005 = HGSCTools.THGSC005.queryByPlanCode(planCode);
this.checkScheduleData(dbSc005); this.checkScheduleData(dbSc005);
int count = HGSCTools.THGSC005A.schedule(queryMap, "A"); // 排产计算
int count = HGSCTools.THGSC005A.schedule(dbSc005, queryMap, CommonConstant.SortType.ASC);
dbSc005.setIsSchedule(CommonConstant.YesNo.YES_1); dbSc005.setIsSchedule(CommonConstant.YesNo.YES_1);
DaoUtils.update(HGSC005.UPDATE, dbSc005); DaoUtils.update(HgScSqlConstant.HgSc005.UPDATE_IS_SCHEDULE, dbSc005);
inInfo = this.query(inInfo); inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT); inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + count + "]条数据排产成功!"); inInfo.setMsg("操作成功!本次对[" + count + "]条数据排产成功!");
...@@ -156,9 +158,9 @@ public class ServiceHGSC005A extends ServiceBase { ...@@ -156,9 +158,9 @@ public class ServiceHGSC005A extends ServiceBase {
String planCode = MapUtils.getString(queryMap, "planCode"); String planCode = MapUtils.getString(queryMap, "planCode");
HGSC005 dbSc005 = HGSCTools.THGSC005.queryByPlanCode(planCode); HGSC005 dbSc005 = HGSCTools.THGSC005.queryByPlanCode(planCode);
this.checkScheduleData(dbSc005); this.checkScheduleData(dbSc005);
int count = HGSCTools.THGSC005A.schedule(queryMap, "D"); int count = HGSCTools.THGSC005A.schedule(dbSc005, queryMap, CommonConstant.SortType.DESC);
dbSc005.setIsSchedule(CommonConstant.YesNo.YES_1); dbSc005.setIsSchedule(CommonConstant.YesNo.YES_1);
DaoUtils.update(HGSC005.UPDATE, dbSc005); DaoUtils.update(HgScSqlConstant.HgSc005.UPDATE_IS_SCHEDULE, dbSc005);
inInfo = this.query(inInfo); inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT); inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + count + "]条数据排产成功!"); inInfo.setMsg("操作成功!本次对[" + count + "]条数据排产成功!");
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd"> <!-- table information <!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">
Generate time : 2024-05-16 16:50:12
Version : 1.0
schema : hggp
tableName : HGSC005
id BIGINT NOT NULL primarykey,
mat_id BIGINT NOT NULL,
company_code VARCHAR NOT NULL,
company_name VARCHAR NOT NULL,
proj_code VARCHAR,
proj_name VARCHAR,
plan_code VARCHAR,
commit_status TINYINT,
finish_date VARCHAR,
account_code VARCHAR NOT NULL,
dep_code VARCHAR,
dep_name VARCHAR,
created_by VARCHAR,
created_name VARCHAR,
created_time VARCHAR,
updated_by VARCHAR,
updated_name VARCHAR,
updated_time VARCHAR
-->
<sqlMap namespace="HGSC005"> <sqlMap namespace="HGSC005">
<sql id="condition"> <sql id="column">
<include refid="HGXSDataAuth.authCondition"/> id as "id",
mat_id as "matId", <!-- 物料清单ID -->
company_code as "companyCode", <!-- 公司编码 -->
company_name as "companyName", <!-- 公司名称 -->
proj_code as "projCode", <!-- 项目编码 -->
proj_name as "projName", <!-- 项目名称 -->
plan_code as "planCode", <!-- 计划编码 -->
commit_status as "commitStatus", <!-- 提交状态 0:未提交;2:已提交 -->
is_schedule as "isSchedule", <!-- 是否排产 0:否;1:是 -->
finish_date as "finishDate", <!-- 完工日期 -->
account_code as "accountCode", <!-- 帐套 -->
dep_code as "depCode", <!-- 部门编码 -->
dep_name as "depName", <!-- 部门名称 -->
created_by as "createdBy", <!-- 创建人 -->
created_name as "createdName", <!-- 创建人名称 -->
created_time as "createdTime", <!-- 创建时间 -->
updated_by as "updatedBy", <!-- 更新人 -->
updated_name as "updatedName", <!-- 修改人名称 -->
updated_time as "updatedTime" <!-- 更新时间 -->
</sql>
<isNotEmpty prepend=" AND " property="id"> <sql id="condition">
id = #id# <include refid="HGXSDataAuth.authCondition"/>
</isNotEmpty> <isNotEmpty prepend=" AND " property="id">
<isNotEmpty prepend=" AND " property="matId"> id = #id#
mat_id = #matId# </isNotEmpty>
</isNotEmpty> <isNotEmpty prepend=" AND " property="matId">
<isNotEmpty prepend=" AND " property="companyCode"> mat_id = #matId#
company_code = #companyCode# </isNotEmpty>
</isNotEmpty> <isNotEmpty prepend=" AND " property="companyCode">
<isNotEmpty prepend=" AND " property="companyName"> company_code = #companyCode#
company_name like ('%$companyName$%') </isNotEmpty>
</isNotEmpty> <isNotEmpty prepend=" AND " property="companyName">
<isNotEmpty prepend=" AND " property="projCode"> company_name like ('%$companyName$%')
proj_code = #projCode# </isNotEmpty>
</isNotEmpty> <isNotEmpty prepend=" AND " property="projCode">
<isNotEmpty prepend=" AND " property="projName"> proj_code = #projCode#
proj_name like ('%$projName$%') </isNotEmpty>
</isNotEmpty> <isNotEmpty prepend=" AND " property="projName">
<isNotEmpty prepend=" AND " property="planCode"> proj_name like ('%$projName$%')
plan_code like ('%$planCode$%') </isNotEmpty>
</isNotEmpty> <isNotEmpty prepend=" AND " property="planCode">
<isNotEmpty prepend=" AND " property="commitStatus"> plan_code like ('%$planCode$%')
commit_status = #commitStatus# </isNotEmpty>
</isNotEmpty> <isNotEmpty prepend=" AND " property="commitStatus">
<isNotEmpty prepend=" AND " property="finishDate"> commit_status = #commitStatus#
finish_date = #finishDate# </isNotEmpty>
</isNotEmpty> <isNotEmpty prepend=" AND " property="finishDate">
<isNotEmpty prepend=" AND " property="isSchedule"> finish_date = #finishDate#
is_schedule = #isSchedule# </isNotEmpty>
</isNotEmpty> <isNotEmpty prepend=" AND " property="isSchedule">
<isNotEmpty prepend=" AND " property="accountCode"> is_schedule = #isSchedule#
account_code = #accountCode# </isNotEmpty>
</isNotEmpty> <isNotEmpty prepend=" AND " property="accountCode">
<isNotEmpty prepend=" AND " property="depCode"> account_code = #accountCode#
dep_code = #depCode# </isNotEmpty>
</isNotEmpty> <isNotEmpty prepend=" AND " property="depCode">
<isNotEmpty prepend=" AND " property="depName"> dep_code = #depCode#
dep_name = #depName# </isNotEmpty>
</isNotEmpty> <isNotEmpty prepend=" AND " property="depName">
<isNotEmpty prepend=" AND " property="createdBy"> dep_name = #depName#
created_by = #createdBy# </isNotEmpty>
</isNotEmpty> <isNotEmpty prepend=" AND " property="createdBy">
<isNotEmpty prepend=" AND " property="createdName"> created_by = #createdBy#
created_name = #createdName# </isNotEmpty>
</isNotEmpty> <isNotEmpty prepend=" AND " property="createdName">
<isNotEmpty prepend=" AND " property="createdTime"> created_name = #createdName#
date_format(created_time,'%Y-%m-%d') = #createdTime# </isNotEmpty>
</isNotEmpty> <isNotEmpty prepend=" AND " property="createdTime">
<isNotEmpty prepend=" AND " property="updatedBy"> date_format(created_time,'%Y-%m-%d') = #createdTime#
updated_by = #updatedBy# </isNotEmpty>
</isNotEmpty> <isNotEmpty prepend=" AND " property="updatedBy">
<isNotEmpty prepend=" AND " property="updatedName"> updated_by = #updatedBy#
updated_name = #updatedName# </isNotEmpty>
</isNotEmpty> <isNotEmpty prepend=" AND " property="updatedName">
<isNotEmpty prepend=" AND " property="updatedTime"> updated_name = #updatedName#
updated_time = #updatedTime# </isNotEmpty>
</isNotEmpty> <isNotEmpty prepend=" AND " property="updatedTime">
<isNotEmpty prepend=" AND " property="matIds"> updated_time = #updatedTime#
mat_id NOT IN <iterate close=")" open="(" conjunction="," property="matIds">#matIds[]#</iterate> </isNotEmpty>
</isNotEmpty> <isNotEmpty prepend=" AND " property="matIds">
</sql> mat_id NOT IN
<iterate close=")" open="(" conjunction="," property="matIds">#matIds[]#</iterate>
</isNotEmpty>
</sql>
<select id="query" parameterClass="java.util.HashMap" <sql id="orderBy">
resultClass="com.baosight.hggp.hg.sc.domain.HGSC005"> <dynamic prepend="ORDER BY">
SELECT <isNotEmpty property="orderBy">
id as "id", $orderBy$
mat_id as "matId", <!-- 物料清单ID --> </isNotEmpty>
company_code as "companyCode", <!-- 公司编码 --> <isEmpty property="orderBy">
company_name as "companyName", <!-- 公司名称 --> id desc
proj_code as "projCode", <!-- 项目编码 --> </isEmpty>
proj_name as "projName", <!-- 项目名称 --> </dynamic>
plan_code as "planCode", <!-- 计划编码 --> </sql>
commit_status as "commitStatus", <!-- 提交状态 0:未提交;2:已提交 -->
is_schedule as "isSchedule", <!-- 是否排产 0:否;1:是 -->
finish_date as "finishDate", <!-- 完工日期 -->
account_code as "accountCode", <!-- 帐套 -->
dep_code as "depCode", <!-- 部门编码 -->
dep_name as "depName", <!-- 部门名称 -->
created_by as "createdBy", <!-- 创建人 -->
created_name as "createdName", <!-- 创建人名称 -->
created_time as "createdTime", <!-- 创建时间 -->
updated_by as "updatedBy", <!-- 更新人 -->
updated_name as "updatedName", <!-- 修改人名称 -->
updated_time as "updatedTime" <!-- 更新时间 -->
FROM ${hggpSchema}.HGSC005 WHERE 1=1
<include refid="condition" />
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy">
$orderBy$
</isNotEmpty>
<isEmpty property="orderBy">
id desc
</isEmpty>
</dynamic>
</select> <select id="query" resultClass="com.baosight.hggp.hg.sc.domain.HGSC005">
SELECT
<include refid="column"/>
FROM ${hggpSchema}.HGSC005 WHERE 1=1
<include refid="condition"/>
<include refid="orderBy"/>
</select>
<select id="count" resultClass="int"> <select id="count" resultClass="int">
SELECT COUNT(*) FROM ${hggpSchema}.HGSC005 WHERE 1=1 SELECT COUNT(*) FROM ${hggpSchema}.HGSC005 WHERE 1=1
<include refid="condition" /> <include refid="condition"/>
</select> </select>
<!-- <insert id="insert">
<isNotEmpty prepend=" AND " property="id"> INSERT INTO ${hggpSchema}.HGSC005 (
id = #id# mat_id, <!-- 物料清单ID -->
</isNotEmpty> company_code, <!-- 公司编码 -->
<isNotEmpty prepend=" AND " property="matId"> company_name, <!-- 公司名称 -->
mat_id = #matId# proj_code, <!-- 项目编码 -->
</isNotEmpty> proj_name, <!-- 项目名称 -->
<isNotEmpty prepend=" AND " property="companyCode"> plan_code, <!-- 计划编码 -->
company_code = #companyCode# commit_status, <!-- 提交状态 0:未提交;2:已提交 -->
</isNotEmpty> finish_date, <!-- 完工日期 -->
<isNotEmpty prepend=" AND " property="companyName"> is_schedule, <!-- 是否排产 0:否;1:是 -->
company_name = #companyName# account_code, <!-- 帐套 -->
</isNotEmpty> dep_code, <!-- 部门编码 -->
<isNotEmpty prepend=" AND " property="projCode"> dep_name, <!-- 部门名称 -->
proj_code = #projCode# created_by, <!-- 创建人 -->
</isNotEmpty> created_name, <!-- 创建人名称 -->
<isNotEmpty prepend=" AND " property="projName"> created_time <!-- 创建时间 -->
proj_name = #projName# ) VALUES (
</isNotEmpty> #matId#, #companyCode#, #companyName#, #projCode#, #projName#, #planCode#, #commitStatus#, #finishDate#,
<isNotEmpty prepend=" AND " property="planCode"> #isSchedule#, #accountCode#, #depCode#, #depName#, #createdBy#, #createdName#, #createdTime#, #updatedBy#,
plan_code = #planCode# #updatedName#, #updatedTime#
</isNotEmpty> )
<isNotEmpty prepend=" AND " property="commitStatus"> </insert>
commit_status = #commitStatus#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="finishDate">
finish_date = #finishDate#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountCode">
account_code = #accountCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="depCode">
dep_code = #depCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="depName">
dep_name = #depName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdBy">
created_by = #createdBy#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdName">
created_name = #createdName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdTime">
created_time = #createdTime#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedBy">
updated_by = #updatedBy#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedName">
updated_name = #updatedName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedTime">
updated_time = #updatedTime#
</isNotEmpty>
-->
<insert id="insert">
INSERT INTO ${hggpSchema}.HGSC005 (id,
mat_id, <!-- 物料清单ID -->
company_code, <!-- 公司编码 -->
company_name, <!-- 公司名称 -->
proj_code, <!-- 项目编码 -->
proj_name, <!-- 项目名称 -->
plan_code, <!-- 计划编码 -->
commit_status, <!-- 提交状态 0:未提交;2:已提交 -->
finish_date, <!-- 完工日期 -->
is_schedule, <!-- 是否排产 0:否;1:是 -->
account_code, <!-- 帐套 -->
dep_code, <!-- 部门编码 -->
dep_name, <!-- 部门名称 -->
created_by, <!-- 创建人 -->
created_name, <!-- 创建人名称 -->
created_time, <!-- 创建时间 -->
updated_by, <!-- 更新人 -->
updated_name, <!-- 修改人名称 -->
updated_time <!-- 更新时间 -->
)
VALUES (#id#, #matId#, #companyCode#, #companyName#, #projCode#, #projName#, #planCode#, #commitStatus#, #finishDate#, #isSchedule#, #accountCode#, #depCode#, #depName#, #createdBy#, #createdName#, #createdTime#, #updatedBy#, #updatedName#, #updatedTime#)
</insert>
<delete id="delete"> <delete id="delete">
DELETE FROM ${hggpSchema}.HGSC005 WHERE DELETE FROM ${hggpSchema}.HGSC005 WHERE ID = #id#
id = #id#
</delete> </delete>
<delete id="delete_by_mat_id"> <delete id="delete_by_mat_id">
DELETE FROM ${hggpSchema}.HGSC005 WHERE DELETE FROM ${hggpSchema}.HGSC005 WHERE MAT_ID = #matId#
mat_id = #matId# </delete>
</delete>
<update id="update"> <update id="update">
UPDATE ${hggpSchema}.HGSC005 UPDATE ${hggpSchema}.HGSC005
SET SET
mat_id = #matId#, <!-- 物料清单ID --> mat_id = #matId#, <!-- 物料清单ID -->
company_code = #companyCode#, <!-- 公司编码 --> company_code = #companyCode#, <!-- 公司编码 -->
company_name = #companyName#, <!-- 公司名称 --> company_name = #companyName#, <!-- 公司名称 -->
proj_code = #projCode#, <!-- 项目编码 --> proj_code = #projCode#, <!-- 项目编码 -->
proj_name = #projName#, <!-- 项目名称 --> proj_name = #projName#, <!-- 项目名称 -->
plan_code = #planCode#, <!-- 计划编码 --> plan_code = #planCode#, <!-- 计划编码 -->
commit_status = #commitStatus#, <!-- 提交状态 0:未提交;2:已提交 --> commit_status = #commitStatus#, <!-- 提交状态 0:未提交;2:已提交 -->
finish_date = #finishDate#, <!-- 完工日期 --> finish_date = #finishDate#, <!-- 完工日期 -->
is_schedule = #isSchedule#, <!-- 是否排产 0:否;1:是 --> is_schedule = #isSchedule#, <!-- 是否排产 0:否;1:是 -->
account_code = #accountCode#, <!-- 帐套 --> account_code = #accountCode#, <!-- 帐套 -->
dep_code = #depCode#, <!-- 部门编码 --> dep_code = #depCode#, <!-- 部门编码 -->
dep_name = #depName#, <!-- 部门名称 --> dep_name = #depName#, <!-- 部门名称 -->
created_by = #createdBy#, <!-- 创建人 --> created_by = #createdBy#, <!-- 创建人 -->
created_name = #createdName#, <!-- 创建人名称 --> created_name = #createdName#, <!-- 创建人名称 -->
created_time = #createdTime#, <!-- 创建时间 --> created_time = #createdTime#, <!-- 创建时间 -->
updated_by = #updatedBy#, <!-- 更新人 --> updated_by = #updatedBy#, <!-- 更新人 -->
updated_name = #updatedName#, <!-- 修改人名称 --> updated_name = #updatedName#, <!-- 修改人名称 -->
updated_time = #updatedTime# <!-- 更新时间 --> updated_time = #updatedTime# <!-- 更新时间 -->
WHERE WHERE id = #id#
id = #id# </update>
</update>
<!-- 修改排产状态 -->
<update id="updateIsSchedule">
UPDATE ${hggpSchema}.HGSC005
SET
IS_SCHEDULE = #isSchedule#,
<include refid="SqlBase.updateRevise"/>
WHERE ID = #id#
</update>
<update id="batch_commit"> <update id="batch_commit">
UPDATE ${hggpSchema}.HGSC005 UPDATE ${hggpSchema}.HGSC005
SET SET
commit_status = 2, <!-- 审批状态 0:待审;1:审核中;2:已审 --> commit_status = 2, <!-- 审批状态 0:待审;1:审核中;2:已审 -->
updated_by = #updatedBy#, <!-- 更新人 --> updated_by = #updatedBy#, <!-- 更新人 -->
updated_name = #updatedName#, <!-- 修改人名称 --> updated_name = #updatedName#, <!-- 修改人名称 -->
updated_time = #updatedTime# <!-- 更新时间 --> updated_time = #updatedTime# <!-- 更新时间 -->
WHERE WHERE
id IN <iterate close=")" open="(" conjunction="," property="ids">#ids[]#</iterate> id IN <iterate close=")" open="(" conjunction="," property="ids">#ids[]#</iterate>
</update> </update>
</sqlMap> </sqlMap>
...@@ -2,6 +2,45 @@ ...@@ -2,6 +2,45 @@
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd"> <!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="HGSC005A"> <sqlMap namespace="HGSC005A">
<sql id="column">
id as "id",
mat_id as "matId", <!-- 物料清单ID -->
mat_detail_id as "matDetailId", <!-- 物料清单明细ID -->
tech_flow_id as "techFlowId", <!-- 工艺流程ID -->
tech_flow_name as "techFlowName", <!-- 工艺流程名称 -->
invent_process_id as "inventProcessId", <!-- 存货工序ID,对应HGPZ005A.id -->
process_code as "processCode", <!-- 工序编码 -->
process_name as "processName", <!-- 工序名称 -->
company_code as "companyCode", <!-- 公司编码 -->
process_order as "processOrder", <!-- 加工顺序 -->
company_name as "companyName", <!-- 公司名称 -->
dep_code as "depCode", <!-- 部门编码 -->
dep_name as "depName", <!-- 部门名称 -->
proj_code as "projCode", <!-- 项目编码 -->
proj_name as "projName", <!-- 项目名称 -->
plan_code as "planCode", <!-- 计划编码 -->
product_type as "productType", <!-- 产品类型 -->
product_code as "productCode", <!-- 产品编号 -->
product_name as "productName", <!-- 产品名称 -->
finish_date as "finishDate", <!-- 完工日期 -->
plan_start_date as "planStartDate", <!-- 计划开始日期 -->
plan_end_date as "planEndDate", <!-- 计划结束日期 -->
quantity as "quantity", <!-- 数量 -->
finish_quantity as "finishQuantity", <!-- 完工数量 -->
unfinish_quantity as "unfinishQuantity", <!-- 未完工数量 -->
single_weight as "singleWeight", <!-- 单重 -->
total_weight as "totalWeight", <!-- 总重 -->
finish_weight as "finishWeight", <!-- 完工重量 -->
unfinish_weight as "unfinishWeight", <!-- 未完工重量 -->
account_code as "accountCode", <!-- 帐套 -->
created_by as "createdBy", <!-- 创建人 -->
created_name as "createdName", <!-- 创建人名称 -->
created_time as "createdTime", <!-- 创建时间 -->
updated_by as "updatedBy", <!-- 更新人 -->
updated_name as "updatedName", <!-- 修改人名称 -->
updated_time as "updatedTime" <!-- 更新时间 -->
</sql>
<sql id="condition"> <sql id="condition">
<!--<include refid="HGXSDataAuth.authCondition"/>--> <!--<include refid="HGXSDataAuth.authCondition"/>-->
<isNotEmpty prepend=" AND " property="id"> <isNotEmpty prepend=" AND " property="id">
...@@ -122,51 +161,16 @@ ...@@ -122,51 +161,16 @@
<select id="query" resultClass="com.baosight.hggp.hg.sc.domain.HGSC005A"> <select id="query" resultClass="com.baosight.hggp.hg.sc.domain.HGSC005A">
SELECT SELECT
id as "id", <include refid="column"/>
mat_id as "matId", <!-- 物料清单ID -->
mat_detail_id as "matDetailId", <!-- 物料清单明细ID -->
tech_flow_id as "techFlowId", <!-- 工艺流程ID -->
tech_flow_name as "techFlowName", <!-- 工艺流程名称 -->
invent_process_id as "inventProcessId", <!-- 存货工序ID,对应HGPZ005A.id -->
process_code as "processCode", <!-- 工序编码 -->
process_name as "processName", <!-- 工序名称 -->
company_code as "companyCode", <!-- 公司编码 -->
process_order as "processOrder", <!-- 加工顺序 -->
company_name as "companyName", <!-- 公司名称 -->
dep_code as "depCode", <!-- 部门编码 -->
dep_name as "depName", <!-- 部门名称 -->
proj_code as "projCode", <!-- 项目编码 -->
proj_name as "projName", <!-- 项目名称 -->
plan_code as "planCode", <!-- 计划编码 -->
product_type as "productType", <!-- 产品类型 -->
product_code as "productCode", <!-- 产品编号 -->
product_name as "productName", <!-- 产品名称 -->
finish_date as "finishDate", <!-- 完工日期 -->
plan_start_date as "planStartDate", <!-- 计划开始日期 -->
plan_end_date as "planEndDate", <!-- 计划结束日期 -->
quantity as "quantity", <!-- 数量 -->
finish_quantity as "finishQuantity", <!-- 完工数量 -->
unfinish_quantity as "unfinishQuantity", <!-- 未完工数量 -->
single_weight as "singleWeight", <!-- 单重 -->
total_weight as "totalWeight", <!-- 总重 -->
finish_weight as "finishWeight", <!-- 完工重量 -->
unfinish_weight as "unfinishWeight", <!-- 未完工重量 -->
account_code as "accountCode", <!-- 帐套 -->
created_by as "createdBy", <!-- 创建人 -->
created_name as "createdName", <!-- 创建人名称 -->
created_time as "createdTime", <!-- 创建时间 -->
updated_by as "updatedBy", <!-- 更新人 -->
updated_name as "updatedName", <!-- 修改人名称 -->
updated_time as "updatedTime" <!-- 更新时间 -->
FROM ${hggpSchema}.HGSC005A WHERE 1=1 FROM ${hggpSchema}.HGSC005A WHERE 1=1
<include refid="condition" /> <include refid="condition" />
<dynamic prepend="ORDER BY"> <dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy"> <isNotEmpty property="orderBy">
$orderBy$ $orderBy$
</isNotEmpty> </isNotEmpty>
<isEmpty property="orderBy"> <isEmpty property="orderBy">
product_type asc , product_name, process_order desc product_type asc, product_code desc, process_order desc
</isEmpty> </isEmpty>
</dynamic> </dynamic>
</select> </select>
...@@ -380,17 +384,26 @@ ...@@ -380,17 +384,26 @@
id = #id# id = #id#
</update> </update>
<update id="update_plan_date"> <update id="update_plan_date">
UPDATE ${hggpSchema}.HGSC005A UPDATE ${hggpSchema}.HGSC005A
SET SET
plan_start_date = #planStartDate#, <!-- 计划开始日期 --> plan_start_date = #planStartDate#, <!-- 计划开始日期 -->
plan_end_date = #planEndDate#, <!-- 计划结束日期 --> plan_end_date = #planEndDate#, <!-- 计划结束日期 -->
updated_by = #updatedBy#, <!-- 更新人 --> updated_by = #updatedBy#, <!-- 更新人 -->
updated_name = #updatedName#, <!-- 修改人名称 --> updated_name = #updatedName#, <!-- 修改人名称 -->
updated_time = #updatedTime# <!-- 更新时间 --> updated_time = #updatedTime# <!-- 更新时间 -->
WHERE WHERE id = #id#
id = #id# </update>
</update>
<!-- 修改计划时间 -->
<update id="updatePlanDate">
UPDATE ${hggpSchema}.HGSC005A
SET
plan_start_date = #planStartDate#, <!-- 计划开始日期 -->
plan_end_date = #planEndDate#, <!-- 计划结束日期 -->
<include refid="SqlBase.updateRevise"/>
WHERE id = #id#
</update>
<select id="queryProcessComboBox" parameterClass="java.util.HashMap" <select id="queryProcessComboBox" parameterClass="java.util.HashMap"
resultClass="java.util.HashMap"> resultClass="java.util.HashMap">
......
...@@ -43,6 +43,7 @@ import com.baosight.hggp.util.DateUtil; ...@@ -43,6 +43,7 @@ import com.baosight.hggp.util.DateUtil;
import com.baosight.hggp.util.DateUtils; import com.baosight.hggp.util.DateUtils;
import com.baosight.hggp.util.EiInfoUtils; import com.baosight.hggp.util.EiInfoUtils;
import com.baosight.hggp.util.FileUtils; import com.baosight.hggp.util.FileUtils;
import com.baosight.hggp.util.ObjectUtils;
import com.baosight.iplat4j.core.ProjectInfo; import com.baosight.iplat4j.core.ProjectInfo;
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;
...@@ -55,6 +56,7 @@ import org.apache.commons.lang3.StringUtils; ...@@ -55,6 +56,7 @@ import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
...@@ -692,123 +694,139 @@ public class HGSCTools { ...@@ -692,123 +694,139 @@ public class HGSCTools {
List<HGSC005A> results = DaoBase.getInstance().query(HGSC005A.QUERY, paramMap); List<HGSC005A> results = DaoBase.getInstance().query(HGSC005A.QUERY, paramMap);
return CollectionUtils.isEmpty(results) ? null : results; return CollectionUtils.isEmpty(results) ? null : results;
} }
public static List<HGSC005A> queryByMatId(Long matId){ // 存货档案单位转换(米)
AssertUtils.isTrue(Objects.isNull(matId)||matId<=0, "物料清单ID不能为空!"); private final static BigDecimal unitConver = new BigDecimal(1000);
Map paramMap = new HashMap(); // 基础工时
paramMap.put(HGSC005A.FIELD_mat_id, matId); private final static BigDecimal baseWorkHour = new BigDecimal(8);
List<HGSC005A> results = DaoBase.getInstance().query(HGSC005A.QUERY, paramMap); // 完成日期差异天数
return CollectionUtils.isEmpty(results) ? null : results; private final static Integer finishDateDiffDay = 3;
}
public static List<HGSC005A> queryByMatId(Long matId) {
private static List<HGSC005A> generatorNewPlanDetail(List<HGSC005A> hgsc005aList){ AssertUtils.isTrue(Objects.isNull(matId) || matId <= 0, "物料清单ID不能为空!");
List<String> inventCodes = hgsc005aList.stream().map(HGSC005A::getProductCode).distinct().collect(Collectors.toList()); Map paramMap = new HashMap();
//通过存货档案编码查询存货档案工序 paramMap.put(HGSC005A.FIELD_mat_id, matId);
List<HGPZ005A> hgpz005AList = HGPZTools.HgPz005A.queryByInventCodes(inventCodes); List<HGSC005A> results = DaoBase.getInstance().query(HGSC005A.QUERY, paramMap);
AssertUtils.isEmpty(hgpz005AList, String.format("产品[%s]工序不存在,请先到存货档案配置产品工序!",inventCodes)); return CollectionUtils.isEmpty(results) ? null : results;
List<HGSC005A> hgsc005AList = new ArrayList<>(); }
hgsc005aList.forEach(hgsc005a->{
List<HGPZ005A> filterHgpz005a = hgpz005AList.stream().filter(o->o.getInventCode().equals(hgsc005a.getProductCode())).collect(Collectors.toList()); private static List<HGSC005A> generatorNewPlanDetail(List<HGSC005A> hgsc005aList) {
AssertUtils.isEmpty(filterHgpz005a, String.format("产品[%s]工序不存在,请先到存货档案配置产品工序!",hgsc005a.getProductName())); List<String> inventCodes = hgsc005aList.stream().map(HGSC005A::getProductCode).distinct()
filterHgpz005a.forEach(pz -> { .collect(Collectors.toList());
HGSC005A obj = new HGSC005A(); //通过存货档案编码查询存货档案工序
BeanUtils.copyProperties(hgsc005a,obj); List<HGPZ005A> hgpz005AList = HGPZTools.HgPz005A.queryByInventCodes(inventCodes);
obj.setInventProcessId(pz.getId()); AssertUtils.isEmpty(hgpz005AList, String.format("产品[%s]工序不存在,请先到存货档案配置产品工序!", inventCodes));
obj.setProcessCode(pz.getProcessCode()); List<HGSC005A> hgsc005AList = new ArrayList<>();
obj.setProcessName(pz.getProcessName()); hgsc005aList.forEach(hgsc005a -> {
obj.setProcessOrder(pz.getProcessOrder()); List<HGPZ005A> filterHgpz005a = hgpz005AList.stream()
hgsc005AList.add(obj); .filter(o -> o.getInventCode().equals(hgsc005a.getProductCode())).collect(Collectors.toList());
}); AssertUtils.isEmpty(filterHgpz005a,
}); String.format("产品[%s]工序不存在,请先到存货档案配置产品工序!", hgsc005a.getProductName()));
return hgsc005AList; filterHgpz005a.forEach(pz -> {
} HGSC005A obj = new HGSC005A();
BeanUtils.copyProperties(hgsc005a, obj);
private static List<HGSC005A> generatorNewPlanDetail(HGSC005A hgsc005a){ obj.setInventProcessId(pz.getId());
//通过存货档案编码查询存货档案工序 obj.setProcessCode(pz.getProcessCode());
List<HGPZ005A> hgpz005AList = HGPZTools.HgPz005A.queryByInventCode(hgsc005a.getProductCode()); obj.setProcessName(pz.getProcessName());
AssertUtils.isEmpty(hgpz005AList, String.format("产品[%s]工序不存在,请先到存货档案配置产品工序!",hgsc005a.getProductName())); obj.setProcessOrder(pz.getProcessOrder());
List<HGSC005A> hgsc005AList = new ArrayList<>(); hgsc005AList.add(obj);
hgpz005AList.forEach(pz -> { });
HGSC005A obj = new HGSC005A(); });
BeanUtils.copyProperties(hgsc005a,obj); return hgsc005AList;
obj.setInventProcessId(pz.getId()); }
obj.setProcessCode(pz.getProcessCode());
obj.setProcessName(pz.getProcessName()); private static List<HGSC005A> generatorNewPlanDetail(HGSC005A hgsc005a) {
obj.setProcessOrder(pz.getProcessOrder()); //通过存货档案编码查询存货档案工序
hgsc005AList.add(obj); List<HGPZ005A> hgpz005AList = HGPZTools.HgPz005A.queryByInventCode(hgsc005a.getProductCode());
}); AssertUtils.isEmpty(hgpz005AList, String.format("产品[%s]工序不存在,请先到存货档案配置产品工序!", hgsc005a.getProductName()));
return hgsc005AList; List<HGSC005A> hgsc005AList = new ArrayList<>();
} hgpz005AList.forEach(pz -> {
HGSC005A obj = new HGSC005A();
private static Map<Long,Optional<HGSC005A>> queryOldPlanDetail(List<HGSC005A> hgsc005aList){ BeanUtils.copyProperties(hgsc005a, obj);
List<String> productCodes = hgsc005aList.stream().map(HGSC005A::getProductCode).distinct().collect(Collectors.toList()); obj.setInventProcessId(pz.getId());
Map paramMap = new HashMap(); obj.setProcessCode(pz.getProcessCode());
//因为提交时肯定matid相同,直接取第一个即可 obj.setProcessName(pz.getProcessName());
paramMap.put(HGSC005A.FIELD_mat_id, hgsc005aList.get(0).getMatId()); obj.setProcessOrder(pz.getProcessOrder());
paramMap.put("productCodes", productCodes); hgsc005AList.add(obj);
List<HGSC005A> oldObjList = DaoBase.getInstance().query(HGSC005A.QUERY, paramMap); });
Map<Long,Optional<HGSC005A>> returnOldObjMap = new LinkedHashMap<>(); return hgsc005AList;
hgsc005aList.forEach(hgsc005a->{ }
//构建计划物料明细ID唯一
if(hgsc005a.getProductType().compareTo(ProductTypeEnum.STRUCT.getCode())==0){ private static Map<Long, Optional<HGSC005A>> queryOldPlanDetail(List<HGSC005A> hgsc005aList) {
List<HGSC005A> oldObjFilterList = oldObjList.stream().filter(o->o.getProductCode().equals(hgsc005a.getProductCode()) List<String> productCodes = hgsc005aList.stream().map(HGSC005A::getProductCode).distinct()
&& o.getMatDetailId().compareTo(hgsc005a.getMatDetailId())==0) .collect(Collectors.toList());
.collect(Collectors.toList()); Map paramMap = new HashMap();
Map<Long,Optional<HGSC005A>> oldObjMap = Optional.ofNullable(oldObjFilterList).orElse(new ArrayList<>()).stream() //因为提交时肯定matid相同,直接取第一个即可
.collect(Collectors.groupingBy(HGSC005A::getInventProcessId,Collectors.maxBy( paramMap.put(HGSC005A.FIELD_mat_id, hgsc005aList.get(0).getMatId());
Comparator.comparingInt(HGSC005A::getQuantity)))); paramMap.put("productCodes", productCodes);
returnOldObjMap.putAll(oldObjMap); List<HGSC005A> oldObjList = DaoBase.getInstance().query(HGSC005A.QUERY, paramMap);
}else{ Map<Long, Optional<HGSC005A>> returnOldObjMap = new LinkedHashMap<>();
List<HGSC005A> oldObjFilterList = oldObjList.stream().filter(o->o.getProductCode().equals(hgsc005a.getProductCode())) hgsc005aList.forEach(hgsc005a -> {
.collect(Collectors.toList()); //构建计划物料明细ID唯一
Map<Long,Optional<HGSC005A>> oldObjMap = Optional.ofNullable(oldObjFilterList).orElse(new ArrayList<>()).stream() if (hgsc005a.getProductType().compareTo(ProductTypeEnum.STRUCT.getCode()) == 0) {
.collect(Collectors.groupingBy(HGSC005A::getInventProcessId,Collectors.maxBy( List<HGSC005A> oldObjFilterList = oldObjList.stream()
Comparator.comparingInt(HGSC005A::getQuantity)))); .filter(o -> o.getProductCode().equals(hgsc005a.getProductCode())
returnOldObjMap.putAll(oldObjMap); && o.getMatDetailId().compareTo(hgsc005a.getMatDetailId()) == 0)
} .collect(Collectors.toList());
}); Map<Long, Optional<HGSC005A>> oldObjMap = Optional.ofNullable(oldObjFilterList)
.orElse(new ArrayList<>()).stream()
return returnOldObjMap; .collect(Collectors.groupingBy(HGSC005A::getInventProcessId, Collectors.maxBy(
} Comparator.comparingInt(HGSC005A::getQuantity))));
returnOldObjMap.putAll(oldObjMap);
private static Map<String,HGSC005A> queryOldPartPlanDetail(List<HGSC005A> hgsc005aList){ } else {
if(CollectionUtils.isNotEmpty(hgsc005aList)) { List<HGSC005A> oldObjFilterList = oldObjList.stream()
List<String> productCodes = hgsc005aList.stream().map(HGSC005A::getProductCode).distinct().collect(Collectors.toList()); .filter(o -> o.getProductCode().equals(hgsc005a.getProductCode()))
Map paramMap = new HashMap(); .collect(Collectors.toList());
//因为提交时肯定matid相同,直接取第一个即可 Map<Long, Optional<HGSC005A>> oldObjMap = Optional.ofNullable(oldObjFilterList)
paramMap.put(HGSC005A.FIELD_mat_id, hgsc005aList.get(0).getMatId()); .orElse(new ArrayList<>()).stream()
paramMap.put("productCodes", productCodes); .collect(Collectors.groupingBy(HGSC005A::getInventProcessId, Collectors.maxBy(
paramMap.put(HGSC005A.FIELD_product_type, ProductTypeEnum.PART.getCode()); Comparator.comparingInt(HGSC005A::getQuantity))));
List<HGSC005A> oldObjList = DaoBase.getInstance().query(HGSC005A.QUERY, paramMap); returnOldObjMap.putAll(oldObjMap);
return Optional.ofNullable(oldObjList).orElse(new ArrayList<>()).stream() }
.collect(Collectors.groupingBy(o -> { });
return o.getProductCode() + "#" + o.getInventProcessId();
}, return returnOldObjMap;
Collectors.collectingAndThen(Collectors.maxBy( }
Comparator.comparingInt(HGSC005A::getQuantity)), Optional::get)));
} private static Map<String, HGSC005A> queryOldPartPlanDetail(List<HGSC005A> hgsc005aList) {
return null; if (CollectionUtils.isNotEmpty(hgsc005aList)) {
} List<String> productCodes = hgsc005aList.stream().map(HGSC005A::getProductCode).distinct()
.collect(Collectors.toList());
private static Map<Long,Optional<HGSC005A>> queryOldPlanDetail(HGSC005A hgsc005a){ Map paramMap = new HashMap();
Map paramMap = new HashMap(); //因为提交时肯定matid相同,直接取第一个即可
paramMap.put(HGSC005A.FIELD_mat_id, hgsc005a.getMatId()); paramMap.put(HGSC005A.FIELD_mat_id, hgsc005aList.get(0).getMatId());
paramMap.put(HGSC005A.FIELD_product_code, hgsc005a.getProductCode()); paramMap.put("productCodes", productCodes);
//构建计划物料明细ID唯一 paramMap.put(HGSC005A.FIELD_product_type, ProductTypeEnum.PART.getCode());
if(hgsc005a.getProductType().compareTo(ProductTypeEnum.STRUCT.getCode())==0){ List<HGSC005A> oldObjList = DaoBase.getInstance().query(HGSC005A.QUERY, paramMap);
paramMap.put(HGSC005A.FIELD_mat_detail_id, hgsc005a.getMatDetailId()); return Optional.ofNullable(oldObjList).orElse(new ArrayList<>()).stream()
} .collect(Collectors.groupingBy(o -> {
List<HGSC005A> oldObjList = DaoBase.getInstance().query(HGSC005A.QUERY, paramMap); return o.getProductCode() + "#" + o.getInventProcessId();
Map<Long,Optional<HGSC005A>> oldObjMap = Optional.ofNullable(oldObjList).orElse(new ArrayList<>()).stream() },
.collect(Collectors.groupingBy(HGSC005A::getInventProcessId,Collectors.maxBy( Collectors.collectingAndThen(Collectors.maxBy(
Comparator.comparingInt(HGSC005A::getQuantity)))); Comparator.comparingInt(HGSC005A::getQuantity)), Optional::get)));
return oldObjMap; }
} return null;
}
public static List<HGSC005A> saveList(List<HGSC005A> hgsc005aList){
checkUpdateData(hgsc005aList); private static Map<Long, Optional<HGSC005A>> queryOldPlanDetail(HGSC005A hgsc005a) {
hgsc005aList = constructObj(hgsc005aList); Map paramMap = new HashMap();
List<HGSC005A> hgsc005AList = generatorNewPlanDetail(hgsc005aList); paramMap.put(HGSC005A.FIELD_mat_id, hgsc005a.getMatId());
paramMap.put(HGSC005A.FIELD_product_code, hgsc005a.getProductCode());
//构建计划物料明细ID唯一
if (hgsc005a.getProductType().compareTo(ProductTypeEnum.STRUCT.getCode()) == 0) {
paramMap.put(HGSC005A.FIELD_mat_detail_id, hgsc005a.getMatDetailId());
}
List<HGSC005A> oldObjList = DaoBase.getInstance().query(HGSC005A.QUERY, paramMap);
Map<Long, Optional<HGSC005A>> oldObjMap = Optional.ofNullable(oldObjList).orElse(new ArrayList<>()).stream()
.collect(Collectors.groupingBy(HGSC005A::getInventProcessId, Collectors.maxBy(
Comparator.comparingInt(HGSC005A::getQuantity))));
return oldObjMap;
}
public static List<HGSC005A> saveList(List<HGSC005A> hgsc005aList) {
checkUpdateData(hgsc005aList);
hgsc005aList = constructObj(hgsc005aList);
List<HGSC005A> hgsc005AList = generatorNewPlanDetail(hgsc005aList);
// Map<Long,Optional<HGSC005A>> oldObjMap = queryOldPlanDetail(hgsc005aList); // Map<Long,Optional<HGSC005A>> oldObjMap = queryOldPlanDetail(hgsc005aList);
// List<HGSC005A> createList = new ArrayList<>(); // List<HGSC005A> createList = new ArrayList<>();
// List<HGSC005A> updateList = new ArrayList<>(); // List<HGSC005A> updateList = new ArrayList<>();
...@@ -825,235 +843,238 @@ public class HGSCTools { ...@@ -825,235 +843,238 @@ public class HGSCTools {
// createList.add(o); // createList.add(o);
// } // }
// }); // });
if(CollectionUtils.isNotEmpty(hgsc005AList)){ if (CollectionUtils.isNotEmpty(hgsc005AList)) {
DaoUtils.insertBatch(HGSC005A.INSERT,hgsc005AList); DaoUtils.insertBatch(HGSC005A.INSERT, hgsc005AList);
} }
// if(CollectionUtils.isNotEmpty(updateList)){ // if(CollectionUtils.isNotEmpty(updateList)){
// DaoUtils.updateBatch(HGSC005A.UPDATE,updateList); // DaoUtils.updateBatch(HGSC005A.UPDATE,updateList);
// } // }
return hgsc005aList; return hgsc005aList;
} }
public static HGSC005A save(HGSC005A hgsc005a) {
public static HGSC005A save(HGSC005A hgsc005a){ checkUpdateData(hgsc005a);
checkUpdateData(hgsc005a); constructObj(hgsc005a);
constructObj(hgsc005a); List<HGSC005A> hgsc005AList = generatorNewPlanDetail(hgsc005a);
List<HGSC005A> hgsc005AList = generatorNewPlanDetail(hgsc005a); Map<Long, Optional<HGSC005A>> oldObjMap = queryOldPlanDetail(hgsc005a);
Map<Long,Optional<HGSC005A>> oldObjMap = queryOldPlanDetail(hgsc005a); List<HGSC005A> createList = new ArrayList<>();
List<HGSC005A> createList = new ArrayList<>(); List<HGSC005A> updateList = new ArrayList<>();
List<HGSC005A> updateList = new ArrayList<>(); hgsc005AList.forEach(o -> {
hgsc005AList.forEach(o -> { Optional<HGSC005A> op = oldObjMap.get(o.getInventProcessId());
Optional<HGSC005A> op = oldObjMap.get(o.getInventProcessId()); if (Objects.nonNull(op)) {
if(Objects.nonNull(op)){ HGSC005A uo = op.get();
HGSC005A uo = op.get(); uo.setQuantity(uo.getQuantity() + o.getQuantity());
uo.setQuantity(uo.getQuantity()+o.getQuantity()); uo.setUnfinishQuantity(uo.getUnfinishQuantity() + o.getQuantity());
uo.setUnfinishQuantity(uo.getUnfinishQuantity()+o.getQuantity()); handleWeight(hgsc005a, uo);
handleWeight(hgsc005a,uo); updateList.add(uo);
updateList.add(uo); } else {
}else{ handleWeight(hgsc005a, o);
handleWeight(hgsc005a,o); createList.add(o);
createList.add(o); }
} });
}); if (CollectionUtils.isNotEmpty(createList)) {
if(CollectionUtils.isNotEmpty(createList)){ createList.forEach(obj -> {
createList.forEach(obj -> { DaoUtils.insert(HGSC005A.INSERT, obj);
DaoUtils.insert(HGSC005A.INSERT,obj); });
}); }
} if (CollectionUtils.isNotEmpty(updateList)) {
if(CollectionUtils.isNotEmpty(updateList)){ updateList.forEach(obj -> {
updateList.forEach(obj -> { DaoUtils.update(HGSC005A.UPDATE, obj);
DaoUtils.update(HGSC005A.UPDATE,obj); });
}); }
} return hgsc005a;
return hgsc005a; }
}
public static HGSC005A update(HGSC005A hgsc005a) {
public static HGSC005A update(HGSC005A hgsc005a){ checkUpdateData(hgsc005a);
checkUpdateData(hgsc005a); constructObj(hgsc005a);
constructObj(hgsc005a); List<HGSC005A> hgsc005AList = generatorNewPlanDetail(hgsc005a);
List<HGSC005A> hgsc005AList = generatorNewPlanDetail(hgsc005a); Map<Long, Optional<HGSC005A>> oldObjMap = queryOldPlanDetail(hgsc005a);
Map<Long,Optional<HGSC005A>> oldObjMap = queryOldPlanDetail(hgsc005a); List<HGSC005A> createList = new ArrayList<>();
List<HGSC005A> createList = new ArrayList<>(); List<HGSC005A> updateList = new ArrayList<>();
List<HGSC005A> updateList = new ArrayList<>(); hgsc005AList.forEach(o -> {
hgsc005AList.forEach(o -> { Optional<HGSC005A> op = oldObjMap.get(o.getInventProcessId());
Optional<HGSC005A> op = oldObjMap.get(o.getInventProcessId()); if (Objects.nonNull(op)) {
if(Objects.nonNull(op)){ HGSC005A uo = op.get();
HGSC005A uo = op.get(); uo.setQuantity(o.getQuantity());
uo.setQuantity(o.getQuantity()); uo.setUnfinishQuantity(o.getQuantity() - uo.getFinishQuantity());
uo.setUnfinishQuantity(o.getQuantity()-uo.getFinishQuantity()); handleWeight(hgsc005a, uo);
handleWeight(hgsc005a,uo); updateList.add(uo);
updateList.add(uo); } else {
}else{ handleWeight(hgsc005a, o);
handleWeight(hgsc005a,o); createList.add(o);
createList.add(o); }
} });
}); if (CollectionUtils.isNotEmpty(createList)) {
if(CollectionUtils.isNotEmpty(createList)){ createList.forEach(obj -> {
createList.forEach(obj -> { DaoUtils.insert(HGSC005A.INSERT, obj);
DaoUtils.insert(HGSC005A.INSERT,obj); });
}); }
} if (CollectionUtils.isNotEmpty(updateList)) {
if(CollectionUtils.isNotEmpty(updateList)){ updateList.forEach(obj -> {
updateList.forEach(obj -> { DaoUtils.update(HGSC005A.UPDATE, obj);
DaoUtils.update(HGSC005A.UPDATE,obj); });
}); }
} return hgsc005a;
return hgsc005a; }
}
public static void delete(HGSC005A hgsc005a) {
public static void delete(HGSC005A hgsc005a){ checkUpdateData(hgsc005a);
checkUpdateData(hgsc005a); Map<Long, Optional<HGSC005A>> oldObjMap = queryOldPlanDetail(hgsc005a);
Map<Long,Optional<HGSC005A>> oldObjMap = queryOldPlanDetail(hgsc005a); List<Long> deleteIds = new ArrayList<>();
List<Long> deleteIds = new ArrayList<>(); List<HGSC005A> updateList = new ArrayList<>();
List<HGSC005A> updateList = new ArrayList<>(); oldObjMap.forEach((k, v) -> {
oldObjMap.forEach((k,v)->{ HGSC005A oldObj = v.get();
HGSC005A oldObj = v.get(); if (oldObj.getQuantity() - hgsc005a.getQuantity() <= 0) {
if(oldObj.getQuantity()-hgsc005a.getQuantity()<=0){ handleWeight(hgsc005a, oldObj);
handleWeight(hgsc005a,oldObj); deleteIds.add(oldObj.getId());
deleteIds.add(oldObj.getId()); } else {
}else{ oldObj.setQuantity(oldObj.getQuantity() - hgsc005a.getQuantity());
oldObj.setQuantity(oldObj.getQuantity()-hgsc005a.getQuantity()); oldObj.setUnfinishQuantity(oldObj.getQuantity() - oldObj.getFinishQuantity());
oldObj.setUnfinishQuantity(oldObj.getQuantity()-oldObj.getFinishQuantity()); handleWeight(hgsc005a, oldObj);
handleWeight(hgsc005a,oldObj); updateList.add(oldObj);
updateList.add(oldObj); }
} });
}); if (CollectionUtils.isNotEmpty(deleteIds)) {
if(CollectionUtils.isNotEmpty(deleteIds)){ List<HGSC005A> dbList = queryByMatId(hgsc005a.getMatId());
List<HGSC005A> dbList = queryByMatId(hgsc005a.getMatId()); //如果全部删除则删除主表
//如果全部删除则删除主表 if (deleteIds.size() == dbList.size()) {
if(deleteIds.size() == dbList.size()){ DaoUtils.update(HGSC005.DELETE_BY_MAT_ID, new HashMap<String, Object>() {{
DaoUtils.update(HGSC005.DELETE_BY_MAT_ID,new HashMap<String,Object>(){{put(HGSC005.FIELD_mat_id,hgsc005a.getMatId());}}); put(HGSC005.FIELD_mat_id, hgsc005a.getMatId());
} }});
DaoUtils.update(HGSC005A.BATCH_DELETE, new HashMap<String,Object>(){{put("ids",deleteIds);}}); }
} DaoUtils.update(HGSC005A.BATCH_DELETE, new HashMap<String, Object>() {{
if(CollectionUtils.isNotEmpty(updateList)){ put("ids", deleteIds);
DaoUtils.updateBatch(HGSC005A.UPDATE,updateList); }});
} }
if(hgsc005a.getProductType().compareTo(ProductTypeEnum.STRUCT.getCode())==0 if (CollectionUtils.isNotEmpty(updateList)) {
&& CollectionUtils.isNotEmpty(hgsc005a.getPartList())){ DaoUtils.updateBatch(HGSC005A.UPDATE, updateList);
deletePartList(hgsc005a.getPartList()); }
} if (hgsc005a.getProductType().compareTo(ProductTypeEnum.STRUCT.getCode()) == 0
} && CollectionUtils.isNotEmpty(hgsc005a.getPartList())) {
deletePartList(hgsc005a.getPartList());
public static void deletePartList(List<HGSC005A> hgsc005aList){ }
List<Long> deleteIds = new ArrayList<>(); }
List<HGSC005A> updateList = new ArrayList<>();
if(CollectionUtils.isNotEmpty(hgsc005aList)) { public static void deletePartList(List<HGSC005A> hgsc005aList) {
Map<String, HGSC005A> hgsc005aMap = hgsc005aList.stream().collect(Collectors.toMap(HGSC005A::getProductCode, o -> o, (o1, o2) -> { List<Long> deleteIds = new ArrayList<>();
o1.setQuantity(o1.getQuantity() + o2.getQuantity()); List<HGSC005A> updateList = new ArrayList<>();
o1.setTotalWeight(o1.getSingleWeight().multiply(new BigDecimal(o1.getQuantity()))); if (CollectionUtils.isNotEmpty(hgsc005aList)) {
return o1; Map<String, HGSC005A> hgsc005aMap = hgsc005aList.stream()
})); .collect(Collectors.toMap(HGSC005A::getProductCode, o -> o, (o1, o2) -> {
checkUpdateData(hgsc005aList); o1.setQuantity(o1.getQuantity() + o2.getQuantity());
Map<String, HGSC005A> oldObjMap = queryOldPartPlanDetail(hgsc005aList); o1.setTotalWeight(o1.getSingleWeight().multiply(new BigDecimal(o1.getQuantity())));
if (Objects.nonNull(oldObjMap)) { return o1;
oldObjMap.forEach((k, oldObj) -> { }));
if(Objects.nonNull(oldObj)) { checkUpdateData(hgsc005aList);
HGSC005A hgsc005a = hgsc005aMap.get(k.split("#")[0]); Map<String, HGSC005A> oldObjMap = queryOldPartPlanDetail(hgsc005aList);
if (oldObj.getQuantity() - hgsc005a.getQuantity() <= 0) { if (Objects.nonNull(oldObjMap)) {
handleWeight(hgsc005a, oldObj); oldObjMap.forEach((k, oldObj) -> {
deleteIds.add(oldObj.getId()); if (Objects.nonNull(oldObj)) {
} else { HGSC005A hgsc005a = hgsc005aMap.get(k.split("#")[0]);
oldObj.setQuantity(oldObj.getQuantity() - hgsc005a.getQuantity()); if (oldObj.getQuantity() - hgsc005a.getQuantity() <= 0) {
oldObj.setUnfinishQuantity(oldObj.getQuantity() - oldObj.getFinishQuantity()); handleWeight(hgsc005a, oldObj);
handleWeight(hgsc005a, oldObj); deleteIds.add(oldObj.getId());
updateList.add(oldObj); } else {
} oldObj.setQuantity(oldObj.getQuantity() - hgsc005a.getQuantity());
} oldObj.setUnfinishQuantity(oldObj.getQuantity() - oldObj.getFinishQuantity());
}); handleWeight(hgsc005a, oldObj);
} updateList.add(oldObj);
} }
if(CollectionUtils.isNotEmpty(deleteIds)){ }
Long matId = hgsc005aList.get(0).getMatId(); });
List<HGSC005A> dbList = queryByMatId(matId); }
//如果全部删除则删除主表 }
if(deleteIds.size() == dbList.size()){ if (CollectionUtils.isNotEmpty(deleteIds)) {
DaoUtils.update(HGSC005.DELETE_BY_MAT_ID,new HashMap<String,Object>(){{put(HGSC005.FIELD_mat_id,matId);}}); Long matId = hgsc005aList.get(0).getMatId();
} List<HGSC005A> dbList = queryByMatId(matId);
DaoUtils.update(HGSC005A.BATCH_DELETE, new HashMap<String,Object>(){{put("ids",deleteIds);}}); //如果全部删除则删除主表
} if (deleteIds.size() == dbList.size()) {
if(CollectionUtils.isNotEmpty(updateList)){ DaoUtils.update(HGSC005.DELETE_BY_MAT_ID, new HashMap<String, Object>() {{
DaoUtils.updateBatch(HGSC005A.UPDATE,updateList); put(HGSC005.FIELD_mat_id, matId);
} }});
} }
DaoUtils.update(HGSC005A.BATCH_DELETE, new HashMap<String, Object>() {{
private static void handleWeight(HGSC005A hgsc005a, HGSC005A target){ put("ids", deleteIds);
if(Objects.nonNull(hgsc005a.getSingleWeight())) { }});
target.setSingleWeight(hgsc005a.getSingleWeight()); }
target.setTotalWeight(hgsc005a.getSingleWeight().multiply(new BigDecimal(target.getQuantity()))); if (CollectionUtils.isNotEmpty(updateList)) {
target.setFinishWeight(hgsc005a.getSingleWeight().multiply(new BigDecimal(target.getFinishQuantity()))); DaoUtils.updateBatch(HGSC005A.UPDATE, updateList);
target.setUnfinishWeight(hgsc005a.getSingleWeight().multiply(new BigDecimal(target.getUnfinishQuantity()))); }
} }
}
private static void handleWeight(HGSC005A hgsc005a, HGSC005A target) {
/** if (Objects.nonNull(hgsc005a.getSingleWeight())) {
* 校验修改的数据 target.setSingleWeight(hgsc005a.getSingleWeight());
* target.setTotalWeight(hgsc005a.getSingleWeight().multiply(new BigDecimal(target.getQuantity())));
* @param hgsc005aList target.setFinishWeight(hgsc005a.getSingleWeight().multiply(new BigDecimal(target.getFinishQuantity())));
*/ target.setUnfinishWeight(
private static void checkUpdateData(List<HGSC005A> hgsc005aList) { hgsc005a.getSingleWeight().multiply(new BigDecimal(target.getUnfinishQuantity())));
for(HGSC005A hgsc005a : hgsc005aList){ }
checkUpdateData(hgsc005a); }
}
} /**
* 校验修改的数据
public static List<HGSC005A> constructObj(List<HGSC005A> hgsc005aList){ *
HGSC005 hgsc005 = THGSC005.queryByMatId(hgsc005aList.get(0).getMatId()); * @param hgsc005aList
List<HGSC005A> result = new ArrayList<>(); */
Map<String,HGSC005A> hgsc005AMap = new HashMap<>(); private static void checkUpdateData(List<HGSC005A> hgsc005aList) {
hgsc005aList.forEach(hgsc005a -> { for (HGSC005A hgsc005a : hgsc005aList) {
hgsc005a.setPlanCode(hgsc005.getPlanCode()); checkUpdateData(hgsc005a);
hgsc005a.setCompanyCode(hgsc005.getCompanyCode()); }
hgsc005a.setCompanyName(hgsc005.getCompanyName()); }
hgsc005a.setDepCode(hgsc005.getDepCode());
hgsc005a.setDepName(hgsc005.getDepName()); public static List<HGSC005A> constructObj(List<HGSC005A> hgsc005aList) {
hgsc005a.setProjCode(hgsc005.getProjCode()); HGSC005 hgsc005 = THGSC005.queryByMatId(hgsc005aList.get(0).getMatId());
hgsc005a.setProjName(hgsc005.getProjName()); List<HGSC005A> result = new ArrayList<>();
hgsc005a.setFinishDate(hgsc005.getFinishDate()); Map<String, HGSC005A> hgsc005AMap = new HashMap<>();
hgsc005a.setUnfinishQuantity(hgsc005a.getQuantity()); hgsc005aList.forEach(hgsc005a -> {
hgsc005a.setFinishQuantity(0); hgsc005a.setPlanCode(hgsc005.getPlanCode());
hgsc005a.setUnfinishWeight(hgsc005a.getTotalWeight()); hgsc005a.setCompanyCode(hgsc005.getCompanyCode());
//零件 hgsc005a.setCompanyName(hgsc005.getCompanyName());
if(hgsc005a.getProductType().compareTo(ProductTypeEnum.PART.getCode())==0){ hgsc005a.setDepCode(hgsc005.getDepCode());
HGSC005A hisObj = hgsc005AMap.get(hgsc005a.getProductCode()); hgsc005a.setDepName(hgsc005.getDepName());
if(Objects.nonNull(hisObj)){ hgsc005a.setProjCode(hgsc005.getProjCode());
hgsc005a.setQuantity(hgsc005a.getQuantity() + hisObj.getQuantity()); hgsc005a.setProjName(hgsc005.getProjName());
hgsc005a.setUnfinishQuantity(hgsc005a.getQuantity()); hgsc005a.setFinishDate(hgsc005.getFinishDate());
hgsc005a.setTotalWeight(hgsc005a.getTotalWeight().add(hisObj.getTotalWeight())); hgsc005a.setUnfinishQuantity(hgsc005a.getQuantity());
hgsc005a.setUnfinishWeight(hgsc005a.getTotalWeight()); hgsc005a.setFinishQuantity(0);
} hgsc005a.setUnfinishWeight(hgsc005a.getTotalWeight());
hgsc005AMap.put(hgsc005a.getProductCode(),hgsc005a); //零件
}else{ if (hgsc005a.getProductType().compareTo(ProductTypeEnum.PART.getCode()) == 0) {
result.add(hgsc005a); HGSC005A hisObj = hgsc005AMap.get(hgsc005a.getProductCode());
} if (Objects.nonNull(hisObj)) {
}); hgsc005a.setQuantity(hgsc005a.getQuantity() + hisObj.getQuantity());
if(MapUtils.isNotEmpty(hgsc005AMap)){ hgsc005a.setUnfinishQuantity(hgsc005a.getQuantity());
result.addAll(hgsc005AMap.values().stream().collect(Collectors.toList())); hgsc005a.setTotalWeight(hgsc005a.getTotalWeight().add(hisObj.getTotalWeight()));
} hgsc005a.setUnfinishWeight(hgsc005a.getTotalWeight());
return result; }
} hgsc005AMap.put(hgsc005a.getProductCode(), hgsc005a);
} else {
//存货档案单位转换(米) result.add(hgsc005a);
private final static BigDecimal unitConver = new BigDecimal(1000); }
//基础工时 });
private final static BigDecimal baseWorkHour = new BigDecimal(8); if (MapUtils.isNotEmpty(hgsc005AMap)) {
private final static Integer finishDateDiffDay = new Integer(-3); result.addAll(hgsc005AMap.values().stream().collect(Collectors.toList()));
}
/** return result;
* 校验修改的数据 }
*
* @param hgsc005a /**
*/ * 校验修改的数据
private static void checkUpdateData(HGSC005A hgsc005a) { *
AssertUtils.isTrue(Objects.isNull(hgsc005a.getMatId()) || hgsc005a.getMatId() <= 0, "物料清单ID不能为空!"); * @param hgsc005a
AssertUtils.isTrue(Objects.isNull(hgsc005a.getMatDetailId()) || hgsc005a.getMatDetailId() <= 0, */
"物料清单明细ID不能为空!"); private static void checkUpdateData(HGSC005A hgsc005a) {
AssertUtils.isEmpty(hgsc005a.getProductCode(), "产品编码不能为空!"); AssertUtils.isTrue(Objects.isNull(hgsc005a.getMatId()) || hgsc005a.getMatId() <= 0, "物料清单ID不能为空!");
AssertUtils.isEmpty(hgsc005a.getProductName(), "产品名称不能为空!"); AssertUtils.isTrue(Objects.isNull(hgsc005a.getMatDetailId()) || hgsc005a.getMatDetailId() <= 0,
AssertUtils.isTrue(Objects.isNull(hgsc005a.getTechFlowId()) || hgsc005a.getTechFlowId() <= 0, "物料清单明细ID不能为空!");
"工艺流程ID不能为空!"); AssertUtils.isEmpty(hgsc005a.getProductCode(), "产品编码不能为空!");
AssertUtils.isTrue(Objects.isNull(hgsc005a.getQuantity()) || hgsc005a.getQuantity() <= 0, "数量不能为空!"); AssertUtils.isEmpty(hgsc005a.getProductName(), "产品名称不能为空!");
} AssertUtils.isTrue(Objects.isNull(hgsc005a.getTechFlowId()) || hgsc005a.getTechFlowId() <= 0,
"工艺流程ID不能为空!");
AssertUtils.isTrue(Objects.isNull(hgsc005a.getQuantity()) || hgsc005a.getQuantity() <= 0, "数量不能为空!");
}
public static List<HGSC005A> constructObj(List<HGSC005A> hgsc005aList, HGSC005 hgsc005) { public static List<HGSC005A> constructObj(List<HGSC005A> hgsc005aList, HGSC005 hgsc005) {
hgsc005aList.forEach(hgsc005a -> { hgsc005aList.forEach(hgsc005a -> {
...@@ -1091,232 +1112,390 @@ public class HGSCTools { ...@@ -1091,232 +1112,390 @@ public class HGSCTools {
/** /**
* 排产 * 排产
* *
* @param dbSc005 主计划信息
* @param queryMap * @param queryMap
* @param sortType * @param sortType A:正序,D:倒序
* @return * @return
*/ */
public static int schedule(Map queryMap, String sortType) { public static int schedule(HGSC005 dbSc005, Map queryMap, String sortType) {
List<HGSC005A> hgsc005AList = DaoBase.getInstance().query(HGSC005A.QUERY, queryMap); // 查询计划明细数据
// hgsc005AList.sort(Comparator.comparing(HGSC005A::getProductType).thenComparing(HGSC005A::getProcessOrder,Comparator.reverseOrder())); List<HGSC005A> dbSc005As = DaoBase.getInstance().query(HGSC005A.QUERY, queryMap);
//通过工序编码查询工序设置 // 正序排序
List<String> processCodes = hgsc005AList.stream().map(HGSC005A::getProcessCode) if (CommonConstant.SortType.ASC.equals(sortType)) {
.collect(Collectors.toList()); dbSc005As.sort(Comparator.comparingInt(HGSC005A::getProductType).reversed()
List<HGSJ001> hgsj001List = HGSJTools.Hgsj001.queryByProcessCodes(processCodes); .thenComparing(HGSC005A::getProductCode).reversed()
//通过产品编码查询存货档案 .thenComparingLong(HGSC005A::getProcessOrder));
List<String> productCodes = hgsc005AList.stream().map(HGSC005A::getProductCode) }
.collect(Collectors.toList()); // 通过工序编码查询工序设置
List<HGPZ005> hgpz005List = HGPZTools.HgPz005.listByInventCodes(productCodes); Map<String, HGSJ001> dbSj001Map = HGSJTools.Hgsj001.mapByCode(
//通过存货档案工序ID查询存货档案工序 ObjectUtils.listEpKey(dbSc005As, HGSC005A.FIELD_process_code));
List<Long> inventProcessIds = hgsc005AList.stream().map(HGSC005A::getInventProcessId) // 通过产品编码查询存货档案
.collect(Collectors.toList()); List<HGPZ005> dbPz005s = HGPZTools.HgPz005.listByInventCodes(
List<HGPZ005A> hgpz005AList = HGPZTools.HgPz005A.queryByIds(inventProcessIds); ObjectUtils.listEpKey(dbSc005As, HGSC005A.FIELD_product_code));
//筛选计划构建,并按产品分组 // 通过存货档案工序ID查询存货档案工序
Map<String, List<HGSC005A>> strctMap = hgsc005AList.stream() List<HGPZ005A> dbPz005As = HGPZTools.HgPz005A.queryByIds(
.filter(o -> o.getProductType().compareTo(ProductTypeEnum.STRUCT.getCode()) == 0) ObjectUtils.listEpKey(dbSc005As, HGSC005A.FIELD_invent_process_id));
// 筛选计划构件,并按产品分组
Map<String, List<HGSC005A>> structMap = dbSc005As.stream()
.filter(o -> o.getProductType().equals(ProductTypeEnum.STRUCT.getCode()))
.collect(Collectors.groupingBy(HGSC005A::getProductCode)); .collect(Collectors.groupingBy(HGSC005A::getProductCode));
List<HGSC005A> partList = hgsc005AList.stream() // 筛选零件
.filter(o -> o.getProductType().compareTo(ProductTypeEnum.PART.getCode()) == 0) List<HGSC005A> parts = dbSc005As.stream()
.filter(o -> o.getProductType().equals(ProductTypeEnum.PART.getCode()))
.collect(Collectors.toList()); .collect(Collectors.toList());
// 计算工序时间
if (CommonConstant.SortType.ASC.equals(sortType)) {
calcPlanDataAsc(dbSc005, dbSj001Map, dbPz005s, dbPz005As, structMap, parts);
} else {
calcPlanDataDesc(dbSj001Map, dbPz005s, dbPz005As, structMap, parts);
}
return dbSc005As.size();
}
/**
* 按照正序的方式计算工序的时间
*
* @param dbSc005
* @param dbSj001Map
* @param dbPz005s
* @param dbPz005As
* @param structMap
* @param parts
*/
private static void calcPlanDataAsc(HGSC005 dbSc005, Map<String, HGSJ001> dbSj001Map, List<HGPZ005> dbPz005s,
List<HGPZ005A> dbPz005As, Map<String, List<HGSC005A>> structMap, List<HGSC005A> parts) {
String maxDate = "";
BigDecimal remainder = BigDecimal.ZERO;
// 计算零件开始结束时间
for (HGSC005A iSc005A : parts) {
// 找出工序信息
HGSJ001 dbSj001 = dbSj001Map.get(iSc005A.getProcessCode());
AssertUtils.isNull(dbSj001, String.format("工序【%s】不存在", iSc005A.getProcessCode()));
// 计算工序时长
remainder = calculateWordHourAsc(dbSc005, iSc005A, dbSj001, dbPz005s, dbPz005As, maxDate, remainder);
// 设置最大时间
maxDate = StringUtils.isBlank(maxDate) || DateUtils.isAfter(iSc005A.getPlanEndDate(), maxDate)
? iSc005A.getPlanEndDate() : maxDate;
DaoUtils.update(HgScSqlConstant.HgSc005A.UPDATE_PLAN_DATE, iSc005A);
}
// 计算构件开始结束时间
for (Map.Entry<String, List<HGSC005A>> structEntry : structMap.entrySet()) {
for (HGSC005A iSc005A : structEntry.getValue()) {
// 找出工序信息
HGSJ001 dbSj001 = dbSj001Map.get(iSc005A.getProcessCode());
AssertUtils.isNull(dbSj001, String.format("工序【%s】不存在", iSc005A.getProcessCode()));
// 计算工序时长
remainder = calculateWordHourAsc(dbSc005, iSc005A, dbSj001, dbPz005s, dbPz005As, maxDate,
remainder);
maxDate = StringUtils.isBlank(maxDate) || DateUtils.isAfter(iSc005A.getPlanEndDate(), maxDate)
? iSc005A.getPlanEndDate() : maxDate;
DaoUtils.update(HgScSqlConstant.HgSc005A.UPDATE_PLAN_DATE, iSc005A);
}
}
}
/**
* 按照倒序的方式计算工序的时间
*
* @param dbSj001Map
* @param dbPz005s
* @param dbPz005As
* @param structMap
* @param parts
*/
private static void calcPlanDataDesc(Map<String, HGSJ001> dbSj001Map, List<HGPZ005> dbPz005s,
List<HGPZ005A> dbPz005As,
Map<String, List<HGSC005A>> structMap, List<HGSC005A> parts) {
String minDate = ""; String minDate = "";
BigDecimal remainder = new BigDecimal(0); BigDecimal remainder = new BigDecimal(0);
for (String key : strctMap.keySet()) { // 计算构件开始结束时间
for (Map.Entry<String, List<HGSC005A>> structEntry : structMap.entrySet()) {
String endDate = ""; String endDate = "";
for (HGSC005A planInfo : strctMap.get(key)) { for (HGSC005A iSc005A : structEntry.getValue()) {
remainder = calculateWordHour(planInfo, hgsj001List, hgpz005List, hgpz005AList, endDate, remainder); // 找出工序信息
if (StringUtils.isBlank(minDate)) { HGSJ001 dbSj001 = dbSj001Map.get(iSc005A.getProcessCode());
minDate = planInfo.getPlanStartDate(); AssertUtils.isNull(dbSj001, String.format("工序【%s】不存在", iSc005A.getProcessCode()));
} else { // 计算工序时长
minDate = DateUtil.toDate(planInfo.getPlanStartDate(), DateUtil.DATE10_PATTERN) remainder = calculateWordHourDesc(iSc005A, dbSj001, dbPz005s, dbPz005As, endDate, remainder);
.compareTo(DateUtil.toDate(minDate, DateUtil.DATE10_PATTERN)) <= 0 minDate = StringUtils.isBlank(minDate) || DateUtils.isBefore(iSc005A.getPlanStartDate(), minDate)
? planInfo.getPlanStartDate() : minDate; ? iSc005A.getPlanStartDate() : minDate;
} DaoUtils.update(HgScSqlConstant.HgSc005A.UPDATE_PLAN_DATE, iSc005A);
DaoUtils.update(HGSC005A.UPDATE, planInfo);
} }
} }
for (HGSC005A planInfo : partList) { // 计算零件开始结束时间
remainder = calculateWordHour(planInfo, hgsj001List, hgpz005List, hgpz005AList, minDate, remainder); for (HGSC005A iSc005A : parts) {
if (StringUtils.isBlank(minDate)) { // 找出工序信息
minDate = planInfo.getPlanStartDate(); HGSJ001 dbSj001 = dbSj001Map.get(iSc005A.getProcessCode());
} else { AssertUtils.isNull(dbSj001, String.format("工序【%s】不存在", iSc005A.getProcessCode()));
minDate = DateUtil.toDate(planInfo.getPlanStartDate(), DateUtil.DATE10_PATTERN) // 计算工序时长
.compareTo(DateUtil.toDate(minDate, DateUtil.DATE10_PATTERN)) <= 0 remainder = calculateWordHourDesc(iSc005A, dbSj001, dbPz005s, dbPz005As, minDate, remainder);
? planInfo.getPlanStartDate() : minDate; minDate = StringUtils.isBlank(minDate) || DateUtils.isBefore(iSc005A.getPlanStartDate(), minDate)
} ? iSc005A.getPlanStartDate() : minDate;
DaoUtils.update(HGSC005A.UPDATE, planInfo); DaoUtils.update(HgScSqlConstant.HgSc005A.UPDATE_PLAN_DATE, iSc005A);
} }
return hgsc005AList.size();
} }
private static String handleEndDate(String endDate, HGSC005A planInfo) { /**
if (StringUtils.isBlank(endDate) && StringUtils.isNotBlank(planInfo.getFinishDate())) { * @param dbSc005A
endDate = DateUtil.toDateStr(DateUtils.addDays(DateUtil.toDate(planInfo.getFinishDate(), * @param dbSj001
DateUtil.DATE10_PATTERN), finishDateDiffDay.intValue()), DateUtil.DATE10_PATTERN); * @param dbPz005s
* @param dbPz005As
* @param startDate
* @param remainder
* @return
*/
private static BigDecimal calculateWordHourAsc(HGSC005 dbSc005, HGSC005A dbSc005A, HGSJ001 dbSj001,
List<HGPZ005> dbPz005s, List<HGPZ005A> dbPz005As, String startDate, BigDecimal remainder) {
// 计算开始时间
startDate = handleStartDate(startDate, dbSc005, dbSj001);
dbSc005A.setPlanStartDate(startDate);
// 计算工序时间
BigDecimal workHour = calculateWordHour(dbSc005A, dbSj001, dbPz005s, dbPz005As, remainder);
BigDecimal day = workHour.divide(baseWorkHour, 0, ROUND_DOWN);
if (day.compareTo(BigDecimal.ZERO) > 0) {
startDate = LocalDate.parse(startDate).plusDays(day.intValue()).toString();
} }
return endDate; dbSc005A.setPlanEndDate(startDate);
return workHour.remainder(baseWorkHour);
} }
private static BigDecimal calculateWordHour(HGSC005A planInfo, List<HGSJ001> hgsj001List, /**
List<HGPZ005> hgpz005List, List<HGPZ005A> hgpz005AList, String endDate, BigDecimal remainder) { * @param dbSc005A
endDate = handleEndDate(endDate, planInfo); * @param dbSj001
planInfo.setPlanEndDate(endDate); * @param dbPz005s
AtomicReference<BigDecimal> workHour = new AtomicReference<>(new BigDecimal(0)); * @param dbPz005As
BigDecimal finalRemainder = remainder; * @param endDate
hgsj001List.stream().forEach(sj -> { * @param remainder
if (StringUtils.equals(sj.getProcessCode(), planInfo.getProcessCode())) { * @return
hgpz005AList.forEach(productProcess -> { */
if (productProcess.getId().compareTo(planInfo.getInventProcessId()) == 0) { private static BigDecimal calculateWordHourDesc(HGSC005A dbSc005A, HGSJ001 dbSj001,
BigDecimal composingCoeff = productProcess.getComposingCoeff(); List<HGPZ005> dbPz005s, List<HGPZ005A> dbPz005As, String endDate, BigDecimal remainder) {
hgpz005List.forEach(product->{ // 计算结束时间
if(StringUtils.equals(product.getInventCode(),planInfo.getProductCode())){ endDate = handleEndDate(endDate, dbSc005A, dbSj001);
//额定工时 dbSc005A.setPlanEndDate(endDate);
BigDecimal timing = sj.getStandardJob().multiply(sj.getStandardDays()).divide(sj.getStandardNum(),2, ROUND_DOWN); // 计算工序时间
ComputeTypeEnum computeType = ComputeTypeEnum.getEnumByCode(sj.getComputeType()); BigDecimal workHour = calculateWordHour(dbSc005A, dbSj001, dbPz005s, dbPz005As, remainder);
switch (computeType){ BigDecimal day = workHour.divide(baseWorkHour, 0, ROUND_DOWN);
case CD: if (day.compareTo(BigDecimal.ZERO) > 0) {
workHour.set(product.getLength().multiply(new BigDecimal(planInfo.getQuantity())).divide(unitConver, 2, ROUND_DOWN).multiply(composingCoeff) endDate = LocalDate.parse(endDate).minusDays(day.intValue()).toString();
.divide(timing,2, ROUND_DOWN) }
.multiply(baseWorkHour).add(finalRemainder)); dbSc005A.setPlanStartDate(endDate);
break; return workHour.remainder(baseWorkHour);
case SL: }
workHour.set(new BigDecimal(planInfo.getQuantity()).multiply(composingCoeff)
.divide(timing,2, ROUND_DOWN)
.multiply(baseWorkHour).add(finalRemainder));
break;
case ZL:
workHour.set(planInfo.getTotalWeight().multiply(composingCoeff)
.divide(timing,2, ROUND_DOWN)
.multiply(baseWorkHour).add(finalRemainder));
break;
default:
break;
}
}
});
}
});
}
});
BigDecimal day = workHour.get().divide(baseWorkHour, 0, ROUND_DOWN);
remainder = workHour.get().remainder(baseWorkHour);
if(day.compareTo(new BigDecimal(0))>0) {
endDate = DateUtil.toDateStr(DateUtils.addDays(DateUtil.toDate(endDate,DateUtil.DATE10_PATTERN),day.negate().intValue()),DateUtil.DATE10_PATTERN);
}
planInfo.setPlanStartDate(endDate);
return remainder;
}
}
public static class THGSC006{
public static void generatorOrder(List<HGSC005> hgsc005List, List<HGSC005A> hgsc005AList){
Map<String, Optional<HGSC005>> hgsc005Map = hgsc005List.stream().collect(Collectors.groupingBy(HGSC005::getPlanCode,Collectors.maxBy(
Comparator.comparingLong(HGSC005::getId))));
Map<String,List<HGSC005A>> hgsc005aMap = hgsc005AList.stream().collect(Collectors.groupingBy(HGSC005A::getPlanCode));
hgsc005Map.forEach((k,v) -> {
HGSC005 hgsc005 = v.get();
HGSC006 hgsc006 = constructObj(hgsc005);
List<HGSC006A> hgsc006AList = THGSC006A.constructObj(hgsc006,hgsc005aMap.get(hgsc005.getPlanCode()));
DaoUtils.insert(HGSC006.INSERT,hgsc006);
DaoUtils.insert(HGSC006A.INSERT,hgsc006AList);
});
}
public static HGSC006 constructObj(HGSC005 hgsc005){
HGSC006 hgsc006 = new HGSC006();
hgsc006.setOrderCode(SequenceGenerator.getNextSequence(HGConstant.SequenceId.HGSC006_ORDER_CODE));
hgsc006.setMatId(hgsc005.getMatId());
hgsc006.setPlanId(hgsc005.getId());
hgsc006.setCompanyCode(hgsc005.getCompanyCode());
hgsc006.setCompanyName(hgsc005.getCompanyName());
hgsc006.setProjCode(hgsc005.getProjCode());
hgsc006.setProjName(hgsc005.getProjName());
hgsc006.setAssignStatus(UNASSIGN.getCode());
return hgsc006;
}
public static HGSC006 getByOrderCode(String orderCode) {
AssertUtils.isEmpty(orderCode, "订单编号不能为空!");
HGSC006 results = (HGSC006)DaoBase.getInstance().get(HGSC006.QUERY, HGSC006.FIELD_order_code, orderCode);
return results;
}
}
public static class THGSC006A{
/**
* 锁
*
* @param orderDetailId
* @return
*/
public static void lock(Long orderDetailId) {
if (Objects.isNull(orderDetailId)||orderDetailId<=0) {
return;
}
Map queryMap = new HashMap();
queryMap.put(HGSC006A.FIELD_id, orderDetailId);
DaoBase.getInstance().update(HGSqlConstant.HGSC006A.LOCK, queryMap);
}
public static HGSC006A getById(Long orderDetailId){
AssertUtils.isTrue(Objects.isNull(orderDetailId)||orderDetailId<=0, "订单明细ID不能为空!");
HGSC006A results = (HGSC006A)DaoBase.getInstance().get(HGSC006A.QUERY, HGSC006A.FIELD_id, orderDetailId);
return results;
}
public static List<HGSC006A> constructObj(HGSC006 hgsc006,List<HGSC005A> hgsc005AList){
List<HGSC006A> result = new ArrayList<>();
hgsc005AList.forEach(o -> {
HGSC006A hgsc006a = new HGSC006A();
hgsc006a.setPlanId(hgsc006.getPlanId());
hgsc006a.setOrderCode(hgsc006.getOrderCode());
hgsc006a.setPlanDetailId(o.getId());
hgsc006a.setCompanyCode(o.getCompanyCode());
hgsc006a.setCompanyName(o.getCompanyName());
hgsc006a.setProjCode(o.getProjCode());
hgsc006a.setProjName(o.getProjName());
hgsc006a.setInventProcessId(o.getInventProcessId());
hgsc006a.setTechFlowId(o.getTechFlowId());
hgsc006a.setTechFlowName(o.getTechFlowName());
hgsc006a.setProcessCode(o.getProcessCode());
hgsc006a.setProcessName(o.getProcessName());
hgsc006a.setProcessOrder(o.getProcessOrder());
hgsc006a.setProductType(o.getProductType());
hgsc006a.setProductCode(o.getProductCode());
hgsc006a.setProductName(o.getProductName());
hgsc006a.setPlanStartDate(o.getPlanStartDate());
hgsc006a.setPlanEndDate(o.getPlanEndDate());
hgsc006a.setQuantity(o.getQuantity());
hgsc006a.setUnassignQuantity(o.getQuantity());
hgsc006a.setAssignQuantity(0);
hgsc006a.setSingleWeight(o.getSingleWeight());
hgsc006a.setTotalWeight(o.getTotalWeight());
hgsc006a.setUnassignWeight(hgsc006a.getTotalWeight());
result.add(hgsc006a);
});
return result;
}
public static List<HGSC006A> getByOrderCode(String orderCode) { /**
AssertUtils.isEmpty(orderCode, "订单编号不能为空!"); * @param dbSc005A
Map paramMap = new HashMap(); * @param dbSj001
paramMap.put(HGSC006A.FIELD_order_code, orderCode); * @param dbPz005s
List<HGSC006A> results = DaoBase.getInstance().query(HGSC006A.QUERY, paramMap); * @param dbPz005As
return CollectionUtils.isEmpty(results) ? null : results; * @param remainder
* @return
*/
private static BigDecimal calculateWordHour(HGSC005A dbSc005A, HGSJ001 dbSj001,
List<HGPZ005> dbPz005s, List<HGPZ005A> dbPz005As, BigDecimal remainder) {
AtomicReference<BigDecimal> workHour = new AtomicReference<>(BigDecimal.ZERO);
for (HGPZ005A dbPz005A : dbPz005As) {
if (dbPz005A.getId().compareTo(dbSc005A.getInventProcessId()) != 0) {
continue;
}
BigDecimal composingCoeff = dbPz005A.getComposingCoeff();
for (HGPZ005 dbPz005 : dbPz005s) {
if (!StringUtils.equals(dbPz005.getInventCode(), dbSc005A.getProductCode())) {
continue;
}
// 额定工时
BigDecimal timing = dbSj001.getStandardJob().multiply(dbSj001.getStandardDays())
.divide(dbSj001.getStandardNum(), 2, ROUND_DOWN);
ComputeTypeEnum computeType = ComputeTypeEnum.getEnumByCode(dbSj001.getComputeType());
switch (computeType) {
case CD:
workHour.set(dbPz005.getLength().multiply(new BigDecimal(dbSc005A.getQuantity()))
.divide(unitConver, 2, ROUND_DOWN).multiply(composingCoeff)
.divide(timing, 2, ROUND_DOWN)
.multiply(baseWorkHour).add(remainder));
break;
case SL:
workHour.set(new BigDecimal(dbSc005A.getQuantity()).multiply(composingCoeff)
.divide(timing, 2, ROUND_DOWN)
.multiply(baseWorkHour).add(remainder));
break;
case ZL:
workHour.set(dbSc005A.getTotalWeight().multiply(composingCoeff)
.divide(timing, 2, ROUND_DOWN)
.multiply(baseWorkHour).add(remainder));
break;
default:
break;
}
}
}
return workHour.get().divide(baseWorkHour, 0, ROUND_DOWN);
} }
public static List<HGSC006A> otherById(String orderCode, Long orderDetailId) { /**
AssertUtils.isEmpty(orderCode, "订单编号不能为空!"); * 处理开始日期
AssertUtils.isTrue(Objects.isNull(orderDetailId) || orderDetailId <= 0, "生产订单明细ID不能为空!"); *
Map paramMap = new HashMap(); * @param startDate
paramMap.put(HGSC006A.FIELD_order_code, orderCode); * @param dbSc005
paramMap.put(HGSC006A.FIELD_id, orderDetailId); * @param dbSj001
List<HGSC006A> results = DaoBase.getInstance().query(HGSC006A.QUERY_OTHER, paramMap); * @return
return CollectionUtils.isEmpty(results) ? null : results; */
private static String handleStartDate(String startDate, HGSC005 dbSc005, HGSJ001 dbSj001) {
// 计划的开始时间
LocalDate planStartDate = DateUtils.parseToDate(dbSc005.getCreatedTime());
if (StringUtils.isBlank(startDate)) {
return planStartDate.toString();
}
// 计算重叠天数
LocalDate startLocalDate = LocalDate.parse(startDate);
LocalDate newLocalDate = startLocalDate.minusDays(dbSj001.getOverlapDay());
return newLocalDate.isBefore(planStartDate) ? planStartDate.toString() : newLocalDate.toString();
}
/**
* 处理结束日期
*
* @param endDate
* @param dbSc005A
* @return
*/
private static String handleEndDate(String endDate, HGSC005A dbSc005A, HGSJ001 dbSj001) {
LocalDate finishDate = LocalDate.parse(dbSc005A.getFinishDate()).minusDays(finishDateDiffDay);
if (StringUtils.isBlank(endDate)) {
return finishDate.toString();
}
// 计算重叠天数
LocalDate endLocalDate = LocalDate.parse(endDate);
LocalDate newLocalDate = endLocalDate.plusDays(dbSj001.getOverlapDay());
return newLocalDate.isAfter(finishDate) ? finishDate.toString() : newLocalDate.toString();
} }
} }
/**
* @author:songx
* @date:2024/9/10,9:27
*/
public static class THGSC006 {
public static void generatorOrder(List<HGSC005> hgsc005List, List<HGSC005A> hgsc005AList) {
Map<String, Optional<HGSC005>> hgsc005Map = hgsc005List.stream()
.collect(Collectors.groupingBy(HGSC005::getPlanCode, Collectors.maxBy(
Comparator.comparingLong(HGSC005::getId))));
Map<String, List<HGSC005A>> hgsc005aMap = hgsc005AList.stream()
.collect(Collectors.groupingBy(HGSC005A::getPlanCode));
hgsc005Map.forEach((k, v) -> {
HGSC005 hgsc005 = v.get();
HGSC006 hgsc006 = constructObj(hgsc005);
List<HGSC006A> hgsc006AList = THGSC006A.constructObj(hgsc006, hgsc005aMap.get(hgsc005.getPlanCode()));
DaoUtils.insert(HGSC006.INSERT, hgsc006);
DaoUtils.insert(HGSC006A.INSERT, hgsc006AList);
});
}
public static HGSC006 constructObj(HGSC005 hgsc005) {
HGSC006 hgsc006 = new HGSC006();
hgsc006.setOrderCode(SequenceGenerator.getNextSequence(HGConstant.SequenceId.HGSC006_ORDER_CODE));
hgsc006.setMatId(hgsc005.getMatId());
hgsc006.setPlanId(hgsc005.getId());
hgsc006.setCompanyCode(hgsc005.getCompanyCode());
hgsc006.setCompanyName(hgsc005.getCompanyName());
hgsc006.setProjCode(hgsc005.getProjCode());
hgsc006.setProjName(hgsc005.getProjName());
hgsc006.setAssignStatus(UNASSIGN.getCode());
return hgsc006;
}
public static HGSC006 getByOrderCode(String orderCode) {
AssertUtils.isEmpty(orderCode, "订单编号不能为空!");
HGSC006 results = (HGSC006) DaoBase.getInstance().get(HGSC006.QUERY, HGSC006.FIELD_order_code, orderCode);
return results;
}
}
/** /**
* @author:songx * @author:songx
* @date:2024/9/8,9:41 * @date:2024/9/10,9:27
*/
public static class THGSC006A {
/**
* 锁
*
* @param orderDetailId
* @return
*/
public static void lock(Long orderDetailId) {
if (Objects.isNull(orderDetailId) || orderDetailId <= 0) {
return;
}
Map queryMap = new HashMap();
queryMap.put(HGSC006A.FIELD_id, orderDetailId);
DaoBase.getInstance().update(HGSqlConstant.HGSC006A.LOCK, queryMap);
}
public static HGSC006A getById(Long orderDetailId) {
AssertUtils.isTrue(Objects.isNull(orderDetailId) || orderDetailId <= 0, "订单明细ID不能为空!");
HGSC006A results = (HGSC006A) DaoBase.getInstance().get(HGSC006A.QUERY, HGSC006A.FIELD_id, orderDetailId);
return results;
}
public static List<HGSC006A> constructObj(HGSC006 hgsc006, List<HGSC005A> hgsc005AList) {
List<HGSC006A> result = new ArrayList<>();
hgsc005AList.forEach(o -> {
HGSC006A hgsc006a = new HGSC006A();
hgsc006a.setPlanId(hgsc006.getPlanId());
hgsc006a.setOrderCode(hgsc006.getOrderCode());
hgsc006a.setPlanDetailId(o.getId());
hgsc006a.setCompanyCode(o.getCompanyCode());
hgsc006a.setCompanyName(o.getCompanyName());
hgsc006a.setProjCode(o.getProjCode());
hgsc006a.setProjName(o.getProjName());
hgsc006a.setInventProcessId(o.getInventProcessId());
hgsc006a.setTechFlowId(o.getTechFlowId());
hgsc006a.setTechFlowName(o.getTechFlowName());
hgsc006a.setProcessCode(o.getProcessCode());
hgsc006a.setProcessName(o.getProcessName());
hgsc006a.setProcessOrder(o.getProcessOrder());
hgsc006a.setProductType(o.getProductType());
hgsc006a.setProductCode(o.getProductCode());
hgsc006a.setProductName(o.getProductName());
hgsc006a.setPlanStartDate(o.getPlanStartDate());
hgsc006a.setPlanEndDate(o.getPlanEndDate());
hgsc006a.setQuantity(o.getQuantity());
hgsc006a.setUnassignQuantity(o.getQuantity());
hgsc006a.setAssignQuantity(0);
hgsc006a.setSingleWeight(o.getSingleWeight());
hgsc006a.setTotalWeight(o.getTotalWeight());
hgsc006a.setUnassignWeight(hgsc006a.getTotalWeight());
result.add(hgsc006a);
});
return result;
}
public static List<HGSC006A> getByOrderCode(String orderCode) {
AssertUtils.isEmpty(orderCode, "订单编号不能为空!");
Map paramMap = new HashMap();
paramMap.put(HGSC006A.FIELD_order_code, orderCode);
List<HGSC006A> results = DaoBase.getInstance().query(HGSC006A.QUERY, paramMap);
return CollectionUtils.isEmpty(results) ? null : results;
}
public static List<HGSC006A> otherById(String orderCode, Long orderDetailId) {
AssertUtils.isEmpty(orderCode, "订单编号不能为空!");
AssertUtils.isTrue(Objects.isNull(orderDetailId) || orderDetailId <= 0, "生产订单明细ID不能为空!");
Map paramMap = new HashMap();
paramMap.put(HGSC006A.FIELD_order_code, orderCode);
paramMap.put(HGSC006A.FIELD_id, orderDetailId);
List<HGSC006A> results = DaoBase.getInstance().query(HGSC006A.QUERY_OTHER, paramMap);
return CollectionUtils.isEmpty(results) ? null : results;
}
}
/**
* @author:songx
* @date:2024/9/10,9:27
*/ */
public static class THGSC007 { public static class THGSC007 {
...@@ -1361,9 +1540,12 @@ public class HGSCTools { ...@@ -1361,9 +1540,12 @@ public class HGSCTools {
return DaoBase.getInstance().query(HGSC007.QUERY, queryMap); return DaoBase.getInstance().query(HGSC007.QUERY, queryMap);
} }
} }
/**
* @author:songx
* @date:2024/9/10,9:27
*/
public static class THGSC008 { public static class THGSC008 {
public static HGSC008 getById(Long taskId) { public static HGSC008 getById(Long taskId) {
...@@ -1386,110 +1568,118 @@ public class HGSCTools { ...@@ -1386,110 +1568,118 @@ public class HGSCTools {
HGSC007 hgsc007 = HGSCTools.THGSC007.getById(Long.valueOf(taskId)); HGSC007 hgsc007 = HGSCTools.THGSC007.getById(Long.valueOf(taskId));
HGSC008 hgsc008 = new HGSC008(); HGSC008 hgsc008 = new HGSC008();
BeanUtils.copyProperties(hgsc007, hgsc008); BeanUtils.copyProperties(hgsc007, hgsc008);
cleanBaseInfo(hgsc008); cleanBaseInfo(hgsc008);
hgsc008.setTaskId(hgsc007.getId()); hgsc008.setTaskId(hgsc007.getId());
hgsc008.setQuantity(NumberUtils.toInteger(resultMap.get(HGSC008.FIELD_quantity))); hgsc008.setQuantity(NumberUtils.toInteger(resultMap.get(HGSC008.FIELD_quantity)));
hgsc008.setRegisterDate(String.valueOf(resultMap.get(HGSC008.FIELD_register_date))); hgsc008.setRegisterDate(String.valueOf(resultMap.get(HGSC008.FIELD_register_date)));
hgsc008.setExceedReason(resultMap.get(HGSC008.FIELD_exceed_reason).toString()); hgsc008.setExceedReason(resultMap.get(HGSC008.FIELD_exceed_reason).toString());
hgsc008.setTotalWeight(hgsc007.getSingleWeight().multiply(new BigDecimal(hgsc008.getQuantity()))); hgsc008.setTotalWeight(hgsc007.getSingleWeight().multiply(new BigDecimal(hgsc008.getQuantity())));
checkAddDate(hgsc008); checkAddDate(hgsc008);
hgsc008.setWorkCode(SequenceGenerator.getNextSequence(HGConstant.SequenceId.HGSC008_WORK_CODE)); hgsc008.setWorkCode(SequenceGenerator.getNextSequence(HGConstant.SequenceId.HGSC008_WORK_CODE));
DaoUtils.insert(HGSC008.INSERT,hgsc008); DaoUtils.insert(HGSC008.INSERT, hgsc008);
HGZLTools.THGZL002.add(hgsc008); HGZLTools.THGZL002.add(hgsc008);
return hgsc008; return hgsc008;
} }
private static void checkAddDate(HGSC008 hgsc008) {
private static void checkAddDate(HGSC008 hgsc008){
// List<String> orgIdList = UserSessionUtils.getOrgId(); // List<String> orgIdList = UserSessionUtils.getOrgId();
// AssertUtils.isEmpty(hgsc008.getGroupCode(),"生产任务班组信息异常,请联系管理员!"); // AssertUtils.isEmpty(hgsc008.getGroupCode(),"生产任务班组信息异常,请联系管理员!");
// AssertUtils.isTrue(!orgIdList.contains(hgsc008.getGroupCode()),"非当前任务生产组用户,无法报工此任务!"); // AssertUtils.isTrue(!orgIdList.contains(hgsc008.getGroupCode()),"非当前任务生产组用户,无法报工此任务!");
AssertUtils.isNull(hgsc008.getQuantity(),"报工数量不能为空!"); AssertUtils.isNull(hgsc008.getQuantity(), "报工数量不能为空!");
} }
private static void cleanBaseInfo(HGSC008 hgsc008){ private static void cleanBaseInfo(HGSC008 hgsc008) {
hgsc008.setCreatedBy(null); hgsc008.setCreatedBy(null);
hgsc008.setCreatedName(null); hgsc008.setCreatedName(null);
hgsc008.setCreatedTime(null); hgsc008.setCreatedTime(null);
hgsc008.setUpdatedBy(null); hgsc008.setUpdatedBy(null);
hgsc008.setUpdatedName(null); hgsc008.setUpdatedName(null);
hgsc008.setUpdatedTime(null); hgsc008.setUpdatedTime(null);
hgsc008.setDepCode(null); hgsc008.setDepCode(null);
hgsc008.setDepName(null); hgsc008.setDepName(null);
hgsc008.setId(null); hgsc008.setId(null);
} }
public static void delete(List<Long> ids) { public static void delete(List<Long> ids) {
checkDeleteDate(ids); checkDeleteDate(ids);
DaoUtils.update(HGSC008.BATCH_DELETE, new HashMap<String,Object>(){{put("ids",ids);}}); DaoUtils.update(HGSC008.BATCH_DELETE, new HashMap<String, Object>() {{
HGZLTools.THGZL002.deleteByWorkIds(ids); put("ids", ids);
ids.forEach( id -> { }});
HGSCTools.THGSC099.deleteByMatId(id, HGConstant.FileBizType.SCBG); HGZLTools.THGZL002.deleteByWorkIds(ids);
}); ids.forEach(id -> {
} HGSCTools.THGSC099.deleteByMatId(id, HGConstant.FileBizType.SCBG);
});
private static void checkDeleteDate(List<Long> ids){ }
List<HGZL002> hgzl002s = HGZLTools.THGZL002.listByWorkIds(ids);
List<String> workCodes = hgzl002s.stream().filter(o -> o.getCheckStatus().compareTo(CheckStatusEnum.CHECKED.getCode())==0).map(HGZL002::getWorkCode).collect(Collectors.toList()); private static void checkDeleteDate(List<Long> ids) {
if(CollectionUtils.isNotEmpty(workCodes)){ List<HGZL002> hgzl002s = HGZLTools.THGZL002.listByWorkIds(ids);
AssertUtils.isNotEmpty(workCodes,String.format("生产报工单[%s]已经质检完成,无法删除!",String.join(",",workCodes))); List<String> workCodes = hgzl002s.stream()
} .filter(o -> o.getCheckStatus().compareTo(CheckStatusEnum.CHECKED.getCode()) == 0)
} .map(HGZL002::getWorkCode).collect(Collectors.toList());
} if (CollectionUtils.isNotEmpty(workCodes)) {
public static class THGSC099{ AssertUtils.isNotEmpty(workCodes, String.format("生产报工单[%s]已经质检完成,无法删除!", String.join(",", workCodes)));
}
public static List<HGSC099> listByMatId(Long matId, String bizType) { }
Map queryMap = new HashMap(); }
queryMap.put(HGSC099.FIELD_mat_id, matId);
queryMap.put(HGSC099.FIELD_biz_type, bizType); /**
// 项目环境 * @author:songx
String projectEnv = ProjectInfo.getProjectEnv(); * @date:2024/9/10,9:27
if (CommonConstant.projectEnv.RUN.equalsIgnoreCase(projectEnv)) { */
return DaoBase.getInstance().query("HGSC099.queryRun", queryMap); public static class THGSC099 {
} else {
return DaoBase.getInstance().query("HGSC099.queryDev", queryMap); public static List<HGSC099> listByMatId(Long matId, String bizType) {
} Map queryMap = new HashMap();
} queryMap.put(HGSC099.FIELD_mat_id, matId);
queryMap.put(HGSC099.FIELD_biz_type, bizType);
public static List<HGSC099> listByMatIds(List<Long> matIds, List<String> bizTypes) { // 项目环境
AssertUtils.isEmpty(matIds, "物料ID不能为空!"); String projectEnv = ProjectInfo.getProjectEnv();
Map queryMap = new HashMap(); if (CommonConstant.projectEnv.RUN.equalsIgnoreCase(projectEnv)) {
queryMap.put("matIds", matIds); return DaoBase.getInstance().query("HGSC099.queryRun", queryMap);
queryMap.put("bizTypes", bizTypes); } else {
// 项目环境 return DaoBase.getInstance().query("HGSC099.queryDev", queryMap);
String projectEnv = ProjectInfo.getProjectEnv(); }
if (CommonConstant.projectEnv.RUN.equalsIgnoreCase(projectEnv)) { }
return DaoBase.getInstance().query("HGSC099.queryRun", queryMap);
} else { public static List<HGSC099> listByMatIds(List<Long> matIds, List<String> bizTypes) {
return DaoBase.getInstance().query("HGSC099.queryDev", queryMap); AssertUtils.isEmpty(matIds, "物料ID不能为空!");
} Map queryMap = new HashMap();
} queryMap.put("matIds", matIds);
queryMap.put("bizTypes", bizTypes);
public static void deleteByMatId(Long matId, String bizType){ // 项目环境
List<HGSC099> hgsc099List = listByMatId(matId,bizType); String projectEnv = ProjectInfo.getProjectEnv();
for (int i = 0; i < hgsc099List.size(); i++) { if (CommonConstant.projectEnv.RUN.equalsIgnoreCase(projectEnv)) {
HGSC099 hgsc099 = hgsc099List.get(i); return DaoBase.getInstance().query("HGSC099.queryRun", queryMap);
DaoUtils.update(HGSC099.DELETE, hgsc099); } else {
if (!hgsc099.getDocId().isEmpty()) { return DaoBase.getInstance().query("HGSC099.queryDev", queryMap);
delectDoc(hgsc099.getDocId()); }
} }
}
public static void deleteByMatId(Long matId, String bizType) {
} List<HGSC099> hgsc099List = listByMatId(matId, bizType);
for (int i = 0; i < hgsc099List.size(); i++) {
/** HGSC099 hgsc099 = hgsc099List.get(i);
* 删除文件 DaoUtils.update(HGSC099.DELETE, hgsc099);
* @param docId 文件ID if (!hgsc099.getDocId().isEmpty()) {
*/ delectDoc(hgsc099.getDocId());
public static void delectDoc(String docId){ }
Map<String,Object> map = new HashMap<>(); }
map.put("docId",docId);
List<HGDS002> list = DaoBase.getInstance().query(HGDS002.QUERY,map); }
if (list.size() > 0) {
String realPath = list.get(0).getRealPath(); /**
// 项目环境 * 删除文件
String projectEnv = ProjectInfo.getProjectEnv(); * @param docId 文件ID
*/
public static void delectDoc(String docId) {
Map<String, Object> map = new HashMap<>();
map.put("docId", docId);
List<HGDS002> list = DaoBase.getInstance().query(HGDS002.QUERY, map);
if (list.size() > 0) {
String realPath = list.get(0).getRealPath();
// 项目环境
String projectEnv = ProjectInfo.getProjectEnv();
// if (projectEnv.equals(CommonConstant.projectEnv.RUN)) { // if (projectEnv.equals(CommonConstant.projectEnv.RUN)) {
// EiInfo queryInfo = new EiInfo(); // EiInfo queryInfo = new EiInfo();
// queryInfo.set(HGSC099.FIELD_doc_id,list.get(0).getDocId()); // queryInfo.set(HGSC099.FIELD_doc_id,list.get(0).getDocId());
...@@ -1511,16 +1701,15 @@ public class HGSCTools { ...@@ -1511,16 +1701,15 @@ public class HGSCTools {
// } // }
// } // }
// }else { // }else {
FileUtils.deleteFile(realPath); FileUtils.deleteFile(realPath);
// } // }
DaoBase.getInstance().delete(HGDS002.DELETE,map); DaoBase.getInstance().delete(HGDS002.DELETE,map);
} }
} }
}
}
public static class THGSC009{ public static class THGSC009{
/* public static void generatorOrder(List<HGSC005> hgsc005List, List<HGSC005A> hgsc005AList){ /* public static void generatorOrder(List<HGSC005> hgsc005List, List<HGSC005A> hgsc005AList){
......
...@@ -46,6 +46,7 @@ public class HGSJ001 extends DaoEPBase { ...@@ -46,6 +46,7 @@ public class HGSJ001 extends DaoEPBase {
public static final String FIELD_STATUS = "status"; /* 状态0.停止1.启用*/ public static final String FIELD_STATUS = "status"; /* 状态0.停止1.启用*/
public static final String FIELD_COMPUTE_TYPE = "computeType"; /* 计算类型*/ public static final String FIELD_COMPUTE_TYPE = "computeType"; /* 计算类型*/
public static final String FIELD_COST_WEIGHT = "costWeight"; public static final String FIELD_COST_WEIGHT = "costWeight";
public static final String FIELD_OVERLAP_DAY = "overlapDay"; /* 前后工序重叠天数*/
public static final String COL_ID = "ID"; /* 主键id*/ public static final String COL_ID = "ID"; /* 主键id*/
public static final String COL_ACCOUNT_CODE = "ACCOUNT_CODE"; /* 企业编码 预留*/ public static final String COL_ACCOUNT_CODE = "ACCOUNT_CODE"; /* 企业编码 预留*/
...@@ -67,6 +68,7 @@ public class HGSJ001 extends DaoEPBase { ...@@ -67,6 +68,7 @@ public class HGSJ001 extends DaoEPBase {
public static final String COL_STANDARD_NUM = "STANDARD_NUM"; /* 标准工序人数*/ public static final String COL_STANDARD_NUM = "STANDARD_NUM"; /* 标准工序人数*/
public static final String COL_PRINC = "PRINC"; /* 负责人*/ public static final String COL_PRINC = "PRINC"; /* 负责人*/
public static final String COL_STATUS = "STATUS"; /* 状态0.停止1.启用*/ public static final String COL_STATUS = "STATUS"; /* 状态0.停止1.启用*/
public static final String COL_OVERLAP_DAY = "OVERLAP_DAY"; /* 前后工序重叠天数*/
public static final String QUERY = "HGSJ001.query"; public static final String QUERY = "HGSJ001.query";
public static final String COUNT = "HGSJ001.count"; public static final String COUNT = "HGSJ001.count";
...@@ -99,6 +101,7 @@ public class HGSJ001 extends DaoEPBase { ...@@ -99,6 +101,7 @@ public class HGSJ001 extends DaoEPBase {
private Integer status = 0; /* 状态0.停止1.启用*/ private Integer status = 0; /* 状态0.停止1.启用*/
private Integer computeType = 0; private Integer computeType = 0;
private BigDecimal costWeight = new BigDecimal(0.000); private BigDecimal costWeight = new BigDecimal(0.000);
private Integer overlapDay = 0; /* 前后工序重叠天数*/
/** /**
* initialize the metadata. * initialize the metadata.
...@@ -210,6 +213,11 @@ public class HGSJ001 extends DaoEPBase { ...@@ -210,6 +213,11 @@ public class HGSJ001 extends DaoEPBase {
eiColumn.setFieldLength(15); eiColumn.setFieldLength(15);
eiColumn.setDescName("费用权重"); eiColumn.setDescName("费用权重");
eiMetadata.addMeta(eiColumn); eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_OVERLAP_DAY);
eiColumn.setType("N");
eiColumn.setDescName("前后工序重叠天数");
eiMetadata.addMeta(eiColumn);
} }
...@@ -565,6 +573,15 @@ public class HGSJ001 extends DaoEPBase { ...@@ -565,6 +573,15 @@ public class HGSJ001 extends DaoEPBase {
public void setCostWeight(BigDecimal costWeight) { public void setCostWeight(BigDecimal costWeight) {
this.costWeight = costWeight; this.costWeight = costWeight;
} }
public Integer getOverlapDay() {
return overlapDay;
}
public void setOverlapDay(Integer overlapDay) {
this.overlapDay = overlapDay;
}
/** /**
* get the value from Map. * get the value from Map.
* *
...@@ -596,6 +613,7 @@ public class HGSJ001 extends DaoEPBase { ...@@ -596,6 +613,7 @@ public class HGSJ001 extends DaoEPBase {
setStatus(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_STATUS)), status)); setStatus(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_STATUS)), status));
setComputeType(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_COMPUTE_TYPE)), computeType)); setComputeType(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_COMPUTE_TYPE)), computeType));
setCostWeight(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_COST_WEIGHT)), costWeight)); setCostWeight(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_COST_WEIGHT)), costWeight));
setOverlapDay(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_OVERLAP_DAY)), overlapDay));
} }
/** /**
...@@ -628,6 +646,7 @@ public class HGSJ001 extends DaoEPBase { ...@@ -628,6 +646,7 @@ public class HGSJ001 extends DaoEPBase {
map.put(FIELD_STATUS, StringUtils.toString(status, eiMetadata.getMeta(FIELD_STATUS))); map.put(FIELD_STATUS, StringUtils.toString(status, eiMetadata.getMeta(FIELD_STATUS)));
map.put(FIELD_COMPUTE_TYPE, StringUtils.toString(computeType, eiMetadata.getMeta(FIELD_COMPUTE_TYPE))); map.put(FIELD_COMPUTE_TYPE, StringUtils.toString(computeType, eiMetadata.getMeta(FIELD_COMPUTE_TYPE)));
map.put(FIELD_COST_WEIGHT,StringUtils.toString(costWeight, eiMetadata.getMeta(FIELD_COST_WEIGHT))); map.put(FIELD_COST_WEIGHT,StringUtils.toString(costWeight, eiMetadata.getMeta(FIELD_COST_WEIGHT)));
map.put(FIELD_OVERLAP_DAY,StringUtils.toString(overlapDay, eiMetadata.getMeta(FIELD_OVERLAP_DAY)));
return map; return map;
} }
......
...@@ -3,54 +3,35 @@ ...@@ -3,54 +3,35 @@
<sqlMap namespace="HGSJ001"> <sqlMap namespace="HGSJ001">
<sql id="column"> <sql id="column">
ID as "id", <!-- 主键id --> ID as "id", <!-- 主键id -->
ACCOUNT_CODE as "accountCode", <!-- 企业编码 预留 --> ACCOUNT_CODE as "accountCode", <!-- 企业编码 预留 -->
DEP_CODE as "depCode", <!-- 部门编码 --> DEP_CODE as "depCode", <!-- 部门编码 -->
CREATED_BY as "createdBy", <!-- 创建人 --> CREATED_BY as "createdBy", <!-- 创建人 -->
CREATED_NAME as "createdName", <!-- 创建人名称 --> CREATED_NAME as "createdName", <!-- 创建人名称 -->
CREATED_TIME as "createdTime", <!-- 创建时间 --> CREATED_TIME as "createdTime", <!-- 创建时间 -->
UPDATED_BY as "updatedBy", <!-- 更新人 --> UPDATED_BY as "updatedBy", <!-- 更新人 -->
UPDATED_NAME as "updatedName", <!-- 更新人名称 --> UPDATED_NAME as "updatedName", <!-- 更新人名称 -->
UPDATED_TIME as "updatedTime", <!-- 更新时间 --> UPDATED_TIME as "updatedTime", <!-- 更新时间 -->
DELETE_FLAG as "deleteFlag", <!-- 是否删除0.否1.是 --> DELETE_FLAG as "deleteFlag", <!-- 是否删除0.否1.是 -->
FACTORY_CODE as "factoryCode", <!-- 厂区编码 --> FACTORY_CODE as "factoryCode", <!-- 厂区编码 -->
FACTORY_NAME as "factoryName", <!-- 厂区名称 --> FACTORY_NAME as "factoryName", <!-- 厂区名称 -->
PROCESS_CODE as "processCode", <!-- 工序编码 --> PROCESS_CODE as "processCode", <!-- 工序编码 -->
PROCESS_NAME as "processName", <!-- 工序名称 --> PROCESS_NAME as "processName", <!-- 工序名称 -->
UNIT as "unit", <!-- 单位 --> UNIT as "unit", <!-- 单位 -->
STANDARD_JOB as "standardJob", <!-- 标准作业 --> STANDARD_JOB as "standardJob", <!-- 标准作业 -->
STANDARD_DAYS as "standardDays", <!-- 标准人天 --> STANDARD_DAYS as "standardDays", <!-- 标准人天 -->
STANDARD_NUM as "standardNum", <!-- 标准工序人数 --> STANDARD_NUM as "standardNum", <!-- 标准工序人数 -->
PRINC as "princ", <!-- 负责人 --> PRINC as "princ", <!-- 负责人 -->
PRINC_NAME as "princName", <!-- 负责人名称 --> PRINC_NAME as "princName", <!-- 负责人名称 -->
STATUS as "status", <!-- 状态0.停止1.启动 --> STATUS as "status", <!-- 状态0.停止1.启动 -->
COMPUTE_TYPE as "computeType", COMPUTE_TYPE as "computeType",
COST_WEIGHT as "costWeight" <!-- 费用权重 --> COST_WEIGHT as "costWeight", <!-- 费用权重 -->
OVERLAP_DAY as "overlapDay" <!-- 前后工序重叠天数 -->
</sql> </sql>
<sql id="authCondition">
<!-- 无权限时使用 -->
<isNotEmpty prepend=" AND " property="authDepCode">
DEP_CODE = #authDepCode#
</isNotEmpty>
<!-- 仅本人和部门组合 -->
<isEqual prepend=" AND " property="authCombination" compareValue="1">
(CREATED_BY = #authOnlyPeople# OR DEP_CODE IN <iterate close=")" open="(" conjunction="," property="authDepCodes">#authDepCodes[]#</iterate>)
</isEqual>
<!-- 仅本人或部门 -->
<isNotEqual prepend=" AND " property="authCombination" compareValue="1">
<isNotEmpty property="authOnlyPeople">
CREATED_BY = #authOnlyPeople#
</isNotEmpty>
<isNotEmpty property="authDepCodes">
DEP_CODE IN <iterate close=")" open="(" conjunction="," property="authDepCodes">#authDepCodes[]#</iterate>
</isNotEmpty>
</isNotEqual>
</sql>
<sql id="condition"> <sql id="condition">
AND DELETE_FLAG = 0 AND DELETE_FLAG = 0
<include refid="authCondition"/> <include refid="HGXSDataAuth.authCondition"/>
<isNotEmpty prepend=" AND " property="id"> <isNotEmpty prepend=" AND " property="id">
ID = #id# ID = #id#
</isNotEmpty> </isNotEmpty>
...@@ -128,175 +109,105 @@ ...@@ -128,175 +109,105 @@
</isNotEmpty> </isNotEmpty>
</sql> </sql>
<select id="query" parameterClass="java.util.HashMap" <sql id="orderBy">
resultClass="com.baosight.hggp.hg.sj.domain.HGSJ001"> <dynamic prepend="ORDER BY">
SELECT <isNotEmpty property="orderBy">
<include refid="column"/> $orderBy$
FROM ${hggpSchema}.HGGY001 WHERE 1=1 </isNotEmpty>
<include refid="condition" /> <isEmpty property="orderBy">
<dynamic prepend="ORDER BY"> CREATED_TIME DESC, ID ASC
<isNotEmpty property="orderBy"> </isEmpty>
$orderBy$ </dynamic>
</isNotEmpty> </sql>
<isEmpty property="orderBy">
CREATED_TIME desc,ID asc
</isEmpty>
</dynamic>
</select> <select id="query" resultClass="com.baosight.hggp.hg.sj.domain.HGSJ001">
SELECT
<include refid="column"/>
FROM ${hggpSchema}.HGGY001 WHERE 1=1
<include refid="condition"/>
<include refid="orderBy"/>
</select>
<select id="count" resultClass="int"> <select id="count" resultClass="int">
SELECT COUNT(*) FROM ${hggpSchema}.HGGY001 WHERE 1=1 SELECT COUNT(*) FROM ${hggpSchema}.HGGY001 WHERE 1=1
<include refid="condition" /> <include refid="condition"/>
</select> </select>
<!-- <insert id="insert">
<isNotEmpty prepend=" AND " property="id"> INSERT INTO ${hggpSchema}.HGGY001 (
ID = #id# ACCOUNT_CODE, <!-- 企业编码 预留 -->
</isNotEmpty> DEP_CODE, <!-- 部门编码 -->
<isNotEmpty prepend=" AND " property="accountCode"> CREATED_BY, <!-- 创建人 -->
ACCOUNT_CODE = #accountCode# CREATED_NAME, <!-- 创建人名称 -->
</isNotEmpty> CREATED_TIME, <!-- 创建时间 -->
<isNotEmpty prepend=" AND " property="depCode"> DELETE_FLAG, <!-- 是否删除0.否1.是 -->
DEP_CODE = #depCode# FACTORY_CODE, <!-- 厂区编码 -->
</isNotEmpty> FACTORY_NAME, <!-- 厂区名称 -->
<isNotEmpty prepend=" AND " property="createdBy"> PROCESS_CODE, <!-- 工序编码 -->
CREATED_BY = #createdBy# PROCESS_NAME, <!-- 工序名称 -->
</isNotEmpty> UNIT, <!-- 单位 -->
<isNotEmpty prepend=" AND " property="createdName"> STANDARD_JOB, <!-- 标准作业 -->
CREATED_NAME = #createdName# STANDARD_DAYS, <!-- 标准人天 -->
</isNotEmpty> STANDARD_NUM, <!-- 标准工序人数 -->
<isNotEmpty prepend=" AND " property="createdTime"> PRINC, <!-- 负责人 -->
CREATED_TIME = #createdTime# PRINC_NAME,
</isNotEmpty> STATUS, <!-- 状态0.停止1.启动 -->
<isNotEmpty prepend=" AND " property="updatedBy"> COMPUTE_TYPE, COST_WEIGHT, OVERLAP_DAY
UPDATED_BY = #updatedBy# ) VALUES (
</isNotEmpty> #accountCode#, #depCode#, #createdBy#, #createdName#, #createdTime#,
<isNotEmpty prepend=" AND " property="updatedName"> #deleteFlag#, #factoryCode#, #factoryName#, #processCode#, #processName#,
UPDATED_NAME = #updatedName# #unit#, #standardJob#, #standardDays#, #standardNum#, #princ#, #princName#,
</isNotEmpty> #status#, #computeType#, #costWeight#, #overlapDay#)
<isNotEmpty prepend=" AND " property="updatedTime"> </insert>
UPDATED_TIME = #updatedTime#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="deleteFlag">
DELETE_FLAG = #deleteFlag#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="factoryCode">
FACTORY_CODE = #factoryCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="factoryName">
FACTORY_NAME = #factoryName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="processCode">
PROCESS_CODE = #processCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="processName">
PROCESS_NAME = #processName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="unit">
UNIT = #unit#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="standardJob">
STANDARD_JOB = #standardJob#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="standardDays">
STANDARD_DAYS = #standardDays#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="standardNum">
STANDARD_NUM = #standardNum#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="princ">
PRINC = #princ#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="status">
STATUS = #status#
</isNotEmpty>
-->
<insert id="insert">
INSERT INTO ${hggpSchema}.HGGY001 (ID, <!-- 主键id -->
ACCOUNT_CODE, <!-- 企业编码 预留 -->
DEP_CODE, <!-- 部门编码 -->
CREATED_BY, <!-- 创建人 -->
CREATED_NAME, <!-- 创建人名称 -->
CREATED_TIME, <!-- 创建时间 -->
UPDATED_BY, <!-- 更新人 -->
UPDATED_NAME, <!-- 更新人名称 -->
UPDATED_TIME, <!-- 更新时间 -->
DELETE_FLAG, <!-- 是否删除0.否1.是 -->
FACTORY_CODE, <!-- 厂区编码 -->
FACTORY_NAME, <!-- 厂区名称 -->
PROCESS_CODE, <!-- 工序编码 -->
PROCESS_NAME, <!-- 工序名称 -->
UNIT, <!-- 单位 -->
STANDARD_JOB, <!-- 标准作业 -->
STANDARD_DAYS, <!-- 标准人天 -->
STANDARD_NUM, <!-- 标准工序人数 -->
PRINC, <!-- 负责人 -->
PRINC_NAME,
STATUS, <!-- 状态0.停止1.启动 -->
COMPUTE_TYPE,
COST_WEIGHT
)
VALUES (#id#, #accountCode#, #depCode#, #createdBy#, #createdName#, #createdTime#, #updatedBy#, #updatedName#, #updatedTime#, #deleteFlag#, #factoryCode#, #factoryName#, #processCode#, #processName#, #unit#, #standardJob#, #standardDays#, #standardNum#, #princ#, #princName#,#status#,#computeType#, #costWeight#)
</insert>
<delete id="delete"> <delete id="delete">
DELETE FROM ${hggpSchema}.HGGY001 WHERE DELETE FROM ${hggpSchema}.HGGY001 WHERE ID = #id#
ID = #id# </delete>
</delete>
<!--逻辑删除--> <!--逻辑删除-->
<update id="deleteFlag"> <update id="deleteFlag">
UPDATE ${hggpSchema}.HGGY001 UPDATE ${hggpSchema}.HGGY001
SET SET
UPDATED_BY = #updatedBy#, <!-- 更新人 --> UPDATED_BY = #updatedBy#, <!-- 更新人 -->
UPDATED_NAME = #updatedName#, <!-- 更新人名称 --> UPDATED_NAME = #updatedName#, <!-- 更新人名称 -->
UPDATED_TIME = #updatedTime#, <!-- 更新时间 --> UPDATED_TIME = #updatedTime#, <!-- 更新时间 -->
DELETE_FLAG = #deleteFlag# <!-- 是否删除0.否1.是 --> DELETE_FLAG = #deleteFlag# <!-- 是否删除0.否1.是 -->
WHERE WHERE ID = #id#
ID = #id# </update>
</update>
<update id="update"> <update id="update">
UPDATE ${hggpSchema}.HGGY001 UPDATE ${hggpSchema}.HGGY001
SET SET
ACCOUNT_CODE = #accountCode#, <!-- 企业编码 预留 --> UPDATED_BY = #updatedBy#, <!-- 更新人 -->
DEP_CODE = #depCode#, <!-- 部门编码 --> UPDATED_NAME = #updatedName#, <!-- 更新人名称 -->
CREATED_BY = #createdBy#, <!-- 创建人 --> UPDATED_TIME = #updatedTime#, <!-- 更新时间 -->
CREATED_NAME = #createdName#, <!-- 创建人名称 --> DELETE_FLAG = #deleteFlag#, <!-- 是否删除0.否1.是 -->
CREATED_TIME = #createdTime#, <!-- 创建时间 --> FACTORY_CODE = #factoryCode#, <!-- 厂区编码 -->
UPDATED_BY = #updatedBy#, <!-- 更新人 --> FACTORY_NAME = #factoryName#, <!-- 厂区名称 -->
UPDATED_NAME = #updatedName#, <!-- 更新人名称 --> PROCESS_CODE = #processCode#, <!-- 工序编码 -->
UPDATED_TIME = #updatedTime#, <!-- 更新时间 --> PROCESS_NAME = #processName#, <!-- 工序名称 -->
DELETE_FLAG = #deleteFlag#, <!-- 是否删除0.否1.是 --> UNIT = #unit#, <!-- 单位 -->
FACTORY_CODE = #factoryCode#, <!-- 厂区编码 --> STANDARD_JOB = #standardJob#, <!-- 标准作业 -->
FACTORY_NAME = #factoryName#, <!-- 厂区名称 --> STANDARD_DAYS = #standardDays#, <!-- 标准人天 -->
PROCESS_CODE = #processCode#, <!-- 工序编码 --> STANDARD_NUM = #standardNum#, <!-- 标准工序人数 -->
PROCESS_NAME = #processName#, <!-- 工序名称 --> PRINC = #princ#, <!-- 负责人 -->
UNIT = #unit#, <!-- 单位 --> PRINC_NAME = #princName#,
STANDARD_JOB = #standardJob#, <!-- 标准作业 --> STATUS = #status#, <!-- 状态0.停止1.启动 -->
STANDARD_DAYS = #standardDays#, <!-- 标准人天 --> COMPUTE_TYPE = #computeType#,
STANDARD_NUM = #standardNum#, <!-- 标准工序人数 --> COST_WEIGHT = #costWeight#,
PRINC = #princ#, <!-- 负责人 --> OVERLAP_DAY = #overlapDay#
PRINC_NAME = #princName#, WHERE ID = #id#
STATUS = #status#, <!-- 状态0.停止1.启动 --> </update>
COMPUTE_TYPE = #computeType#,
COST_WEIGHT = #costWeight#
WHERE
ID = #id#
</update>
<update id="updateStatus"> <update id="updateStatus">
UPDATE ${hggpSchema}.HGGY001 UPDATE ${hggpSchema}.HGGY001
SET SET
UPDATED_BY = #updatedBy#, <!-- 更新人 --> UPDATED_BY = #updatedBy#, <!-- 更新人 -->
UPDATED_NAME = #updatedName#, <!-- 更新人名称 --> UPDATED_NAME = #updatedName#, <!-- 更新人名称 -->
UPDATED_TIME = #updatedTime#, <!-- 更新时间 --> UPDATED_TIME = #updatedTime#, <!-- 更新时间 -->
STATUS = #status# <!-- 状态0.启用1.停止 --> STATUS = #status# <!-- 状态0.启用1.停止 -->
WHERE WHERE ID = #id#
ID = #id# </update>
</update>
<select id="queryProcessCode" parameterClass="java.util.HashMap" resultClass="java.util.HashMap"> <select id="queryProcessCode" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
SELECT SELECT
......
...@@ -22,27 +22,51 @@ import java.util.stream.Collectors; ...@@ -22,27 +22,51 @@ import java.util.stream.Collectors;
*/ */
public class HGSJTools { public class HGSJTools {
/**
*
* @author:songx
* @date:2024/9/10,11:04
*/
public static class Hgsj001 { public static class Hgsj001 {
public static List<HGSJ001> queryByProcessCodes(List<String> processCodes){ /**
*
* @param processCodes
* @return
*/
public static List<HGSJ001> queryByProcessCodes(List<String> processCodes){
AssertUtils.isEmpty(processCodes, "工序编码不能为空!"); AssertUtils.isEmpty(processCodes, "工序编码不能为空!");
Map paramMap = new HashMap(); Map paramMap = new HashMap();
paramMap.put("processCodes", processCodes); paramMap.put("processCodes", processCodes);
List<HGSJ001> results = DaoBase.getInstance().query(HGSJ001.QUERY, paramMap); List<HGSJ001> results = DaoBase.getInstance().query(HGSJ001.QUERY, paramMap);
return CollectionUtils.isEmpty(results) ? null : results; return CollectionUtils.isEmpty(results) ? null : results;
} }
}
/**
/** * @param processCodes
* Hgsj002a公共DAO方法定义 * @return
*/ */
public static class Hgsj002a { public static Map<String, HGSJ001> mapByCode(List<String> processCodes) {
/** List<HGSJ001> results = queryByProcessCodes(processCodes);
* 查询 if (CollectionUtils.isEmpty(results)) {
* @param parentId return null;
* @return }
*/ return results.stream().collect(Collectors.toMap(HGSJ001::getProcessCode, item -> item));
public static List<HGSJ002A> list(Long parentId){ }
}
/**
* Hgsj002a公共DAO方法定义
*/
public static class Hgsj002a {
/**
* 查询
*
* @param parentId
* @return
*/
public static List<HGSJ002A> list(Long parentId){
AssertUtils.isNull(parentId, "parentId不能为空"); AssertUtils.isNull(parentId, "parentId不能为空");
Map queryMap = new HashMap(); Map queryMap = new HashMap();
queryMap.put(HGSJ002A.FIELD_PAREND_ID, parentId); queryMap.put(HGSJ002A.FIELD_PAREND_ID, parentId);
......
...@@ -3,15 +3,12 @@ ...@@ -3,15 +3,12 @@
*/ */
package com.baosight.hggp.util; package com.baosight.hggp.util;
import java.text.SimpleDateFormat;
import java.time.Instant; import java.time.Instant;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters; import java.time.temporal.TemporalAdjusters;
import java.util.Date;
import java.util.GregorianCalendar;
/** /**
* jdk8中新增的日期处理类,更安全、更精确也更明确 * jdk8中新增的日期处理类,更安全、更精确也更明确
...@@ -21,7 +18,7 @@ import java.util.GregorianCalendar; ...@@ -21,7 +18,7 @@ import java.util.GregorianCalendar;
*/ */
public class DateUtils extends org.apache.commons.lang3.time.DateUtils { public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
public static final DateTimeFormatter DATETIME_ALL = DateTimeFormatter.ofPattern("yyyy-MM-dd\'T\'HH:mm:ss"); public static final DateTimeFormatter DATETIME_ALL = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");
public static final DateTimeFormatter TIME = DateTimeFormatter.ofPattern("HHmmss"); public static final DateTimeFormatter TIME = DateTimeFormatter.ofPattern("HHmmss");
public static final DateTimeFormatter SHORT_YMDHMSS = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS"); public static final DateTimeFormatter SHORT_YMDHMSS = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS");
public static final DateTimeFormatter SHORT_DATETIME = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); public static final DateTimeFormatter SHORT_DATETIME = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
...@@ -39,26 +36,27 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { ...@@ -39,26 +36,27 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
* @return * @return
*/ */
public static String getYesMonth(String date) { public static String getYesMonth(String date) {
return getYesMonth(date,DateTimeFormatter.ISO_LOCAL_DATE); return getYesMonth(date, DateTimeFormatter.ISO_LOCAL_DATE);
} }
public static String getYesMonth(String date,DateTimeFormatter dateTimeFormatter) { public static String getYesMonth(String date, DateTimeFormatter dateTimeFormatter) {
LocalDate endLocalDate = LocalDate.parse(date, dateTimeFormatter); LocalDate endLocalDate = LocalDate.parse(date, dateTimeFormatter);
endLocalDate = endLocalDate.minusMonths(1).with(TemporalAdjusters.firstDayOfMonth()); endLocalDate = endLocalDate.minusMonths(1).with(TemporalAdjusters.firstDayOfMonth());
return endLocalDate.format(dateTimeFormatter); return endLocalDate.format(dateTimeFormatter);
} }
/** /**
* 获取下个月的1号日期 * 获取下个月的1号日期
* *
* @param date 2023-09-06 or 20230906 * @param date 2023-09-06 or 20230906
* @return * @return
*/ */
public static String getPlusYesMonth(String date,DateTimeFormatter dateTimeFormatter) { public static String getPlusYesMonth(String date, DateTimeFormatter dateTimeFormatter) {
LocalDate endLocalDate = LocalDate.parse(date, dateTimeFormatter); LocalDate endLocalDate = LocalDate.parse(date, dateTimeFormatter);
endLocalDate = endLocalDate.plusMonths(1).with(TemporalAdjusters.firstDayOfMonth()); endLocalDate = endLocalDate.plusMonths(1).with(TemporalAdjusters.firstDayOfMonth());
return endLocalDate.format(dateTimeFormatter); return endLocalDate.format(dateTimeFormatter);
} }
/** /**
* 获取当前的日期字符串(yyyy-MM) * 获取当前的日期字符串(yyyy-MM)
* *
...@@ -76,7 +74,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { ...@@ -76,7 +74,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
public static String date() { public static String date() {
return date(null); return date(null);
} }
/** /**
* 获取前一天日期字符串(yyyy-MM-dd) * 获取前一天日期字符串(yyyy-MM-dd)
* *
...@@ -85,14 +83,16 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { ...@@ -85,14 +83,16 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
public static String yesterday() { public static String yesterday() {
return LocalDate.now().minusDays(1).format(DATE); return LocalDate.now().minusDays(1).format(DATE);
} }
/** /**
* 获取后一天日期字符串(yyyy-MM-dd) * 获取后一天日期字符串(yyyy-MM-dd)
* *
* @return * @return
*/ */
public static String yesterdayEnd(String date,Integer day) { public static String yesterdayEnd(String date, Integer day) {
return LocalDate.parse(date, SHORT_DATE).plusDays(day).format(DATE); return LocalDate.parse(date, SHORT_DATE).plusDays(day).format(DATE);
} }
/** /**
* 获取日期字符串(yyyy-MM-dd) * 获取日期字符串(yyyy-MM-dd)
* *
...@@ -252,4 +252,32 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { ...@@ -252,4 +252,32 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
.replaceAll(" ", ""); .replaceAll(" ", "");
} }
/**
* 转换成日期
*
* @param dateTime yyyyMMddhhmmss
* @return
*/
public static LocalDate parseToDate(String dateTime) {
return LocalDateTime.parse(dateTime, SHORT_DATETIME).toLocalDate();
}
/**
* @param startDate yyyy-MM-dd
* @param endDate yyyy-MM-dd
* @return
*/
public static boolean isBefore(String startDate, String endDate) {
return LocalDate.parse(startDate).isBefore(LocalDate.parse(endDate));
}
/**
* @param startDate yyyy-MM-dd
* @param endDate yyyy-MM-dd
* @return
*/
public static boolean isAfter(String startDate, String endDate) {
return LocalDate.parse(startDate).isAfter(LocalDate.parse(endDate));
}
} }
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
<!-- 工具 --> <!-- 工具 -->
<sqlMap resource="com/baosight/hggp/hg/dm/sql/HGDM099.xml"/> <sqlMap resource="com/baosight/hggp/hg/dm/sql/HGDM099.xml"/>
<!-- 工艺 -->
<sqlMap resource="com/baosight/hggp/hg/sj/sql/HGSJ001.xml"/>
<!--成本--> <!--成本-->
<sqlMap resource="com/baosight/hggp/hg/cb/sql/HGCB001.xml"/> <sqlMap resource="com/baosight/hggp/hg/cb/sql/HGCB001.xml"/>
<sqlMap resource="com/baosight/hggp/hg/cb/sql/HGCB002.xml"/> <sqlMap resource="com/baosight/hggp/hg/cb/sql/HGCB002.xml"/>
...@@ -27,6 +30,7 @@ ...@@ -27,6 +30,7 @@
<sqlMap resource="com/baosight/hggp/hg/cg/sql/HGCG001.xml"/> <sqlMap resource="com/baosight/hggp/hg/cg/sql/HGCG001.xml"/>
<sqlMap resource="com/baosight/hggp/hg/cg/sql/HGCG002.xml"/> <sqlMap resource="com/baosight/hggp/hg/cg/sql/HGCG002.xml"/>
<sqlMap resource="com/baosight/hggp/hg/cg/sql/HGCG003.xml"/> <sqlMap resource="com/baosight/hggp/hg/cg/sql/HGCG003.xml"/>
<!-- 库存 --> <!-- 库存 -->
<sqlMap resource="com/baosight/hggp/hg/kc/sql/HGKC001.xml"/> <sqlMap resource="com/baosight/hggp/hg/kc/sql/HGKC001.xml"/>
<sqlMap resource="com/baosight/hggp/hg/kc/sql/HGKC002.xml"/> <sqlMap resource="com/baosight/hggp/hg/kc/sql/HGKC002.xml"/>
...@@ -44,6 +48,7 @@ ...@@ -44,6 +48,7 @@
<sqlMap resource="com/baosight/hggp/hg/kc/sql/HGKC011.xml"/> <sqlMap resource="com/baosight/hggp/hg/kc/sql/HGKC011.xml"/>
<sqlMap resource="com/baosight/hggp/hg/kc/sql/HGKC013.xml"/> <sqlMap resource="com/baosight/hggp/hg/kc/sql/HGKC013.xml"/>
<sqlMap resource="com/baosight/hggp/hg/kc/sql/HGKC013A.xml"/> <sqlMap resource="com/baosight/hggp/hg/kc/sql/HGKC013A.xml"/>
<!-- 质量 --> <!-- 质量 -->
<sqlMap resource="com/baosight/hggp/hg/zl/sql/HGZL001.xml"/> <sqlMap resource="com/baosight/hggp/hg/zl/sql/HGZL001.xml"/>
<sqlMap resource="com/baosight/hggp/hg/zl/sql/HGZL002.xml"/> <sqlMap resource="com/baosight/hggp/hg/zl/sql/HGZL002.xml"/>
......
...@@ -7,7 +7,7 @@ $(function () { ...@@ -7,7 +7,7 @@ $(function () {
}); });
// 正序排产 // 正序排产
$("#BNT_SCHEDULE_EX").on("click", scheduleEx); $("#BNT_SCHEDULE_ASC").on("click", scheduleAsc);
// 倒序排产 // 倒序排产
$("#BNT_SCHEDULE").on("click", schedule); $("#BNT_SCHEDULE").on("click", schedule);
...@@ -45,10 +45,10 @@ $(window).load(function () { ...@@ -45,10 +45,10 @@ $(window).load(function () {
/** /**
* 正序排产 * 正序排产
*/ */
function schedule() { function scheduleAsc() {
JSUtils.confirm("自动排产将覆盖原排产数据,请谨慎操作,确认对当前数据进行排产? ", { JSUtils.confirm("自动排产将覆盖原排产数据,请谨慎操作,确认对当前数据进行正序排产? ", {
ok: function () { ok: function () {
JSUtils.submitGridsData("result", "HGSC005A", "scheduleEx", true); JSUtils.submitGridsData("result", "HGSC005A", "scheduleAsc", true);
} }
}); });
} }
...@@ -57,7 +57,7 @@ function schedule() { ...@@ -57,7 +57,7 @@ function schedule() {
* 倒序排产 * 倒序排产
*/ */
function schedule() { function schedule() {
JSUtils.confirm("自动排产将覆盖原排产数据,请谨慎操作,确认对当前数据进行排产? ", { JSUtils.confirm("自动排产将覆盖原排产数据,请谨慎操作,确认对当前数据进行倒序排产? ", {
ok: function () { ok: function () {
JSUtils.submitGridsData("result", "HGSC005A", "schedule", true); JSUtils.submitGridsData("result", "HGSC005A", "schedule", true);
} }
......
...@@ -20,8 +20,7 @@ $(function (){ ...@@ -20,8 +20,7 @@ $(function (){
pageSize: 10, pageSize: 10,
pageSizes: [10, 20, 50, 100], pageSizes: [10, 20, 50, 100],
}, },
columns: [ columns: [{
{
field: "operator", field: "operator",
title: "操作", title: "操作",
template: function (item) { template: function (item) {
...@@ -229,7 +228,7 @@ let save = function (btnNode) { ...@@ -229,7 +228,7 @@ let save = function (btnNode) {
if(flag) { if(flag) {
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"保存\"操作? ", { JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"保存\"操作? ", {
ok: function () { ok: function () {
JSUtils.submitGridsData("result", "HGSJ001", "save", true); JSUtils.submitGridsData("result", "HGSJ001", "save", false);
btnNode.attr("disabled", false); btnNode.attr("disabled", false);
} }
}); });
...@@ -274,4 +273,4 @@ function loadChange(grid,e,field) { ...@@ -274,4 +273,4 @@ function loadChange(grid,e,field) {
var td = tr.children("td:eq("+index+")"); var td = tr.children("td:eq("+index+")");
// 触发 td.click 事件, // 触发 td.click 事件,
td.trigger("click"); td.trigger("click");
} }
\ No newline at end of file
<%--
Created by IntelliJ IDEA.
User: 1
Date: 2024/5/6
Time: 9:39
To change this template use File | Settings | File Templates.
--%>
<!DOCTYPE html> <!DOCTYPE html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="EF" tagdir="/WEB-INF/tags/EF" %> <%@ taglib prefix="EF" tagdir="/WEB-INF/tags/EF" %>
<%@ page import="com.baosight.iplat4j.core.web.threadlocal.UserSession" %> <%@ page import="com.baosight.iplat4j.core.web.threadlocal.UserSession" %>
<% <%
String loginName = UserSession.getLoginName(); String loginName = UserSession.getLoginName();
%> %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/> <c:set var="ctx" value="${pageContext.request.contextPath}"/>
<c:set var="loginName" value="<%=loginName%>" /> <c:set var="loginName" value="<%=loginName%>"/>
<EF:EFPage title="工序设置"> <EF:EFPage title="工序设置">
<EF:EFRegion id="inqu" title="查询条件"> <EF:EFRegion id="inqu" title="查询条件">
<div class="row"> <div class="row">
<EF:EFSelect blockId="inqu_status" row="0" ename="factoryCode" cname="公司名称" colWidth="3" filter="contains"> <EF:EFSelect blockId="inqu_status" row="0" ename="factoryCode" cname="公司名称" colWidth="3" filter="contains">
<EF:EFOption label="全部" value=""/> <EF:EFOption label="全部" value=""/>
<EF:EFOptions blockId="roleCompany" textField="companyName" valueField="companyCode"/> <EF:EFOptions blockId="roleCompany" textField="companyName" valueField="companyCode"/>
</EF:EFSelect> </EF:EFSelect>
<EF:EFInput blockId="inqu_status" row="0" ename="processName" cname="工序名称" placeholder="模糊查询" colWidth="3"/> <EF:EFInput blockId="inqu_status" row="0" ename="processName" cname="工序名称" placeholder="模糊查询" colWidth="3"/>
<EF:EFInput blockId="inqu_status" row="0" ename="princName" cname="负责人" placeholder="模糊查询" colWidth="3"/> <EF:EFInput blockId="inqu_status" row="0" ename="princName" cname="负责人" placeholder="模糊查询" colWidth="3"/>
<EF:EFSelect blockId="inqu_status" row="0" ename="status" cname="状态" colWidth="3" filter="contains"> <EF:EFSelect blockId="inqu_status" row="0" ename="status" cname="状态" colWidth="3" filter="contains">
<EF:EFOption label="全部" value=""/> <EF:EFOption label="全部" value=""/>
<EF:EFCodeOption codeName="hpjx.hpjx.status"/> <EF:EFCodeOption codeName="hpjx.hpjx.status"/>
</EF:EFSelect> </EF:EFSelect>
<EF:EFInput blockId="inqu_status" row="0" ename="companyCode" cname="公司编码" type="hidden" colWidth="3"/> <EF:EFInput blockId="inqu_status" row="0" ename="companyCode" cname="公司编码" type="hidden" colWidth="3"/>
</div> </div>
</EF:EFRegion> </EF:EFRegion>
<EF:EFRegion id="result" title="明细信息"> <EF:EFRegion id="result" title="明细信息">
<EF:EFGrid blockId="result" autoDraw="override" isFloat="true"> <EF:EFGrid blockId="result" autoDraw="override" isFloat="true">
<EF:EFColumn ename="id" primaryKey="true" cname="内码" hidden="true"/> <EF:EFColumn ename="id" primaryKey="true" cname="内码" hidden="true"/>
<EF:EFColumn ename="accountCode" cname="企业编码" hidden="true"/> <EF:EFColumn ename="accountCode" cname="企业编码" hidden="true"/>
<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:EFComboColumn ename="factoryCode" cname="公司名称" <EF:EFComboColumn ename="factoryCode" cname="公司名称"
columnTemplate="#=textField#" itemTemplate="#=textField#" columnTemplate="#=textField#" itemTemplate="#=textField#"
textField="textField" valueField="valueField" textField="textField" valueField="valueField"
maxLength="16" width="200" required="true" maxLength="16" width="200" required="true"
align="center" filter="contains" sort="true"> align="center" filter="contains" sort="true">
<EF:EFOptions blockId="roleCompany" textField="companyName" valueField="companyCode"/> <EF:EFOptions blockId="roleCompany" textField="companyName" valueField="companyCode"/>
</EF:EFComboColumn> </EF:EFComboColumn>
<EF:EFColumn ename="factoryName" cname="公司名称" hidden="true"/> <EF:EFColumn ename="factoryName" cname="公司名称" hidden="true"/>
<EF:EFColumn ename="processCode" cname="工序编码" enable="false" width="100" align="center"/> <EF:EFColumn ename="processCode" cname="工序编码" enable="false" width="100" align="center"/>
<EF:EFColumn ename="processName" cname="工序名称" width="120" enable="true" readonly="true" align="center" required="true"/> <EF:EFColumn ename="processName" cname="工序名称" width="120" enable="true" readonly="true" align="center"
<EF:EFColumn ename="unit" cname="单位" width="80" enable="true" readonly="false" align="center"/> required="true"/>
<EF:EFColumn ename="standardJob" cname="标准作业" width="100" enable="true" format="{0:N3}" editType="number" <EF:EFColumn ename="unit" cname="单位" width="80" enable="true" readonly="false" align="center"/>
displayType="0" sort="true" align="right" required="true" <EF:EFColumn ename="standardJob" cname="标准作业" width="100" enable="true" format="{0:N3}" editType="number"
data-regex="/^-?[0-9]{1,15}?$/" maxLength="15" displayType="0" sort="true" align="right" required="true"
data-errorprompt="请输入数字,该值最大可设置15位整数!"/> data-regex="/^-?[0-9]{1,15}?$/" maxLength="15"
<EF:EFColumn ename="standardDays" cname="标准人天" width="100" enable="true" format="{0:N3}" editType="number" data-errorprompt="请输入数字,该值最大可设置15位整数!"/>
displayType="0" sort="true" align="right" <EF:EFColumn ename="standardDays" cname="标准人天" width="100" enable="true" format="{0:N3}" editType="number"
data-regex="/^-?[0-9]{1,15}?$/" maxLength="20" required="true" displayType="0" sort="true" align="right"
data-errorprompt="请输入数字,该值最大可设置15位整数!"/> data-regex="/^-?[0-9]{1,15}?$/" maxLength="20" required="true"
<EF:EFColumn ename="standardNum" cname="标准工序人数" width="100" enable="true" format="{0:N3}" editType="number" data-errorprompt="请输入数字,该值最大可设置15位整数!"/>
displayType="0" sort="true" align="right" <EF:EFColumn ename="standardNum" cname="标准工序人数" width="120" enable="true" format="{0:N3}" editType="number"
data-regex="/^-?[0-9]{1,15}?$/" maxLength="20" required="true" displayType="0" sort="true" align="right"
data-errorprompt="请输入数字,该值最大可设置15位整数!"/> data-regex="/^-?[0-9]{1,15}?$/" maxLength="20" required="true"
<EF:EFComboColumn ename="computeType" cname="计算类型" width="80" enable="true" align="center" required="true"> data-errorprompt="请输入数字,该值最大可设置15位整数!"/>
<EF:EFCodeOption codeName="hggp.hgsj.computeType"/> <EF:EFColumn ename="overlapDay" cname="工序重叠天数" width="120" align="center" required="true"/>
</EF:EFComboColumn> <EF:EFComboColumn ename="computeType" cname="计算类型" width="80" enable="true" align="center" required="true">
<EF:EFColumn ename="costWeight" cname="费用权重" width="100" enable="true" format="{0:N3}" editType="number" <EF:EFCodeOption codeName="hggp.hgsj.computeType"/>
displayType="0" sort="true" align="right" </EF:EFComboColumn>
data-regex="/^-?[0-9]{1,15}([.][0-9]{1,3})?$/" maxLength="15" required="true" <EF:EFColumn ename="costWeight" cname="费用权重" width="100" enable="true" format="{0:N3}" editType="number"
data-errorprompt="请输入数字,该值最大可设置15位整数!"/> displayType="0" sort="true" align="right"
<EF:EFComboColumn ename="princ" cname="负责人" defaultValue="${loginName}" data-regex="/^-?[0-9]{1,15}([.][0-9]{1,3})?$/" maxLength="15" required="true"
columnTemplate="#=textField#" itemTemplate="#=textField#" data-errorprompt="请输入数字,该值最大可设置15位整数!"/>
textField="textField" valueField="valueField" <EF:EFComboColumn ename="princ" cname="负责人" defaultValue="${loginName}"
maxLength="16" width="120" required="true" columnTemplate="#=textField#" itemTemplate="#=textField#"
align="center" filter="contains" sort="true"> textField="textField" valueField="valueField"
<EF:EFOptions blockId="user_block_id" textField="textField" valueField="valueField"/> maxLength="16" width="120" required="true"
</EF:EFComboColumn> align="center" filter="contains" sort="true">
<%--<EF:EFColumn ename="princ" cname="负责人" width="120" enable="true" readonly="false" align="center" required="true"/>--%> <EF:EFOptions blockId="user_block_id" textField="textField" valueField="valueField"/>
<EF:EFComboColumn ename="status" cname="状态" width="80" enable="true" readonly="false" align="center" required="true" defaultValue="1"> </EF:EFComboColumn>
<EF:EFCodeOption codeName="hpjx.hpjx.status"/> <%--<EF:EFColumn ename="princ" cname="负责人" width="120" enable="true" readonly="false" align="center" required="true"/>--%>
</EF:EFComboColumn> <EF:EFComboColumn ename="status" cname="状态" width="80" enable="true" readonly="false" align="center"
<EF:EFColumn cname="创建人" ename="createdName" align="center" width="100" readonly="true" required="false" required="true" defaultValue="1">
enable="false"/> <EF:EFCodeOption codeName="hpjx.hpjx.status"/>
<EF:EFColumn cname="创建时间" ename="createdTime" parseFormats="['yyyyMMddHHmmss']" editType="datetime" </EF:EFComboColumn>
dateFormat="yyyy-MM-dd HH:mm:ss" align="center" width="120" readonly="true" required="false" <EF:EFColumn cname="创建人" ename="createdName" align="center" width="100" readonly="true" required="false"
enable="false"/> enable="false"/>
</EF:EFGrid> <EF:EFColumn cname="创建时间" ename="createdTime" parseFormats="['yyyyMMddHHmmss']" editType="datetime"
</EF:EFRegion> dateFormat="yyyy-MM-dd HH:mm:ss" align="center" width="120" readonly="true" required="false"
enable="false"/>
</EF:EFGrid>
</EF:EFRegion>
</EF:EFPage> </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