Commit de3c1c84 by 宋祥

1.组织机构编辑可修改组织类型等

parent de1c37a0
......@@ -13,6 +13,7 @@ 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.hpjx.util.StringUtils;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
......@@ -22,6 +23,10 @@ import com.baosight.iplat4j.ed.util.SequenceGenerator;
import com.baosight.xservices.xs.og.domain.XSOG01;
import com.baosight.xservices.xs.util.LoginUserDetails;
import org.apache.commons.collections.CollectionUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -97,8 +102,14 @@ public class ServiceXSOG0801A extends ServiceEPBase {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 非管理员组织机构编码前缀增加企业编码 added by songx at 2024-01-15
String companyCode = UserSessionUtils.getCompanyCode();
resultRows.forEach((row) -> {
String orgId = SequenceGenerator.getNextSequence(HPConstant.SequenceId.ORG_CODE);
List<Map> newRows = new ArrayList<>();
for (Map row : resultRows) {
// 已存在的数据跳过
String orgId = MapUtils.getString(row, "orgId");
if (StringUtils.isNotBlank(orgId)) {
continue;
}
orgId = SequenceGenerator.getNextSequence(HPConstant.SequenceId.ORG_CODE);
row.put("orgId", orgId);
row.put("orgEname", orgId);
row.put("companyCode", companyCode);
......@@ -115,9 +126,15 @@ public class ServiceXSOG0801A extends ServiceEPBase {
row.put("factoryCode", factoryOrg.getOrgId());
row.put("factoryName", factoryOrg.getOrgCname());
}
});
newRows.add(row);
}
if (CollectionUtils.isEmpty(newRows)) {
inInfo.setStatus(EiConstant.STATUS_FAILURE);
inInfo.setMsg("请新增一行输入需要新增的数据");
return inInfo;
}
EiInfo call = new EiInfo();
call.set("list", resultRows);
call.set("list", newRows);
call.set(EiConstant.serviceId, "S_XS_87");
XServiceManager.call(call);
inInfo = this.query(inInfo);
......
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.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;
import com.baosight.hpjx.util.MapUtils;
import com.baosight.hpjx.util.StringUtils;
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.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 org.apache.commons.collections.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 新增组织机构
*
* @author:songx
* @date:2022/7/11,11:08
*/
public class ServiceXSOG0801B extends ServiceEPBase {
/**
* 初始化
*
* @param inInfo
* @return
*/
@Override
public EiInfo initLoad(EiInfo inInfo) {
try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
Org org = HPXSTools.XsOrg.get(MapUtils.getString(queryMap, "orgId"));
// 回填父级ID
queryMap.put("parentOrgId", org.getParentOrgId());
String condition;
if (OrgTypeEnum.FACTORY.getCode().equals(org.getOrgType())) {
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 orgId = MapUtils.getString(queryRow, "orgId");
if ("".equals(orgId)) {
return inInfo;
}
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 {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
resultRows.forEach((row) -> {
row.put("establishDate", DateUtils.formatShort(row.get("establishDate")));
row.put("recRevisor", UserSession.getLoginName());
});
EiInfo call = new EiInfo();
call.set("list", resultRows);
call.set(EiConstant.serviceId, "S_XS_89");
XServiceManager.call(call);
inInfo = this.query(inInfo);
inInfo.setMsg("修改成功");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "修改组织机构失败");
}
return inInfo;
}
}
......@@ -152,6 +152,9 @@
<isNotEmpty prepend=" AND " property="parentOrgId">
PARENT_ORG_ID = #parentOrgId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="orgId">
ORG_ID = #orgId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="orgCname">
ORG_CNAME like ('%$orgCname$%')
</isNotEmpty>
......
......@@ -359,6 +359,7 @@ public class ServiceXSOrgManage extends ServiceEPBase {
block.setCell(i, "orgBriefName", inInfoRowMap.get("orgBriefName").toString());
}
block.setCell(i, "establishDate", inInfoRowMap.get("establishDate"));
block.setCell(i, "recRevisor", recRevisor);
block.setCell(i, "recReviseTime", DateUtils.curDateTimeStr14());
}
......
......@@ -20,7 +20,6 @@
</script>
<script type="text/javascript">
let projectEnv = "${projectEnv}";
console.warn("projectEnv", projectEnv);
</script>
<script src="${ctx}/common/js/common.js"></script>
<script src="${ctx}/common/js/jsUtils.js"></script>
......@@ -568,9 +568,17 @@ $(function () {
IPLAT.alert("请在组织机构树选择任意节点后编辑组织机构")
return
}
$("#inqu_status3-0-orgId").val(orgId)
result3Grid.dataSource.page(1)
$("#editOrgWindow").data("kendoWindow").open();
// $("#inqu_status3-0-orgId").val(orgId)
// result3Grid.dataSource.page(1)
// $("#editOrgWindow").data("kendoWindow").open();
let params = "&inqu_status-0-orgId=" + orgId;
JSColorbox.open({
href: "XSOG0801B?methodName=initLoad" + params,
title: "<div style='text-align: center;'>编辑组织机构</div>",
width: "70%",
height: "70%",
callbackName: editCallback
});
})
$("#categoryTree").mousedown(function (e) {
......@@ -913,6 +921,15 @@ let addCallback = function (parentOrgId) {
}
/**
* 编辑组织机构回调
*/
let editCallback = function (parentOrgId) {
// 回填父级ID
$("#inqu_status2-0-parentOrgId").val(parentOrgId);
refreshTree();
}
/**
* 刷新树
*/
let refreshTree = function () {
......
......@@ -308,7 +308,7 @@
<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:EFComboColumn ename="orgType" cname="组织类型" align="center">
<EF:EFCodeOption codeName="xs.og.orgType" textField="label" valueField="value"/>
</EF:EFComboColumn>
<EF:EFColumn ename="orgNodeType" cname="节点类型" hidden="true" defaultValue="2"/> <%--隐藏 默认值为2--%>
......
$(function () {
IPLATUI.EFGrid = {
"result": {
columns: [],
columns: [{
field: "orgId",
template: function (e) {
// 新增时,组织机构编码需要置空
if (e.isNew()) {
e["orgId"] = "";
}
return e['orgId'];
}
}],
onSave: function (e) {
// 阻止后台保存请求,使用自定义保存
e.preventDefault();
......
......@@ -23,7 +23,7 @@
<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:EFComboColumn ename="orgType" cname="组织类型" align="center" required="true" >
<EF:EFOptions blockId="orgTypeBlock" textField="label" valueField="value"/>
</EF:EFComboColumn>
<EF:EFColumn ename="orgNodeType" cname="节点类型" hidden="true" defaultValue="2"/> <%--隐藏 默认值为2--%>
......
$(function () {
IPLATUI.EFGrid = {
"result": {
columns: [],
onSave: function (e) {
// 阻止后台保存请求,使用自定义保存
e.preventDefault();
save();
}
}
};
$("#ef_form_head").hide();
});
/**
* 页面加载时执行
*/
$(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", "XSOG0801B", "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="result" title="组织机构">
<EF:EFInput cname="上级组织编码" blockId="inqu_status" ename="parentOrgId" row="0" type="hidden"/>
<EF:EFInput cname="组织编码" blockId="inqu_status" ename="orgId" row="0" type="hidden"/>
<EF:EFGrid blockId="result" autoBind="false" autoDraw="false" checkMode="multiple,row">
<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="组织类型" align="center" required="true" >
<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