Commit b7474cdb by 宋祥

1.组织机构表增加厂区代码字段

parent 42f8e1c7
......@@ -76,6 +76,9 @@
</sql>
<sql id="customCondition">
<isNotEmpty prepend=" AND " property="ids">
ID IN <iterate close=")" open="(" conjunction="," property="ids">#ids[]#</iterate>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventTypes">
INVENT_TYPE IN <iterate close=")" open="(" conjunction="," property="inventTypes">#inventTypes[]#</iterate>
</isNotEmpty>
......
......@@ -12,8 +12,14 @@ import com.baosight.hpjx.hp.pz.domain.HPPZ007;
import com.baosight.hpjx.hp.pz.domain.HPPZ009;
import com.baosight.hpjx.hp.pz.domain.HPPZ011;
import com.baosight.hpjx.util.AssertUtils;
import com.baosight.hpjx.util.MapUtils;
import com.baosight.hpjx.util.ObjectUtils;
import com.baosight.hpjx.util.StringUtils;
import com.baosight.iplat4j.core.data.DaoEPBase;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.collections.CollectionUtils;
import java.math.BigDecimal;
......@@ -23,10 +29,13 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
/**
* @author:songx
* @date:2024/1/16,10:48
*/
@Slf4j
public class HPPZTools {
/**
......@@ -274,14 +283,41 @@ public class HPPZTools {
* @return
*/
public static HPPZ006 get(Long id) {
AssertUtils.isNull(id, "仓库编码不能为空");
AssertUtils.isNull(id, "规格ID不能为空");
Map queryMap = new HashMap();
queryMap.put("id", id);
List<HPPZ006> results = DaoBase.getInstance().query(HPPZ006.QUERY, queryMap);
AssertUtils.isNull(results, String.format("规格[%s]不存在", id));
return results.get(0);
}
/**
* 查询
*
* @param ids
* @return
*/
public static List<HPPZ006> list(List<Long> ids) {
AssertUtils.isNull(ids, "规格ID不能为空");
Map queryMap = new HashMap();
queryMap.put("ids", ids);
return DaoBase.getInstance().query(HPPZ006.QUERY, queryMap);
}
/**
* 查询
*
* @param ids
* @return
*/
public static Map<Long, HPPZ006> map(List<Long> ids) {
List<HPPZ006> results = list(ids);
if (CollectionUtils.isEmpty(results)) {
return null;
}
return results.stream().collect(Collectors.toMap(HPPZ006::getId, item -> item));
}
/**
* 计算单重
*
......@@ -391,6 +427,57 @@ public class HPPZTools {
return newPz006;
}
}
/**
* 设置用户信息
*
* @param inInfo
* @param idName
*/
public static void setSpecInfo(EiInfo inInfo, String idName) {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
if (CollectionUtils.isEmpty(resultRows)) {
return;
}
List<Long> ids = ObjectUtils.listKey(resultRows, idName);
if (CollectionUtils.isEmpty(ids)) {
return;
}
Map<Long, HPPZ006> resultMap = map(ids);
if (MapUtils.isEmpty(resultMap)) {
return;
}
for (Map resultRow : resultRows) {
Long id = MapUtils.getLong(resultRow, idName);
HPPZ006 dbPz006 = resultMap.get(id);
resultRow.put(HPPZ006.FIELD_SPEC, dbPz006 == null ? "" : dbPz006.getSpec());
resultRow.put(HPPZ006.FIELD_LENGTH, dbPz006 == null ? "" : dbPz006.getLength());
resultRow.put(HPPZ006.FIELD_WIDTH, dbPz006 == null ? "" : dbPz006.getWidth());
resultRow.put(HPPZ006.FIELD_THICK, dbPz006 == null ? "" : dbPz006.getThick());
}
}
/**
* 设置规格
*
* @param bean
* @param keyName
*/
public static void setSpecInfo(DaoEPBase bean, String keyName) {
try {
String inventRecordId = BeanUtils.getProperty(bean, keyName);
if (StringUtils.isBlank(inventRecordId)) {
return;
}
HPPZ006 dbPz06 = get(Long.parseLong(inventRecordId));
BeanUtils.setProperty(bean, HPPZ006.FIELD_SPEC, dbPz06.getSpec());
BeanUtils.setProperty(bean, HPPZ006.FIELD_LENGTH, dbPz06.getLength());
BeanUtils.setProperty(bean, HPPZ006.FIELD_WIDTH, dbPz06.getWidth());
BeanUtils.setProperty(bean, HPPZ006.FIELD_THICK, dbPz06.getThick());
} catch (Throwable e) {
log.warn("设置规格失败:{}", e.getMessage(), e);
}
}
}
/**
......
......@@ -65,6 +65,33 @@
<include refid="customCondition"/>
</select>
<!-- 查询父级信息(递归) -->
<select id="queryParent" resultClass="com.baosight.hpjx.hp.xs.domain.Org">
SELECT
T3.ORG_ID as "orgId", T3.ORG_CNAME as "orgCname",
T3.PARENT_ORG_ID as "parentOrgId", T3.ORG_TYPE as "orgType"
FROM (
SELECT
@CODES as CODES,
(SELECT @CODES:=GROUP_CONCAT(PARENT_ORG_ID) FROM IPLAT.TXSOG01 WHERE FIND_IN_SET(ORG_ID, @CODES)
AND COMPANY_CODE = #companyCode#
AND IS_DELETED = 0
) as T1,
@LEVEL:=@LEVEL+1 as level
FROM IPLAT.TXSOG01,
(select @CODES:=#orgId#, @LEVEL:= 0) T4
where @CODES is not null
) T2,
IPLAT.TXSOG01 T3
WHERE 1=1
AND FIND_IN_SET(T3.ORG_ID, T2.CODES)
<isNotEmpty prepend=" AND " property="orgType">
ORG_TYPE = #orgType#
</isNotEmpty>
AND COMPANY_CODE = #companyCode#
ORDER BY T2.LEVEL, T3.ORG_ID
</select>
<!-- 查询组织信息 -->
<select id="queryComboBox" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
SELECT
......@@ -90,31 +117,32 @@
<include refid="order"/>
</select>
<!-- 查询组信息(递归) -->
<!-- 查询子集组信息,包括生产组和下料组(递归) -->
<select id="queryGroupComboBox" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
SELECT
T2.LEVEL AS "level", T3.ORG_ID AS "orgId", T3.ORG_CNAME AS "orgCname"
T2.LEVEL AS "level", T3.ORG_ID AS "orgId", T3.ORG_CNAME AS "orgCname",
T3.FACTORY_CODE AS "factoryCode", T5.FACTORY_NAME AS "factoryName"
FROM (
SELECT
@CODES AS CODES,
(SELECT @CODES := GROUP_CONCAT(ORG_ID)
(SELECT @CODES:=GROUP_CONCAT(ORG_ID)
FROM ${platSchema}.TXSOG01
WHERE FIND_IN_SET(PARENT_ORG_ID, @CODES)
AND COMPANY_CODE = #companyCode#
AND IS_DELETED = 0
) AS T1,
@LEVEL:= @LEVEL+1 AS LEVEL
@LEVEL:=@LEVEL+1 AS LEVEL
FROM ${platSchema}.TXSOG01,
(SELECT @CODES:=#parentOrgId#, @LEVEL:= 0) T4
WHERE @CODES IS NOT NULL
) T2,
${platSchema}.TXSOG01 T3
LEFT JOIN ${platSchema}.TXSOG01 T5 ON T3.FACTORY_CODE = T5.ORG_ID
WHERE 1=1
AND FIND_IN_SET(T3.ORG_ID, T2.CODES)
AND ORG_TYPE IN ('prodGroup', 'cutGroup')
AND T3.ORG_TYPE IN ('prodGroup', 'cutGroup', 'factory')
<isNotEmpty prepend=" AND " property="orgType">
ORG_TYPE = #orgType#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyCode">
COMPANY_CODE = #companyCode#
T3.ORG_TYPE = #orgType#
</isNotEmpty>
ORDER BY T2.LEVEL, T3.ORG_ID
</select>
......
package com.baosight.hpjx.hp.xs.tools;
import com.baosight.hpjx.core.dao.DaoBase;
import com.baosight.hpjx.core.enums.OrgTypeEnum;
import com.baosight.hpjx.hp.xs.domain.Org;
import com.baosight.hpjx.hp.xs.domain.User;
import com.baosight.hpjx.util.AssertUtils;
......@@ -80,6 +81,38 @@ public class HPXSTools {
List<Org> results = DaoBase.getInstance().query("HPXSOrg.query", paramMap);
return CollectionUtils.isEmpty(results) ? null : results.get(0);
}
/**
* 查询
*
* @param orgId
* @return
*/
public static List<Org> queryParent(String orgId) {
AssertUtils.isNull(orgId, "组织ID不能为空");
Map queryMap = new HashMap();
queryMap.put("orgId", orgId);
List<Org> results = DaoBase.getInstance().query("HPXSOrg.queryParent", queryMap);
AssertUtils.isNull(results, String.format("组织[%s]不存在父级信息", orgId));
return results;
}
/**
* 查询所属厂区
*
* @param orgId
* @return
*/
public static Org queryFactory(String orgId) {
AssertUtils.isNull(orgId, "组织ID不能为空");
Map queryMap = new HashMap();
queryMap.put("orgId", orgId);
queryMap.put("orgType", OrgTypeEnum.FACTORY.getCode());
List<Org> results = DaoBase.getInstance().query("HPXSOrg.queryParent", queryMap);
AssertUtils.isNull(results, String.format("组织[%s]不存在厂区信息", orgId));
return results.get(0);
}
}
}
......@@ -7,6 +7,8 @@ import com.baosight.hpjx.core.security.UserSessionUtils;
import com.baosight.hpjx.core.tools.CodeValueTools;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.kc.domain.HPKC010;
import com.baosight.hpjx.hp.xs.domain.Org;
import com.baosight.hpjx.hp.xs.tools.HPXSTools;
import com.baosight.hpjx.util.DateUtils;
import com.baosight.hpjx.util.EiInfoUtils;
import com.baosight.hpjx.util.LogUtils;
......@@ -96,13 +98,23 @@ public class ServiceXSOG0801A extends ServiceEPBase {
// 非管理员组织机构编码前缀增加企业编码 added by songx at 2024-01-15
String companyCode = UserSessionUtils.getCompanyCode();
resultRows.forEach((row) -> {
String orgCode = SequenceGenerator.getNextSequence(HPConstant.SequenceId.ORG_CODE);
row.put("orgId", orgCode);
row.put("orgEname", orgCode);
String orgId = SequenceGenerator.getNextSequence(HPConstant.SequenceId.ORG_CODE);
row.put("orgId", orgId);
row.put("orgEname", orgId);
row.put("companyCode", companyCode);
row.put("establishDate", DateUtils.formatShort(MapUtils.getString(row, "establishDate")));
row.put("parentOrgId", queryRow.get("parentOrgId"));
row.put("recCreator", UserSession.getLoginName());
// 厂区代码
if (OrgTypeEnum.FACTORY.getCode().equals(row.get("orgType"))) {
row.put("factoryCode", orgId);
row.put("factoryName", row.get("orgCname"));
} else {
// 查询所属厂
Org factoryOrg = HPXSTools.XsOrg.queryFactory(queryRow.get("parentOrgId").toString());
row.put("factoryCode", factoryOrg.getOrgId());
row.put("factoryName", factoryOrg.getOrgCname());
}
});
EiInfo call = new EiInfo();
call.set("list", resultRows);
......
......@@ -286,12 +286,14 @@
REC_REVISE_TIME, <!-- 记录修改时刻 -->
ARCHIVE_FLAG, <!-- 归档标记 -->
IS_DELETED, <!-- 逻辑删除(1-已删除|0-正常状态) -->
COMPANY_CODE <!-- 企业编码 -->
COMPANY_CODE, <!-- 企业编码 -->
FACTORY_CODE,
FACTORY_NAME
) VALUES (
#orgId#, #orgEname#, #orgCname#, #orgBriefName#, #orgType#, #parentOrgId#,
#establishDate#, #orgLevel#, #orgNodeType#, #sortIndex#, #recCreator#,
#recCreateTime#, #recRevisor#, #recReviseTime#, #archiveFlag#, #isDeleted#,
#companyCode#
#companyCode#, #factoryCode#, #factoryName#
)
</insert>
......
......@@ -269,6 +269,8 @@ public class ServiceXSOrgManage extends ServiceEPBase {
insertMap.put("archiveFlag", " ");
insertMap.put("isDeleted", "0");
insertMap.put("companyCode", inInfoRowMap.get("companyCode"));
insertMap.put("factoryCode", inInfoRowMap.get("factoryCode"));
insertMap.put("factoryName", inInfoRowMap.get("factoryName"));
if (insertFlag) {
this.dao.insert("XSOG01.insert", insertMap);
} else {
......
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