Commit f093af35 by wasx8023

1.用工管理可以修改

2.组织机构删除的时候清空用工关系
parent 04694bbd
......@@ -278,8 +278,14 @@ public class HPSqlConstant {
*/
public class HPPZ013 {
// 查询
// 修改
public static final String UPDATE = "HPPZ013.update";
// 修改状态
public static final String UPDATE_STATUS = "HPPZ013.updateStatus";
// 清空生产部门
public static final String CLEAR_GROUP = "HPPZ013.clearGroup";
// 清空生产厂区
public static final String CLEAR_FACTORY = "HPPZ013.clearFactory";
}
/**
......
......@@ -106,7 +106,7 @@ public class ServiceHPPZ013 extends ServiceBase {
for (Map resultRow : resultRows) {
HPPZ01301 fPz01301 = new HPPZ01301();
fPz01301.fromMap(resultRow);
AssertUtils.isEmpty(fPz01301.getFactoryCode(), "请选择工厂");
AssertUtils.isEmpty(fPz01301.getFactoryCode(), "请选择厂区");
AssertUtils.isEmpty(fPz01301.getGroupType(), "请选择生产组类型");
AssertUtils.isEmpty(fPz01301.getGroupCode(), "请选择生产组");
AssertUtils.isEmpty(fPz01301.getUserName(), "请输入姓名");
......@@ -195,7 +195,7 @@ public class ServiceHPPZ013 extends ServiceBase {
* @param fPz01301
*/
private void modify(HPPZ01301 fPz01301) {
DaoUtils.update(HPSqlConstant.HPPZ013.UPDATE_STATUS, fPz01301);
DaoUtils.update(HPSqlConstant.HPPZ013.UPDATE, fPz01301);
}
/**
......
......@@ -91,6 +91,8 @@ public class ServiceHPPZ014 extends ServiceBase {
Map queryMap = EiInfoUtils.getFirstRow(inInfo, "main");
String regDate = DateUtils.formatShort(queryMap.get("regDate"));
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 数据校验
this.checkData(resultRows, regDate);
// 写入数据
this.saveData(resultRows, regDate);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
......@@ -102,6 +104,24 @@ public class ServiceHPPZ014 extends ServiceBase {
}
/**
* 校验数据
*
* @param resultRows
* @param regDate
*/
private void checkData(List<Map> resultRows, String regDate) {
AssertUtils.isEmpty(regDate, "登记时间不能为空");
for (Map resultRow : resultRows) {
HPPZ013 fPz013 = new HPPZ013();
fPz013.fromMap(resultRow);
AssertUtils.isEmpty(fPz013.getFactoryCode(), "请选择厂区");
AssertUtils.isEmpty(fPz013.getGroupType(), "请选择生产组类型");
AssertUtils.isEmpty(fPz013.getGroupCode(), "请选择生产组");
}
}
/**
* 保存数据
*
* @param resultRows
......
......@@ -159,6 +159,21 @@
</delete>
<!-- 修改状态 -->
<update id="update">
UPDATE ${hpjxSchema}.T_HPPZ013
SET
STATUS = #status#, <!-- 状态:1-在职,2-离职 -->
FACTORY_CODE = #factoryCode#, <!-- 工厂编码 -->
FACTORY_NAME = #factoryName#, <!-- 工厂名称 -->
GROUP_TYPE = #groupType#, <!-- 部门类型 -->
GROUP_CODE = #groupCode#, <!-- 生产组编码 -->
GROUP_NAME = #groupName#, <!-- 生产组名称 -->
REMARK = #remark#, <!-- 备注 -->
<include refid="updateRevise"/>
WHERE ID = #id#
</update>
<!-- 修改状态 -->
<update id="updateStatus">
UPDATE ${hpjxSchema}.T_HPPZ013
SET
......@@ -168,6 +183,30 @@
WHERE ID = #id#
</update>
<!-- 清空生产部门 -->
<update id="clearGroup">
UPDATE ${hpjxSchema}.T_HPPZ013
SET
GROUP_TYPE = '',
GROUP_CODE = '',
GROUP_NAME = '',
<include refid="updateRevise"/>
WHERE GROUP_CODE = #groupCode#
</update>
<!-- 清空生产厂区 -->
<update id="clearFactory">
UPDATE ${hpjxSchema}.T_HPPZ013
SET
FACTORY_CODE = '',
FACTORY_NAME = '',
GROUP_TYPE = '',
GROUP_CODE = '',
GROUP_NAME = '',
<include refid="updateRevise"/>
WHERE FACTORY_CODE = #factoryCode#
</update>
<select id="queryComboBox" parameterClass="java.util.HashMap"
resultClass="java.util.HashMap">
SELECT DISTINCT
......
......@@ -535,9 +535,13 @@ public class HPPZTools {
}
}
}
/**
* @author:songx
* @date:2024/3/14,20:59
*/
public static class HpPz013 {
public static HPPZ013 get(String userId) {
AssertUtils.isNull(userId, "工人ID不能为空");
Map queryMap = new HashMap();
......@@ -546,6 +550,33 @@ public class HPPZTools {
AssertUtils.isEmpty(results, String.format("工人ID[%s]不存在", userId));
return results.get(0);
}
/**
* 清空生产部门关系
*
* @param orgId
* @return
*/
public static void clearGroup(String orgId) {
AssertUtils.isNull(orgId, "组织机构ID不能为空");
Map queryMap = new HashMap();
queryMap.put("groupCode", orgId);
DaoUtils.update(HPSqlConstant.HPPZ013.CLEAR_GROUP, queryMap);
}
/**
* 清空厂区关系
*
* @param orgId
* @return
*/
public static void clearFactory(String orgId) {
AssertUtils.isNull(orgId, "组织机构ID不能为空");
Map queryMap = new HashMap();
queryMap.put("factoryCode", orgId);
DaoUtils.update(HPSqlConstant.HPPZ013.CLEAR_FACTORY, queryMap);
}
}
/**
......
......@@ -99,6 +99,9 @@
<isEqual prepend=" AND " property="isComplete" compareValue="0">
B.NUM - B.COMPLETE_NUM &gt; 0
</isEqual>
<isEqual prepend=" AND " property="isComplete" compareValue="1">
B.NUM - B.COMPLETE_NUM = 0
</isEqual>
</sql>
<sql id="order">
......
......@@ -21,6 +21,7 @@ import com.baosight.iplat4j.core.util.NumberUtils;
import org.apache.commons.collections.CollectionUtils;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -815,6 +816,39 @@ public class HPSCTools {
return results.stream().collect(Collectors.toMap(HPSC005B::getProdTaskNo, item -> item));
}
/**
* 查询信息
*
* @param factoryCode
* @param isComplete 是否完工
* @return
*/
public static List<HPSC005B> listByFactory(String factoryCode, Integer isComplete) {
if (StringUtils.isEmpty(factoryCode)) {
return null;
}
Map queryMap = new HashMap();
queryMap.put("factoryCode", factoryCode);
queryMap.put("isComplete", isComplete);
return DaoBase.getInstance().query(HPSC005B.QUERY, queryMap);
}
/**
* 查询信息
*
* @param orgNo 生产组
* @param isComplete
* @return
*/
public static List<HPSC005B> listByGroup(String orgNo, Integer isComplete) {
if (StringUtils.isEmpty(orgNo)) {
return null;
}
Map queryMap = new HashMap();
queryMap.put("orgNo", orgNo);
queryMap.put("isComplete", isComplete);
return DaoBase.getInstance().query(HPSC005B.QUERY, queryMap);
}
}
......
package com.baosight.xservices.xs.og.service;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.enums.OrgTypeEnum;
import com.baosight.hpjx.core.security.UserSessionUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.pz.domain.HPPZ009;
import com.baosight.hpjx.hp.pz.tools.HPPZTools;
import com.baosight.hpjx.hp.sc.domain.HPSC005A;
import com.baosight.hpjx.hp.sc.domain.HPSC005B;
import com.baosight.hpjx.hp.sc.tools.HPSCTools;
import com.baosight.hpjx.hp.xs.domain.Org;
import com.baosight.hpjx.hp.xs.tools.HPXSTools;
import com.baosight.hpjx.util.AssertUtils;
import com.baosight.iplat4j.common.ed.domain.TEDCM01;
import com.baosight.iplat4j.core.data.dao.DaoFactory;
import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.ioc.spring.PlatApplicationContext;
import com.baosight.iplat4j.core.log.Logger;
import com.baosight.iplat4j.core.log.LoggerFactory;
......@@ -186,14 +195,22 @@ public class ServiceXSOG0801 extends ServiceBase {
String orgId = (String)inInfo.get("inqu_status-0-parentOrgId");
List deleteList = inInfo.getBlock(EiConstant.resultBlock).getRows();
for(int i = 0; i < deleteList.size(); ++i) {
for (int i = 0; i < deleteList.size(); ++i) {
inInfo.getBlock(EiConstant.resultBlock).getRow(i).put("orgId", orgId);
// 清空组织机构下面人员的工人关系
Org org = HPXSTools.XsOrg.get(orgId);
// 校验是否存在进行中的任务
this.checkExistsTask(org.getOrgId(), org.getOrgCname(), org.getOrgType());
// 清除用工关系
clearHp013(org.getOrgId(), org.getOrgType());
}
call.set("list", inInfo.getBlock(EiConstant.resultBlock).getRows());
call.set(EiConstant.serviceId, "S_XS_91");
EiInfo result = XServiceManager.call(call);
return result;
inInfo = XServiceManager.call(call);
if (inInfo.getStatus() == EiConstant.STATUS_FAILURE) {
throw new PlatException(inInfo.getMsg());
}
return inInfo;
}
public EiInfo queryUserOutOfOrgId(EiInfo inInfo) {
......@@ -341,33 +358,75 @@ public class ServiceXSOG0801 extends ServiceBase {
EiBlock block = inInfo.getBlock(EiConstant.resultBlock);
Map idMap = new HashMap();
int sum = 0;
for(int i = 0; i < block.getRowCount(); ++i) {
String orgId = block.getCell(i, "orgId").toString();
Map orgIdMap = new HashMap();
orgIdMap.put("orgId", orgId);
List orgIdChildList = this.dao.query("XSOG01.queryOrgChild", orgIdMap);
for(int j = 0; j < orgIdChildList.size(); ++j) {
idMap.put("orgId", ((Map)orgIdChildList.get(j)).get("ORG_ID"));
for (int j = 0; j < orgIdChildList.size(); ++j) {
Map childMap = ((Map) orgIdChildList.get(j));
String childOrgId = childMap.get("ORG_ID").toString();
String childOrgName = childMap.get("ORG_CNAME").toString();
String childOrgType = childMap.get("ORG_TYPE").toString();
// 校验是否存在进行中的任务
this.checkExistsTask(childOrgId, childOrgName, childOrgType);
idMap.put("orgId", childOrgId);
idMap.put("recRevisor", UserSession.getLoginName());
idMap.put("recReviseTime", DateUtils.curDateTimeStr14());
this.dao.update("XSOG01.deleteOrg", idMap);
Map memberMap = new HashMap();
memberMap.put("orgId", ((Map)orgIdChildList.get(j)).get("ORG_ID"));
memberMap.put("orgId", ((Map) orgIdChildList.get(j)).get("ORG_ID"));
this.dao.delete("XSOG02.deleteRelationByOrgId", memberMap);
// 清除用工关系
clearHp013(childOrgId, childOrgType);
++sum;
}
}
inInfo.setMsg("删除[" + sum + "]条记录成功");
return inInfo;
}
/**
* 进行中的生产任务
*
* @param orgId 组织机构
* @param orgName
* @param orgType 组织类型
*/
private void checkExistsTask(String orgId, String orgName, String orgType) {
if (OrgTypeEnum.FACTORY.getCode().equals(orgType)) {
List<HPSC005B> dbSc005s = HPSCTools.HpSc005b.listByFactory(orgId, CommonConstant.YesNo.NO_0);
AssertUtils.isNotEmpty(dbSc005s, String.format("厂区【%s】已存在进行中的任务不能删除", orgName));
dbSc005s = HPSCTools.HpSc005b.listByFactory(orgId, CommonConstant.YesNo.YES_1);
AssertUtils.isNotEmpty(dbSc005s, String.format("厂区【%s】存在历史完成任务,删除将影响数据展示", orgName));
} else if (OrgTypeEnum.PROD_GROUP.getCode().equals(orgType)
|| OrgTypeEnum.CUT_GROUP.getCode().equals(orgType)) {
List<HPSC005B> dbSc005s = HPSCTools.HpSc005b.listByGroup(orgId, CommonConstant.YesNo.NO_0);
AssertUtils.isNotEmpty(dbSc005s, String.format("生产部门【%s】已存在进行中的任务不能删除", orgName));
dbSc005s = HPSCTools.HpSc005b.listByGroup(orgId, CommonConstant.YesNo.YES_1);
AssertUtils.isNotEmpty(dbSc005s, String.format("生产部门【%s】存在历史完成任务,删除将影响数据展示", orgName));
}
}
/**
* 清空用工关系
*
* @param orgId 组织机构
* @param orgType 组织类型
*/
private void clearHp013(String orgId, String orgType) {
if (OrgTypeEnum.FACTORY.getCode().equals(orgType)) {
HPPZTools.HpPz013.clearFactory(orgId);
} else if (OrgTypeEnum.PROD_GROUP.getCode().equals(orgType)
|| OrgTypeEnum.CUT_GROUP.getCode().equals(orgType)) {
HPPZTools.HpPz013.clearGroup(orgId);
}
}
public EiInfo updateTree(EiInfo inInfo) {
new EiInfo();
String orgId = (String)inInfo.getCell("result", 0, "orgId");
String parentOrgType = (String)inInfo.getCell("result", 0, "parentOrgId");
String orgId = (String) inInfo.getCell("result", 0, "orgId");
String parentOrgType = (String) inInfo.getCell("result", 0, "parentOrgId");
Map map = new HashMap();
map.put("orgId", orgId);
map.put("parentOrgType", parentOrgType);
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="XSOG01">
<!--组织机构所有子节点树查询-->
<select id="queryOrgChild" resultClass="java.util.HashMap">
SELECT PARENT_ORG_ID, ORG_ID,ORG_ENAME,ORG_CNAME,ORG_TYPE FROM ${platSchema}.TXSOG01 WHERE FIND_IN_SET(ORG_ID,${platSchema}.getChildrenOrg(#orgId#)) AND IS_DELETED = '0';
</select>
<!--根据组织机构编码 获取所有父节点的组织机构信息。包括本身-->
<select id="queryOrgByOrgEnameAndLevel" parameterClass="java.util.HashMap"
resultClass="java.util.HashMap">
SELECT org_id as "orgId",
org_ename as "orgEname",
org_cname as "orgCname",
org_type as "orgType",
sort_index as "sortIndex",
parent_org_id as "parentOrgId"
from ${platSchema}.txsog01
where FIND_IN_SET(org_id,${platSchema}.queryParentOrgs(#orgId#)) AND IS_DELETED = '0';
</select>
<!--根据组织机构编码向上递归组织机构 返回组织结构Id、父组织机构Id、由下向上的层级数-->
<sql id="getRecursiveUpOrg">
SELECT
@a as orgId,
(SELECT org_ename FROM ${platSchema}.TXSOG01 where org_id = @a) as orgEname,
(SELECT org_Cname FROM ${platSchema}.TXSOG01 where org_id = @a) as orgCname,
(SELECT org_type FROM ${platSchema}.TXSOG01 where org_id = @a) as orgType,
(SELECT @a:=parent_org_id from ${platSchema}.txsog01 where org_id = @a limit 0,1) as parentOrgId,
@b := @b+1 as lv
FROM (SELECT @a:= (SELECT ORG_ID FROM ${platSchema}.txsog01 WHERE 1=1
<isNotEmpty prepend=" AND " property="orgId">
ORG_ID = #orgId#
</isNotEmpty>
<isEmpty prepend=" " property="orgId">
<isNotEmpty prepend=" AND " property="orgEname">
ORG_ENAME = #orgEname#
</isNotEmpty>
</isEmpty>
AND IS_DELETED = '0' limit 0,1),@b:=0) vars,txsog01 t
where @a <![CDATA[<>]]> ''
</sql>
<!--根据组织机构代码获取匹配特定类型的父组织机构-->
<select id="getParentOrgByOrgEnameAndOrgType" parameterClass="java.util.HashMap"
resultClass="java.util.HashMap">
select * FROM (<include refid="getRecursiveUpOrg"/>) a Where a.orgEname <![CDATA[<>]]> #orgEname# AND a.orgType = #orgType#
</select>
<!--向上递归查询 到组织机构类型不等于company-->
<select id="queryOneLevelOrgByOrgId" parameterClass="java.util.HashMap"
resultClass="java.util.HashMap">
SELECT org_id as "orgId",org_ename as "orgEname",org_cname as "orgCname" from ${platSchema}.txsog01
where FIND_IN_SET(org_id,${platSchema}.queryParentOrg(#orgId#,'company')) AND org_Id != 'root';
</select>
</sqlMap>
\ No newline at end of file
......@@ -264,10 +264,12 @@
<!--组织机构所有子节点树查询-->
<select id="queryOrgChild" resultClass="java.util.HashMap">
WITH report(PARENT_ORG_ID, ORG_ID,ORG_ENAME,ORG_CNAME) AS (
SELECT PARENT_ORG_ID, ORG_ID,ORG_ENAME,ORG_CNAME FROM ${platSchema}.TXSOG01 WHERE ORG_ID = #orgId# and is_deleted = '0'
UNION ALL
SELECT b.PARENT_ORG_ID, b.ORG_ID,b.ORG_ENAME,b.ORG_CNAME FROM report a, ${platSchema}.TXSOG01 b WHERE b.PARENT_ORG_ID = a.ORG_ID and b.is_deleted = '0'
WITH report(PARENT_ORG_ID, ORG_ID,ORG_ENAME,ORG_CNAME, ORG_TYPE) AS (
SELECT PARENT_ORG_ID, ORG_ID,ORG_ENAME,ORG_CNAME,ORG_TYPE FROM ${platSchema}.TXSOG01
WHERE ORG_ID = #orgId# and is_deleted = '0'
UNION ALL
SELECT b.PARENT_ORG_ID, b.ORG_ID,b.ORG_ENAME,b.ORG_CNAME,b.ORG_TYPE FROM report a, ${platSchema}.TXSOG01 b
WHERE b.PARENT_ORG_ID = a.ORG_ID and b.is_deleted = '0'
)
SELECT * FROM report
</select>
......
......@@ -97,7 +97,7 @@ let save = function () {
for (let i = 0; i < rows.length; i++) {
let item = rows[i];
if (isBlank(item['factoryCode'])) {
message("选中的第" + (i + 1) + "行\"工厂\",不能为空!");
message("选中的第" + (i + 1) + "行\"厂区\",不能为空!");
return;
}
if (isBlank(item['groupType'])) {
......@@ -153,6 +153,21 @@ let checkIn = function () {
message("请选择数据");
return;
}
for (let i = 0; i < rows.length; i++) {
let item = rows[i];
if (isBlank(item['factoryCode'])) {
message("选中的第" + (i + 1) + "行\"厂区\",不能为空!");
return;
}
if (isBlank(item['groupType'])) {
message("选中的第" + (i + 1) + "行\"部门类型\",不能为空!");
return;
}
if (isBlank(item['groupCode'])) {
message("选中的第" + (i + 1) + "行\"生产部门\",不能为空!");
return;
}
}
JSColorbox.open({
href: "HPPZ013A?methodName=initLoad",
title: "<div style='text-align: center;'>用工登记</div>",
......
......@@ -42,14 +42,13 @@
<EF:EFColumn ename="userId" cname="工号" enable="false" width="120" align="center"/>
<EF:EFColumn ename="userName" cname="姓名" width="120" align="center" required="true" readonly="true"/>
<EF:EFComboColumn ename="factoryCode" cname="厂区" width="110" align="center" defaultValue="" required="true"
filter="contains" readonly="true">
filter="contains">
<EF:EFOptions blockId="factory_record_block_id" valueField="valueField" textField="textField"/>
</EF:EFComboColumn>
<EF:EFComboColumn ename="groupType" cname="部门类型" width="80" align="center" required="true"
readonly="true">
<EF:EFComboColumn ename="groupType" cname="部门类型" width="80" align="center" required="true">
<EF:EFCodeOption codeName="xs.og.orgType" condition="ITEM_CODE IN ('prodGroup', 'cutGroup')"/>
</EF:EFComboColumn>
<EF:EFColumn ename="groupCode" cname="生产部门" width="120" align="center" required="true" readonly="true"/>
<EF:EFColumn ename="groupCode" cname="生产部门" width="120" align="center" required="true"/>
<EF:EFComboColumn ename="gender" cname="性别" width="80" align="center" required="true" readonly="true"
valueField="valueField" textField="textField">
<EF:EFCodeOption codeName="xservices.xs.sex"/>
......
......@@ -42,13 +42,15 @@
<EF:EFColumn ename="regDate" cname="登记日期" enable="false" width="100" align="center"
editType="date" dateFormat="yyyy-MM-dd" parseFormats="['yyyyMMdd']"/>
<EF:EFColumn ename="userId" cname="工号" enable="false" width="120" align="center"/>
<EF:EFComboColumn ename="factoryCode" cname="工厂" enable="false" width="110" align="center">
<EF:EFColumn ename="factoryName" cname="厂区" enable="false" width="120" align="center"/>
<EF:EFComboColumn ename="factoryCode" cname="厂区" enable="false" width="110" align="center" hidden="true">
<EF:EFOptions blockId="factory_record_block_id" valueField="valueField" textField="textField"/>
</EF:EFComboColumn>
<EF:EFComboColumn ename="groupType" cname="部门类型" enable="false" width="80" align="center">
<EF:EFCodeOption codeName="xs.og.orgType" condition="ITEM_CODE IN ('prodGroup', 'cutGroup')"/>
</EF:EFComboColumn>
<EF:EFComboColumn ename="groupCode" cname="生产部门" enable="false" width="110" align="center">
<EF:EFColumn ename="groupName" cname="生产部门" enable="false" width="120" align="center"/>
<EF:EFComboColumn ename="groupCode" cname="生产部门" enable="false" width="110" align="center" hidden="true">
<EF:EFOptions blockId="group_record_block_id" valueField="valueField" textField="textField"/>
</EF:EFComboColumn>
<EF:EFColumn ename="userName" cname="姓名" enable="false" width="120" align="center"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment