Commit 505308d1 by 宋祥

1.德诚开放接口

parent 294bfa0c
......@@ -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 List<DcContractList> 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));
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("【德诚】添加工作互动失败");
}
return DcApiUtils.handleResult(result, DcContractList.class);
}
}
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
* 获取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("【智邦】获取项目管理列表失败");
public static String getTokenCache() {
String token = SingletonHolder.TOKEN;
if (StringUtils.isNotBlank(token)) {
return token;
}
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;
}
/**
* 构建返回结果对象
*
* @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);
}
/**
* 处理返回消息
*
* @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();
} else if (DeChengConst.ApiStatus.S2.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");
String status = headerJson.getString("status");
// 会话非法
if (DeChengConst.ApiStatus.S400.equals(status)) {
DcTokenApi.refreshToken();
} else if (DeChengConst.ApiStatus.S2.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);
}
......@@ -654,7 +654,9 @@ public class HGSqlConstant {
* @date:2024/1/20,16:45
*/
public class HgXsOrg {
// 查询组织机构
public static final String GET = "HGXSOrg.get";
// 查询组织机构
public static final String QUERY = "HGXSOrg.query";
// 查询企业下所有的组织机构
......
......@@ -16,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;
......@@ -350,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());
// 规格
......@@ -540,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);
// 新增组织机构顶级
......
......@@ -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 {
......
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";
}
}
......@@ -13,7 +13,11 @@ public class HgWdSqlConstant {
* @date:2024/2/22,13:57
*/
public static class HgWd001 {
// 根据父节点统计
public static final String COUNT_BY_PARENT = "HGWD001.countByParent";
// 搜索树节点
public static final String SEARCH_TREE_NODE = "HGWD001.searchTreeNode";
}
}
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;
......
......@@ -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) {
results.add(buildLeaf(parentLabel, dbSc001.getProjCode(), dbSc001.getProjName(), 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;
}
}
......@@ -17,6 +17,7 @@
COMPANY_NAME as "companyName", <!-- 公司名称 -->
PROJ_CODE as "projCode", <!-- 项目编码 -->
PROJ_NAME as "projName", <!-- 项目名称 -->
PARENT_ID as "parentId", <!-- 父级ID -->
FILE_ID as "fileId", <!-- 文件ID -->
FILE_TYPE as "fileType", <!-- 文件类型 -->
FILE_NAME as "fileName", <!-- 文件名称 -->
......@@ -27,6 +28,7 @@
</sql>
<sql id="condition">
AND DELETE_FLAG = 0
<isNotEmpty prepend=" AND " property="id">
ID = #id#
</isNotEmpty>
......@@ -54,9 +56,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 +68,9 @@
<isNotEmpty prepend=" AND " property="projName">
PROJ_NAME LIKE CONCAT('%', #projName#, '%')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="parentId">
PARENT_ID = #parentId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="fileId">
FILE_ID = #fileId#
</isNotEmpty>
......@@ -88,10 +90,16 @@
REMARK = #remark#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="releaseDate">
RELEASE_DATE = #releaseDate#
RELEASE_DATE = #releaseDate#
</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 +126,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 +174,7 @@
COMPANY_NAME, <!-- 公司名称 -->
PROJ_CODE, <!-- 项目编码 -->
PROJ_NAME, <!-- 项目名称 -->
PARENT_ID, <!-- 父级ID -->
FILE_ID, <!-- 文件ID -->
FILE_TYPE, <!-- 文件类型 -->
FILE_NAME, <!-- 文件名称 -->
......@@ -140,7 +185,7 @@
) VALUES (
#accountCode#, #depCode#, #createdBy#, #createdName#, #createdTime#,
#deleteFlag#, #companyCode#, #companyName#, #projCode#, #projName#,
#fileId#, #fileType#, #fileName#,
#parentIdId#, #fileId#, #fileType#, #fileName#,
#docVersion#, #status#, #remark#, #releaseDate#
<selectKey resultClass="long" keyProperty="id">
SELECT MAX(ID) AS "id" FROM ${hggpSchema}.HGWD001
......
<?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
......@@ -49,11 +51,41 @@ 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);
......
......@@ -7,6 +7,28 @@ package com.baosight.hggp.hg.xs.constant;
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
......
......@@ -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;
}
......
......@@ -3,28 +3,44 @@ 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.enums.DeleteFlagEnum;
import com.baosight.hggp.core.enums.OrgTypeEnum;
import com.baosight.hggp.core.extapp.decheng.api.DcOpenApi;
import com.baosight.hggp.core.extapp.decheng.model.DcDeptList;
import com.baosight.hggp.core.model.Pager;
import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.hg.sc.domain.HGSC098;
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.xs.constant.HgXsSqlConstant;
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.DateUtils;
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.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 org.apache.commons.collections.CollectionUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
/**
* @author:songx
* @date:2024/1/15,15:08
*/
@Slf4j
public class ServiceHGXSOrg extends ServiceBase {
/**
......@@ -99,5 +115,101 @@ public class ServiceHGXSOrg extends ServiceBase {
}
return inInfo;
}
/**
* 同步智邦部门信息
*
* @param inInfo
* @return
*/
public EiInfo syncDcDept(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 {
syncDcDeptData(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 syncDcDeptData(String accountCode) throws IOException, InstantiationException, IllegalAccessException {
int pageIndex = 1;
Pager<DcDeptList> pager = DcOpenApi.deptList(pageIndex);
List<DcDeptList> zbDepts = pager.getData();
if (CollectionUtils.isEmpty(zbDepts)) {
return;
}
// 写入合同数据
syncDcDeptData(accountCode, zbDepts);
}
/**
* 写入部门信息
*
* @param accountCode
* @param zbDepts
*/
private void syncDcDeptData(String accountCode, List<DcDeptList> zbDepts) {
// 查询帐套信息
HGPZ009 dbPz009 = HGPZTools.HgPz009.getByCode(accountCode);
for (DcDeptList zbDept : zbDepts) {
String orgId = dbPz009.getLoginPrefix() + zbDept.getNodeId();
Org dbOrg = HGXSTools.XsOrg.get(orgId);
if (dbOrg == null) {
dbOrg = new Org();
dbOrg.setOrgId(orgId);
this.syncDcDeptAdd(accountCode, zbDept, dbOrg, dbPz009);
} else {
Map updateMap = new HashMap();
updateMap.put(Org.FIELD_ORG_ID, orgId);
updateMap.put(Org.FIELD_ORG_CNAME, zbDept.getNodeText());
updateMap.put(Org.FIELD_REC_REVISOR, "System");
updateMap.put(Org.FIELD_REC_REVISE_TIME, DateUtils.shortDateTime());
updateMap.put(Org.FIELD_IS_DELETED, DeleteFlagEnum.UN_REMOVE.getCode().toString());
dao.update(HgXsSqlConstant.HgXsOrg.UPDATE_ORG_CNAME, updateMap);
}
}
}
/**
* 新增数据
*
* @param accountCode
* @param zbDept
* @param dbOrg
* @param dbPz009
*/
private void syncDcDeptAdd(String accountCode, DcDeptList zbDept, Org dbOrg, HGPZ009 dbPz009) {
String orgId = dbOrg.getOrgId();
dbOrg.setAccountCode(accountCode);
dbOrg.setOrgEname(orgId);
dbOrg.setOrgCname(zbDept.getNodeText());
dbOrg.setOrgType(OrgTypeEnum.DEPT.getCode());
dbOrg.setParentOrgId("-1".equals(zbDept.getParentId())
? accountCode : dbPz009.getLoginPrefix() + zbDept.getParentId());
dbOrg.setEstablishDate("20240101");
dbOrg.setSortIndex(zbDept.getFullSort());
dbOrg.setCompanyCode(accountCode);
dbOrg.setCompanyName(dbPz009.getAccountName());
dbOrg.setRecCreator("System");
dbOrg.setRecCreateTime(DateUtils.shortDateTime());
dbOrg.setIsDeleted(DeleteFlagEnum.UN_REMOVE.getCode().toString());
dao.insert("XSOG01.insert", dbOrg);
}
}
......@@ -2,27 +2,46 @@ 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.extapp.decheng.api.DcOpenApi;
import com.baosight.hggp.core.extapp.decheng.model.DcUser;
import com.baosight.hggp.core.extapp.decheng.model.DcUserList;
import com.baosight.hggp.core.model.Pager;
import com.baosight.hggp.core.security.UserSessionUtils;
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.xs.constant.HgXsSqlConstant;
import com.baosight.hggp.hg.xs.domain.User;
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.hggp.util.ObjectUtils;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
/**
* 当前类已屏蔽SQL自动补全企业参数,如需查询需要需自行添加企业编码参数
*
* @author:songx
* @date:2024/1/15,15:08
*/
@Slf4j
public class ServiceHGXSUser extends ServiceBase {
/**
......@@ -112,13 +131,13 @@ public class ServiceHGXSUser extends ServiceBase {
}else {
CommonMethod.initBlock(inInfo, list, queryMap, false);
}
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "查询企业失败");
}
return inInfo;
}
/**
* 查询用户下拉框
*
......@@ -137,7 +156,7 @@ public class ServiceHGXSUser extends ServiceBase {
}
return inInfo;
}
/**
* 查询用户的企业下拉框
*
......@@ -160,4 +179,153 @@ public class ServiceHGXSUser extends ServiceBase {
return inInfo;
}
/**
* 同步德诚用户信息
*
* @param inInfo
* @return
*/
public EiInfo syncDcSingleUser(EiInfo inInfo) {
try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
HGPZ009 dbPz009 = HGPZTools.HgPz009.getByCode(MapUtils.getString(queryMap, HGPZ009.FIELD_ACCOUNT_CODE));
Integer ord = MapUtils.getInteger(queryMap, "ord");
syncDcUserSingle(dbPz009, ord);
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsg("同步德诚用户信息成功");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "同步德诚用户信息失败");
}
return inInfo;
}
/**
* 同步智邦用户信息
*
* @param inInfo
* @return
*/
public EiInfo syncDcUser(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 {
syncDcUserData(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 syncDcUserData(String accountCode) throws Exception {
int pageIndex = 1;
while (true) {
// 超过1000次不在执行
if (pageIndex > 1000) {
break;
}
Pager<DcUserList> pager = DcOpenApi.userList(pageIndex);
List<DcUserList> zbUsers = pager.getData();
if (CollectionUtils.isEmpty(zbUsers) || pageIndex > pager.getTotalPages()) {
break;
}
// 写入合同数据
syncDcUserData(accountCode, zbUsers);
pageIndex++;
}
}
/**
* 写入用户信息
*
* @param accountCode
* @param ZbUserLists
*/
private void syncDcUserData(String accountCode, List<DcUserList> ZbUserLists) {
// 查询帐套信息
HGPZ009 dbPz009 = HGPZTools.HgPz009.getByCode(accountCode);
for (DcUserList zbUserList : ZbUserLists) {
try {
syncDcUserSingle(dbPz009, zbUserList.getOrd());
} catch (Exception e) {
log.error("同步德诚用户失败:{}", e.getMessage(), e);
}
}
}
/**
* 同步单个用户
*
* @param dbPz009
* @param ord
* @throws IOException
*/
private void syncDcUserSingle(HGPZ009 dbPz009, Integer ord) throws Exception {
// 获取用户详情
DcUser zbUser = DcOpenApi.userDetail(ord);
if (zbUser == null) {
return;
}
String userId = dbPz009.getLoginPrefix() + ord;
// 判断用户是否存在
User dbUser = HGXSTools.XsUser.get(userId);
if (dbUser == null) {
this.syncDcSingleUserAdd(zbUser, dbPz009, userId);
} else {
this.syncDcSingleUserModify(zbUser, userId);
}
}
/**
* 新增用户
*
* @param zbUser
* @param dbPz009
* @param userId
* @throws Exception
*/
private void syncDcSingleUserAdd(DcUser zbUser, HGPZ009 dbPz009, String userId)
throws Exception {
// 新增用户
HGXSTools.XsUser.addUser(dbPz009.getAccountCode(), userId, zbUser.getName(), zbUser.getSex(), zbUser.getEmail(),
zbUser.getCardid());
// 新增用户和组织机构关系
Map addMap = new HashMap();
addMap.put("orgId", dbPz009.getLoginPrefix() + zbUser.getOrgsid());
addMap.put("userId", userId);
addMap.put("recCreator", "System");
addMap.put("recCreateTime", DateUtils.shortDateTime());
dao.insert(HgXsSqlConstant.HgXsOrg.ADD_RELATION, addMap);
}
/**
* @param zbUser
* @param userId
*/
private void syncDcSingleUserModify(DcUser zbUser, String userId) {
Map updateMap = new HashMap();
updateMap.put(User.FIELD_LOGIN_NAME, userId);
updateMap.put(User.FIELD_USER_NAME, zbUser.getName());
updateMap.put(User.FIELD_GENDER, HGXSUtils.XsUser.convertGender(zbUser.getSex()));
updateMap.put(User.FIELD_EMAIL, zbUser.getEmail());
updateMap.put(User.FIELD_MOBILE, zbUser.getMobile());
updateMap.put(User.FIELD_ID_CARD, zbUser.getCardid() == null ? " " : zbUser.getCardid());
updateMap.put(User.FIELD_REC_REVISOR, "System");
updateMap.put(User.FIELD_REC_REVISE_TIME, DateUtils.shortDateTime());
dao.update(HgXsSqlConstant.HgXsUser.UPDATE_DC_USER, updateMap);
}
}
......@@ -2,6 +2,17 @@
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="HGXSOrg">
<sql id="column">
ORG_ID as "orgId",
ORG_ENAME as "orgEname",
ORG_CNAME as "orgCname",
ORG_TYPE as "orgType",
PARENT_ORG_ID as "parentOrgId",
ACCOUNT_CODE AS "accountCode",
FACTORY_CODE AS "factoryCode",
COMPANY_CODE AS "companyCode"
</sql>
<sql id="condition">
AND IS_DELETED = '0'
<isNotEmpty prepend=" AND " property="accountCode">
......@@ -42,16 +53,18 @@
</sql>
<!-- 查询组织信息 -->
<select id="get" resultClass="com.baosight.hggp.hg.xs.domain.Org">
SELECT
<include refid="column"/>
FROM ${platSchema}.TXSOG01
WHERE 1=1
AND ORG_ID = #orgId#
</select>
<!-- 查询组织信息 -->
<select id="query" resultClass="com.baosight.hggp.hg.xs.domain.Org">
SELECT
ORG_ID as "orgId",
ORG_ENAME as "orgEname",
ORG_CNAME as "orgCname",
ORG_TYPE as "orgType",
PARENT_ORG_ID as "parentOrgId",
ACCOUNT_CODE AS "accountCode",
FACTORY_CODE AS "factoryCode",
COMPANY_CODE AS "companyCode"
<include refid="column"/>
FROM ${platSchema}.TXSOG01
WHERE 1=1
<include refid="condition"/>
......@@ -242,4 +255,23 @@
AND C.LOGIN_NAME = #loginName#
</select>
<!-- 修改组织名称 -->
<update id="updateOrgCname">
UPDATE ${platSchema}.TXSOG01
SET
ORG_CNAME = #orgCname#,
REC_REVISOR = #recRevisor#,
REC_REVISE_TIME = #recReviseTime#,
IS_DELETED = '0'
WHERE ORG_ID = #orgId#
</update>
<!-- 新增管理 -->
<insert id="addRelation">
INSERT INTO ${platSchema}.TXSOG02 (
ORG_ID, USER_ID, REC_CREATOR, REC_CREATE_TIME
) VALUES (
#orgId#, #userId#, #recCreator#, #recCreateTime#
)
</insert>
</sqlMap>
......@@ -102,4 +102,18 @@
</isNotEmpty>
</select>
<!-- 修改德诚用户名称 -->
<update id="updateDcUser">
UPDATE ${platSchema}.XS_USER
SET
USER_NAME = #userName#,
GENDER = #gender#,
MOBILE = #mobile#,
EMAIL = #email#,
ID_CARD = #idCard#,
REC_REVISOR = #recRevisor#,
REC_REVISE_TIME = #recReviseTime#
WHERE LOGIN_NAME = #loginName#
</update>
</sqlMap>
......@@ -9,6 +9,7 @@ import com.baosight.hggp.hg.xs.domain.HGXS007;
import com.baosight.hggp.hg.xs.domain.Org;
import com.baosight.hggp.hg.xs.domain.User;
import com.baosight.hggp.hg.xs.domain.UserGroup;
import com.baosight.hggp.hg.xs.utils.HGXSUtils;
import com.baosight.hggp.util.AssertUtils;
import com.baosight.hggp.util.MapUtils;
import com.baosight.hggp.util.ObjectUtils;
......@@ -206,8 +207,8 @@ public class HGXSTools {
* @param gender
* @param mobile
*/
public static void addUser(String accountCode, String userId, String userName, String gender, String mobile)
throws Exception {
public static void addUser(String accountCode, String userId, String userName, String gender, String mobile,
String idCard) throws Exception {
Map inInfoRowMap = new HashMap();
inInfoRowMap.put("userId", userId);
inInfoRowMap.put("loginName", userId);
......@@ -217,7 +218,8 @@ public class HGXSTools {
inInfoRowMap.put("password", password);
inInfoRowMap.put("rePass", password);
inInfoRowMap.put("email", " ");
inInfoRowMap.put("gender", StringUtils.isBlank(gender) ? " " : gender);
inInfoRowMap.put("idCard", StringUtils.isBlank(idCard) ? " " : idCard);
inInfoRowMap.put("gender", HGXSUtils.XsUser.convertGender(gender));
inInfoRowMap.put("mobile", StringUtils.isBlank(mobile) ? " " : mobile);
inInfoRowMap.put("accountCode", accountCode);
EiInfo inInfo = new EiInfo();
......@@ -315,7 +317,7 @@ public class HGXSTools {
*
* @return
*/
public static Org get(String orgId) {
public static Org query(String orgId) {
AssertUtils.isEmpty(orgId, "组织编码不能为空");
Map paramMap = new HashMap();
paramMap.put("orgId", orgId);
......@@ -327,6 +329,19 @@ public class HGXSTools {
/**
* 查询组织机构
*
* @return
*/
public static Org get(String orgId) {
AssertUtils.isEmpty(orgId, "组织编码不能为空");
Map paramMap = new HashMap();
paramMap.put(Org.FIELD_ORG_ID, orgId);
List<Org> results = DaoBase.getInstance().query(HGSqlConstant.HgXsOrg.GET, paramMap);
return CollectionUtils.isEmpty(results) ? null : results.get(0);
}
/**
* 查询组织机构
*
* @param orgIds
* @return
*/
......
......@@ -8,6 +8,7 @@ import com.baosight.hggp.hg.xs.domain.UserGroup;
import com.baosight.hggp.hg.xs.tools.HGXSTools;
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 org.apache.commons.collections.CollectionUtils;
......@@ -22,6 +23,34 @@ import java.util.Map;
public class HGXSUtils {
/**
* @author:songx
* @date:2024/8/29,22:11
*/
public static class XsUser {
/**
* 性别转换
*
* @param gender
* @return
*/
public static String convertGender(String gender) {
if (StringUtils.isBlank(gender)) {
return " ";
} else if ("男".equals(gender)) {
return "1";
} else if ("女".equals(gender)) {
return "2";
} else if ("1".equals(gender) || "2".equals(gender)) {
return gender;
} else {
return " ";
}
}
}
/**
* 用户组
*
* @author:songx
......
......@@ -41,7 +41,7 @@ public class ServiceXSOG0800 extends TreeService {
map.put("label", "root");
map.put("text", "组织机构");
} else {
Org org = HGXSTools.XsOrg.get(accountCode);
Org org = HGXSTools.XsOrg.query(accountCode);
map.put("label", org == null ? "root" : org.getOrgId());
map.put("text", org == null ? "组织机构" : org.getOrgCname());
}
......
package com.baosight.xservices.xs.og.service;
import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.enums.OrgTypeEnum;
import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.hg.constant.HGConstant;
......@@ -353,7 +352,7 @@ public class ServiceXSOG0801 extends ServiceBase {
deleteMap.put("orgId", orgId);
String userId = MapUtils.getString(deleteMap, "userId");
// 清空组织机构
Org org = HGXSTools.XsOrg.get(orgId);
Org org = HGXSTools.XsOrg.query(orgId);
clearHp013(orgId, org.getOrgType(), userId);
}
call.set("list", inInfo.getBlock(EiConstant.resultBlock).getRows());
......@@ -489,7 +488,7 @@ public class ServiceXSOG0801 extends ServiceBase {
row.put("recRevisor", UserSession.getLoginName());
String orgId = MapUtils.getString(row, "orgEname");
// 清空组织机构下面人员的工人关系
Org org = HGXSTools.XsOrg.get(orgId);
Org org = HGXSTools.XsOrg.query(orgId);
// 校验是否存在进行中的任务
this.checkExistsTask(org.getOrgId(), org.getOrgCname(), org.getOrgType());
// 清除用工关系
......
......@@ -52,7 +52,7 @@ public class ServiceXSOG0801A extends ServiceEPBase {
OrgTypeEnum.DEPT.getCode());
} else {
// 查询组织
Org org = HGXSTools.XsOrg.get(parentOrgId);
Org org = HGXSTools.XsOrg.query(parentOrgId);
if(CommonConstant.Field.ROOT.equals(org.getParentOrgId())) {
condition = String.format(" ITEM_CODE IN ('%s', '%s', '%s')", OrgTypeEnum.COMPANY.getCode(),
OrgTypeEnum.FACTORY.getCode(), OrgTypeEnum.DEPT.getCode());
......
package com.baosight.xservices.xs.og.service;
import com.baosight.hggp.core.constant.CodesetConstant;
import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.enums.OrgTypeEnum;
import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.core.tools.CodeValueTools;
......@@ -40,7 +39,7 @@ public class ServiceXSOG0801B extends ServiceEPBase {
public EiInfo initLoad(EiInfo inInfo) {
try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
Org org = HGXSTools.XsOrg.get(MapUtils.getString(queryMap, "orgId"));
Org org = HGXSTools.XsOrg.query(MapUtils.getString(queryMap, "orgId"));
// 回填父级ID
queryMap.put("parentOrgId", org.getParentOrgId());
String condition;
......
......@@ -83,8 +83,9 @@ public class ServiceXS0102 extends ServiceEPBase implements LoginConstants {
return inInfo;
}
// 企业账号无需校验身份证 added by songx at 20240819
if (loginName.lastIndexOf("0000") < 0) {
AssertUtils.isTrue(!HGSCUtil.isValidChineseID(idCard), "请填写正确的身份证号!");
if (!(loginName.lastIndexOf("0000") > -1 || " ".equals(idCard))) {
AssertUtils.isEmpty(idCard, "请填写正确的身份证号");
// AssertUtils.isTrue(!HGSCUtil.isValidChineseID(idCard), "请填写正确的身份证号!");
}
if (!rePass.equals(password)) {
inInfo.setStatus(-1);
......
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" monitorInterval="10">
<Properties>
<Property name="PID">mylog</Property>
<Configuration status="WARN">
<properties>
<property name="LOG_HOME">./logs</property>
<Property name="LOG_EXCEPTION_CONVERSION_WORD">%xwEx</Property>
<Property name="LOG_LEVEL_PATTERN">%5p</Property> <!--<Property name="LOG_PATTERN">%d{yyyy-MM-dd HH:mm:ss} %-5level [%thread][%file:%line] - %msg%n</Property>-->
<!--参考文档 https://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout -->
<Property name="LOG_PATTERN">%highlight{%d{yyyy-MM-dd HH:mm:ss} %-5level [%thread] %logger{1.} - %msg%n%}</Property>
<Property name="filename">iplat.$${date:yyyy-MM-dd}.log</Property>
</Properties>
<Appenders> <!--<Console name="Console" target="SYSTEM_OUT" follow="true">--> <!--<PatternLayout pattern="${LOG_PATTERN}"/>--> <!--</Console>--> <!-- 用来定义输出到控制台的配置 -->
<Console name="Console" target="SYSTEM_OUT"> <!-- 设置控制台只输出error及以上级别的信息(onMatch),其他的直接拒绝(onMismatch)-->
<ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY" />
<PatternLayout pattern="${LOG_PATTERN}" />
<Property name="LOG_LEVEL_PATTERN">%5p</Property>
<Property name="LOG_PATTERN">%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level[%thread] %logger{1.} - %msg%n</Property>
</properties>
<Appenders>
<!--*********************控制台日志***********************-->
<Console name="Console" target="SYSTEM_OUT" follow="true">
<PatternLayout charset="GBK" pattern="${LOG_PATTERN}"/>
</Console>
<RollingRandomAccessFile name="MyFile" fileName="apps/logs/iplat.log" filePattern="apps/logs/iplat.%d{yyyy-MM-dd}-%i.log.gz">
<TextArea name="platLogAppender">
<PatternLayout pattern="%m%n"/>
</TextArea>
<!--*********************文件日志***********************-->
<!--info级别日志-->
<RollingFile name="InfoAppender" fileName="${LOG_HOME}/info.log"
filePattern="${LOG_HOME}/%d{yyyy-MM-dd}/info-%i.log.gz">
<!-- <Filters>-->
<!-- &lt;!&ndash;过滤掉warn及更高级别日志&ndash;&gt;-->
<!-- <ThresholdFilter level="warn" onMatch="DENY" onMismatch="NEUTRAL"/>-->
<!-- </Filters>-->
<!--设置日志格式-->
<PatternLayout>
<Pattern>%d{yyyy-MM-dd HH:mm:ss} %-5level [%thread] %logger{1.} - %msg%n%throwable{short}</Pattern>
<pattern>${LOG_PATTERN}</pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true" />
<SizeBasedTriggeringPolicy size="1024 MB" />
<!-- 设置日志文件切分参数 -->
<!--<OnStartupTriggeringPolicy/>-->
<!--设置日志基础文件大小,超过该大小就触发日志文件滚动更新-->
<SizeBasedTriggeringPolicy size="20MB"/>
<!--设置日志文件滚动更新的时间,依赖于文件命名filePattern的设置-->
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
</Policies>
<DefaultRolloverStrategy max="50" />
</RollingRandomAccessFile>
<TextArea name="platLogAppender">
<PatternLayout pattern="%m%n" />
</TextArea>
<!--设置日志的文件个数上限,不设置默认为7个,超过大小后会被覆盖;依赖于filePattern中的%i-->
<DefaultRolloverStrategy max="100"/>
</RollingFile>
<!--warn级别日志-->
<RollingFile name="WarnAppender" fileName="${LOG_HOME}/warn.log"
filePattern="${LOG_HOME}/%d{yyyy-MM-dd}/warn-%i.log.gz">
<Filters>
<!--过滤掉error及更高级别日志-->
<ThresholdFilter level="error" onMatch="DENY" onMismatch="NEUTRAL"/>
</Filters>
<!--设置日志格式-->
<PatternLayout>
<pattern>${LOG_PATTERN}</pattern>
</PatternLayout>
<Policies>
<!-- 设置日志文件切分参数 -->
<!--<OnStartupTriggeringPolicy/>-->
<!--设置日志基础文件大小,超过该大小就触发日志文件滚动更新-->
<SizeBasedTriggeringPolicy size="20MB"/>
<!--设置日志文件滚动更新的时间,依赖于文件命名filePattern的设置-->
<TimeBasedTriggeringPolicy/>
</Policies>
<!--设置日志的文件个数上限,不设置默认为7个,超过大小后会被覆盖;依赖于filePattern中的%i-->
<DefaultRolloverStrategy max="100"/>
</RollingFile>
<!--error及更高级别日志-->
<RollingFile name="ErrorAppender" fileName="${LOG_HOME}/error.log"
filePattern="${LOG_HOME}/%d{yyyy-MM-dd}/error-%i.log.gz">
<!--设置日志格式-->
<PatternLayout>
<pattern>${LOG_PATTERN}</pattern>
</PatternLayout>
<Policies>
<!-- 设置日志文件切分参数 -->
<!--<OnStartupTriggeringPolicy/>-->
<!--设置日志基础文件大小,超过该大小就触发日志文件滚动更新-->
<SizeBasedTriggeringPolicy size="20MB"/>
<!--设置日志文件滚动更新的时间,依赖于文件命名filePattern的设置-->
<TimeBasedTriggeringPolicy/>
</Policies>
<!--设置日志的文件个数上限,不设置默认为7个,超过大小后会被覆盖;依赖于filePattern中的%i-->
<DefaultRolloverStrategy max="100"/>
</RollingFile>
<Async name="Async">
<AppenderRef ref="InfoAppender" level="info"/>
<AppenderRef ref="WarnAppender" level="warn"/>
<AppenderRef ref="ErrorAppender" level="error"/>
</Async>
</Appenders>
<Loggers> <!--用来增加sql的日志,无论下面root logger级别是什么都输出sql log-->
<logger name="com.baosight.iplat4j.core.data.ibatis.dao.SqlMapDaoLogProxy" level="ERROR" />
<AsyncLogger name="com.baosight.iplat4j" level="INFO" additivity="false">
<AppenderRef ref="Console" />
<AppenderRef ref="MyFile" />
<AppenderRef ref="platLogAppender" />
</AsyncLogger>
<logger name="org.springframework" level="ERROR" />
<logger name="org.thymeleaf" level="ERROR" />
<Root level="INFO">
<AppenderRef ref="Console" />
<AppenderRef ref="MyFile" />
<AppenderRef ref="platLogAppender" />
<Loggers>
<!-- 根日志设置 -->
<Root level="info">
<AppenderRef ref="Console"/>
<AppenderRef ref="Async"/>
</Root>
<!--用来增加sql的日志,无论下面root logger级别是什么都输出sql log-->
<logger name="com.baosight.iplat4j.core.data.ibatis.dao.SqlMapDaoLogProxy" level="info"/>
<!--spring日志-->
<Logger name="org.springframework" level="error"/>
<!-- mybatis日志 -->
<Logger name="com.mybatis" level="warn"/>
<Logger name="org.hibernate" level="warn"/>
<Logger name="com.zaxxer.hikari" level="warn"/>
<Logger name="org.quartz" level="warn"/>
</Loggers>
</Configuration>
......@@ -97,5 +97,6 @@
<!-- 文档库 -->
<sqlMap resource="com/baosight/hggp/hg/wd/sql/HGWD001.xml"/>
<sqlMap resource="com/baosight/hggp/hg/wd/sql/HGWD002.xml"/>
<sqlMap resource="com/baosight/hggp/hg/wd/sql/HGWD003.xml"/>
</sqlMapConfig>
......@@ -11,7 +11,7 @@
<EF:EFInput ename="inqu_status-0-whCode" cname="仓库编码" colWidth="3" type="hidden"/>
<EF:EFInput ename="inqu_status-0-receiveId" cname="领料单id" colWidth="3" type="hidden"/>
<div class="row">
<EF:EFSelect cname="存货类型" blockId="inqu_status" ename="inventType" row="0" colWidth="3"
<EF:EFSelect cname="存货类型" ename="inventType" blockId="inqu_status" row="0" colWidth="3"
optionLabel="全部" defultValue="" filter="contains">
<EF:EFOptions blockId="invent_type_block_id" textField="textField" valueField="valueField"/>
</EF:EFSelect>
......
......@@ -16,7 +16,7 @@
<EF:EFColumn ename="operator" cname="操作" locked="true" enable="false" width="100" align="center"/>
<EF:EFColumn ename="companyName" cname="公司名称" enable="false" width="120" align="center"/>
<EF:EFColumn ename="projCode" cname="项目编码" enable="false" width="120" align="center"/>
<EF:EFColumn ename="projName" cname="项目名称" enable="false" width="120" align="center"/>
<EF:EFColumn ename="projName" cname="项目名称" enable="false" width="220" align="left"/>
<EF:EFColumn ename="createdBy" cname="创建人" enable="false" width="100" align="center"/>
<EF:EFColumn ename="createdTime" cname="创建时间" enable="false" width="140" align="center"
editType="datetime" parseFormats="['yyyyMMddHHmmss','yyyy-MM-dd HH:mm:ss']"/>
......
$(function () {
IPLATUI.EFTree = {
"docTree": {
select: function (e) {
var nodeData = this.dataItem(e.node);
let value = nodeData.label;
let leafType = nodeData.leafType;
IPLATUI.EFTree.docTree.selectNode.treeId = value;
IPLATUI.EFTree.docTree.selectNode.leaf = nodeData.leaf;
IPLATUI.EFTree.docTree.selectNode.leafType = leafType;
// leafType=C:目录
if (leafType == 'C') {
$("#inqu_status-0-fileId").val(value);
$("#inqu_status-0-fileName").val(nodeData.text);
} else {
$("#inqu_status-0-fileId").val('');
$("#inqu_status-0-fileName").val('');
}
resultGrid.dataSource.page(1);
// 显示授权按钮
showAuthButton();
},
selectNode: {
treeId: '',
leaf: false,
leafType: ''
}
// ROOT: {label: "root", text: "系统菜单", leaf: true}
}
};
IPLATUI.EFGrid = {
"result": {
exportGrid: false, // 隐藏右侧自定义导出按钮
loadComplete: function (grid) {
}
}
}
// 树节点查询
$("#search").on("click", search);
// 查询
$("#QUERY").on("click", query);
// 授权
$("#AUTH").on("click", auth);
// 删除
$("#REMOVE_USER").on("click", removeUser);
});
/**
* 页面加载
*/
$(window).load(function () {
// 查询
query();
// 授权按钮是否可用
showAuthButton();
});
/**
* 查询
*/
let query = function () {
resultGrid.dataSource.page(1);
}
/**
* 树节点查询
*/
let search = function () {
let tree = $("#docTree").data("kendoTreeView");
let fileName = $("#searchText").val();
if (isBlank(fileName)) {
return;
}
let inInfo = new EiInfo();
inInfo.set("inqu_status-0-fileName", fileName);
EiCommunicator.send("HGWD003", "searchNode", inInfo, {
onSuccess: function (res) {
if (-1 === res.getStatus()) {
message(res.msg);
return;
}
// 获取所有满足条件的子节点路径
var nodes = res.getBlock("$").getMappedRows();
expandTreeNode(tree, nodes);
},
onFail: function (res) {
message(res.msg);
}
});
}
/**
* 批量展开树节点
*
* @param tree
* @param nodeIdList
*/
function expandTreeNode(tree, nodes) {
if (nodes.length === 0 || tree == null) {
return;
}
const node = nodes[0];
let barDataItem = tree.dataSource.get(node);
if (barDataItem) {
tree.expandPath(nodes)
} else {
setTimeout(() => {
expandTreeNode(tree, nodes)
}, 100)
}
}
/**
* 授权
*/
let auth = function () {
let fileId = $("#inqu_status-0-fileId").val();
if (isBlank(fileId)) {
message("请选择需要授权的目录");
return;
}
let fileName = $("#inqu_status-0-fileName").val();
let params = {
"inqu_status-0-fileId": fileId
}
JSColorbox.open({
href: "HGWD003A",
title: "<div style='text-align: center;'>正在为:【" + fileName + "】授权用户</div>",
width: "70%",
height: "80%",
params: params,
callbackName: authCallback
});
}
/**
* 授权回调
*/
let authCallback = function (res) {
// 刷新页面
query();
}
/**
* 删除授权用户
*/
let removeUser = function () {
let rows = resultGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据");
return;
}
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"删除\"操作? ", {
ok: function () {
JSUtils.submitGridsData("result", "HGWD003", "removeUser",
false, function (res) {
message(res.msg);
if (res.status !== -1) {
query();
}
}
);
}
});
}
/**
* 显示授权按钮
*/
let showAuthButton = function () {
let leafType = IPLATUI.EFTree.docTree.selectNode.leafType;
// C:目录
if (leafType && leafType === 'C') {
$("#AUTH").attr("disabled", false);
$("#REMOVE_USER").attr("disabled", false);
} else {
$("#AUTH").attr("disabled", true);
$("#REMOVE_USER").attr("disabled", true);
}
}
<!DOCTYPE html>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="EF" tagdir="/WEB-INF/tags/EF" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<EF:EFPage title="文档权限管理">
<div class="row" style="margin: 0 -10px;">
<div class="col-md-4">
<EF:EFRegion title="文档目录树" id="tree" fitHeight="true">
<%-- <div class="row" style="display: block">--%>
<%-- <div class="col-md-12" style="display:flex;align-items: center">--%>
<%-- <EF:EFInput ename="searchText" colWidth="8" inline="true"/>--%>
<%-- <EF:EFButton ename="search" class="fa fa-search" layout="2"/>--%>
<%-- </div>--%>
<%-- </div>--%>
<div id="menu" style="margin-top: 12px; margin-bottom: 8px">
<EF:EFTree bindId="docTree" ename="node" textField="text" valueField="label" hasChildren="leaf"
serviceName="HGWD003" methodName="queryTree">
</EF:EFTree>
</div>
</EF:EFRegion>
</div>
<div class="col-md-8">
<EF:EFRegion title="查询区" id="inqu">
<EF:EFInput cname="文件ID" ename="fileId" blockId="inqu_status" row="0" type="hidden"/>
<div class="row">
<EF:EFInput cname="文件名称" ename="fileName" blockId="inqu_status" row="0" colWidth="3"
readonly="true"/>
<EF:EFInput cname="部门名称" ename="orgCname" blockId="inqu_status" row="0" colWidth="3"/>
<EF:EFInput cname="用户账号" ename="userId" blockId="inqu_status" row="0" colWidth="3"/>
<EF:EFInput cname="用户姓名" ename="userName" blockId="inqu_status" row="0" colWidth="3"/>
</div>
</EF:EFRegion>
<EF:EFRegion title="已授权用户结果集" id="result">
<EF:EFGrid blockId="result" autoDraw="override" checkMode="row">
<EF:EFColumn ename="id" cname="ID" hidden="true"/>
<EF:EFColumn ename="orgCname" cname="部门名称" enable="false" width="120" align="center"/>
<EF:EFColumn ename="userId" cname="用户账号" enable="false" width="100" align="center"/>
<EF:EFColumn ename="userName" cname="用户姓名" enable="false" width="120" align="center"/>
<EF:EFColumn ename="createdName" cname="创建人" enable="false" width="100" align="center"/>
<EF:EFColumn ename="createdTime" cname="创建时间" enable="false" width="140" align="center"
editType="datetime" parseFormats="['yyyyMMddHHmmss','yyyy-MM-dd HH:mm:ss']"/>
</EF:EFGrid>
</EF:EFRegion>
</div>
</div>
</EF:EFPage>
$(function () {
IPLATUI.EFGrid = {
"result": {
exportGrid: false, // 隐藏右侧自定义导出按钮
loadComplete: function (grid) {
}
}
}
// 查询
$("#QUERY").on("click", query);
// 授权用户
$("#AUTH_USER").on("click", authUser);
});
/**
* 页面加载
*/
$(window).load(function () {
// 查询
query();
});
/**
* 查询
*/
let query = function () {
resultGrid.dataSource.page(1);
}
/**
* 授权用户
*/
let authUser = function () {
let rows = resultGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据");
return;
}
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"授权\"操作? ", {
ok: function () {
JSUtils.submitGridsData("result", "HGWD003A", "authUser",
true, function (res) {
message(res.msg);
if (res.status !== -1) {
parent.JSColorbox.setValueCallback(res);
}
}
);
}
});
}
<!DOCTYPE html>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="EF" tagdir="/WEB-INF/tags/EF" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<EF:EFPage title="文档授权用户">
<EF:EFRegion id="inqu" title="查询条件">
<EF:EFInput ename="fileId" cname="文件ID" blockId="inqu_status" row="0" type="hidden"/>
<div class="row">
<EF:EFInput ename="depName" cname="部门名称" blockId="inqu_status" row="0" colWidth="4"/>
<EF:EFInput ename="loginName" cname="用户账号" blockId="inqu_status" row="0" colWidth="4"/>
<EF:EFInput ename="userName" cname="用户姓名" blockId="inqu_status" row="0" colWidth="4"/>
</div>
</EF:EFRegion>
<EF:EFRegion id="result" title="记录集">
<EF:EFGrid blockId="result" autoDraw="override" checkMode="row">
<EF:EFColumn ename="userId" cname="用户ID" hidden="true" primaryKey="true"/>
<EF:EFColumn ename="depName" cname="部门名称" enable="false" width="120" align="center"/>
<EF:EFColumn ename="loginName" cname="用户账号" enable="false" width="120" align="center"/>
<EF:EFColumn ename="userName" cname="用户姓名" enable="false" width="120" align="center"/>
</EF:EFGrid>
</EF:EFRegion>
</EF:EFPage>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment