Commit 4a3af12b by 宋祥
parents 05ae070b 98137787
......@@ -179,7 +179,7 @@ public enum DdynamicEnum {
* 用途:调拨单下拉框
* 编写:ly
*/
WH_RECORD_BOX_BLOCK_ID("wh_record_box_block_id", "whCode", "whName","companyCode","companyName", "HGKC010.queryWhCodeBox",
WH_RECORD_BOX_BLOCK_ID("wh_record_box_block_id", "whCode", "whName","companyCode","companyName","whType","whTypeName", "HGKC010.queryWhCodeBox",
new HashMap<String,Object>(){{
put("deleteFlag", CommonConstant.YesNo.NO_0);
}}),
......@@ -274,7 +274,7 @@ public enum DdynamicEnum {
* 用途:工序设计下拉框
* 编写:ly
*/
COMPANY_BOX_BLOCK_ID("companyBox_block_id","orgEname","orgCname","HGSJ001.queryCompany",
COMPANY_BOX_BLOCK_ID("companyBox_block_id","orgEname","orgCname","parentOrgId","orgType","HGSJ001.queryCompany",
new HashMap<String,Object>(){{
put("orgType", OrgTypeEnum.COMPANY.getCode());
}}),
......
......@@ -88,6 +88,10 @@ public class CommonConstant {
public static final String PRODUCTTION_ORDER_NO = "productionOrderNo";
// ROOT
public static final String ROOT = "root";
// ROOT2
public static final String ROOT2 = "$";
// NODE
public static final String NODE = "node";
// 项目档案ID
public static final String PROJ_ID = "projId";
// 企业管理员
......
package com.baosight.hggp.core.api;
package com.baosight.hggp.core.extapp.baidu;
import lombok.extern.slf4j.Slf4j;
......
package com.baosight.hggp.core.extapp.decheng.annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* @author:songx
* @date:2021/3/20,21:38
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface AliasNameAnon {
/**
* 名称
*
* @return
*/
String name() default "";
}
package com.baosight.hggp.core.extapp.decheng.api;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baosight.hggp.core.extapp.decheng.constant.DeChengConst;
import com.baosight.hggp.core.extapp.decheng.model.DcChance;
import com.baosight.hggp.core.extapp.decheng.model.DcContractList;
import com.baosight.hggp.core.extapp.decheng.model.DcDeptList;
import com.baosight.hggp.core.extapp.decheng.model.DcUser;
import com.baosight.hggp.core.extapp.decheng.model.DcUserList;
import com.baosight.hggp.core.extapp.decheng.utils.DcApiUtils;
import com.baosight.hggp.core.model.Pager;
import com.baosight.hggp.util.HttpUtils;
import com.baosight.hggp.util.StringUtils;
import com.baosight.iplat4j.core.exception.PlatException;
import java.io.IOException;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
/**
* 德诚开放平台
*
* @author:songx
* @date:2024/1/29,9:16
*/
@Slf4j
public class DcOpenApi {
/**
* 部门管理-列表
*
* @param pageIndex 当前页
*/
public static Pager<DcDeptList> deptList(int pageIndex) throws IOException, InstantiationException,
IllegalAccessException {
JSONObject paramJson = DcApiUtils.buildParamJson(pageIndex);
String result = HttpUtils.post(DeChengConst.DEPT_LIST, DcApiUtils.buildHeader(), JSON.toJSONString(paramJson),
HttpUtils.JSON_MEDIA_TYPE);
if (StringUtils.isBlank(result)) {
throw new PlatException("【德诚】获取部门管理列表失败");
}
return DcApiUtils.handleResultV3(result, DcDeptList.class);
}
/**
* 用户管理-列表
*
* @param pageIndex 当前页
*/
public static Pager<DcUserList> userList(int pageIndex)
throws IOException, InstantiationException, IllegalAccessException {
JSONObject paramJson = DcApiUtils.buildParamJson(pageIndex);
String result = HttpUtils.post(DeChengConst.USER_LIST, DcApiUtils.buildHeader(), JSON.toJSONString(paramJson),
HttpUtils.JSON_MEDIA_TYPE);
if (StringUtils.isBlank(result)) {
throw new PlatException("【德诚】获取用户管理列表失败");
}
return DcApiUtils.handleResultV3(result, DcUserList.class);
}
/**
* 用户管理-详情
*
* @param ord 单据ID
*/
public static DcUser userDetail(int ord) throws IOException {
JSONObject paramJson = new JSONObject();
paramJson.put("ord", ord);
String result = HttpUtils.post(DeChengConst.USER_DETAIL, DcApiUtils.buildHeader(true),
JSON.toJSONString(paramJson), HttpUtils.JSON_MEDIA_TYPE);
if (StringUtils.isBlank(result)) {
throw new PlatException("【德诚】获取用户管理详情失败");
}
return DcApiUtils.handleResultDetailV3(result, DcUser.class);
}
/**
* 项目管理-列表
*
* @param startTime 开始日期 20240815
* @param endTime 结束日期 20240820
* @param pageIndex 当前页
*/
public static List<DcChance> chanceList(String startTime, String endTime, int pageIndex) throws IOException {
JSONArray dataJsons = new JSONArray();
dataJsons.add(DcApiUtils.buildValueJson("a_date_0", startTime));
dataJsons.add(DcApiUtils.buildValueJson("a_date_1", endTime));
dataJsons.add(DcApiUtils.buildValueJson("pageindex", pageIndex));
dataJsons.add(DcApiUtils.buildValueJson("pagesize", 100));
String param = JSON.toJSONString(DcApiUtils.buildParamJson(dataJsons));
String result = HttpUtils.post(DeChengConst.CHANCE_LIST, param, HttpUtils.JSON_MEDIA_TYPE);
if (StringUtils.isBlank(result)) {
throw new PlatException("【德诚】获取项目管理列表失败");
}
return DcApiUtils.handleResult(result, DcChance.class);
}
/**
* 合同管理-列表
*
* @param pageIndex 当前页
*/
public static List<DcContractList> contactList(int pageIndex) throws IOException {
JSONArray dataJsons = new JSONArray();
dataJsons.add(DcApiUtils.buildValueJson("pageindex", pageIndex));
dataJsons.add(DcApiUtils.buildValueJson("pagesize", 100));
String param = JSON.toJSONString(DcApiUtils.buildParamJson(dataJsons));
String result = HttpUtils.post(DeChengConst.CONTRACT_LIST, param, HttpUtils.JSON_MEDIA_TYPE);
if (StringUtils.isBlank(result)) {
throw new PlatException("【德诚】获取合同管理列表失败");
}
return DcApiUtils.handleResult(result, DcContractList.class);
}
/**
* 工作互动-添加
*
* @param title 主题
* @param content 内容
* @param ords 人员标识,多个逗号隔开
* @return
* @throws IOException
*/
public static void interactionAdd(String title, String content, String ords) throws IOException {
JSONArray dataJsons = new JSONArray();
dataJsons.add(DcApiUtils.buildValueJson("title", title));
dataJsons.add(DcApiUtils.buildValueJson("sort2", 451)); // 451:默认分类
dataJsons.add(DcApiUtils.buildValueJson("intro", content));
dataJsons.add(DcApiUtils.buildValueJson("member", 1)); // 0:全部,1: 不分,-1:私密
dataJsons.add(DcApiUtils.buildValueJson("share", ords));
String param = JSON.toJSONString(DcApiUtils.buildParamJson(dataJsons, "__sys_dosave"));
String result = HttpUtils.post(DeChengConst.INTERACTION_ADD, param, HttpUtils.JSON_MEDIA_TYPE);
if (StringUtils.isBlank(result)) {
throw new PlatException("【德诚】添加工作互动失败");
}
// 异常处理
DcApiUtils.handleMessage(JSONObject.parseObject(result));
}
}
package com.baosight.hggp.core.api;
package com.baosight.hggp.core.extapp.decheng.api;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baosight.hggp.core.constant.ZhiBangConst;
import com.baosight.hggp.core.model.zhiBang.Chance;
import com.baosight.hggp.core.extapp.decheng.constant.DeChengConst;
import com.baosight.hggp.util.HttpUtils;
import com.baosight.hggp.util.StringUtils;
import com.baosight.iplat4j.core.exception.PlatException;
import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
/**
......@@ -22,7 +17,7 @@ import lombok.extern.slf4j.Slf4j;
* @date:2024/1/29,9:16
*/
@Slf4j
public class ZhiBangApi {
public class DcTokenApi {
/**
* 获取TOKEN
......@@ -30,7 +25,7 @@ public class ZhiBangApi {
* @return
*/
public static String getToken() {
String token = SingletonHolder.TOKEN;
String token = SingletonHolder.getToken();
if (StringUtils.isBlank(token)) {
throw new PlatException("zhi bang token is null!");
}
......@@ -38,115 +33,29 @@ public class ZhiBangApi {
}
/**
* 刷新TOKEN
*
* @return
*/
public static void refreshToken() {
SingletonHolder.refresh();
}
/**
* 项目管理-列表
*
* @param startTime 开始日期
* @param endTime 结束日期
* @param pageIndex 当前页
*/
public static List<Chance> chanceList(String startTime, String endTime, int pageIndex) throws IOException {
JSONArray dataJsons = new JSONArray();
dataJsons.add(buildValueJson("a_date_0", startTime));
dataJsons.add(buildValueJson("a_date_1", endTime));
dataJsons.add(buildValueJson("pageindex", pageIndex));
dataJsons.add(buildValueJson("pagesize", 100));
String param = JSON.toJSONString(buildParamJson(dataJsons));
String result = HttpUtils.post(ZhiBangConst.CHANCE_LIST, param, HttpUtils.FORM_MEDIA_TYPE);
if (StringUtils.isBlank(result)) {
throw new PlatException("【智邦】获取项目管理列表失败");
}
return handleResult(result, Chance.class);
}
/**
* 组装数据
*
* @return
*/
private static JSONObject buildParamJson(JSONArray dataJsons) {
JSONObject paramJson = new JSONObject();
paramJson.put("session", getToken());
paramJson.put("cmdkey", "refresh");
paramJson.put("datas", dataJsons);
return paramJson;
}
/**
* 组装值的json
*
* @param id
* @param val
* @return
*/
private static JSONObject buildValueJson(String id, Object val) {
JSONObject valueJson = new JSONObject();
valueJson.put("id", id);
valueJson.put("val", val);
return valueJson;
}
/**
* 构建返回结果对象
* 获取TOKEN(缓存)
*
* @param result
* @return
*/
private static <T> List<T> handleResult(String result, Class<T> clazz) {
JSONObject resultJson = JSONObject.parseObject(result);
// 异常处理
handleMessage(resultJson);
// 构建结果数据集
return buildTableData(resultJson, clazz);
public static String getTokenCache() {
String token = SingletonHolder.TOKEN;
if (StringUtils.isNotBlank(token)) {
return token;
}
/**
* 处理返回消息
*
* @param resultJson
*/
private static void handleMessage(JSONObject resultJson) {
JSONObject headerJson = resultJson.getJSONObject("header");
String message = headerJson.getString("message");
String status = headerJson.getString("status");
// 会话非法
if (ZhiBangConst.ApiStatus.S_2.equals(status)) {
refreshToken();
throw new PlatException("【智邦】" + message);
if (refreshToken()) {
return SingletonHolder.TOKEN;
} else {
throw new PlatException("zhi bang token is null!");
}
}
/**
* 构建数据集
* 刷新TOKEN
*
* @param resultJson
* @param clazz
* @param <T>
* @return
*/
private static <T> List<T> buildTableData(JSONObject resultJson, Class<T> clazz) {
JSONObject bodyJson = resultJson.getJSONObject("body");
JSONObject sourceJson = bodyJson.getJSONObject("source");
JSONObject tableJson = sourceJson.getJSONObject("table");
JSONArray colJsons = tableJson.getJSONArray("cols");
JSONArray rowJsons = tableJson.getJSONArray("rows");
return rowJsons.stream().map(item -> {
JSONArray singleRowJsons = (JSONArray) item;
// rowJsons存储的是行数据的为二维数组,长度与colJson相同
JSONObject rowValueJson = new JSONObject();
for (int j = 0; j < colJsons.size(); j++) {
rowValueJson.put(colJsons.getJSONObject(j).getString("id"), singleRowJsons.get(j));
}
return rowValueJson.toJavaObject(clazz);
}).collect(Collectors.toList());
public static boolean refreshToken() {
return SingletonHolder.refresh();
}
/**
......@@ -167,8 +76,13 @@ public class ZhiBangApi {
*
* @return
*/
public static void refresh() {
TOKEN = getToken();
public static boolean refresh() {
String token = getToken();
if (StringUtils.isBlank(token)) {
return false;
}
TOKEN = token;
return true;
}
/**
......@@ -176,10 +90,10 @@ public class ZhiBangApi {
*
* @return
*/
private static String getToken() {
public static String getToken() {
try {
String param = JSON.toJSONString(buildParamJson());
String result = HttpUtils.post(ZhiBangConst.TOKEN_URL, param, HttpUtils.JSON_MEDIA_TYPE);
String result = HttpUtils.post(DeChengConst.TOKEN_URL, param, HttpUtils.JSON_MEDIA_TYPE);
if (StringUtils.isBlank(result)) {
log.error("获取智邦API的TOKEN失败,接口返回null");
return null;
......@@ -215,12 +129,25 @@ public class ZhiBangApi {
*/
private static JSONArray buildDataJson() {
JSONArray dataJsons = new JSONArray();
dataJsons.add(buildValueJson("user", "txt:" + ZhiBangConst.API_KEY));
dataJsons.add(buildValueJson("password", "txt:" + ZhiBangConst.SECRET_KEY));
dataJsons.add(buildValueJson("serialnum", "txt:qwert12345"));
dataJsons.add(buildValueJson("user", "txt:" + DeChengConst.API_KEY));
dataJsons.add(buildValueJson("password", "txt:" + DeChengConst.SECRET_KEY));
dataJsons.add(buildValueJson("serialnum", "txt:abcd1234"));
return dataJsons;
}
/**
* 组装值的json
*
* @param id
* @param val
* @return
*/
private static JSONObject buildValueJson(String id, Object val) {
JSONObject valueJson = new JSONObject();
valueJson.put("id", id);
valueJson.put("val", val);
return valueJson;
}
}
}
package com.baosight.hggp.core.constant;
package com.baosight.hggp.core.extapp.decheng.constant;
/**
* @author:songx
* @date:2024/8/9,15:46
*/
public class ZhiBangConst {
public class DeChengConst {
/**
* Api Key
......@@ -19,12 +19,42 @@ public class ZhiBangConst {
/**
* 鉴权接口
*/
public static final String TOKEN_URL = "http://1.202.243.190:32131/webapi/v3/ov1/login";
public static final String TOKEN_URL = "http://106.15.43.147:6099/webapi/v3/ov1/login";
/**
* 部门管理-列表
*/
public static final String DEPT_LIST = "http://106.15.43.147:6099/webapi/v3/orgs/dept/list";
/**
* 账号管理-列表
*/
public static final String USER_LIST = "http://106.15.43.147:6099/webapi/v3/orgs/user/list";
/**
* 账号管理-详情
*/
public static final String USER_DETAIL = "http://106.15.43.147:6099/webapi/v3/orgs/user/detail";
/**
* 项目管理-列表
*/
public static final String CHANCE_LIST = "http://1.202.243.190:32131/sysa/mobilephone/salesmanage/chance/list.asp";
public static final String CHANCE_LIST = "http://106.15.43.147:6099/sysa/mobilephone/salesmanage/chance/list.asp";
/**
* 合同管理-列表
*/
public static final String CONTRACT_LIST = "http://106.15.43.147:6099/sysa/mobilephone/salesmanage/contract/billlist.asp";
/**
* 合同详情
*/
public static final String CONTRACT_DETAIL = "http://106.15.43.147:6099/webapi/v3/sales/contract/detail";
/**
* 工作互动-添加
*/
public static final String INTERACTION_ADD = "http://106.15.43.147:6099/sysa/mobilephone/officemanage/interaction/add.asp";
/**
* API状态码
......@@ -35,9 +65,19 @@ public class ZhiBangConst {
public static class ApiStatus {
/**
* 正常
*/
public static final String S200 = "200";
/**
* 会话非法
*/
public static final String S_2 = "2";
public static final String S2 = "2";
/**
* token无效
*/
public static final String S400 = "400";
}
......
package com.baosight.hggp.core.model.zhiBang;
package com.baosight.hggp.core.extapp.decheng.model;
import lombok.Data;
/**
* 项目信息
*
* @author:songx
* @date:2024/8/9,16:41
*/
@Data
public class Chance {
public class DcChance {
/**
* 项目标识
*/
private String ord;
/**
* 项目编号
......
package com.baosight.hggp.core.extapp.decheng.model;
import lombok.Data;
/**
* 合同信息
*
* @author:songx
* @date:2024/8/9,16:41
*/
@Data
public class DcContractList {
/**
* 合同标识
*/
private String ord;
/**
* 合同编号
*/
private String htid;
/**
* 合同主题
*/
private String title;
}
package com.baosight.hggp.core.extapp.decheng.model;
import com.baosight.hggp.core.extapp.decheng.annotation.AliasNameAnon;
import lombok.Data;
/**
* @author:songx
* @date:2024/8/29,10:41
*/
@Data
public class DcDeptList {
/**
* 部门标识
*/
@AliasNameAnon(name = "部门标识")
private String nodeId;
/**
* 部门名称
*/
@AliasNameAnon(name = "部门名称")
private String nodeText;
/**
* 上级部门标识
*/
@AliasNameAnon(name = "上级部门标识")
private String parentId;
/**
* 是否停用
*/
@AliasNameAnon(name = "是否停用")
private String stoped;
/**
* 排序
*/
@AliasNameAnon(name = "排序")
private Integer fullSort;
/**
* 添加人员名称
*/
@AliasNameAnon(name = "添加人员")
private String addUname;
/**
* 添加时间
*/
@AliasNameAnon(name = "添加时间")
private String addTime;
}
package com.baosight.hggp.core.extapp.decheng.model;
import com.baosight.hggp.core.extapp.decheng.annotation.AliasNameAnon;
import lombok.Data;
/**
* @author:songx
* @date:2024/8/29,10:41
*/
@Data
public class DcUser {
/**
* 账号名称
*/
@AliasNameAnon(name = "账号名称")
private String Username;
/**
* 员工姓名
*/
@AliasNameAnon(name = "员工姓名")
private String Name;
/**
* 性别
*/
@AliasNameAnon(name = "性别")
private String Sex;
/**
* 部门id
*/
@AliasNameAnon(name = "部门id")
private String Orgsid;
/**
* 身份证号
*/
@AliasNameAnon(name = "身份证号")
private String Cardid;
/**
* 电子邮件
*/
@AliasNameAnon(name = "电子邮件")
private String Email;
/**
* 手机
*/
@AliasNameAnon(name = "手机")
private String Mobile;
}
package com.baosight.hggp.core.extapp.decheng.model;
import com.baosight.hggp.core.extapp.decheng.annotation.AliasNameAnon;
import lombok.Data;
/**
* @author:songx
* @date:2024/8/29,10:41
*/
@Data
public class DcUserList {
/**
* 账号ID
*/
@AliasNameAnon(name = "账号ID")
private Integer ord;
/**
* 账号名称
*/
@AliasNameAnon(name = "账号名称")
private String userName;
/**
* 员工编号(接口存在空值)
*/
@AliasNameAnon(name = "员工编号")
private String ygId;
/**
* 员工姓名
*/
@AliasNameAnon(name = "员工姓名")
private String name;
/**
* 员工状态
*/
@AliasNameAnon(name = "员工状态")
private String status;
/**
* 部门id
*/
@AliasNameAnon(name = "部门id")
private String orgSid;
/**
* 部门名称
*/
@AliasNameAnon(name = "部门名称")
private String partName;
}
package com.baosight.hggp.core.extapp.decheng.utils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baosight.hggp.core.extapp.decheng.annotation.AliasNameAnon;
import com.baosight.hggp.core.extapp.decheng.api.DcTokenApi;
import com.baosight.hggp.core.extapp.decheng.constant.DeChengConst;
import com.baosight.hggp.core.model.Pager;
import com.baosight.hggp.core.utils.ClassFieldUtils;
import com.baosight.hggp.util.StringUtils;
import com.baosight.iplat4j.core.exception.PlatException;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author:songx
* @date:2024/8/30,10:08
*/
public class DcApiUtils {
/**
* 构建header
*
* @return
*/
public static Map buildHeader() {
return buildHeader(false);
}
/**
* 构建header
*
* @return
*/
public static Map buildHeader(boolean isCache) {
Map headerMap = new HashMap();
headerMap.put("ZBAPI-Token", isCache ? DcTokenApi.getTokenCache() : DcTokenApi.getToken());
return headerMap;
}
/**
* @param pageIndex
* @return
*/
public static JSONObject buildParamJson(int pageIndex) {
JSONObject paramJson = new JSONObject();
paramJson.put("page_index", pageIndex < 1 ? 1 : pageIndex);
paramJson.put("page_size", 100);
return paramJson;
}
/**
* 组装数据
*
* @return
*/
public static JSONObject buildParamJson(JSONArray dataJsons) {
return buildParamJson(dataJsons, null);
}
/**
* 组装数据
*
* @param dataJsons
* @param cmdkey
* @return
*/
public static JSONObject buildParamJson(JSONArray dataJsons, String cmdkey) {
JSONObject paramJson = new JSONObject();
paramJson.put("session", DcTokenApi.getToken());
paramJson.put("cmdkey", StringUtils.isBlank(cmdkey) ? "refresh" : cmdkey);
paramJson.put("datas", dataJsons);
return paramJson;
}
/**
* 组装值的json
*
* @param id
* @param val
* @return
*/
public static JSONObject buildValueJson(String id, Object val) {
JSONObject valueJson = new JSONObject();
valueJson.put("id", id);
valueJson.put("val", val);
return valueJson;
}
/**
* 构建返回结果对象
*
* @param result
* @return
*/
public static <T> T handleResultDetailV3(String result, Class<T> clazz) {
JSONObject resultJson = JSONObject.parseObject(result);
// 异常处理
handleMessageV3(resultJson);
// 构建结果数据集
JSONObject dataJson = resultJson.getJSONObject("Data");
return dataJson.toJavaObject(clazz);
}
/**
* 构建返回结果对象
*
* @param result
* @return
*/
public static <T> Pager<T> handleResultV3(String result, Class<T> clazz)
throws InstantiationException, IllegalAccessException {
JSONObject resultJson = JSONObject.parseObject(result);
// 异常处理
handleMessageV3(resultJson);
// 构建结果数据集
Pager pager = new Pager<T>();
pager.setData(buildTableDataV3(resultJson, clazz));
// 分页数据
JSONObject pageJson = resultJson.getJSONObject("Page");
pager.setPageIndex(pageJson.getInteger("PageIndex"));
pager.setPageSize(pageJson.getInteger("PageSize"));
pager.setTotalRows(pageJson.getInteger("RecordCount"));
pager.setTotalPages(pageJson.getInteger("PageCount"));
return pager;
}
/**
* 处理返回消息
*
* @param resultJson
*/
public static void handleMessageV3(JSONObject resultJson) {
String code = resultJson.getString("Code");
if (DeChengConst.ApiStatus.S200.equals(code)) {
return;
}
String msg = resultJson.getString("Msg");
if (DeChengConst.ApiStatus.S400.equals(code)) {
DcTokenApi.refreshToken();
}
throw new PlatException("【智邦】" + msg);
}
/**
* 构建数据集
*
* @param resultJson
* @param clazz
* @param <T>
* @return
*/
public static <T> List<T> buildTableDataV3(JSONObject resultJson, Class<T> clazz)
throws InstantiationException, IllegalAccessException {
JSONArray colJsons = resultJson.getJSONArray("Cols");
JSONArray rowJsons = resultJson.getJSONArray("Rows");
// 获取类所有属性
Field[] fields = clazz.getDeclaredFields();
List<T> results = new ArrayList<>();
for (Object item : rowJsons) {
JSONArray singleRowJsons = (JSONArray) item;
// rowJsons存储的是行数据的为二维数组,长度与colJson相同
T obj = clazz.newInstance();
for (Field f : fields) {
// 获取注解
AliasNameAnon aliasNameAnon = f.getAnnotation(AliasNameAnon.class);
if (aliasNameAnon == null) {
continue;
}
// 设置属性可访问
f.setAccessible(true);
// 获取单元格索引
int index = colJsons.indexOf(aliasNameAnon.name());
// 设置属性
ClassFieldUtils.setFieldValue(obj, f, singleRowJsons.get(index));
}
results.add(obj);
}
return results;
}
/**
* 构建返回结果对象
*
* @param result
* @return
*/
public static <T> List<T> handleResult(String result, Class<T> clazz) {
JSONObject resultJson = JSONObject.parseObject(result);
// 异常处理
handleMessage(resultJson);
// 构建结果数据集
return buildTableData(resultJson, clazz);
}
/**
* 处理返回消息
*
* @param resultJson
*/
public static void handleMessage(JSONObject resultJson) {
JSONObject headerJson = resultJson.getJSONObject("header");
String message = headerJson.getString("message");
Integer status = headerJson.getInteger("status");
if (status != null && status == 0) {
return;
}
// 会话超时
if (DeChengConst.ApiStatus.S400.equals(status)) {
DcTokenApi.refreshToken();
}
throw new PlatException("【智邦】" + message);
}
/**
* 构建数据集
*
* @param resultJson
* @param clazz
* @param <T>
* @return
*/
public static <T> List<T> buildTableData(JSONObject resultJson, Class<T> clazz) {
JSONObject bodyJson = resultJson.getJSONObject("body");
JSONObject sourceJson = bodyJson.getJSONObject("source");
JSONObject tableJson = sourceJson.getJSONObject("table");
JSONArray colJsons = tableJson.getJSONArray("cols");
JSONArray rowJsons = tableJson.getJSONArray("rows");
return rowJsons.stream().map(item -> {
JSONArray singleRowJsons = (JSONArray) item;
// rowJsons存储的是行数据的为二维数组,长度与colJson相同
JSONObject rowValueJson = new JSONObject();
for (int j = 0; j < colJsons.size(); j++) {
rowValueJson.put(colJsons.getJSONObject(j).getString("id"), singleRowJsons.get(j));
}
return rowValueJson.toJavaObject(clazz);
}).collect(Collectors.toList());
}
}
package com.baosight.hggp.core.model;
import java.io.Serializable;
import java.util.List;
import lombok.Data;
/**
* 分页查询返回集合封装
*
* @author:songx
* @date:2020/8/19,10:58
*/
@Data
public class Pager<T> implements Serializable {
private static final long serialVersionUID = -1;
/**
* 当前页
*/
private int pageIndex = 1;
/**
* 每页显示多少条,默认20
*/
private int pageSize = 20;
/**
* 总记录数
*/
private long totalRows;
/**
* 总页数
*/
private long totalPages;
/**
* 本页的数据列表
*/
private List<T> data;
public Pager() {
}
public Pager(int pageIndex, int pageSize) {
this.pageIndex = pageIndex;
this.pageSize = pageSize;
this.totalRows = 0;
this.totalPages = 0;
}
public void setTotalRows(long totalRows) {
this.totalRows = totalRows;
this.totalPages = this.pageSize == 0 ? 0
: (totalRows / this.pageSize + (totalRows % this.pageSize == 0 ? 0 : 1));
}
}
package com.baosight.hggp.core.utils;
import com.baosight.hggp.util.ObjectUtils;
import java.lang.reflect.Field;
import java.math.BigDecimal;
/**
* @author:songx
* @date:2024/8/29,11:26
*/
public class ClassFieldUtils {
/**
* 绑定实体值
*
* @param obj Object
* @param f Field
* @param cellValue
* @return
* @throws RuntimeException
*/
public static void setFieldValue(Object obj, Field f, Object cellValue) throws IllegalAccessException {
if (ObjectUtils.isNullBlank(cellValue)) {
f.set(obj, f.getType() == String.class ? cellValue : null);
return;
}
String value = cellValue.toString();
if (f.getType() == byte.class || f.getType() == Byte.class) {
f.set(obj, Byte.parseByte(value));
} else if (f.getType() == int.class || f.getType() == Integer.class) {
f.set(obj, Integer.parseInt(value));
} else if (f.getType() == Double.class || f.getType() == double.class) {
f.set(obj, Double.parseDouble(value));
} else if (f.getType() == BigDecimal.class) {
f.set(obj, new BigDecimal(value));
} else {
f.set(obj, value);
}
}
}
package com.baosight.hggp.core.utils;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* 线程池工具类
*
* @author:songx
* @date:2021/7/5,14:50
*/
public class ThreadUtils {
/**
* 固定线程池,初始化3个线程
*/
public static ExecutorService FIXED_THREAD = Executors.newFixedThreadPool(8);
}
......@@ -256,8 +256,8 @@ public class ServiceHGCG002 extends ServiceBase {
String contractNo = fCg002.getContractNo();
HGCG002 dbCg002 = dbCg002AMap.get(contractNo);
AssertUtils.isNull(dbCg002, String.format("合同[%s]不存在", contractNo));
AssertUtils.isTrue(StringUtils.isBlank(dbCg002.getSupName()), String.format("合同[%s]供应商为空", contractNo));
AssertUtils.isTrue(StringUtils.isBlank(dbCg002.getPurUserName()), String.format("合同[%s]采购员为空", contractNo));
AssertUtils.isTrue(StringUtils.isBlank(fCg002.getSupName()), String.format("合同[%s]供应商为空", contractNo));
AssertUtils.isTrue(StringUtils.isBlank(fCg002.getPurUserName()), String.format("合同[%s]采购员为空", contractNo));
AssertUtils.isNotEquals(HGConstant.CgContractStatus.S_0, dbCg002.getStatus(),
String.format("合同[%s]状态不是\"待审核\",不允许操作", contractNo));
AssertUtils.isTrue(fCg002.getAmount().compareTo(BigDecimal.ZERO) <= 0, String.format("合同[%s]不含税金额小于等于0,不允许操作", contractNo));
......
......@@ -5,7 +5,10 @@ import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.enums.DeleteFlagEnum;
import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.hg.cg.domain.*;
import com.baosight.hggp.hg.cg.domain.HGCG001;
import com.baosight.hggp.hg.cg.domain.HGCG001A;
import com.baosight.hggp.hg.cg.domain.HGCG002;
import com.baosight.hggp.hg.cg.domain.HGCG002B;
import com.baosight.hggp.hg.cg.tools.HGCGTools;
import com.baosight.hggp.hg.cg.utils.HGCGUtils;
import com.baosight.hggp.hg.constant.HGConstant;
......@@ -123,6 +126,8 @@ public class ServiceHGCG002A extends ServiceBase {
Long id = fCg001A.getId();
HGCG001A dbCg001A = dbCg001AMap.get(id);
AssertUtils.isNull(dbCg001A, String.format("计划明细[%s]不存在", id));
AssertUtils.isGe(BigDecimal.ZERO, fCg001A.getPurQty(), "采购数量不能小于等于0");
AssertUtils.isGt(BigDecimal.ZERO, fCg001A.getPurWeight(), "采购总量不能小于0");
AssertUtils.isTrue(fCg001A.getTaxRate().compareTo(BigDecimal.ZERO) <= 0, "税率不能小于等于0");
AssertUtils.isTrue(fCg001A.getPrice().compareTo(BigDecimal.ZERO) <= 0, "单价不能小于等于0");
}
......@@ -130,13 +135,13 @@ public class ServiceHGCG002A extends ServiceBase {
/**
* 数据保存
* @param resultRows
* @param fCg001As
* @param dbCg001Map
* @param hgcg001Map
*/
private void confirmData(List<HGCG001A> resultRows, Map<Long, HGCG001A> dbCg001Map, Map<String, HGCG001> hgcg001Map) {
private void confirmData(List<HGCG001A> fCg001As, Map<Long, HGCG001A> dbCg001Map, Map<String, HGCG001> hgcg001Map) {
//取一条主表数据,用于拷贝合同主表信息
HGCG001A oneCg001A = resultRows.get(0);
HGCG001A oneCg001A = fCg001As.get(0);
HGCG001 oneCG001 = hgcg001Map.get(oneCg001A.getPlanNo());
HGCG002 newCg002 = new HGCG002();
BeanUtils.copyProperties(oneCG001, newCg002,"id","createdBy","createdName","createdTime","updatedBy","updatedName","updatedTime");
......@@ -146,30 +151,31 @@ public class ServiceHGCG002A extends ServiceBase {
newCg002.setDeleteFlag(DeleteFlagEnum.UN_REMOVE.getCode());
newCg002.setSource(HGConstant.CgSource.DEFAULT);
DaoUtils.insert(HGCG002.INSERT, newCg002);
for (HGCG001A hgcg001A : resultRows) {
for (HGCG001A fCg001A : fCg001As) {
//新增子表信息
insertDetails(hgcg001A,newCg002);
HGCG001 cg001 = hgcg001Map.get(hgcg001A.getPlanNo());
insertDetails(fCg001A, newCg002);
HGCG001 cg001 = hgcg001Map.get(fCg001A.getPlanNo());
// 更新计划状态
HGCGTools.HgCg001.updateStatus(cg001.getPlanNo(), HGConstant.CgPlanStatus.S_4);
// 更新计划状态
HGCGTools.HgCg001A.updateStatus(hgcg001A.getId(), HGConstant.CgPlanStatus.S_4);
HGCGTools.HgCg001A.updateStatus(fCg001A.getId(), HGConstant.CgPlanStatus.S_4);
}
//修改主表信息
HGCGTools.HgCg002.updateCg002Pur(newCg002);
}
private void insertDetails(HGCG001A dbCg001A, HGCG002 newCg002) {
private void insertDetails(HGCG001A fCg001A, HGCG002 newCg002) {
//获取采购计划明细
List<HGCG002B> cg002BList = new LinkedList<>();
HGCG002B cg002B = new HGCG002B();
//拷贝明细信息
BeanUtils.copyProperties(dbCg001A,cg002B,"id","createdBy","createdName","createdTime","updatedBy","updatedName","updatedTime");
BeanUtils.copyProperties(fCg001A, cg002B, "id", "createdBy", "createdName", "createdTime", "updatedBy",
"updatedName", "updatedTime");
cg002B.setDeleteFlag(DeleteFlagEnum.UN_REMOVE.getCode());
cg002B.setPrimaryId(newCg002.getId());
cg002B.setPlanDetailId(dbCg001A.getId());
cg002B.setPlanDetailId(fCg001A.getId());
cg002BList.add(cg002B);
DaoUtils.insertBatch(HGCG002B.INSERT,cg002BList);
DaoUtils.insertBatch(HGCG002B.INSERT, cg002BList);
}
/**
......
......@@ -388,6 +388,8 @@ public class HGSqlConstant {
public static final String LOCKS = MODULE_NAME + "locks";
// 修改库存
public static final String UPDATE_INV = MODULE_NAME + "updateInv";
// 领用查询
public static final String QUERY_LY = MODULE_NAME + "queryLy";
}
/**
......@@ -654,6 +656,8 @@ public class HGSqlConstant {
public class HgXsOrg {
// 查询组织机构
public static final String GET = "HGXSOrg.get";
// 查询组织机构
public static final String QUERY = "HGXSOrg.query";
// 查询企业下所有的组织机构
public static final String QUERY_ALL = "HGXSOrg.queryAll";
......
......@@ -16,10 +16,7 @@ import com.baosight.hggp.hg.sj.domain.HGSJ003;
import com.baosight.hggp.hg.xs.domain.Company;
import com.baosight.hggp.hg.xs.domain.Org;
import com.baosight.hggp.hg.xs.tools.HGXSTools;
import com.baosight.hggp.util.AssertUtils;
import com.baosight.hggp.util.CommonMethod;
import com.baosight.hggp.util.ExcelUtils;
import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.*;
import com.baosight.hggp.util.contants.ACConstants;
import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiConstant;
......@@ -27,6 +24,7 @@ import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import org.apache.commons.collections.CollectionUtils;
import org.apache.poi.ss.formula.functions.T;
import java.math.BigDecimal;
import java.util.*;
......@@ -66,12 +64,46 @@ public class ServiceHGCW002A extends ServiceBase {
*/
public EiInfo partyAQuery(EiInfo inInfo) {
try {
List<Map> params = inInfo.getBlock(EiConstant.queryBlock).getRows();
List<UserVO> userVOList = new ArrayList<>();
String contractCategory = inInfo.getString("contractCategory");
String partyA = inInfo.getString("partyA");
if (contractCategory.equals("1")) {
List<HGPZ002> hgpz002List = HGPZTools.HgPz002.list(1);
List<HGPZ002> hgpz002List = MapUtils.toDaoEPBases(super.query(inInfo,HGPZ002.QUERY, new HGPZ002()).getBlock(EiConstant.resultBlock).getRows(), HGPZ002.class);
if (CollectionUtils.isNotEmpty(hgpz002List)) {
if(params.size()>0){
Map<String,String> params1 = params.get(0);
Map<String,String> params2 = params.size()>1?params.get(1):null;
String username = params1.get("username");
String usercode = params1.get("usercode");
String username1 = params2==null?null:params2.get("username");
String usercode1 = params2==null?null:params2.get("usercode");
if (StringUtils.isNotNull(username)){
switch (username1){
case "eq":
hgpz002List = hgpz002List.stream().filter(hgpz002 -> hgpz002.getCustName().equals(username)).collect(Collectors.toList());
break;
case "neq":
hgpz002List = hgpz002List.stream().filter(hgpz002 -> !hgpz002.getCustName().equals(username)).collect(Collectors.toList());
break;
default:
hgpz002List = hgpz002List.stream().filter(hgpz002 -> hgpz002.getCustName().contains(username)).collect(Collectors.toList());
}
}
if (StringUtils.isNotNull(usercode)){
switch (usercode1){
case "eq":
hgpz002List = hgpz002List.stream().filter(hgpz002 -> hgpz002.getCustCode().equals(usercode)).collect(Collectors.toList());
break;
case "neq":
hgpz002List = hgpz002List.stream().filter(hgpz002 -> !hgpz002.getCustCode().equals(usercode)).collect(Collectors.toList());
break;
default:
hgpz002List = hgpz002List.stream().filter(hgpz002 -> hgpz002.getCustCode().contains(usercode)).collect(Collectors.toList());
}
}
}
hgpz002List.forEach(hgpz002 -> {
UserVO userVO = new UserVO();
userVO.setUsercode(hgpz002.getCustCode());
......@@ -80,7 +112,39 @@ public class ServiceHGCW002A extends ServiceBase {
});
}
} else if (contractCategory.equals("2")) {
List<Company> list = UserSessionUtils.getRoleCompany().stream().filter(c -> c.getCompanyCode().equals(partyA)).collect(Collectors.toList());;
List<Company> list = UserSessionUtils.getRoleCompany().stream().filter(c -> c.getCompanyCode().equals(partyA)).collect(Collectors.toList());
if(params.size()>0){
Map<String,String> params1 = params.get(0);
Map<String,String> params2 = params.size()>1?params.get(1):null;
String username = params1.get("username");
String usercode = params1.get("usercode");
String username1 = params2==null?null:params2.get("username");
String usercode1 = params2==null?null:params2.get("usercode");
if (StringUtils.isNotNull(username)){
switch (username1){
case "eq":
list = list.stream().filter(hgpz002 -> hgpz002.getCompanyName().equals(username)).collect(Collectors.toList());
break;
case "neq":
list = list.stream().filter(hgpz002 -> !hgpz002.getCompanyName().equals(username)).collect(Collectors.toList());
break;
default:
list = list.stream().filter(hgpz002 -> hgpz002.getCompanyName().contains(username)).collect(Collectors.toList());
}
}
if (StringUtils.isNotNull(usercode)){
switch (usercode1){
case "eq":
list = list.stream().filter(hgpz002 -> hgpz002.getCompanyCode().equals(usercode)).collect(Collectors.toList());
break;
case "neq":
list = list.stream().filter(hgpz002 -> !hgpz002.getCompanyCode().equals(usercode)).collect(Collectors.toList());
break;
default:
list = list.stream().filter(hgpz002 -> hgpz002.getCompanyCode().contains(usercode)).collect(Collectors.toList());
}
}
}
for (Company c:list) {
UserVO userVO = new UserVO();
userVO.setUsercode(c.getCompanyCode());
......@@ -103,11 +167,44 @@ public class ServiceHGCW002A extends ServiceBase {
*/
public EiInfo partyBQuery(EiInfo inInfo) {
try {
List<Map> params = inInfo.getBlock(EiConstant.queryBlock).getRows();
List<UserVO> userVOList = new ArrayList<>();
String contractCategory = inInfo.getString("contractCategory");
String partyB = inInfo.getString("partyB");
if (contractCategory.equals("1")) {
List<Company> list = UserSessionUtils.getRoleCompany().stream().filter(c -> c.getCompanyCode().equals(partyB)).collect(Collectors.toList());
if(params.size()>0){
Map<String,String> params1 = params.get(0);
Map<String,String> params2 = params.size()>1?params.get(1):null;
String username = params1.get("username");
String usercode = params1.get("usercode");
String username1 = params2==null?null:params2.get("username");
String usercode1 = params2==null?null:params2.get("usercode");
if (StringUtils.isNotNull(username)){
switch (username1){
case "eq":
list = list.stream().filter(hgpz002 -> hgpz002.getCompanyName().equals(username)).collect(Collectors.toList());
break;
case "neq":
list = list.stream().filter(hgpz002 -> !hgpz002.getCompanyName().equals(username)).collect(Collectors.toList());
break;
default:
list = list.stream().filter(hgpz002 -> hgpz002.getCompanyName().contains(username)).collect(Collectors.toList());
}
}
if (StringUtils.isNotNull(usercode)){
switch (usercode1){
case "eq":
list = list.stream().filter(hgpz002 -> hgpz002.getCompanyCode().equals(usercode)).collect(Collectors.toList());
break;
case "neq":
list = list.stream().filter(hgpz002 -> !hgpz002.getCompanyCode().equals(usercode)).collect(Collectors.toList());
break;
default:
list = list.stream().filter(hgpz002 -> hgpz002.getCompanyCode().contains(usercode)).collect(Collectors.toList());
}
}
}
for (Company c:list) {
UserVO userVO = new UserVO();
userVO.setUsercode(c.getCompanyCode());
......@@ -116,8 +213,41 @@ public class ServiceHGCW002A extends ServiceBase {
}
}
else if (contractCategory.equals("2")) {
List<HGPZ003> hgpz003List = HGCWTools.HgCw002.list(1);
List<HGPZ003> hgpz003List = MapUtils.toDaoEPBases(super.query(inInfo,HGPZ003.QUERY, new HGPZ003()).getBlock(EiConstant.resultBlock).getRows(), HGPZ003.class);
if (CollectionUtils.isNotEmpty(hgpz003List)) {
if(params.size()>0){
Map<String,String> params1 = params.get(0);
Map<String,String> params2 = params.size()>1?params.get(1):null;
String username = params1.get("username");
String usercode = params1.get("usercode");
String username1 = params2==null?null:params2.get("username");
String usercode1 = params2==null?null:params2.get("usercode");
if (StringUtils.isNotNull(username)){
switch (username1){
case "eq":
hgpz003List = hgpz003List.stream().filter(hgpz002 -> hgpz002.getSupName().equals(username)).collect(Collectors.toList());
break;
case "neq":
hgpz003List = hgpz003List.stream().filter(hgpz002 -> !hgpz002.getSupName().equals(username)).collect(Collectors.toList());
break;
default:
hgpz003List = hgpz003List.stream().filter(hgpz002 -> hgpz002.getSupName().contains(username)).collect(Collectors.toList());
}
}
if (StringUtils.isNotNull(usercode)){
switch (usercode1){
case "eq":
hgpz003List = hgpz003List.stream().filter(hgpz002 -> hgpz002.getSupCode().equals(usercode)).collect(Collectors.toList());
break;
case "neq":
hgpz003List = hgpz003List.stream().filter(hgpz002 -> !hgpz002.getSupCode().equals(usercode)).collect(Collectors.toList());
break;
default:
hgpz003List = hgpz003List.stream().filter(hgpz002 -> hgpz002.getSupCode().contains(usercode)).collect(Collectors.toList());
}
}
}
hgpz003List.forEach(hgpz003 -> {
UserVO userVO = new UserVO();
userVO.setUsercode(hgpz003.getSupCode());
......
......@@ -10,6 +10,8 @@ import com.baosight.hggp.hg.cw.domain.*;
import com.baosight.hggp.hg.cw.domain.HGCW010;
import com.baosight.hggp.hg.cw.tools.HGCWTools;
import com.baosight.hggp.hg.cw.vo.UserVO;
import com.baosight.hggp.hg.sb.domain.HGSB001;
import com.baosight.hggp.hg.sb.tools.HGSBTools;
import com.baosight.hggp.hg.sc.domain.HGSC001;
import com.baosight.hggp.hg.sc.tools.HGSCTools;
import com.baosight.hggp.hg.xs.domain.Company;
......@@ -45,8 +47,14 @@ public class ServiceHGCW010 extends ServiceBase {
@OperationLogAnnotation(operModul = "销售开票",operType = "查询",operDesc = "初始化")
public EiInfo initLoad(EiInfo inInfo) {
try {
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.SUP_RECORD_BLOCK_ID,
DdynamicEnum.PROJ_RECORD_BLOCK_ID), null, false);
/*CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.SUP_RECORD_BLOCK_ID,
DdynamicEnum.PROJ_RECORD_BLOCK_ID), null, false);*/
List<String> roleCompanyCode = HGSBTools.getRoleCompanyCode();
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.PROJ_RECORD_BLOCK_ID),
new HashMap<String,Object>(){{
put(HGSB001.FIELD_COMPANY_CODES,roleCompanyCode);
}}
);
EiInfoUtils.addBlock(inInfo,"roleCompany", UserSessionUtils.getRoleCompany(), Company.class);
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HGCW010().eiMetadata);
} catch (Exception e) {
......
......@@ -45,7 +45,7 @@
COMPANY_NAME = #companyName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="projName">
PROJ_NAME = #projName#
PROJ_NAME like CONCAT('%',#projName#,'%')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="projCode">
PROJ_CODE = #projCode#
......
......@@ -23,7 +23,7 @@ public class HGDM099 extends DaoEPBase {
private static final long serialVersionUID = 1L;
public static final String FIELD_ID = "id";
public static final String FIELD_COMPANY_CODE = "companyCode"; /* 企业编码 预留*/
public static final String FIELD_ACCOUNT_CODE = "accountCode"; /* 企业编码 预留*/
public static final String FIELD_DEP_CODE = "depCode"; /* 部门编码*/
public static final String FIELD_CREATED_BY = "createdBy"; /* 创建人*/
public static final String FIELD_CREATED_NAME = "createdName"; /* 创建人名称*/
......@@ -36,6 +36,8 @@ public class HGDM099 extends DaoEPBase {
public static final String FIELD_BIZ_ID = "bizId"; /* 业务ID*/
public static final String FIELD_DOC_ID = "docId"; /* 文件ID*/
public static final String FIELD_DOC_NAME = "docName"; /* 文件名称*/
public static final String FIELD_PREVIEW_NUM = "previewNum"; /* 预览次数*/
public static final String FIELD_DOWNLOAD_NUM = "downloadNum"; /* 下载次数*/
public static final String COL_ID = "ID";
public static final String COL_COMPANY_CODE = "COMPANY_CODE"; /* 企业编码 预留*/
......@@ -51,15 +53,17 @@ public class HGDM099 extends DaoEPBase {
public static final String COL_BIZ_ID = "BIZ_ID"; /* 业务ID*/
public static final String COL_DOC_ID = "DOC_ID"; /* 文件ID*/
public static final String COL_DOC_NAME = "DOC_NAME"; /* 文件名称*/
public static final String COL_PREVIEW_NUM = "PREVIEW_NUM"; /* 预览次数*/
public static final String COL_DOWNLOAD_NUM = "DOWNLOAD_NUM"; /* 下载次数*/
public static final String QUERY = "HPDM099.query";
public static final String COUNT = "HPDM099.count";
public static final String INSERT = "HPDM099.insert";
public static final String UPDATE = "HPDM099.update";
public static final String DELETE = "HPDM099.delete";
public static final String QUERY = "HGDM099.query";
public static final String COUNT = "HGDM099.count";
public static final String INSERT = "HGDM099.insert";
public static final String UPDATE = "HGDM099.update";
public static final String DELETE = "HGDM099.delete";
private Long id = new Long(0);
private String companyCode = " "; /* 企业编码 预留*/
private String accountCode = " "; /* 企业编码*/
private String depCode = " "; /* 部门编码*/
private String createdBy = " "; /* 创建人*/
private String createdName = " "; /* 创建人名称*/
......@@ -72,6 +76,8 @@ public class HGDM099 extends DaoEPBase {
private String bizId = " "; /* 业务ID*/
private String docId = " "; /* 文件ID*/
private String docName = " "; /* 文件名称*/
private Integer previewNum = new Integer(0); /* 预览次数*/
private Integer downloadNum = new Integer(0); /* 下载次数*/
/**
* initialize the metadata.
......@@ -84,8 +90,8 @@ public class HGDM099 extends DaoEPBase {
eiColumn.setDescName(" ");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_COMPANY_CODE);
eiColumn.setDescName("企业编码 预留");
eiColumn = new EiColumn(FIELD_ACCOUNT_CODE);
eiColumn.setDescName("企业编码");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_DEP_CODE);
......@@ -136,6 +142,14 @@ public class HGDM099 extends DaoEPBase {
eiColumn.setDescName("文件名称");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_PREVIEW_NUM);
eiColumn.setDescName("预览次数");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_DOWNLOAD_NUM);
eiColumn.setDescName("下载次数");
eiMetadata.addMeta(eiColumn);
}
/**
......@@ -162,20 +176,20 @@ public class HGDM099 extends DaoEPBase {
this.id = id;
}
/**
* get the companyCode - 企业编码 预留.
* @return the companyCode
* get the accountCode - 企业编码.
* @return the accountCode
*/
public String getCompanyCode() {
return this.companyCode;
public String getAccountCode() {
return this.accountCode;
}
/**
* set the companyCode - 企业编码 预留.
* set the accountCode - 企业编码.
*
* @param companyCode - 企业编码 预留
* @param accountCode - 企业编码
*/
public void setCompanyCode(String companyCode) {
this.companyCode = companyCode;
public void setAccountCode(String accountCode) {
this.accountCode = accountCode;
}
/**
* get the depCode - 部门编码.
......@@ -358,7 +372,7 @@ public class HGDM099 extends DaoEPBase {
* @return the docName
*/
public String getDocName() {
return this.getDocName();
return this.docName;
}
/**
......@@ -369,6 +383,39 @@ public class HGDM099 extends DaoEPBase {
public void setDocName(String docName) {
this.docName = docName;
}
/**
* get the previewNum - 预览次数.
* @return the previewNum
*/
public Integer getPreviewNum() {
return this.previewNum;
}
/**
* set the previewNum - 预览次数.
*
* @param previewNum - 预览次数
*/
public void setPreviewNum(Integer previewNum) {
this.previewNum = previewNum;
}
/**
* get the downloadNum - 下载次数.
* @return the downloadNum
*/
public Integer getDownloadNum() {
return this.downloadNum;
}
/**
* set the downloadNum - 下载次数.
*
* @param downloadNum - 下载次数
*/
public void setDownloadNum(Integer downloadNum) {
this.downloadNum = downloadNum;
}
/**
* get the value from Map.
*
......@@ -378,7 +425,7 @@ public class HGDM099 extends DaoEPBase {
public void fromMap(Map map) {
setId(NumberUtils.toLong(StringUtils.toString(map.get(FIELD_ID)), id));
setCompanyCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_COMPANY_CODE)), companyCode));
setAccountCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_ACCOUNT_CODE)), accountCode));
setDepCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_DEP_CODE)), depCode));
setCreatedBy(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_CREATED_BY)), createdBy));
setCreatedName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_CREATED_NAME)), createdName));
......@@ -391,6 +438,8 @@ public class HGDM099 extends DaoEPBase {
setBizId(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_BIZ_ID)), bizId));
setDocId(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_DOC_ID)), docId));
setDocName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_DOC_NAME)), docName));
setPreviewNum(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_PREVIEW_NUM)), previewNum));
setDownloadNum(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_DOWNLOAD_NUM)), downloadNum));
}
/**
......@@ -401,7 +450,7 @@ public class HGDM099 extends DaoEPBase {
Map map = new HashMap();
map.put(FIELD_ID, StringUtils.toString(id, eiMetadata.getMeta(FIELD_ID)));
map.put(FIELD_COMPANY_CODE, StringUtils.toString(companyCode, eiMetadata.getMeta(FIELD_COMPANY_CODE)));
map.put(FIELD_ACCOUNT_CODE, StringUtils.toString(accountCode, eiMetadata.getMeta(FIELD_ACCOUNT_CODE)));
map.put(FIELD_DEP_CODE, StringUtils.toString(depCode, eiMetadata.getMeta(FIELD_DEP_CODE)));
map.put(FIELD_CREATED_BY, StringUtils.toString(createdBy, eiMetadata.getMeta(FIELD_CREATED_BY)));
map.put(FIELD_CREATED_NAME, StringUtils.toString(createdName, eiMetadata.getMeta(FIELD_CREATED_NAME)));
......@@ -414,6 +463,8 @@ public class HGDM099 extends DaoEPBase {
map.put(FIELD_BIZ_ID, StringUtils.toString(bizId, eiMetadata.getMeta(FIELD_BIZ_ID)));
map.put(FIELD_DOC_ID, StringUtils.toString(docId, eiMetadata.getMeta(FIELD_DOC_ID)));
map.put(FIELD_DOC_NAME, StringUtils.toString(docName, eiMetadata.getMeta(FIELD_DOC_NAME)));
map.put(FIELD_PREVIEW_NUM, StringUtils.toString(previewNum, eiMetadata.getMeta(FIELD_PREVIEW_NUM)));
map.put(FIELD_DOWNLOAD_NUM, StringUtils.toString(downloadNum, eiMetadata.getMeta(FIELD_DOWNLOAD_NUM)));
return map;
}
......
......@@ -46,12 +46,7 @@ public class ServiceHGDM099 extends ServiceEPBase {
@Override
public EiInfo query(EiInfo inInfo) {
try {
// 文件存储位置
if (CommonConstant.FileLocation.S3.equalsIgnoreCase(S3Constant.FILE_LOCATION)) {
inInfo = super.query(inInfo, "HGDM099.queryS3", new HGDM099());
} else {
inInfo = super.query(inInfo, "HGDM099.queryLocal", new HGDM099());
}
inInfo = super.query(inInfo, HGDM099.QUERY, new HGDM099());
} catch (Throwable e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
}
......@@ -83,7 +78,7 @@ public class ServiceHGDM099 extends ServiceEPBase {
* @param inInfo
* @return
*/
public EiInfo delete(EiInfo inInfo) {
public EiInfo remove(EiInfo inInfo) {
try {
List<HGDM099> fDm099s = MapUtils.toDaoEPBases(inInfo, HGDM099.class);
for (HGDM099 fDm099 : fDm099s) {
......
......@@ -3,72 +3,50 @@
<sqlMap namespace="HGDM099">
<sql id="column">
A.ID as "id",
A.COMPANY_CODE as "companyCode", <!-- 企业编码 预留 -->
A.DEP_CODE as "depCode", <!-- 部门编码 预留 -->
A.CREATED_BY as "createdBy", <!-- 创建人 -->
A.CREATED_NAME as "createdName", <!-- 创建人名称 -->
A.CREATED_TIME as "createdTime", <!-- 创建时间 -->
A.UPDATED_BY as "updatedBy", <!-- 修改人 -->
A.UPDATED_NAME as "updatedName", <!-- 修改人名称 -->
A.UPDATED_TIME as "updatedTime", <!-- 修改时间 -->
A.BIZ_TYPE as "bizType", <!-- 业务类型 -->
A.BIZ_ID as "bizId", <!-- 业务ID -->
A.DOC_ID as "docId" <!-- 文件ID -->
</sql>
<sql id="columnLocal">
<include refid="column"/>,
B.DOC_NAME as "docName" <!-- 文件名称 -->
</sql>
<sql id="columnS3">
<include refid="column"/>,
B.RES_CNAME as "docName" <!-- 文件名称 -->
ID as "id",
ACCOUNT_CODE as "accountCode", <!-- 企业编码 -->
DEP_CODE as "depCode", <!-- 部门编码 预留 -->
CREATED_BY as "createdBy", <!-- 创建人 -->
CREATED_NAME as "createdName", <!-- 创建人名称 -->
CREATED_TIME as "createdTime", <!-- 创建时间 -->
UPDATED_BY as "updatedBy", <!-- 修改人 -->
UPDATED_NAME as "updatedName", <!-- 修改人名称 -->
UPDATED_TIME as "updatedTime", <!-- 修改时间 -->
BIZ_TYPE as "bizType", <!-- 业务类型 -->
BIZ_ID as "bizId", <!-- 业务ID -->
DOC_ID as "docId", <!-- 文件ID -->
DOC_NAME as "docName", <!-- 文件名称 -->
PREVIEW_NUM as "previewNum", <!-- 预览次数 -->
DOWNLOAD_NUM as "downloadNum" <!-- 下载次数 -->
</sql>
<sql id="condition">
AND A.DELETE_FLAG = '0'
<include refid="HGXSDataAuth.authConditionA"/>
AND DELETE_FLAG = '0'
<include refid="HGXSDataAuth.authCondition"/>
<isNotEmpty prepend=" AND " property="id">
A.ID = #id#
ID = #id#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="bizType">
A.BIZ_TYPE = #bizType#
BIZ_TYPE = #bizType#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="bizId">
A.BIZ_ID = #bizId#
BIZ_ID = #bizId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="docId">
A.DOC_ID = #docId#
DOC_ID = #docId#
</isNotEmpty>
</sql>
<sql id="customCondition">
<include refid="condition"/>
<isNotEmpty prepend=" AND " property="docName">
DOC_NAME LIKE CONCAT('%', #docName#, '%')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdDateFrom">
A.CREATED_TIME &gt;= CONCAT(REPLACE(#createdDateFrom#, '-', ''), '000000')
CREATED_TIME &gt;= CONCAT(REPLACE(#createdDateFrom#, '-', ''), '000000')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdDateTo">
A.CREATED_TIME &lt;= CONCAT(REPLACE(#createdDateTo#, '-', ''), '235959')
</isNotEmpty>
</sql>
<!-- 本地 -->
<sql id="conditionLocal">
AND A.DOC_ID = B.DOC_ID
<include refid="customCondition"/>
<isNotEmpty prepend=" AND " property="docName">
B.DOC_NAME LIKE CONCAT('%', #docName#, '%')
</isNotEmpty>
</sql>
<!-- S3地址 -->
<sql id="conditionS3">
AND A.DOC_ID = B.RES_ID
<include refid="customCondition"/>
<isNotEmpty prepend=" AND " property="docName">
B.RES_CNAME LIKE CONCAT('%', #docName#, '%')
CREATED_TIME &lt;= CONCAT(REPLACE(#createdDateTo#, '-', ''), '235959')
</isNotEmpty>
</sql>
......@@ -78,46 +56,30 @@
$orderBy$
</isNotEmpty>
<isEmpty property="orderBy">
A.ID asc
ID DESC
</isEmpty>
</dynamic>
</sql>
<select id="queryLocal" resultClass="com.baosight.hggp.hg.dm.domain.HGDM099">
SELECT
<include refid="columnLocal"/>
FROM ${hggpSchema}.HGDM099 A, ${platSchema}.TEUDM02 B
WHERE 1=1
<include refid="conditionLocal"/>
<include refid="orderBy"/>
</select>
<select id="countLocal" resultClass="int">
SELECT COUNT(*)
FROM ${hggpSchema}.HGDM099 A, ${platSchema}.TEUDM02 B
WHERE 1=1
<include refid="conditionLocal"/>
</select>
<select id="queryS3" resultClass="com.baosight.hpjx.hp.dm.domain.HPDM099">
<select id="query" resultClass="com.baosight.hggp.hg.dm.domain.HGDM099">
SELECT
<include refid="columnS3"/>
FROM ${hggpSchema}.HGDM099 A, ${platSchema}.TEUDM05 B
<include refid="column"/>
FROM ${hggpSchema}.HGDM099
WHERE 1=1
<include refid="conditionS3"/>
<include refid="customCondition"/>
<include refid="orderBy"/>
</select>
<select id="countS3" resultClass="int">
<select id="count" resultClass="int">
SELECT COUNT(*)
FROM ${hggpSchema}.HGDM099 A, ${platSchema}.TEUDM05 B
FROM ${hggpSchema}.HGDM099
WHERE 1=1
<include refid="conditionS3"/>
<include refid="customCondition"/>
</select>
<insert id="insert">
INSERT INTO ${hggpSchema}.HGDM099 (
COMPANY_CODE, <!-- 企业编码 预留 -->
ACCOUNT_CODE, <!-- 企业编码 -->
DEP_CODE, <!-- 部门编码 -->
CREATED_BY, <!-- 创建人 -->
CREATED_NAME, <!-- 创建人名称 -->
......@@ -126,17 +88,62 @@
BIZ_TYPE, <!-- 业务类型 -->
BIZ_ID, <!-- 业务ID -->
DOC_ID, <!-- 文件ID -->
DOC_ID <!-- 文件名称 -->
DOC_NAME <!-- 文件名称 -->
) VALUES (
#companyCode#, #depCode#, #createdBy#, #createdName#, #createdTime#,
#accountCode#, #depCode#, #createdBy#, #createdName#, #createdTime#,
#deleteFlag#, #bizType#, #bizId#, #docId#, #docName#
)
</insert>
<delete id="deleteBizId">
UPDATE ${hggpSchema}.HGDM099
SET DELETE_FLAG = 1
WHERE BIZ_ID = #bizId#
</delete>
<delete id="delete">
UPDATE ${hggpSchema}.HGDM099
SET DELETE_FLAG = '1'
SET DELETE_FLAG = 1
WHERE ID = #id#
</delete>
<update id="update">
UPDATE ${hggpSchema}.HGDM099
SET
DOC_ID = #docId#, <!-- 文件ID -->
UPDATED_BY = #updatedBy#, <!-- 修改人 -->
UPDATED_NAME = #updatedName#, <!-- 修改人名称 -->
UPDATED_TIME = #updatedTime# <!-- 修改时间 -->
WHERE ID = #id#
</update>
<update id="batchUpdate">
UPDATE ${hggpSchema}.HGDM099
SET
BIZ_ID = #bizId#, <!-- 物料ID -->
UPDATED_BY = #updatedBy#, <!-- 修改人 -->
UPDATED_NAME = #updatedName#, <!-- 修改人名称 -->
UPDATED_TIME = #updatedTime# <!-- 修改时间 -->
WHERE DOC_ID IN <iterate close=")" open="(" conjunction="," property="docIds">#docIds[]#</iterate>
</update>
<!-- 预览自增 -->
<update id="previewIncr">
UPDATE ${hggpSchema}.HGDM099
SET
PREVIEW_NUM = PREVIEW_NUM + 1,
<include refid="SqlBase.updateRevise"/>
WHERE DOC_ID = #docId#
</update>
<!-- 下载自增 -->
<update id="downloadIncr">
UPDATE ${hggpSchema}.HGDM099
SET
DOWNLOAD_NUM = DOWNLOAD_NUM + 1,
<include refid="SqlBase.updateRevise"/>
WHERE DOC_ID = #docId#
</update>
</sqlMap>
......@@ -41,5 +41,13 @@ public class HpDmTools {
}
}
public static List<HGDM099> getByBizId(String bizType, String docId) {
AssertUtils.isEmpty(docId, "文件ID不能为空");
Map<String, Object> paramMap = new HashMap();
paramMap.put(HGDM099.FIELD_BIZ_TYPE, bizType);
paramMap.put(HGDM099.FIELD_DOC_ID, docId);
return DaoBase.getInstance().query("HGDM099.query", paramMap);
}
}
}
......@@ -12,7 +12,12 @@ import com.baosight.hggp.hg.kc.tools.HGKCTools;
import com.baosight.hggp.hg.kc.utils.HGKCUtils;
import com.baosight.hggp.hg.pz.domain.HGPZ004;
import com.baosight.hggp.hg.xs.domain.Company;
import com.baosight.hggp.util.*;
import com.baosight.hggp.util.AssertUtils;
import com.baosight.hggp.util.CommonMethod;
import com.baosight.hggp.util.EiInfoUtils;
import com.baosight.hggp.util.ErrorCodeUtils;
import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.ObjectUtils;
import com.baosight.hggp.util.contants.ACConstants;
import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiConstant;
......@@ -24,7 +29,11 @@ import com.baosight.iplat4j.ed.util.SequenceGenerator;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
......@@ -39,9 +48,10 @@ public class ServiceHGKC008 extends ServiceBase {
Map map = new HashMap();
map.put(HGKC008.FIELD_ACCOUNT_CODE, UserSessionUtils.getAccountCode());
CommonMethod.initBlock(inInfo,
Arrays.asList(DdynamicEnum.COMPANY_BOX_BLOCK_ID,DdynamicEnum.PROJ_RECORD_BY_ROLE_BLOCK_ID,DdynamicEnum.WH_RECORD_BOX_BLOCK_ID),map,false
Arrays.asList(DdynamicEnum.COMPANY_BOX_BLOCK_ID, DdynamicEnum.PROJ_RECORD_BY_ROLE_BLOCK_ID,
DdynamicEnum.WH_RECORD_BLOCK_ID), map, false
);
EiInfoUtils.addBlock(inInfo,"roleCompany", UserSessionUtils.getRoleCompany(), Company.class);
EiInfoUtils.addBlock(inInfo, "roleCompany", UserSessionUtils.getRoleCompany(), Company.class);
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
......
package com.baosight.hggp.hg.kc.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.common.InventTypeDetailEnum;
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.constant.HGSqlConstant;
import com.baosight.hggp.hg.kc.domain.HGKC008;
import com.baosight.hggp.hg.kc.domain.HGKC008A;
import com.baosight.hggp.hg.kc.domain.HGKC010;
import com.baosight.hggp.hg.kc.utils.HGKCUtils;
import com.baosight.hggp.hg.xs.domain.Company;
import com.baosight.hggp.util.AssertUtils;
import com.baosight.hggp.util.BeanUtils;
import com.baosight.hggp.util.CommonMethod;
import com.baosight.hggp.util.EiInfoUtils;
import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.MapUtils;
import com.baosight.hggp.util.contants.ACConstants;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
/**
* @author:songx
* @date:2024/5/9,11:04
*/
public class ServiceHGKC008B extends ServiceBase {
/**
* 画面初始化
*
* @param inInfo
* @return
*/
@Override
@OperationLogAnnotation(operModul = "综合库存", operType = "查询", operDesc = "初始化")
public EiInfo initLoad(EiInfo inInfo) {
try {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("inventTypeDetails", InventTypeDetailEnum.getInentTypeTwo());
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.COMPANY_CODE_BLOCK_ID));
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.INVENT_TYPE_BLOCK_ID), paramMap);
// CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.INVENT_RECORD_BLOCK_ID), paramMap);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.WH_RECORD_BLOCK_ID), null);
EiInfoUtils.addBlock(inInfo, "roleCompany", UserSessionUtils.getRoleCompany(), Company.class);
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HGKC010().eiMetadata);
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
return inInfo;
}
/**
* 查询操作
*
* @param inInfo
* @return
*/
@Override
@OperationLogAnnotation(operModul = "综合库存", operType = "查询", operDesc = "查询")
public EiInfo query(EiInfo inInfo) {
try {
Map queryRow = EiInfoUtils.getFirstRow(inInfo);
// inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0, "inventTypeDetails", InventTypeDetailEnum.getInentTypeTwo());
inInfo = super.query(inInfo, HGSqlConstant.HgKc010.QUERY_LY, new HGKC010());
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
}
return inInfo;
}
/**
* 确认操作.
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "实时库存", operType = "查询", operDesc = "确认")
public EiInfo confirm(EiInfo inInfo) {
try {
String receiveId = inInfo.getCellStr(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HGKC008A.FIELD_RECEIVE_ID);
List<HGKC010> hgkc010s = MapUtils.toDaoEPBases(inInfo, HGKC010.class);
// db数据
Map<Long, HGKC010> dbHgkc010Map = HGKCUtils.HgKc010.lockGetDataEp(hgkc010s);
List<HGKC008A> hgkc008AList = HGKCUtils.HgKc008A.listByPrimaryId(receiveId);
HGKC008 hgkc008 = HGKCUtils.HgKc008.get(receiveId);
// 数据校验
this.checkConfirmData(hgkc008AList, dbHgkc010Map,hgkc008);
// 保存数据
this.confirmData(dbHgkc010Map, hgkc008);
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + hgkc010s.size() + "]条数据保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
private void confirmData(Map<Long, HGKC010> dbHgkc010Map, HGKC008 hgkc008) {
List<HGKC008A> hgkc008AList = new LinkedList<>();
dbHgkc010Map.forEach((k,v) ->{
HGKC008A hgkc008A = new HGKC008A();
BeanUtils.copyProperties(hgkc008,hgkc008A,"id","createdBy","createdName","createdTime","updatedBy","updatedName","updatedTime");
hgkc008A.setReceiveId(hgkc008.getId());
hgkc008A.setInvLength(v.getLength());
hgkc008A.setInvThick(v.getThick());
hgkc008A.setInvUnitWeight(v.getInvUnitWeight());
hgkc008A.setInvWeight(v.getInvWeight());
hgkc008A.setInvWidth(v.getWidth());
hgkc008A.setInvSpec(v.getSpec());
hgkc008A.setInventType(v.getInventType());
hgkc008A.setInventTypeDetail(v.getInventTypeDetail());
hgkc008A.setInventCode(v.getInventCode());
hgkc008A.setInventName(v.getInventName());
hgkc008A.setInvQty(v.getInvQty());
hgkc008AList.add(hgkc008A);
});
DaoUtils.insertBatch(HGKC008A.INSERT, hgkc008AList);
}
private void checkConfirmData(List<HGKC008A> hgkc008AList, Map<Long, HGKC010> dbHgkc010Map, HGKC008 hgkc008) {
AssertUtils.isTrue(hgkc008.getStatus().compareTo(HGConstant.ProductStatus.YTJ) == 0, "领料单已提交,不可修改");
hgkc008AList.forEach(o -> {
dbHgkc010Map.forEach((k, v) -> {
AssertUtils.isTrue(o.getInventCode().equals(v.getInventCode()), "此领料单已选择存货:" + v.getInventCode());
});
});
}
}
......@@ -69,7 +69,7 @@
INVENT_CODE = #inventCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventName">
INVENT_NAME = #inventName#
INVENT_NAME LIKE CONCAT('%', #inventName#, '%')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="specId">
SPEC_ID = #specId#
......@@ -120,6 +120,30 @@
<include refid="BaseCondition.createdTimeCondition"/>
</sql>
<sql id="lyCondition">
<isNotEmpty prepend=" AND " property="accountCode">
ACCOUNT_CODE = #accountCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="depCode">
DEP_CODE = #depCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyCode">
COMPANY_CODE = #companyCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="whCode">
WH_CODE = #whCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventType">
INVENT_TYPE = #inventType#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventCode">
INVENT_CODE LIKE CONCAT('%', #inventCode#, '%')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventName">
INVENT_NAME LIKE CONCAT('%', #inventName#, '%')
</isNotEmpty>
</sql>
<sql id="orderBy">
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy">
......@@ -145,6 +169,20 @@
<include refid="condition"/>
</select>
<select id="queryLy" resultClass="com.baosight.hggp.hg.kc.domain.HGKC010">
SELECT
<include refid="column"/>
FROM ${hggpSchema}.HGKC010
WHERE 1=1
<include refid="lyCondition"/>
<include refid="orderBy"/>
</select>
<select id="countLy" resultClass="int">
SELECT COUNT(*) FROM ${hggpSchema}.HGKC010 WHERE 1=1
<include refid="lyCondition"/>
</select>
<select id="querySum" resultClass="com.baosight.hggp.hg.kc.domain.HGKC010">
SELECT
ACCOUNT_CODE as "accountCode", <!-- 企业编码 -->
......@@ -251,11 +289,22 @@
<!--仓库公司下拉框-->
<select id="queryWhCodeBox" resultClass="java.util.HashMap">
SELECT distinct
COMPANY_CODE as "companyCode", <!-- 公司编码 -->
COMPANY_NAME as "companyName", <!-- 公司名称 -->
WH_CODE as "whCode", <!-- 仓库编码 -->
WH_NAME as "whName" <!-- 仓库名称 -->
FROM ${hggpSchema}.HGKC010
A.COMPANY_CODE as "companyCode",
A.COMPANY_NAME as "companyName",
A.WH_CODE as "whCode",
A.WH_NAME as "whName",
B.wh_Type as "whType",
B.WH_TYPE_NAME as "whTypeName"
FROM ${hggpSchema}.HGKC010 A
left join (
select distinct
A.WH_CODE,
A.WH_NAME,
B.WH_TYPE,
B.WH_TYPE_NAME
FROM ${hggpSchema}.HGPZ007 A
INNER JOIN ${hggpSchema}.HGPZ006 B on A.WH_TYPE = B.WH_TYPE
) B on A.WH_CODE = B.wh_Code
WHERE 1=1
<include refid="condition"/>
</select>
......
......@@ -3,6 +3,7 @@ package com.baosight.hggp.hg.kc.utils;
import com.baosight.hggp.core.dao.DaoBase;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.enums.DeleteFlagEnum;
import com.baosight.hggp.hg.cg.domain.HGCG003B;
import com.baosight.hggp.hg.constant.HGSqlConstant;
import com.baosight.hggp.hg.kc.domain.*;
import com.baosight.hggp.hg.kc.tools.HGKCTools;
......@@ -15,11 +16,9 @@ import com.baosight.hggp.util.DateUtils;
import com.baosight.hggp.util.MapUtils;
import com.baosight.hggp.util.ObjectUtils;
import com.baosight.hggp.util.StringUtils;
import org.apache.commons.collections.CollectionUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -204,6 +203,52 @@ public class HGKCUtils {
queryRow.put(HGKC007.FIELD_OTHER_OUT_DATE, DateUtils.formatShort(otherOutDate));
}
}
/**
* 查询
*
* @param primaryId
* @return
*/
public static List<HGCG003B> listByPrimaryId(Long primaryId) {
AssertUtils.isNull(primaryId, "收货单id不能为空");
Map<String, Object> paramMap = new HashMap();
paramMap.put("primaryId", primaryId);
return DaoBase.getInstance().query(HGCG003B.QUERY, paramMap);
}
}
public static class HgKc008 {
/**
* 查询
*
* @param receiveId
* @return
*/
public static HGKC008 get(String receiveId) {
AssertUtils.isNull(receiveId, "领料单id不能为空");
Map<String, Object> paramMap = new HashMap();
paramMap.put("id", receiveId);
List<HGKC008> hgkc008List = DaoBase.getInstance().query(HGKC008.QUERY, paramMap);
return hgkc008List.get(0);
}
}
public static class HgKc008A {
/**
* 查询
*
* @param receiveId
* @return
*/
public static List<HGKC008A> listByPrimaryId(String receiveId) {
AssertUtils.isEmpty(receiveId, "领料单id不能为空");
Map<String, Object> paramMap = new HashMap();
paramMap.put("receiveId", receiveId);
return DaoBase.getInstance().query(HGKC008A.QUERY, paramMap);
}
}
/**
* HGKC010 工具类
......@@ -303,7 +348,7 @@ public class HGKCUtils {
*/
private static void addInvData(HGKC010 newKc010) {
// 公司
newKc010.setCompanyName(HGXSTools.XsOrg.get(newKc010.getCompanyCode()).getOrgCname());
newKc010.setCompanyName(HGXSTools.XsOrg.query(newKc010.getCompanyCode()).getOrgCname());
// 仓库
newKc010.setWhName(HGPZTools.HgPz007.get(newKc010.getWhCode()).getWhName());
// 规格
......@@ -493,7 +538,7 @@ public class HGKCUtils {
*/
private static void addInvData(HGKC011 newKc011) {
// 公司
newKc011.setCompanyName(HGXSTools.XsOrg.get(newKc011.getCompanyCode()).getOrgCname());
newKc011.setCompanyName(HGXSTools.XsOrg.query(newKc011.getCompanyCode()).getOrgCname());
// 仓库
newKc011.setWhName(HGPZTools.HgPz007.get(newKc011.getWhCode()).getWhName());
// 生产订单信息
......
......@@ -139,7 +139,7 @@ public class ServiceHGPZ009 extends ServiceBase {
// 默认新增企业管理员账号
String userId = fPz009.getLoginPrefix() + "0000";
HGXSTools.XsUser.addUser(fPz009.getAccountCode(), userId, fPz009.getAccountName(),
null, null);
null, null, null);
// 关联企业管理员角色
this.insertGroupMember(fPz009, userId);
// 新增组织机构顶级
......
......@@ -57,6 +57,21 @@ public class HGPZTools {
queryMap.put("status", status);
return DaoBase.getInstance().query(HGPZ002.QUERY, queryMap);
}
public static List<HGPZ002> list(List<Map> params,Integer status) {
if (status == null) {
return null;
}
Map queryMap = new HashMap<>();
queryMap.put("status", status);
if (CollectionUtils.isNotEmpty(params)){
queryMap.put("code", params.get(0));
queryMap.put("name", params.get(1));
}
//queryMap.put("param0", param.get(0));
return DaoBase.getInstance().query(HGPZ002.QUERY, queryMap);
}
}
public static class HgPz003 {
......@@ -134,6 +149,20 @@ public class HGPZTools {
}
public static class HgPz006 {
public static HGPZ006 getWhCode(String wHCode) {
HGPZ007 pz007 = HGPZTools.HgPz007.get(wHCode);
if (pz007 == null) {
return null;
}
Map queryMap = new HashMap();
queryMap.put(HGPZ006.FIELD_WH_TYPE, pz007.getWhType());
List<HGPZ006> results = DaoBase.getInstance().query(HGPZ006.QUERY, queryMap);
return CollectionUtils.isEmpty(results) ? null : results.get(0);
}
}
/**
* 仓库管理
* HPPZ007 公共DAO定义
......
......@@ -16,5 +16,7 @@ public class HgScSqlConstant {
// 德诚修改
public static final String UPDATE_FOR_DC = "HGSC001.updateForDc";
// 修改项目名称
public static final String UPDATE_PROJ_NAME = "HGSC001.updateProjName";
}
}
package com.baosight.hggp.hg.sc.service;
import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.extapp.decheng.api.DcOpenApi;
import com.baosight.hggp.core.extapp.decheng.model.DcContractList;
import com.baosight.hggp.core.utils.ThreadUtils;
import com.baosight.hggp.hg.pz.domain.HGPZ009;
import com.baosight.hggp.hg.pz.tools.HGPZTools;
import com.baosight.hggp.hg.sc.constant.HgScSqlConstant;
import com.baosight.hggp.hg.sc.domain.HGSC001;
import com.baosight.hggp.hg.sc.tools.HGSCTools;
import com.baosight.hggp.util.AssertUtils;
import com.baosight.hggp.util.EiInfoUtils;
import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.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 org.apache.commons.collections.CollectionUtils;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
/**
* 项目管理
*
* @author:songx
* @date:2022/7/11,11:08
*/
@Slf4j
public class ServiceHGSC101 extends ServiceEPBase {
/**
......@@ -74,4 +87,82 @@ public class ServiceHGSC101 extends ServiceEPBase {
return inInfo;
}
/**
* 同步智邦合同信息
*
* @param inInfo
* @return
*/
public EiInfo syncDcContract(EiInfo inInfo) {
try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
String accountCode = MapUtils.getString(queryMap, HGPZ009.FIELD_ACCOUNT_CODE);
AssertUtils.isEmpty(accountCode, "企业编码不能为空");
ThreadUtils.FIXED_THREAD.execute(() -> {
try {
syncDcContractData(accountCode);
} catch (Exception e) {
log.error("同步智邦合同信息失败:{}", e.getMessage(), e);
}
});
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsg("同步智邦合同信息成功");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "同步智邦合同信息失败");
}
return inInfo;
}
/**
* 同步智邦合同信息
*
* @param accountCode
*/
private void syncDcContractData(String accountCode) throws IOException {
int pageIndex = 1;
while (true) {
// 超过1000次不在执行
if (pageIndex > 1000) {
break;
}
List<DcContractList> zbContracts = DcOpenApi.contactList(pageIndex);
if (CollectionUtils.isEmpty(zbContracts)) {
break;
}
// 写入合同数据
saveContractData(accountCode, zbContracts);
pageIndex++;
}
}
/**
* 写入合同信息
*
* @param accountCode
* @param zbContracts
*/
private void saveContractData(String accountCode, List<DcContractList> zbContracts) {
// 查询帐套信息
HGPZ009 dbPz009 = HGPZTools.HgPz009.getByCode(accountCode);
String prefix = dbPz009.getLoginPrefix();
for (DcContractList zbContract : zbContracts) {
String projCode = prefix + zbContract.getOrd();
HGSC001 dbSc001 = HGSCTools.Hgsc001.queryByCode(projCode);
if (dbSc001 == null) {
dbSc001 = new HGSC001();
dbSc001.setAccountCode(accountCode);
dbSc001.setDepCode(accountCode);
dbSc001.setDepName(dbPz009.getAccountName());
dbSc001.setProjCode(projCode);
dbSc001.setProjName(zbContract.getTitle());
DaoUtils.insert(HGSC001.INSERT, dbSc001);
} else {
Map updateMap = new HashMap();
updateMap.put(HGSC001.FIELD_proj_code, projCode);
updateMap.put(HGSC001.FIELD_proj_name, zbContract.getTitle());
DaoUtils.insert(HgScSqlConstant.HgSc001.UPDATE_PROJ_NAME, dbSc001);
}
}
}
}
......@@ -90,6 +90,14 @@
</isNotEmpty>
</sql>
<sql id="customCondition">
<include refid="condition"/>
<isNotEmpty prepend=" AND " property="projCodes">
PROJ_CODE IN
<iterate close=")" open="(" conjunction="," property="projCodes">#projCodes[]#</iterate>
</isNotEmpty>
</sql>
<select id="query" resultClass="com.baosight.hggp.hg.sc.domain.HGSC001">
SELECT
id as "id",
......@@ -121,7 +129,7 @@
updated_name as "updatedName", <!-- 修改人名称 -->
updated_time as "updatedTime" <!-- 更新时间 -->
FROM ${hggpSchema}.HGSC001 WHERE 1=1
<include refid="condition" />
<include refid="customCondition" />
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy">
$orderBy$
......@@ -130,12 +138,11 @@
id desc
</isEmpty>
</dynamic>
</select>
<select id="count" resultClass="int">
SELECT COUNT(*) FROM ${hggpSchema}.HGSC001 WHERE 1=1
<include refid="condition"/>
<include refid="customCondition"/>
</select>
<insert id="insert">
......@@ -301,4 +308,13 @@
WHERE PROJ_CODE = #projCode#
</update>
<!-- 修改项目名称 -->
<update id="updateProjName">
UPDATE ${hggpSchema}.HGSC001
SET
PROJ_NAME = #projName#,
<include refid="SqlBase.updateRevise"/>
WHERE PROJ_CODE = #projCode#
</update>
</sqlMap>
......@@ -188,8 +188,19 @@ public class HGSCTools {
}
}
/**
* 项目信息
*
* @author:songx
* @date:2024/8/28,17:40
*/
public static class Hgsc001 {
/**
*
* @param code
* @return
*/
public static HGSC001 queryByCode(String code) {
AssertUtils.isNull(code, "项目Code不能为空!");
List<HGSC001> results = DaoBase.getInstance().query(HGSC001.QUERY, new HashMap<String,Object>(){
......@@ -197,6 +208,17 @@ public class HGSCTools {
});
return CollectionUtils.isEmpty(results) ? null : results.get(0);
}
/**
* @param projCodes
* @return
*/
public static List<HGSC001> queryByCode(List<String> projCodes) {
AssertUtils.isEmpty(projCodes, "项目Code不能为空!");
Map queryMap = new HashMap();
queryMap.put("projCodes", projCodes);
return DaoBase.getInstance().query(HGSC001.QUERY, queryMap);
}
}
public static class Hgsc003 {
......
......@@ -316,12 +316,14 @@
<select id="queryCompany" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
select DISTINCT
a.ORG_ENAME as "orgEname",
a.ORG_CNAME as "orgCname"
a.ORG_CNAME as "orgCname",
a.PARENT_ORG_ID as "parentOrgId",
a.ORG_TYPE as "orgType"
from ${platSchema}.txsog01 a
<isNotEmpty property="userId">
left join ${platSchema}.txsog02 b on a.ORG_ID = b.ORG_ID
</isNotEmpty>
where a.IS_DELETED = 0
where a.IS_DELETED = 0 AND A.PARENT_ORG_ID NOT IN ('root')
<isNotEmpty prepend=" AND " property="accountCode">
a.ACCOUNT_CODE = #accountCode#
</isNotEmpty>
......
package com.baosight.hggp.hg.wd.constant;
import javax.print.DocFlavor;
/**
* @author:songx
* @date:2024/8/16,15:51
......@@ -20,4 +22,18 @@ public class HgWdConstant {
public static final Integer S_1 = 1;
}
/**
* 树节点类型
*
* @author:songx
* @date:2024/8/28,16:27
*/
public static class LeafType {
// 项目
public static final String P = "P";
// 目录
public static final String C = "C";
}
}
......@@ -14,6 +14,10 @@ public class HgWdSqlConstant {
*/
public static class HgWd001 {
// 根据父节点统计
public static final String COUNT_BY_PARENT = "HGWD001.countByParent";
// 搜索树节点
public static final String SEARCH_TREE_NODE = "HGWD001.searchTreeNode";
}
}
......@@ -35,6 +35,8 @@ public class HGWD001 extends DaoEPBase {
public static final String FIELD_COMPANY_NAME = "companyName"; /* 公司名称*/
public static final String FIELD_PROJ_CODE = "projCode"; /* 项目编码*/
public static final String FIELD_PROJ_NAME = "projName"; /* 项目名称*/
public static final String FIELD_LEAF_LEVEL = "leafLevel"; /* 节点层级*/
public static final String FIELD_PARENT_ID = "parentId"; /* 父级ID*/
public static final String FIELD_FILE_ID = "fileId"; /* 文件ID*/
public static final String FIELD_FILE_TYPE = "fileType"; /* 文件类型*/
public static final String FIELD_FILE_NAME = "fileName"; /* 文件名称*/
......@@ -57,6 +59,8 @@ public class HGWD001 extends DaoEPBase {
public static final String COL_COMPANY_NAME = "COMPANY_NAME"; /* 公司名称*/
public static final String COL_PROJ_CODE = "PROJ_CODE"; /* 项目编码*/
public static final String COL_PROJ_NAME = "PROJ_NAME"; /* 项目名称*/
public static final String COL_PARENT_ID = "PARENT_ID"; /* 节点层级*/
public static final String COL_LEAF_LEVEL = "LEAF_LEVEL"; /* 父级ID*/
public static final String COL_FILE_ID = "FILE_ID"; /* 文件ID*/
public static final String COL_FILE_TYPE = "FILE_TYPE"; /* 文件类型*/
public static final String COL_FILE_NAME = "FILE_NAME"; /* 文件名称*/
......@@ -86,6 +90,8 @@ public class HGWD001 extends DaoEPBase {
private String companyName = " "; /* 公司名称*/
private String projCode = " "; /* 项目编码*/
private String projName = " "; /* 项目名称*/
private Integer leafLevel = new Integer(0);
private String parentId = " ";
private String fileId = " "; /* 文件ID*/
private String fileType = " "; /* 文件类型*/
private String fileName = " "; /* 文件名称*/
......@@ -157,6 +163,14 @@ public class HGWD001 extends DaoEPBase {
eiColumn.setDescName("项目名称");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_LEAF_LEVEL);
eiColumn.setDescName("节点层级");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_PARENT_ID);
eiColumn.setDescName("父级ID");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_FILE_ID);
eiColumn.setDescName("文件ID");
eiMetadata.addMeta(eiColumn);
......@@ -419,6 +433,37 @@ public class HGWD001 extends DaoEPBase {
public void setProjName(String projName) {
this.projName = projName;
}
/**
* get the leafLevel - 层级
* @return 层级
*/
public Integer getLeafLevel() {
return leafLevel;
}
/**
* set the leafLevel - 层级
* @param leafLevel - 层级
*/
public void setLeafLevel(Integer leafLevel) {
this.leafLevel = leafLevel;
}
/**
* get the parentId - 父级
* @return 父级
*/
public String getParentId() {
return parentId;
}
/**
* set the parentId - 层级
* @param parentId - 层级
*/
public void setParentId(String parentId) {
this.parentId = parentId;
}
/**
* get the fileId - 文件ID.
* @return the fileId
......@@ -553,6 +598,8 @@ public class HGWD001 extends DaoEPBase {
setCompanyName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_COMPANY_NAME)), companyName));
setProjCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_PROJ_CODE)), projCode));
setProjName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_PROJ_NAME)), projName));
setLeafLevel(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_LEAF_LEVEL)), leafLevel));
setParentId(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_PARENT_ID)), parentId));
setFileId(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_FILE_ID)), fileId));
setFileType(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_FILE_TYPE)), fileType));
setFileName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_FILE_NAME)), fileName));
......@@ -583,6 +630,8 @@ public class HGWD001 extends DaoEPBase {
map.put(FIELD_COMPANY_NAME, StringUtils.toString(companyName, eiMetadata.getMeta(FIELD_COMPANY_NAME)));
map.put(FIELD_PROJ_CODE, StringUtils.toString(projCode, eiMetadata.getMeta(FIELD_PROJ_CODE)));
map.put(FIELD_PROJ_NAME, StringUtils.toString(projName, eiMetadata.getMeta(FIELD_PROJ_NAME)));
map.put(FIELD_LEAF_LEVEL, StringUtils.toString(leafLevel, eiMetadata.getMeta(FIELD_LEAF_LEVEL)));
map.put(FIELD_PARENT_ID, StringUtils.toString(parentId, eiMetadata.getMeta(FIELD_PARENT_ID)));
map.put(FIELD_FILE_ID, StringUtils.toString(fileId, eiMetadata.getMeta(FIELD_FILE_ID)));
map.put(FIELD_FILE_TYPE, StringUtils.toString(fileType, eiMetadata.getMeta(FIELD_FILE_TYPE)));
map.put(FIELD_FILE_NAME, StringUtils.toString(fileName, eiMetadata.getMeta(FIELD_FILE_NAME)));
......
......@@ -2,27 +2,21 @@ package com.baosight.hggp.hg.wd.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.common.ChangeTypeEnum;
import com.baosight.hggp.common.CompanyTypeEnum;
import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.dao.DaoBase;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.enums.OrgTypeEnum;
import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.core.utils.Iplat4jUtils;
import com.baosight.hggp.core.tools.Iplat4jTools;
import com.baosight.hggp.hg.constant.HGConstant;
import com.baosight.hggp.hg.cw.domain.HGCW999;
import com.baosight.hggp.hg.cw.tools.HGCWTools;
import com.baosight.hggp.hg.sb.domain.HGSB001;
import com.baosight.hggp.hg.sb.domain.HGSB003;
import com.baosight.hggp.hg.sj.domain.HGSJ002;
import com.baosight.hggp.hg.dm.domain.HGDM099;
import com.baosight.hggp.hg.dm.tools.HpDmTools;
import com.baosight.hggp.hg.wd.constant.HgWdConstant;
import com.baosight.hggp.hg.wd.domain.HGWD001;
import com.baosight.hggp.hg.wd.domain.HGWD001A;
import com.baosight.hggp.hg.wd.tools.HGWDTools;
import com.baosight.hggp.hg.xs.domain.Company;
import com.baosight.hggp.hg.xs.domain.Org;
import com.baosight.hggp.hg.xs.domain.User;
import com.baosight.hggp.util.*;
import com.baosight.hggp.util.contants.ACConstants;
import com.baosight.iplat4j.core.ei.EiBlock;
......@@ -80,15 +74,17 @@ public class ServiceHGWD001 extends ServiceEPBase {
hgwd001.setDeleteFlag(CommonConstant.YesNo.YES_1);
Map map1 = new HashMap();
map1.put(HGWD001A.FIELD_MAT_ID, hgwd001.getId());
List<HGWD001A> hgwd001AList = DaoBase.getInstance().query(HGWD001A.QUERY, map1);
/*List<HGWD001A> hgwd001AList = DaoBase.getInstance().query(HGWD001A.QUERY, map1);
for (HGWD001A hgwd001A:hgwd001AList) {
if (hgwd001A.getChangeType().equals(ChangeTypeEnum.UPLOAD_ADD.getCode())
|| hgwd001A.getChangeType().equals(ChangeTypeEnum.UPLOAD_DELETE.getCode())) {
Iplat4jUtils.deleteFileByDocId(hgwd001A.getChangeStart());
}
}
DaoUtils.update("HGCW999.deleteMatId", map1); //删除附件记录
DaoUtils.update(HGWD001A.DELETE_MAT_ID, map1); //删除变更记录
}*/
DaoUtils.update("HGDM099.deleteBizId",
new HashMap<String,String>(){{put(HGDM099.FIELD_BIZ_ID, hgwd001.getId().toString());}}); //删除附件记录
//DaoUtils.update(HGWD001A.DELETE_MAT_ID, map1); //删除变更记录
hgwd001.setStatus(HgWdConstant.FileStatus.S_0);
DaoUtils.update(HGWD001.DELETE, hgwd001);
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
......@@ -106,14 +102,16 @@ public class ServiceHGWD001 extends ServiceEPBase {
public EiInfo save(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
List<Map<String, Object>> edcm01List = Iplat4jTools.EdCm01.list("hggp.hgwd.fileType");
// 写入数据
for (Map resultRow : resultRows) {
HGWD001 hgwd001 = new HGWD001();
hgwd001.fromMap(resultRow);
hgwd001.setStatus(HgWdConstant.FileStatus.S_0);
if (hgwd001.getId() == null || hgwd001.getId() == 0) {
this.add(hgwd001);
} else {
this.modify(hgwd001);
this.modify(hgwd001,edcm01List);
}
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
......@@ -146,7 +144,7 @@ public class ServiceHGWD001 extends ServiceEPBase {
/**
* 修改操作
*/
public void modify(HGWD001 hgwd001) {
public void modify(HGWD001 hgwd001,List<Map<String, Object>> edcm01List) {
HGWD001 wd001 =HGWDTools.HgWd001.get(hgwd001.getId());
HGWD001A hgwd001a = new HGWD001A();
hgwd001a.setCompanyCode(hgwd001.getCompanyCode());
......@@ -161,9 +159,11 @@ public class ServiceHGWD001 extends ServiceEPBase {
hgwd001a.setChangeEnd(hgwd001.getFileName());
HGWDTools.HgWd001.add(hgwd001a);
}else if (wd001 != null && !wd001.getFileType().equals(hgwd001.getFileType())){
List<Map> fileType1 = edcm01List.stream().filter(map -> map.get("itemCode").equals(wd001.getFileType())).collect(Collectors.toList());
List<Map> fileType2 = edcm01List.stream().filter(map -> map.get("itemCode").equals(hgwd001.getFileType())).collect(Collectors.toList());
hgwd001a.setChangeContent("文件类型");
hgwd001a.setChangeStart(wd001.getFileType());
hgwd001a.setChangeEnd(hgwd001.getFileType());
hgwd001a.setChangeStart(fileType1.get(0).get("itemCname").toString());
hgwd001a.setChangeEnd(fileType2.get(0).get("itemCname").toString());
HGWDTools.HgWd001.add(hgwd001a);
}
......@@ -206,5 +206,94 @@ public class ServiceHGWD001 extends ServiceEPBase {
return inInfo;
}
@OperationLogAnnotation(operModul = "文档库",operType = "修改",operDesc = "文档库-附件清单A-修改附件操作")
public EiInfo updateFile(EiInfo inInfo) {
try {
String ndocId = inInfo.getCellStr(EiConstant.resultBlock, ACConstants.ROW_CODE_0, "ndocId");
List<HGDM099> hgdm099s = HpDmTools.HpDm099.getByBizId("WD",ndocId);
for (HGDM099 hgdm099:hgdm099s) {
DaoUtils.update(HGDM099.DELETE, hgdm099);
HGWD001 hgwd001 = HGWDTools.HgWd001.get(hgdm099.getBizId());
if (hgwd001 != null) {
HGWD001A hgwd001a =initHgwd001a(hgwd001, hgdm099,ChangeTypeEnum.DELETE.getCode());
HGWDTools.HgWd001.add(hgwd001a);
hgwd001.setStatus(HgWdConstant.FileStatus.S_0);
HGWDTools.HgWd001.updateStatus(hgwd001);
}
}
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
for (Map resultRow : resultRows) {
HGDM099 hgdm099 = new HGDM099();
hgdm099.fromMap(resultRow);
hgdm099.setDeleteFlag(CommonConstant.YesNo.NO_0);
DaoUtils.insert(HGDM099.INSERT, hgdm099);
HGWD001 hgwd001 =HGWDTools.HgWd001.get(hgdm099.getBizId());
if (hgwd001 != null) {
HGWD001A hgwd001a =initHgwd001a(hgwd001, hgdm099,ChangeTypeEnum.ADD.getCode());
HGWDTools.HgWd001.add(hgwd001a);
hgwd001.setStatus(HgWdConstant.FileStatus.S_0);
HGWDTools.HgWd001.updateStatus(hgwd001);
}
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据新增成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "新增失败");
}
return inInfo;
}
public HGWD001A initHgwd001a(HGWD001 hgwd001,HGDM099 hgdm099,String type){
HGWD001A hgwd001a = new HGWD001A();
hgwd001a.setCompanyCode(hgwd001.getCompanyCode());
hgwd001a.setCompanyName(hgwd001.getCompanyName());
hgwd001a.setProjCode(hgwd001.getProjCode());
hgwd001a.setProjName(hgwd001.getProjName());
if (ChangeTypeEnum.ADD.getCode().equals(type)){
hgwd001a.setChangeType(ChangeTypeEnum.UPLOAD_ADD.getCode());
hgwd001a.setChangeContent("上传附件");
}else if (ChangeTypeEnum.DELETE.getCode().equals(type)){
hgwd001a.setChangeType(ChangeTypeEnum.UPLOAD_DELETE.getCode());
hgwd001a.setChangeContent("删除附件");
}
hgwd001a.setChangeEnd(hgdm099.getDocName());
hgwd001a.setChangeStart(hgdm099.getDocId());
hgwd001a.setMatId(hgwd001.getId());
return hgwd001a;
}
/**
* 删除组织及子节点
*
* @param inInfo
* @return
*/
public EiInfo deleteOrgAndChildrenById(EiInfo inInfo) {
try {
List<Map> rows = inInfo.getBlock(EiConstant.resultBlock).getRows();
Map idMap = new HashMap();
int sum = 0;
for (int i = 0; i < rows.size(); ++i) {
String orgId = rows.get(i).get("fileId").toString();
Map orgIdMap = new HashMap();
orgIdMap.put("parentId", orgId);
List orgIdChildList = this.dao.query("HGWD001.queryFileChild", orgIdMap);
for (int j = 0; j < orgIdChildList.size(); ++j) {
Map childMap = ((Map) orgIdChildList.get(j));
String childOrgId = childMap.get("id").toString();
idMap.put("id", childOrgId);
this.dao.update("HGWD001.delete", idMap);
Map memberMap = new HashMap();
memberMap.put(HGDM099.FIELD_BIZ_ID, ((Map) orgIdChildList.get(j)).get("fileId"));
DaoUtils.update("HGDM099.deleteBizId",memberMap); //删除附件记录
++sum;
}
}
inInfo.setMsg("删除[" + sum + "]条记录成功");
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "删除失败");
}
return inInfo;
}
}
package com.baosight.hggp.hg.wd.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.hg.cw.tools.HGCWTools;
import com.baosight.hggp.hg.wd.constant.HgWdConstant;
import com.baosight.hggp.hg.wd.domain.HGWD001;
import com.baosight.hggp.hg.wd.domain.HGWD001B;
import com.baosight.hggp.hg.wd.domain.HGWD002;
import com.baosight.hggp.hg.wd.tools.HGWDTools;
import com.baosight.hggp.util.CommonMethod;
import com.baosight.hggp.util.EiInfoUtils;
import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.MapUtils;
......@@ -19,7 +15,6 @@ import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
......
......@@ -3,8 +3,6 @@ package com.baosight.hggp.hg.wd.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.hg.cw.tools.HGCWTools;
import com.baosight.hggp.hg.wd.domain.HGWD001;
import com.baosight.hggp.hg.wd.domain.HGWD001B;
import com.baosight.hggp.hg.wd.domain.HGWD001C;
import com.baosight.hggp.hg.wd.domain.HGWD002;
import com.baosight.hggp.hg.wd.tools.HGWDTools;
......
package com.baosight.hggp.hg.wd.service;
import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.dao.DaoBase;
import com.baosight.hggp.core.enums.OrgTypeEnum;
import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.hg.sc.domain.HGSC001;
import com.baosight.hggp.hg.xs.domain.Org;
import com.baosight.hggp.hg.xs.tools.HGXSTools;
import com.baosight.iplat4j.core.ei.*;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.ef.ui.tree.TreeService;
import com.baosight.xservices.xs.service.ServiceXSTreeNode;
import com.baosight.xservices.xs.util.LoginUserDetails;
import org.apache.commons.lang.StringUtils;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author LiuYang
* @version 1.0 2024/8/29
* @description 文件库树
*/
public class ServiceHGWD001D extends TreeService {
private EiBlockMeta eiMetadata = null;
public ServiceHGWD001D() {
}
@Override
public List getTopNodes() {
HashMap<String, String> map = new HashMap();
List<HashMap> list = new ArrayList();
String accountCode = UserSessionUtils.getAccountCode();
if (StringUtils.isEmpty(accountCode) || CommonConstant.Field.ADMIN.equals(accountCode)) {
map.put("label", "root");
map.put("text", "组织机构");
list.add(map);
} else {
//Org org = HGXSTools.XsOrg.get(accountCode);
List<HGSC001> hgsc001List = DaoBase.getInstance().query("HGSC001.query", new HashMap<String,String>(){{put("accountCode", accountCode);}}, 0, -999999);
//map.put("label", org == null ? "root" : org.getOrgId());
//map.put("text", org == null ? "文档库" : org.getOrgCname());
for (HGSC001 hgsc001 : hgsc001List) {
HashMap<String,String> hashMap = new HashMap<>();
hashMap.put("label", hgsc001.getProjCode());
hashMap.put("text", hgsc001.getProjName());
hashMap.put("projCode", hgsc001.getProjCode());
hashMap.put("projName", hgsc001.getProjName());
hashMap.put("type", "1");
hashMap.put("leaf", "0");
hashMap.put("leafLevel", "0");
hashMap.put("parentId", "0");
list.add(hashMap);
}
}
return list;
}
@Override
public List getChildNodes(String parentLabel) {
if (StringUtils.isEmpty(parentLabel) || "$".equals(parentLabel)) {
parentLabel = "root";
}
Map queryMap = new HashMap();
queryMap.put("node", parentLabel);
// 非管理员仅查询所属企业用户 added by songx at 2024-01-16
queryMap.put("accountCode", LoginUserDetails.isUserAdmin(UserSessionUtils.getLoginName())
? null : UserSessionUtils.getAccountCode());
queryMap.put("userId", LoginUserDetails.isUserAdmin(UserSessionUtils.getLoginName())
? null : UserSessionUtils.getUserId());
List<Map> ret = this.dao.query("HGWD001.queryOrganiation", queryMap, 0, -999999);
Map parentOrgMap = new HashMap();
String orgId;
for(int i = 0; i < ret.size(); ++i) {
Map org = (Map)ret.get(i);
orgId = (String)org.get("parentId");
if (parentOrgMap.get(orgId) == null) {
parentOrgMap.put(orgId, new ArrayList());
}
((List)parentOrgMap.get(orgId)).add(org);
}
List result = (List)parentOrgMap.get(parentLabel);
if(CollectionUtils.isEmpty(result)){
return result;
}
for(int i = 0; i < result.size(); ++i) {
orgId = (String)((Map)result.get(i)).get("label");
String hasChild = parentOrgMap.get(orgId) != null ? "2" : "1";
// ((Map)result.get(i)).put("leaf", hasChild);
((Map)result.get(i)).put("leaf", "0");
}
return result;
}
public EiInfo search(EiInfo inInfo) {
EiInfo outInfo = new EiInfo();
try {
outInfo = super.query(inInfo, "XSOG0100.search");
} catch (PlatException var5) {
var5.printStackTrace();
EiBlock block = new EiBlock(EiConstant.resultBlock);
outInfo.setBlock(block);
}
return outInfo;
}
public EiInfo expandPath(EiInfo inInfo) {
EiInfo outInfo = super.query(inInfo, "XSOG0100.expandPath");
return outInfo;
}
@Override
public EiBlockMeta initMetaData() {
if (this.eiMetadata == null) {
this.eiMetadata = new EiBlockMeta();
EiColumn eiColumn = new EiColumn("label");
eiColumn.setDescName("label");
eiColumn.setNullable(false);
eiColumn.setPrimaryKey(false);
this.eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("parent");
eiColumn.setDescName("parent");
eiColumn.setNullable(false);
eiColumn.setPrimaryKey(false);
this.eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("text");
eiColumn.setDescName("text");
eiColumn.setNullable(false);
eiColumn.setPrimaryKey(false);
this.eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("leaf");
eiColumn.setDescName("leaf");
eiColumn.setType(EiConstant.COLUMN_TYPE_NUMBER);
eiColumn.setNullable(false);
eiColumn.setPrimaryKey(false);
this.eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("companyCode");
eiColumn.setDescName("companyCode");
eiColumn.setNullable(false);
eiColumn.setPrimaryKey(false);
this.eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("projCode");
eiColumn.setDescName("projCode");
eiColumn.setNullable(false);
eiColumn.setPrimaryKey(false);
this.eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("leafLevel");
eiColumn.setDescName("leafLevel");
eiColumn.setNullable(false);
eiColumn.setPrimaryKey(false);
this.eiMetadata.addMeta(eiColumn);
}
return this.eiMetadata;
}
public EiInfo searchNodePath(EiInfo inInfo) {
String leafName = (String)inInfo.get("leafName");
Map map = new HashMap();
List queryNodeList = this.dao.query("XSOG01.queryOrganiation", map);
List nodeList = new ArrayList();
Iterator var6 = queryNodeList.iterator();
while(var6.hasNext()) {
Object node = var6.next();
String parentId = (String)((HashMap)node).get("parentOrgId");
if (!"".equals(parentId.trim())) {
((HashMap)node).put("parentId", parentId);
nodeList.add(node);
}
}
ServiceXSTreeNode root = ServiceXSTreeNode.buildTree(nodeList);
List allPath = ServiceXSTreeNode.findAllPath(root, nodeList, leafName);
inInfo.set("allPath", allPath);
return inInfo;
}
}
package com.baosight.hggp.hg.wd.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.common.ChangeTypeEnum;
import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.enums.OrgTypeEnum;
import com.baosight.hggp.core.tools.Iplat4jTools;
import com.baosight.hggp.hg.constant.HGConstant;
import com.baosight.hggp.hg.wd.constant.HgWdConstant;
import com.baosight.hggp.hg.wd.domain.HGWD001;
import com.baosight.hggp.hg.wd.domain.HGWD001A;
import com.baosight.hggp.hg.wd.tools.HGWDTools;
import com.baosight.hggp.hg.xs.domain.Org;
import com.baosight.hggp.util.CommonMethod;
import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.contants.ACConstants;
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.ed.util.SequenceGenerator;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author LiuYang
* @version 1.0 2024/8/29
* @description 新增文档库
*/
public class ServiceHGWD001E extends ServiceEPBase {
@Override
public EiInfo initLoad(EiInfo inInfo) {
try {
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.PROJ_RECORD_BLOCK_ID));
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.COMPANY_BOX_BLOCK_ID),new HashMap<String,Object>(){{
put(Org.FIELD_ORG_TYPE, OrgTypeEnum.COMPANY.getCode());
}});
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HGWD001().eiMetadata);
}catch (Exception e){
LogUtils.setMsg(inInfo,e,"初始化失败");
}
return inInfo;
}
@Override
public EiInfo query(EiInfo inInfo) {
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HGWD001.FIELD_DELETE_FLAG, CommonConstant.YesNo.NO_0);
/*String parentId = inInfo.getCellStr(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HGWD001.FIELD_PARENT_ID);
if (parentId.indexOf("Q")==0){
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HGWD001.FIELD_ACCOUNT_CODE, parentId);
}else if (parentId.indexOf("R")==0){
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HGWD001.FIELD_COMPANY_CODE, parentId);
}*/
return super.query(inInfo, HGWD001.QUERY,new HGWD001());
}
/**
* 保存操作
*/
@OperationLogAnnotation(operModul = "文档库",operType = "保存",operDesc = "保存操作")
public EiInfo save(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
List<Map<String, Object>> edcm01List = Iplat4jTools.EdCm01.list("hggp.hgwd.fileType");
// 写入数据
for (Map resultRow : resultRows) {
HGWD001 hgwd001 = new HGWD001();
hgwd001.fromMap(resultRow);
hgwd001.setStatus(HgWdConstant.FileStatus.S_0);
if (hgwd001.getId() == null || hgwd001.getId() == 0) {
this.add(hgwd001);
} else {
this.modify(hgwd001,edcm01List);
}
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
/**
* 新增操作
*/
public void add(HGWD001 hgwd001) {
hgwd001.setFileId(SequenceGenerator.getNextSequence(HGConstant.SequenceId.WD_FILE_ID));
hgwd001.setDocVersion(hgwd001.getDocVersion() + 1);
DaoUtils.insert(HGWD001.INSERT, hgwd001);
HGWD001A hgwd001a = new HGWD001A();
hgwd001a.setCompanyCode(hgwd001.getCompanyCode());
hgwd001a.setCompanyName(hgwd001.getCompanyName());
hgwd001a.setProjCode(hgwd001.getProjCode());
hgwd001a.setProjName(hgwd001.getProjName());
hgwd001a.setChangeType(ChangeTypeEnum.ADD.getCode());
hgwd001a.setChangeContent("文件名称");
hgwd001a.setChangeEnd(hgwd001.getFileName());
hgwd001a.setMatId(hgwd001.getId());
HGWDTools.HgWd001.add(hgwd001a);
}
/**
* 修改操作
*/
public void modify(HGWD001 hgwd001,List<Map<String, Object>> edcm01List) {
HGWD001 wd001 =HGWDTools.HgWd001.get(hgwd001.getId());
HGWD001A hgwd001a = new HGWD001A();
hgwd001a.setCompanyCode(hgwd001.getCompanyCode());
hgwd001a.setCompanyName(hgwd001.getCompanyName());
hgwd001a.setProjCode(hgwd001.getProjCode());
hgwd001a.setProjName(hgwd001.getProjName());
hgwd001a.setChangeType(ChangeTypeEnum.UPDATE.getCode());
hgwd001a.setMatId(hgwd001.getId());
if (wd001 != null && !wd001.getFileName().equals(hgwd001.getFileName())){
hgwd001a.setChangeContent("文件名称");
hgwd001a.setChangeStart(wd001.getFileName());
hgwd001a.setChangeEnd(hgwd001.getFileName());
HGWDTools.HgWd001.add(hgwd001a);
}else if (wd001 != null && !wd001.getFileType().equals(hgwd001.getFileType())){
List<Map> fileType1 = edcm01List.stream().filter(map -> map.get("itemCode").equals(wd001.getFileType())).collect(Collectors.toList());
List<Map> fileType2 = edcm01List.stream().filter(map -> map.get("itemCode").equals(hgwd001.getFileType())).collect(Collectors.toList());
hgwd001a.setChangeContent("文件类型");
hgwd001a.setChangeStart(fileType1.get(0).get("itemCname").toString());
hgwd001a.setChangeEnd(fileType2.get(0).get("itemCname").toString());
HGWDTools.HgWd001.add(hgwd001a);
}
DaoUtils.update(HGWD001.UPDATE, hgwd001);
}
}
package com.baosight.hggp.hg.wd.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.common.ChangeTypeEnum;
import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.enums.OrgTypeEnum;
import com.baosight.hggp.core.tools.Iplat4jTools;
import com.baosight.hggp.hg.constant.HGConstant;
import com.baosight.hggp.hg.wd.constant.HgWdConstant;
import com.baosight.hggp.hg.wd.domain.HGWD001;
import com.baosight.hggp.hg.wd.domain.HGWD001A;
import com.baosight.hggp.hg.wd.tools.HGWDTools;
import com.baosight.hggp.hg.xs.domain.Org;
import com.baosight.hggp.util.CommonMethod;
import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.contants.ACConstants;
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.ed.util.SequenceGenerator;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author LiuYang
* @version 1.0 2024/8/29
* @description 修改文档库
*/
public class ServiceHGWD001F extends ServiceEPBase {
@Override
public EiInfo initLoad(EiInfo inInfo) {
try {
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.PROJ_RECORD_BLOCK_ID));
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.COMPANY_BOX_BLOCK_ID),new HashMap<String,Object>(){{
put(Org.FIELD_ORG_TYPE, OrgTypeEnum.COMPANY.getCode());
}});
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HGWD001().eiMetadata);
}catch (Exception e){
LogUtils.setMsg(inInfo,e,"初始化失败");
}
return inInfo;
}
@Override
public EiInfo query(EiInfo inInfo) {
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HGWD001.FIELD_DELETE_FLAG, CommonConstant.YesNo.NO_0);
return super.query(inInfo, HGWD001.QUERY,new HGWD001());
}
/**
* 保存操作
*/
@OperationLogAnnotation(operModul = "文档库",operType = "保存",operDesc = "保存操作")
public EiInfo save(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
List<Map<String, Object>> edcm01List = Iplat4jTools.EdCm01.list("hggp.hgwd.fileType");
// 写入数据
for (Map resultRow : resultRows) {
HGWD001 hgwd001 = new HGWD001();
hgwd001.fromMap(resultRow);
hgwd001.setStatus(HgWdConstant.FileStatus.S_0);
if (hgwd001.getId() == null || hgwd001.getId() == 0) {
this.add(hgwd001);
} else {
this.modify(hgwd001,edcm01List);
}
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
/**
* 新增操作
*/
public void add(HGWD001 hgwd001) {
hgwd001.setFileId(SequenceGenerator.getNextSequence(HGConstant.SequenceId.WD_FILE_ID));
hgwd001.setDocVersion(hgwd001.getDocVersion() + 1);
DaoUtils.insert(HGWD001.INSERT, hgwd001);
HGWD001A hgwd001a = new HGWD001A();
hgwd001a.setCompanyCode(hgwd001.getCompanyCode());
hgwd001a.setCompanyName(hgwd001.getCompanyName());
hgwd001a.setProjCode(hgwd001.getProjCode());
hgwd001a.setProjName(hgwd001.getProjName());
hgwd001a.setChangeType(ChangeTypeEnum.ADD.getCode());
hgwd001a.setChangeContent("文件名称");
hgwd001a.setChangeEnd(hgwd001.getFileName());
hgwd001a.setMatId(hgwd001.getId());
HGWDTools.HgWd001.add(hgwd001a);
}
/**
* 修改操作
*/
public void modify(HGWD001 hgwd001,List<Map<String, Object>> edcm01List) {
HGWD001 wd001 =HGWDTools.HgWd001.get(hgwd001.getId());
HGWD001A hgwd001a = new HGWD001A();
hgwd001a.setCompanyCode(hgwd001.getCompanyCode());
hgwd001a.setCompanyName(hgwd001.getCompanyName());
hgwd001a.setProjCode(hgwd001.getProjCode());
hgwd001a.setProjName(hgwd001.getProjName());
hgwd001a.setChangeType(ChangeTypeEnum.UPDATE.getCode());
hgwd001a.setMatId(hgwd001.getId());
if (wd001 != null && !wd001.getFileName().equals(hgwd001.getFileName())){
hgwd001a.setChangeContent("文件名称");
hgwd001a.setChangeStart(wd001.getFileName());
hgwd001a.setChangeEnd(hgwd001.getFileName());
HGWDTools.HgWd001.add(hgwd001a);
}else if (wd001 != null && !wd001.getFileType().equals(hgwd001.getFileType())){
List<Map> fileType1 = edcm01List.stream().filter(map -> map.get("itemCode").equals(wd001.getFileType())).collect(Collectors.toList());
List<Map> fileType2 = edcm01List.stream().filter(map -> map.get("itemCode").equals(hgwd001.getFileType())).collect(Collectors.toList());
hgwd001a.setChangeContent("文件类型");
hgwd001a.setChangeStart(fileType1.get(0).get("itemCname").toString());
hgwd001a.setChangeEnd(fileType2.get(0).get("itemCname").toString());
HGWDTools.HgWd001.add(hgwd001a);
}
DaoUtils.update(HGWD001.UPDATE, hgwd001);
}
}
package com.baosight.hggp.hg.wd.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.common.ChangeTypeEnum;
import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.enums.OrgTypeEnum;
import com.baosight.hggp.core.tools.Iplat4jTools;
import com.baosight.hggp.hg.constant.HGConstant;
import com.baosight.hggp.hg.wd.constant.HgWdConstant;
import com.baosight.hggp.hg.wd.domain.HGWD001;
import com.baosight.hggp.hg.wd.domain.HGWD001A;
import com.baosight.hggp.hg.wd.tools.HGWDTools;
import com.baosight.hggp.hg.xs.domain.Org;
import com.baosight.hggp.util.CommonMethod;
import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.contants.ACConstants;
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.ed.util.SequenceGenerator;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author LiuYang
* @version 1.0 2024/8/29
* @description 文档添加项目
*/
public class ServiceHGWD001G extends ServiceEPBase {
@Override
public EiInfo initLoad(EiInfo inInfo) {
try {
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.PROJ_RECORD_BLOCK_ID));
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.COMPANY_BOX_BLOCK_ID),new HashMap<String,Object>(){{
put(Org.FIELD_ORG_TYPE, OrgTypeEnum.COMPANY.getCode());
}});
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HGWD001().eiMetadata);
}catch (Exception e){
LogUtils.setMsg(inInfo,e,"初始化失败");
}
return inInfo;
}
@Override
public EiInfo query(EiInfo inInfo) {
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HGWD001.FIELD_DELETE_FLAG, CommonConstant.YesNo.NO_0);
return super.query(inInfo, HGWD001.QUERY,new HGWD001());
}
@OperationLogAnnotation(operModul = "文档库",operType = "保存",operDesc = "保存操作")
public EiInfo save(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
List<Map<String, Object>> edcm01List = Iplat4jTools.EdCm01.list("hggp.hgwd.fileType");
// 写入数据
for (Map resultRow : resultRows) {
HGWD001 hgwd001 = new HGWD001();
hgwd001.fromMap(resultRow);
hgwd001.setStatus(HgWdConstant.FileStatus.S_0);
HGWDTools.HgWd001.checkProjCode(hgwd001.getProjCode());
if (hgwd001.getId() == null || hgwd001.getId() == 0) {
this.add(hgwd001);
} else {
this.modify(hgwd001,edcm01List);
}
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
/**
* 新增操作
*/
public void add(HGWD001 hgwd001) {
hgwd001.setFileId(hgwd001.getProjCode());
hgwd001.setFileName(hgwd001.getProjName());
hgwd001.setDocVersion(hgwd001.getDocVersion() + 1);
DaoUtils.insert(HGWD001.INSERT, hgwd001);
HGWD001A hgwd001a = new HGWD001A();
hgwd001a.setCompanyCode(hgwd001.getCompanyCode());
hgwd001a.setCompanyName(hgwd001.getCompanyName());
hgwd001a.setProjCode(hgwd001.getProjCode());
hgwd001a.setProjName(hgwd001.getProjName());
hgwd001a.setChangeType(ChangeTypeEnum.ADD.getCode());
hgwd001a.setChangeContent("项目名称");
hgwd001a.setChangeEnd(hgwd001.getFileName());
hgwd001a.setMatId(hgwd001.getId());
HGWDTools.HgWd001.add(hgwd001a);
}
/**
* 修改操作
*/
public void modify(HGWD001 hgwd001,List<Map<String, Object>> edcm01List) {
HGWD001 wd001 =HGWDTools.HgWd001.get(hgwd001.getId());
HGWD001A hgwd001a = new HGWD001A();
hgwd001a.setCompanyCode(hgwd001.getCompanyCode());
hgwd001a.setCompanyName(hgwd001.getCompanyName());
hgwd001a.setProjCode(hgwd001.getProjCode());
hgwd001a.setProjName(hgwd001.getProjName());
hgwd001a.setChangeType(ChangeTypeEnum.UPDATE.getCode());
hgwd001a.setMatId(hgwd001.getId());
if (wd001 != null && !wd001.getFileName().equals(hgwd001.getFileName())){
hgwd001a.setChangeContent("项目名称");
hgwd001a.setChangeStart(wd001.getFileName());
hgwd001a.setChangeEnd(hgwd001.getFileName());
HGWDTools.HgWd001.add(hgwd001a);
}else if (wd001 != null && !wd001.getFileType().equals(hgwd001.getFileType())){
List<Map> fileType1 = edcm01List.stream().filter(map -> map.get("itemCode").equals(wd001.getFileType())).collect(Collectors.toList());
List<Map> fileType2 = edcm01List.stream().filter(map -> map.get("itemCode").equals(hgwd001.getFileType())).collect(Collectors.toList());
hgwd001a.setChangeContent("文件类型");
hgwd001a.setChangeStart(fileType1.get(0).get("itemCname").toString());
hgwd001a.setChangeEnd(fileType2.get(0).get("itemCname").toString());
HGWDTools.HgWd001.add(hgwd001a);
}
DaoUtils.update(HGWD001.UPDATE, hgwd001);
}
}
......@@ -2,34 +2,17 @@ package com.baosight.hggp.hg.wd.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.enums.DeleteFlagEnum;
import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.hg.cg.tools.HGCGTools;
import com.baosight.hggp.hg.constant.HGConstant;
import com.baosight.hggp.hg.cw.tools.HGCWTools;
import com.baosight.hggp.hg.kc.domain.HGKC001;
import com.baosight.hggp.hg.kc.tools.HGKCTools;
import com.baosight.hggp.hg.kc.utils.HGKCUtils;
import com.baosight.hggp.hg.wd.constant.HgWdConstant;
import com.baosight.hggp.hg.wd.domain.HGWD001;
import com.baosight.hggp.hg.wd.domain.HGWD002;
import com.baosight.hggp.hg.xs.domain.Company;
import com.baosight.hggp.util.AssertUtils;
import com.baosight.hggp.util.CommonMethod;
import com.baosight.hggp.util.EiInfoUtils;
import com.baosight.hggp.util.ErrorCodeUtils;
import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.MapUtils;
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 java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
......
package com.baosight.hggp.hg.wd.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.dao.DaoBase;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.enums.DeleteFlagEnum;
import com.baosight.hggp.hg.sc.domain.HGSC001;
import com.baosight.hggp.hg.sc.tools.HGSCTools;
import com.baosight.hggp.hg.wd.constant.HgWdConstant;
import com.baosight.hggp.hg.wd.constant.HgWdSqlConstant;
import com.baosight.hggp.hg.wd.domain.HGWD001;
import com.baosight.hggp.hg.wd.domain.HGWD003;
import com.baosight.hggp.hg.wd.tools.HGWDTools;
import com.baosight.hggp.util.AssertUtils;
import com.baosight.hggp.util.EiInfoUtils;
import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.MapUtils;
import com.baosight.hggp.util.ObjectUtils;
import com.baosight.hggp.util.StringUtils;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import org.apache.commons.collections.CollectionUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author:songx
* @date:2024/5/9,11:04
*/
public class ServiceHGWD003 extends ServiceEPBase {
/**
* 画面初始化
*
* @param inInfo
* @return
*/
@Override
@OperationLogAnnotation(operModul = "文档浏览", operType = "查询", operDesc = "初始化")
public EiInfo initLoad(EiInfo inInfo) {
try {
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HGWD003().eiMetadata);
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
return inInfo;
}
/**
* 查询
*
* @param inInfo
* @return
*/
public EiInfo query(EiInfo inInfo) {
try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
String fileId = MapUtils.getString(queryMap, HGWD003.FIELD_FILE_ID);
if (StringUtils.isBlank(fileId)) {
return inInfo;
}
inInfo = super.query(inInfo, HGWD003.QUERY, new HGWD003());
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "查询节点失败");
}
return inInfo;
}
/**
* 树节点查询
*
* @param inInfo
* @return
*/
public EiInfo queryTree(EiInfo inInfo) {
try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
String node = MapUtils.getString(queryMap, CommonConstant.Field.NODE);
if (CommonConstant.Field.ROOT.equals(node) || CommonConstant.Field.ROOT2.equals(node)) {
inInfo.addBlock(node).setRows(queryTopNode(node));
} else {
inInfo.addBlock(node).setRows(queryChildNode(node));
}
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "查询节点失败");
}
return inInfo;
}
/**
* 查询树根
*
* @return
*/
public List queryTopNode(String parentLabel) {
List<Map> results = new ArrayList();
List<HGSC001> dbSc001s = dao.query(HGSC001.QUERY, new HashMap<>());
if (CollectionUtils.isEmpty(dbSc001s)) {
return results;
}
for (HGSC001 dbSc001 : dbSc001s) {
String text = "[" + dbSc001.getProjCode() + "]" + dbSc001.getProjName();
results.add(buildLeaf(parentLabel, dbSc001.getProjCode(), text, HgWdConstant.LeafType.P));
}
// 设置叶子节点
setTreeNodeLeaf(results);
return results;
}
/**
* 查询叶子节点
*
* @param parentLabel
* @return
*/
public List queryChildNode(String parentLabel) {
List<Map> results = new ArrayList();
Map queryMap = new HashMap();
queryMap.put("parentId", parentLabel);
List<HGWD001> dbWd001s = dao.query(HGWD001.QUERY, queryMap);
if (CollectionUtils.isEmpty(dbWd001s)) {
return results;
}
for (HGWD001 dbWd001 : dbWd001s) {
results.add(buildLeaf(parentLabel, dbWd001.getFileId(), dbWd001.getFileName(), HgWdConstant.LeafType.C));
}
// 设置叶子节点
setTreeNodeLeaf(results);
return results;
}
/**
* 搜索树节点
*
* @param inInfo
* @return
*/
public EiInfo searchNode(EiInfo inInfo) {
try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
List<HGWD001> dbWd001s = DaoBase.getInstance().query(HgWdSqlConstant.HgWd001.SEARCH_TREE_NODE, queryMap);
// 设置一级项目节点信息
List<Map> nodes = this.buildProjInfo(dbWd001s);
inInfo.addBlock(CommonConstant.Field.ROOT2).setRows(nodes);
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "搜索节点失败");
}
return inInfo;
}
/**
* 设置一级项目节点信息
*
* @param dbWd001s
*/
private List<Map> buildProjInfo(List<HGWD001> dbWd001s) {
List<Map> results = new ArrayList();
if (CollectionUtils.isEmpty(dbWd001s)) {
return results;
}
for (HGWD001 dbWd001 : dbWd001s) {
results.add(buildLeaf(dbWd001.getParentId(), dbWd001.getFileId(), dbWd001.getFileName(),
HgWdConstant.LeafType.C));
}
// 项目信息
List<String> projCodes = dbWd001s.stream().filter(item -> item.getLeafLevel() == 1)
.map(HGWD001::getParentId).collect(Collectors.toList());
List<HGSC001> dbSc001s = HGSCTools.Hgsc001.queryByCode(projCodes);
for (HGSC001 dbSc001 : dbSc001s) {
results.add(buildLeaf(CommonConstant.Field.ROOT2, dbSc001.getProjCode(), dbSc001.getProjName(),
HgWdConstant.LeafType.P));
}
return results;
}
/**
* 构建叶子节点
*
* @param parentLabel
* @param label
* @param text
*/
private HashMap buildLeaf(String parentLabel, String label, String text, String leafType) {
HashMap<String, String> leafMap = new HashMap();
leafMap.put("parent", parentLabel);
leafMap.put("label", label);
leafMap.put("text", text);
leafMap.put("leafType", leafType);
return leafMap;
}
/**
* 删除用户
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "文档权限", operType = "保存", operDesc = "操作")
public EiInfo removeUser(EiInfo inInfo) {
try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
// 获取FILE_ID
String fileId = MapUtils.getString(queryMap, HGWD003.FIELD_FILE_ID);
AssertUtils.isEmpty(fileId, "请选择目录");
List<HGWD003> fWd003s = MapUtils.toDaoEPBases(inInfo, HGWD003.class);
for (HGWD003 fWd003 : fWd003s) {
fWd003.setDeleteFlag(DeleteFlagEnum.REMOVE.getCode());
DaoUtils.insert(HGWD003.DELETE, fWd003);
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + fWd003s.size() + "]条数据删除成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "删除失败");
}
return inInfo;
}
/**
* 设置叶子节点是否可以展开
*
* @param nodes
*/
private void setTreeNodeLeaf(List<Map> nodes) {
if (CollectionUtils.isEmpty(nodes)) {
return;
}
List<String> labels = ObjectUtils.listKey(nodes, "label");
Map<String, Integer> resultMap = HGWDTools.HgWd001.countByParent(labels);
for (Map node : nodes) {
Integer cnt = resultMap == null ? null : resultMap.get(node.get("label"));
node.put("leaf", cnt == null || cnt == 0 ? 1 : 0);
}
}
}
package com.baosight.hggp.hg.wd.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.hg.pz.domain.HGPZ016;
import com.baosight.hggp.hg.sc.domain.HGSC001;
import com.baosight.hggp.hg.wd.domain.HGWD001;
import com.baosight.hggp.hg.wd.domain.HGWD002;
import com.baosight.hggp.hg.wd.domain.HGWD003;
import com.baosight.hggp.hg.xs.domain.User;
import com.baosight.hggp.util.AssertUtils;
import com.baosight.hggp.util.EiInfoUtils;
import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.MapUtils;
import com.baosight.hggp.util.StringUtil;
import com.baosight.iplat4j.core.ei.EiBlockMeta;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import org.apache.commons.collections.CollectionUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author:songx
* @date:2024/5/9,11:04
*/
public class ServiceHGWD003A extends ServiceEPBase {
private EiBlockMeta eiMetadata = null;
/**
* 画面初始化
*
* @param inInfo
* @return
*/
@Override
@OperationLogAnnotation(operModul = "文档权限", operType = "查询", operDesc = "初始化")
public EiInfo initLoad(EiInfo inInfo) {
try {
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new User().eiMetadata);
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
return inInfo;
}
/**
* 树节点查询
*
* @param inInfo
* @return
*/
public EiInfo query(EiInfo inInfo) {
try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
inInfo = super.query(inInfo, "HGWD003A.query", new User());
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "查询节点失败");
}
return inInfo;
}
/**
* 保存
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "文档权限", operType = "保存", operDesc = "操作")
public EiInfo authUser(EiInfo inInfo) {
try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
// 获取FILE_ID
String fileId = MapUtils.getString(queryMap, HGWD003.FIELD_FILE_ID);
AssertUtils.isEmpty(fileId, "请选择目录");
List<HGWD003> fWd003s = MapUtils.toDaoEPBases(inInfo, HGWD003.class);
for (HGWD003 fWd003 : fWd003s) {
fWd003.setFileId(fileId);
DaoUtils.insert(HGWD003.INSERT, fWd003);
}
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + fWd003s.size() + "]条数据授权成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "授权失败");
}
return inInfo;
}
}
......@@ -7,12 +7,13 @@ import com.baosight.hggp.core.constant.S3Constant;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.hg.cw.domain.HGCW999;
import com.baosight.hggp.hg.cw.tools.HGCWTools;
import com.baosight.hggp.hg.dm.domain.HGDM099;
import com.baosight.hggp.hg.ds.domain.HGDS002;
import com.baosight.hggp.hg.wd.constant.HgWdConstant;
import com.baosight.hggp.hg.wd.domain.HGWD001;
import com.baosight.hggp.hg.wd.domain.HGWD001A;
import com.baosight.hggp.hg.wd.tools.HGWDTools;
import com.baosight.hggp.util.FileUtils;
import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.*;
import com.baosight.iplat4j.core.ProjectInfo;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
......@@ -43,7 +44,7 @@ public class ServiceHGWD099 extends ServiceEPBase {
@Override
public EiInfo initLoad(EiInfo inInfo) {
try {
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HGCW999().eiMetadata);
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HGDM099().eiMetadata);
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
......@@ -60,34 +61,9 @@ public class ServiceHGWD099 extends ServiceEPBase {
@Override
public EiInfo query(EiInfo inInfo) {
try {
// 项目环境
if (CommonConstant.FileLocation.S3.equalsIgnoreCase(S3Constant.FILE_LOCATION)) {
inInfo = super.query(inInfo, "HGCW999.queryRun", new HGCW999());
} else {
inInfo = super.query(inInfo, "HGCW999.queryDev", new HGCW999());
}
} catch (Throwable e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
}
return inInfo;
}
public EiInfo queryDoc(EiInfo inInfo) {
try {
String docId = inInfo.getString("docId");
HGCW999 HGCW999 = new HGCW999();
List<HGCW999> list = new ArrayList<>();
Map<String,Object> map = new HashMap<>();
map.put("docId",docId);
// 项目环境
if (CommonConstant.FileLocation.S3.equalsIgnoreCase(S3Constant.FILE_LOCATION)) {
list = this.dao.query("HGCW999.queryRun",map);
} else {
list = this.dao.query("HGCW999.queryDev",map);
}
if (CollectionUtils.isNotEmpty(list)) {
HGCW999 = list.get(0);
inInfo.set("data",HGCW999);
Map queryRow =EiInfoUtils.getFirstRow(inInfo);
if(StringUtils.isNotEmpty(queryRow.get(HGDM099.FIELD_BIZ_ID).toString())){
inInfo = super.query(inInfo, HGDM099.QUERY, new HGDM099());
}
} catch (Throwable e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
......@@ -95,16 +71,6 @@ public class ServiceHGWD099 extends ServiceEPBase {
return inInfo;
}
public void add(HGCW999 HGCW999) {
DaoUtils.insert("HGCW999.insert", HGCW999);
}
public void deleteEntity(HGCW999 HGCW999) {
DaoUtils.update("HGCW999.delete", HGCW999);
}
/**
* 新增操作
*
......@@ -117,10 +83,11 @@ public class ServiceHGWD099 extends ServiceEPBase {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
for (Map resultRow : resultRows) {
HGCW999 fSc002A = new HGCW999();
fSc002A.fromMap(resultRow);
this.add(fSc002A);
HGWD001 hgwd001 =HGWDTools.HgWd001.get(fSc002A.getMatId());
HGDM099 hgdm099 = new HGDM099();
hgdm099.fromMap(resultRow);
hgdm099.setDeleteFlag(CommonConstant.YesNo.NO_0);
DaoUtils.insert(HGDM099.INSERT, hgdm099);
HGWD001 hgwd001 =HGWDTools.HgWd001.get(hgdm099.getBizId());
if (hgwd001 != null) {
HGWD001A hgwd001a = new HGWD001A();
hgwd001a.setCompanyCode(hgwd001.getCompanyCode());
......@@ -129,10 +96,12 @@ public class ServiceHGWD099 extends ServiceEPBase {
hgwd001a.setProjName(hgwd001.getProjName());
hgwd001a.setChangeType(ChangeTypeEnum.UPLOAD_ADD.getCode());
hgwd001a.setChangeContent("上传附件");
hgwd001a.setChangeEnd(fSc002A.getDocName());
hgwd001a.setChangeStart(fSc002A.getDocId());
hgwd001a.setChangeEnd(hgdm099.getDocName());
hgwd001a.setChangeStart(hgdm099.getDocId());
hgwd001a.setMatId(hgwd001.getId());
HGWDTools.HgWd001.add(hgwd001a);
hgwd001.setStatus(HgWdConstant.FileStatus.S_0);
HGWDTools.HgWd001.updateStatus(hgwd001);
}
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
......@@ -153,14 +122,12 @@ public class ServiceHGWD099 extends ServiceEPBase {
@Override
public EiInfo delete(EiInfo inInfo) {
try {
Long matId = null;
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
for (int i = 0; i < resultRows.size(); i++) {
HGCW999 fSc002A = new HGCW999();
fSc002A.fromMap(resultRows.get(i));
matId = fSc002A.getMatId();
this.deleteEntity(fSc002A);
HGWD001 hgwd001 =HGWDTools.HgWd001.get(matId);
for (Map resultRow : resultRows) {
HGDM099 hgdm099 = new HGDM099();
hgdm099.fromMap(resultRow);
DaoUtils.update(HGDM099.DELETE, hgdm099);
HGWD001 hgwd001 = HGWDTools.HgWd001.get(hgdm099.getBizId());
if (hgwd001 != null) {
HGWD001A hgwd001a = new HGWD001A();
hgwd001a.setCompanyCode(hgwd001.getCompanyCode());
......@@ -169,14 +136,14 @@ public class ServiceHGWD099 extends ServiceEPBase {
hgwd001a.setProjName(hgwd001.getProjName());
hgwd001a.setChangeType(ChangeTypeEnum.UPLOAD_DELETE.getCode());
hgwd001a.setChangeContent("删除附件");
hgwd001a.setChangeEnd(fSc002A.getDocName());
hgwd001a.setChangeStart(fSc002A.getDocId());
hgwd001a.setChangeEnd(hgdm099.getDocName());
hgwd001a.setChangeStart(hgdm099.getDocId());
hgwd001a.setMatId(hgwd001.getId());
HGWDTools.HgWd001.add(hgwd001a);
hgwd001.setStatus(HgWdConstant.FileStatus.S_0);
HGWDTools.HgWd001.updateStatus(hgwd001);
}
}
//List<HGCW999> hgcw999List = HGCWTools.HgCw999.queryByBiz(matId,"HT");
//inInfo.addBlock(EiConstant.resultBlock).addRows(hgcw999List);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据删除成功!");
} catch (Exception e) {
......
......@@ -17,6 +17,8 @@
COMPANY_NAME as "companyName", <!-- 公司名称 -->
PROJ_CODE as "projCode", <!-- 项目编码 -->
PROJ_NAME as "projName", <!-- 项目名称 -->
LEAF_LEVEL as "leafLevel", <!--节点层级-->
PARENT_ID as "parentId", <!--父级ID-->
FILE_ID as "fileId", <!-- 文件ID -->
FILE_TYPE as "fileType", <!-- 文件类型 -->
FILE_NAME as "fileName", <!-- 文件名称 -->
......@@ -27,6 +29,7 @@
</sql>
<sql id="condition">
AND DELETE_FLAG = 0
<isNotEmpty prepend=" AND " property="id">
ID = #id#
</isNotEmpty>
......@@ -54,9 +57,6 @@
<isNotEmpty prepend=" AND " property="updatedTime">
UPDATED_TIME = #updatedTime#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="deleteFlag">
DELETE_FLAG = #deleteFlag#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyCode">
COMPANY_CODE = #companyCode#
</isNotEmpty>
......@@ -69,6 +69,12 @@
<isNotEmpty prepend=" AND " property="projName">
PROJ_NAME LIKE CONCAT('%', #projName#, '%')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="leafLevel">
LEAF_LEVEL = #leafLevel#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="parentId">
PARENT_ID = #parentId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="fileId">
FILE_ID = #fileId#
</isNotEmpty>
......@@ -92,6 +98,12 @@
</isNotEmpty>
</sql>
<sql id="customCondition">
<isNotEmpty prepend=" AND " property="parentIds">
PARENT_ID IN <iterate close=")" open="(" conjunction="," property="parentIds">#parentIds[]#</iterate>
</isNotEmpty>
</sql>
<sql id="orderBy">
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy">
......@@ -118,6 +130,42 @@
<include refid="condition"/>
</select>
<!-- 更具父级节点统计 -->
<select id="countByParent" resultClass="java.util.HashMap">
SELECT PARENT_ID, COUNT(1) AS CNT
FROM ${hggpSchema}.HGWD001
WHERE 1=1
AND DELETE_FLAG = 0
AND PARENT_ID IN <iterate close=")" open="(" conjunction="," property="parentIds">#parentIds[]#</iterate>
GROUP BY PARENT_ID
</select>
<!-- 搜索树节点 -->
<select id="searchTreeNode" resultClass="com.baosight.hggp.hg.wd.domain.HGWD001">
SELECT DISTINCT
T3.FILE_ID as "fileId", T3.FILE_NAME as "fileName", T3.PARENT_ID as "parentId", T3.LEAF_LEVEL as "leafLevel"
FROM (
SELECT
@CODES as CODES,
(
SELECT @CODES:=GROUP_CONCAT(PARENT_ID) FROM ${hggpSchema}.HGWD001
WHERE FIND_IN_SET(FILE_ID, @CODES) AND ACCOUNT_CODE = #accountCode# AND DELETE_FLAG = 0
) AS T1,
@LEVEL:=@LEVEL+1 AS LEVEL
FROM ${hggpSchema}.HGWD001,
(
SELECT @CODES:=(SELECT GROUP_CONCAT(FILE_ID) FROM ${hggpSchema}.HGWD001
WHERE FILE_NAME LIKE CONCAT('%', #fileName#, '%')), @LEVEL:= 0
) T4
WHERE @CODES IS NOT NULL
) T2,
${hggpSchema}.HGWD001 T3
WHERE T3.DELETE_FLAG = 0
AND FIND_IN_SET(T3.FILE_ID, T2.CODES)
AND T3.ACCOUNT_CODE = #accountCode#
ORDER BY T3.FILE_ID
</select>
<insert id="insert">
INSERT INTO ${hggpSchema}.HGWD001 (
ACCOUNT_CODE, <!-- 企业编码 -->
......@@ -130,6 +178,8 @@
COMPANY_NAME, <!-- 公司名称 -->
PROJ_CODE, <!-- 项目编码 -->
PROJ_NAME, <!-- 项目名称 -->
LEAF_LEVEL, <!--节点层级-->
PARENT_ID, <!--父级ID-->
FILE_ID, <!-- 文件ID -->
FILE_TYPE, <!-- 文件类型 -->
FILE_NAME, <!-- 文件名称 -->
......@@ -139,7 +189,7 @@
RELEASE_DATE
) VALUES (
#accountCode#, #depCode#, #createdBy#, #createdName#, #createdTime#,
#deleteFlag#, #companyCode#, #companyName#, #projCode#, #projName#,
#deleteFlag#, #companyCode#, #companyName#, #projCode#, #projName#,#leafLevel#,#parentId#,
#fileId#, #fileType#, #fileName#,
#docVersion#, #status#, #remark#, #releaseDate#
<selectKey resultClass="long" keyProperty="id">
......@@ -167,6 +217,14 @@
WHERE ID = #id#
</update>
<update id="updateStatus">
UPDATE ${hggpSchema}.HGWD001
SET
STATUS = #status#, <!-- 状态 -->
<include refid="SqlBase.updateRevise"/>
WHERE ID = #id#
</update>
<update id="updateReleaseDate">
UPDATE ${hggpSchema}.HGWD001
SET
......@@ -177,4 +235,103 @@
WHERE ID = #id#
</update>
<select id="queryTree" resultClass="java.util.HashMap">
SELECT
COMPANY_CODE as "companyCode", <!-- 公司编码 -->
COMPANY_NAME as "companyName", <!-- 公司名称 -->
PROJ_CODE as "projCode", <!-- 项目编码 -->
PROJ_NAME as "projName", <!-- 项目名称 -->
LEAF_LEVEL as "leafLevel", <!--节点层级-->
PARENT_ID as "pId", <!--父级ID-->
FILE_ID as "fileId", <!-- 文件ID -->
FILE_TYPE as "fileType", <!-- 文件类型 -->
FILE_NAME as "fileName" <!-- 文件名称 -->
FROM ${hggpSchema}.HGWD001
WHERE 1=1
<isNotEmpty prepend=" AND " property="pEname">
PARENT_ID = #pEname#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyCode">
COMPANY_CODE = #companyCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="projCode">
PROJ_CODE = #projCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="parentId">
PARENT_ID = #parentId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="fileId">
FILE_ID = #fileId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="leafLevel">
LEAF_LEVEL = #leafLevel#
</isNotEmpty>
ORDER BY CREATED_TIME DESC
</select>
<!-- 文档库子节点树查询 -->
<select id="queryOrganiation" resultClass="java.util.HashMap">
SELECT
A.COMPANY_CODE as "companyCode", <!-- 公司编码 -->
A.COMPANY_NAME as "companyName", <!-- 公司名称 -->
A.PROJ_CODE as "projCode", <!-- 项目编码 -->
A.PROJ_NAME as "projName", <!-- 项目名称 -->
A.FILE_ID as "label",
A.FILE_ID as "ename",
A.FILE_NAME as "text",
A.FILE_TYPE as "leaf",
A.FILE_TYPE as "type",
A.PARENT_ID as "parentId",
A.DELETE_FLAG as "isDeleted",
A.LEAF_LEVEL as "leafLevel"
FROM ${hggpSchema}.HGWD001 A INNER JOIN ${hggpSchema}.HGWD003 B ON A.FILE_ID = B.FILE_ID
WHERE 1=1
<isEmpty prepend=" AND " property="deletedQuery">
A.DELETE_FLAG = '0'
</isEmpty>
<isNotEmpty prepend=" AND " property="node">
A.PARENT_ID = #node#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyCode">
A.COMPANY_CODE = #companyCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountCode">
A.ACCOUNT_CODE = #accountCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="userId">
B.USER_ID = #userId#
</isNotEmpty>
group by A.COMPANY_CODE,A.PROJ_CODE,A.FILE_ID,A.FILE_NAME,A.FILE_TYPE,A.PARENT_ID,A.DELETE_FLAG
order by A.CREATED_TIME asc
</select>
<!--档库所有子节点树查询-->
<select id="queryFileChild" resultClass="java.util.HashMap">
SELECT
T3.ID as "id", T3.FILE_ID AS "fileId",T3.FILE_TYPE AS "fileType", T3.PARENT_ID as "parentId"
FROM (
SELECT
@CODES AS CODES,
(
SELECT @CODES:=GROUP_CONCAT(FILE_ID)
FROM ${hggpSchema}.HGWD001
WHERE FIND_IN_SET(PARENT_ID, @CODES)
<isNotEmpty prepend=" AND " property="accountCode">
ACCOUNT_CODE = #accountCode#
</isNotEmpty>
AND DELETE_FLAG = 0
) AS T1,
@LEVEL:=@LEVEL+1 AS LEVEL
FROM ${hggpSchema}.HGWD001,
<isNotEmpty property="parentId">
(SELECT @CODES:=#parentId#, @LEVEL:= 0) T4
</isNotEmpty>
WHERE @CODES IS NOT NULL
) T2,
${hggpSchema}.HGWD001 T3
WHERE T3.DELETE_FLAG = 0
AND FIND_IN_SET(T3.FILE_ID, T2.CODES)
ORDER BY T3.FILE_ID ASC
</select>
</sqlMap>
<?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="HGWD003">
<sql id="column">
A.ID as "id",
A.ACCOUNT_CODE as "accountCode", <!-- 企业编码 -->
A.DEP_CODE as "depCode", <!-- 部门编码 -->
A.CREATED_BY as "createdBy", <!-- 记录创建者 -->
A.CREATED_NAME as "createdName", <!-- 记录创建名称 -->
A.CREATED_TIME as "createdTime", <!-- 记录创建时间 -->
A.UPDATED_BY as "updatedBy", <!-- 记录修改者 -->
A.UPDATED_NAME as "updatedName", <!-- 记录修改名称 -->
A.UPDATED_TIME as "updatedTime", <!-- 记录修改时间 -->
A.DELETE_FLAG as "deleteFlag", <!-- 0-未删除,1-已删除 -->
A.FILE_ID as "fileId", <!-- 文件ID -->
A.USER_ID as "userId", <!-- 用户ID -->
A.REMARK as "remark" <!-- 备注 -->
</sql>
<sql id="columnB">
B.USER_NAME as "userName"
</sql>
<sql id="columnD">
D.ORG_ID as "orgId",
D.ORG_CNAME as "orgCname"
</sql>
<sql id="condition">
AND A.DELETE_FLAG = 0
<isNotEmpty prepend=" AND " property="accountCode">
A.ACCOUNT_CODE = #accountCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="id">
A.ID = #id#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="fileId">
A.FILE_ID = #fileId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="userId">
A.USER_ID LIKE CONCAT('%', #userId#, '%')
</isNotEmpty>
</sql>
<sql id="conditionB">
<isNotEmpty prepend=" AND " property="userName">
B.USER_NAME LIKE CONCAT('%', #userName#, '%')
</isNotEmpty>
</sql>
<sql id="conditionD">
<isNotEmpty prepend=" AND " property="orgCname">
D.ORG_CNAME LIKE CONCAT('%', #orgCname#, '%')
</isNotEmpty>
</sql>
<sql id="orderBy">
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy">
$orderBy$
</isNotEmpty>
<isEmpty property="orderBy">
A.ID DESC
</isEmpty>
</dynamic>
</sql>
<select id="query" resultClass="com.baosight.hggp.hg.wd.domain.HGWD003">
SELECT
<include refid="column"/>,
<include refid="columnB"/>,
<include refid="columnD"/>
FROM ${hggpSchema}.HGWD003 A
INNER JOIN ${platSchema}.XS_USER B ON A.USER_ID = B.LOGIN_NAME
LEFT JOIN ${platSchema}.TXSOG02 C ON B.USER_ID = C.USER_ID
LEFT JOIN ${platSchema}.TXSOG01 D ON C.ORG_ID = D.ORG_ID
WHERE 1=1
<include refid="condition"/>
<include refid="conditionB"/>
<include refid="conditionD"/>
<include refid="orderBy"/>
</select>
<select id="count" resultClass="int">
SELECT COUNT(*)
FROM ${hggpSchema}.HGWD001 A
INNER JOIN ${platSchema}.XS_USER B ON A.USER_ID = B.LOGIN_NAME
LEFT JOIN ${platSchema}.TXSOG02 C ON B.USER_ID = C.USER_ID
LEFT JOIN ${platSchema}.TXSOG01 D ON C.ORG_ID = D.ORG_ID
WHERE 1=1
<include refid="condition"/>
<include refid="conditionB"/>
<include refid="conditionD"/>
</select>
<insert id="insert">
INSERT INTO ${hggpSchema}.HGWD003 (
ACCOUNT_CODE, <!-- 企业编码 -->
DEP_CODE, <!-- 部门编码 -->
CREATED_BY, <!-- 记录创建者 -->
CREATED_NAME, <!-- 记录创建名称 -->
CREATED_TIME, <!-- 记录创建时间 -->
FILE_ID, <!-- 文件ID -->
USER_ID, <!-- 文件ID -->
REMARK <!-- 备注 -->
) VALUES (
#accountCode#, #depCode#, #createdBy#, #createdName#, #createdTime#,
#fileId#, #userId#, #remark#
)
</insert>
<!-- 逻辑删除 -->
<delete id="delete">
UPDATE ${hggpSchema}.HGWD003 SET DELETE_FLAG = 1 WHERE ID = #id#
</delete>
</sqlMap>
<?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="HGWD003A">
<sql id="column">
A.USER_ID as "userId", <!-- 用户id -->
A.USER_NAME as "userName", <!-- 用户名 -->
A.LOGIN_NAME as "loginName", <!-- 登录id -->
A.GENDER as "gender", <!-- 性别 -->
A.MOBILE as "mobile", <!-- 手机号 -->
A.EMAIL as "email", <!-- 邮箱 -->
A.ACCOUNT_CODE as "accountCode" <!-- 企业编码 -->
</sql>
<sql id="columnB">
C.ORG_ID as "depCode", <!-- 部门编码-->
C.ORG_CNAME as "depName" <!-- 部门名称-->
</sql>
<sql id="condition">
<!-- 过滤已经添加的用户 -->
AND NOT EXISTS (SELECT * FROM ${hggpSchema}.HGWD003 T WHERE A.LOGIN_NAME = T.USER_ID
AND T.DELETE_FLAG = 0 AND T.FILE_ID = #fileId#
)
<isNotEmpty prepend=" AND " property="accountCode">
A.ACCOUNT_CODE = #accountCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="loginName">
A.LOGIN_NAME = #loginName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="userId">
A.USER_ID LIKE CONCAT('%', #userId#, '%')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="userName">
A.USER_NAME LIKE CONCAT('%', #userName#, '%')
</isNotEmpty>
</sql>
<sql id="conditionC">
<isNotEmpty prepend=" AND " property="depName">
C.ORG_CNAME LIKE CONCAT('%', #depName#, '%')
</isNotEmpty>
</sql>
<sql id="orderBy">
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy">
$orderBy$
</isNotEmpty>
<isEmpty property="orderBy">
A.REC_CREATE_TIME DESC
</isEmpty>
</dynamic>
</sql>
<!-- 查询用户信息 -->
<select id="query" resultClass="com.baosight.hggp.hg.xs.domain.User">
SELECT
<include refid="column"/>,
<include refid="columnB"/>
FROM ${platSchema}.XS_USER A
LEFT JOIN ${platSchema}.TXSOG02 B ON A.USER_ID = B.USER_ID
LEFT JOIN ${platSchema}.TXSOG01 C ON B.ORG_ID = C.ORG_ID
WHERE 1=1
<include refid="condition"/>
<include refid="conditionC"/>
</select>
<select id="count" resultClass="int">
SELECT COUNT(*)
FROM ${platSchema}.XS_USER A
LEFT JOIN ${platSchema}.TXSOG02 B ON A.USER_ID = B.USER_ID
LEFT JOIN ${platSchema}.TXSOG01 C ON B.ORG_ID = C.ORG_ID
WHERE 1=1
<include refid="condition"/>
<include refid="conditionC"/>
</select>
</sqlMap>
......@@ -7,11 +7,13 @@ import com.baosight.hggp.hg.wd.domain.HGWD001;
import com.baosight.hggp.hg.wd.domain.HGWD001A;
import com.baosight.hggp.hg.wd.domain.HGWD002;
import com.baosight.hggp.util.AssertUtils;
import com.baosight.hggp.util.MapUtils;
import org.apache.commons.collections.CollectionUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author:songx
......@@ -30,9 +32,12 @@ public class HGWDTools {
* @return
*/
public static HGWD001 get(String fileId) {
AssertUtils.isEmpty(fileId, "文件ID不能为空");
//AssertUtils.isEmpty(fileId, "文件ID不能为空");
Map queryMap = new HashMap();
if (fileId != null) {
queryMap.put(HGWD001.FIELD_FILE_ID, fileId);
}
List<HGWD001> results = DaoBase.getInstance().query(HGWD001.QUERY, queryMap);
return CollectionUtils.isEmpty(results) ? null : results.get(0);
}
......@@ -49,11 +54,53 @@ public class HGWDTools {
return CollectionUtils.isEmpty(results) ? null : results.get(0);
}
/**
* 根据父节点统计
*
* @param parentIds
* @return
*/
public static Map<String, Integer> countByParent(List<String> parentIds) {
AssertUtils.isEmpty(parentIds, "文件ID不能为空");
Map queryMap = new HashMap();
queryMap.put("parentIds", parentIds);
List<Map> results = DaoBase.getInstance().query(HgWdSqlConstant.HgWd001.COUNT_BY_PARENT, queryMap);
if (CollectionUtils.isEmpty(results)) {
return null;
}
return results.stream().collect(Collectors.toMap(item -> MapUtils.getString(item, HGWD001.COL_PARENT_ID),
item -> MapUtils.getInteger(item, "CNT")));
}
/**
* 搜索树节点
*
* @param fileName
* @return
*/
public static List<HGWD001> searchTreeNode(String fileName) {
Map queryMap = new HashMap();
queryMap.put("fileName", fileName);
return DaoBase.getInstance().query(HgWdSqlConstant.HgWd001.SEARCH_TREE_NODE, queryMap);
}
public static void add(HGWD001A hgwd001a) {
AssertUtils.isNull(hgwd001a, "文档对象不能为空");
DaoUtils.insert(HGWD001A.INSERT, hgwd001a);
}
public static void updateStatus(HGWD001 hgwd001) {
AssertUtils.isNull(hgwd001, "文档对象不能为空");
DaoUtils.update("HGWD001.updateStatus", hgwd001);
}
public static void checkProjCode(String projCode) {
AssertUtils.isNull(projCode, "项目不能为空!");
Map queryMap = new HashMap<>();
queryMap.put(HGWD001.FIELD_FILE_ID, projCode);
List results = DaoBase.getInstance().query(HGWD001.QUERY, queryMap);
AssertUtils.isTrue(!CollectionUtils.isEmpty(results), "项目已存在,不能重复添加!");
}
}
......
package com.baosight.hggp.hg.xs.constant;
/**
* @author:songx
* @date:2024/8/27,9:14
*/
public class HgXsConstant {
/**
* 状态
*
* @author:songx
* @date:2024/5/7,16:36
*/
public static class FolStatus {
// 待回访
public static final Integer S0 = 0;
// 已回访
public static final Integer S1 = 1;
}
}
package com.baosight.hggp.hg.xs.constant;
/**
* @author:songx
* @date:2024/8/27,9:14
*/
public class HgXsSqlConstant {
/**
* @author:songx
* @date:2024/8/29,15:54
*/
public static class HgXsUser {
// 修改德诚用户
public static final String UPDATE_DC_USER = "HGXSUser.updateDcUser";
}
/**
* @author:songx
* @date:2024/8/29,15:54
*/
public static class HgXsOrg {
// 新增管理
public static final String ADD_RELATION = "HGXSOrg.addRelation";
// 修改组织名称
public static final String UPDATE_ORG_CNAME = "HGXSOrg.updateOrgCname";
}
/**
* 客户回访
*
* @author:songx
* @date:2024/5/7,16:36
*/
public static class HgXs007 {
// 审核
public static final String CHECK = "HGXS007.check";
// 锁
public static final String LOCK = "HGXS007.lock";
}
}
......@@ -46,6 +46,7 @@ public class User extends DaoEPBase {
public static final String FIELD_DEP_CODE = "depCode"; /* 部门编码*/
public static final String FIELD_DEP_NAME = "depName"; /* 部门名称*/
public static final String FIELD_ID_CODE = "idCode";
public static final String FIELD_ID_CARD = "idCard";
public static final String COL_USER_ID = "USER_ID"; /* 用户ID*/
public static final String COL_LOGIN_NAME = "LOGIN_NAME";
......@@ -99,6 +100,7 @@ public class User extends DaoEPBase {
private String depCode = ""; /* 部门编码*/
private String depName = ""; /* 部门名称*/
private String idCode = "";
private String idCard = "";
/**
* initialize the metadata.
*/
......@@ -202,6 +204,9 @@ public class User extends DaoEPBase {
eiColumn.setDescName("身份证号码");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_ID_CARD);
eiColumn.setDescName("身份证号码");
eiMetadata.addMeta(eiColumn);
}
/**
......@@ -576,6 +581,14 @@ public class User extends DaoEPBase {
this.idCode = idCode;
}
public String getIdCard() {
return idCard;
}
public void setIdCard(String idCard) {
this.idCard = idCard;
}
/**
* get the value from Map.
*
......@@ -608,6 +621,7 @@ public class User extends DaoEPBase {
setDepCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_DEP_CODE)), depCode));
setDepName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_DEP_NAME)), depName));
setIdCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_ID_CODE)), idCode));
setIdCard(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_ID_CARD)), idCard));
}
/**
......@@ -641,6 +655,7 @@ public class User extends DaoEPBase {
map.put(FIELD_DEP_CODE, StringUtils.toString(depCode, eiMetadata.getMeta(FIELD_DEP_CODE)));
map.put(FIELD_DEP_NAME, StringUtils.toString(depName, eiMetadata.getMeta(FIELD_DEP_NAME)));
map.put(FIELD_ID_CODE, StringUtils.toString(idCode, eiMetadata.getMeta(FIELD_ID_CODE)));
map.put(FIELD_ID_CARD, StringUtils.toString(idCard, eiMetadata.getMeta(FIELD_ID_CARD)));
return map;
}
......
package com.baosight.hggp.hg.xs.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.hg.xs.constant.HgXsConstant;
import com.baosight.hggp.hg.xs.constant.HgXsSqlConstant;
import com.baosight.hggp.hg.xs.domain.HGXS007;
import com.baosight.hggp.hg.xs.tools.HGXSTools;
import com.baosight.hggp.hg.xs.utils.HGXSUtils;
import com.baosight.hggp.util.AssertUtils;
import com.baosight.hggp.util.CommonMethod;
import com.baosight.hggp.util.DateUtils;
import com.baosight.hggp.util.EiInfoUtils;
import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.MapUtils;
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.service.impl.ServiceBase;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* 客户回访
*
* @author:songx
* @date:2024/8/27,9:05
*/
public class ServiceHGXS007 extends ServiceBase {
/**
* 画面初始化
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "客户回访", operType = "查询", operDesc = "初始化")
public EiInfo initLoad(EiInfo inInfo) {
try {
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.COMPANY_CODE_BLOCK_ID));
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HGXS007().eiMetadata);
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
return inInfo;
}
/**
* 查询操作
*
* @param inInfo
* @return
*/
@Override
@OperationLogAnnotation(operModul = "客户回访", operType = "查询")
public EiInfo query(EiInfo inInfo) {
try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
queryMap.put(HGXS007.FIELD_FOL_DATE, DateUtils.formatShort(queryMap.get(HGXS007.FIELD_FOL_DATE)));
inInfo = super.query(inInfo, HGXS007.QUERY, new HGXS007());
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
}
return inInfo;
}
/**
* 删除操作
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "客户回访", operType = "删除")
public EiInfo remove(EiInfo inInfo) {
try {
List<HGXS007> fXs007s = MapUtils.toDaoEPBases(inInfo, HGXS007.class);
Map<Long, HGXS007> dbXs007s = HGXSUtils.HgXs007.lockAndGet(fXs007s);
for (HGXS007 fXs007 : fXs007s) {
Long id = fXs007.getId();
HGXS007 dbXs007 = dbXs007s.get(id);
this.checkData(dbXs007);
DaoUtils.update(HGXS007.DELETE, fXs007);
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + fXs007s.size() + "]条数据删除成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "删除失败");
}
return inInfo;
}
/**
* 审核
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "客户回访", operType = "审核")
public EiInfo check(EiInfo inInfo) {
try {
List<HGXS007> fXs007s = MapUtils.toDaoEPBases(inInfo, HGXS007.class);
Map<Long, HGXS007> dbXs007s = HGXSUtils.HgXs007.lockAndGet(fXs007s);
for (HGXS007 fXs007 : fXs007s) {
Long id = fXs007.getId();
HGXS007 dbXs007 = dbXs007s.get(id);
this.checkData(dbXs007);
fXs007.setFolStatus(HgXsConstant.FolStatus.S1);
DaoUtils.update(HgXsSqlConstant.HgXs007.CHECK, fXs007);
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + fXs007s.size() + "]条数据审核成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "审核失败");
}
return inInfo;
}
/**
* 检查状态
*
* @param inInfo
* @return
*/
public EiInfo checkStatus(EiInfo inInfo) {
try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
HGXS007 dbXs007 = HGXSUtils.HgXs007.lockAndGet(MapUtils.getLong(queryMap, HGXS007.FIELD_ID));
this.checkData(dbXs007);
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "操作失败");
}
return inInfo;
}
/**
* 数据校验
*
* @param dbXs007
*/
private void checkData(HGXS007 dbXs007) {
AssertUtils.isNotEquals(dbXs007.getDeleteFlag(), CommonConstant.YesNo.NO_0,
String.format("回访单【%s】不是\"未删除\"状态,不允许操作", dbXs007.getId()));
AssertUtils.isNotEquals(dbXs007.getFolStatus(), HgXsConstant.FolStatus.S0,
String.format("回访单【%s】不是\"待回访\"状态,不允许操作", dbXs007.getId()));
}
}
package com.baosight.hggp.hg.xs.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.constant.S3Constant;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.utils.Iplat4jUtils;
import com.baosight.hggp.hg.cw.domain.HGCW002;
import com.baosight.hggp.hg.cw.domain.HGCW999;
import com.baosight.hggp.hg.dm.domain.HGDM099;
import com.baosight.hggp.hg.xs.constant.HgXsConstant;
import com.baosight.hggp.hg.xs.domain.HGXS007;
import com.baosight.hggp.hg.xs.tools.HGXSTools;
import com.baosight.hggp.hg.xs.utils.HGXSUtils;
import com.baosight.hggp.util.AssertUtils;
import com.baosight.hggp.util.CommonMethod;
import com.baosight.hggp.util.DateUtils;
import com.baosight.hggp.util.EiInfoUtils;
import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.MapUtils;
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 java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* 附件清单
*
* @author:songx
* @date:2022/7/11,11:08
*/
public class ServiceHGXS007A extends ServiceEPBase {
/**
* 初始化
*
* @param inInfo
* @return
*/
@Override
public EiInfo initLoad(EiInfo inInfo) {
try {
this.setDetailInfo(inInfo);
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HGDM099().eiMetadata);
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
return inInfo;
}
/**
* 查询操作
*
* @param inInfo
* @return
*/
@Override
@OperationLogAnnotation(operModul = "附件清单", operType = "查询", operDesc = "物料清单-附件清单A-查询")
public EiInfo query(EiInfo inInfo) {
try {
inInfo = super.query(inInfo, HGDM099.QUERY, new HGDM099());
} catch (Throwable e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
}
return inInfo;
}
/**
* 删除
*
* @param inInfo
* @return
*/
public EiInfo remove(EiInfo inInfo) {
try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
Long bizId = MapUtils.getLong(queryMap, HGDM099.FIELD_BIZ_ID);
HGXS007 dbXs007 = HGXSUtils.HgXs007.lockAndGet(bizId);
this.checkData(dbXs007);
List<HGDM099> fDm099s = MapUtils.toDaoEPBases(inInfo, HGDM099.class);
for (HGDM099 fDm099 : fDm099s) {
DaoUtils.update(HGDM099.DELETE, fDm099);
if (!fDm099.getDocId().isEmpty()) {
Iplat4jUtils.deleteFileByDocId(fDm099.getDocId());
}
}
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + fDm099s.size() + "]条数据删除成功!");
} catch (Throwable e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
}
return inInfo;
}
/**
* 数据校验
*
* @param dbXs007
*/
private void checkData(HGXS007 dbXs007) {
AssertUtils.isNotEquals(dbXs007.getDeleteFlag(), CommonConstant.YesNo.NO_0,
String.format("回访单【%s】不是\"未删除\"状态,不允许操作", dbXs007.getId()));
AssertUtils.isNotEquals(dbXs007.getFolStatus(), HgXsConstant.FolStatus.S0,
String.format("回访单【%s】不是\"待回访\"状态,不允许操作", dbXs007.getId()));
}
/**
* 设置信息
*
* @param inInfo
*/
public void setDetailInfo(EiInfo inInfo) {
Map queryRow = EiInfoUtils.getFirstRow(inInfo);
Long bizId = MapUtils.getLong(queryRow, HGDM099.FIELD_BIZ_ID);
if (bizId == null) {
return;
}
EiBlock block = new EiBlock(CommonConstant.Field.DETAIL);
block.addRow(HGXSTools.HgXs007.get(bizId));
block.addBlockMeta(new HGXS007().eiMetadata);
inInfo.setBlock(block);
}
}
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