Commit c24c5700 by 江和松

蓝图清单功能提交

parent 13a6d086
......@@ -101,6 +101,8 @@ public class HGConstant {
public static final String INSPEC_CODE = "INSPEC_CODE";
// 保养单号
public static final String UPKEEP_CODE = "UPKEEP_CODE";
// 蓝图编号
public static final String BLUEPRINT_CODE = "BLUEPRINT_CODE";
}
/**
......@@ -181,4 +183,32 @@ public class HGConstant {
public static final String QT = "QT";
}
/**
* 停用状态
*
* @author:songx
* @date:2024/1/20,15:18
*/
public static class EnablingStatus {
// 停用
public static final Integer TY = 0;
// 启用
public static final Integer QY = 1;
}
/**
* 审批状态
*
* @author:songx
* @date:2024/5/15,15:18
*/
public static class ApprovalStatus {
// 待审
public static final Integer DS = 0;
// 审批中
public static final Integer SPZ = 1;
// 已审
public static final Integer YS = 2;
}
}
package com.baosight.hggp.hg.sc.service;
import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.hg.constant.HGConstant;
import com.baosight.hggp.hg.sc.domain.HGSC001;
import com.baosight.hggp.hg.sc.domain.HGSC003;
import com.baosight.hggp.util.*;
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.resource.I18nMessages;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import java.util.*;
/**
* @Author jhs
* @Date 2024/5/14 14:46
*/
public class ServiceHGSC003 extends ServiceBase {
public EiInfo initLoad(EiInfo inInfo) {
try {
inInfo = super.query(inInfo, HGSC003.QUERY, new HGSC003());
Map map = new HashMap();
map.put(HGSC003.FIELD_account_code, UserSessionUtils.getAccountCode());
CommonMethod.initBlock(inInfo,
Arrays.asList(DdynamicEnum.COMPANY_BOX_BLOCK_ID,DdynamicEnum.PROJ_RECORD_BLOCK_ID),map,false
);
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
return inInfo;
}
public EiInfo query(EiInfo inInfo) {
try {
inInfo = super.query(inInfo, HGSC003.QUERY, new HGSC003());
Map map = new HashMap();
map.put(HGSC003.FIELD_account_code, UserSessionUtils.getAccountCode());
CommonMethod.initBlock(inInfo,
Arrays.asList(DdynamicEnum.COMPANY_BOX_BLOCK_ID,DdynamicEnum.PROJ_RECORD_BLOCK_ID),map,false
);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
}
return inInfo;
}
@Override
public EiInfo delete(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 蓝图ids
List<Long> ids = ObjectUtils.listKey(resultRows, HGSC003.FIELD_id);
DaoUtils.update(HGSC003.BATCH_DELETE, new HashMap<String,Object>(){{put("ids",ids);}});
// HGSCTools.THGSC003A.deleteByProIds(ids);
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据删除成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "删除失败");
}
return inInfo;
}
public EiInfo deactivate(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 蓝图ids
List<Long> ids = ObjectUtils.listKey(resultRows, "id");
DaoUtils.update(HGSC003.BATCH_DEACTIVATE, new HashMap<String,Object>(){{put("ids",ids);}});
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
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);
HGSC003 hgsc003 = new HGSC003();
hgsc003.fromMap(resultMap);
this.checkSaveData(hgsc003);
if(Objects.nonNull(hgsc003.getId())&&hgsc003.getId()!=0){
DaoUtils.update(HGSC003.UPDATE, hgsc003);
}else {
//生成蓝图编号
hgsc003.setBlueprintCode(SequenceGenerator.getNextSequence(HGConstant.SequenceId.BLUEPRINT_CODE));
hgsc003.setBlueprintStatus(HGConstant.EnablingStatus.QY);
DaoUtils.insert(HGSC003.INSERT, hgsc003);
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
/**
* 校验保存的数据
*
* @param hgsc003
*/
private void checkSaveData(HGSC003 hgsc003) {
if(Objects.nonNull(hgsc003.getId())&&hgsc003.getId()>0){
HGSC003 oldHgsc003 = (HGSC003) super.dao.get(HGSC003.QUERY,HGSC003.FIELD_id,hgsc003.getId());
AssertUtils.isTrue(oldHgsc003.getBlueprintStatus().compareTo(HGConstant.EnablingStatus.QY) == 0,"蓝图启用中不可修改!");
}
Map<String,Object> map = new HashMap<>();
map.put("projCode",hgsc003.getProjCode());
List<HGSC003> oldHgsc003List = this.dao.query(HGSC003.QUERY,map);
for(HGSC003 o : oldHgsc003List){
AssertUtils.isTrue(!(o.getId().intValue() == hgsc003.getId().intValue()),"已存在此项目号的蓝图!");
}
AssertUtils.isEmpty(UserSessionUtils.getAccountCode(), "当前用户未绑定公司,无法操作数据,请联系管理员!");
AssertUtils.isEmpty(UserSessionUtils.getOrgId(), "当前用户未绑定部门,无法操作数据,请联系管理员!");
AssertUtils.isEmpty(hgsc003.getCompanyCode(), "请选择公司!");
AssertUtils.isEmpty(hgsc003.getProjCode(), "请填写项目编号!");
AssertUtils.isEmpty(hgsc003.getProjName(), "请填写项目名称!");
AssertUtils.isEmpty(hgsc003.getBlueprintName(), "请填写蓝图名称!");
}
/**
* 修改启用状态
* @param inInfo
* @return
*/
public EiInfo updateBlueprintStatus(EiInfo inInfo){
int i = 0;
try {
HGSC003 hgsc003 = new HGSC003();
EiBlock eiBlock = inInfo.getBlock(EiConstant.resultBlock);
for (i = 0; i < eiBlock.getRowCount(); i++) {
Map<?, ?> map = eiBlock.getRow(i);
hgsc003.fromMap(map);
DaoUtils.update(HGSC003.UPDATE_BLUEPRINT_STATUS, hgsc003);
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsgByKey("ep.1000", new String[]{String.valueOf(i), I18nMessages.getText("label.update", "修改")});
} catch (PlatException e) {
e.printStackTrace();
inInfo.setStatus(EiConstant.STATUS_FAILURE);
ErrorCodeUtils.handleUpdateException(inInfo,i,e);
logError("修改失败", e.getMessage());
return inInfo;
}
return inInfo;
}
/**
* 项目档案下拉框
* @param inInfo
* @return
*/
public EiInfo projComboBox(EiInfo inInfo){
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
String companyCode = MapUtils.getString(queryMap, HGSC001.FIELD_company_code);
String approvalStatus = MapUtils.getString(queryMap, HGSC001.FIELD_approval_status);
Map map = new HashMap();
map.put(HGSC001.FIELD_account_code, UserSessionUtils.getAccountCode());
map.put(HGSC001.FIELD_company_code, companyCode);
map.put(HGSC001.FIELD_approval_status, approvalStatus);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.PROJ_RECORD_BLOCK_ID), map,false);
return inInfo;
}
}
......@@ -376,6 +376,9 @@
<isNotEmpty prepend=" AND " property="companyCodes">
COMPANY_CODE IN <iterate close=")" open="(" conjunction="," property="companyCodes">#companyCodes[]#</iterate>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="approvalStatus">
approval_status = #approvalStatus#
</isNotEmpty>
ORDER BY PROJ_CODE
</select>
</sqlMap>
<?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">
<sqlMap namespace="HGSC003">
<sql id="condition">
<isNotEmpty prepend=" AND " property="id">
id = #id#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyCode">
company_code = #companyCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyName">
company_name like ('%$companyName$%')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="blueprintCode">
blueprint_code = #blueprintCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="blueprintName">
blueprint_name like ('%$blueprintName$%')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="projCode">
proj_code = #projCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="projName">
proj_name like ('%$projName$%')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="blueprintStatus">
blueprint_status = #blueprintStatus#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="approvalStatus">
approval_status = #approvalStatus#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountCode">
account_code = #accountCode#
</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>
</sql>
<select id="query" parameterClass="java.util.HashMap"
resultClass="com.baosight.hggp.hg.sc.domain.HGSC003">
SELECT
id as "id", <!-- 主键 -->
company_code as "companyCode", <!-- 公司编码 -->
company_name as "companyName", <!-- 公司名称 -->
dep_code as "depCode", <!-- 部门编码 -->
dep_name as "depName", <!-- 部门名称 -->
blueprint_code as "blueprintCode", <!-- 蓝图编号 -->
blueprint_name as "blueprintName", <!-- 蓝图名称 -->
proj_code as "projCode", <!-- 项目编码 -->
proj_name as "projName", <!-- 项目名称 -->
blueprint_status as "blueprintStatus", <!-- 蓝图状态 0:停用,1:启用 -->
approval_status as "approvalStatus", <!-- 审批状态 0:待审;1:审核中;2:已审 -->
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}.HGSC003 WHERE 1=1
<include refid="condition" />
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy">
$orderBy$
</isNotEmpty>
</dynamic>
</select>
<select id="count" resultClass="int">
SELECT COUNT(*) FROM ${hggpSchema}.HGSC003 WHERE 1=1
<include refid="condition" />
</select>
<insert id="insert">
INSERT INTO ${hggpSchema}.HGSC003 (id, <!-- 主键 -->
company_code, <!-- 公司编码 -->
company_name, <!-- 公司名称 -->
dep_code, <!-- 部门编码 -->
dep_name, <!-- 部门名称 -->
blueprint_code, <!-- 蓝图编号 -->
blueprint_name, <!-- 蓝图名称 -->
proj_code, <!-- 项目编码 -->
proj_name, <!-- 项目名称 -->
blueprint_status, <!-- 蓝图状态 0:停用,1:启用 -->
approval_status, <!-- 审批状态 0:待审;1:审核中;2:已审 -->
account_code, <!-- 帐套 -->
created_by, <!-- 创建人 -->
created_name, <!-- 创建人名称 -->
created_time, <!-- 创建时间 -->
updated_by, <!-- 更新人 -->
updated_name, <!-- 修改人名称 -->
updated_time <!-- 更新时间 -->
)
VALUES (#id#, #companyCode#, #companyName#, #depCode#, #depName#, #blueprintCode#, #blueprintName#, #projCode#, #projName#, #blueprintStatus#, #approvalStatus#, #accountCode#, #createdBy#, #createdName#, #createdTime#, #updatedBy#, #updatedName#, #updatedTime#)
</insert>
<delete id="delete">
DELETE FROM ${hggpSchema}.HGSC003 WHERE
</delete>
<update id="update">
UPDATE ${hggpSchema}.HGSC003
SET
id = #id#, <!-- 主键 -->
company_code = #companyCode#, <!-- 公司编码 -->
company_name = #companyName#, <!-- 公司名称 -->
dep_code = #depCode#, <!-- 部门编码 -->
dep_name = #depName#, <!-- 部门名称 -->
blueprint_code = #blueprintCode#, <!-- 蓝图编号 -->
blueprint_name = #blueprintName#, <!-- 蓝图名称 -->
proj_code = #projCode#, <!-- 项目编码 -->
proj_name = #projName#, <!-- 项目名称 -->
blueprint_status = #blueprintStatus#, <!-- 蓝图状态 0:停用,1:启用 -->
approval_status = #approvalStatus#, <!-- 审批状态 0:待审;1:审核中;2:已审 -->
account_code = #accountCode#, <!-- 帐套 -->
created_by = #createdBy#, <!-- 创建人 -->
created_name = #createdName#, <!-- 创建人名称 -->
created_time = #createdTime#, <!-- 创建时间 -->
updated_by = #updatedBy#, <!-- 更新人 -->
updated_name = #updatedName#, <!-- 修改人名称 -->
updated_time = #updatedTime# <!-- 更新时间 -->
WHERE
</update>
<delete id="batchDelete">
DELETE FROM ${hggpSchema}.HGSC003 WHERE
id IN <iterate close=")" open="(" conjunction="," property="ids">#ids[]#</iterate>
</delete>
<update id="batchDeactivate">
UPDATE ${hggpSchema}.HGSC003
SET
blueprint_status = 0, <!-- 蓝图状态 0:停用,1:启用 -->
updated_by = #updatedBy#, <!-- 更新人 -->
updated_name = #updatedName#, <!-- 修改人名称 -->
updated_time = #updatedTime# <!-- 更新时间 -->
WHERE
id IN <iterate close=")" open="(" conjunction="," property="ids">#ids[]#</iterate>
</update>
<update id="updateBlueprintStatus">
UPDATE ${hggpSchema}.HGSC003
SET
UPDATED_BY = #updatedBy#, <!-- 更新人 -->
UPDATED_NAME = #updatedName#, <!-- 更新人名称 -->
UPDATED_TIME = #updatedTime#, <!-- 更新时间 -->
BLUEPRINT_STATUS = #blueprintStatus# <!-- 状态0.启用1.停止 -->
WHERE
ID = #id#
</update>
</sqlMap>
<!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}"/>
<script>
var ctx = "${ctx}";
</script>
<head>
</head>
<EF:EFPage title="蓝图清单">
<EF:EFRegion id="inqu" title="查询条件">
<div class="row">
<EF:EFInput ename="inqu_status-0-companyName" cname="公司名称" colWidth="3"/>
<EF:EFInput ename="inqu_status-0-blueprintName" cname="蓝图名称" colWidth="3"/>
<EF:EFInput ename="inqu_status-0-projName" cname="项目名称" colWidth="3"/>
<EF:EFSelect cname="状态" ename="inqu_status-0-blueprintStatus" colWidth="3" filter="contains">
<EF:EFOption label="全部" value=""/>
<EF:EFCodeOption codeName="hggp.hgsc.enablingStatus" />
</EF:EFSelect>
</div>
</EF:EFRegion>
<EF:EFRegion id="result" title="记录集">
<EF:EFGrid blockId="result" autoDraw="no" isFloat="true" copyToAdd="false">
<EF:EFColumn ename="id" cname="主键" hidden="true"/>
<EF:EFColumn ename="operator" cname="操作" locked="true" enable="false" width="100" align="center"/>
<EF:EFComboColumn ename="companyCode" cname="公司名称"
columnTemplate="#=textField#" itemTemplate="#=textField#"
textField="textField" valueField="valueField"
maxLength="16" width="120" required="true"
align="center" filter="contains" sort="true">
<EF:EFOptions blockId="companyBox_block_id" textField="textField" valueField="valueField"/>
</EF:EFComboColumn>
<EF:EFColumn ename="companyName" cname="公司名称" hidden="true"/>
<EF:EFColumn ename="blueprintCode" cname="蓝图编码" enable="false" width="120" align="center"/>
<EF:EFColumn ename="blueprintName" cname="蓝图名称" enable="true" width="120" align="center" required="true"/>
<EF:EFColumn ename="projCode" cname="项目编码" enable="true" width="120" align="center"/>
<EF:EFColumn ename="projName" cname="项目名称" width="120" align="center" enable="false"/>
<EF:EFComboColumn ename="blueprintStatus" cname="状态" width="80" align="center" enable="false" required="false" readonly="true">
<EF:EFCodeOption codeName="hggp.hgsc.enablingStatus" />
</EF:EFComboColumn>
</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