From f84b755516d34c13ea6cd622f655b8c5d40aca8c Mon Sep 17 00:00:00 2001 From: "youhong.ai" Date: Sat, 15 Jul 2023 10:55:05 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E5=9B=BD=E5=B0=8F=E5=90=9B=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E8=AE=A4=E8=AF=81=E5=8A=A0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sso/impl/SsoGuoXiaoJunPocImpl.java | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/customization/youhong/guoxiaojun/sso/impl/SsoGuoXiaoJunPocImpl.java b/src/main/java/com/customization/youhong/guoxiaojun/sso/impl/SsoGuoXiaoJunPocImpl.java index 6eea439..fbd4647 100644 --- a/src/main/java/com/customization/youhong/guoxiaojun/sso/impl/SsoGuoXiaoJunPocImpl.java +++ b/src/main/java/com/customization/youhong/guoxiaojun/sso/impl/SsoGuoXiaoJunPocImpl.java @@ -27,7 +27,6 @@ import java.util.Objects; public class SsoGuoXiaoJunPocImpl { public static final String API_SSO_URL = "/api/aiyh/guoxiaojun/sso"; - public static final String LOGIN_URL = "/wui/index.html"; public static final String API_CHECK_OUT_URI = "/api/hrm/login/checkLogout"; private final Logger log = Util.getLogger(); @@ -55,20 +54,24 @@ public class SsoGuoXiaoJunPocImpl { if (requestURI.equals(API_CHECK_OUT_URI)) { // 退出登录 session.removeAttribute("outUserId"); - String logOutUrl = Util.getCusConfigValue("oauth2-proxy-logout-url"); - response.setHeader("logOutUrl", logOutUrl); return; } // sso 认证 if (session.getAttribute("outUserId") == null) { - authorSso(response, session); + authorSso(response); } } catch (IOException e) { log.error("重定地址失败!" + Util.getErrString(e)); } } - // + /** + *

登录oa系统

+ * + * @param request 请求 + * @param response 响应 + * @throws IOException 异常 + */ private void loginOa(HttpServletRequest request, HttpServletResponse response) throws IOException { HttpSession session; String outUserId = request.getHeader("X-Credential-Identifier"); @@ -84,11 +87,13 @@ public class SsoGuoXiaoJunPocImpl { response.sendRedirect(Util.getCusConfigValueNullOrEmpty("SSO_SUCCESS_REDIRECT_URL", "/wui/index.html")); } - private void authorSso(HttpServletResponse response, HttpSession session) throws IOException { - Object outUserId = session.getAttribute("outUserId"); - if (Objects.nonNull(outUserId)) { - return; - } + /** + *

跳转认证

+ * + * @param response 响应 + * @throws IOException 异常 + */ + private void authorSso(HttpServletResponse response) throws IOException { // 地址重定向到国小君aut2认证地址 response.sendRedirect(Util.getCusConfigValue("oauth2-proxy-url") + "?url=" + URLEncoder.encode(Util.getCusConfigValue("OA_URL") + API_SSO_URL, "UTF-8")); From bf480091b95b430f7cba765a022db4c611488311 Mon Sep 17 00:00:00 2001 From: "weilin.zhu" Date: Sat, 15 Jul 2023 11:40:07 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E5=AF=B9=E5=88=9B=E5=BB=BA=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E4=BF=A1=E6=81=AF=E8=A7=86=E5=9B=BE=EF=BC=88workflow?= =?UTF-8?q?=5Ffield=5Ftable=5Fview=EF=BC=89=E8=AF=AD=E5=8F=A5=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- view-mysql.sql | 14 +++++--------- view-oracle.sql | 11 +++-------- view-sql-server.sql | 11 +++-------- 3 files changed, 11 insertions(+), 25 deletions(-) diff --git a/view-mysql.sql b/view-mysql.sql index c55b822..4b35c65 100644 --- a/view-mysql.sql +++ b/view-mysql.sql @@ -84,10 +84,10 @@ INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, VALUES (-989, 'workflowid', '工作流id:workflowid', 'workflow_requestbase', 999, 'main table', '单行文本', '1'); -- 创建试图 create -or replace view workflow_field_table_view as + or replace view workflow_field_table_view as select wb.id, wb.fieldname, - concat(ht.indexdesc, ':', wb.fieldname) indexdesc, + concat(ht.indexdesc, ':', wb.fieldname,'(',wb.id,')') indexdesc, ( case when wb.detailtable is null then (select distinct tablename from workflow_bill where id = wb.billid) @@ -103,16 +103,12 @@ select wb.id, when wb.detailtable is null then 'main table' else wb.detailtable end ) showtablename, - (case - when wb.fieldhtmltype = '1' then '单行文本框' - when wb.FIELDHTMLTYPE = '2' then '多行文本框' - when wb.FIELDHTMLTYPE = '3' then '流览框' - when wb.FIELDHTMLTYPE = '4' then 'check框' - when wb.FIELDHTMLTYPE = '5' then '选择框' - else '附件上传' end) fieldhtmltype, + + wf.TYPENAME as fieldhtmltype, wb.FIELDHTMLTYPE fieldtype from workflow_billfield wb left join htmllabelindex ht on wb.fieldlabel = ht.id + left join workflow_fieldtype wf on wf.ID = wb.fieldhtmltype union all select * from cus_workflow_base_field_assist; diff --git a/view-oracle.sql b/view-oracle.sql index 7fc61df..5098625 100644 --- a/view-oracle.sql +++ b/view-oracle.sql @@ -91,7 +91,7 @@ VALUES (-989, 'workflowid', '工作流id:workflowid', 'workflow_requestbase', create or replace view workflow_field_table_view as select wb.id, wb.fieldname, - (ht.indexdesc || ':' || wb.fieldname) indexdesc, + (ht.indexdesc || ':' || wb.fieldname || '(' || CAST(wb.id as VARCHAR2(10)) || ')') indexdesc, ( case when wb.detailtable is null then (select distinct tablename from workflow_bill where id = wb.billid) @@ -107,16 +107,11 @@ select wb.id, when wb.detailtable is null then 'main table' else wb.detailtable end ) showtablename, - (case - when wb.fieldhtmltype = '1' then '单行文本框' - when wb.FIELDHTMLTYPE = '2' then '多行文本框' - when wb.FIELDHTMLTYPE = '3' then '流览框' - when wb.FIELDHTMLTYPE = '4' then 'check框' - when wb.FIELDHTMLTYPE = '5' then '选择框' - else '附件上传' end) fieldhtmltype, + wf.TYPENAME as fieldhtmltype, wb.FIELDHTMLTYPE fieldtype from workflow_billfield wb left join htmllabelindex ht on wb.fieldlabel = ht.id + left join workflow_fieldtype wf on wf.ID = wb.fieldhtmltype union all select * from cus_workflow_base_field_assist / diff --git a/view-sql-server.sql b/view-sql-server.sql index c589dfa..f441ca0 100644 --- a/view-sql-server.sql +++ b/view-sql-server.sql @@ -95,7 +95,7 @@ drop view workflow_field_table_view create view workflow_field_table_view as select wb.id, wb.fieldname, - (ht.indexdesc + ':' + wb.fieldname) indexdesc, + (ht.indexdesc + ':' + wb.fieldname + '(' + CONVERT(varchar(10),wb.id) + ')') indexdesc, ( case when wb.detailtable is null then (select distinct tablename from workflow_bill where id = wb.billid) @@ -111,16 +111,11 @@ select wb.id, when wb.detailtable is null then 'main table' else wb.detailtable end ) showtablename, - (case - when wb.fieldhtmltype = '1' then '单行文本框' - when wb.FIELDHTMLTYPE = '2' then '多行文本框' - when wb.FIELDHTMLTYPE = '3' then '流览框' - when wb.FIELDHTMLTYPE = '4' then 'check框' - when wb.FIELDHTMLTYPE = '5' then '选择框' - else '附件上传' end) fieldhtmltype, + wf.TYPENAME as fieldhtmltype, wb.FIELDHTMLTYPE fieldtype from workflow_billfield wb left join htmllabelindex ht on wb.fieldlabel = ht.id + left join workflow_fieldtype wf on wf.ID = wb.fieldhtmltype union all select * from cus_workflow_base_field_assist go From 1e1ab2c087361e1a07ca2d94d1fed81024b5001b Mon Sep 17 00:00:00 2001 From: "chaoyang.he" Date: Sat, 15 Jul 2023 17:44:11 +0800 Subject: [PATCH 3/8] xiugai --- .../controller/ContractRePushController.java | 54 --- .../porsche_repush/mapper/QueryMapper.java | 24 -- .../service/ContractRePushService.java | 91 ---- ...AccessInterfaceReturnParamsController.java | 33 ++ .../AccessInterfaceReturnParamsMapper.java | 7 + .../AccessInterfaceReturnParamsService.java | 9 + ...ccessInterfaceReturnParamsServiceImpl.java | 405 ++++++++++++++++++ .../java/builderpackage/AutoPackageJar.java | 8 +- .../chaoyang/he/hangtiankeji/DemoTest.java | 12 + 9 files changed, 473 insertions(+), 170 deletions(-) delete mode 100644 src/main/java/com/api/bokang/xiao/porsche_repush/controller/ContractRePushController.java delete mode 100644 src/main/java/com/api/bokang/xiao/porsche_repush/mapper/QueryMapper.java delete mode 100644 src/main/java/com/api/bokang/xiao/porsche_repush/service/ContractRePushService.java create mode 100644 src/main/java/com/api/chaoyang/he/hcy_anyong/accessinterface/controller/AccessInterfaceReturnParamsController.java create mode 100644 src/main/java/com/api/chaoyang/he/hcy_anyong/accessinterface/mapper/AccessInterfaceReturnParamsMapper.java create mode 100644 src/main/java/com/api/chaoyang/he/hcy_anyong/accessinterface/service/AccessInterfaceReturnParamsService.java create mode 100644 src/main/java/com/api/chaoyang/he/hcy_anyong/accessinterface/service/impl/AccessInterfaceReturnParamsServiceImpl.java create mode 100644 src/test/java/chaoyang/he/hangtiankeji/DemoTest.java diff --git a/src/main/java/com/api/bokang/xiao/porsche_repush/controller/ContractRePushController.java b/src/main/java/com/api/bokang/xiao/porsche_repush/controller/ContractRePushController.java deleted file mode 100644 index 137ef38..0000000 --- a/src/main/java/com/api/bokang/xiao/porsche_repush/controller/ContractRePushController.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.api.bokang.xiao.porsche_repush.controller; - -import aiyh.utils.ApiResult; -import aiyh.utils.Util; -import com.api.bokang.xiao.porsche_repush.service.ContractRePushService; -import io.swagger.v3.oas.annotations.parameters.RequestBody; -import org.apache.log4j.Logger; -import weaver.hrm.HrmUserVarify; -import weaver.hrm.User; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.ws.rs.*; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import java.util.List; -import java.util.Map; - -/** - * @ClassName ContractRePushController - * @Author 肖博亢 - * @Date 2023/5/10 10:47 - * @Description

- **/ -@Path("/xbk/porsche_repush") -public class ContractRePushController { - - private final Logger log = Util.getLogger(); - - private final ContractRePushService contractRePushService = new ContractRePushService(); - - /** - *

获取流程的总数

- * @param request 请求体 - * @param response 响应体 - * @param param 请求参数 - * @return 请求结果 - */ - @Path("/contractRePush") - @POST - @Produces(MediaType.APPLICATION_JSON) - public String contractRePush(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map param) { - try{ - log.info("into contractRePush success params ==> "+param); - User loginUser = HrmUserVarify.getUser(request, response); - List> result = contractRePushService.contractRePushService(param,loginUser); - return ApiResult.success(result); - }catch (Exception e){ - log.error("contractRePush error ==> "+ Util.getErrString(e)); - return ApiResult.error(e.getMessage()); - } - } - -} diff --git a/src/main/java/com/api/bokang/xiao/porsche_repush/mapper/QueryMapper.java b/src/main/java/com/api/bokang/xiao/porsche_repush/mapper/QueryMapper.java deleted file mode 100644 index d161879..0000000 --- a/src/main/java/com/api/bokang/xiao/porsche_repush/mapper/QueryMapper.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.api.bokang.xiao.porsche_repush.mapper; - -import aiyh.utils.annotation.recordset.ParamMapper; -import aiyh.utils.annotation.recordset.Select; -import aiyh.utils.annotation.recordset.SqlMapper; - -import java.util.List; -import java.util.Map; - -/** - * @ClassName QueryMapper - * @Author 肖博亢 - * @Date 2023/5/10 11:00 - * @Description

- **/ -@SqlMapper -public interface QueryMapper { - - @Select("select * from uf_zcht where id in $t{ids}") - List> queryContractByIds(@ParamMapper("ids")String ids); - - @Select("select * from actionsettingdetail where ACTIONID = (select id from actionsetting where actionname = #{actionName})") - List> queryActionParam(@ParamMapper("actionName")String actionName); -} diff --git a/src/main/java/com/api/bokang/xiao/porsche_repush/service/ContractRePushService.java b/src/main/java/com/api/bokang/xiao/porsche_repush/service/ContractRePushService.java deleted file mode 100644 index fbecbda..0000000 --- a/src/main/java/com/api/bokang/xiao/porsche_repush/service/ContractRePushService.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.api.bokang.xiao.porsche_repush.service; - -import aiyh.utils.Util; -import aiyh.utils.excention.CustomerException; -import com.alibaba.fastjson.JSON; -import com.api.bokang.xiao.porsche_repush.mapper.QueryMapper; -import org.apache.log4j.Logger; -import weaver.aiyh_pcn.common_fadada.action.CommonContractRevocationAction; -import weaver.aiyh_pcn.common_fadada.action.CommonCreateContractAction; -import weaver.aiyh_pcn.common_fadada.action.CommonOneselfSignAction; -import weaver.hrm.User; -import weaver.systeminfo.SystemEnv; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -/** - * @ClassName ContractRePushService - * @Author 肖博亢 - * @Date 2023/5/10 10:48 - * @Description

- **/ -public class ContractRePushService { - - private final Logger log = Util.getLogger(); - - private final QueryMapper queryMapper = Util.getMapper(QueryMapper.class); - - public List> contractRePushService(Map param, User loginUser) { - String ids = Util.null2String(param.get("ids")); - int labelId = Util.getIntValue(String.valueOf(param.get("labelId"))); - String contractCreateAction = Util.null2String(param.get("contractCreateAction")); - String signOtherAction = Util.null2String(param.get("signOtherAction")); - String contractRevocationAction = Util.null2String(param.get("ContractRevocationAction")); - String workflowField = Util.null2String(param.get("workflowField")); - List> createList = queryMapper.queryActionParam(contractCreateAction); - List> signOtherList = queryMapper.queryActionParam(signOtherAction); - List> contractRevocationList = queryMapper.queryActionParam(contractRevocationAction); - Map contractActionParam = createList.stream().collect(Collectors - .toMap( - item -> Util.null2String(item.get("attrname")), - item -> Util.null2String(item.get("attrvalue")) - ) - ); - Map signOtherActionParam = signOtherList.stream().collect(Collectors - .toMap( - item -> Util.null2String(item.get("attrname")), - item -> Util.null2String(item.get("attrvalue")) - ) - ); - Map contractRevocationParam = contractRevocationList.stream().collect(Collectors - .toMap( - item -> Util.null2String(item.get("attrname")), - item -> Util.null2String(item.get("attrvalue")) - ) - ); - log.info(String.format("contractCreateAction ==> param:%s signOtherAction ==> param:%s contractRevocationAction ==> param:%s", - JSON.toJSONString(contractRevocationParam), - JSON.toJSONString(contractActionParam), - JSON.toJSONString(signOtherActionParam) - )); - List> contractList = queryMapper.queryContractByIds(ids); - List> result = new ArrayList<>(); - for (Map contract : contractList) { - String signStatus = Util.null2String(contract.get("zcgsqszt")); - if("1".equals(signStatus)){ - throw new CustomerException(SystemEnv.getHtmlLabelName(labelId, loginUser.getLanguage())); - } - } - for (Map contract : contractList) { - Map info = new HashMap<>(); - int requestId = Util.getIntValue(String.valueOf(contract.get(workflowField))); - try{ - //合同撤回 - Util.actionTest(CommonContractRevocationAction.class,requestId,contractRevocationParam); - //合同创建 - Util.actionTest(CommonCreateContractAction.class,requestId,contractActionParam); - //对方签署 - Util.actionTest(CommonOneselfSignAction.class,requestId,signOtherActionParam); - }catch (CustomerException exception){ - info.put(String.valueOf(requestId),false); - } - info.put(String.valueOf(requestId),true); - result.add(info); - } - return result; - } -} diff --git a/src/main/java/com/api/chaoyang/he/hcy_anyong/accessinterface/controller/AccessInterfaceReturnParamsController.java b/src/main/java/com/api/chaoyang/he/hcy_anyong/accessinterface/controller/AccessInterfaceReturnParamsController.java new file mode 100644 index 0000000..127e34e --- /dev/null +++ b/src/main/java/com/api/chaoyang/he/hcy_anyong/accessinterface/controller/AccessInterfaceReturnParamsController.java @@ -0,0 +1,33 @@ +package com.api.chaoyang.he.hcy_anyong.accessinterface.controller; + +import aiyh.utils.ApiResult; +import com.api.chaoyang.he.hcy_anyong.accessinterface.service.AccessInterfaceReturnParamsService; +import com.api.chaoyang.he.hcy_anyong.accessinterface.service.impl.AccessInterfaceReturnParamsServiceImpl; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.List; +import java.util.Map; + +@Path("/access/hcy/") +public class AccessInterfaceReturnParamsController { + + private final AccessInterfaceReturnParamsService accessInterfaceReturnParamsService = new AccessInterfaceReturnParamsServiceImpl(); + + @POST + @Path("/interface/return/params") + @Produces(MediaType.APPLICATION_JSON) + public String returnParams(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + return accessInterfaceReturnParamsService.paramsString(request, response); + } catch (Exception e) { + e.printStackTrace(); + return ApiResult.error(500,"fail"); + } + } +} diff --git a/src/main/java/com/api/chaoyang/he/hcy_anyong/accessinterface/mapper/AccessInterfaceReturnParamsMapper.java b/src/main/java/com/api/chaoyang/he/hcy_anyong/accessinterface/mapper/AccessInterfaceReturnParamsMapper.java new file mode 100644 index 0000000..e4ff447 --- /dev/null +++ b/src/main/java/com/api/chaoyang/he/hcy_anyong/accessinterface/mapper/AccessInterfaceReturnParamsMapper.java @@ -0,0 +1,7 @@ +package com.api.chaoyang.he.hcy_anyong.accessinterface.mapper; + +import aiyh.utils.annotation.recordset.SqlMapper; + +@SqlMapper +public interface AccessInterfaceReturnParamsMapper { +} diff --git a/src/main/java/com/api/chaoyang/he/hcy_anyong/accessinterface/service/AccessInterfaceReturnParamsService.java b/src/main/java/com/api/chaoyang/he/hcy_anyong/accessinterface/service/AccessInterfaceReturnParamsService.java new file mode 100644 index 0000000..04274a4 --- /dev/null +++ b/src/main/java/com/api/chaoyang/he/hcy_anyong/accessinterface/service/AccessInterfaceReturnParamsService.java @@ -0,0 +1,9 @@ +package com.api.chaoyang.he.hcy_anyong.accessinterface.service; + + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public interface AccessInterfaceReturnParamsService { + String paramsString(HttpServletRequest request, HttpServletResponse response); +} diff --git a/src/main/java/com/api/chaoyang/he/hcy_anyong/accessinterface/service/impl/AccessInterfaceReturnParamsServiceImpl.java b/src/main/java/com/api/chaoyang/he/hcy_anyong/accessinterface/service/impl/AccessInterfaceReturnParamsServiceImpl.java new file mode 100644 index 0000000..d1a2591 --- /dev/null +++ b/src/main/java/com/api/chaoyang/he/hcy_anyong/accessinterface/service/impl/AccessInterfaceReturnParamsServiceImpl.java @@ -0,0 +1,405 @@ +package com.api.chaoyang.he.hcy_anyong.accessinterface.service.impl; + +import aiyh.utils.ApiResult; +import aiyh.utils.Util; +import com.alibaba.fastjson.JSONObject; +import com.api.chaoyang.he.hcy_anyong.accessinterface.service.AccessInterfaceReturnParamsService; +import org.apache.commons.codec.binary.Base64; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpUriRequest; +import org.apache.log4j.Logger; +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; +import javax.net.ssl.SSLContext; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URISyntaxException; +import java.nio.charset.StandardCharsets; +import java.security.InvalidKeyException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.text.SimpleDateFormat; +import java.util.*; +import org.apache.http.Header; +import org.apache.http.HttpResponse; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.entity.EntityBuilder; +import org.apache.http.client.methods.RequestBuilder; +import org.apache.http.client.utils.URIBuilder; +import org.apache.http.config.ConnectionConfig; +import org.apache.http.config.Registry; +import org.apache.http.config.RegistryBuilder; +import org.apache.http.config.SocketConfig; +import org.apache.http.conn.socket.ConnectionSocketFactory; +import org.apache.http.conn.socket.PlainConnectionSocketFactory; +import org.apache.http.conn.ssl.DefaultHostnameVerifier; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.entity.ContentType; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; +import org.apache.http.util.EntityUtils; +import java.io.Closeable; + + +public class AccessInterfaceReturnParamsServiceImpl implements AccessInterfaceReturnParamsService { + + /** + * 访问域名或ip + */ + private static final String HOST = "https://7efeed4ac5b94e42b40fd1ab3f5a6715-cn-shanghai-vpc.alicloudapi.com"; + /** + * 应用appKey + */ + private static final String APP_KEY = "204191153"; + /** + * 应用appSecret + */ + private static final String APP_SECRET = "dJfXKZFZoZb0tSjvl8fImM0m5nvMckCl"; + /** + * apiId + */ + private static final String API_ID = "11863"; + /** + * 日志处理 + */ + private final Logger logger = Util.getLogger(); + + /** + * 请求头 + */ + private static final Map headers = new HashMap<>(); + + + /** + * 根据前端获取的数据,查询接口返回数据 + * @param request req + * @param response res + * @return 接口返回值 + */ + public String paramsString(HttpServletRequest request, HttpServletResponse response) { + try { + String keyId = request.getParameter("keyId"); + HashMap bodyMap = new HashMap<>(); + bodyMap.put("keyId",keyId); + String bodyJsonStr = JSONObject.toJSONString(bodyMap); + createHears(bodyJsonStr); + //获取返回结果 + String result = sendSyncRequest(headers, bodyJsonStr.getBytes(StandardCharsets.UTF_8)); + return ApiResult.success(result,200, "success"); + } catch (Exception e) { + e.printStackTrace(); + return ApiResult.error(500, "fail"); + } + } + + + /** + * 封装header + * @throws UnsupportedEncodingException 抛出异常 + * @throws InvalidKeyException 抛出异常 + * @throws NoSuchAlgorithmException 抛出异常 + */ + private void createHears(String bodyJsonStr) throws UnsupportedEncodingException, InvalidKeyException, NoSuchAlgorithmException { + //date,设置请求头中的时间戳 + Date current = new Date(); + headers.put("date", getHttpDateHeaderValue(current)); + logger.info("生成header[date]:"+getHttpDateHeaderValue(current)); + + + //x-ca-timestamp,设置请求头中的时间戳,以timeIntervalSince1970的形式 + headers.put("x-ca-timestamp", String.valueOf(current.getTime())); + logger.info("生成header[x-ca-timestamp]:"+ current.getTime()); + + + //host,设置请求头中的主机地址 + headers.put("host", HOST); + logger.info("生成header[host]:"+ HOST); + + //x-ca-key,设置请求头中的Api绑定的的AppKey + headers.put("x-ca-key", APP_KEY); + logger.info("生成header[x-ca-key]:"+ APP_KEY); + + + //content-type,设置请求数据类型 + headers.put("content-type", "application/json; charset=utf-8"); + logger.info("生成header[content-type]:application/json; charset=utf-8"); + + //accept,设置应答数据类型 + headers.put("accept", "application/json; charset=utf-8"); + logger.info("生成header[accept]:application/json; charset=utf-8"); + + //x-ca-signature-method,签名加密方式 + headers.put("x-ca-signature-method", "HmacSHA256"); + logger.info("生成header[x-ca-signature-method]:HmacSHA256"); + + String md5 = base64AndMD5(bodyJsonStr.getBytes(StandardCharsets.UTF_8)); + headers.put("content-md5", md5); + logger.info("生成header[content-md5]:"+md5); + + //x-ca-signature,签名用作服务器校验 + String stringToSign = buildStringToSign(headers); + String signature = sign(stringToSign); + headers.put("x-ca-signature",signature); + logger.info("生成header[x-ca-signature]:"+signature); + + //x-ca-stage,生产环境标识 + headers.put("x-ca-stage","RELEASE"); + logger.info("生成header[x-ca-stage]:RELEASE"); + + //x-ca-signature-headers,同时所有加入签名的头的列表,需要用逗号分隔形成一个字符串,加入一个新HTTP头@"X-Ca-Signature-Headers" + logger.info("生成header[x-ca-signature-headers]:"+headers.get("x-ca-signature-headers")); + } + + /** + * 获取日期 + * @param date 日期 + * @return 日期字符串 + */ + private static String getHttpDateHeaderValue(Date date) { + SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US); + dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); + return dateFormat.format(date); + } + + + public static String base64AndMD5(byte[] bytes) { + if (bytes == null) { + throw new IllegalArgumentException("bytes can not be null"); + } + try { + final MessageDigest md = MessageDigest.getInstance("MD5"); + md.reset(); + md.update(bytes); + byte[] md5Result = md.digest(); + String base64Result = Base64.encodeBase64String(md5Result); + /* + * 正常情况下,base64的结果为24位,因与服务器有约定,在超过24位的情况下,截取前24位 + */ + return base64Result.length() > 24 ? base64Result.substring(0, 23) : base64Result; + } catch (final NoSuchAlgorithmException e) { + throw new IllegalArgumentException("unknown algorithm MD5"); + } + } + + + //换行符 + private static final String CLOUDAPI_LF = "\n"; + private static final String HTTP_METHOD = "POST"; + /** + * path为oneservice创建的API指定的请求方式(get或者list)+API_ID生成 + */ + private static final String PATH = "/get/"+API_ID; + private static final String ENV = "PROD"; + private static final String URL = PATH+"?appKey="+APP_KEY+"&env="+ENV; + + + /** + * 构建需要参与签名的字符串 + */ + public static String buildStringToSign(Map headers) { + + StringBuilder sb = new StringBuilder(); + sb.append(HTTP_METHOD).append(CLOUDAPI_LF); + + //如果有@"Accept"头,这个头需要参与签名 + if (headers.get("accept") != null) { + sb.append(headers.get("accept")); + } + sb.append(CLOUDAPI_LF); + + //如果有@"Content-MD5"头,这个头需要参与签名 + if (headers.get("content-md5") != null) { + sb.append(headers.get("content-md5")); + } + sb.append(CLOUDAPI_LF); + + //如果有@"Content-Type"头,这个头需要参与签名 + if (headers.get("content-type") != null) { + sb.append(headers.get("content-type")); + } + sb.append(CLOUDAPI_LF); + + //签名优先读取HTTP_CA_HEADER_DATE,因为通过浏览器过来的请求不允许自定义Date(会被浏览器认为是篡改攻击) + if (headers.get("date") != null) { + sb.append(headers.get("date")); + } + sb.append(CLOUDAPI_LF); + + //将headers合成一个字符串 + sb.append(buildHeaders(headers)); + + //url + sb.append(URL); + + return sb.toString(); + } + + /** + * 将headers合成一个字符串 + * 需要注意的是,HTTP头需要按照字母排序加入签名字符串 + * 同时所有加入签名的头的列表,需要用逗号分隔形成一个字符串,加入一个新HTTP头@"X-Ca-Signature-Headers" + */ + private static String buildHeaders(Map headers) { + //使用TreeMap,默认按照字母排序 + Map headersToSign = new TreeMap<>(); + + + StringBuilder signHeadersStringBuilder = new StringBuilder(); + + int flag = 0; + for (Map.Entry header : headers.entrySet()) { + if (header.getKey().startsWith("x-ca-")) { + if (flag != 0) { + signHeadersStringBuilder.append(","); + } + flag++; + signHeadersStringBuilder.append(header.getKey()); + headersToSign.put(header.getKey(), header.getValue()); + } + } + + //同时所有加入签名的头的列表,需要用逗号分隔形成一个字符串,加入一个新HTTP头@"X-Ca-Signature-Headers" + headers.put("x-ca-signature-headers",signHeadersStringBuilder.toString()); + + StringBuilder sb = new StringBuilder(); + for (Map.Entry e : headersToSign.entrySet()) { + sb.append(e.getKey()).append(':').append(e.getValue()).append(CLOUDAPI_LF); + } + return sb.toString(); + } + + /** + * 生成签名串 + * @param stringToSign 签名串 + * @return 生成的签名串 + */ + public static String sign(String stringToSign) throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException { + Mac hmacSha256 = Mac.getInstance("HmacSHA256"); + byte[] keyBytes = APP_SECRET.getBytes(StandardCharsets.UTF_8); + hmacSha256.init(new SecretKeySpec(keyBytes, 0, keyBytes.length, "HmacSHA256")); + return new String(Base64.encodeBase64(hmacSha256.doFinal(stringToSign.getBytes(StandardCharsets.UTF_8)))); + } + + + public String sendSyncRequest(Map headers,byte[] body) { + HttpUriRequest httpRequest = buildRequest(headers,body); + CloseableHttpResponse httpResponse = null; + try { + httpResponse = httpClient.execute(httpRequest); + return parseToApiResponse(httpResponse); + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + closeQuietly(httpResponse); + } + } + + public static void closeQuietly(Closeable closeable) { + try { + if (closeable != null) { + closeable.close(); + } + } catch (IOException ignored) { + } + + } + + private static HttpUriRequest buildRequest(Map headers,byte[] body) { + RequestBuilder builder = RequestBuilder.create(HTTP_METHOD); + + /* + * 拼接URL + * HTTP + HOST + PATH(With pathparameter) + Query Parameter + */ + try { + URIBuilder uriBuilder = new URIBuilder(); + uriBuilder.setScheme("HTTP"); + uriBuilder.setHost(HOST); + uriBuilder.setPath(PATH); + //增加url上参数,/get/1254131194177714180?appKey=203787616&env=PROD + uriBuilder.addParameter("appKey",APP_KEY); + uriBuilder.addParameter("env",ENV); + builder.setUri(uriBuilder.build()); + } catch (URISyntaxException e) { + throw new RuntimeException("build http request uri failed", e); + } + + EntityBuilder bodyBuilder = EntityBuilder.create(); + bodyBuilder.setContentType(ContentType.parse("application/octet-stream; charset=utf-8")); + bodyBuilder.setBinary(body); + builder.setEntity(bodyBuilder.build()); + + for (Map.Entry entry : headers.entrySet()) { + builder.addHeader(entry.getKey(), entry.getValue()); + } + + return builder.build(); + } + + private static CloseableHttpClient httpClient; + + + public static void init() { + SocketConfig socketConfig = SocketConfig.custom().setTcpNoDelay(true).setSoKeepAlive(true).setSoReuseAddress(true) + .setSoTimeout(10000).build(); + Registry registry = getRegistry(); + PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(registry); + connectionManager.setDefaultConnectionConfig(ConnectionConfig.custom().build()); + connectionManager.setDefaultSocketConfig(socketConfig); + connectionManager.setMaxTotal(64); + connectionManager.setDefaultMaxPerRoute(5); + RequestConfig defaultConfig = RequestConfig.custom() + .setConnectTimeout(10000) + .setSocketTimeout(10000) + .setConnectionRequestTimeout(10000) + .build(); + httpClient = HttpClients.custom().setConnectionManager(connectionManager).setDefaultRequestConfig(defaultConfig).build(); + } + + private static Registry getRegistry() { + RegistryBuilder registryBuilder = RegistryBuilder.create(); + try { + registryBuilder.register("http", PlainConnectionSocketFactory.INSTANCE).build(); + registryBuilder.register("https",new SSLConnectionSocketFactory(SSLContext.getDefault(), new DefaultHostnameVerifier())); + + } catch (Exception e) { + throw new RuntimeException("HttpClientUtil init failure !", e); + } + return registryBuilder.build(); + } + + /** + * 处理接口返回参数 + * @param httpResponse 相应信息 + * @return 返回接口中的内容封装成字符串 + * @throws IOException 异常 + */ + private String parseToApiResponse(HttpResponse httpResponse) throws IOException { + logger.info("code:"+httpResponse.getStatusLine().getStatusCode()); + // message + logger.info("message:"+httpResponse.getStatusLine().getReasonPhrase()); + + if(httpResponse.getEntity() != null){ + // content type + Header contentType = httpResponse.getEntity().getContentType(); + if(contentType != null){ + logger.info("ContentType:"+contentType.getValue()); + } + else + { + logger.info("ContentType:application/text; charset=utf-8"); + } + logger.info(httpResponse.getEntity()); + // body + return new String(EntityUtils.toByteArray(httpResponse.getEntity())); + } + + return null; + + } + + +} diff --git a/src/test/java/builderpackage/AutoPackageJar.java b/src/test/java/builderpackage/AutoPackageJar.java index 99269b8..6ffe683 100644 --- a/src/test/java/builderpackage/AutoPackageJar.java +++ b/src/test/java/builderpackage/AutoPackageJar.java @@ -6,6 +6,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.util.jar.JarEntry; import java.util.jar.JarOutputStream; +import java.util.regex.Pattern; /** *

测试自动打包

@@ -25,7 +26,12 @@ public class AutoPackageJar { public static void createJar(String targetPath) { String path = AutoPackageJar.class.getResource("").getPath(); - String finalPath = path.split(File.separator + targetPath)[0] + File.separator + targetPath + FileTreeBuilder.classPath; + if(path.startsWith("/")){ + path = path.substring(1); + path = path.replace("/",File.separator); + } + String regex = File.separator + targetPath; + String finalPath = path.split(Pattern.quote(regex))[0] + File.separator + targetPath + FileTreeBuilder.classPath; createJar(finalPath + "aiyh", finalPath + "aiyh_utils.jar"); createJar(finalPath + "ebu7common", finalPath + "ebu7common.jar"); } diff --git a/src/test/java/chaoyang/he/hangtiankeji/DemoTest.java b/src/test/java/chaoyang/he/hangtiankeji/DemoTest.java new file mode 100644 index 0000000..2b17403 --- /dev/null +++ b/src/test/java/chaoyang/he/hangtiankeji/DemoTest.java @@ -0,0 +1,12 @@ +package chaoyang.he.hangtiankeji; + +import basetest.BaseTest; +import org.junit.Test; + +public class DemoTest extends BaseTest { + + @Test + public void test01(){ + System.out.println("测试成功"); + } +} From fca7ee645ad16c90af0e0179ad2ce0c1cdc84fd5 Mon Sep 17 00:00:00 2001 From: "chaoyang.he" Date: Sat, 15 Jul 2023 17:53:22 +0800 Subject: [PATCH 4/8] xiugai --- src/test/java/BuilderPackageEcology.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/test/java/BuilderPackageEcology.java b/src/test/java/BuilderPackageEcology.java index a8ea1df..6c20c36 100644 --- a/src/test/java/BuilderPackageEcology.java +++ b/src/test/java/BuilderPackageEcology.java @@ -26,6 +26,7 @@ import java.io.IOException; import java.text.SimpleDateFormat; import java.util.List; import java.util.*; +import java.util.regex.Pattern; public class BuilderPackageEcology extends Application { @@ -115,7 +116,11 @@ public class BuilderPackageEcology extends Application { try { FileCompressor.compressFiles(filePaths, outputFile.getAbsolutePath(), path -> { String rootPath = Util.class.getResource("/").getPath(); - rootPath = rootPath.split(File.separator + FileTreeBuilder.targetPath)[0] + File.separator + FileTreeBuilder.targetPath + FileTreeBuilder.classPath; + if(rootPath.startsWith("/")){ + rootPath = rootPath.substring(1); + rootPath = rootPath.replace("/",File.separator); + } + rootPath = rootPath.split(Pattern.quote(File.separator + FileTreeBuilder.targetPath))[0] + File.separator + FileTreeBuilder.targetPath + FileTreeBuilder.classPath; String replace = "/ecology/" + (isEcology ? "WEB-INF/classes/" : "classbean/"); if (path.endsWith(".jar")) { replace = "/ecology/WEB-INF/lib/"; From 12bf9f86c4efbcbb73e34988d7a6941298e8846d Mon Sep 17 00:00:00 2001 From: "youhong.ai" Date: Mon, 17 Jul 2023 13:26:32 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=89=93=E5=8C=85?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sendtodo/impl/SendTodoTaskImpl.java | 69 +++++++++++++++++++ src/test/java/BuilderPackageEcology.java | 1 - 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/customization/youhong/guoxiaojun/sendtodo/impl/SendTodoTaskImpl.java diff --git a/src/main/java/com/customization/youhong/guoxiaojun/sendtodo/impl/SendTodoTaskImpl.java b/src/main/java/com/customization/youhong/guoxiaojun/sendtodo/impl/SendTodoTaskImpl.java new file mode 100644 index 0000000..fcf6abf --- /dev/null +++ b/src/main/java/com/customization/youhong/guoxiaojun/sendtodo/impl/SendTodoTaskImpl.java @@ -0,0 +1,69 @@ +package com.customization.youhong.guoxiaojun.sendtodo.impl; + +import lombok.Setter; +import weaver.ofs.interfaces.SendRequestStatusDataInterfaces; +import weaver.workflow.request.todo.DataObj; + +import java.util.ArrayList; + +/** + *

国小君统一待办推送

+ * + *

create: 2023/7/15 13:32

+ * + * @author youHong.ai + */ +@Setter +public class SendTodoTaskImpl implements SendRequestStatusDataInterfaces { + + /** + * 后台设置id + */ + public String id; + /** + * 设置的系统编号 + */ + public String syscode; + /** + * 服务器URL + */ + public String serverurl; + /** + * 流程白名单 + */ + public ArrayList workflowwhitelist; + /** + * 人员白名单 + */ + public ArrayList userwhitelist; + + @Override + public String getId() { + return id; + } + + @Override + public String getSyscode() { + return syscode; + } + + @Override + public String getServerurl() { + return serverurl; + } + + @Override + public ArrayList getWorkflowwhitelist() { + return workflowwhitelist; + } + + @Override + public ArrayList getUserwhitelist() { + return userwhitelist; + } + + @Override + public void SendRequestStatusData(ArrayList datas) { + + } +} diff --git a/src/test/java/BuilderPackageEcology.java b/src/test/java/BuilderPackageEcology.java index a8ea1df..edb8113 100644 --- a/src/test/java/BuilderPackageEcology.java +++ b/src/test/java/BuilderPackageEcology.java @@ -253,7 +253,6 @@ public class BuilderPackageEcology extends Application { Node rootIcon = new ImageView( new javafx.scene.image.Image(Objects.requireNonNull(getClass().getResourceAsStream(iconName))) );// 定义一个图片类型节点对象 - checkBox.setGraphic(rootIcon); } else if (item.getFileName().endsWith(".jar")) { Node fileIcon = new ImageView( From 82670bae0e526760b6ed994805fa5cfde2132ddf Mon Sep 17 00:00:00 2001 From: "youhong.ai" Date: Mon, 17 Jul 2023 13:28:14 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=89=93=E5=8C=85?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/BuilderPackageEcology.java | 4 ++-- src/test/java/builderpackage/AutoPackageJar.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/java/BuilderPackageEcology.java b/src/test/java/BuilderPackageEcology.java index 57a5a6f..7fc5c3a 100644 --- a/src/test/java/BuilderPackageEcology.java +++ b/src/test/java/BuilderPackageEcology.java @@ -116,9 +116,9 @@ public class BuilderPackageEcology extends Application { try { FileCompressor.compressFiles(filePaths, outputFile.getAbsolutePath(), path -> { String rootPath = Util.class.getResource("/").getPath(); - if(rootPath.startsWith("/")){ + if (rootPath.startsWith("/") && File.separator.equals("\\")) { rootPath = rootPath.substring(1); - rootPath = rootPath.replace("/",File.separator); + rootPath = rootPath.replace("/", File.separator); } rootPath = rootPath.split(Pattern.quote(File.separator + FileTreeBuilder.targetPath))[0] + File.separator + FileTreeBuilder.targetPath + FileTreeBuilder.classPath; String replace = "/ecology/" + (isEcology ? "WEB-INF/classes/" : "classbean/"); diff --git a/src/test/java/builderpackage/AutoPackageJar.java b/src/test/java/builderpackage/AutoPackageJar.java index 6ffe683..037e970 100644 --- a/src/test/java/builderpackage/AutoPackageJar.java +++ b/src/test/java/builderpackage/AutoPackageJar.java @@ -26,9 +26,9 @@ public class AutoPackageJar { public static void createJar(String targetPath) { String path = AutoPackageJar.class.getResource("").getPath(); - if(path.startsWith("/")){ + if (path.startsWith("/") && File.separator.equals("\\")) { path = path.substring(1); - path = path.replace("/",File.separator); + path = path.replace("/", File.separator); } String regex = File.separator + targetPath; String finalPath = path.split(Pattern.quote(regex))[0] + File.separator + targetPath + FileTreeBuilder.classPath; From e272a1f29526bb24befdeeae1214952a2954b672 Mon Sep 17 00:00:00 2001 From: wangxuanran <3055088966@qq.com> Date: Mon, 17 Jul 2023 16:46:15 +0800 Subject: [PATCH 7/8] =?UTF-8?q?util=E5=8A=A0=E8=BE=93=E5=87=BA=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E4=BF=A1=E6=81=AF=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/aiyh/utils/Util.java | 25 + .../workflow/controller/GetExchangeRate.java | 66 +- .../workflow/mapper/ExchangeRateMapper.java | 4 +- .../controller/CommonDataAsyncController.java | 42 + .../ey/jiahx/UpdateStatusAchargeTwo.java | 212 +++++ .../ey/zhang/ImportExtValidateTemplate.java | 342 -------- .../ey/zhang/ImportNtoOValidateTemplate.java | 307 ------- .../ey/zhangm/didi/util/EYSeconddevUtil.java | 773 ++++++++++++++++++ .../ey/zhangm/util/EYSeconddevUtil.java | 17 + .../xuanran/wang/eny/ModelFieldAsyncTest.java | 17 + 10 files changed, 1145 insertions(+), 660 deletions(-) create mode 100644 src/main/java/com/api/xuanran/wang/xk_hospital/data_async/controller/CommonDataAsyncController.java create mode 100644 src/main/java/weaver/formmode/customjavacode/modeexpand/ey/jiahx/UpdateStatusAchargeTwo.java delete mode 100644 src/main/java/weaver/formmode/interfaces/impl/ey/zhang/ImportExtValidateTemplate.java delete mode 100644 src/main/java/weaver/formmode/interfaces/impl/ey/zhang/ImportNtoOValidateTemplate.java create mode 100644 src/main/java/weaver/seconddev/ey/zhangm/didi/util/EYSeconddevUtil.java diff --git a/src/main/java/aiyh/utils/Util.java b/src/main/java/aiyh/utils/Util.java index b1ff738..16c18ea 100644 --- a/src/main/java/aiyh/utils/Util.java +++ b/src/main/java/aiyh/utils/Util.java @@ -4067,6 +4067,31 @@ public class Util extends weaver.general.Util { } } } + + /** + *

将线程错误信息输出

+ * @author xuanran.wang + * @dateTime 2023/7/17 16:43 + * @param e 线程异常对象 + **/ + public static void logErrorStr(Throwable e){ + logErrorStr(e, null); + } + + /** + *

将线程错误信息输出

+ * @author xuanran.wang + * @dateTime 2023/7/17 16:43 + * @param e 线程异常对象 + * @param logger 日志对象 + **/ + public static void logErrorStr(Throwable e, Logger logger){ + if(null != logger){ + logger.error(getErrString(e)); + }else { + Util.getLogger().error(getErrString(e)); + } + } } diff --git a/src/main/java/com/api/xuanran/wang/eny/workflow/controller/GetExchangeRate.java b/src/main/java/com/api/xuanran/wang/eny/workflow/controller/GetExchangeRate.java index 2bac670..6a7f2c3 100644 --- a/src/main/java/com/api/xuanran/wang/eny/workflow/controller/GetExchangeRate.java +++ b/src/main/java/com/api/xuanran/wang/eny/workflow/controller/GetExchangeRate.java @@ -6,50 +6,98 @@ import aiyh.utils.excention.CustomerException; import com.alibaba.fastjson.JSONObject; import com.api.xuanran.wang.eny.workflow.mapper.ExchangeRateMapper; import io.swagger.v3.oas.annotations.parameters.RequestBody; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; +import weaver.seconddev.ey.zhangm.util.EYSeconddevUtil; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.ws.rs.*; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; import java.util.Map; /** - *

+ *

根据接口币种数据以及流程币种转成对应的汇率

* * @author xuanran.wang * @date 2023/7/14 15:02 */ -@Path("/wxr/eny/workflow/rate") +@Path("/wxr/ey/workflow/rate") public class GetExchangeRate { private final Logger log = Util.getLogger(); private final ExchangeRateMapper mapper = Util.getMapper(ExchangeRateMapper.class); + private EYSeconddevUtil eySeconddevUtil = null; @POST @Path("/exchange") - @Produces(MediaType.APPLICATION_OCTET_STREAM) + @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public String exchangeRate(@Context HttpServletRequest request, @Context HttpServletResponse response, - @RequestBody Map params){ + @RequestBody Map params){ try { + if(eySeconddevUtil == null){ + eySeconddevUtil = new EYSeconddevUtil(); + } // 地区 - String area = Util.null2DefaultStr(params.get("area"),""); + String date = Util.null2DefaultStr(params.get("date"),""); // 本位币 String baseCurrency = Util.null2DefaultStr(params.get("baseCurrency"),""); // 接口币种 String interfaceCurrency = Util.null2DefaultStr(params.get("interfaceCurrency"),""); - if(StringUtils.isBlank(area) || StringUtils.isBlank(baseCurrency) || StringUtils.isBlank(interfaceCurrency)){ + // 是否打印参数 + String printParams = Util.null2DefaultStr(params.get("printParams"),""); + // rateType + String rateType = Util.null2DefaultStr(params.get("rateType"),"5"); + // 字段名 + List> fieldList = (List>) params.get("fieldList"); + boolean print = "1".equals(printParams); + if(print){ + log.info("params : " + JSONObject.toJSONString(params)); + } + if(StringUtils.isBlank(date) || StringUtils.isBlank(baseCurrency) + || StringUtils.isBlank(interfaceCurrency) || CollectionUtils.isEmpty(fieldList)){ log.error("params : " + JSONObject.toJSONString(params)); throw new CustomerException("参数不可为空!"); } - String interfac = mapper.selectCurrencyIdByCurrencyName(interfaceCurrency); - return ""; + // 接口币种名称转OA数据id + String baseCurrencyName = mapper.selectCurrencyNameById(baseCurrency); + if(StringUtils.isBlank(baseCurrencyName)){ + throw new CustomerException("当前币种id : " + interfaceCurrency + " 在oa表中没有找到对应的name!"); + } + Map res = new HashMap<>(); + for (Map map : fieldList) { + if(print){ + log.info("map : " + JSONObject.toJSONString(map)); + } + String money = Util.null2DefaultStr(map.get("money"), ""); + String field = Util.null2DefaultStr(map.get("field"),""); + if(print){ + log.info("field : " + field + " ,money : " + money + " ,baseCurrencyName : " + + baseCurrencyName + " ,interfaceCurrency : " + interfaceCurrency + " ,rateType : " + rateType + " ,date : " + date); + } + if(StringUtils.isBlank(money) || StringUtils.isBlank(field)){ + continue; + } + Map rate = eySeconddevUtil.getExchargeRate(new BigDecimal(money), baseCurrencyName, interfaceCurrency, rateType, date); + if(print){ + log.info("field : " + field + " ,rate : " + JSONObject.toJSONString(rate)); + } + res.put(field, rate); + } + // 调方法获取汇率 + return ApiResult.success(res); }catch (Exception e){ - return ApiResult.error("汇率转换error : " + e.getMessage()); + log.error("exchangeRate error : " + e.getMessage()); + log.error(Util.getErrString(e)); + return ApiResult.error("汇率转换接口error : [ " + e.getMessage() + " ]"); } } diff --git a/src/main/java/com/api/xuanran/wang/eny/workflow/mapper/ExchangeRateMapper.java b/src/main/java/com/api/xuanran/wang/eny/workflow/mapper/ExchangeRateMapper.java index 8fe3999..7769f1d 100644 --- a/src/main/java/com/api/xuanran/wang/eny/workflow/mapper/ExchangeRateMapper.java +++ b/src/main/java/com/api/xuanran/wang/eny/workflow/mapper/ExchangeRateMapper.java @@ -12,6 +12,6 @@ import aiyh.utils.annotation.recordset.SqlMapper; */ @SqlMapper public interface ExchangeRateMapper { - @Select("select id from fnacurrency where currencyname = #{currencyName}") - String selectCurrencyIdByCurrencyName(@ParamMapper("currencyName") String currencyName); + @Select("select currencyname from fnacurrency where id = #{id}") + String selectCurrencyNameById(@ParamMapper("id") String id); } diff --git a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/controller/CommonDataAsyncController.java b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/controller/CommonDataAsyncController.java new file mode 100644 index 0000000..4e23cda --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/controller/CommonDataAsyncController.java @@ -0,0 +1,42 @@ +package com.api.xuanran.wang.xk_hospital.data_async.controller; + +import aiyh.utils.ApiResult; +import aiyh.utils.Util; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import org.apache.log4j.Logger; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Map; + +/** + *

胸科医院数据同步

+ * + * @author xuanran.wang + * @date 2023/7/17 16:38 + */ +@Path("/wxr/xk_hospital/common") +public class CommonDataAsyncController { + + private final Logger logger = Util.getLogger(); + + @POST + @Path("/{configId}}") + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + public String async(@Context HttpServletRequest request, + @Context HttpServletResponse response, + @PathParam("configId") String configId, + @RequestBody Map params){ + try { + return ""; + }catch (Exception e){ + logger.error("CommonDataAsyncController error : " + e.getMessage()); + Util.logErrorStr(e, logger); + return ApiResult.error("数据同步失败! [ " + e.getMessage() + " ]"); + } + } +} diff --git a/src/main/java/weaver/formmode/customjavacode/modeexpand/ey/jiahx/UpdateStatusAchargeTwo.java b/src/main/java/weaver/formmode/customjavacode/modeexpand/ey/jiahx/UpdateStatusAchargeTwo.java new file mode 100644 index 0000000..e82739f --- /dev/null +++ b/src/main/java/weaver/formmode/customjavacode/modeexpand/ey/jiahx/UpdateStatusAchargeTwo.java @@ -0,0 +1,212 @@ +package weaver.formmode.customjavacode.modeexpand.ey.jiahx; + + +import com.api.nonstandardext.model_field_async.service.ModelFieldAsyncServiceImpl; +import weaver.conn.RecordSet; +import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.HashMap; +import java.util.Map; + +/** + * @Description + * @Author 贾寒旭 + * @Date 2023/4/24 + * @Other + * @Version + */ +public class UpdateStatusAchargeTwo extends AbstractModeExpandJavaCodeNew { + @Override + public Map doModeExpand(Map param) { + BaseBean baseBean = new BaseBean(); + +// src/weaver/formmode/customjavacode/modeexpand/getKmmb.java + baseBean.writeLog("保存自定义接口开始UpdateStatusAchargeTwo"); + Map result = new HashMap(); + try { + User user = (User) param.get("user"); + int billid = -1;//数据id + int modeid = -1;//模块id + RequestInfo requestInfo = (RequestInfo) param.get("RequestInfo"); + if (requestInfo != null) { + billid = Util.getIntValue(requestInfo.getRequestid()); + modeid = Util.getIntValue(requestInfo.getWorkflowid()); + RecordSet rs = new RecordSet(); + if (billid > 0 && modeid > 0) { +// 撤销账单规则,当requestTypewb = (BillingReversal账单)根据原账单号oriInvoiceNo文本字段找到原账单主表和子表数据更新数据 + String sql = "select m.id id,m.finishedTime finishedTime,m.requestTypewb requestTypewb,d.engCodewb engCodewb,m.invoiceNo invoiceNo,d.subInvoiceNo subInvoiceNo," + + "d.totalAmount totalAmount,m.oriInvoiceNo oriInvoiceNo,d.wskje wskje," + + "d.subTotal subTotalZeo,d.totalAmount totalAmountZeo,d.localTotalAmount as localTotalAmountlAmountZeo," + + "d.rmbTotalAmount as rmbTotalAmountZeo,d.balanceAmount as balanceAmountZeo from uf_zdjmbd_dt1 d left join uf_zdjmbd m on m.id = d.mainid where m.id = ?"; + rs.executeQuery(sql, billid); + String mid = ""; + while (rs.next()) { + mid = rs.getString("id"); + String requestTypewb = rs.getString("requestTypewb"); + if (requestTypewb.equals("credit_request")) { + String engCode = rs.getString("engCodewb"); + String invoiceNo = rs.getString("invoiceNo"); + String subInvoiceNo = rs.getString("subInvoiceNo"); + String totalAmount = rs.getString("totalAmount"); + String finishedTime = rs.getString("finishedTime"); + double wskje = Util.getDoubleValue(rs.getString("wskje"), 0f); + String oriInvoiceNo = rs.getString("oriInvoiceNo");//原账单号 + String sqls = "select d.mainid mainid,d.engCodewb engCodewb,d.wskje wskje from uf_zdjmbd_dt1 d left join uf_zdjmbd m on m.id = d.mainid where m.invoiceStatus='0' and m.invoiceNo = ?"; + RecordSet rss = new RecordSet(); + rss.executeQuery(sqls, oriInvoiceNo); + while (rss.next()) { + String orengCode = rss.getString("engCodewb"); + String mainid = rss.getString("mainid"); + double wskjeY = Util.getDoubleValue(rss.getString("wskje"), 0f); + if (orengCode.equals(engCode) && (Math.abs(Util.getDoubleValue(totalAmount, 0f)) < wskjeY)) { +// 1、插入撤销账单号的明细5冲销明细,生成对应新数据 +// 冲销金额cxje=账单.冲销金额cxje + |撤销账单子表.项目代码一致的totalAmount|(绝对值) + String insertsql = "insert into uf_zdjmbd_dt5 (cxzdh,cxzzdh,zdh,zzdh,cxje,cxrq,engCodewb,mainid) values(?,?,?,?,?,?,?,?)"; + RecordSet insertRs = new RecordSet(); + insertRs.executeUpdate(insertsql, invoiceNo, subInvoiceNo, oriInvoiceNo, oriInvoiceNo, totalAmount, finishedTime, engCode, mainid); + String Qusql = "select cxje from uf_zdjmbd_dt1 where engCodewb = ? and mainid = ?"; + RecordSet recordSet1 = new RecordSet(); + recordSet1.executeQuery(Qusql, engCode, mainid); + while (recordSet1.next()) { + double cxje = Util.getDoubleValue(recordSet1.getString("cxje"), 0f); + cxje += Math.abs(Util.getDoubleValue(totalAmount)); + String UpSql = "update uf_zdjmbd_dt1 set cxje = ? where engCodewb = ? and mainid = ?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeUpdate(UpSql, cxje, engCode, mainid); + } + // 未收款金额wskje(需要先执行冲销金额的更新) + // 未收款金额wskje=uf_zdjmbd_dt1中的总金额totalAmount-已收款金额yskje-冲销金额cxje + String Upsql1 = "update uf_zdjmbd_dt1 set wskje = totalAmount-yskje-cxje-hxje where engCodewb = ? and mainid = ?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeUpdate(Upsql1, engCode, mainid); + // 收款状态skzt + // 如果账单明细.未收款金额wskje > 0 则改为1,部分收款 + // 如果账单明细.未收款金额wskje = 0 则改为2,全部收款 + String Qsql1 = "select wskje from uf_zdjmbd_dt1 where engCodewb = ? and mainid = ? "; + recordSet.executeQuery(Qsql1, engCode, mainid); + String skzt = ""; + while (recordSet.next()) { + double wskje1 = Util.getDoubleValue(recordSet.getString("wskje"), 0f); + if (wskje1 > 0) { + skzt = "1"; + } else if (wskje == 0) { + skzt = "2"; + } else { + skzt = "9"; + } + } + String Upsql2 = "update uf_zdjmbd_dt1 set skzt = ? where engCodewb = ? and mainid = ?"; + RecordSet recordSet2 = new RecordSet(); + recordSet2.executeUpdate(Upsql2, skzt, engCode, mainid); + + // 2、更新账单uf_zdjmbd的主表中冲销金额cxje: + // 冲销金额cxje + // 冲销金额cxje=uf_zdjmbd_dt1中的冲销金额cxje合计 + // 未收款金额wskje + // 未收款金额wskje=uf_zdjmbd_dt1中的未收款金额wskje合计 + // 收款状态skzt + // 如果账单明细1.未收款金额合计wskje > 0 则改为1,部分收款 + // 如果账单明细1.未收款金额合计wskje = 0 则改为2,全部收款 + // 账单状态invoiceStatus + // 如果账单明细1.未收款金额合计wskje = 0 则改为2,close + RecordSet Mrs = new RecordSet(); + String Msql = "select * from uf_zdjmbd_dt1 where mainid = ?"; + double cxje1 = 0; + double wskje1 = 0; + String M_skzt = ""; + String invoiceStatus = ""; + Mrs.executeQuery(Msql, mainid); + while (Mrs.next()) { + cxje1 += Util.getDoubleValue(Mrs.getString("cxje"), 0f); + wskje1 += Util.getDoubleValue(Mrs.getString("wskje"), 0f); + if (wskje1 > 0) { + M_skzt = "1"; + invoiceStatus = "0"; + } else if (wskje1 == 0) { + M_skzt = "2"; + invoiceStatus = "1"; + } else { + M_skzt = "1"; + invoiceStatus = "0"; + } + String mainidC = Mrs.getString("mainid"); + String Mupsql = "update uf_zdjmbd set cxje =?,wskje = ?,skzt = ?,invoiceStatus = ? where id = ?"; + baseBean.writeLog("Mupsql=====" + Mupsql); + recordSet2.executeUpdate(Mupsql, cxje1, wskje1, M_skzt, invoiceStatus, mainidC); + } + } + + /** + * 通过配置同步字段 + * @author xuanran.wang + * @date 2023-06-27 + */ + new ModelFieldAsyncServiceImpl().asyncDataByClassName(this.getClass().getSimpleName(), String.valueOf(billid)); + } + String Usql = "update uf_zdjmbd set invoiceStatus = '1' where id = ?"; + RecordSet Urs = new RecordSet(); + Urs.executeUpdate(Usql, billid); + } else if ("zb_request".equals(requestTypewb)) { +// baseBean.writeLog("零账单处理>>>>>>>>>>>>>"); +// String engCode = rs.getString("engCodewb"); +// String invoiceNo = rs.getString("invoiceNo"); +// String subInvoiceNo = rs.getString("subInvoiceNo"); +// //2023年6月1日 新增零账单数据处理 --cds +// String querySql = "select m.id mainid,d.id id,d.engCodewb engCodewb,d.subInvoiceNo as subInvoiceNo from uf_zdjmbd_dt1 d left join uf_zdjmbd m on m.id = d.mainid where m.invoiceStatus='0' and m.invoiceNo = ?"; +// RecordSet rs1 = new RecordSet(); +// rs1.executeQuery(querySql, invoiceNo); +// while (rs1.next()) { +// String engCodewb = Util.null2String(rs1.getString("engCodewb")); +// String subInvoiceNo_dt = Util.null2String(rs1.getString("subInvoiceNo")); +// String dtid = Util.null2String(rs1.getString("id")); +// if (engCodewb.equals(engCode) && subInvoiceNo_dt.equals(subInvoiceNo)) { +// /*1、更新正数账单uf_zdjmbd_dt1子表的字段 +// subTotal +// subTotal = 正数账单中的subTotal+零账单子表.subTotal +// totalAmount +// totalAmount = 正数账单中的totalAmount+零账单子表.totalAmount +// localTotalAmount +// localTotalAmountlAmount = 正数账单中的localTotalAmountlAmount+零账单子表.localTotalAmountlAmount +// rmbTotalAmount +// rmbTotalAmount = 正数账单中的rmbTotalAmount+零账单子表.rmbTotalAmount +// balanceAmount +// balanceAmount = 正数账单中的balanceAmount+零账单子表.balanceAmount +// */ +// double subTotal = Util.getDoubleValue(rs.getString("subTotalZeo"), 0f); +// double totalAmount = Util.getDoubleValue(rs.getString("totalAmountZeo"), 0f); +// double localTotalAmountlAmount = Util.getDoubleValue(rs.getString("localTotalAmountlAmountZeo"), 0f); +// double rmbTotalAmount = Util.getDoubleValue(rs.getString("rmbTotalAmountZeo"), 0f); +// double balanceAmount = Util.getDoubleValue(rs.getString("balanceAmountZeo"), 0f); +// +// String updateSql = "update uf_zdjmbd_dt1 set subTotal=ifnull(subTotal,0)+" + subTotal + ",totalAmount=ifnull(totalAmount,0)+" + totalAmount + ",localTotalAmount=ifnull(localTotalAmount,0)+" + localTotalAmountlAmount + ",rmbTotalAmount=ifnull(rmbTotalAmount,0)+" + rmbTotalAmount + ",balanceAmount=ifnull(balanceAmount,0)+" + balanceAmount + " where id=" + dtid; +// baseBean.writeLog("更新零账单updateSql: " + updateSql); +// RecordSet updateRs = new RecordSet(); +// boolean updateFlag = updateRs.executeUpdate(updateSql); +// baseBean.writeLog("更新零账单updateFlag: " + updateFlag); +// } +// } + } + + } + +// //更新零账单主表的账单状态invoiceStatus改为1,close +// if (!"".equals(mid)) { +// String updateSql = "update uf_zdjmbd set invoiceStatus='1' where id=" + mid; +// baseBean.writeLog("更新零账单主表账单状态Sql:" + updateSql); +// boolean flag = rs.executeUpdate(updateSql); +// baseBean.writeLog("更新零账单主表账单状态flag:" + flag); +// } + } + } + } catch (Exception e) { + baseBean.writeLog("UpdateStatusAchargeTwo catch exception:" + e); + result.put("errmsg", "自定义出错信息"); + result.put("flag", "false"); + } + return result; + } +} diff --git a/src/main/java/weaver/formmode/interfaces/impl/ey/zhang/ImportExtValidateTemplate.java b/src/main/java/weaver/formmode/interfaces/impl/ey/zhang/ImportExtValidateTemplate.java deleted file mode 100644 index 81b2124..0000000 --- a/src/main/java/weaver/formmode/interfaces/impl/ey/zhang/ImportExtValidateTemplate.java +++ /dev/null @@ -1,342 +0,0 @@ -package weaver.formmode.interfaces.impl.ey.zhang; - -import com.alibaba.fastjson.JSON; -import org.apache.commons.lang.StringUtils; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; -import weaver.conn.RecordSet; -import weaver.file.ExcelParseForPOI; -import weaver.formmode.interfaces.ImportPreInterfaceForPOIAction; -import weaver.general.BaseBean; -import weaver.general.Util; -import weaver.hrm.User; -import weaver.seconddev.ey.zhangm.didi.util.DaoUtils; -import weaver.seconddev.ey.zhangm.util.EYSeconddevUtil; - -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Pattern; - - -/** - * @Description - * @Author miao.zhang - * @Version V1.0.0 - * @Since 1.0 - * @Date 6/22/23 - */ -public class ImportExtValidateTemplate implements ImportPreInterfaceForPOIAction { - - @Override - public String checkImportData(Map param, User user, ExcelParseForPOI excelParse) { - - EYSeconddevUtil eySeconddevUtil = new EYSeconddevUtil(); - String ssids="ey_clentid_col,budget_version_col,plan_source_col,ey_bucode_col,ey_oucode_col,ey_mucode_col,ey_smucode_col,ey_engagementname_col,ey_ep_col,ey_em_col,ey_pfma_col,"; - ssids=ssids+"ey_local_service_code_col,ey_mercury_code_col,ey_pycode_col,ey_pacelink_col,ey_oppr_code_col,ey_blocking_level_col,opencheckcustom,"; - ssids=ssids+"opencheckbudget,opencheckcodeblock,opencheckgpn,opencheckengagementname,opencheckpycode,opencheckcodeblockByBcp,openchecklocalservicecode,"; - ssids=ssids+"opencheckconfidential,opencheckopprCode,opencheckmercury,opencheckblocklevel"; - Map ey_params_map =eySeconddevUtil.getSystemParamValues(ssids); - - int ey_clentid_col = Util.getIntValue(ey_params_map.get("ey_clentid_col")); - int budget_version_col = Util.getIntValue(ey_params_map.get("budget_version_col")); - int plan_source_col = Util.getIntValue(ey_params_map.get("plan_source_col")); - int ey_bucode_col = Util.getIntValue(ey_params_map.get("ey_bucode_col")); - int ey_oucode_col = Util.getIntValue(ey_params_map.get("ey_oucode_col")); - int ey_mucode_col = Util.getIntValue(ey_params_map.get("ey_mucode_col")); - int ey_smucode_col = Util.getIntValue(ey_params_map.get("ey_smucode_col")); - int ey_engagementname_col = Util.getIntValue(ey_params_map.get("ey_engagementname_col")); - int ey_ep_col = Util.getIntValue(ey_params_map.get("ey_ep_col")); - int ey_em_col = Util.getIntValue(ey_params_map.get("ey_em_col")); - int ey_pfma_col = Util.getIntValue(ey_params_map.get("ey_pfma_col")); - int ey_local_service_code_col = Util.getIntValue(ey_params_map.get("ey_local_service_code_col")); - int ey_mercury_code_col = Util.getIntValue(ey_params_map.get("ey_mercury_code_col")); - int ey_pycode_col = Util.getIntValue(ey_params_map.get("ey_pycode_col")); - int ey_pacelink_col = Util.getIntValue(ey_params_map.get("ey_pacelink_col")); - int ey_oppr_code_col = Util.getIntValue(ey_params_map.get("ey_oppr_code_col")); - int ey_blocking_level_col = Util.getIntValue(ey_params_map.get("ey_blocking_level_col")); - String opencheckcustom = Util.null2String(ey_params_map.get("opencheckcustom")); - String opencheckbudget = Util.null2String(ey_params_map.get("opencheckbudget")); - String opencheckcodeblock = Util.null2String(ey_params_map.get("opencheckcodeblock")); - String opencheckgpn = Util.null2String(ey_params_map.get("opencheckgpn")); - String opencheckengagementname = Util.null2String(ey_params_map.get("opencheckengagementname")); - String opencheckpycode = Util.null2String(ey_params_map.get("opencheckpycode")); - String opencheckcodeblockByBcp = Util.null2String(ey_params_map.get("opencheckcodeblockByBcp")); - String openchecklocalservicecode = Util.null2String(ey_params_map.get("openchecklocalservicecode")); - String opencheckconfidential = Util.null2String(ey_params_map.get("opencheckconfidential")); - String opencheckopprCode =Util.null2String(ey_params_map.get("opencheckopprCode")); - String opencheckmercury =Util.null2String(ey_params_map.get("opencheckmercury")); - String opencheckblocklevel =Util.null2String(ey_params_map.get("opencheckblocklevel")); - - new BaseBean().writeLog("opencheckcustom==>" + opencheckcustom+",opencheckbudget==>"+opencheckbudget+",opencheckcodeblock==>"+opencheckcodeblock); - new BaseBean().writeLog("opencheckgpn==>" + opencheckgpn+",opencheckengagementname==>"+opencheckengagementname+",opencheckpycode==>"+opencheckpycode); - new BaseBean().writeLog("opencheckcodeblockByBcp==>" + opencheckcodeblockByBcp+",openchecklocalservicecode==>"+openchecklocalservicecode+",opencheckconfidential==>"+opencheckconfidential); - new BaseBean().writeLog("opencheckopprCode==>" + opencheckopprCode+",opencheckmercury==>"+opencheckmercury); - - - // 获取模块ID - Integer modeId = Util.getIntValue(param.get("modeid").toString()); - //表单id - Integer formId = Util.getIntValue(param.get("formid").toString()); - // 获取当前登录人员ID - Integer userId = user.getUID(); - String sheetname = "1"; - //获取第 sheetindex 个sheet的第row行第col列的单元格的值 (下标都是从1开始) - //String value = excelParse.getValue("1", 2, 2); - Workbook wb = excelParse.getWb(); - Sheet sheet = wb.getSheetAt(Util.getIntValue(sheetname) - 1); - StringBuilder error = new StringBuilder(); - Pattern DATE_PATTERN = Pattern.compile("^\\d{4}-\\d{2}$"); - if (sheet != null) { - int rowSum = sheet.getPhysicalNumberOfRows(); - new BaseBean().writeLog("rowSum==>" + rowSum); - int current_row = 0; - for (int i = 2; i <= rowSum; i++) { - current_row = i - 1; - String client_id = Util.null2String(excelParse.getValue("1", i, ey_clentid_col)); - String budget_version_id = Util.null2String(excelParse.getValue("1", i, budget_version_col)); - String bucode = Util.null2String(excelParse.getValue("1", i, ey_bucode_col)); - String oucode = Util.null2String(excelParse.getValue("1", i, ey_oucode_col)); - String mucode = Util.null2String(excelParse.getValue("1", i, ey_mucode_col)); - String plan_source = Util.null2String(excelParse.getValue("1", i, plan_source_col)); - String smucode = Util.null2String(excelParse.getValue("1", i, ey_smucode_col)); - String engagement_name = Util.null2String(excelParse.getValue("1", i, ey_engagementname_col)).trim(); - String ep = Util.null2String(excelParse.getValue("1", i, ey_ep_col)); - String em = Util.null2String(excelParse.getValue("1", i, ey_em_col)); - String pfma = Util.null2String(excelParse.getValue("1", i, ey_pfma_col)); - String pycode = Util.null2String(excelParse.getValue("1", i, ey_pycode_col)).trim(); - String blocking_level= Util.null2String(excelParse.getValue("1", i, ey_blocking_level_col)).trim(); - new BaseBean().writeLog("pycode==>"+pycode); - - - String pace_link = Util.null2String(excelParse.getValue("1", i, ey_pacelink_col)).trim(); - String local_service_code =Util.null2String(excelParse.getValue("1", i, ey_local_service_code_col)).trim(); - String opprCode =Util.null2String(excelParse.getValue("1", i, ey_oppr_code_col)).trim(); - String mercury_code =Util.null2String(excelParse.getValue("1", i, ey_mercury_code_col)).trim(); - String countryregioncode =Util.null2String(DaoUtils.querySingleVal("select countryregioncode from uf_Codeblockjcdab where bucode=? and oucode=? and mucode=? and smucode=?",bucode, oucode, mucode, smucode)); - String local_global_service_code =DaoUtils.querySingleVal("select global_service_code from uf_service_code where Servicecode=?",local_service_code); - new BaseBean().writeLog("====1、mercury_code===="+mercury_code ); - String mercury_global_service_code =DaoUtils.querySingleVal("select global_service_code from uf_msc_gsc where mercury_service_code=?",mercury_code); - - //1、Excel模版 BU 、OU、MU、SMU校验:是否存在对应codeblock Done - if (opencheckcodeblock.equals("1")) { - new BaseBean().writeLog("====1、opencheckcodeblock.start====" ); - RecordSet recordSet = DaoUtils.executeQuery("select " + - " count(1) as rowcount " + - " from uf_Codeblockjcdab where bucode=? and oucode=? and mucode=? and smucode=?", bucode, oucode, mucode, smucode); - if (recordSet.next()) { - int rowcount = recordSet.getInt("rowcount"); - if (rowcount > 1) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认codeblock是否唯一!").append("
"); - } else if (rowcount == 0) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,未匹配到对应codeblock数据!").append("
"); - } - } - - new BaseBean().writeLog("====1、opencheckcodeblock.end====" ); - } - - //2、Excel模版 BU 、OU、MU、SMU校验:调用业务核心接口 Done - if (opencheckcodeblockByBcp.equals("1")) { - new BaseBean().writeLog("====2、opencheckcodeblockByBcp.start====" ); - boolean flag =eySeconddevUtil.getLegalEffective(bucode,oucode,mucode,smucode); - new BaseBean().writeLog("getLegalEffective===>"+flag); - if(!flag){ - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认Bu,Ou,Mu,Smu有效性! ").append("
"); - } - new BaseBean().writeLog("====2、opencheckcodeblockByBcp.end====" ); - } - - //3、Excel模版商机校验:国家编号不是MNG,商机id必填 Done - if (opencheckopprCode.equals("1") ) { - new BaseBean().writeLog("====3、opencheckopprCode.start====" ); - new BaseBean().writeLog("====3、countryregioncode===="+countryregioncode ); - if(StringUtils.isNotBlank(countryregioncode)){ - if( !countryregioncode.equals("MNG") && opprCode.equals("")){ - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,商机id必填! ").append("
"); - } - } - - new BaseBean().writeLog("====3、opencheckopprCode.end====" ); - } - - //4、Excel模版Client_id校验 Done - if (opencheckcustom.equals("1")) { - new BaseBean().writeLog("====4、opencheckcustom.start====" ); - Map custominfo = eySeconddevUtil.getCustomInfo(client_id); - String code = Util.null2String((String)custominfo.get("code")); - new BaseBean().writeLog("getCustomInfo===>"+code); - if (!code.equals("100")) { - //return "数据验证失败:第一个sheet第"+current_row+"行数据的,请确认客户中心系统中已存在该客户!"; - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认客户中心系统中已存在该客户! ") - .append("
"); - } - new BaseBean().writeLog("====4、opencheckcustom.end====" ); - } - - //5、Excel模版Client_id,商机id,PACE_ID(截取PACE_link) 校验项 :前置条件:国家编号不是MNG, - // 调用商机接口传入Client_id,商机id,PACE_ID 是否有效,有效返回IsConfidential Done - if (opencheckconfidential.equals("1")) { - new BaseBean().writeLog("====5、opencheckconfidential.start====" ); - String pace_id =""; - if(StringUtils.isNotBlank(pace_link)){ - int beginindex =pace_link.lastIndexOf("Assessment/")+11; - String endstr =pace_link.substring(beginindex,pace_link.length()); - int endindex = endstr.lastIndexOf("/"); - pace_id =pace_link.substring(beginindex,beginindex+endindex); - new BaseBean().writeLog("ModeExpandForExtCodeImport,pace_id==>"+pace_id); - } - Map result =eySeconddevUtil.getConfidentialInfo(opprCode,pace_id,client_id); - String errstr =Util.null2String(result.get("errorstr")); - if(StringUtils.isNotBlank(errstr)){ - error.append("数据验证失败:第一个sheet第" + current_row + "行数据,请确认"+errstr.substring(0,errstr.length()-1)+"等问题! ") - .append("
"); - } - new BaseBean().writeLog("====5、opencheckconfidential.end====" ); - } - - //6、Excel模版”PY_Code” 校验: PY code 历史上是否存在对应的.engagement_code Done - if (opencheckpycode.equals("1")) { - new BaseBean().writeLog("====6、opencheckpycode.start====" ); - new BaseBean().writeLog("====6、opencheckpycode.pycode===="+pycode ); - if(StringUtils.isNotBlank(pycode)){ - RecordSet rs2 = new RecordSet(); - rs2.executeQuery("select id from uf_xmjbxxjmbd where engagement_code=?", pycode); - if (!rs2.next()) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,该项目PY_CODE未关联! ").append("
"); - } - } - new BaseBean().writeLog("====6、opencheckpycode.end====" ); - } - - //7、Excel模版“本地服务编码”校验:uf_service_code.Servicecode 是否存在 Done - if (openchecklocalservicecode.equals("1")) { - new BaseBean().writeLog("====7、openchecklocalservicecode.start====" ); - RecordSet rs2 = new RecordSet(); - new BaseBean().writeLog("====7、openchecklocalservicecode.local_service_code====" +local_service_code); - rs2.executeQuery("select id from uf_service_code where Servicecode=? ",local_service_code); - if(!rs2.next()){ - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认本地服务编码是否有效! ").append("
"); - } - new BaseBean().writeLog("====7、openchecklocalservicecode.end====" ); - } - - //8、Excel模版“计划编号”校验项 ,根据“计划来源”,调用CCT&MMT或者SmartHub接口是否存在 Done - if (opencheckbudget.equals("1")) { - new BaseBean().writeLog("==8、opencheckbudget。start=="); - Map budgetinfo = new HashMap (); - new BaseBean().writeLog("==plan_source=="+plan_source); - if(!(plan_source.equals("CCT") || plan_source.equals("MMT") || plan_source.equals("SmartHub") )){ - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,计划来源填写错误只允许填写CCT、MMT、SmartHub!").append("
"); - } - if (plan_source.equals("CCT") || plan_source.equals("MMT")) { - budgetinfo = eySeconddevUtil.getBudgetInfo("mmtplandetail", budget_version_id); - } else { - budgetinfo = eySeconddevUtil.getBudgetInfo("smarthubbudgetdetail", budget_version_id); - } - new BaseBean().writeLog("==budgetinfo=="+ JSON.toJSONString(budgetinfo)); - if (budgetinfo.isEmpty() || budgetinfo==null) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认预算系统中是否存在该预算!").append("
"); - } - new BaseBean().writeLog("==8、opencheckbudget。end=="); - } - - //9、Excel模版GPN是否存在 Done - if (opencheckgpn.equals("1")) { - - new BaseBean().writeLog("==9、opencheckgpn。start=="); - new BaseBean().writeLog("em==>"+em); - new BaseBean().writeLog("ep==>"+ep); - new BaseBean().writeLog("pfma==>"+pfma); - - if (StringUtils.isNotBlank(ep)) { - RecordSet recordSet=new RecordSet(); - recordSet.executeQuery("select id from hrmresource where workcode=?",ep); - if(!recordSet.next()){ - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认EP的GPN不存在系统中!").append("
"); - } - } - - if (StringUtils.isNotBlank(em)) { - RecordSet recordSet=new RecordSet(); - recordSet.executeQuery("select id from hrmresource where workcode=?",em); - if(!recordSet.next()){ - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认EP的GPN不存在系统中!").append("
"); - } - } - - if (StringUtils.isNotBlank(pfma)) { - RecordSet recordSet=new RecordSet(); - recordSet.executeQuery("select id from hrmresource where workcode=?",pfma); - if(!recordSet.next()){ - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认PFMA的GPN不存在系统中!").append("
"); - } - } - new BaseBean().writeLog("==9、opencheckgpn。end=="); - } - - //10、mercury_service_code校验 Done - if(opencheckmercury.equals("1")){ - new BaseBean().writeLog("==10、opencheckmercury。start=="); - new BaseBean().writeLog("====10、mercury_global_service_code===="+mercury_global_service_code ); - new BaseBean().writeLog("====10、local_global_service_code===="+local_global_service_code ); - if(!mercury_global_service_code.equals(local_global_service_code)){ - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认MercuryCode与global_service_code不匹配!").append("
"); - } - new BaseBean().writeLog("==10、opencheckmercury。end=="); - } - - - //11、Excel的项目名称 Done - if (opencheckengagementname.equals("1")) { - new BaseBean().writeLog("==11、opencheckengagementname。start=="); - new BaseBean().writeLog("==11、opencheckengagementname。engagement_name=="+engagement_name); - RecordSet recordSet = new RecordSet(); - recordSet.executeQuery("select " + - " servicelinecode, subservicelinecode " + - " from uf_Codeblockjcdab where bucode=? and oucode=? and mucode=? and smucode=?", bucode, oucode, mucode, smucode); - if(recordSet.next()){ - String servicelinecode =Util.null2String(recordSet.getString("servicelinecode")); - String subservicelinecode =Util.null2String(recordSet.getString("subservicelinecode")); - if(servicelinecode.equals("01") && subservicelinecode.equals("0101")){ //serviceline=01和subserviceline=0101时,触发项目名称校验 - //检验 :0~3位 必须是AUT 或者 INT - boolean flag = EYSeconddevUtil.vaildateImportEnagementName(engagement_name,local_global_service_code); - String datestr = engagement_name.substring(3, 10); - if(!flag){ - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认前3位是否合规! ").append("
"); - }else if(!DATE_PATTERN.matcher(datestr).matches()){ //检验:4~10位 必须是YYYY-MM - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认4到10位是否日期字段,如:2001-01! ").append("
"); - - } - } - } - new BaseBean().writeLog("==11、opencheckengagementname。end=="); - } - - //12、BlockLevel Done - if(opencheckblocklevel.equals("1")){ - new BaseBean().writeLog("==12、opencheckblocklevel.start=="); - if (StringUtils.isNotBlank(ep)) { - RecordSet recordSet=new RecordSet(); - recordSet.executeQuery("select id from uf_bl where engblocklevel =?",blocking_level); - if(!recordSet.next()){ - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,blocking_level填写有误请检查!").append("
"); - } - } - new BaseBean().writeLog("==12、opencheckblocklevel.end=="); - } - // 12、校验项目EP Rank - if (!"".equals(ep) && !eySeconddevUtil.validateEngagementRoleRank(ep,"1","0")) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,EP填写有误请检查!").append("
"); - } - // 13、校验项目EM Rank - if (!"".equals(em) && !eySeconddevUtil.validateEngagementRoleRank(em,"1","0")) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,EM填写有误请检查!").append("
"); - } - } - } - - String returnstr =error.toString(); - new BaseBean().writeLog("returnstr===>"+returnstr); - return returnstr; - } -} diff --git a/src/main/java/weaver/formmode/interfaces/impl/ey/zhang/ImportNtoOValidateTemplate.java b/src/main/java/weaver/formmode/interfaces/impl/ey/zhang/ImportNtoOValidateTemplate.java deleted file mode 100644 index cf859ba..0000000 --- a/src/main/java/weaver/formmode/interfaces/impl/ey/zhang/ImportNtoOValidateTemplate.java +++ /dev/null @@ -1,307 +0,0 @@ -package weaver.formmode.interfaces.impl.ey.zhang; - -import org.apache.commons.lang.StringUtils; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; -import weaver.conn.RecordSet; -import weaver.file.ExcelParseForPOI; -import weaver.formmode.interfaces.ImportPreInterfaceForPOIAction; -import weaver.general.BaseBean; -import weaver.general.Util; -import weaver.hrm.User; -import weaver.seconddev.ey.zhangm.didi.util.DaoUtils; -import weaver.seconddev.ey.zhangm.util.EYSeconddevUtil; - -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Pattern; - - -/** - * @Description - * @Author miao.zhang - * @Version V1.0.0 - * @Since 1.0 - * @Date 6/22/23 - */ -public class ImportNtoOValidateTemplate implements ImportPreInterfaceForPOIAction { - - - @Override - public String checkImportData(Map param, User user, ExcelParseForPOI excelParse) { - - EYSeconddevUtil eySeconddevUtil = new EYSeconddevUtil(); - - - String ssids="ey_nto_clentid_col,ey_nto_budget_version_col,ey_nto_bucode_col,ey_nto_oucode_col,ey_nto_mucode_col,ey_nto_smucode_col,ey_nto_engagementname_col,ey_nto_ep_col,ey_nto_em_col,ey_nto_pfma_col,"; - ssids=ssids+"ey_nto_engagementcode_col,ey_nto_mercurycode_col,ey_nto_pacelink_col,opencheckntooengagementstatus,"; - ssids=ssids+"opencheckntooservicecode,opencheckntooserviceline,opencheckntopycode,opencheckntoengagementname,opencheckntocustom,opencheckntocodeblock,opencheckntogpn,"; - ssids=ssids+"opencheckntobudget,opencheckntomercury,opencheckntopaceid"; - Map ey_params_map =eySeconddevUtil.getSystemParamValues(ssids); - - - int ey_clentid_col = Util.getIntValue(ey_params_map.get("ey_nto_clentid_col")); - int budget_version_col = Util.getIntValue(ey_params_map.get("ey_nto_budget_version_col")); - int ey_bucode_col = Util.getIntValue(ey_params_map.get("ey_nto_bucode_col")); - int ey_oucode_col = Util.getIntValue(ey_params_map.get("ey_nto_oucode_col")); - int ey_mucode_col = Util.getIntValue(ey_params_map.get("ey_nto_mucode_col")); - int ey_smucode_col = Util.getIntValue(ey_params_map.get("ey_nto_smucode_col")); - int ey_engagementname_col = Util.getIntValue(ey_params_map.get("ey_nto_engagementname_col")); - int ey_ep_col = Util.getIntValue(ey_params_map.get("ey_nto_ep_col")); - int ey_em_col = Util.getIntValue(ey_params_map.get("ey_nto_em_col")); - int ey_pfma_col = Util.getIntValue(ey_params_map.get("ey_nto_pfma_col")); - int ey_engagementcode_col = Util.getIntValue(ey_params_map.get("ey_nto_engagementcode_col")); - int ey_mercurycode_col = Util.getIntValue(ey_params_map.get("ey_nto_mercurycode_col")); - int ey_pacelink_col = Util.getIntValue(ey_params_map.get("ey_nto_pacelink_col")); - - String opencheckntooengagementstatus = Util.null2String(ey_params_map.get("opencheckntooengagementstatus")); - String opencheckntoservicecode = Util.null2String(ey_params_map.get("opencheckntooservicecode")); - String opencheckntoserviceline = Util.null2String(ey_params_map.get("opencheckntooserviceline")); - String opencheckntopycode = Util.null2String(ey_params_map.get("opencheckntopycode")); - String opencheckntoengagementname = Util.null2String(ey_params_map.get("opencheckntoengagementname")); - String opencheckntocustom = Util.null2String(ey_params_map.get("opencheckntocustom")); - String opencheckntocodeblock= Util.null2String(ey_params_map.get("opencheckntocodeblock")); - String opencheckntogpn= Util.null2String(ey_params_map.get("opencheckntogpn")); - String opencheckntobudget = Util.null2String(ey_params_map.get("opencheckntobudget")); - String opencheckntomercury= Util.null2String(ey_params_map.get("opencheckntomercury")); - String opencheckntopaceid = Util.null2String(ey_params_map.get("opencheckntopaceid")); - - new BaseBean().writeLog("opencheckntooengagementstatus==>" + opencheckntooengagementstatus+",opencheckntoservicecode==>"+opencheckntoservicecode+",opencheckntoserviceline==>"+opencheckntoserviceline); - new BaseBean().writeLog("opencheckntopycode==>" + opencheckntopycode+",opencheckntoengagementname==>"+opencheckntoengagementname+",opencheckntocustom==>"+opencheckntocustom); - new BaseBean().writeLog("opencheckntocodeblock==>" + opencheckntocodeblock+",opencheckntogpn==>"+opencheckntogpn+",opencheckntobudget==>"+opencheckntobudget); - new BaseBean().writeLog("opencheckntomercury==>" + opencheckntomercury+",opencheckntopaceid==>"+opencheckntopaceid); - - - // 获取模块ID - Integer modeId = Util.getIntValue(param.get("modeid").toString()); - //表单id - Integer formId = Util.getIntValue(param.get("formid").toString()); - // 获取当前登录人员ID - Integer userId = user.getUID(); - String sheetname = "1"; - //获取第 sheetindex 个sheet的第row行第col列的单元格的值 (下标都是从1开始) - //String value = excelParse.getValue("1", 2, 2); - Workbook wb = excelParse.getWb(); - Sheet sheet = wb.getSheetAt(Util.getIntValue(sheetname) - 1); - StringBuilder error = new StringBuilder(); - Pattern DATE_PATTERN = Pattern.compile("^\\d{4}-\\d{2}$"); - if (sheet != null) { - int rowSum = sheet.getPhysicalNumberOfRows(); - new BaseBean().writeLog("rowSum==>" + rowSum); - int current_row = 0; - for (int i = 2; i <= rowSum; i++) { - current_row = i - 1; - String client_id = Util.null2String(excelParse.getValue("1", i, ey_clentid_col)); - String budget_version_id = Util.null2String(excelParse.getValue("1", i, budget_version_col)); - String bucode = Util.null2String(excelParse.getValue("1", i, ey_bucode_col)); - String oucode = Util.null2String(excelParse.getValue("1", i, ey_oucode_col)); - String mucode = Util.null2String(excelParse.getValue("1", i, ey_mucode_col)); - String smucode = Util.null2String(excelParse.getValue("1", i, ey_smucode_col)); - String engagement_name = Util.null2String(excelParse.getValue("1", i, ey_engagementname_col)).trim(); - String ep = Util.null2String(excelParse.getValue("1", i, ey_ep_col)); - String em = Util.null2String(excelParse.getValue("1", i, ey_em_col)); - String pfma = Util.null2String(excelParse.getValue("1", i, ey_pfma_col)); - String engagement_code = Util.null2String(excelParse.getValue("1", i, ey_engagementcode_col)).trim(); - String mercury_code = Util.null2String(excelParse.getValue("1", i, ey_mercurycode_col)).trim(); - String pace_link = Util.null2String(excelParse.getValue("1", i, ey_pacelink_col)).trim(); - - RecordSet rs2 = new RecordSet(); - rs2.executeQuery("select engagement_status,local_service_code,global_service_code,service_line,sub_service_line,py_code from uf_xmjbxxjmbd where engagement_code=? ", engagement_code); - if(rs2.next()) { - String local_service_code = Util.null2String(rs2.getString("local_service_code")); - String service_line = Util.null2String(rs2.getString("service_line")); - String global_service_code = Util.null2String(rs2.getString("global_service_code")); - String sub_service_line = Util.null2String(rs2.getString("sub_service_line")); - String temp_py_code = Util.null2String(rs2.getString("py_code")); - String engagement_status = Util.null2String(rs2.getString("engagement_status")); - //String local_global_service_code =DaoUtils.querySingleVal("select global_service_code from uf_service_code where Servicecode=?",local_service_code); - String mercury_global_service_code = DaoUtils.querySingleVal("select global_service_code from uf_msc_gsc where mercury_service_code=?", mercury_code); - String old_pace_id = DaoUtils.querySingleVal("select pace_id from uf_xmjbxxjmbd where engagement_code=?", temp_py_code); - String py_engagement_name = DaoUtils.querySingleVal("select engagement_name from uf_xmjbxxjmbd where engagement_code=?", temp_py_code); - - //1、校验该项目编号在项目档案中的 通过engcode查询,项目状态为N - if (opencheckntooengagementstatus.equals("1")) { - new BaseBean().writeLog("====1、opencheckntooengagementstatus.start===="); - new BaseBean().writeLog("engagement_status==>" + engagement_status); - if (!engagement_status.equals("N")) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,原项目状态不为N! ").append("
"); - } - new BaseBean().writeLog("====1、opencheckntooengagementstatus.end===="); - } - - //2、校验GSC为031、035。通过engcode查询,GSC为GSC =031、GSC=035 ,local_serivce_code=03500 or local_serivce_code=03100 - if (opencheckntoservicecode.equals("1")) { - new BaseBean().writeLog("====2、opencheckntoservicecode.start===="); - new BaseBean().writeLog("local_service_code==>" + local_service_code); - if (!local_service_code.equals("03500") && !local_service_code.equals("03100")) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,原项目本地服务编码是03500或03100! ").append("
"); - } - new BaseBean().writeLog("====2、opencheckntoservicecode.end===="); - } - //3、原项目业务线必须是ASU! - if (opencheckntoserviceline.equals("1")) { - new BaseBean().writeLog("====3、opencheckntoserviceline.start===="); - new BaseBean().writeLog("====3、service_line====" + service_line); - new BaseBean().writeLog("====3、sub_service_line====" + sub_service_line); - if (!(service_line.equals("01") && sub_service_line.equals("0101"))) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,原项目业务线必须是ASU,子业务线是Audit! ").append("
"); - } - new BaseBean().writeLog("====3、opencheckntoserviceline.end===="); - } - - //4、校该项目编号在项目档案中关联的PY Code不能为空 - if (opencheckntopycode.equals("1")) { - new BaseBean().writeLog("====4、opencheckntopycode.start===="); - new BaseBean().writeLog("====4、opencheckntopycode.temp_py_code====" + temp_py_code); - if (temp_py_code.equals("")) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,项目原PY_CODE不能为空! ").append("
"); - } - new BaseBean().writeLog("====4、opencheckntopycode.end===="); - } - - //5、Excel的项目名称 Done - if (opencheckntoengagementname.equals("1")) { - new BaseBean().writeLog("====5、opencheckntoengagementname.start===="); - if (engagement_name.equals(py_engagement_name)) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,项目名称不合规,请确认项目名称是否重复或名称格式是否错误,正确格式如:AUD2023-01XXXXX! ").append("
"); - }else if(engagement_name.length()<=10){ - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,项目名称不合规,请确认项目名称是否重复或名称格式是否错误,正确格式如:AUD2023-01XXXXX! ").append("
"); - }else if (engagement_name.length()>10 ){ - String datestr = engagement_name.substring(3, 10); - //String perfix = engagement_name.substring(0, 3); - boolean flag = EYSeconddevUtil.vaildateImportEnagementName(engagement_name,global_service_code); - //检验:4~10位 必须是YYYY-MM - if (!DATE_PATTERN.matcher(datestr).matches()) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,项目名称不合规,请确认项目名称是否重复或名称格式是否错误,正确格式如:AUD2023-01XXXXX! ").append("
"); - }else if(!flag) { //检验 :0~3位 必须是AUT 或者 INT - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,项目名称不合规,请确认项目名称是否重复或名称格式是否错误,正确格式如:AUD2023-01XXXXX! ").append("
"); - } - }else if (engagement_name.length()<=10){ - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,项目名称不合规,请确认项目名称是否重复或名称格式是否错误,正确格式如:AUD2023-01XXXXX! ").append("
"); - } - - new BaseBean().writeLog("====5、opencheckntoengagementname.end===="); - } - - //6、客户信息 Done - if (opencheckntocustom.equals("1")) { - new BaseBean().writeLog("====6、opencheckntocustom.start===="); - Map custominfo = eySeconddevUtil.getCustomInfo(client_id); - String code = Util.null2String(custominfo.get("code")); - if (!code.equals("100")) { - //return "数据验证失败:第一个sheet第"+current_row+"行数据的,请确认客户中心系统中已存在该客户!"; - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认客户中心系统中已存在该客户! ") - .append("
"); - } - new BaseBean().writeLog("====6、opencheckntocustom.end===="); - } - - //7、pace_id校验 - if (opencheckntopaceid.equals("1")) { - new BaseBean().writeLog("====7、opencheckntopaceid.start===="); - String pace_id = ""; - if (StringUtils.isNotBlank(pace_link)) { - int beginindex = pace_link.lastIndexOf("Assessment/") + 11; - String endstr = pace_link.substring(beginindex, pace_link.length()); - int endindex = endstr.lastIndexOf("/"); - pace_id = pace_link.substring(beginindex, beginindex + endindex); - new BaseBean().writeLog("ModeExpandForExtCodeImport,pace_id==>" + pace_id); - } - if (pace_id.equals(old_pace_id)) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,未创建新的PACE!").append("
"); - } - - new BaseBean().writeLog("====7、opencheckntopaceid.end===="); - } - - //8、CodeBlock信息 Done - if (opencheckntocodeblock.equals("1")) { - new BaseBean().writeLog("====8、opencheckntocodeblock.start===="); - RecordSet recordSet = DaoUtils.executeQuery("select " + - " id " + - " from uf_Codeblockjcdab where bucode=? and oucode=? and mucode=? and smucode=?", bucode, oucode, mucode, smucode); - if (!recordSet.next()) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,未匹配到对应codeblock数据!").append("
"); - } - new BaseBean().writeLog("====8、opencheckntocodeblock.end===="); - } - - //9、GPN是否存在 Done - if (opencheckntogpn.equals("1")) { - new BaseBean().writeLog("====9、opencheckntogpn.start===="); - new BaseBean().writeLog("em==>" + em); - new BaseBean().writeLog("ep==>" + ep); - new BaseBean().writeLog("pfma==>" + pfma); - - if (StringUtils.isNotBlank(ep)) { - RecordSet recordSet = new RecordSet(); - recordSet.executeQuery("select id from hrmresource where workcode=?", ep); - if (!recordSet.next()) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认EP的GPN不存在系统中!").append("
"); - } - } - - if (StringUtils.isNotBlank(em)) { - RecordSet recordSet = new RecordSet(); - recordSet.executeQuery("select id from hrmresource where workcode=?", em); - if (!recordSet.next()) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认EP的GPN不存在系统中!").append("
"); - } - } - - if (StringUtils.isNotBlank(pfma)) { - RecordSet recordSet = new RecordSet(); - recordSet.executeQuery("select id from hrmresource where workcode=?", pfma); - if (!recordSet.next()) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认PFMA的GPN不存在系统中!").append("
"); - } - } - new BaseBean().writeLog("====9、opencheckntogpn.end===="); - } - - // 10、SmartHub检查 - if (opencheckntobudget.equals("1")) { - new BaseBean().writeLog("====10、opencheckntobudget.start===="); - Map budgetinfo = new HashMap (); - budgetinfo = eySeconddevUtil.getBudgetInfo("smarthubbudgetdetail", budget_version_id); - //} - if (budgetinfo.size() == 0) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认预算系统中已存在该预算!").append("
"); - } - new BaseBean().writeLog("====10、opencheckntobudget.end===="); - } - -// 11、mercury_service_code校验 Done - if (opencheckntomercury.equals("1")) { - new BaseBean().writeLog("====11、opencheckntomercury.start===="); - new BaseBean().writeLog("global_service_code==>" + global_service_code); - new BaseBean().writeLog("mercury_global_service_code==>" + mercury_global_service_code); - if (!(mercury_global_service_code.equals(global_service_code))) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认Mercury Service Code与Global Service Code不匹配!").append("
"); - } - new BaseBean().writeLog("====11、opencheckntomercury.end===="); - } - - }else{ - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认Engagement Code不存在!").append("
"); - - } - // 12、校验项目EP Rank - if (!"".equals(ep) && !eySeconddevUtil.validateEngagementRoleRank(ep,"1","0")) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,EP填写有误请检查!").append("
"); - } - // 13、校验项目EM Rank - if (!"".equals(em) && !eySeconddevUtil.validateEngagementRoleRank(em,"1","0")) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,EM填写有误请检查!").append("
"); - } - } - } - if (error.toString().equals("")) { - return ""; - } else { - return error.toString(); - } - - - } -} diff --git a/src/main/java/weaver/seconddev/ey/zhangm/didi/util/EYSeconddevUtil.java b/src/main/java/weaver/seconddev/ey/zhangm/didi/util/EYSeconddevUtil.java new file mode 100644 index 0000000..13e24d3 --- /dev/null +++ b/src/main/java/weaver/seconddev/ey/zhangm/didi/util/EYSeconddevUtil.java @@ -0,0 +1,773 @@ +package weaver.seconddev.ey.zhangm.didi.util; + + +import com.alibaba.fastjson.JSON; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.wbi.util.StringUtil; +import com.weaver.esb.client.EsbClient; +import com.weaver.esb.spi.EsbService; +import okhttp3.*; + +import org.apache.commons.lang.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.resource.ResourceComInfo; +import weaver.seconddev.ey.zhangm.didi.entity.Result; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.util.*; + +public class EYSeconddevUtil extends BaseBean { + /** + * 获取汇率相关信息 + * @param amount 转换前金额 + * @param fromCurrency 本位币 + * @param toCurrency 目标币种 + * @param rateType 汇率类型 0 CN日汇率 6 日汇率global CN周汇率 1 周汇率global 2 + * @param date + * @return {"rateType":"rateType","date","2023-10-11","formCurrency":"CNY","toCurrency":"USD","exchargeRate":"8.000000","tronferBeforeAmount":"1000.00","tronferAfterAmount":"8000.00"} + */ + public Map getExchargeRate(BigDecimal amount,String fromCurrency,String toCurrency,String rateType,String date){ + RecordSet rs = new RecordSet(); + //rs.executeQuery(""); + return null; + } + /** + * 校验用户是否存在 + * @param workcode + * @return + */ + public boolean validateUser(String workcode){ + RecordSet rs = new RecordSet(); + rs.executeQuery("select id from hrmresource where workcode=?,workcode"); + return rs.getCounts()>0; + } + /** + * 校验EM、EP rank + * @param gpn + * @param mark 内部项目、外部项目标识 0 内部、1外部 + * @param role 项目角色标识标识 0 EP、1 EM + * @return + */ + public boolean validateEngagementRoleRank(String gpn,String mark,String role){ + RecordSet rs=new RecordSet(); + rs.executeQuery("select id from hrmresource where workcode=?",gpn); + String userId=""; + if(rs.next()){ + userId=Util.null2String(rs.getString(1)); + } + writeLog("validateEngagementRoleRank>>>>gpn:"+gpn); + // 查询rank + String rank=""; + rs.executeQuery("select concat(field2,field24) from cus_fielddata scope='HrmCustomFieldByInfoType' and scopeid=-1 and id=?",userId); + if(rs.next()){ + rank=Util.null2String(rs.getString(1)); + } + writeLog("validateEngagementRoleRank>>>>rank:"+rank); + // 校验rank + rs.executeQuery("select id from uf_xmjsrankjyb where rankcode=? and mark=? and role=?",rank,mark,role); + return rs.getCounts()>0; + } + + public String getSystemParamValue(String ssid){ + String paramvalue =""; + if(!"".equals(ssid)){ + String select_sql="select paramvalue from uf_dd_prmt where ssid ='"+ssid+"'"; + RecordSet rs =new RecordSet(); + rs.executeSql(select_sql); + if(rs.next()){ + paramvalue = Util.null2String(rs.getString("paramvalue")); + } + } + return paramvalue; + } + + public Map getSystemParamValues(String ssids){ + + HashMap paramvalues=new HashMap(); + String ssidsstr=""; + if(!"".equals(ssids)){ + String [] ssidsArray = ssids.split(","); + for (String s:ssidsArray){ + if(!"".equals(s)) { + ssidsstr = ssidsstr + "'" + s + "',"; + } + } + if(!"".equals(ssidsstr)) { + ssidsstr = ssidsstr.substring(0, ssidsstr.length() - 1); + String select_sql="select ssid,paramvalue from uf_dd_prmt where ssid in("+ssidsstr+")"; + RecordSet rs =new RecordSet(); + rs.executeSql(select_sql); + while (rs.next()){ + paramvalues.put(rs.getString("ssid"),rs.getString("paramvalue")); + } + } + } + return paramvalues; + } + + public String getUserAllRole(Integer userid){ + String returnStr = ""; + RecordSet rs = new RecordSet(); + rs.executeSql("select roleid from hrmrolemembers where resourceid=" + userid); + while (rs.next()) { + returnStr = returnStr + Util.null2String(rs.getString("roleid")) + ","; + } + if (!"".equals(returnStr)) { + returnStr = returnStr.substring(0, returnStr.length() - 1); + } + if ("".equals(returnStr)) { + returnStr = "0"; + } + return returnStr; + } + + public String getMD5Str(String plainText){ + //定义一个字节数组 + byte[] secretBytes = null; + try { + // 生成一个MD5加密计算摘要 + MessageDigest md = MessageDigest.getInstance("MD5"); + //对字符串进行加密 + md.update(plainText.getBytes()); + //获得加密后的数据 + secretBytes = md.digest(); + } catch (NoSuchAlgorithmException e) { + //throw new RuntimeException("没有md5这个算法!"); + //throw new RuntimeException(SystemEnv.getHtmlLabelName(517545,userLanguage)); + } + //将加密后的数据转换为16进制数字 + String md5code = new BigInteger(1, secretBytes).toString(16); + // 如果生成数字未满32位,需要前面补0 + // 不能把变量放到循环条件,值改变之后会导致条件变化。如果生成30位 只能生成31位md5 + int tempIndex = 32 - md5code.length(); + for (int i = 0; i < tempIndex; i++) { + md5code = "0" + md5code; + } + return md5code; + } + + public static String getCurrentTime() { + Date newdate = new Date(); + long datetime = newdate.getTime(); + Timestamp timestamp = new Timestamp(datetime); + String currenttime = (timestamp.toString()).substring(11, 13) + ":" + (timestamp.toString()).substring(14, 16) + ":" + + (timestamp.toString()).substring(17, 19); + return currenttime; + } + + public static String getCurrentDate() { + Date newdate = new Date(); + long datetime = newdate.getTime(); + Timestamp timestamp = new Timestamp(datetime); + String currentdate = (timestamp.toString()).substring(0, 4) + "-" + (timestamp.toString()).substring(5, 7) + "-" + + (timestamp.toString()).substring(8, 10); + return currentdate; + } + + /** + * 获取当前日期时间。 YYYY-MM-DD HH:MM:SS + * @return 当前日期时间 + */ + public static String getCurDateTime() { + Date newdate = new Date(); + long datetime = newdate.getTime(); + Timestamp timestamp = new Timestamp(datetime); + return (timestamp.toString()).substring(0, 19); + } + + /** + * 获取时间戳 格式如:19990101235959 + * @return + */ + public static String getTimestamp(){ + return getCurDateTime().replace("-", "").replace(":", "").replace(" ", ""); + } + + public static String doAction(Map paramDatajson,String url,String method){ + String resultstr=""; + try{ + OkHttpClient client = new OkHttpClient().newBuilder() + .build(); + MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); + new BaseBean().writeLog("json==>"+ JSON.toJSONString(paramDatajson)); + + RequestBody body = RequestBody.create(mediaType, "datajson="+ JSON.toJSONString(paramDatajson)); + + Request request = new Request.Builder() + .url(url) + .method(method, body) + .addHeader("Content-Type", "application/x-www-form-urlencoded") + .build(); + Response result = client.newCall(request).execute(); + resultstr = result.body().string(); + + }catch (Exception e){ + new BaseBean().writeLog("请求失败"+getCurrentDate()+" "+getCurrentDate()+"====errormsg:"+e.getMessage()); + } + return resultstr; + } + + /** + * 传入两个时间范围,返回这两个时间范围内的所有日期,并保存在一个集合中 + * + * @param beginTime + * @param endTime + * @return + * @throws Exception + */ + public static List findEveryDay(String beginTime, String endTime) + throws Exception { + //创建一个放所有日期的集合 + List dates = new ArrayList(); + + //创建时间解析对象规定解析格式 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + + //将传入的时间解析成Date类型,相当于格式化 + Date dBegin = sdf.parse(beginTime); + Date dEnd = sdf.parse(endTime); + + //将格式化后的第一天添加进集合 + dates.add(sdf.format(dBegin)); + + //使用本地的时区和区域获取日历 + Calendar calBegin = Calendar.getInstance(); + + //传入起始时间将此日历设置为起始日历 + calBegin.setTime(dBegin); + + //判断结束日期前一天是否在起始日历的日期之后 + while (dEnd.after(calBegin.getTime())) { + + //根据日历的规则:月份中的每一天,为起始日历加一天 + calBegin.add(Calendar.DAY_OF_MONTH, 1); + + //得到的每一天就添加进集合 + dates.add(sdf.format(calBegin.getTime())); + //如果当前的起始日历超过结束日期后,就结束循环 + } + return dates; + } + + public String createHrToken() throws Exception{ + String accessToken=""; + OkHttpClient client = new OkHttpClient().newBuilder().build(); + String clientId =getSystemParamValue("eyhrclientId"); + String appId =getSystemParamValue("eyhrappId"); + String appSecret =getSystemParamValue("eyhrappSecret"); + String hrsynccreatetokenurl =getSystemParamValue("hrsynccreatetokenurl"); + String hrsyncaddress =getSystemParamValue("hrsyncaddress"); + Mapparams =new HashMap (); + params.put("clientId",clientId); + params.put("appId",appId); + params.put("appSecret",appSecret); + MediaType mediaType = MediaType.parse("application/json"); + RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(params)); + Request request = new Request.Builder() + .url(hrsyncaddress+hrsynccreatetokenurl) + .method("POST", body) + .addHeader("Content-Type", "application/json") + .build(); + Response response = client.newCall(request).execute(); + if (response.isSuccessful()) { + Result result = Result.success(Objects.requireNonNull(response.body()).string()); + if (result.isOk()) { + JSONObject data = JSON.parseObject(result.getContent()); + String code = Objects.requireNonNull(data).getString("code"); + String msg = Objects.requireNonNull(data).getString("msg"); + if(code.equals("0")){ + // 将组织机构数据封装至List + accessToken = Objects.requireNonNull(data).getJSONObject("data").getString("accessToken"); + //new BaseBean().writeLog("Token授权==>"+accessToken); + }else{ + //new BaseBean().writeLog("Token授权异常,code==>"+code+",msg==>"+msg); + } + } + } + //new BaseBean().writeLog("Token授权,accessToken==>"+accessToken); + return accessToken; + } + + public String createToken(String clientId,String appId,String appSecret,String address,String tokenurl) throws Exception{ + String accessToken=""; + OkHttpClient client = new OkHttpClient().newBuilder().build(); + Mapparams =new HashMap (); + params.put("clientId",clientId); + params.put("appId",appId); + params.put("appSecret",appSecret); + MediaType mediaType = MediaType.parse("application/json"); + RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(params)); + Request request = new Request.Builder() + .url(address+tokenurl) + .method("POST", body) + .addHeader("Content-Type", "application/json") + .build(); + Response response = client.newCall(request).execute(); + if (response.isSuccessful()) { + Result result = Result.success(Objects.requireNonNull(response.body()).string()); + if (result.isOk()) { + JSONObject data = JSON.parseObject(result.getContent()); + String code = Objects.requireNonNull(data).getString("code"); + String msg = Objects.requireNonNull(data).getString("msg"); + if(code.equals("0")){ + // 将组织机构数据封装至List + accessToken = Objects.requireNonNull(data).getJSONObject("data").getString("accessToken"); + //new BaseBean().writeLog("Token授权==>"+accessToken); + }else{ + //new BaseBean().writeLog("Token授权异常,code==>"+code+",msg==>"+msg); + } + } + } + //new BaseBean().writeLog("Token授权,accessToken==>"+accessToken); + return accessToken; + } + + /** + * 获取当前人所能看到所有数据 + */ + public String getEyCustomRigthSql(int userid,String tablename){ + String returnStr = " select id from "+tablename+" where "; + String matchsql ="select * from uf_stand_match_conf where tablename=?"; + RecordSet recordSet=new RecordSet(); + recordSet.executeQuery(matchsql,tablename); + if(recordSet.next()){ + try { + ResourceComInfo resourceComInfo=new ResourceComInfo(); + String workcode=resourceComInfo.getWorkcode(userid+"");//员工工号 + String currentroleids =getUserAllRole(userid);//获取当前人员所有角色id + String georegion_fieldname =Util.null2String(recordSet.getString("georegion_fieldname")); + String legalentity_fieldname =Util.null2String(recordSet.getString("legalentity_fieldname")); + String type_fieldname =Util.null2String(recordSet.getString("type_fieldname")); + String codeblock_fieldname =Util.null2String(recordSet.getString("codeblock_fieldname")); + String engagementcode_fieldname =Util.null2String(recordSet.getString("engagementcode_fieldname")); + //业务维度 + if(StringUtil.isNotBlank(codeblock_fieldname)){ + String codeblocksql = getEyCodeBlockRightSql(workcode,codeblock_fieldname); + if(StringUtil.isNotBlank(codeblocksql)){ + returnStr =returnStr+codeblocksql; + } + } + //3.1先查询中间匹配表-firm + //判断台账中间表是否配置完全 + if(StringUtil.isNotBlank(georegion_fieldname)&&StringUtil.isNotBlank(legalentity_fieldname)) { + String firmsql = getEyfirmRightSql(type_fieldname,georegion_fieldname, legalentity_fieldname, currentroleids); + if (StringUtil.isNotBlank(firmsql)) { + returnStr = returnStr + firmsql; + } + } + //3.2先查询中间匹配表-gds + if(StringUtil.isNotBlank(type_fieldname)) { + String typesql =getEyGdsRightSql(type_fieldname,currentroleids); + if(StringUtil.isNotBlank(typesql)){ + returnStr = returnStr + typesql; + } + } + writeLog("getEyCustomRigthSql,returnStr==>"+returnStr); + } catch (Exception e) { + e.printStackTrace(); + } + } + + return returnStr; + } + + /** + *业务维度权限 + */ + public String getEyCodeBlockRightSql(String workcode,String codeblock_fieldname){ + String result=""; + //1、项目卡片中所有成员 + String codeblocksql ="select codeblock from uf_xmjbxxjmbd where id in (" + + "select mainid from uf_xmjbxxjmbd_dt2 where role_gpn='"+workcode+"' " + + ")"; + //2、通过第三接口获取公司高层维护的codeblock + codeblocksql = codeblocksql +" union " + + " select codeblock from uf_permisson_conf_business where gpn='"+workcode+"' "; + result = " ( "+codeblock_fieldname+" in ("+codeblocksql+") ) or"; + writeLog("codeblocksql==>"+codeblocksql); + return result; + } + + /** + *FIRM财务维度权限 + */ + public String getEyfirmRightSql(String type_fieldname,String georegion_fieldname,String legalentity_fieldname,String currentroleids) { + String result=""; + RecordSet rs =new RecordSet(); + String firmrolesql =" select legalentity,georegion,roleids from uf_permissionconfig where isopen=0"; + rs.executeQuery(firmrolesql,new Object[0]); + List> firmmatchlist =new ArrayList >(); + while(rs.next()){ + String roleids =Util.null2String(rs.getString("roleids")); + String legalentity =Util.null2String(rs.getString("legalentity")); + String georegion =Util.null2String(rs.getString("georegion")); + //判断规则中间表是否配置完全 + if(!legalentity.equals("")&&!georegion.equals("")){ + String[] currentroleidarry =currentroleids.split(","); + //判断当前用户所有角色与规则表的角色是否匹配 + for(String roleid:currentroleidarry){ + if((","+roleid+",").indexOf(","+roleids+",")>=0){ + //legalentity和georegion封装 + HashMap rolematch =new HashMap (); + rolematch.put("legalentity",legalentity); + rolematch.put("georegion",georegion); + firmmatchlist.add(rolematch); + break; + } + } + } + } + //遍历legalentity和georegion封装的map 转换sql + if(firmmatchlist.size()>0){ + for(Map match:firmmatchlist){ + String type =Util.null2String(match.get("type")); + String legalentity =Util.null2String(match.get("legalentity")); + String georegion =Util.null2String(match.get("georegion")); + if(StringUtil.isNotBlank(type)){ + String firmsql =""; + String lesql = legalentity_fieldname + " in ("; + String geosql = georegion_fieldname + " in ("; + String[] typearry =type.split(","); + for(String t:typearry){ + firmsql =firmsql+type_fieldname+"='"+t+"' and"; + if(StringUtil.isNotBlank(legalentity)){ + String[] legalentityarry =legalentity.split(","); + for(String le:legalentityarry){ + lesql =lesql+"'"+le+"',"; + } + lesql=lesql.substring(0,lesql.length()-1)+")"; + firmsql =firmsql+lesql+" and"; + } + + if(StringUtil.isNotBlank(georegion)){ + String[] georegionarry =georegion.split(","); + for(String geo:georegionarry){ + geosql =geosql+"'"+geo+"',"; + } + geosql=geosql.substring(0,geosql.length()-1)+")"; + firmsql =firmsql+geosql+" and"; + } + } + result =result+"("+firmsql.substring(0,firmsql.length()-3)+")or"; + } + } + } + writeLog("result==>"+result); + return result; + } + + /** + *GDS财务维度权限 + */ + public String getEyGdsRightSql(String type_fieldname,String currentroleids){ + String result =""; + List> gdsmatchlist =new ArrayList >(); + RecordSet rs =new RecordSet(); + String gdsrolesql =" select type,legalentity,roleids from uf_permisson_conf_gds where isopen=0 "; + rs.executeQuery(gdsrolesql,new Object[0]); + while(rs.next()){ + String roleids =Util.null2String(rs.getString("roleids")); + String type =Util.null2String(rs.getString("type")); + if(!type.equals("")){ + String[] currentroleidarry =currentroleids.split(","); + //判断当前用户所有角色与规则表的角色是否匹配 + for(String roleid:currentroleidarry){ + if((","+roleid+",").indexOf(","+roleids+",")>=0){ + //legalentity和georegion封装 + HashMap rolematch =new HashMap (); + rolematch.put("type",type); + gdsmatchlist.add(rolematch); + break; + } + } + } + } + if(gdsmatchlist.size()>0){ + Set typeset =new HashSet(); + for(Map match:gdsmatchlist){ + String type =Util.null2String(match.get("type")); + String[] typearry =type.split(","); + for(String value:typearry){ + typeset.add(value); + } + } + for(String s:typeset){ + result =result + "("+type_fieldname+"='"+s+"') or"; + } + } + return result; + } + + public Map getConfidentialInfo(String opprCode,String paceFolderId,String clientId){ + Map result =new HashMap <>(); + String eventKey = "checkopportunitypaceandclient"; //事件标识 + Map body =new HashMap (); + Map params =new HashMap (); + List> reqdata =new ArrayList <>(); + params.put("opprCode",opprCode); + params.put("paceFolderId",paceFolderId); + params.put("clientId",clientId); + reqdata.add(params); + body.put("body",reqdata); + String paramsstr = JSON.toJSONString(body); //事件请求参数 + //EsbService其他方法及说明见ESB API接口说明文档 + EsbService service = EsbClient.getService(); //获取 ESB 服务 + String clientdetailjsonstr = service.execute(eventKey, paramsstr); + new BaseBean().writeLog("getConfidentialInfo,JsonStr==>"+clientdetailjsonstr); + if(StringUtils.isNotBlank(clientdetailjsonstr)){ + JSONObject jsonObject=JSON.parseObject(clientdetailjsonstr); + JSONArray resultdata =jsonObject.getJSONObject("data").getJSONArray("data"); + String errorStr =""; + String isConfidential ="1"; + for(int i=0;i0) { + for (int j = 0; j < opprsIsConfidential.size(); j++) { + String isConfidentialflag =Util.null2String(opprsIsConfidential.getJSONObject(j).getString("isConfidential")); + if (isConfidentialflag.equals("true")) { + isConfidential = "0"; + } + } + } + } + result.put("errorstr",errorStr); + result.put("isConfidential",isConfidential); + } + return result; + } + + public boolean getLegalEffective(String bucode,String oucode,String mucode,String smucode){ + boolean result =false; + String eventKey = "getLegalEffective"; //事件标识 + Map params =new HashMap (); + params.put("buCode",bucode); + params.put("ouCode",oucode); + params.put("muCode",mucode); + params.put("smuCode",smucode); + String paramsstr = JSON.toJSONString(params); //事件请求参数 + //EsbService其他方法及说明见ESB API接口说明文档 + EsbService service = EsbClient.getService(); //获取 ESB 服务 + String clientdetailjsonstr = service.execute(eventKey, paramsstr); + new BaseBean().writeLog("clientdetailjsonstr,getLegalEffective==>"+clientdetailjsonstr); + + if (StringUtils.isNotBlank(clientdetailjsonstr)) { + JSONObject jsonObject = JSON.parseObject(clientdetailjsonstr); + JSONObject resultdata = jsonObject.getJSONObject("data").getJSONObject("data"); + result = resultdata.getBoolean("isLegal"); + } + + return result; + } + + /** + * 获取预算信息 + * @param eventKey 事件key + * @param eventKey primaryKey + */ + public Map getBudgetInfo(String eventKey,String primaryKey){ + Map result =new HashMap <>(); + //事件标识 + Map params_mmt =new HashMap (); + params_mmt.put("PrimaryKey",primaryKey); + String paramsstr_mmt = JSON.toJSONString(params_mmt); //事件请求参数 + //EsbService其他方法及说明见ESB API接口说明文档 + EsbService service = EsbClient.getService(); //获取 ESB 服务 + String mmtdetailjsonstr = service.execute(eventKey, paramsstr_mmt); + new BaseBean().writeLog("getBudgetInfo===>"+mmtdetailjsonstr); + if(StringUtils.isNotBlank(mmtdetailjsonstr)){ + JSONObject jsonObject=JSON.parseObject(mmtdetailjsonstr); + if(jsonObject.getJSONObject("data").getJSONArray("list")!=null) { + JSONObject resultdata = jsonObject.getJSONObject("data").getJSONArray("list").getJSONObject(0); + if (eventKey.equals("smarthubbudgetdetail")) { + String startDate =Util.null2String(resultdata.getString("startDate")); + String closeDate =Util.null2String(resultdata.getString("closeDate")); + if(!startDate.equals("")){ + result.put("estimated_start_date", startDate.substring(0,10)); + }else{ + result.put("estimated_start_date", ""); + } + if(!closeDate.equals("")){ + result.put("estimated_close_date", closeDate.substring(0,10)); + }else{ + result.put("estimated_close_date", ""); + } + + } else { + result.put("estimated_start_date", formatDate(resultdata.getString("estimatedStartDate"))); + result.put("estimated_close_date", formatDate(resultdata.getString("estimatedEndDate"))); + } + if (eventKey.equals("smarthubbudgetdetail")) { + result.put("eaf", formatDouble(Util.null2String(resultdata.getString("eaf")))); + } else { + result.put("eaf", formatDouble(Util.null2String(resultdata.getString("engagementAdjustedFactor")))); + } + result.put("standard_engagement_revenue", resultdata.getString("ser")); + result.put("net_engagement_revenue", resultdata.getString("ner")); + if (eventKey.equals("smarthubbudgetdetail")) { + result.put("current_year_total_revenue", formatDouble(Util.null2String(resultdata.getString("ter")))); + } else { + result.put("current_year_total_revenue", Util.null2String(resultdata.getString("currentFyTer"))); + } + result.put("total_revenue", Util.null2String(resultdata.getString("ter"))); + if (eventKey.equals("smarthubbudgetdetail")) { + result.put("margin", "0.00"); + } else { + result.put("margin", formatDouble(Util.null2String(resultdata.getString("marginPercent")))); + } + if (eventKey.equals("smarthubbudgetdetail")) { + result.put("partner_involvement", formatDouble(Util.null2String(resultdata.getString("partnerInvolvement")))); + } else { + result.put("partner_involvement", formatDouble(Util.null2String(resultdata.getString("partnerLeverage")))); + } + result.put("erp1", formatDouble(Util.null2String(resultdata.getString("erp")))); + result.put("realization", formatDouble(Util.null2String(resultdata.getString("erp")))); + + String expenses =Util.null2String(resultdata.getString("totalExpense")); + if(expenses.equals("")){ + expenses ="0.00"; + } + result.put("expenses",expenses); + if (eventKey.equals("smarthubbudgetdetail")) { + result.put("margin1", "0.00"); + } else { + result.put("margin1", resultdata.getString("margin")); + } + if (eventKey.equals("smarthubbudgetdetail")) { + result.put("total_cost", "0.00"); + } else { + result.put("total_cost", Util.null2String(resultdata.getString("stdCost"))); + } + String hours =Util.null2String(resultdata.getString("totalHours")); + if(hours.equals("")){ + hours ="0.00"; + } + + result.put("hours",hours ); + } + new BaseBean().writeLog(JSON.toJSONString(result)); + } + return result; + } + + /** + * 获取客户信息 + * @param clientId 客户id + */ + public Map getCustomInfo(String clientId){ + Map result =new HashMap <>(); + String eventKey = "clientdetail"; //事件标识 + Map params =new HashMap (); + params.put("clientId",clientId); + String paramsstr = JSON.toJSONString(params); //事件请求参数 + //EsbService其他方法及说明见ESB API接口说明文档 + EsbService service = EsbClient.getService(); //获取 ESB 服务 + String clientdetailjsonstr = service.execute(eventKey, paramsstr); + + + String clientScope =""; + String chineseName =""; + new BaseBean().writeLog("clientdetailjsonstr,getCustomInfo==>"+clientdetailjsonstr); + if(StringUtils.isNotBlank(clientdetailjsonstr)){ + JSONObject jsonObject=JSON.parseObject(clientdetailjsonstr); + String returncode =jsonObject.getString("code"); + if(returncode.equals("100")){ + JSONObject resultdata =jsonObject.getJSONObject("data").getJSONObject("result"); + clientScope =Util.null2String(resultdata.getString("clientScope")); + //chineseName =Util.null2String(resultdata.getString("chineseName")); + chineseName =Util.null2String(resultdata.getString("englishName")); + result.put("client_name",chineseName); + if(clientScope.equals("100")){ + result.put("client_type","0"); + }else if (clientScope.equals("101")){ + result.put("client_type","1"); + }else if (clientScope.equals("102")){ + result.put("client_type","2"); + } + } + result.put("code",returncode); + }else{ + result.put("code","-1"); + result.put("client_name",""); + result.put("client_type",""); + } + new BaseBean().writeLog("getCustomInfo,returnmap==>"+JSON.toJSONString(result)); + return result; + } + + private static String formatDouble(String value){ + String result=""; + if(value.equals("")){ + result ="0.00"; + }else{ + BigDecimal bigDecimal =new BigDecimal(value); + result = bigDecimal.divide(new BigDecimal(100)).toString(); + + } + return result; + } + + private static String formatDate(String datestr){ + long time = Long.parseLong(datestr); + Date date = new Date(time); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + String str = dateFormat.format(date); + return str; + } + + public static boolean vaildateImportEnagementName(String engagementname,String global_service_code){ + boolean flag=false; + if(engagementname.equals("")||global_service_code.equals("")){ + return flag; + } + RecordSet recordSet1=new RecordSet(); + String perfix = engagementname.substring(0, 3); + recordSet1.executeQuery("select id from uf_mcgzb where global_service_code=? and mcgz=?",global_service_code,perfix); + if(recordSet1.next()){ + flag =true; + } + return flag; + } + + public static String removespace(String resource) + { + char ch=' '; + return remove(resource,ch); + } + + public static String remove(String resource,char ch) + { + StringBuffer buffer=new StringBuffer(); + int position=0; + char currentChar; + while(position getExchargeRate(BigDecimal decimal, String fromCurrency,String toCurrency,String codeblock, String a){ + RecordSet rs = new RecordSet(); + //rs.executeQuery(""); + return new HashMap<>(); + } + /** + * 校验用户是否存在 + * @param workcode + * @return + */ + public boolean validateUser(String workcode){ + RecordSet rs = new RecordSet(); + rs.executeQuery("select id from hrmresource where workcode=?,workcode"); + return rs.getCounts()>0; + } /** * 校验EM、EP rank * @param gpn @@ -40,12 +55,14 @@ public class EYSeconddevUtil extends BaseBean { if(rs.next()){ userId=Util.null2String(rs.getString(1)); } + writeLog("validateEngagementRoleRank>>>>gpn:"+gpn); // 查询rank String rank=""; rs.executeQuery("select concat(field2,field24) from cus_fielddata scope='HrmCustomFieldByInfoType' and scopeid=-1 and id=?",userId); if(rs.next()){ rank=Util.null2String(rs.getString(1)); } + writeLog("validateEngagementRoleRank>>>>rank:"+rank); // 校验rank rs.executeQuery("select id from uf_xmjsrankjyb where rankcode=? and mark=? and role=?",rank,mark,role); return rs.getCounts()>0; diff --git a/src/test/java/xuanran/wang/eny/ModelFieldAsyncTest.java b/src/test/java/xuanran/wang/eny/ModelFieldAsyncTest.java index cf1698c..1810c2f 100644 --- a/src/test/java/xuanran/wang/eny/ModelFieldAsyncTest.java +++ b/src/test/java/xuanran/wang/eny/ModelFieldAsyncTest.java @@ -9,6 +9,7 @@ import aiyh.utils.tool.org.apache.commons.jexl3.MapContext; import basetest.BaseTest; import com.alibaba.fastjson.JSONObject; import com.api.nonstandardext.model_field_async.entity.ModelFieldAsyncConfigClass; +import com.api.xuanran.wang.eny.workflow.mapper.ExchangeRateMapper; import org.apache.commons.lang3.StringUtils; import org.junit.Test; import com.api.nonstandardext.model_field_async.entity.ModelFieldAsyncConfig; @@ -89,6 +90,22 @@ public class ModelFieldAsyncTest extends BaseTest { return (T) response.get(split[len - 1]); } + private final ExchangeRateMapper mapper = Util.getMapper(ExchangeRateMapper.class); + @Test + public void testE(){ + String json ="{\"date\":\"2021-04-07\",\"interfaceCurrency\":\"CNY\",\"printParams\":1,\"fieldList\":[{\"field\":\"field11111\",\"money\":12920295.96}],\"baseCurrency\":\"1\"} "; + Map map = JSONObject.parseObject(json, Map.class); + List> fieldList = (List>) map.get("fieldList"); + System.out.println("list : " + fieldList); + for (Map objectMap : fieldList) { + double money = Util.getDoubleValue(Util.null2DefaultStr(objectMap.get("money"), ""), 0); + if(money == 0){ + break; + } + System.out.println("money : " + money); + } + } + } From 97325c17df0a7514ce65bc3c6a7ea4c3a57542fc Mon Sep 17 00:00:00 2001 From: "weilin.zhu" Date: Mon, 17 Jul 2023 18:26:35 +0800 Subject: [PATCH 8/8] =?UTF-8?q?ASC=20=E7=B2=BE=E5=93=81=E9=85=92=E4=B8=9A?= =?UTF-8?q?=20=E5=87=AD=E8=AF=81=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cssc/schedule/util/PushModeDataUtil.java | 19 +- .../zhu/asc/workflow/VoucherPushAction.java | 104 +++++ .../weilin/zhu/common/util/CommonUtil.java | 100 +++++ .../zhu/common/util/FieldDetailInfo.java | 42 ++ .../common/util/mapper/CommonSqlMapper.java | 42 ++ .../voucher/action/CommonVoucherAction.java | 230 ++++++++++ .../action/CusActionPostInterface.java | 22 + .../voucher/action/ResultMessageUtil.java | 32 ++ .../voucher/convert/CusAsyncConvert.java | 21 + .../convert/FieldChangeRuleMethod.java | 213 +++++++++ .../voucher/convert/RuleMethodParam.java | 43 ++ .../common/voucher/entity/BaseConfigDao.java | 60 +++ .../voucher/entity/NodeFieldMappingDao.java | 59 +++ .../voucher/entity/ObjectMappingDao.java | 43 ++ .../voucher/entity/VoucherConstants.java | 62 +++ .../voucher/mapper/CommVoucherSqlMapper.java | 143 ++++++ .../voucher/util/CommonVoucherUtil.java | 416 ++++++++++++++++++ .../sqlmapper/OrganizationSyncSqlMapper.java | 2 +- .../xyzq/scheduled/task/SyncOrgDataTask.java | 1 - .../common/action/RequestDataToApiAction.java | 2 +- .../common/action/RequestDataToApiAction.java | 2 +- 21 files changed, 1645 insertions(+), 13 deletions(-) create mode 100644 src/main/java/weaver/weilin/zhu/asc/workflow/VoucherPushAction.java create mode 100644 src/main/java/weaver/weilin/zhu/common/util/CommonUtil.java create mode 100644 src/main/java/weaver/weilin/zhu/common/util/FieldDetailInfo.java create mode 100644 src/main/java/weaver/weilin/zhu/common/util/mapper/CommonSqlMapper.java create mode 100644 src/main/java/weaver/weilin/zhu/common/voucher/action/CommonVoucherAction.java create mode 100644 src/main/java/weaver/weilin/zhu/common/voucher/action/CusActionPostInterface.java create mode 100644 src/main/java/weaver/weilin/zhu/common/voucher/action/ResultMessageUtil.java create mode 100644 src/main/java/weaver/weilin/zhu/common/voucher/convert/CusAsyncConvert.java create mode 100644 src/main/java/weaver/weilin/zhu/common/voucher/convert/FieldChangeRuleMethod.java create mode 100644 src/main/java/weaver/weilin/zhu/common/voucher/convert/RuleMethodParam.java create mode 100644 src/main/java/weaver/weilin/zhu/common/voucher/entity/BaseConfigDao.java create mode 100644 src/main/java/weaver/weilin/zhu/common/voucher/entity/NodeFieldMappingDao.java create mode 100644 src/main/java/weaver/weilin/zhu/common/voucher/entity/ObjectMappingDao.java create mode 100644 src/main/java/weaver/weilin/zhu/common/voucher/entity/VoucherConstants.java create mode 100644 src/main/java/weaver/weilin/zhu/common/voucher/mapper/CommVoucherSqlMapper.java create mode 100644 src/main/java/weaver/weilin/zhu/common/voucher/util/CommonVoucherUtil.java diff --git a/src/main/java/weaver/cssc/schedule/util/PushModeDataUtil.java b/src/main/java/weaver/cssc/schedule/util/PushModeDataUtil.java index 279df99..d9ee681 100644 --- a/src/main/java/weaver/cssc/schedule/util/PushModeDataUtil.java +++ b/src/main/java/weaver/cssc/schedule/util/PushModeDataUtil.java @@ -32,15 +32,7 @@ public class PushModeDataUtil { public Map getConfigurationByKeyId(String keyId){ Map configMap = sqlMapper.getPushDataConfiguration(keyId); - if(configMap != null && configMap.size() > 0){ - int mainKeyId = (int) configMap.get("id"); - - List> fieldList = sqlMapper.getPushDataDetailConfiguration(mainKeyId); - - configMap.put("fieldList",fieldList); - } - - return configMap; + return getConfiguration(configMap); } /** @@ -51,6 +43,15 @@ public class PushModeDataUtil { public Map getConfigurationByModeId(int modeId){ Map configMap = sqlMapper.getPushDataConfigurationByModeId(modeId); + return getConfiguration(configMap); + } + + /** + * 获取配置信息 + * @param configMap 配置信息结果 + * @return 返回配置信息 + */ + private Map getConfiguration(Map configMap) { if(configMap != null && configMap.size() > 0){ int mainKeyId = (int) configMap.get("id"); diff --git a/src/main/java/weaver/weilin/zhu/asc/workflow/VoucherPushAction.java b/src/main/java/weaver/weilin/zhu/asc/workflow/VoucherPushAction.java new file mode 100644 index 0000000..685b620 --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/asc/workflow/VoucherPushAction.java @@ -0,0 +1,104 @@ +package weaver.weilin.zhu.asc.workflow; + +import aiyh.utils.Util; +import aiyh.utils.httpUtil.HttpArgsType; +import aiyh.utils.httpUtil.ResponeVo; +import aiyh.utils.httpUtil.util.HttpUtils; +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import weaver.file.Prop; +import weaver.weilin.zhu.common.util.CommonUtil; +import weaver.weilin.zhu.common.voucher.action.CusActionPostInterface; +import weaver.weilin.zhu.common.voucher.action.ResultMessageUtil; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +/** + * ASC 精品酒店 + * JSON数据推送 NC 接口操作,通用凭证Action后置方法 + * @author bleach + * @version v1.0 2023-07-10 + */ +public class VoucherPushAction implements CusActionPostInterface { + + /** + * 日志操作类 + */ + private final Logger logger = Util.getLogger(); + + + + /** + * 后置处理方法 + * + * @param params 后置处理器参数 + * @return 处理后返回值 + */ + @SuppressWarnings("unchecked") + @Override + public ResultMessageUtil postProcessor(Map params) { + ResultMessageUtil resultMessageUtil = new ResultMessageUtil(); + + JSONObject postObj = (JSONObject) params.get("pushJsonObject"); + Map workflowBaseMap = (Map) params.get("workflowBaseMap"); + Map pathParam = (Map) params.get("pathParam"); + + + Map logMap = new HashMap<>(); + logMap.put("rid",workflowBaseMap.get("requestId")); + logMap.put("interface_name",Util.null2String(pathParam.get("pathParam"))); + logMap.put("system_name",Util.null2String(pathParam.get("system_name"))); + logMap.put("systemCode",Util.null2String(pathParam.get("systemCode"))); + + + //获取接口请求地址 + String requestURL = Util.null2String(Prop.getPropValue("AscVoucher", "url")); + + Map headerMap = new HashMap<>(); + headerMap.put("Content-Type", HttpArgsType.APPLICATION_JSON); + + HttpUtils httpUtils = new HttpUtils(); + + try { + //进行接口数据推送 + ResponeVo responeVo = httpUtils.apiPostObject(requestURL, postObj, headerMap); + + if(responeVo != null && responeVo.getCode() == 200){ + logMap.put("message",responeVo.getEntityString()); + + //接口返回所有信息 + resultMessageUtil.setResponseBody(responeVo.getEntityString()); + + Map resultMap = responeVo.getResponseMap(); + + if(resultMap != null){ + String state = Util.null2String(resultMap.get("state")); + + resultMessageUtil.setSuccess("1".equals(state)); + + logMap.put("result","1".equals(state) ? 0 : 1); + + } else { + logMap.put("result",1); + logMap.put("message","接口返回信息为空!"); + } + } else { + logMap.put("result",1); + logMap.put("message","接口返回信息为空或者请求失败!"); + } + } catch (IOException e) { + logger.error("接口请求异常,异常信息:[" + e.getMessage() + "]"); + logMap.put("result",1); + logMap.put("message","接口请求异常,异常信息:[" + e.getMessage() + "]!"); + throw new RuntimeException(e); + } + + int modeid = Util.getIntValue(Prop.getPropValue("global", "interfacelog_modeid")); + + CommonUtil.insertNewDataToMode(modeid,"uf_interface_log",logMap); + + return resultMessageUtil; + } +} diff --git a/src/main/java/weaver/weilin/zhu/common/util/CommonUtil.java b/src/main/java/weaver/weilin/zhu/common/util/CommonUtil.java new file mode 100644 index 0000000..df75aa8 --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/common/util/CommonUtil.java @@ -0,0 +1,100 @@ +package weaver.weilin.zhu.common.util; + +import aiyh.utils.Util; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.weilin.zhu.common.util.mapper.CommonSqlMapper; + +import java.util.Map; + +/** + * 通用的工具类型 + */ +public class CommonUtil { + + + /** + * 获取数据库操作接口 + */ + private static final CommonSqlMapper sqlMapper = Util.getMapper(CommonSqlMapper.class); + + /** + * 获取字段详细信息 + * @param fieldId 字段ID + * @return 字段详细信息 + */ + public static FieldDetailInfo getFieldDetailInfo(int fieldId){ + FieldDetailInfo fieldDetailInfo = new FieldDetailInfo(); + + if(fieldId != 0) { + RecordSet rs = new RecordSet(); + + String selectSQL = "select id,fieldName,viewType,detailTable,fieldDbType from workflow_billField where id = ?"; + + if (rs.executeQuery(selectSQL, fieldId) && rs.next()) { + //字段数据库名称 + String fieldName = Util.null2String(rs.getString("fieldName")); + //字段所属 + int viewType = Util.getIntValue(rs.getString("viewType"),0); + //字段明细表名称 + String detailTable = Util.null2String(rs.getString("detailTable")); + //字段数据库类型 + String fieldDbType = Util.null2String(rs.getString("fieldDbType")); + + + fieldDetailInfo.setId(fieldId); + fieldDetailInfo.setFieldName(fieldName); + fieldDetailInfo.setDetailTable(detailTable); + fieldDetailInfo.setDbType(fieldDbType); + + if(viewType == 1 && !"".equals(detailTable)){ + int detailIndex = Util.getIntValue(detailTable.substring(detailTable.indexOf("_dt") + 3),-1); + + fieldDetailInfo.setDetailIndex(detailIndex); + } else { + fieldDetailInfo.setDetailIndex(0); + } + } + } + + return fieldDetailInfo; + } + + + /** + * 根据模块表名称 获取其对应的模块ID (可以预见的BUG:若一个表被多个模块引用,则会出问题) + * @param modeTableName 模块表名称 + * @return 模块ID + */ + public static int getModeIdByTableName(String modeTableName) { + return sqlMapper.getModeIdByTableName(modeTableName); + } + + /** + * 往建模中写入新的记录 + * @param modeId 模块ID + * @param modeTableName 模块表名称 + * @param dataMap 数据集 + */ + public static void insertNewDataToMode(int modeId,String modeTableName, Map dataMap){ + //获取新的记录ID + int newDataId = Util.getModeDataId(modeTableName,modeId,1); + + if(newDataId > 0){ + StringBuilder updateSql = new StringBuilder(); + updateSql.append("update ").append(modeTableName).append(" set modeDataModifyDatetime = '").append(TimeUtil.getCurrentTimeString()).append("'"); + + for(String key : dataMap.keySet()){ + updateSql.append(",").append(key).append("=?"); + } + + updateSql.append(" where id = #{id}"); + + dataMap.put("id",newDataId); + + if(sqlMapper.insertModeData(updateSql.toString(),dataMap)){ + sqlMapper.deleteRedundancyData(modeTableName,newDataId); + } + } + } +} diff --git a/src/main/java/weaver/weilin/zhu/common/util/FieldDetailInfo.java b/src/main/java/weaver/weilin/zhu/common/util/FieldDetailInfo.java new file mode 100644 index 0000000..9437abd --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/common/util/FieldDetailInfo.java @@ -0,0 +1,42 @@ +package weaver.weilin.zhu.common.util; + +import lombok.Data; + +/** + * 字段详细信息实体类 + * @author bleach + * @version 2023-07-10 + */ +@Data +public class FieldDetailInfo { + + /** + * 字段ID + */ + private int id; + + /** + * 字段名称 + */ + private String fieldName; + + /** + * 字段所属 0-主表 1-明细表 + */ + private int viewType; + + /** + * 明细表名称 + */ + private String detailTable; + + /** + * 字段存储数据库类型 + */ + private String dbType; + + /** + * 所属明细表下标 + */ + private int detailIndex; +} diff --git a/src/main/java/weaver/weilin/zhu/common/util/mapper/CommonSqlMapper.java b/src/main/java/weaver/weilin/zhu/common/util/mapper/CommonSqlMapper.java new file mode 100644 index 0000000..750e8a8 --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/common/util/mapper/CommonSqlMapper.java @@ -0,0 +1,42 @@ +package weaver.weilin.zhu.common.util.mapper; + +import aiyh.utils.annotation.recordset.*; + +import java.util.Map; + +/** + * 通用工具类 操作数据库接口 + * @author bleach + * @version 2023-07-12 + */ +public interface CommonSqlMapper { + + /** + * 根据模块表名称 获取其对应的模块ID (可以预见的BUG:若一个表被多个模块引用,则会出问题) + * @param tableName 模块表名称 + * @return 模块ID + */ + @Select("select m.id from modeInfo m inner join workflow_bill wb on m.formId = wb.id where lower(wb.tableName) = #{tableName}") + int getModeIdByTableName(@ParamMapper("tableName") String tableName); + + + /** + * 更新建模数据 + * @param updateSql 更新的SQL语句 + * @param dataMap 数据集 + * @return 更新结果 + */ + @Update(custom = true) + boolean insertModeData(@SqlString String updateSql, Map dataMap); + + + + /** + * 删除建模数据 + * @param tableName 表单名称 + * @param dataId 数据ID + * @return 更新结果 + */ + @Delete("delete from $t{tableName} where id = #{dataId}") + boolean deleteRedundancyData(@ParamMapper("tableName") String tableName, @ParamMapper("dataId") int dataId); +} diff --git a/src/main/java/weaver/weilin/zhu/common/voucher/action/CommonVoucherAction.java b/src/main/java/weaver/weilin/zhu/common/voucher/action/CommonVoucherAction.java new file mode 100644 index 0000000..7c6c3b0 --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/common/voucher/action/CommonVoucherAction.java @@ -0,0 +1,230 @@ +package weaver.weilin.zhu.common.voucher.action; + +import aiyh.utils.Util; +import aiyh.utils.action.SafeCusBaseAction; +import aiyh.utils.annotation.ActionDefaultTestValue; +import aiyh.utils.annotation.PrintParamMark; +import aiyh.utils.annotation.RequiredMark; +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.hrm.User; +import weaver.soa.workflow.request.RequestInfo; +import weaver.weilin.zhu.common.voucher.entity.BaseConfigDao; +import weaver.weilin.zhu.common.voucher.util.CommonVoucherUtil; +import weaver.weilin.zhu.common.voucher.mapper.CommVoucherSqlMapper; +import weaver.zwl.common.ToolUtilNew; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.Map; + +/** + * 通用凭证Action入口 + * @author bleach + * @version 2023-07-10 + */ +public class CommonVoucherAction extends SafeCusBaseAction { + + /** + * 日志操作类 + */ + private final Logger logger = Util.getLogger(); + + /** + * SQL接口 + */ + private final CommVoucherSqlMapper sqlMapper = Util.getMapper(CommVoucherSqlMapper.class); + + /** + * 自定义参数值 + */ + private String cusParamValue; + + /** + * 后置实现类接口路径 + */ + @RequiredMark("具体接口请求实现接口类路径!") + @ActionDefaultTestValue("weaver.weilin.zhu.asc.workflow.VoucherPushAction") + @PrintParamMark + private String implementorPath; + + + + /** + *

action 提交流程业务处理方法

+ *

具体业务逻辑实现 + * 全局存在log成员变量,用于日志的输出 Util.actionFailException(requestManager,"error msg"); 用于提示action执行失败 + *

+ * + * @param requestId 流程请求ID + * @param billTable 流程对应主表名称 + * @param workflowId 流程对应流程ID + * @param user 当前节点操作者用户 + * @param requestInfo 请求管理对象 + */ + @Override + public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) { + logger.info("--------------- CommonVoucherAction Begin ---------------"); + + Map workflowBaseMap = getWorkflowBaseInfo(requestInfo.getRsTrans(),requestId); + + CommonVoucherUtil voucherUtil = new CommonVoucherUtil(); + + voucherUtil.setWorkflowBaseMap(workflowBaseMap); + + //自定义配置 + BaseConfigDao baseConfigDao = voucherUtil.getConfigurationByWorkflowId(String.valueOf(workflowId), cusParamValue); + + assert baseConfigDao != null; + + voucherUtil.setThisUser(user); + voucherUtil.setObjectMappingDaoList(baseConfigDao.getObjectMappingDaoList()); + voucherUtil.setNodeFieldMappingDaoList(baseConfigDao.getNodeFieldMappingDaoList()); + + RecordSet rs ; + + String dataCondition = baseConfigDao.getDataCondition(); + + if(StringUtils.isNotBlank(dataCondition)){ + rs = sqlMapper.getWorkflowMainTableInfoAndCondition(billTable,requestId, ToolUtilNew.staticToDBC(dataCondition)); + } else { + rs = sqlMapper.getWorkflowMainTableInfo(billTable,requestId); + } + + if(!rs.next()){ + logger.info("当前流程不满足自定义条件!"); + } + + workflowBaseMap.put("mainId",Util.null2String(rs.getString("id"))); + + //推送的报文 + JSONObject postJsonObj = new JSONObject(); + + StringBuilder postXmlObj = new StringBuilder(); + + if(baseConfigDao.getDataFormat() == 1){ + postXmlObj = voucherUtil.recursionGenerateXML("",null,null,0,0,0); + } else { + //推送的报文 + postJsonObj = voucherUtil.recursionGenerateJsonObject("",null,null,0,0,0); + } + + if(postJsonObj != null || postXmlObj.length() > 0){ + + if(StringUtils.isNotBlank(implementorPath)){ + Map pathParam = Util.parseCusInterfacePathParam(implementorPath); + String className = pathParam.remove("_ClassPath"); + + Map paramsMap = new HashMap<>(); + paramsMap.put("pushJsonObject",postJsonObj); + paramsMap.put("pushXmlObject",postXmlObj); + paramsMap.put("pathParam",pathParam); + paramsMap.put("requestInfo",requestInfo); + paramsMap.put("workflowBaseMap",workflowBaseMap); + paramsMap.put("userInfo",user); + + ResultMessageUtil resultMessageUtil = executePostProcessor(className,paramsMap); + + if(resultMessageUtil.isSuccess()){ + String backFieldname = baseConfigDao.getBackFieldname(); + + String backFieldValue = resultMessageUtil.getBackFieldValue(); + + sqlMapper.resultBackToWorkflowBill(billTable,backFieldname,backFieldValue,requestId); + } else { + //获取失败的错误提示 + String tipMessage = resultMessageUtil.getTipMessage(); + + if(baseConfigDao.getExceptionContinue() == 0){ + //阻止流程提交 + Util.actionFail(requestInfo.getRequestManager(),tipMessage); + } + } + } + } + + logger.info("--------------- CommonVoucherAction End ---------------"); + } + + /** + * 获取流程基础信息 + * @param trans 当前事务 + * @param requestId 流程请求ID + * @return 当前流程信息 + */ + private Map getWorkflowBaseInfo(RecordSetTrans trans,String requestId){ + Map baseInfo = new HashMap<>(); + + if(trans == null){ + trans = new RecordSetTrans(); + } + + String selectSQL = "select requestName,requestMark from workflow_requestBase where requestId = ?"; + + try { + if(trans.executeQuery(selectSQL,requestId) && trans.next()){ + baseInfo.put("requestName",Util.null2String(trans.getString(1))); + baseInfo.put("requestMark",Util.null2String(trans.getString(2))); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + + return baseInfo; + } + + + /** + * 执行自定义后置处理方法 + * + * @param className 全路径类名 + * @param params 参数 + * @return 返回值 + */ + private ResultMessageUtil executePostProcessor(String className, Map params) { + Class aClass; + try { + aClass = Class.forName(className); + } catch (ClassNotFoundException e) { + throw new IllegalArgumentException("未能找到自定义action接口处理方法:" + className); + } + Constructor constructor; + try { + constructor = aClass.getConstructor(); + } catch (NoSuchMethodException e) { + throw new IllegalArgumentException(className + "没有空参构造方法,无法获取构造方法对象!"); + } + if (!CusActionPostInterface.class.isAssignableFrom(aClass)) { + throw new IllegalArgumentException("自定义后置处理接口:" + className + " 不是" + + CusActionPostInterface.class.getName() + "的子类或实现类!"); + } + CusActionPostInterface o; + try { + o = (CusActionPostInterface) constructor.newInstance(); + } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { + throw new IllegalArgumentException("无法构造" + className + "对象!"); + } + return o.postProcessor(params); + } + + + public String getCusParamValue() { + return cusParamValue; + } + + public void setCusParamValue(String cusParamValue) { + this.cusParamValue = cusParamValue; + } + + public String getImplementorPath() { + return implementorPath; + } + + public void setImplementorPath(String implementorPath) { + this.implementorPath = implementorPath; + } +} diff --git a/src/main/java/weaver/weilin/zhu/common/voucher/action/CusActionPostInterface.java b/src/main/java/weaver/weilin/zhu/common/voucher/action/CusActionPostInterface.java new file mode 100644 index 0000000..762cdeb --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/common/voucher/action/CusActionPostInterface.java @@ -0,0 +1,22 @@ +package weaver.weilin.zhu.common.voucher.action; + +import java.util.Map; + +/** + * 自定义接口操作 + * 通过配置动态生成了JSONObject或者XML信息 + * 该接口中拿到对应的信息进行后续操作 + * + * @author bleach + */ + +public interface CusActionPostInterface { + + /** + * 后置处理方法 + * + * @param params 后置处理器参数 + * @return 处理后返回值 + */ + ResultMessageUtil postProcessor(Map params); +} diff --git a/src/main/java/weaver/weilin/zhu/common/voucher/action/ResultMessageUtil.java b/src/main/java/weaver/weilin/zhu/common/voucher/action/ResultMessageUtil.java new file mode 100644 index 0000000..6d7f7dd --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/common/voucher/action/ResultMessageUtil.java @@ -0,0 +1,32 @@ +package weaver.weilin.zhu.common.voucher.action; + +import lombok.Data; + +/** + * 自定义接口操作 + * 返回信息实体类 + */ +@Data +public class ResultMessageUtil { + + /** + * 是否调用成功 + */ + private boolean isSuccess; + + /** + * 提示消息说明 + */ + private String tipMessage; + + /** + * 接口返回信息 + */ + private String responseBody; + + /** + * 回写的字段值 + */ + private String backFieldValue; + +} diff --git a/src/main/java/weaver/weilin/zhu/common/voucher/convert/CusAsyncConvert.java b/src/main/java/weaver/weilin/zhu/common/voucher/convert/CusAsyncConvert.java new file mode 100644 index 0000000..99aa139 --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/common/voucher/convert/CusAsyncConvert.java @@ -0,0 +1,21 @@ +package weaver.weilin.zhu.common.voucher.convert; + + +import weaver.weilin.zhu.common.voucher.entity.NodeFieldMappingDao; + +import java.util.Map; + +/** + * 自定义转换规则接口 + * @author bleach + */ +public interface CusAsyncConvert { + /** + * 自定义转换接口 + * @param dao 配置信息 + * @param param 自定义转换规则参数 + * @param pathParam 自定义接口路径 + * @return 转换后的值 + */ + String cusConvert(NodeFieldMappingDao dao, RuleMethodParam param, Map pathParam); +} diff --git a/src/main/java/weaver/weilin/zhu/common/voucher/convert/FieldChangeRuleMethod.java b/src/main/java/weaver/weilin/zhu/common/voucher/convert/FieldChangeRuleMethod.java new file mode 100644 index 0000000..15a6b83 --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/common/voucher/convert/FieldChangeRuleMethod.java @@ -0,0 +1,213 @@ +package weaver.weilin.zhu.common.voucher.convert; + +import aiyh.utils.Util; +import aiyh.utils.annotation.MethodRuleNo; +import aiyh.utils.excention.CustomerException; +import com.google.common.base.Strings; +import org.apache.commons.lang3.StringUtils; +import weaver.general.TimeUtil; +import weaver.weilin.zhu.common.util.FieldDetailInfo; +import weaver.weilin.zhu.common.voucher.entity.NodeFieldMappingDao; +import weaver.zwl.common.ToolUtilNew; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; +import java.util.function.BiFunction; + +/** + * 流程字段转换规则处理 + * @author bleach + * @version 2023-07-04 + */ +public class FieldChangeRuleMethod { + + public static final Map> VALUE_RULE_FUNCTION = new HashMap<>(); + + static { + Class valueRuleMethodClass = FieldChangeRuleMethod.class; + Method[] methods = valueRuleMethodClass.getMethods(); + for (Method method : methods) { + if (method.isAnnotationPresent(MethodRuleNo.class)) { + MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class); + int value = annotation.value();//规则标识 + VALUE_RULE_FUNCTION.put(value, (config, map) -> { + try { + FieldChangeRuleMethod valueRuleMethod = new FieldChangeRuleMethod(); + return method.invoke(valueRuleMethod, config, map).toString(); + } catch (IllegalAccessException | InvocationTargetException e) { + throw new RuntimeException(e); + } + }); + } + } + } + + + /** + * 不转换 + * @param dao 流程字段配置信息 + * @param param 转换规则参数集合 + * @return 返回转换后的值 + */ + @MethodRuleNo(value = 0, desc = "不转换") + public String noChange(NodeFieldMappingDao dao, RuleMethodParam param) { + String fieldValue = ""; + FieldDetailInfo fieldInfo = dao.getWfField(); + + if(fieldInfo != null){ + String fieldName = fieldInfo.getFieldName();//字段名称 + + if(StringUtils.isNotBlank(fieldName)){ + int viewType = fieldInfo.getViewType(); + + if(viewType == 0){ + fieldValue = Util.null2String(param.getRs().getString(fieldName)); + } else if(viewType == 1 && param.getRs_detail() != null){ + fieldValue = Util.null2String(param.getRs_detail().getString(fieldName)); + } + + } + } + return fieldValue; + } + + /** + * 流程请求ID + * @param dao 明细配置 + * @param param 转换规则参数集合 + * @return 返回转换后的值 + */ + @MethodRuleNo(value = 1, desc = "流程请求ID") + public String workflowRequestId(NodeFieldMappingDao dao,RuleMethodParam param) { + return Util.null2String(param.getWorkflowBaseMap().get("requestId")); + } + + /** + * 流程请求标题 + * @param dao 明细配置 + * @param param 转换规则参数集合 + * @return 返回转换后的值 + */ + @MethodRuleNo(value = 2, desc = "流程请求标题") + public String workflowRequestTitle(NodeFieldMappingDao dao,RuleMethodParam param) { + return Util.null2String(param.getWorkflowBaseMap().get("requestName")); + } + + /** + * 流程请求编号 + * @param dao 明细配置 + * @param param 转换规则参数集合 + * @return 返回转换后的值 + */ + @MethodRuleNo(value = 3, desc = "流程请求编号") + public String workflowRequestMark(NodeFieldMappingDao dao,RuleMethodParam param) { + return Util.null2String(param.getWorkflowBaseMap().get("requestMark")); + } + + /** + * 系统日期 + * @param dao 明细配置 + * @param param 转换规则参数集合 + * @return 返回转换后的值 + */ + @MethodRuleNo(value = 4, desc = "系统日期") + public String systemDate(NodeFieldMappingDao dao,RuleMethodParam param) { + return TimeUtil.getCurrentDateString(); + } + + /** + * 系统日期时间 + * @param dao 明细配置 + * @param param 转换规则参数集合 + * @return 返回转换后的值 + */ + @MethodRuleNo(value = 5, desc = "系统日期时间") + public String systemDateTime(NodeFieldMappingDao dao,RuleMethodParam param) { + return TimeUtil.getCurrentTimeString(); + } + + /** + * 固定值 + * @param dao 明细配置 + * @param param 转换规则参数集合 + * @return 返回转换后的值 + */ + @MethodRuleNo(value = 6, desc = "固定值") + public String fixValue(NodeFieldMappingDao dao,RuleMethodParam param) { + return Util.null2String(dao.getCusSQL()); + } + + /** + * 明细序列 + * @param dao 明细配置 + * @param param 转换规则参数集合 + * @return 返回转换后的值 + */ + @MethodRuleNo(value = 7, desc = "明细序列") + public String getDetailRowNum(NodeFieldMappingDao dao,RuleMethodParam param) { + return Util.null2String(param.getRowNum()); + } + + + /** + * 自定义SQL转换 + * @param dao 明细配置 + * @param param 转换规则参数集合 + * @return 返回转换后的值 + */ + @MethodRuleNo(value = 8, desc = "自定义SQL") + public String customizeSQL(NodeFieldMappingDao dao,RuleMethodParam param) { + String fieldName = dao.getNodeName();//字段名称 + + //字段值 + String fieldValue = noChange(dao,param); + + String cusSQL = dao.getCusSQL(); + + int detailKeyId = -1; + if(StringUtils.isNotBlank(cusSQL)){ + if( cusSQL.contains("{dt.id}") && param.getRs_detail() != null) { + detailKeyId = Util.getIntValue(param.getRs_detail().getString("id"), -1); + } + + if(param.getThisUser() != null){ + cusSQL = cusSQL.replace("{userId}", String.valueOf(param.getThisUser().getUID())); + + cusSQL = cusSQL.replace("{departmentId}", String.valueOf(param.getThisUser().getUserDepartment())); + + cusSQL = cusSQL.replace("{subCompanyId}", String.valueOf(param.getThisUser().getUserSubCompany1())); + } + } + + fieldValue = ToolUtilNew.getStaticValueByChangeRule(cusSQL,fieldValue,Util.null2String(param.getWorkflowBaseMap().get("requestId")),detailKeyId); + + return fieldValue; + } + + /** + * 自定义转换接口 + * @param dao 明细配置 + * @param param 转换规则参数集合 + * @return 返回转换后的值 + */ + @MethodRuleNo(value = 9, desc = "自定义接口") + public String getCusConvertInterface(NodeFieldMappingDao dao, RuleMethodParam param) { + String cusText = dao.getCusSQL(); + if(Strings.isNullOrEmpty(cusText)){ + return null; + } + try { + Class clazz = Class.forName(cusText); + if(!CusAsyncConvert.class.isAssignableFrom(clazz)){ + throw new CustomerException(cusText + " 接口不存在或者未实现 weaver.weilin.zhu.common.voucher.convert.CusAsyncConvert类!"); + } + CusAsyncConvert o = (CusAsyncConvert) clazz.newInstance(); + Map pathParam = Util.parseCusInterfacePathParam(cusText); + return o.cusConvert(dao, param, pathParam); + }catch (Exception e){ + return null; + } + } +} diff --git a/src/main/java/weaver/weilin/zhu/common/voucher/convert/RuleMethodParam.java b/src/main/java/weaver/weilin/zhu/common/voucher/convert/RuleMethodParam.java new file mode 100644 index 0000000..f75a93a --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/common/voucher/convert/RuleMethodParam.java @@ -0,0 +1,43 @@ +package weaver.weilin.zhu.common.voucher.convert; + +import lombok.Getter; +import lombok.Setter; +import weaver.conn.RecordSet; +import weaver.hrm.User; + +import java.util.Map; + +/** + * 转换规则方法需要的参数类 + * @author bleach + * @version 2023-07-04 + */ +@Getter +@Setter +public class RuleMethodParam { + /** + * 流程主表数据集 + */ + private RecordSet rs ; + + /** + * 流程明细表某一行数据集 + */ + private RecordSet rs_detail; + + /** + * 流程基础信息数组 + */ + private Map workflowBaseMap; + + /** + * 明细序列 + */ + private int rowNum; + + /** + * 当前用户 + */ + private User thisUser; + +} diff --git a/src/main/java/weaver/weilin/zhu/common/voucher/entity/BaseConfigDao.java b/src/main/java/weaver/weilin/zhu/common/voucher/entity/BaseConfigDao.java new file mode 100644 index 0000000..045b90e --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/common/voucher/entity/BaseConfigDao.java @@ -0,0 +1,60 @@ +package weaver.weilin.zhu.common.voucher.entity; + +import lombok.Data; + +import java.util.List; + +/** + * 凭证通用功能 + * 基础配置 + * @author bleach + * @version 2023-07-10 + */ +@Data +public class BaseConfigDao { + + /** + * 配置ID + */ + private int id; + + /** + * 流程类型ID + */ + private String workflowId; + + /** + * 自定义参数值 + */ + private String cusParamValue; + + /** + * 数据条件 + */ + private String dataCondition; + + /** + * 异常是否继续 + */ + private int exceptionContinue; + + /** + * 数据格式 0-JSON 1-XML + */ + private int dataFormat; + + /** + * 回写字段名称 + */ + private String backFieldname; + + /** + * 对象与流程明细映射关系配置 + */ + private List objectMappingDaoList; + + /** + * 节点与流程字段详细配置 + */ + private List nodeFieldMappingDaoList; +} diff --git a/src/main/java/weaver/weilin/zhu/common/voucher/entity/NodeFieldMappingDao.java b/src/main/java/weaver/weilin/zhu/common/voucher/entity/NodeFieldMappingDao.java new file mode 100644 index 0000000..41b246c --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/common/voucher/entity/NodeFieldMappingDao.java @@ -0,0 +1,59 @@ +package weaver.weilin.zhu.common.voucher.entity; + +import lombok.Data; +import weaver.weilin.zhu.common.util.FieldDetailInfo; + +/** + * 凭证通用功能 + * 节点与流程字段配置详细 + * @author bleach + * @version 2023-07-10 + */ +@Data +public class NodeFieldMappingDao { + + /** + * 配置的数据ID + */ + private int id; + + /** + * 节点名称 + */ + private String nodeName; + + /** + * 父节点名称 + */ + private String parentNode; + + /** + * 节点类型 0-普通文本 1-普通对象 2-数组文本 3-数组对象 + */ + private int nodeType; + + /** + * 流程字段信息 + */ + private FieldDetailInfo wfField; + + /** + * 借贷方向 + */ + private String entriesDirection; + + /** + * 转换规则 + */ + private int changeRule; + + /** + * 自定义规则 + */ + private String cusSQL; + + /** + * 特殊属性 0-普通字段 1-金额控制字段 2-科目字段 + */ + private int specialAttr; +} diff --git a/src/main/java/weaver/weilin/zhu/common/voucher/entity/ObjectMappingDao.java b/src/main/java/weaver/weilin/zhu/common/voucher/entity/ObjectMappingDao.java new file mode 100644 index 0000000..2c4db1f --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/common/voucher/entity/ObjectMappingDao.java @@ -0,0 +1,43 @@ +package weaver.weilin.zhu.common.voucher.entity; + +import lombok.Data; + +/** + * 凭证通用功能 + * 对象与流程明细映射关系配置 + * @author bleach + * @version 2023-07-10 + */ +@Data +public class ObjectMappingDao { + + /** + * 数据ID + */ + private int id; + + /** + * 对象名称 + */ + private String objectName; + + /** + * 流程明细 + */ + private int dtIndex; + + /** + * 别名 + */ + private String alias; + + /** + * 借贷方向 + */ + private String entriesDirection; + + /** + * 数据条件 + */ + private String dtCondition; +} diff --git a/src/main/java/weaver/weilin/zhu/common/voucher/entity/VoucherConstants.java b/src/main/java/weaver/weilin/zhu/common/voucher/entity/VoucherConstants.java new file mode 100644 index 0000000..2521903 --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/common/voucher/entity/VoucherConstants.java @@ -0,0 +1,62 @@ +package weaver.weilin.zhu.common.voucher.entity; + +/** + * 凭证通过功能 + * 常量配置 + */ +public class VoucherConstants { + + + /** + * 借贷方向 - 非凭证分录 + */ + public static final int EntriesDirection_NoVoucher = 0; + + /** + * 借贷方向 - 普通借方 + */ + public static final int EntriesDirection_Comm_Debit = 1; + + + /** + * 借贷方向 - 税额借方 + */ + public static final int EntriesDirection_Tax_Debit = 2; + + + + /** + * 借贷方向 - 普通贷方 + */ + public static final int EntriesDirection_Comm_Credit = 3; + + + /** + * 借贷方向 - 冲销贷方 + */ + public static final int EntriesDirection_WriteOff_Credit = 4; + + + /** + * 节点类型 - 普通文本 + */ + public static final int Node_Type_Comm_Text = 0; + + + /** + * 节点类型 - 普通对象 + */ + public static final int Node_Type_Comm_Object = 1; + + + /** + * 节点类型 - 数组文本 + */ + public static final int Node_Type_Array_Text = 2; + + + /** + * 节点类型 - 数组对象 + */ + public static final int Node_Type_Array_Object = 3; +} diff --git a/src/main/java/weaver/weilin/zhu/common/voucher/mapper/CommVoucherSqlMapper.java b/src/main/java/weaver/weilin/zhu/common/voucher/mapper/CommVoucherSqlMapper.java new file mode 100644 index 0000000..ce813f9 --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/common/voucher/mapper/CommVoucherSqlMapper.java @@ -0,0 +1,143 @@ +package weaver.weilin.zhu.common.voucher.mapper; + +import aiyh.utils.annotation.recordset.*; +import weaver.conn.RecordSet; +import weaver.weilin.zhu.common.voucher.entity.BaseConfigDao; +import weaver.weilin.zhu.common.voucher.entity.NodeFieldMappingDao; +import weaver.weilin.zhu.common.voucher.entity.ObjectMappingDao; + +import java.util.List; + +/** + * 凭证通用功能 + * 凭证相关数据操作接口 + * @author bleach + */ +@SqlMapper +public interface CommVoucherSqlMapper { + + /** + * 根据流程类型ID获取其对应的配置信息 + * @param workflowIds 流程类型ID + * @return 配置信息 + */ + @Select("select * from uf_comm_voucher where wfId in ($t{workflowIds})") + @CollectionMappings({ + @CollectionMapping( + property = "objectMappingDaoList", + column = "id", + id = @Id(value = Integer.class, methodId = 1) + ), + @CollectionMapping( + property = "nodeFieldMappingDaoList", + column = "id", + id = @Id(value = Integer.class,methodId = 2) + ) + }) + BaseConfigDao getConfigurationByWorkflowId(@ParamMapper("workflowIds") String workflowIds); + + + + /** + * 根据流程类型ID获取其对应的配置信息 + * @param workflowIds 流程类型ID + * @return 配置信息 + */ + @Select("select * from uf_comm_voucher where wfId in ($t{workflowIds}) and cusParamValue = #{cusParamValue}") + @CollectionMappings({ + @CollectionMapping( + property = "objectMappingDaoList", + column = "id", + id = @Id(value = Integer.class, methodId = 1) + ), + @CollectionMapping( + property = "nodeFieldMappingDaoList", + column = "id", + id = @Id(value = Integer.class,methodId = 2) + ) + }) + BaseConfigDao getConfigurationByWorkflowIdAndCondition(@ParamMapper("workflowIds") String workflowIds,@ParamMapper("cusParamValue") String cusParamValue); + + + + /** + * 获取对象与流程明细表映射配置信息 + * @param mainId 主表主键ID + * @return 映射详细信息 + */ + @Select("select * from uf_comm_voucher_dt1 where mainId = #{mainId}") + @CollectionMethod(value = 1,desc = "获取对象与流程明细表映射配置信息") + List getObjectMappingByMainKeyId(@ParamMapper("mainId") int mainId); + + + + /** + * 获取对象与流程明细表映射配置信息 + * @param mainId 主表主键ID + * @return 映射详细信息 + */ + @Select("select * from uf_comm_voucher_dt2 where mainId = #{mainId}") + @Associations({ + @Association( + property = "wfField", + column = "wfField", + select = "weaver.weilin.zhu.common.util.CommonUtil.getFieldDetailInfo", + id = @Id(Integer.class) + ) + }) + @CaseConversion(value = false) + @CollectionMethod(value = 2,desc = "获取节点名称与字段详细配置信息") + List getNodeFieldMappingByMainKeyId(@ParamMapper("mainId") int mainId); + + + + /** + * 查询流程主表的信息 + * @param billTableMain 明细表名称 + * @param requestId 流程请求D值 + * @return 查询结果数据集 + */ + @Select("select * from $t{billTableMain} where requestId = #{requestId}") + RecordSet getWorkflowMainTableInfo(@ParamMapper("billTableMain") String billTableMain,@ParamMapper("requestId") String requestId); + + + /** + * 查询流程主表的信息 + * @param billTableMain 明细表名称 + * @param requestId 流程请求D值 + * @return 查询结果数据集 + */ + @Select("select * from $t{billTableMain} where requestId = #{requestId} and $t{condition}") + RecordSet getWorkflowMainTableInfoAndCondition(@ParamMapper("billTableMain") String billTableMain,@ParamMapper("requestId") String requestId,@ParamMapper("condition") String condition); + + + + /** + * 查询流程某个明细表的信息 + * @param detailTableName 明细表名称 + * @param mainId 流程主表主键ID值 + * @return 查询结果数据集 + */ + @Select("select * from $t{detailTableName} where mainId = #{mainId}") + RecordSet getWorkflowDetailTableInfo(@ParamMapper("detailTableName") String detailTableName,@ParamMapper("mainId") String mainId); + + + /** + * 查询流程某个明细表的信息 + * @param detailTableName 明细表名称 + * @param mainId 流程主表主键ID值 + * @return 查询结果数据集 + */ + @Select("select * from $t{detailTableName} where mainId = #{mainId} and $t{condition}") + RecordSet getWorkflowDetailTableInfoAndCondition(@ParamMapper("detailTableName") String detailTableName,@ParamMapper("mainId") String mainId,@ParamMapper("condition") String condition); + + /** + * 更新流程表单字段信息 + * @param billTable 表单名称 + * @param backFieldName 回写字段名称 + * @param backFieldValue 回写字段值 + * @param requestId 流程请求ID + */ + @Update("update $t{billTable} set $t{backFieldName} = #{backFieldValue} where requestId = #{requestId}") + void resultBackToWorkflowBill(@ParamMapper("billTable") String billTable,@ParamMapper("backFieldName") String backFieldName,@ParamMapper("backFieldValue") String backFieldValue,@ParamMapper("requestId") String requestId); +} diff --git a/src/main/java/weaver/weilin/zhu/common/voucher/util/CommonVoucherUtil.java b/src/main/java/weaver/weilin/zhu/common/voucher/util/CommonVoucherUtil.java new file mode 100644 index 0000000..190076d --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/common/voucher/util/CommonVoucherUtil.java @@ -0,0 +1,416 @@ +package weaver.weilin.zhu.common.voucher.util; + +import aiyh.utils.Util; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.hrm.User; +import weaver.weilin.zhu.common.util.FieldDetailInfo; +import weaver.weilin.zhu.common.voucher.convert.FieldChangeRuleMethod; +import weaver.weilin.zhu.common.voucher.convert.RuleMethodParam; +import weaver.weilin.zhu.common.voucher.entity.BaseConfigDao; +import weaver.weilin.zhu.common.voucher.entity.NodeFieldMappingDao; +import weaver.weilin.zhu.common.voucher.entity.ObjectMappingDao; +import weaver.weilin.zhu.common.voucher.mapper.CommVoucherSqlMapper; +import weaver.workflow.workflow.WorkflowVersion; +import weaver.weilin.zhu.common.voucher.entity.VoucherConstants; +import weaver.zwl.common.ToolUtilNew; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 凭证通用功能 + * 凭证操作工具类 + * @author bleach + * @version 2023-07-10 + */ +public class CommonVoucherUtil { + + /** + * 数据操作接口 + */ + private final CommVoucherSqlMapper sqlMapper = Util.getMapper(CommVoucherSqlMapper.class); + + + /** + * 流程基础信息 + */ + private Map workflowBaseMap; + + /** + * 当前用户 + */ + private User thisUser; + + /** + * 对象与流程明细映射关系配置集合 + */ + private List objectMappingDaoList; + + /** + * 节点与流程字段配置集合 + */ + private List nodeFieldMappingDaoList; + + public CommonVoucherUtil() { + } + + /** + * 根据流程类型ID和自定义参数值,获取其对应的配置信息 + * @param workflowId 流程类型ID + * @param cusParamValue 自定义参数值 + * @return 配置信息 + */ + public BaseConfigDao getConfigurationByWorkflowId(String workflowId,String cusParamValue){ + BaseConfigDao dao = new BaseConfigDao(); + + //获取该流程类型对应的所有版本ID + String allWorkflowIds = WorkflowVersion.getAllVersionStringByWFIDs(workflowId); + + if(StringUtils.isNotBlank(cusParamValue)){ + dao = sqlMapper.getConfigurationByWorkflowIdAndCondition(allWorkflowIds,cusParamValue); + } else { + dao = sqlMapper.getConfigurationByWorkflowId(allWorkflowIds); + } + + return dao; + } + + /** + * 递归生成JSON对象 + * @param parentNode 父节点名称 + * @param rs 流程主表数据集 + * @param rs_detail 流程某个明细表某行数据集 + * @param dtIndex 明细序列 + * @param itemDirection 借贷方向 + * @param rowNum 明细序号 + * @return JSON对象 + */ + public JSONObject recursionGenerateJsonObject(String parentNode, RecordSet rs,RecordSet rs_detail, int dtIndex, int itemDirection,int rowNum){ + JSONObject jsonObject = new JSONObject(); + + for(NodeFieldMappingDao nodeFieldMappingDao : nodeFieldMappingDaoList){ + //节点名称 + String _nodeName = nodeFieldMappingDao.getNodeName(); + + if(StringUtils.isBlank(_nodeName)){ + continue; + } + + /* 父节点名称 */ + String _parentNode = nodeFieldMappingDao.getParentNode(); + + if(!_parentNode.equals(parentNode)){ + continue; + } + + int _nodeType = nodeFieldMappingDao.getNodeType(); + + if(itemDirection > 0){//说明为会计分录 + String _entriesDirection = nodeFieldMappingDao.getEntriesDirection(); + + if(!_entriesDirection.contains(String.valueOf(itemDirection))){//传进来的会计分录方向与当前不一致 + continue; + } + } + + //流程字段新 + FieldDetailInfo workflowField = nodeFieldMappingDao.getWfField(); + + if(workflowField != null){ + int _viewType = workflowField.getViewType(); + + int _detailIndex = workflowField.getDetailIndex(); + if(_viewType == 1 && _detailIndex != dtIndex){ + continue; + } + } + + RuleMethodParam param = new RuleMethodParam(); + param.setRs(rs); + param.setRs_detail(rs_detail); + param.setWorkflowBaseMap(workflowBaseMap); + param.setRowNum(rowNum); + param.setThisUser(thisUser); + + switch (_nodeType){ + case VoucherConstants.Node_Type_Comm_Text: + String nodeValue = FieldChangeRuleMethod.VALUE_RULE_FUNCTION.get(nodeFieldMappingDao.getChangeRule()).apply(nodeFieldMappingDao, param); + + if(nodeFieldMappingDao.getSpecialAttr() == 1 && Util.getDoubleValue(nodeValue,0.0) == 0){ + return null; + } + + jsonObject.put(_nodeName,nodeValue); + + break; + case VoucherConstants.Node_Type_Comm_Object: + JSONObject commObj = recursionGenerateJsonObject(_nodeName,rs,rs_detail,dtIndex,itemDirection,rowNum); + + jsonObject.put(_nodeName,commObj); + break; + case VoucherConstants.Node_Type_Array_Text: + JSONArray arrayText = new JSONArray(); + + String arrayTextValue = FieldChangeRuleMethod.VALUE_RULE_FUNCTION.get(nodeFieldMappingDao.getChangeRule()).apply(nodeFieldMappingDao,param); + + if(StringUtils.isNotBlank(arrayTextValue)){ + arrayText.addAll(Arrays.asList(Util.TokenizerString2(arrayTextValue, ","))); + } + + jsonObject.put(_nodeName,arrayText); + break; + case VoucherConstants.Node_Type_Array_Object: + + JSONArray itemArray = new JSONArray(); + + int _rowNum = 1; + + for(ObjectMappingDao objectMappingDao : objectMappingDaoList){ + String _objectName = objectMappingDao.getObjectName(); + + //别名 + String alias = objectMappingDao.getAlias(); + + if(!_objectName.equals(_nodeName) || (StringUtils.isNotBlank(alias) && !alias.equals(_nodeName))){//对象节点名称 与当前节点不一致 + continue; + } + + int _dtIndex = objectMappingDao.getDtIndex(); + + String _entriesDirection = objectMappingDao.getEntriesDirection(); + + //父节点名称 + String tmpParentNode = StringUtils.isNotBlank(alias) ? alias : _objectName; + + if(_dtIndex > 0){ + String dtCondition = objectMappingDao.getDtCondition(); + + RecordSet _rs_detail; + + //流程明细表名称 + String detailTable = Util.null2String(workflowBaseMap.get("billTableName")) + "_dt" + _dtIndex; + + if(StringUtils.isNotBlank(dtCondition)){ + dtCondition = ToolUtilNew.staticToDBC(dtCondition); + + _rs_detail = sqlMapper.getWorkflowDetailTableInfoAndCondition(detailTable,Util.null2String(workflowBaseMap.get("mainId")),dtCondition); + } else { + _rs_detail = sqlMapper.getWorkflowDetailTableInfo(detailTable,Util.null2String(workflowBaseMap.get("mainId"))); + } + + while(_rs_detail.next()){ + for(String direction : Util.TokenizerString2(_entriesDirection,",")) { + JSONObject itemObj = recursionGenerateJsonObject(tmpParentNode, rs, _rs_detail, _dtIndex, Util.getIntValue(direction), _rowNum++); + + if(itemObj == null || itemObj.isEmpty()){ + _rowNum--; + } else { + itemArray.add(itemObj); + } + } + } + } else {//说明信息来自主表 + for(String direction : Util.TokenizerString2(_entriesDirection,",")){ + JSONObject itemObj = recursionGenerateJsonObject(tmpParentNode,rs,null,0,Util.getIntValue(direction),_rowNum++); + + if(itemObj == null || itemObj.isEmpty()){ + _rowNum--; + } else { + itemArray.add(itemObj); + } + } + } + } + + jsonObject.put(_nodeName,itemArray); + + break; + } + } + + return jsonObject; + } + + /** + * 递归生成XML字符串 + * @param parentNode 父节点名称 + * @param rs 流程主表数据集 + * @param rs_detail 流程某个明细表某行数据集 + * @param dtIndex 明细序列 + * @param itemDirection 借贷方向 + * @param rowNum 明细序号 + * @return XML字符串 + */ + public StringBuilder recursionGenerateXML(String parentNode, RecordSet rs,RecordSet rs_detail, int dtIndex, int itemDirection,int rowNum){ + StringBuilder xmlBuilder = new StringBuilder(); + for(NodeFieldMappingDao nodeFieldMappingDao : nodeFieldMappingDaoList) { + //节点名称 + String _nodeName = nodeFieldMappingDao.getNodeName(); + + if (StringUtils.isBlank(_nodeName)) { + continue; + } + + //父节点名称 + String _parentNode = nodeFieldMappingDao.getParentNode(); + + if (!_parentNode.equals(parentNode)) { + continue; + } + + int _nodeType = nodeFieldMappingDao.getNodeType(); + + if (itemDirection > 0) {//说明为会计分录 + String _entriesDirection = nodeFieldMappingDao.getEntriesDirection(); + + if (!_entriesDirection.contains(String.valueOf(itemDirection))) {//传进来的会计分录方向与当前不一致 + continue; + } + } + + //流程字段新 + FieldDetailInfo workflowField = nodeFieldMappingDao.getWfField(); + + if (workflowField != null) { + int _viewType = workflowField.getViewType(); + + int _detailIndex = workflowField.getDetailIndex(); + if (_viewType == 1 && _detailIndex != dtIndex) { + continue; + } + } + + RuleMethodParam param = new RuleMethodParam(); + param.setRs(rs); + param.setRs_detail(rs_detail); + param.setWorkflowBaseMap(workflowBaseMap); + param.setRowNum(rowNum); + param.setThisUser(thisUser); + + switch (_nodeType) { + case VoucherConstants.Node_Type_Comm_Text: + String nodeValue = FieldChangeRuleMethod.VALUE_RULE_FUNCTION.get(nodeFieldMappingDao.getChangeRule()).apply(nodeFieldMappingDao, param); + + if (nodeFieldMappingDao.getSpecialAttr() == 1 && Util.getDoubleValue(nodeValue, 0.0) == 0) { + return null; + } + xmlBuilder.append("<").append(_nodeName).append(">"); + xmlBuilder.append(nodeValue); + xmlBuilder.append("\n"); + break; + case VoucherConstants.Node_Type_Array_Text: + break; + + case VoucherConstants.Node_Type_Comm_Object: + StringBuilder innerXML = recursionGenerateXML(_nodeName,rs,rs_detail,dtIndex,itemDirection,rowNum); + xmlBuilder.append("<").append(_nodeName).append(">"); + xmlBuilder.append(innerXML); + xmlBuilder.append("\n"); + break; + + case VoucherConstants.Node_Type_Array_Object: + int _rowNum = 1; + + for(ObjectMappingDao objectMappingDao : objectMappingDaoList) { + String _objectName = objectMappingDao.getObjectName(); + + //别名 + String alias = objectMappingDao.getAlias(); + + if (!_objectName.equals(_nodeName) || (StringUtils.isNotBlank(alias) && !alias.equals(_nodeName))) {//对象节点名称 与当前节点不一致 + continue; + } + + int _dtIndex = objectMappingDao.getDtIndex(); + + String _entriesDirection = objectMappingDao.getEntriesDirection(); + + //父节点名称 + String tmpParentNode = StringUtils.isNotBlank(alias) ? alias : _objectName; + + if (_dtIndex > 0) { + String dtCondition = objectMappingDao.getDtCondition(); + + RecordSet _rs_detail; + + //流程明细表名称 + String detailTable = Util.null2String(workflowBaseMap.get("billTableName")) + "_dt" + _dtIndex; + + if (StringUtils.isNotBlank(dtCondition)) { + dtCondition = ToolUtilNew.staticToDBC(dtCondition); + + _rs_detail = sqlMapper.getWorkflowDetailTableInfoAndCondition(detailTable, Util.null2String(workflowBaseMap.get("mainId")), dtCondition); + } else { + _rs_detail = sqlMapper.getWorkflowDetailTableInfo(detailTable, Util.null2String(workflowBaseMap.get("mainId"))); + } + + while (_rs_detail.next()) { + for (String direction : Util.TokenizerString2(_entriesDirection, ",")) { + StringBuilder innerItem = recursionGenerateXML(tmpParentNode,rs,_rs_detail,_dtIndex,Util.getIntValue(direction),_rowNum); + + if(innerItem != null && innerItem.length() > 0){ + xmlBuilder.append("<").append(_nodeName).append(">"); + xmlBuilder.append(innerItem); + xmlBuilder.append("\n"); + } else { + _rowNum--; + } + } + } + } else { //说明数据来自主表 + for(String direction : Util.TokenizerString2(_entriesDirection,",")){ + StringBuilder innerItem = recursionGenerateXML(tmpParentNode,rs,null,0,Util.getIntValue(direction),_rowNum++); + + if(innerItem != null && innerItem.length() > 0){ + xmlBuilder.append("<").append(_nodeName).append(">"); + xmlBuilder.append(innerItem); + xmlBuilder.append("\n"); + } else { + _rowNum--; + } + } + } + } + + break; + } + } + return xmlBuilder; + } + + public User getThisUser() { + return thisUser; + } + + public void setThisUser(User thisUser) { + this.thisUser = thisUser; + } + + public Map getWorkflowBaseMap() { + return workflowBaseMap; + } + + public void setWorkflowBaseMap(Map workflowBaseMap) { + this.workflowBaseMap = workflowBaseMap; + } + + public List getObjectMappingDaoList() { + return objectMappingDaoList; + } + + public void setObjectMappingDaoList(List objectMappingDaoList) { + this.objectMappingDaoList = objectMappingDaoList; + } + + public List getNodeFieldMappingDaoList() { + return nodeFieldMappingDaoList; + } + + public void setNodeFieldMappingDaoList(List nodeFieldMappingDaoList) { + this.nodeFieldMappingDaoList = nodeFieldMappingDaoList; + } +} diff --git a/src/main/java/weaver/weilin/zhu/xyzq/scheduled/sqlmapper/OrganizationSyncSqlMapper.java b/src/main/java/weaver/weilin/zhu/xyzq/scheduled/sqlmapper/OrganizationSyncSqlMapper.java index b75d680..f3ade99 100644 --- a/src/main/java/weaver/weilin/zhu/xyzq/scheduled/sqlmapper/OrganizationSyncSqlMapper.java +++ b/src/main/java/weaver/weilin/zhu/xyzq/scheduled/sqlmapper/OrganizationSyncSqlMapper.java @@ -48,7 +48,7 @@ public interface OrganizationSyncSqlMapper { @Association( property = "modeField", column = "modeField", - select = "weaver.common.util.CommonUtil.getFieldInfo", + select = "weaver.weilin.zhu.common.util.CommonUtil.getFieldDetailInfo", id = @Id(Integer.class) ) }) diff --git a/src/main/java/weaver/weilin/zhu/xyzq/scheduled/task/SyncOrgDataTask.java b/src/main/java/weaver/weilin/zhu/xyzq/scheduled/task/SyncOrgDataTask.java index a6e2c5a..b424c23 100644 --- a/src/main/java/weaver/weilin/zhu/xyzq/scheduled/task/SyncOrgDataTask.java +++ b/src/main/java/weaver/weilin/zhu/xyzq/scheduled/task/SyncOrgDataTask.java @@ -22,7 +22,6 @@ public class SyncOrgDataTask extends BaseCronJob { public void execute() { if(StringUtils.isNotBlank(keyId)){ OrganizationSyncUtil syncUtil = new OrganizationSyncUtil(); - syncUtil.syncData(Util.getIntValue(keyId,0)); } } diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/action/RequestDataToApiAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/action/RequestDataToApiAction.java index a9d2b8e..8fcdd87 100644 --- a/src/main/jinwei_tao_old_src/com/api/taojw/common/action/RequestDataToApiAction.java +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/action/RequestDataToApiAction.java @@ -67,7 +67,7 @@ public class RequestDataToApiAction implements Action { } catch (Exception e) { requestInfo.getRequestManager().setMessageid("2022052791002"); requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +",请联系管理员!"); - logger.error("VoucherAction.select * from workflow_requestBase error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + logger.error("CommonVoucherAction.select * from workflow_requestBase error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); return Action.FAILURE_AND_CONTINUE; } //获取当前流程信息 diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/common/action/RequestDataToApiAction.java b/src/main/jinwei_tao_old_src/weaver/taojw/common/action/RequestDataToApiAction.java index 68fa61b..c527a91 100644 --- a/src/main/jinwei_tao_old_src/weaver/taojw/common/action/RequestDataToApiAction.java +++ b/src/main/jinwei_tao_old_src/weaver/taojw/common/action/RequestDataToApiAction.java @@ -66,7 +66,7 @@ public class RequestDataToApiAction implements Action { } catch (Exception e) { requestInfo.getRequestManager().setMessageid("2022052791002"); requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +",请联系管理员!"); - logger.error("VoucherAction.select * from workflow_requestBase error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + logger.error("CommonVoucherAction.select * from workflow_requestBase error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); return Action.FAILURE_AND_CONTINUE; } //获取当前流程信息