Commit 25913320 by 宋祥

1.组织机构调整,第一级只能是厂区

parent e7740ae1
package com.baosight.hpjx.core.constant;
/**
* @author:songx
* @date:2024/3/1,17:36
*/
public class CodesetConstant {
/**
* 组织机构
*
* @author:songx
* @date:2024/3/1,17:36
*/
public static class XsOg {
// 组织机构类型
public static final String ORG_TYPE = "xs.og.orgType";
}
}
......@@ -54,6 +54,8 @@ public class CommonConstant {
public static final String PROD_ORDER_NO = "prodOrderNo";
// 生产订单号2
public static final String PRODUCTTION_ORDER_NO = "productionOrderNo";
// ROOT
public static final String ROOT = "root";
}
}
package com.baosight.hpjx.core.enums;
/**
* @author:songx
* @date:2024/3/1,17:29
*/
public enum OrgTypeEnum {
FACTORY("factory", "厂区"),
DEPT("dept", "部门"),
PROD_GROUP("prodGroup", "生产组"),
CUT_GROUP("cutGroup", "下料组"),
;
private String code;
private String value;
OrgTypeEnum(String code, String value) {
this.code = code;
this.value = value;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
package com.baosight.hpjx.core.tools;
import com.baosight.hpjx.util.StringUtils;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.soa.XServiceManager;
import java.util.List;
/**
* @author:songx
* @date:2023/4/13,14:38
*/
public class CodeValueTools {
/**
* getCodeValueList.
*
* @param codesetCode
* @return
*/
public static List getCodeValues(String codesetCode) {
return getCodeValues(codesetCode, null);
}
/**
* getCodeValueList.
*
* @param codesetCode
* @param condition
* @return
*/
public static List getCodeValues(String codesetCode, String condition) {
EiInfo callInfo = new EiInfo();
callInfo.set(EiConstant.serviceId, "S_ED_02");
callInfo.set("codeset", codesetCode);
if (StringUtils.isNotBlank(condition)) {
callInfo.set("condition", condition);
}
return (List) XServiceManager.call(callInfo).get("list");
}
}
......@@ -14,6 +14,8 @@ public class HPConstant {
*/
public class SequenceId {
// 组织机构编码
public static final String ORG_CODE = "ORG_CODE";
// 组编码
public static final String GROUP_CODE = "GROUP_CODE";
// 厂区编码
......
package com.baosight.xservices.xs.og.service;
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.iplat4j.common.ed.domain.TEDCM01;
......@@ -16,6 +17,7 @@ import com.baosight.iplat4j.core.service.soa.XServiceManager;
import com.baosight.iplat4j.core.util.DateUtils;
import com.baosight.iplat4j.core.web.threadlocal.UserSession;
import com.baosight.iplat4j.ed.util.AdminUtil;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import com.baosight.xservices.xs.domain.XS01;
import com.baosight.xservices.xs.domain.XS02;
import com.baosight.xservices.xs.og.domain.XSOG01;
......@@ -260,14 +262,15 @@ public class ServiceXSOG0801 extends ServiceBase {
}
// 非管理员组织机构编码前缀增加企业编码 added by songx at 2024-01-15
String companyCode = UserSessionUtils.getCompanyCode();
HPPZ009 dbPz009 = StringUtils.isBlank(companyCode) ? null : HPPZTools.HpPz009.getByCode(companyCode);
final String companyPrefix = dbPz009 == null ? "" : "[" + dbPz009.getLoginPrefix() + "]";
// HPPZ009 dbPz009 = StringUtils.isBlank(companyCode) ? null : HPPZTools.HpPz009.getByCode(companyCode);
// final String companyPrefix = dbPz009 == null ? "" : "[" + dbPz009.getLoginPrefix() + "]";
String orgCode = SequenceGenerator.getNextSequence(HPConstant.SequenceId.ORG_CODE);
resultBlock = inInfo.getBlock(EiConstant.resultBlock);
List rows = resultBlock.getRows();
rows.forEach((m) -> {
Map row = (Map) m;
row.put("orgId", companyPrefix + inInfo.get("result2-0-orgEname"));
row.put("orgEname", companyPrefix + row.get("orgEname"));
row.put("orgId", orgCode);
row.put("orgEname", orgCode);
row.put("companyCode", companyCode);
row.put("parentOrgId", inInfo.get("inqu_status2-0-parentOrgId"));
row.put("recCreator", UserSession.getLoginName());
......
package com.baosight.xservices.xs.og.service;
import com.baosight.hpjx.core.constant.CodesetConstant;
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.core.tools.CodeValueTools;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.kc.domain.HPKC010;
import com.baosight.hpjx.util.DateUtils;
import com.baosight.hpjx.util.EiInfoUtils;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.hpjx.util.MapUtils;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import com.baosight.iplat4j.core.service.soa.XServiceManager;
import com.baosight.iplat4j.core.web.threadlocal.UserSession;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import com.baosight.xservices.xs.og.domain.XSOG01;
import com.baosight.xservices.xs.util.LoginUserDetails;
import java.util.List;
import java.util.Map;
/**
* 新增组织机构
*
* @author:songx
* @date:2022/7/11,11:08
*/
public class ServiceXSOG0801A extends ServiceEPBase {
/**
* 初始化
*
* @param inInfo
* @return
*/
@Override
public EiInfo initLoad(EiInfo inInfo) {
try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
String parentOrgId = MapUtils.getString(queryMap, "parentOrgId");
String condition;
if (CommonConstant.Field.ROOT.equals(parentOrgId)) {
condition = String.format(" ITEM_CODE = '%s'", OrgTypeEnum.FACTORY.getCode());
} else {
condition = String.format(" ITEM_CODE IN ('%s', '%s', '%s')", OrgTypeEnum.DEPT.getCode(),
OrgTypeEnum.PROD_GROUP.getCode(), OrgTypeEnum.CUT_GROUP.getCode());
}
List<Map> orgTypes = CodeValueTools.getCodeValues(CodesetConstant.XsOg.ORG_TYPE, condition);
inInfo.addBlock("orgTypeBlock").addRows(orgTypes);
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HPKC010().eiMetadata);
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
return inInfo;
}
/**
* 查询数据列表
*
* @param inInfo
* @return
*/
@Override
public EiInfo query(EiInfo inInfo) {
try {
Map queryRow = EiInfoUtils.getFirstRow(inInfo);
String parentOrgId = MapUtils.getString(queryRow, "parentOrgId");
if ("".equals(parentOrgId)) {
return inInfo;
}
// 非管理员仅查询所属企业用户 added by songx at 2024-01-16
if (!LoginUserDetails.isUserAdmin(UserSessionUtils.getLoginName())) {
queryRow.put("companyCode", UserSessionUtils.getCompanyCode());
}
inInfo = super.query(inInfo, "XSOG01.query", new XSOG01());
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
}
return inInfo;
}
/**
* 保存
*
* @param inInfo
* @return
*/
public EiInfo save(EiInfo inInfo) {
try {
Map queryRow = EiInfoUtils.getFirstRow(inInfo);
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 非管理员组织机构编码前缀增加企业编码 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);
row.put("companyCode", companyCode);
row.put("establishDate", DateUtils.formatShort(MapUtils.getString(row, "establishDate")));
row.put("parentOrgId", queryRow.get("parentOrgId"));
row.put("recCreator", UserSession.getLoginName());
});
EiInfo call = new EiInfo();
call.set("list", resultRows);
call.set(EiConstant.serviceId, "S_XS_87");
XServiceManager.call(call);
inInfo = this.query(inInfo);
inInfo.setMsg("新增成功");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "新增组织机构失败");
}
return inInfo;
}
}
......@@ -483,13 +483,22 @@ $(function () {
IPLAT.alert("请在组织机构树选择任意节点后新增组织机构")
return
}
$("#inqu_status2-0-parentOrgId").val(parentId)
// $("#inqu_status2-0-parentOrgId").val(parentId)
// $("#inqu_status2-0-parentOrgEname").val(parentId)
$("#inqu_status2-0-orgEname").val("")
$("#inqu_status2-0-orgCname").val("")
IPLAT.EFSelect.value($("#inqu_status2-0-orgType"), "")
result2Grid.dataSource.page(1)
$("#insertOrgWindow").data("kendoWindow").open();
// $("#inqu_status2-0-orgEname").val("")
// $("#inqu_status2-0-orgCname").val("")
// IPLAT.EFSelect.value($("#inqu_status2-0-orgType"), "")
// result2Grid.dataSource.page(1)
// $("#insertOrgWindow").data("kendoWindow").open();
let params = "&inqu_status-0-parentOrgId=" + parentId
+ "&inqu_status-0-parentOrgEname=" + parentId;
JSColorbox.open({
href: "XSOG0801A?methodName=initLoad" + params,
title: "<div style='text-align: center;'>新增子组织机构</div>",
width: "70%",
height: "70%",
callbackName: addCallback
});
})
/**
......@@ -767,43 +776,25 @@ $(function () {
}
},
"result2": {
columns: [{
field: "establishDate",
attributes: {
class: "i-input-readonly"
}
}],
onSuccess: (e) => {
if (e.type === "create") {
setTimeout(() => {
const selectTreeNode = (tree, treeOrgId) => {
if (!tree || treeOrgId == null) {
return
}
setTimeout(() => {
let barDataItem = tree.dataSource.get(treeOrgId);
if (barDataItem) {
let barElement = tree.findByUid(barDataItem.uid);
// 刷新完成后选中对应的树节点
tree.select(barElement);
} else {
selectTreeNode(tree, treeOrgId)
}
}, 100)
}
// 刷新树节点
const tree = $("#categoryTree").data("kendoTreeView");
const treeOrgId = $("#inqu_status2-0-parentOrgId").val()
tree.reload(treeOrgId)
expandTreeNode(tree, treeOrgId)
// tree.expandPath(treeOrgId)
// 展开成功后选中对应的树节点
selectTreeNode(tree, treeOrgId);
}, 500)
refreshTree();
}
},
},
"result3": {
columns: [{
field: "establishDate",
attributes: {
class: "i-input-readonly"
}
}],
onSuccess: (e) => {
if (e.type === "update") {
setTimeout(() => {
......@@ -912,10 +903,49 @@ $(function () {
});
let movedUser;
/**
* 新增组织机构回调
*/
let addCallback = function (parentOrgId) {
// 回填父级ID
$("#inqu_status2-0-parentOrgId").val(parentOrgId);
refreshTree();
}
let splitter;
/**
* 刷新树
*/
let refreshTree = function () {
setTimeout(() => {
const selectTreeNode = (tree, treeOrgId) => {
if (!tree || treeOrgId == null) {
return
}
setTimeout(() => {
let barDataItem = tree.dataSource.get(treeOrgId);
if (barDataItem) {
let barElement = tree.findByUid(barDataItem.uid);
// 刷新完成后选中对应的树节点
tree.select(barElement);
} else {
selectTreeNode(tree, treeOrgId)
}
}, 100)
}
// 刷新树节点
const tree = $("#categoryTree").data("kendoTreeView");
const treeOrgId = $("#inqu_status2-0-parentOrgId").val()
tree.reload(treeOrgId)
expandTreeNode(tree, treeOrgId)
// tree.expandPath(treeOrgId)
// 展开成功后选中对应的树节点
selectTreeNode(tree, treeOrgId);
}, 500);
}
let movedUser;
let splitter;
/**
* 扩展信息查看
* @param e
......
......@@ -134,7 +134,6 @@
</div>
<div id="menu" style="margin-top: 12px; margin-bottom: 8px">
<EF:EFTree bindId="categoryTree" ename="tree_name" textField="text" valueField="label"
hasChildren="leaf" pid="parent_id"
serviceName="XSOG0800" methodName="query">
......@@ -146,8 +145,7 @@
<span style="font-size: 16px; width: 16px; vertical-align: middle;" class="fa fa-plus"></span>新增
</li>
<li data-type="delete" id="isDel">
<span style="font-size: 16px; width: 16px; vertical-align: middle;"
class="fa fa-minus-circle"></span>删除
<span style="font-size: 16px; width: 16px; vertical-align: middle;" class="fa fa-minus-circle"></span>删除
</li>
<li data-type="edit" id="isEdit">
<span style="font-size: 16px; width: 16px; vertical-align: middle;" class="fa fa-pencil"></span>编辑
......@@ -265,7 +263,7 @@
<div class="row">
<EF:EFInput ename="inqu_status2-0-parentOrgId" cname="上级组织Id" type="hidden"/>
<EF:EFInput ename="inqu_status2-0-parentOrgEname" cname="上级组织编码" type="hidden"/>
<EF:EFInput ename="inqu_status2-0-orgEname" cname="组织编码"/>
<EF:EFInput ename="inqu_status2-0-orgEname" cname="组织编码" type="hidden"/>
<EF:EFInput ename="inqu_status2-0-orgCname" cname="组织名称"/>
<%--这里注册成小代码,下拉查询--%>
<EF:EFSelect cname="组织类型" optionLabel="全部" blockId="inqu_status2" ename="orgType" row="0">
......@@ -279,9 +277,9 @@
insertMethod="insertOrgByParentId"
>
<EF:EFColumn ename="orgId" cname="组织ID" hidden="true"/> <%--隐藏--%>
<EF:EFColumn ename="orgEname" cname="组织编码" required="true" readonly="true" locked="true"/>
<EF:EFColumn ename="orgEname" cname="组织编码" readonly="true" hidden="true"/>
<EF:EFColumn ename="orgCname" cname="组织名称" required="true" locked="true"/>
<EF:EFColumn ename="orgBriefName" cname="组织别名"/>
<EF:EFColumn ename="orgBriefName" cname="组织别名" hidden="true"/>
<EF:EFComboColumn ename="orgType" cname="组织类型" required="true" textField="label" valueField="value">
<EF:EFCodeOption codeName="xs.og.orgType" textField="label" valueField="value"/>
</EF:EFComboColumn>
......@@ -290,7 +288,7 @@
<EF:EFColumn ename="establishDate" cname="成立时间" required="true" width="170" parseFormats="['yyyyMMdd']"
editType="date"
dateFormat="yyyy-MM-dd" align="center"/>
<EF:EFColumn ename="orgLevel" cname="组织级别" align="center"/>
<EF:EFColumn ename="orgLevel" cname="组织级别" align="center" hidden="true"/>
<EF:EFColumn ename="sortIndex" cname="排序" align="center"/>
</EF:EFGrid>
</EF:EFRegion>
......@@ -305,22 +303,19 @@
</div>
<EF:EFRegion id="result3Region" title="子组织机构">
<EF:EFGrid blockId="result3" autoBind="false" autoDraw="false" checkMode="multiple, row"
queryMethod="queryOrgById"
updateMethod="updateOrgById"
>
queryMethod="queryOrgById" updateMethod="updateOrgById">
<EF:EFColumn ename="orgId" cname="组织ID" hidden="true"/> <%--隐藏--%>
<EF:EFColumn ename="orgEname" cname="组织编码" required="true" readonly="true" locked="true"/>
<EF:EFColumn ename="orgCname" cname="组织名称" required="true" locked="true"/>
<EF:EFColumn ename="orgBriefName" cname="组织别名"/>
<EF:EFComboColumn ename="orgType" cname="组织类型" required="true" textField="label" valueField="value">
<EF:EFColumn ename="orgEname" cname="组织编码" readonly="true" locked="true" hidden="true"/>
<EF:EFColumn ename="orgCname" cname="组织名称" locked="true" required="true" />
<EF:EFColumn ename="orgBriefName" cname="组织别名" hidden="true"/>
<EF:EFComboColumn ename="orgType" cname="组织类型" align="center" readonly="true">
<EF:EFCodeOption codeName="xs.og.orgType" textField="label" valueField="value"/>
</EF:EFComboColumn>
<EF:EFColumn ename="orgNodeType" cname="节点类型" hidden="true" defaultValue="2"/> <%--隐藏 默认值为2--%>
<EF:EFColumn ename="parentOrgId" cname="上级组织编码" readonly="true" hidden="true"/> <%--隐藏--%>
<EF:EFColumn ename="establishDate" cname="成立时间" required="true" width="170" parseFormats="['yyyyMMdd']"
editType="date"
dateFormat="yyyy-MM-dd" align="center"/>
<EF:EFColumn ename="orgLevel" cname="组织级别" align="center"/>
editType="date" dateFormat="yyyy-MM-dd" align="center"/>
<EF:EFColumn ename="orgLevel" cname="组织级别" align="center" hidden="true"/>
<EF:EFColumn ename="sortIndex" cname="排序" align="center"/>
</EF:EFGrid>
</EF:EFRegion>
......
$(function () {
IPLATUI.EFGrid = {
"result": {
columns: [],
onSave: function (e) {
// 阻止后台保存请求,使用自定义保存
e.preventDefault();
save();
}
}
};
$("#ef_form_head").hide();
// 查询
$("#QUERY").on("click", query);
});
/**
* 页面加载时执行
*/
$(window).load(function () {
// 初始化查询
query();
});
/**
* 查询
*/
var query = function (e) {
resultGrid.dataSource.page(1);
};
/**
* 选择库存
*/
let save = function () {
let rows = resultGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据")
return;
}
for (let i = 0; i < rows.length; i++) {
let orgCname = rows[i]['orgCname'];
if (isBlank(orgCname)) {
message("组织机构名称不能为空");
return;
}
let orgType = rows[i]['orgType'];
if (isBlank(orgType)) {
message("组织类型不能为空");
return;
}
let establishDate = rows[i]['establishDate'];
if (isBlank(establishDate)) {
message("成立时间不能为空");
return;
}
}
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"保存\"操作? ", {
ok: function () {
JSUtils.submitGridsData("result", "XSOG0801A", "save", true, function (e) {
var status = e.getStatus();
if (status !== -1) {
let parentOrgId = $("#inqu_status-0-parentOrgId").val();
parent.JSColorbox.setValueCallback(parentOrgId);
}
});
}
});
}
<!DOCTYPE html>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="EF" tagdir="/WEB-INF/tags/EF" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<EF:EFPage title="新增组织机构">
<EF:EFRegion id="inqu" title="查询条件">
<div class="row">
<EF:EFInput cname="上级组织Id" blockId="inqu_status" ename="parentOrgId" row="0" type="hidden"/>
<EF:EFInput cname="上级组织编码" blockId="inqu_status" ename="parentOrgEname" row="0" type="hidden"/>
<EF:EFInput cname="组织编码" blockId="inqu_status" ename="orgEname" row="0" type="hidden"/>
<EF:EFInput cname="组织名称" blockId="inqu_status" ename="orgCname" row="0"/>
<EF:EFSelect cname="组织类型" blockId="inqu_status" ename="orgType" row="0" optionLabel="全部">
<EF:EFOptions blockId="orgTypeBlock" textField="label" valueField="value"/>
</EF:EFSelect>
</div>
</EF:EFRegion>
<EF:EFRegion id="result" title="子组织机构">
<EF:EFGrid blockId="result" autoBind="false" autoDraw="false" checkMode="multiple,row" readonly="true">
<EF:EFColumn ename="orgId" cname="组织ID" hidden="true"/>
<EF:EFColumn ename="orgEname" cname="组织编码" readonly="true" hidden="true"/>
<EF:EFColumn ename="orgCname" cname="组织名称" required="true" locked="true"/>
<EF:EFColumn ename="orgBriefName" cname="组织别名" hidden="true"/>
<EF:EFComboColumn ename="orgType" cname="组织类型" required="true" textField="label" valueField="value">
<EF:EFOptions blockId="orgTypeBlock" textField="label" valueField="value"/>
</EF:EFComboColumn>
<EF:EFColumn ename="orgNodeType" cname="节点类型" hidden="true" defaultValue="2"/> <%--隐藏 默认值为2--%>
<EF:EFColumn ename="parentOrgId" cname="上级组织编码" readonly="true" hidden="true"/> <%--隐藏--%>
<EF:EFColumn ename="establishDate" cname="成立时间" required="true" width="170" parseFormats="['yyyyMMdd']"
editType="date" dateFormat="yyyy-MM-dd" align="center"/>
<EF:EFColumn ename="orgLevel" cname="组织级别" align="center" hidden="true"/>
<EF:EFColumn ename="sortIndex" cname="排序" align="center"/>
</EF:EFGrid>
</EF:EFRegion>
</EF:EFPage>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment