From d78176c580b16385181dccbaf27ecc6a16e2d6ae Mon Sep 17 00:00:00 2001 From: wangxuanran <3055088966@qq.com> Date: Thu, 4 May 2023 14:34:40 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=A4=87=E4=BB=BD?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/OtherSystemToOAController.java | 66 ++ .../sso/mapper/OtherSystemToOAMapper.java | 44 + .../sso/service/OtherSystemToOAService.java | 49 ++ .../impl/OtherSystemToOAServiceImpl.java | 97 +++ .../BatchCreateWorkFlowController.java | 2 +- .../shyl/controller/GetStudentsClass.java | 2 +- .../service/BatchCreateWorkflowService.java | 4 +- .../controller/EmailOutSendController.java | 45 + .../email/entity/EmailOutConfigDetail.java | 17 + .../email/entity/EmailOutConfigMain.java | 21 + .../email/mapper/EmailOutSendMapper.java | 42 + .../email/service/EmailOutSendService.java | 17 + .../service/impl/EmailOutSendServiceImpl.java | 120 +++ .../wang/common/mapper/CommonMapper.java | 9 + .../xuanran/wang/common/util/CommonUtil.java | 52 ++ .../xuanran/wang/common/util/CusData2OA.java | 99 +++ .../xuanran/wang/cssc/cms/WorkflowToCms.java | 153 ++++ .../wang/cssc/cms/entity/CusSuccess.java | 27 + .../cms/service/WorkflowToCmsService.java | 14 + .../impl/WorkFlowToCmsServiceImpl.java | 73 ++ .../cssc/cms/util/RequestMasterPlate.java | 80 ++ .../sap/action/WorkflowToSap.java | 53 ++ .../entity/eneity/DetailRequestConfig.java | 41 + .../sap/entity/eneity/MainRequestConfig.java | 47 ++ .../sap/service/WorkflowToSapService.java | 16 + .../impl/WorkflowToSapServiceImpl.java | 49 ++ .../sap/util/ReadConfigUtil.java | 565 +++++++++++++ .../service/WorkFlowToVmsAndMQService.java | 39 +- .../sh_bigdata/common/entity/CusSuccess.java | 3 +- .../common/service/CusDataDecipher.java | 15 + .../common/util/RequestMasterPlate.java | 10 +- .../common/util/SendTodoTaskUtil.java | 19 +- .../sh_bigdata/common/util/ShBigDataUtil.java | 69 +- .../sh_bigdata/common/util/TokenUtil.java | 40 +- .../OrganizationHrmSyncFromOtherSys.java | 37 + .../annotations/CusOrgHrmAsyncConvert.java | 16 + .../entity/OrgHrmAsyncCache.java | 43 + .../entity/OrgHrmAsyncConfigDetail.java | 30 + .../entity/OrgHrmAsyncConfigMain.java | 39 + .../entity/OtherSysDepartment.java | 23 +- .../job/OrganizationHrmSyncJob.java | 146 ++++ .../mapper/OrgHrmAsyncMapper.java | 86 +- .../service/OrgHrmAsyncApiService.java | 15 +- .../service/OrgHrmAsyncService.java | 17 +- .../impl/OrgHrmAsyncApiServiceImpl.java | 45 +- .../impl/OrgHrmAsyncEntityServiceImpl.java | 265 ++++++ .../service/impl/OrgHrmAsyncServiceImpl.java | 775 +++++++++++++++--- .../org_hrm_async/util/OrgHrmAsyncUtil.java | 102 +++ .../org_hrm_async/util/ValueRuleMethod.java | 178 ++++ .../org_hrm_async/util/ValueRuleMethodNo.java | 19 + .../task_async/entity/CusDoneTask.java | 2 +- .../task_async/entity/CusTodoTask.java | 2 +- .../service/impl/SendTodoTaskServiceImpl.java | 3 +- .../shyl/dataasync/entity/StudentClass.java | 2 + .../shyl/dataasync/job/CusDataAsyncJob.java | 36 +- .../service/CusDataAsyncService.java | 38 + .../wang/shyl_mq/mapper/ConsumerMapper.java | 4 +- .../shyl_mq/service/impl/OrgServiceImpl.java | 2 +- .../wang/shyl_mq/util/RocketConsumerUtil.java | 1 + .../prop/prop2map/ShBigdataConf.properties | 54 +- .../xuanran/wang/big_data/BigDataTest.java | 400 +++++++++ src/test/java/xuanran/wang/cssc/FileTest.java | 204 +++++ .../wang/eighty_five_degreec/SAPTest.java | 52 ++ .../java/xuanran/wang/immc/Kafka/MQTest.java | 8 + .../wang/traffic_bank/EmailOutSendTest.java | 45 + 65 files changed, 4477 insertions(+), 211 deletions(-) create mode 100644 src/main/java/com/api/xuanran/wang/sh_bigdata/sso/controller/OtherSystemToOAController.java create mode 100644 src/main/java/com/api/xuanran/wang/sh_bigdata/sso/mapper/OtherSystemToOAMapper.java create mode 100644 src/main/java/com/api/xuanran/wang/sh_bigdata/sso/service/OtherSystemToOAService.java create mode 100644 src/main/java/com/api/xuanran/wang/sh_bigdata/sso/service/impl/OtherSystemToOAServiceImpl.java create mode 100644 src/main/java/com/api/xuanran/wang/traffic_bank/email/controller/EmailOutSendController.java create mode 100644 src/main/java/com/api/xuanran/wang/traffic_bank/email/entity/EmailOutConfigDetail.java create mode 100644 src/main/java/com/api/xuanran/wang/traffic_bank/email/entity/EmailOutConfigMain.java create mode 100644 src/main/java/com/api/xuanran/wang/traffic_bank/email/mapper/EmailOutSendMapper.java create mode 100644 src/main/java/com/api/xuanran/wang/traffic_bank/email/service/EmailOutSendService.java create mode 100644 src/main/java/com/api/xuanran/wang/traffic_bank/email/service/impl/EmailOutSendServiceImpl.java create mode 100644 src/main/java/weaver/xuanran/wang/common/util/CusData2OA.java create mode 100644 src/main/java/weaver/xuanran/wang/cssc/cms/WorkflowToCms.java create mode 100644 src/main/java/weaver/xuanran/wang/cssc/cms/entity/CusSuccess.java create mode 100644 src/main/java/weaver/xuanran/wang/cssc/cms/service/WorkflowToCmsService.java create mode 100644 src/main/java/weaver/xuanran/wang/cssc/cms/service/impl/WorkFlowToCmsServiceImpl.java create mode 100644 src/main/java/weaver/xuanran/wang/cssc/cms/util/RequestMasterPlate.java create mode 100644 src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/action/WorkflowToSap.java create mode 100644 src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/entity/eneity/DetailRequestConfig.java create mode 100644 src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/entity/eneity/MainRequestConfig.java create mode 100644 src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/service/WorkflowToSapService.java create mode 100644 src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/service/impl/WorkflowToSapServiceImpl.java create mode 100644 src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/util/ReadConfigUtil.java create mode 100644 src/main/java/weaver/xuanran/wang/sh_bigdata/common/service/CusDataDecipher.java create mode 100644 src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/annotations/CusOrgHrmAsyncConvert.java create mode 100644 src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/entity/OrgHrmAsyncCache.java create mode 100644 src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/entity/OrgHrmAsyncConfigDetail.java create mode 100644 src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/entity/OrgHrmAsyncConfigMain.java create mode 100644 src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/job/OrganizationHrmSyncJob.java create mode 100644 src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/service/impl/OrgHrmAsyncEntityServiceImpl.java create mode 100644 src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/util/OrgHrmAsyncUtil.java create mode 100644 src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/util/ValueRuleMethod.java create mode 100644 src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/util/ValueRuleMethodNo.java create mode 100644 src/test/java/xuanran/wang/big_data/BigDataTest.java create mode 100644 src/test/java/xuanran/wang/cssc/FileTest.java create mode 100644 src/test/java/xuanran/wang/eighty_five_degreec/SAPTest.java create mode 100644 src/test/java/xuanran/wang/traffic_bank/EmailOutSendTest.java diff --git a/src/main/java/com/api/xuanran/wang/sh_bigdata/sso/controller/OtherSystemToOAController.java b/src/main/java/com/api/xuanran/wang/sh_bigdata/sso/controller/OtherSystemToOAController.java new file mode 100644 index 0000000..076bda2 --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/sh_bigdata/sso/controller/OtherSystemToOAController.java @@ -0,0 +1,66 @@ +package com.api.xuanran.wang.sh_bigdata.sso.controller; + +import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; +import com.alibaba.fastjson.JSONObject; +import com.api.xuanran.wang.sh_bigdata.sso.service.OtherSystemToOAService; +import com.api.xuanran.wang.sh_bigdata.sso.service.impl.OtherSystemToOAServiceImpl; +import com.sun.jersey.api.view.Viewable; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import weaver.integration.util.SessionUtil; +import weaver.xuanran.wang.sh_bigdata.common.util.ShBigDataUtil; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.Context; +import java.util.Map; + +/** + *

第三方系统登录oa

+ * + * @author xuanran.wang + * @date 2023/4/17 14:22 + */ +@Path("/wxr/sh_big_data/sso") +public class OtherSystemToOAController { + + private final Logger log = Util.getLogger(); + private final OtherSystemToOAService service = new OtherSystemToOAServiceImpl(); + @Path("/login/{appId}") + @GET + public Viewable login(@PathParam("appId") String appId, + @Context HttpServletRequest request, + @Context HttpServletResponse response) { + try { + log.info("appId : " + appId); + String code = Util.null2DefaultStr(request.getParameter("code"),""); + log.info("sso login code : " + code); + if(StringUtils.isBlank(code)){ + throw new CustomerException("code is null!"); + } + // 获取重定向地址和secret + Map redirectUrlAndCorpsecret = service.getRedirectUrlAndCorpsecret(appId); + String redirectUrl = Util.null2DefaultStr(redirectUrlAndCorpsecret.get("REDIRECTURL"),""); + log.info("successSendRedirectUrl : " + redirectUrl); + if(StringUtils.isBlank(redirectUrl)){ + throw new CustomerException("redirectUrl is null! " + JSONObject.toJSONString(redirectUrlAndCorpsecret)); + } + int userId = service.getUserFromOtherSys(code, redirectUrlAndCorpsecret); + SessionUtil.createSession(userId + "", request, response); + response.sendRedirect(redirectUrl); + }catch (Exception e){ + log.error("sso error : " + e.getMessage()); + log.error(Util.getErrString(e)); + try { + response.sendRedirect(Util.null2DefaultStr(ShBigDataUtil.getPropertiesValByKey("loginErrorSendRedirectUrl"),"/login/login.jsp")); + }catch (Exception ec){ + log.error("sendRedirect error " + ec.getMessage()); + } + } + return null; + } +} diff --git a/src/main/java/com/api/xuanran/wang/sh_bigdata/sso/mapper/OtherSystemToOAMapper.java b/src/main/java/com/api/xuanran/wang/sh_bigdata/sso/mapper/OtherSystemToOAMapper.java new file mode 100644 index 0000000..f3c4884 --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/sh_bigdata/sso/mapper/OtherSystemToOAMapper.java @@ -0,0 +1,44 @@ +package com.api.xuanran.wang.sh_bigdata.sso.mapper; + +import aiyh.utils.annotation.recordset.ParamMapper; +import aiyh.utils.annotation.recordset.Select; +import aiyh.utils.annotation.recordset.SqlMapper; + +import java.util.Map; + +/** + *

第三方系统登录oa mapper

+ * + * @author xuanran.wang + * @date 2023/4/18 09:54 + */ +@SqlMapper +public interface OtherSystemToOAMapper { + /** + *

根据outKey查oa ID

+ * @author xuanran.wang + * @dateTime 2023/4/20 11:46 + * @param outKey 外键id + * @return oa ID + **/ + @Select("select id from hrmresource where outkey = #{outKey}") + int selectUserIdByOutKey(@ParamMapper("outKey") String outKey); + /** + *

根据appId 查跳转的地址

+ * @author xuanran.wang + * @dateTime 2023/4/20 11:47 + * @param appId appId + * @return 跳转的地址 + **/ + @Select("select zydz from uf_AppPortal where zcsjbs = #{appId}") + String selectRedirectUrlByAppId(@ParamMapper("appId") String appId); + /** + *

根据appId 查跳转的地址

+ * @author xuanran.wang + * @dateTime 2023/4/20 11:47 + * @param appId appId + * @return 跳转的地址 + **/ + @Select("select zydz redirectUrl, secret from uf_AppPortal where zcsjbs = #{appId}") + Map selectRedirectUrlAndSecretByAppId(@ParamMapper("appId") String appId); +} diff --git a/src/main/java/com/api/xuanran/wang/sh_bigdata/sso/service/OtherSystemToOAService.java b/src/main/java/com/api/xuanran/wang/sh_bigdata/sso/service/OtherSystemToOAService.java new file mode 100644 index 0000000..7f736c4 --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/sh_bigdata/sso/service/OtherSystemToOAService.java @@ -0,0 +1,49 @@ +package com.api.xuanran.wang.sh_bigdata.sso.service; + +import weaver.xuanran.wang.sh_bigdata.common.entity.CusSuccess; + +import java.util.Map; + +/** + *

第三方系统登录oa

+ * + * @author xuanran.wang + * @date 2023/4/17 14:27 + */ +public interface OtherSystemToOAService { + /** + *

发请求根据code获取第三方系统用户id

+ * @author xuanran.wang + * @dateTime 2023/4/18 13:29 + * @param url 请求地址 + * @param params 参数 + * @param headers 请求头 + * @param cusSuccess 自定义接口成功/失败标识 + * @return 接口响应字段 + **/ + int getUserIdByCode(String url, Map params, Map headers, CusSuccess cusSuccess, Map redirectUrlSecret); + /** + *

根据第三方系统人员code匹配oa人员id

+ * @author xuanran.wang + * @dateTime 2023/4/18 13:30 + * @param code 第三方系统人员code + * @return oa人员id + **/ + int getUserFromOtherSys(String code, Map redirectUrlSecret); + /** + *

根据appId获取oa地址

+ * @author xuanran.wang + * @dateTime 2023/4/20 11:14 + * @param appId 建模appId + * @return 跳转应用地址 + **/ + String getLoginSuccessSendRedirectUrl(String appId); + /** + *

根据appId获取跳转地址和corpsecret

+ * @author xuanran.wang + * @dateTime 2023/4/20 11:14 + * @param appId 建模appId + * @return 跳转应用地址 + **/ + Map getRedirectUrlAndCorpsecret(String appId); +} diff --git a/src/main/java/com/api/xuanran/wang/sh_bigdata/sso/service/impl/OtherSystemToOAServiceImpl.java b/src/main/java/com/api/xuanran/wang/sh_bigdata/sso/service/impl/OtherSystemToOAServiceImpl.java new file mode 100644 index 0000000..3e1581a --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/sh_bigdata/sso/service/impl/OtherSystemToOAServiceImpl.java @@ -0,0 +1,97 @@ +package com.api.xuanran.wang.sh_bigdata.sso.service.impl; + +import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; +import com.alibaba.fastjson.JSONObject; +import com.api.xuanran.wang.sh_bigdata.sso.mapper.OtherSystemToOAMapper; +import com.api.xuanran.wang.sh_bigdata.sso.service.OtherSystemToOAService; +import org.apache.commons.collections.MapUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import weaver.xuanran.wang.sh_bigdata.common.entity.CusSuccess; +import weaver.xuanran.wang.sh_bigdata.common.util.RequestMasterPlate; +import weaver.xuanran.wang.sh_bigdata.common.util.ShBigDataUtil; + +import java.util.HashMap; +import java.util.Map; + +/** + *

第三方系统登录oa

+ * + * @author xuanran.wang + * @date 2023/4/17 14:35 + */ +public class OtherSystemToOAServiceImpl implements OtherSystemToOAService { + + private final RequestMasterPlate requestMasterPlate = new RequestMasterPlate(); + private final CusSuccess cusSuccess = CusSuccess.builder() + .successField("code") + .successValue(0) + .errorMsg("msg") + .dataKey("data.id") + .build(); + private final OtherSystemToOAMapper otherSystemToOAMapper = Util.getMapper(OtherSystemToOAMapper.class); + private final Logger log = Util.getLogger(); + @Override + public int getUserIdByCode(String url, Map params, Map headers, CusSuccess cusSuccess, Map redirectUrlSecret) { + String secret = Util.null2DefaultStr(redirectUrlSecret.get("SECRET"), ""); + log.info("secret : " + secret); + if(StringUtils.isBlank(secret)){ + throw new CustomerException("secret is null! " + JSONObject.toJSONString(redirectUrlSecret)); + } + return requestMasterPlate.apiGet(ShBigDataUtil.addToken2Url(url, secret), params ,new HashMap<>(), cusSuccess); + } + + @Override + public int getUserFromOtherSys(String code, Map redirectUrlSecret) { + HashMap params = new HashMap<>(); + params.put("code", code); + // 获取第三方系统id + String getUserInfoByCodeUrl = ShBigDataUtil.getPropertiesValByKey("getUserInfoByCodeUrl"); + int codeId; + try { + codeId = getUserIdByCode(getUserInfoByCodeUrl, params, new HashMap<>(), cusSuccess, redirectUrlSecret); + }catch (Exception e){ + String getUserIdDebug = ShBigDataUtil.getPropertiesValByKey("getUserIdDebug"); + // 开启调试模式 + if("1".equals(getUserIdDebug)){ + codeId = Util.getIntValue(ShBigDataUtil.getPropertiesValByKey("getUserIdDebugOutKey"), 109); + log.info("debug codeId : " + codeId); + }else { + throw new CustomerException(e.getMessage()); + } + } + if(codeId < 0){ + throw new CustomerException(Util.logStr("code : {}, not found in {} .", code, getUserInfoByCodeUrl)); + } + int id = otherSystemToOAMapper.selectUserIdByOutKey(codeId + ""); + if(id < 0){ + throw new CustomerException(Util.logStr("code : {} not found in OA!", id)); + } + return id; + } + + @Override + public String getLoginSuccessSendRedirectUrl(String appId) { + String defaultUrl = Util.null2DefaultStr(ShBigDataUtil.getPropertiesValByKey("loginSuccessSendRedirectUrl"), "/wui/index.html#/main"); + String url = otherSystemToOAMapper.selectRedirectUrlByAppId(appId); + if(StringUtils.isBlank(appId) || StringUtils.isBlank(url)){ + return defaultUrl; + } + return url; + } + + @Override + public Map getRedirectUrlAndCorpsecret(String appId) { + Map res = otherSystemToOAMapper.selectRedirectUrlAndSecretByAppId(appId); + if(MapUtils.isEmpty(res)){ + throw new CustomerException(Util.logStr("该appId在建模配置中不存在配置!")); + } + long count = res.values().stream().filter(StringUtils::isBlank).count(); + if(count > 0){ + throw new CustomerException(Util.logStr("该appId查询重定向地址或secret数据为空!: {}", JSONObject.toJSONString(res))); + } + return res; + } + +} diff --git a/src/main/java/com/api/xuanran/wang/shyl/controller/BatchCreateWorkFlowController.java b/src/main/java/com/api/xuanran/wang/shyl/controller/BatchCreateWorkFlowController.java index 94abd03..01dc790 100644 --- a/src/main/java/com/api/xuanran/wang/shyl/controller/BatchCreateWorkFlowController.java +++ b/src/main/java/com/api/xuanran/wang/shyl/controller/BatchCreateWorkFlowController.java @@ -71,7 +71,7 @@ public class BatchCreateWorkFlowController { return ApiResult.success(service.batchCreateWorkflow(user, workflows)); }catch (Exception e){ log.error(Util.logStr("batchCreate error : {}", e.getMessage())); - return ApiResult.error(500,"批量创建流程接口发生异常! 异常信息 :[ " + e.getMessage() + " ]"); + return ApiResult.error(500, e.getMessage()); } } diff --git a/src/main/java/com/api/xuanran/wang/shyl/controller/GetStudentsClass.java b/src/main/java/com/api/xuanran/wang/shyl/controller/GetStudentsClass.java index 10b720f..3e58125 100644 --- a/src/main/java/com/api/xuanran/wang/shyl/controller/GetStudentsClass.java +++ b/src/main/java/com/api/xuanran/wang/shyl/controller/GetStudentsClass.java @@ -16,7 +16,7 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; /** - *

+ *

<学员接口/h1> * * @author xuanran.wang * @date 2023/3/1 10:56 diff --git a/src/main/java/com/api/xuanran/wang/shyl/service/BatchCreateWorkflowService.java b/src/main/java/com/api/xuanran/wang/shyl/service/BatchCreateWorkflowService.java index 7621447..998cd6e 100644 --- a/src/main/java/com/api/xuanran/wang/shyl/service/BatchCreateWorkflowService.java +++ b/src/main/java/com/api/xuanran/wang/shyl/service/BatchCreateWorkflowService.java @@ -37,9 +37,7 @@ public class BatchCreateWorkflowService { private final Logger log = Util.getLogger(); private static final String CUSTOM_ID = "customId"; - // private final MeetingMapper meetingTransMapper = Util.getTransMapper(MeetingMapper.class); - private final MeetingService meetingService = new MeetingService(); /** *

取消会议 支持多个

@@ -97,7 +95,7 @@ public class BatchCreateWorkflowService { } } if(errors.size() > 0){ - throw new CustomerException("创建流程失败!错误参数流程 : \n" + JSONObject.toJSONString(errors)); + throw new CustomerException(JSONObject.toJSONString(errors)); } return res; }catch (Exception e){ diff --git a/src/main/java/com/api/xuanran/wang/traffic_bank/email/controller/EmailOutSendController.java b/src/main/java/com/api/xuanran/wang/traffic_bank/email/controller/EmailOutSendController.java new file mode 100644 index 0000000..f0e59ac --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/traffic_bank/email/controller/EmailOutSendController.java @@ -0,0 +1,45 @@ +package com.api.xuanran.wang.traffic_bank.email.controller; + +import aiyh.utils.ApiResult; +import aiyh.utils.Util; +import com.alibaba.fastjson.JSONObject; +import com.api.xuanran.wang.traffic_bank.email.service.EmailOutSendService; +import com.api.xuanran.wang.traffic_bank.email.service.impl.EmailOutSendServiceImpl; +import io.swagger.v3.oas.annotations.parameters.RequestBody; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.Consumes; +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.Map; + +/** + *

交银理财邮件外发

+ * + * @author xuanran.wang + * @date 2023/4/18 14:11 + */ +@Path("/wxr/traffic_bank/email") +public class EmailOutSendController { + + private final EmailOutSendService service = new EmailOutSendServiceImpl(); + + @Path("/send") + @POST + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + public String sendEmail(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map param) { + try { + service.sendEmail(param); + return ApiResult.success(null); + }catch (Exception e){ + Util.getLogger().error("EmailOutSendController error " + e.getMessage()); + Util.getLogger().error(Util.getErrString(e)); + return ApiResult.error("发送邮件异常 : " + e.getMessage()); + } + } +} diff --git a/src/main/java/com/api/xuanran/wang/traffic_bank/email/entity/EmailOutConfigDetail.java b/src/main/java/com/api/xuanran/wang/traffic_bank/email/entity/EmailOutConfigDetail.java new file mode 100644 index 0000000..f636e5c --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/traffic_bank/email/entity/EmailOutConfigDetail.java @@ -0,0 +1,17 @@ +package com.api.xuanran.wang.traffic_bank.email.entity; + +import lombok.Data; + +/** + *

邮件外发配置表明细

+ * + * @author xuanran.wang + * @date 2023/4/18 14:23 + */ +@Data +public class EmailOutConfigDetail { + private String interfaceField; + private String fieldName; + private String cusStyleClass; + private int mergeCell; +} diff --git a/src/main/java/com/api/xuanran/wang/traffic_bank/email/entity/EmailOutConfigMain.java b/src/main/java/com/api/xuanran/wang/traffic_bank/email/entity/EmailOutConfigMain.java new file mode 100644 index 0000000..7004a09 --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/traffic_bank/email/entity/EmailOutConfigMain.java @@ -0,0 +1,21 @@ +package com.api.xuanran.wang.traffic_bank.email.entity; + +import lombok.Data; + +import java.util.List; + +/** + *

邮件外发配置表主表

+ * + * @author xuanran.wang + * @date 2023/4/18 14:17 + */ +@Data +public class EmailOutConfigMain { + private int transType; + private String templatePath; + private String emailAddressCusSql; + private int enable; + private String titleField; + private List configDetailList; +} diff --git a/src/main/java/com/api/xuanran/wang/traffic_bank/email/mapper/EmailOutSendMapper.java b/src/main/java/com/api/xuanran/wang/traffic_bank/email/mapper/EmailOutSendMapper.java new file mode 100644 index 0000000..f295e6d --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/traffic_bank/email/mapper/EmailOutSendMapper.java @@ -0,0 +1,42 @@ +package com.api.xuanran.wang.traffic_bank.email.mapper; + +import aiyh.utils.annotation.recordset.*; +import com.api.xuanran.wang.traffic_bank.email.entity.EmailOutConfigDetail; +import com.api.xuanran.wang.traffic_bank.email.entity.EmailOutConfigMain; +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OrgHrmAsyncConfigDetail; + +import java.util.List; +import java.util.Map; + +/** + *

邮件外发mapper

+ * + * @author xuanran.wang + * @date 2023/4/18 14:26 + */ +@SqlMapper +public interface EmailOutSendMapper { + + @Select("select * from uf_email_out_config where trans_type = #{transType}") + @CollectionMappings({ + @CollectionMapping(property = "configDetailList", + column = "id", + id = @Id(value = Integer.class, methodId = 1)) + }) + EmailOutConfigMain selectConfigByTypeId(@ParamMapper("transType") int transType); + + /** + *

查询配置表明细表信息

+ * @author xuanran.wang + * @dateTime 2023/3/1 16:39 + * @param mainId 主表数据id + * @return 配置集合 + **/ + @Select("select * from uf_email_out_config_dt1 where mainid = #{mainId}") + @CollectionMethod(1) + List selectConfigDetail(@ParamMapper("mainId") int mainId); + + @Select(custom = true) + String selectCustomerSql(@SqlString String sql, Map map); + +} diff --git a/src/main/java/com/api/xuanran/wang/traffic_bank/email/service/EmailOutSendService.java b/src/main/java/com/api/xuanran/wang/traffic_bank/email/service/EmailOutSendService.java new file mode 100644 index 0000000..376a617 --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/traffic_bank/email/service/EmailOutSendService.java @@ -0,0 +1,17 @@ +package com.api.xuanran.wang.traffic_bank.email.service; + +import com.api.xuanran.wang.traffic_bank.email.entity.EmailOutConfigMain; + +import java.util.List; +import java.util.Map; + +/** + *

邮件外发

+ * + * @author xuanran.wang + * @date 2023/4/18 14:15 + */ +public interface EmailOutSendService { + EmailOutConfigMain selectConfigByTransType(int type); + void sendEmail(Map params); +} diff --git a/src/main/java/com/api/xuanran/wang/traffic_bank/email/service/impl/EmailOutSendServiceImpl.java b/src/main/java/com/api/xuanran/wang/traffic_bank/email/service/impl/EmailOutSendServiceImpl.java new file mode 100644 index 0000000..0ebcd22 --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/traffic_bank/email/service/impl/EmailOutSendServiceImpl.java @@ -0,0 +1,120 @@ +package com.api.xuanran.wang.traffic_bank.email.service.impl; + +import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; +import com.alibaba.fastjson.JSONObject; +import com.api.xuanran.wang.traffic_bank.email.entity.EmailOutConfigDetail; +import com.api.xuanran.wang.traffic_bank.email.entity.EmailOutConfigMain; +import com.api.xuanran.wang.traffic_bank.email.mapper.EmailOutSendMapper; +import com.api.xuanran.wang.traffic_bank.email.service.EmailOutSendService; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import org.springframework.util.Assert; +import org.springframework.util.CollectionUtils; +import weaver.email.EmailWorkRunnable; + +import java.util.*; + +/** + *

邮件外发业务方法

+ * + * @author xuanran.wang + * @date 2023/4/18 14:33 + */ +public class EmailOutSendServiceImpl implements EmailOutSendService { + private final EmailOutSendMapper emailOutSendMapper = Util.getMapper(EmailOutSendMapper.class); + private final Logger log = Util.getLogger(); + @Override + public EmailOutConfigMain selectConfigByTransType(int type) { + EmailOutConfigMain configMain = emailOutSendMapper.selectConfigByTypeId(type); + Assert.notNull(configMain, Util.logStr("type= {}, not found config in uf_email_out_config!", type)); + List configDetailList = configMain.getConfigDetailList(); + Assert.notEmpty(configDetailList, Util.logStr("type= {}, not found config in uf_email_out_config_dt1!", type)); + return configMain; + } + + @Override + public void sendEmail(Map param) { + int type = Util.getIntValue(Util.null2DefaultStr(param.get("type"), ""), -1); + EmailOutConfigMain outConfigMain = selectConfigByTransType(type); + List> data = (List>) param.get("data"); + Map map = convertConfigToMail(outConfigMain, data); + List addressList = (List) map.get("address"); + String title = Util.null2DefaultStr(map.get("title"),""); + String email = Util.null2DefaultStr(map.get("email"), ""); + log.info("sendEmailInfo => \n " + JSONObject.toJSONString(map)); + if(CollectionUtils.isEmpty(addressList)){ + log.error("address is empty!"); + return; + } + for (String address : addressList) { + EmailWorkRunnable workRunnable = new EmailWorkRunnable(address, title, email); + if(!workRunnable.emailCommonRemind()){ + throw new CustomerException(Util.logStr("发送邮件失败! 邮件地址: {}, 标题: {}, 内容: {}",address, title, email)); + } + } + } + + + /** + *

根据配置将参数进行转换

+ * @author xuanran.wang + * @dateTime 2023/4/19 11:05 + * @param outConfigMain 配置表对象 + * @param params 邮件参数 + * @return 转换后的邮件参数map + **/ + public Map convertConfigToMail(EmailOutConfigMain outConfigMain, List> params){ + List detailConfig = outConfigMain.getConfigDetailList(); + String title = ""; + String titleField = Util.null2DefaultStr(outConfigMain.getTitleField(),""); + String emailAddressCusSql = outConfigMain.getEmailAddressCusSql(); + String sql = Util.sbc2dbcCase(emailAddressCusSql); + List emailList = new ArrayList<>(); + StringBuilder sb = new StringBuilder(); + int size = 0; + // 表头 + for (EmailOutConfigDetail detail : detailConfig) { + sb.append("").append(detail.getFieldName()).append(""); + size++; + } + sb.append(""); + for (Map param : params) { + sb.append(""); + for (EmailOutConfigDetail detail : detailConfig) { + int mergeCell = detail.getMergeCell(); + if(mergeCell > 0){ + sb.append(""); + sb.append(Util.null2DefaultStr(param.get(detail.getInterfaceField()),"")); + }else { + sb.append("").append(Util.null2DefaultStr(param.get(detail.getInterfaceField()),"")); + } + sb.append(""); + } + sb.append(""); + String email = emailOutSendMapper.selectCustomerSql(sql, param); + if(StringUtils.isNotBlank(email)){ + emailList.add(email); + } + if(StringUtils.isNotBlank(titleField)){ + title = Util.null2DefaultStr(param.get(titleField),""); + } + } + String html = outConfigMain.getTemplatePath(); + html = html + .replace("\n"," ") + .replace("\t"," ") + .replace("{tableInfo}", sb.toString()) + .replace("{?data.size}", size + "") + .replace("{?title}", title); + Map email = new HashMap<>(); + email.put("title", title); + email.put("email", html); + email.put("address", emailList); + return email; + } + +} diff --git a/src/main/java/weaver/xuanran/wang/common/mapper/CommonMapper.java b/src/main/java/weaver/xuanran/wang/common/mapper/CommonMapper.java index ec35493..1a13798 100644 --- a/src/main/java/weaver/xuanran/wang/common/mapper/CommonMapper.java +++ b/src/main/java/weaver/xuanran/wang/common/mapper/CommonMapper.java @@ -112,4 +112,13 @@ public interface CommonMapper { @Update("update meeting set meetingstatus = 4 where requestid in (${requestIds})") boolean cancelMeeting(@ParamMapper("requestIds") List requestIds); + + @Select(custom = true) + String selectCustomerSql(@SqlString String sql, Map map); + + @Update(custom = true) + boolean updateModelInfo(@SqlString String sql, Map params); + + @BatchUpdate(custom = true) + boolean updateModelInfoList(@SqlString String sql, @BatchSqlArgs List> params); } diff --git a/src/main/java/weaver/xuanran/wang/common/util/CommonUtil.java b/src/main/java/weaver/xuanran/wang/common/util/CommonUtil.java index 818b3f0..6d2b236 100644 --- a/src/main/java/weaver/xuanran/wang/common/util/CommonUtil.java +++ b/src/main/java/weaver/xuanran/wang/common/util/CommonUtil.java @@ -10,6 +10,9 @@ import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; import weaver.conn.RecordSet; import weaver.formmode.data.ModeDataApproval; +import weaver.formmode.data.ModeDataIdUpdate; +import weaver.formmode.setup.ModeRightInfo; +import weaver.general.TimeUtil; import weaver.hrm.User; import weaver.xiao.commons.config.entity.RequestMappingConfig; import weaver.xiao.commons.config.service.DealWithMapping; @@ -60,6 +63,9 @@ public class CommonUtil { **/ private static final CommonMapper commonMapper = Util.getMapper(CommonMapper.class); + private static final ModeDataIdUpdate modeDataIdUpdate = ModeDataIdUpdate.getInstance(); + private static final ModeRightInfo moderightinfo = new ModeRightInfo(); + public CommonUtil(){ } @@ -655,6 +661,52 @@ public class CommonUtil { return commonMapper.queryMeetingIdByRequestId(requestId); } + /** + *

删除建模数据

+ * @author xuanran.wang + * @dateTime 2022/11/23 21:02 + * @param modelId 模块id + * @param ids 数据集合 + * @return 删除是否成功 + **/ + public static boolean deleteModelDataByIds(String modelId, List ids){ + String tableName = commonMapper.getModelNameByModelId(modelId); + return commonMapper.deleteModelDataByIds(tableName, ids); + } + /** + *

获取建模数据id

+ * @author xuanran.wang + * @dateTime 2022/12/15 10:56 + * @param modelTableName 表名 + * @param modelId 模块id + * @return 新的建模数据id + **/ + private static Integer getNewIdByModelInfo(String modelTableName, int modelId){ + String currentDateTime = TimeUtil.getCurrentTimeString(); + //日期 + String currentDate = currentDateTime.substring(0, 10); + //时间 + String currentTime = currentDateTime.substring(11); + return modeDataIdUpdate.getModeDataNewId(modelTableName, modelId, 1, 0, currentDate, currentTime); + } + + /** + *

校验模块id 并获取表名

+ * @author xuanran.wang + * @dateTime 2023/2/9 11:18 + * @param modelId 模块id + * @return 表名 + **/ + public static String checkModelId(int modelId){ + if(modelId < 0){ + throw new RuntimeException("建模模块id不能小于0!"); + } + String tableName = commonMapper.getModelNameByModelId(String.valueOf(modelId)); + if(StringUtils.isBlank(tableName)){ + throw new CustomerException("模块id为 " + modelId + ", 在系统中暂没查询到对应表单!"); + } + return tableName; + } } diff --git a/src/main/java/weaver/xuanran/wang/common/util/CusData2OA.java b/src/main/java/weaver/xuanran/wang/common/util/CusData2OA.java new file mode 100644 index 0000000..7e7e465 --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/common/util/CusData2OA.java @@ -0,0 +1,99 @@ +package weaver.xuanran.wang.common.util; + +import aiyh.utils.Util; +import aiyh.utils.annotation.recordset.BatchUpdate; +import aiyh.utils.excention.CustomerException; +import org.apache.axis2.databinding.types.xsd._float; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import weaver.formmode.data.ModeDataIdUpdate; +import weaver.formmode.setup.ModeRightInfo; +import weaver.xuanran.wang.common.mapper.CommonMapper; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +/** + *

自定义数据写入oa

+ * + * @author xuanran.wang + * @date 2023/4/19 16:24 + */ +public class CusData2OA { + private static final CommonMapper commonMapper = Util.getMapper(CommonMapper.class); + private static final Logger log = Util.getLogger(); + private static final String TABLE_NAME_PLACEHOLDER = "#\\{tableName}"; + + public static String writeToModel(String modelId, String uniqueSql, Map params){ + return baseExecute(modelId, uniqueSql, Collections.singletonList(params)).get(0); + } + + public static String writeToModel(String modelId, Map params){ + return baseExecute(modelId, "", Collections.singletonList(params)).get(0); + } + + public static List batchWriteToModel(String modelId, List> params){ + return baseExecute(modelId, "", params); + } + + public static List batchWriteToModel(String modelId, String uniqueSql, List> params){ + return baseExecute(modelId, uniqueSql, params); + } + + @BatchUpdate + public static List baseExecute(String modelId, String uniqueSql, List> params){ + int modelIdInt = Util.getIntValue(modelId, -1); + String tableName = CommonUtil.checkModelId(modelIdInt); + if(modelIdInt < 0 || StringUtils.isBlank(tableName)){ + throw new CustomerException("modelId can not < 0 or modelTableName can not empty!"); + } + uniqueSql = Util.sbc2dbcCase(uniqueSql); + uniqueSql = uniqueSql.replaceAll(TABLE_NAME_PLACEHOLDER, tableName); + String modelDataId = ""; + List delList = new ArrayList<>(); + List modelDataList = new ArrayList<>(); + String updateSql = ""; + + for (Map param : params) { + if(StringUtils.isNotBlank(uniqueSql)){ + modelDataId = commonMapper.selectCustomerSql(uniqueSql, param); + } + if(StringUtils.isBlank(modelDataId)){ + modelDataId = Util.null2DefaultStr(Util.getModeDataId(tableName, modelIdInt, 1),""); + delList.add(modelDataId); + Util.rebuildModeDataShare(1, tableName, Util.getIntValue(modelDataId, -1)); + } + if(StringUtils.isBlank(updateSql)){ + updateSql = buildUpdateSql(tableName, param); + } + param.put("id",modelDataId); + modelDataList.add(modelDataId); + } + try { + if (!commonMapper.updateModelInfoList(updateSql, params)) { + throw new CustomerException("update model data sql execute error!"); + } + }catch (Exception e){ + CommonUtil.deleteDataByIds(delList, tableName); + throw new CustomerException(e); + } + return modelDataList; + } + + public static String buildUpdateSql(String tableName, Map params) { + StringBuilder sqlSb = new StringBuilder("update ") + .append(tableName) + .append(" set "); + for (Map.Entry entry : params.entrySet()) { + sqlSb.append(entry.getKey()) + .append(" = #{item.") + .append(entry.getKey()) + .append("},"); + } + sqlSb.deleteCharAt(sqlSb.length() - 1); + sqlSb.append(" where id = #{item.id}"); + return sqlSb.toString(); + } +} diff --git a/src/main/java/weaver/xuanran/wang/cssc/cms/WorkflowToCms.java b/src/main/java/weaver/xuanran/wang/cssc/cms/WorkflowToCms.java new file mode 100644 index 0000000..d9f5b35 --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/cssc/cms/WorkflowToCms.java @@ -0,0 +1,153 @@ +package weaver.xuanran.wang.cssc.cms; + +import aiyh.utils.Util; +import aiyh.utils.action.SafeCusBaseAction; +import aiyh.utils.annotation.ActionDesc; +import aiyh.utils.annotation.ActionOptionalParam; +import aiyh.utils.annotation.PrintParamMark; +import aiyh.utils.annotation.RequiredMark; +import weaver.hrm.User; +import weaver.soa.workflow.request.RequestInfo; +import weaver.xuanran.wang.cssc.cms.entity.CusSuccess; +import weaver.xuanran.wang.cssc.cms.service.WorkflowToCmsService; +import weaver.xuanran.wang.cssc.cms.service.impl.WorkFlowToCmsServiceImpl; + +/** + *

中国船舶研究所流程数据推送到科研综合管理系统

+ * + * @author xuanran.wang + * @date 2023/4/26 10:52 + */ +@ActionDesc(value = "中国船舶研究所流程数据推送到科研综合管理系统", author = "xuanran.wang") +public class WorkflowToCms extends SafeCusBaseAction { + private final WorkflowToCmsService workflowToCmsService = new WorkFlowToCmsServiceImpl(); + @PrintParamMark + @RequiredMark("建模配置文件唯一标识") + private String onlyMark; + + @PrintParamMark + private String tokenOnlyMark; + @PrintParamMark + private String tokenSuccessField; + @PrintParamMark + private String tokenSuccessVal; + @PrintParamMark + private String tokenMsg; + @PrintParamMark + private String tokenDataKey; + + + @PrintParamMark + @ActionOptionalParam(value = "code", desc = "接口成功标识字段") + private String successField; + @PrintParamMark + @ActionOptionalParam(value = "successVal", desc = "接口成功标识默认200") + private String successVal; + @PrintParamMark + @ActionOptionalParam(value = "message", desc = "报错返回信息字段") + private String msg; + @PrintParamMark + private String dataKey; + + @Override + public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) { + log.info("-------------- " + requestId + " begin --------------"); + CusSuccess cmsResponseVoField = CusSuccess + .builder() + .successField(Util.null2DefaultStr(successField, "success")) + .successValue(Util.null2DefaultStr(successVal, "true")) + .errorMsg(Util.null2DefaultStr(msg, "error")) + .dataKey(Util.null2DefaultStr(dataKey, "result.accessToken")) + .build(); + log.info(""); + + CusSuccess tokenSuccess = CusSuccess + .builder() + .successField(Util.null2DefaultStr(tokenSuccessField, "success")) + .successValue(Util.null2DefaultStr(tokenSuccessVal, "true")) + .errorMsg(Util.null2DefaultStr(tokenMsg, "error")) + .dataKey(Util.null2DefaultStr(tokenDataKey,"")) + .build(); + workflowToCmsService.workflowToCms(onlyMark,tokenOnlyMark, billTable, requestId,cmsResponseVoField, tokenSuccess); + } + + public String getOnlyMark() { + return onlyMark; + } + + public void setOnlyMark(String onlyMark) { + this.onlyMark = onlyMark; + } + + public String getSuccessField() { + return successField; + } + + public void setSuccessField(String successField) { + this.successField = successField; + } + + public String getSuccessVal() { + return successVal; + } + + public void setSuccessVal(String successVal) { + this.successVal = successVal; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public String getTokenOnlyMark() { + return tokenOnlyMark; + } + + public void setTokenOnlyMark(String tokenOnlyMark) { + this.tokenOnlyMark = tokenOnlyMark; + } + + public String getTokenSuccessField() { + return tokenSuccessField; + } + + public void setTokenSuccessField(String tokenSuccessField) { + this.tokenSuccessField = tokenSuccessField; + } + + public String getTokenSuccessVal() { + return tokenSuccessVal; + } + + public void setTokenSuccessVal(String tokenSuccessVal) { + this.tokenSuccessVal = tokenSuccessVal; + } + + public String getTokenMsg() { + return tokenMsg; + } + + public void setTokenMsg(String tokenMsg) { + this.tokenMsg = tokenMsg; + } + + public String getTokenDataKey() { + return tokenDataKey; + } + + public void setTokenDataKey(String tokenDataKey) { + this.tokenDataKey = tokenDataKey; + } + + public String getDataKey() { + return dataKey; + } + + public void setDataKey(String dataKey) { + this.dataKey = dataKey; + } +} diff --git a/src/main/java/weaver/xuanran/wang/cssc/cms/entity/CusSuccess.java b/src/main/java/weaver/xuanran/wang/cssc/cms/entity/CusSuccess.java new file mode 100644 index 0000000..ef44af1 --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/cssc/cms/entity/CusSuccess.java @@ -0,0 +1,27 @@ +package weaver.xuanran.wang.cssc.cms.entity; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import weaver.xuanran.wang.sh_bigdata.common.service.CusDataDecipher; + + +/** + *

自定义请求条件

+ * + * @author xuanran.wang + * @date 2023/4/6 19:34 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class CusSuccess { + private String successField; + private Object successValue; + private String errorMsg; + private String dataKey; + private Object response; + private CusDataDecipher cusDataDecipher; +} diff --git a/src/main/java/weaver/xuanran/wang/cssc/cms/service/WorkflowToCmsService.java b/src/main/java/weaver/xuanran/wang/cssc/cms/service/WorkflowToCmsService.java new file mode 100644 index 0000000..b30454f --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/cssc/cms/service/WorkflowToCmsService.java @@ -0,0 +1,14 @@ +package weaver.xuanran.wang.cssc.cms.service; + +import weaver.xuanran.wang.cssc.cms.entity.CusSuccess; + +/** + *

+ * + * @author xuanran.wang + * @date 2023/4/26 10:53 + */ +public interface WorkflowToCmsService { + String getToken(String onlyMark, String billTable, String requestId, CusSuccess cusSuccess); + void workflowToCms(String onlyMark,String tokenMark,String billTable, String requestId, CusSuccess cusSuccess, CusSuccess tokenSuccess); +} diff --git a/src/main/java/weaver/xuanran/wang/cssc/cms/service/impl/WorkFlowToCmsServiceImpl.java b/src/main/java/weaver/xuanran/wang/cssc/cms/service/impl/WorkFlowToCmsServiceImpl.java new file mode 100644 index 0000000..f3f65e7 --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/cssc/cms/service/impl/WorkFlowToCmsServiceImpl.java @@ -0,0 +1,73 @@ +package weaver.xuanran.wang.cssc.cms.service.impl; + +import aiyh.utils.Util; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.xiao.commons.config.entity.RequestMappingConfig; +import weaver.xiao.commons.config.service.DealWithMapping; +import weaver.xuanran.wang.common.util.CommonUtil; +import weaver.xuanran.wang.cssc.cms.entity.CusSuccess; +import weaver.xuanran.wang.cssc.cms.service.WorkflowToCmsService; +import weaver.xuanran.wang.cssc.cms.util.RequestMasterPlate; + +import java.util.HashMap; +import java.util.Map; + +/** + *

vms业务方法

+ * + * @Author xuanran.wang + * @Date 2022/12/1 10:58 + */ +public class WorkFlowToCmsServiceImpl implements WorkflowToCmsService { + private final DealWithMapping dealWithMapping = new DealWithMapping(); + private final Logger log = Util.getLogger(); // 获取日志对象 + private final RequestMasterPlate requestMasterPlate = new RequestMasterPlate(); + @Override + public String getToken(String onlyMark,String billTable, + String requestId, CusSuccess cusSuccess) { + RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(onlyMark); // 将配置参数通过唯一标识查询处理成树形结构 + RecordSet recordSet = initRs(requestMappingConfig, billTable, requestId); + String url = requestMappingConfig.getRequestUrl(); + dealWithMapping.setMainTable(billTable); + Map param = dealWithMapping.getRequestParam(recordSet, requestMappingConfig); + return requestMasterPlate.apiPost(url, param, new HashMap<>(), cusSuccess); + } + + /** + *

推送数据

+ * + * @param onlyMark 唯一编码 + * @param billTable 表名 + * @param requestId 请求id + * @author xuanran.wang + * @dateTime 2022/12/5 17:05 + **/ + @Override + public void workflowToCms(String onlyMark,String tokenMark, String billTable, + String requestId, CusSuccess cusSuccess, CusSuccess tokenSuccess) { + Map headers = new HashMap<>(); + if(StringUtils.isNotBlank(tokenMark)) { + String token = getToken(tokenMark, billTable, requestId, tokenSuccess); + headers.put("Authorization", "Bearer " + token); + } + RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(onlyMark); // 将配置参数通过唯一标识查询处理成树形结构 + RecordSet recordSet = initRs(requestMappingConfig, billTable, requestId); + String url = requestMappingConfig.getRequestUrl(); + dealWithMapping.setMainTable(billTable); + Map param = dealWithMapping.getRequestParam(recordSet, requestMappingConfig); + requestMasterPlate.apiPost(url, param, headers, cusSuccess); + } + + public RecordSet initRs( RequestMappingConfig requestMappingConfig, String billTable, String requestId){ + String selectMainSql = CommonUtil.getSelectSql(requestMappingConfig, billTable); + log.info(Util.logStr("查询主表数据sql : {}, requestId : {}", selectMainSql, requestId)); + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(selectMainSql, requestId); + recordSet.next(); + return recordSet; + } +} + + diff --git a/src/main/java/weaver/xuanran/wang/cssc/cms/util/RequestMasterPlate.java b/src/main/java/weaver/xuanran/wang/cssc/cms/util/RequestMasterPlate.java new file mode 100644 index 0000000..d2ed309 --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/cssc/cms/util/RequestMasterPlate.java @@ -0,0 +1,80 @@ +package weaver.xuanran.wang.cssc.cms.util; + +import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; +import aiyh.utils.httpUtil.ResponeVo; +import aiyh.utils.httpUtil.util.HttpUtils; +import com.alibaba.fastjson.JSON; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import weaver.xuanran.wang.cssc.cms.entity.CusSuccess; + +import javax.ws.rs.core.MediaType; +import java.io.IOException; +import java.util.Map; + +/** + *

请求模版方法

+ * + * @author xuanran.wang + * @date 2023/4/4 11:51 + */ +public class RequestMasterPlate { + private final Logger log = Util.getLogger(); + private final HttpUtils httpUtils = new HttpUtils(); + private static final int HTTP_SUCCESS_CODE = 200; + + public T apiGet(String url, Map params, Map headers, CusSuccess cusSuccess){ + ResponeVo responeVo; + try { + responeVo = httpUtils.apiGet(url, params, headers); + } catch (IOException e) { + throw new CustomerException(Util.logStr("发送请求发生异常! : {}", e.getMessage())); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串 + } + return parseResponse(url, responeVo, params, cusSuccess); + } + + public T apiPost(String url, Object o, Map headers, CusSuccess cusSuccess){ + ResponeVo responeVo; + try { + headers.put("Content-Type", MediaType.APPLICATION_JSON); + responeVo = httpUtils.apiPostObject(url, o, headers); + } catch (IOException e) { + throw new CustomerException(Util.logStr("发送请求发生异常! : {}", e.getMessage())); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串 + } + return parseResponse(url, responeVo, o, cusSuccess); + } + + public T parseResponse(String url, ResponeVo responseVo, Object o, CusSuccess cusSuccess){ + if (responseVo.getCode() != HTTP_SUCCESS_CODE) { // 相应状态码 + log.error(Util.logStr("can not fetch [{}],this request params is [{}]," + // 构建日志字符串 + "this request heard is [{}],but response status code is [{}]," + + "this response is [{}]", url, JSON.toJSON(o), JSON.toJSONString(httpUtils.getGlobalCache().header), responseVo.getCode(), // 相应状态码 + responseVo.getEntityString())); // 相应内容 + throw new CustomerException(Util.logStr("can not fetch [{}]", url)); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串 + } + Map response; + if(cusSuccess.getCusDataDecipher() != null){ + response = cusSuccess.getCusDataDecipher().decoder(responseVo); + }else { + response = responseVo.getResponseMap(); // 根据相应结果转化为map集合 + } + cusSuccess.setResponse(response); + String responseValue = Util.null2DefaultStr(response.get(cusSuccess.getSuccessField()), ""); + if (!cusSuccess.getSuccessValue().equals(responseValue)) { + throw new CustomerException(Util.logStr("接口地址:[{}], 接口响应码不为: [{}], 接口响应信息: {}", url, cusSuccess.getSuccessValue(), Util.null2DefaultStr(response.get(cusSuccess.getErrorMsg()), ""))); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串 + } + String[] split = Util.null2DefaultStr(cusSuccess.getDataKey(),"").split("\\."); + int len = split.length; + if(len == 0 || StringUtils.isBlank(cusSuccess.getDataKey())){ + return (T)response; + } + for (int i = 0; i < len - 1; i++) { + response = (Map) response.get(split[i]); + } + return (T) response.get(split[len - 1]); + } + + + +} diff --git a/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/action/WorkflowToSap.java b/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/action/WorkflowToSap.java new file mode 100644 index 0000000..46cc313 --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/action/WorkflowToSap.java @@ -0,0 +1,53 @@ +package weaver.xuanran.wang.eighty_five_degreec.sap.action; + +import aiyh.utils.ThreadPoolConfig; +import aiyh.utils.action.SafeCusBaseAction; +import aiyh.utils.annotation.ActionDesc; +import aiyh.utils.annotation.PrintParamMark; +import aiyh.utils.annotation.RequiredMark; +import weaver.hrm.User; +import weaver.soa.workflow.request.RequestInfo; +import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.MainRequestConfig; +import weaver.xuanran.wang.eighty_five_degreec.sap.service.WorkflowToSapService; +import weaver.xuanran.wang.eighty_five_degreec.sap.service.impl.WorkflowToSapServiceImpl; + +import java.util.concurrent.ExecutorService; + +/** + *

将流程数据推送到sap中

+ * + * @author xuanran.wang + * @date 2023/4/14 16:30 + */ +@ActionDesc(value = "流程数据推送到SAP",author = "xuanran.wang") +public class WorkflowToSap extends SafeCusBaseAction { + + private final WorkflowToSapService service = new WorkflowToSapServiceImpl(); + private final ExecutorService pool = ThreadPoolConfig.createThreadPoolInstance(); + @PrintParamMark + @RequiredMark("配置表唯一标识") + private String uniqueCode; + @PrintParamMark + @RequiredMark("日志表模块id") + private String modelId; + + @Override + public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) { + try { + MainRequestConfig config = service.getRequestConfig(uniqueCode, billTable); + String xml = service.convertXml(config, requestId, billTable); + String response = service.sendToSap(); + pool.execute(()->{ + try { + service.logToOA(modelId, config.getRequestUrl(), requestId, xml, response); + }catch (Exception e){ + log.error("日志数据写入建模失败! " + e.getMessage()); + } + }); + }catch (Exception e){ + log.error("流程数据推送SAP error : " + e.getMessage()); + } + + } + +} diff --git a/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/entity/eneity/DetailRequestConfig.java b/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/entity/eneity/DetailRequestConfig.java new file mode 100644 index 0000000..5509ef1 --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/entity/eneity/DetailRequestConfig.java @@ -0,0 +1,41 @@ +package weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity; + + +import aiyh.utils.annotation.recordset.SqlDbFieldAnn; +import aiyh.utils.annotation.recordset.SqlOracleDbFieldAnn; +import lombok.Data; + +/** + * @Author xuanran.wang + * @Date 2022/6/18 16:47 + */ +@Data +public class DetailRequestConfig { + @SqlDbFieldAnn("paramName") + @SqlOracleDbFieldAnn("PARAMNAME") + private String paramName; + @SqlDbFieldAnn("paramType") + @SqlOracleDbFieldAnn("PARAMTYPE") + private String paramType; + @SqlDbFieldAnn("getValueType") + @SqlOracleDbFieldAnn("GETVALUETYPE") + private String getValueType; + @SqlDbFieldAnn("valueContext") + @SqlOracleDbFieldAnn("VALUECONTEXT") + private String valueContext; + @SqlDbFieldAnn("tableName") + @SqlOracleDbFieldAnn("TABLENAME") + private String tableName; + @SqlDbFieldAnn("workFlowField") + @SqlOracleDbFieldAnn("WORKFLOWFIELD") + private String workFlowField; + @SqlDbFieldAnn("fieldName") + @SqlOracleDbFieldAnn("FIELDNAME") + private String fieldName; + @SqlDbFieldAnn("detailId") + @SqlOracleDbFieldAnn("DETAILID") + private String detailId; + @SqlDbFieldAnn("parentName") + @SqlOracleDbFieldAnn("PARENTNAME") + private String parentName; +} diff --git a/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/entity/eneity/MainRequestConfig.java b/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/entity/eneity/MainRequestConfig.java new file mode 100644 index 0000000..28f5c50 --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/entity/eneity/MainRequestConfig.java @@ -0,0 +1,47 @@ +package weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity; + + +import aiyh.utils.annotation.recordset.SqlDbFieldAnn; +import aiyh.utils.annotation.recordset.SqlOracleDbFieldAnn; +import lombok.Data; + +import java.util.List; + +/** + * @Author xuanran.wang + * @Date 2022/6/18 15:43 + */ +@Data +public class MainRequestConfig { + @SqlDbFieldAnn("id") + @SqlOracleDbFieldAnn("ID") + private String id; + @SqlDbFieldAnn("uniqueCode") + @SqlOracleDbFieldAnn("UNIQUECODE") + private String uniqueCode; + @SqlDbFieldAnn("workflow") + @SqlOracleDbFieldAnn("WORKFLOW") + private String workflow; + @SqlDbFieldAnn("requestUrl") + @SqlOracleDbFieldAnn("REQUESTURL") + private String requestUrl; + @SqlDbFieldAnn("dataSource") + @SqlOracleDbFieldAnn("DATASOURCE") + private String dataSource; + @SqlDbFieldAnn("detailIndex") + @SqlOracleDbFieldAnn("DETAILINDEX") + private String detailIndex; + @SqlDbFieldAnn("cusSql") + @SqlOracleDbFieldAnn("CUSSQL") + private String cusSql; + @SqlDbFieldAnn("configFilePath") + @SqlOracleDbFieldAnn("CONFIGFILEPATH") + private String configFilePath; + @SqlDbFieldAnn("enable") + @SqlOracleDbFieldAnn("ENABLE") + private String enable; + @SqlDbFieldAnn("methodParameterClassName") + @SqlOracleDbFieldAnn("METHODPARAMETERCLASSNAME") + private String methodParameterClassName; + private List detailRequestConfigList; +} diff --git a/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/service/WorkflowToSapService.java b/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/service/WorkflowToSapService.java new file mode 100644 index 0000000..0498b63 --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/service/WorkflowToSapService.java @@ -0,0 +1,16 @@ +package weaver.xuanran.wang.eighty_five_degreec.sap.service; + +import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.MainRequestConfig; + +/** + *

流程数据推送sap

+ * + * @author xuanran.wang + * @date 2023/4/19 15:15 + */ +public interface WorkflowToSapService { + MainRequestConfig getRequestConfig(String uniqueCode, String tableName); + String convertXml(MainRequestConfig config, String requestId, String tableName); + String sendToSap(); + void logToOA(String modelId, String url, String requestId, String requestXml, String response); +} diff --git a/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/service/impl/WorkflowToSapServiceImpl.java b/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/service/impl/WorkflowToSapServiceImpl.java new file mode 100644 index 0000000..b0aa755 --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/service/impl/WorkflowToSapServiceImpl.java @@ -0,0 +1,49 @@ +package weaver.xuanran.wang.eighty_five_degreec.sap.service.impl; + +import aiyh.utils.Util; +import weaver.xuanran.wang.common.util.CusInfoToOAUtil; +import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.MainRequestConfig; +import weaver.xuanran.wang.eighty_five_degreec.sap.service.WorkflowToSapService; +import weaver.xuanran.wang.eighty_five_degreec.sap.util.ReadConfigUtil; + +import java.util.Collections; +import java.util.HashMap; + + +/** + *

将流程数据推送至sap

+ * + * @author xuanran.wang + * @date 2023/4/19 15:17 + */ +public class WorkflowToSapServiceImpl implements WorkflowToSapService { + private final ReadConfigUtil configUtil = new ReadConfigUtil(); + + @Override + public MainRequestConfig getRequestConfig(String uniqueCode, String tableName) { + return configUtil.getConfigByUniqueCode(uniqueCode, tableName); + } + + @Override + public String convertXml(MainRequestConfig config, String requestId, String tableName) { + return configUtil.getXml(config, requestId, tableName); + } + + @Override + public String sendToSap() { + // TODO sap接口调用方式暂时搞不了 + return ""; + } + + @Override + public void logToOA(String modelId, String url, String requestId, + String requestXml, String response) { + HashMap params = new HashMap<>(); + params.put("requestUrlAndFunName", url); + params.put("reqId", requestId); + params.put("requestXml", requestXml); + params.put("responseCode",""); + params.put("erpResponse", response); + CusInfoToOAUtil.getDataId(Util.getIntValue(modelId, -1), params, "select id from #{tableName} where reqId = ?", Collections.singletonList(requestId)); + } +} diff --git a/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/util/ReadConfigUtil.java b/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/util/ReadConfigUtil.java new file mode 100644 index 0000000..d805dd1 --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/util/ReadConfigUtil.java @@ -0,0 +1,565 @@ +package weaver.xuanran.wang.eighty_five_degreec.sap.util; + +import com.google.common.base.Strings; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.general.GCONST; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.DetailRequestConfig; +import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.MainRequestConfig; +import weaver.zwl.common.ToolUtil; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStreamReader; +import java.lang.reflect.Field; +import java.nio.charset.StandardCharsets; +import java.security.SecureRandom; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +/** + * @Author xuanran.wang + * @Date 2022/11/14 11:33 + * 读取配置文件 + */ +public class ReadConfigUtil extends ToolUtil { + private static final int enable = 0; + private final Logger log = aiyh.utils.Util.getLogger(); + + /** + *

读取配置文件

+ * @param uniqueCode 唯一编码 + * @param mainTableName 主表名称 + * @return 配置对象 + */ + public MainRequestConfig getConfigByUniqueCode(String uniqueCode, String mainTableName){ + MainRequestConfig res = new MainRequestConfig(); + RecordSet queryRs = new RecordSet(); + String sql = "select * from uf_memsic_createXml where uniqueCode = ? and enable = ?"; + if (queryRs.executeQuery(sql, uniqueCode,enable)) { + if (queryRs.next()) { + res = getInstance(queryRs, MainRequestConfig.class); + } + } + if (res == null || StringUtils.isBlank(res.getId()) || (-1 == Util.getIntValue(res.getId(), -1))) { + throw new RuntimeException("配置不存在"); + } + int mainId = Util.getIntValue(res.getId()); + // 配置明细表 + sql = "select paramName,paramType,parentName,getValueType,workflowField,valueContext,fv.tableName," + + " fv.id fieldId,fv.fieldname,fv.indexdesc " + + " from uf_memsic_createXml_dt1 config " + + " left join workflow_field_table_view fv on config.workflowField = fv.id " + + " where mainid = ? and enable = ?"; + if (queryRs.executeQuery(sql, mainId,enable)) { + ArrayList detailConfigs = new ArrayList<>(); + while (queryRs.next()) { + DetailRequestConfig detailConfig = getInstance(queryRs, DetailRequestConfig.class); + String tableName = detailConfig.getTableName(); + // 主表默认0 + String detailId = "0"; + // 明细id替换 + if(!mainTableName.equals(detailConfig.getTableName())){ + detailId = tableName.replaceAll(mainTableName + "_dt", ""); + } + detailConfig.setDetailId(detailId); + detailConfigs.add(detailConfig); + } + res.setDetailRequestConfigList(detailConfigs); + } + return res; + } + + /** + *

获取对象

+ * @author xuanran.wang + * @dateTime 2022/11/15 22:20 + * @param queryRs 查询结果集 + * @param clazz 返回类class + * @return 返回类对象 + **/ + public static T getInstance(RecordSet queryRs, Class clazz) { + T res = null; + try { + res = clazz.newInstance(); + Field[] fields = clazz.getDeclaredFields(); + for (Field field : fields) { + // 判断字段类型 + if (field.getType().isAssignableFrom(List.class) || field.getType().isAssignableFrom(Map.class)) { + continue; + } + field.setAccessible(true); + String fieldName = field.getName(); + if ("oracle".equals(queryRs.getDBType())) { + fieldName = fieldName.toUpperCase(); + } + String value = Util.null2String(queryRs.getString(fieldName)); + field.set(res, value); + } + } catch (Exception e) { + throw new RuntimeException("实体类生成异常"); + } + return res; + } + + /** + *

获取参数值

+ * @param detailRequestConfig 配置文件 + * @param mainRs 主表recordSet + * @param detailRs 明细recordSet + * @return 参数值 + */ + public Object getParamValue(DetailRequestConfig detailRequestConfig, + RecordSet mainRs, RecordSet detailRs, int count){ + Object value = ""; + try { + // 参数类型 + String paramType = detailRequestConfig.getParamType(); + // 取值方式 + String getValueType = detailRequestConfig.getGetValueType(); + // 明细id + String detailId = detailRequestConfig.getDetailId(); + // 自定义文本 + String valueContext = detailRequestConfig.getValueContext(); + // 接口参数名称 + String paramName = detailRequestConfig.getParamName(); + // 父级参数名称 + String parentName = detailRequestConfig.getParentName(); + switch (getValueType){ + // 流程字段 + case "0":{ + String fieldName = detailRequestConfig.getFieldName(); + if("0".equals(detailId)){ + value = Util.null2String(mainRs.getString(fieldName)); + }else{ + value = Util.null2String(detailRs.getString(fieldName)); + } + break; + } + // 固定值 + case "1":{ + value = Util.null2String(detailRequestConfig.getValueContext()); + break; + } + // 当前时间 + case "3":{ + // 当前时间 + value = TimeUtil.getCurrentTimeString(); + break; + } + // 自定义sql + case "4":{ + String fieldName = detailRequestConfig.getFieldName(); + String tempValue; + if("0".equals(detailId)){ + tempValue = Util.null2String(mainRs.getString(fieldName)); + }else{ + tempValue = Util.null2String(detailRs.getString(fieldName)); + } + String requestId = Util.null2String(mainRs.getString("requestid")); + value = getValueByChangeRule(detailRequestConfig.getValueContext(), tempValue, requestId); + break; + } + // 请求id + case "5" : { + value = Util.null2String(mainRs.getString("requestid")); + }break; + // 主数据id + case "6": { + if ("mainRecord".equals(parentName)) { + value = Util.null2String(mainRs.getString("id")); + } else { + value = Util.null2String(detailRs.getString("id")); + } + }break; + // 随机数 + case "7": { + int bit = Util.getIntValue(valueContext, 10); + value = this.getGUID(bit); + }break; + case "9":{ + value = count; + }break; + default:break; + } + // 参数类型 + switch (paramType){ + // String + case "0":{ + value = Util.null2String(value); + value = String.valueOf(value).replaceAll(" ", " ") + .replaceAll("
", " ") + .replaceAll("&", "&") + .replaceAll("<", "<") + .replaceAll(">", ">") + .replaceAll("\"", """) + .replaceAll("'", "'"); + break; + } + // Int + case "1":{ + value = Util.getIntValue(String.valueOf(value),0); + break; + } + // Double + case "2":{ + value = Util.getDoubleValue(String.valueOf(value),0); + break; + } + //日期类型 + case "3" : { + if (null == value || Strings.isNullOrEmpty(String.valueOf(value))) { + value = ""; + break; + } + try { + Date date = value instanceof Date ? (Date) value : parseDate(String.valueOf(value)); + value = this.diyDateFortMat(date, "yyyy-MM-dd"); + } catch (Exception e) { + throw new RuntimeException("时间处理异常:参数>>" + paramName); + } + }break; + // 时间日期类型 + case "4": { + if (null == value || Strings.isNullOrEmpty(String.valueOf(value))) { + value = ""; + break; + } + try { + Date date = value instanceof Date ? (Date) value : parseDate(String.valueOf(value)); + value = this.diyDateFortMat(date, "yyyy-MM-dd HH:mm:ss"); + } catch (Exception e) { + throw new RuntimeException("时间处理异常:参数>>" + paramName + " 异常信息:" + e); + } + } + break; + // 自定义时间格式化类型 + case "7": { + if (null == value || Strings.isNullOrEmpty(String.valueOf(value))) { + value = ""; + break; + } + try { + Date date = value instanceof Date ? (Date) value : parseDate(String.valueOf(value)); + value = this.diyDateFortMat(date, valueContext); + } catch (Exception e) { + throw new RuntimeException("时间处理异常:参数>>" + paramName + " 异常信息:" + e.getMessage()); + } + } + break; + // 时间戳类型 + case "8": { + if (null == value || Strings.isNullOrEmpty(String.valueOf(value))) { + value = ""; + break; + } + try { + Date date = value instanceof Date ? (Date) value : parseDate(String.valueOf(value)); + value = date.getTime(); + } catch (Exception e) { + throw new RuntimeException("时间处理异常:参数>>" + paramName + " 异常信息:" + e.getMessage()); + } + }break; + default:break; + } + }catch (Exception e){ + throw new RuntimeException("执行setCommonParamValue发生异常 : " + e.getMessage()); + } + return value; + } + + /** + *

日期解析

+ * @param dateStr 日期字符串 + * @return 日期对象 + */ + public static Date parseDate(String dateStr) { + ThreadLocal SIMPLE_DATE_FORMAT = ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyy-MM-dd")); + if (dateStr == null || dateStr.length() == 0) { + return null; + } + String regex = "\\/|\\.|年|月|日"; + Date date = null; + try { + date = SIMPLE_DATE_FORMAT.get().parse(dateStr.replaceAll(regex, "-")); + return date; + } catch (ParseException e) { + throw new RuntimeException("无法将" + dateStr + "转换为日期对象!", e); + } + } + + /** + *

自定义时间格式化

+ * @param date 日期 + * @param tempStr 格式化字符串 + * @return 格式化字符串 + */ + private static String diyDateFortMat(Date date,String tempStr){ + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(tempStr); + return simpleDateFormat.format(date); + } + + /** + *

根据配置对象生成xml

+ * @param config 配置对象 + * @param requestId 请求id + * @param tableName 表名 + * @return xml + */ + public String getXml(MainRequestConfig config, String requestId,String tableName){ + try { + String configFilePath = config.getConfigFilePath(); + if(StringUtils.isBlank(configFilePath)){ + throw new RuntimeException("建模主表配置文件不能为空!"); + } + String requestUrl = config.getRequestUrl(); + if(StringUtils.isBlank(requestUrl)){ + throw new RuntimeException("获取配置文件明细表为空!"); + } + List requestConfigList = config.getDetailRequestConfigList(); + if(CollectionUtils.isEmpty(requestConfigList)){ + throw new RuntimeException("获取配置文件明细表为空!"); + } + String sql = "select * from " + tableName + " where requestid = ?"; + if(StringUtils.isNotBlank(config.getCusSql())){ + sql += config.getCusSql(); + } + String dataSource = config.getDataSource(); + RecordSet mainRs = new RecordSet(); + RecordSet detailRs = new RecordSet(); + mainRs.executeQuery(sql, requestId); + log.info("执行主表查询SQL[ " + sql + " ], 参数 [ " + requestId + " ]"); + if (mainRs.next()) { + String mainId = mainRs.getString("id"); + String mainXml = ""; + String detailXml = ""; + // 主表 + if ("0".equals(dataSource)) { + mainXml = getMainXml(requestConfigList, mainRs, detailRs); + } else if("1".equals(dataSource)) { + // 仅明细 + detailXml = getDetailXml(requestConfigList, mainRs, detailRs, config.getDetailIndex(), tableName, mainId); + }else { + // 主表-明细 + mainXml = getMainXml(requestConfigList, mainRs, detailRs); + detailXml = getDetailXml(requestConfigList, mainRs, detailRs, config.getDetailIndex(), tableName, mainId); + } + StringBuilder xml = new StringBuilder(); + try { + String filePath = parseConfigPath(configFilePath); + log.info("模板配置文件路径 [ " + filePath + " ]"); + FileInputStream in = new FileInputStream(filePath); + InputStreamReader inReader = new InputStreamReader(in, StandardCharsets.UTF_8); + BufferedReader bufReader = new BufferedReader(inReader); + String line; + while ((line = bufReader.readLine()) != null) { + if(line.contains("{mainRecord}")){ + line = mainXml; + xml.append(line); + }else if(line.contains("{detailRecord}")){ + line = detailXml; + xml.append(line); + }else { + if(StringUtils.isNotBlank(line)){ + String pattern = "(?<=\\{).+(?=})"; + Pattern compile = Pattern.compile(pattern); + Matcher matcher = compile.matcher(line); + while (matcher.find()){ + String field = matcher.group(); + if(StringUtils.isNotBlank(field)){ + if(field.startsWith("main.")){ + String mainField = field.replace("main.", ""); + line = line.replaceAll("#\\{.+}",Util.null2String(mainRs.getString(mainField))); + }else if(field.startsWith("sql.")){ + String selectSql = field.replace("sql.", ""); + Matcher matcherSql = compile.matcher(selectSql); + while (matcherSql.find()){ + String sqlField = matcherSql.group(); + String value = Util.null2String(mainRs.getString(sqlField)); + String replaceAllSql = selectSql.replaceAll("#\\{.+}", "\\?"); + line = line.replaceAll("#\\{.+}",Util.null2String(getValueByChangeRule(replaceAllSql,value, requestId))); + } + } + } + } + } + xml.append(line).append("\n"); + } + } + bufReader.close(); + inReader.close(); + in.close(); + } catch (Exception e) { + throw new RuntimeException("读取配置文件失败!文件路径=> " + configFilePath + " error => " + e.getMessage()); + } + return xml.toString(); + } + }catch (Exception e){ + throw new RuntimeException("生成xml发生异常, " + e.getMessage()); + } + return ""; + } + + /** + *

获取主xml

+ * @param requestConfigList 配置明细集合 + * @param mainRs 主表recordSet + * @param detailRs 明细recordSet + * @return 主表xml + */ + public String getMainXml(List requestConfigList, + RecordSet mainRs, + RecordSet detailRs){ + List collect = requestConfigList.stream() + .filter(item -> "mainRecord".equals(item.getParentName())) + .collect(Collectors.toList()); + StringBuilder mainSb = new StringBuilder(); + appendXml(mainSb, collect, mainRs, detailRs,1); + return mainSb.toString(); + } + + /** + *

获取明细xml

+ * @param requestConfigList 配置集合 + * @param mainRs 主表recordSet + * @param detailRs 明细表recordSet + * @param detailIndex 明细下标 + * @param tableName 表名 + * @param mainId 主数据id + * @return 明细xml + */ + public String getDetailXml(List requestConfigList, + RecordSet mainRs, RecordSet detailRs, String detailIndex, + String tableName, String mainId){ + // 明细 + String[] detailIdArr = detailIndex.split(","); + StringBuilder detailSb = new StringBuilder(); + for (String detailId : detailIdArr) { + List detailCollect = requestConfigList.stream() + .filter(item -> "detailRecord".equals(item.getParentName()) + ).collect(Collectors.toList()); + String detailSql = "select * from " + tableName + "_dt" + detailId + " where mainid = ?"; + if (detailRs.executeQuery(detailSql, mainId)) { + int count = 1; + while (detailRs.next()) { + appendXml(detailSb, detailCollect, mainRs, detailRs, count++); + } + } + } + return detailSb.toString(); + } + + /** + *

xml拼接

+ * @param xml xml对象 + * @param configList 配置对象集合 + * @param mainRs 主表recordSet + * @param detailRs 明细recordSet + * @param count 序号 + */ + public void appendXml(StringBuilder xml, List configList, + RecordSet mainRs, RecordSet detailRs, int count){ + for (DetailRequestConfig requestConfig : configList) { + String paramName = requestConfig.getParamName(); + xml.append("<") + .append(paramName) + .append(">") + .append(getParamValue(requestConfig, mainRs, detailRs,count)) + .append("<") + .append(paramName) + .append(">") + .append("\n"); + } + } + + /** + *

解析请求xml模板位置

+ * wxr.memsic.test.xml = /wxr/memsic/test.xml + * @param configFilePath 模板文件路径 + * @return 解析后的文件路径 + */ + public String parseConfigPath(String configFilePath){ + StringBuilder filePath = new StringBuilder(GCONST.getSysFilePath()); + int beginIndex = configFilePath.indexOf("."); + int endIndex = configFilePath.lastIndexOf("."); + if(beginIndex == endIndex){ + filePath.append(configFilePath); + }else { + String[] pathArr = configFilePath.split("\\."); + for (int i = 0; i < pathArr.length - 2; i++) { + if(i != 0){ + filePath.append(File.separator); + } + filePath.append(pathArr[i]); + } + filePath.append(File.separator) + .append(pathArr[pathArr.length - 2]) + .append(".") + .append(pathArr[pathArr.length - 1]); + } + return filePath.toString(); + } + + private String getGUID(int bit) { + StringBuilder uid = new StringBuilder(); + // 产生16位的强随机数 + Random rd = new SecureRandom(); + for (int i = 0; i < bit; i++) { + // 产生0-2的3位随机数 + int type = rd.nextInt(3); + switch (type) { + case 0: + // 0-9的随机数 + uid.append(rd.nextInt(10)); + break; + case 1: + // ASCII在65-90之间为大写,获取大写随机 + uid.append((char) (rd.nextInt(25) + 65)); + break; + case 2: + // ASCII在97-122之间为小写,获取小写随机 + uid.append((char) (rd.nextInt(25) + 97)); + break; + default: + break; + } + } + return uid.toString(); + } + + + /** + *

解析响应数据

+ * @param responseMap 响应map + * @param responseField 需要从map中获取指定字段的标识 Response.Execution + * @return 响应数据 + */ + public String parseMap(Map responseMap, String responseField){ + String[] strArr = responseField.split("\\."); + int i = 0; + while (i < strArr.length - 1){ + Object o = responseMap.get(strArr[i]); + if(o instanceof Map){ + responseMap = (Map) o; + }else if(o instanceof List){ + List> list = (List>) o; + if(CollectionUtils.isEmpty(list)){ + return ""; + } + responseMap = list.get(0); + } + i++; + } + return Util.null2String(responseMap.get(strArr[strArr.length - 1])); + } + +} diff --git a/src/main/java/weaver/xuanran/wang/immc/service/WorkFlowToVmsAndMQService.java b/src/main/java/weaver/xuanran/wang/immc/service/WorkFlowToVmsAndMQService.java index 84d08ef..6de58fa 100644 --- a/src/main/java/weaver/xuanran/wang/immc/service/WorkFlowToVmsAndMQService.java +++ b/src/main/java/weaver/xuanran/wang/immc/service/WorkFlowToVmsAndMQService.java @@ -13,14 +13,18 @@ import org.apache.kafka.clients.producer.ProducerRecord; import org.apache.kafka.clients.producer.RecordMetadata; import org.apache.log4j.Logger; import weaver.conn.RecordSet; +import weaver.general.GCONST; import weaver.xiao.commons.config.entity.RequestMappingConfig; import weaver.xiao.commons.config.service.DealWithMapping; import weaver.xuanran.wang.common.util.CommonUtil; import weaver.xuanran.wang.immc.entity.VmsResponseVoField; import javax.ws.rs.core.MediaType; -import java.io.IOException; +import java.io.*; +import java.nio.file.Files; +import java.util.HashMap; import java.util.Map; +import java.util.Properties; /** *

vms业务方法

@@ -115,32 +119,41 @@ public class WorkFlowToVmsAndMQService { **/ public void sendToMQ(String kafkaConfig, Map message){ KafkaProducer producer = null; + InputStream inputStream = null; try { - Map configMap = Util.getProperties2Map(kafkaConfig); - if(MapUtils.isEmpty(configMap)){ + String path = GCONST.getPropertyPath() + "prop2map" + File.separator + kafkaConfig + ".properties"; + File configFile = new File(path); + if(!configFile.exists()){ throw new CustomerException("please check /web-inf/prop2map has " + kafkaConfig + ".properties"); } - log.info("kafkaConfig : " + JSONObject.toJSONString(configMap)); - String topic = Util.null2DefaultStr(configMap.get("topic"),""); + Properties prop = new Properties(); + inputStream= new BufferedInputStream(Files.newInputStream(configFile.toPath())); + prop.load(inputStream); + log.info("prop => " + JSONObject.toJSONString(prop)); + log.info("msg => " + JSONObject.toJSONString(message)); + String topic = Util.null2DefaultStr(prop.getProperty("topic"),""); if(StringUtils.isBlank(topic)){ throw new CustomerException("kafka properties topic can not null!"); } - producer = new KafkaProducer<>(configMap); + producer = new KafkaProducer<>(prop); // 发送消息到指定主题 ProducerRecord record = new ProducerRecord<>(topic, JSONObject.toJSONString(message)); - try { - RecordMetadata recordMetadata = producer.send(record).get(); - log.info(Util.logStr("send mq recordMetadata: {}", JSONObject.toJSONString(recordMetadata))); - }catch (Exception e){ - throw new CustomerException(Util.logStr("producer send error: {}!", e.getMessage())); - } + producer.send(record).get(); }catch (Exception e){ - throw new CustomerException(Util.logStr("send to kafka error!: {}", e.getMessage())); + log.error(Util.getErrString(e)); + throw new CustomerException(Util.logStr("send to kafka error!: [{}]", e.getMessage())); }finally { // 关闭Kafka生产者实例 if(producer != null){ producer.close(); } + if(inputStream != null){ + try { + inputStream.close(); + }catch (Exception e){ + log.error("inputStream close error! " + e.getMessage()); + } + } } } diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/common/entity/CusSuccess.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/common/entity/CusSuccess.java index 75622c5..1750741 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/common/entity/CusSuccess.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/common/entity/CusSuccess.java @@ -4,8 +4,8 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import weaver.xuanran.wang.sh_bigdata.common.service.CusDataDecipher; -import java.util.function.Consumer; /** *

自定义请求条件

@@ -23,4 +23,5 @@ public class CusSuccess { private String errorMsg; private String dataKey; private Object response; + private CusDataDecipher cusDataDecipher; } diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/common/service/CusDataDecipher.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/common/service/CusDataDecipher.java new file mode 100644 index 0000000..7e56528 --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/common/service/CusDataDecipher.java @@ -0,0 +1,15 @@ +package weaver.xuanran.wang.sh_bigdata.common.service; + +import aiyh.utils.httpUtil.ResponeVo; + +import java.util.Map; + +/** + *

自定义解密类

+ * + * @author xuanran.wang + * @date 2023/4/10 13:20 + */ +public interface CusDataDecipher { + Map decoder(ResponeVo responeVo); +} diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/RequestMasterPlate.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/RequestMasterPlate.java index b638132..beb3b3c 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/RequestMasterPlate.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/RequestMasterPlate.java @@ -5,7 +5,6 @@ import aiyh.utils.excention.CustomerException; import aiyh.utils.httpUtil.ResponeVo; import aiyh.utils.httpUtil.util.HttpUtils; import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; import weaver.xuanran.wang.sh_bigdata.common.entity.CusSuccess; @@ -52,11 +51,16 @@ public class RequestMasterPlate{ responseVo.getEntityString())); // 相应内容 throw new CustomerException(Util.logStr("can not fetch [{}]", url)); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串 } - Map response = responseVo.getResponseMap(); // 根据相应结果转化为map集合 + Map response; + if(cusSuccess.getCusDataDecipher() != null){ + response = cusSuccess.getCusDataDecipher().decoder(responseVo); + }else { + response = responseVo.getResponseMap(); // 根据相应结果转化为map集合 + } cusSuccess.setResponse(response); int responseValue = Util.getIntValue(Util.null2DefaultStr(response.get(cusSuccess.getSuccessField()), ""),-1); if (cusSuccess.getSuccessValue() != responseValue) { - throw new CustomerException(Util.logStr("接口响应码不为: [{}], 接口响应信息: {}", cusSuccess.getSuccessValue(), Util.null2DefaultStr(response.get(cusSuccess.getErrorMsg()), ""))); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串 + throw new CustomerException(Util.logStr("接口地址:[{}], 接口响应码不为: [{}], 接口响应信息: {}", url, cusSuccess.getSuccessValue(), Util.null2DefaultStr(response.get(cusSuccess.getErrorMsg()), ""))); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串 } String[] split = Util.null2DefaultStr(cusSuccess.getDataKey(),"").split("\\."); int len = split.length; diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/SendTodoTaskUtil.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/SendTodoTaskUtil.java index 6810040..1a796ff 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/SendTodoTaskUtil.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/SendTodoTaskUtil.java @@ -26,7 +26,7 @@ import java.util.stream.Collectors; public class SendTodoTaskUtil { private final SendTodoTaskMapper mapper = Util.getMapper(SendTodoTaskMapper.class); private final CommonMapper commonMapper = Util.getMapper(CommonMapper.class); - private String appId; + private String agentId; private String oaAddress; private Logger log = Util.getLogger(); @@ -71,11 +71,11 @@ public class SendTodoTaskUtil { int requestId = obj.getRequestid(); int userId = obj.getUser().getUID(); todoTask.setTaskNum(taskId); - todoTask.setAppId(appId); + todoTask.setAgentid(agentId); todoTask.setTaskName(obj.getRequestnamenew()); todoTask.setTaskDesc(obj.getRequestnamenew()); - todoTask.setLinkUrl(oaAddress + "/spa/workflow/static4form/index.html?#/main/workflow/req?requestid="+requestId); - todoTask.setMobileLinkUrl(oaAddress + "/spa/workflow/static4mobileform/index.html?#/req?requestid="+requestId); + todoTask.setLinkUrl(Util.null2DefaultStr(ShBigDataUtil.getPropertiesValByKey("taskPcUrl"), oaAddress) + "/spa/workflow/static4form/index.html?#/main/workflow/req?requestid="+requestId); + todoTask.setMobileLinkUrl(Util.null2DefaultStr(ShBigDataUtil.getPropertiesValByKey("taskMobileUrl"), oaAddress) + "/spa/workflow/static4mobileform/index.html?#/req?requestid="+requestId); todoTask.setSender(getConvertHrm(0, obj, obj.getCreator().getUID() + "")); todoTask.setReceiver(getConvertHrm(1, obj,userId + "")); res.add(todoTask); @@ -99,7 +99,7 @@ public class SendTodoTaskUtil { CusDoneTask doneTask = new CusDoneTask(); doneTask.setTaskNum(num); doneTask.setStatus(1); - doneTask.setAppId(appId); + doneTask.setAgentid(agentId); res.add(doneTask); } } @@ -156,11 +156,10 @@ public class SendTodoTaskUtil { * @return OA地址 **/ public String getOAAddress(){ - String address = mapper.queryOAAddress(); - if(StringUtils.isBlank(address)){ - throw new CustomerException("OAAddress can not null!"); - } - return address; + // if(StringUtils.isBlank(address)){ +// throw new CustomerException("OAAddress can not null!"); +// } + return Util.null2DefaultStr(mapper.queryOAAddress(),""); } diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/ShBigDataUtil.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/ShBigDataUtil.java index 5688afc..bcf46c6 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/ShBigDataUtil.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/ShBigDataUtil.java @@ -2,11 +2,9 @@ package weaver.xuanran.wang.sh_bigdata.common.util; import aiyh.utils.Util; import aiyh.utils.excention.CustomerException; -import com.alibaba.fastjson.JSONObject; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringUtils; -import weaver.xuanran.wang.sh_bigdata.common.entity.CusSuccess; -import weaver.xuanran.wang.sh_bigdata.common.entity.CusToken; +import weaver.general.TimeUtil; import weaver.xuanran.wang.sh_bigdata.org_hrm_async.annotations.CusDbEntityMapping; import java.lang.reflect.Field; @@ -28,6 +26,15 @@ public class ShBigDataUtil { static { WHILTE_LIST.add("hrmSenderConvertRuleSql"); WHILTE_LIST.add("hrmReceiveConvertRuleSql"); + WHILTE_LIST.add("maxLevel"); + WHILTE_LIST.add("orgNoFetchChild"); + WHILTE_LIST.add("orgUpdateTime"); + WHILTE_LIST.add("hrmUpdateTime"); + WHILTE_LIST.add("orgHrmAsyncLogModelId"); + WHILTE_LIST.add("loginSuccessSendRedirectUrl"); + WHILTE_LIST.add("loginErrorSendRedirectUrl"); + WHILTE_LIST.add("getUserIdDebug"); + WHILTE_LIST.add("getUserIdDebugOutKey"); } /** @@ -37,7 +44,18 @@ public class ShBigDataUtil { * @return token **/ public static String getToken(){ - return TokenUtil.getToken(); + return TokenUtil.getToken(ShBigDataUtil.getPropertiesValByKey("corpSecret")); + } + + /** + *

获取token

+ * @author xuanran.wang + * @dateTime 2023/4/6 19:59 + * @param secret 密钥 + * @return token + **/ + public static String getToken(String secret){ + return TokenUtil.getToken(secret); } /** @@ -51,6 +69,18 @@ public class ShBigDataUtil { return url + "?access_token=" + getToken(); } + /** + *

给post请求的url添加token

+ * @author xuanran.wang + * @dateTime 2023/4/6 20:11 + * @param url 路径 + * @param secret 密钥 + * @return 添加完token的路径url + **/ + public static String addToken2Url(String url, String secret){ + return url + "?access_token=" + getToken(secret); + } + /** *

获取配置文件

* @author xuanran.wang @@ -90,6 +120,19 @@ public class ShBigDataUtil { * @return 参数 **/ public static LinkedHashMap parseCusDbEntityMapping(int type, Object o) throws IllegalAccessException { + return parseCusDbEntityMapping(type, 0, false); + } + + /** + *

解析注解并将实体类转换成map

+ * @author xuanran.wang + * @dateTime 2023/4/6 12:27 + * @param type 表类型 0: 分部, 1: 部门 + * @param o 对象 + * @param addSysParam 是否添加系统默认参数 + * @return 参数 + **/ + public static LinkedHashMap parseCusDbEntityMapping(int type, Object o, boolean addSysParam) throws IllegalAccessException { Class clazz = o.getClass(); LinkedHashMap params = new LinkedHashMap<>(); Field[] fields = clazz.getDeclaredFields(); @@ -103,18 +146,28 @@ public class ShBigDataUtil { if(cusDbEntityMapping != null){ String[] dbFields = cusDbEntityMapping.dbFiled(); String dbField; - if(dbFields.length == 0 || type == -1){ - dbField = field.getName(); + if(dbFields.length <= 1 || type == -1){ + dbField = dbFields[0]; }else { - int index = Math.min(dbFields.length, type); - dbField = dbFields[index - 1]; + dbField = dbFields[type]; + } + if(StringUtils.isBlank(dbField)){ + continue; } field.setAccessible(true); params.put(dbField, field.get(o)); } } + if(addSysParam){ + String dateTime = TimeUtil.getCurrentTimeString(); + params.put("creater",1); + params.put("created", dateTime); + params.put("modifier", 1); + params.put("modified", dateTime); + } return params; } + } diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/TokenUtil.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/TokenUtil.java index 706bf4c..f9ae238 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/TokenUtil.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/TokenUtil.java @@ -10,6 +10,7 @@ import weaver.xuanran.wang.sh_bigdata.common.entity.CusToken; import java.util.Date; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; /** *

token 工具类

@@ -19,39 +20,43 @@ import java.util.Map; */ public class TokenUtil { private static final Logger log = Util.getLogger(); - private static volatile CusToken cusToken = null; +// private static volatile CusToken cusToken = null; private static final CusSuccess tokenCusSuccess = CusSuccess.builder() .successField("errcode") .successValue(0) - .errorMsg("msg") + .errorMsg("errmsg") .dataKey("") .build(); private static final RequestMasterPlate requestMasterPlate = new RequestMasterPlate(); + private static final Map TOKEN_MAP = new ConcurrentHashMap<>(); /** *

获取token

* @author xuanran.wang * @dateTime 2023/4/6 19:59 * @return token + * @param secret 密钥 **/ - public static String getToken() { - if(cusToken == null){ + public static String getToken(String secret) { + CusToken token = TOKEN_MAP.get(secret); + if(token == null){ synchronized (TokenUtil.class){ - if(cusToken == null){ - return getTokenByHTTP(); + token = TOKEN_MAP.get(secret); + if(token == null){ + return getTokenByHTTP(secret); } } } - long expiryTime = cusToken.getExpiryTime(); + long expiryTime = token.getExpiryTime(); if(new Date().getTime() >= expiryTime){ synchronized (TokenUtil.class){ - expiryTime = cusToken.getExpiryTime(); + expiryTime = token.getExpiryTime(); if(new Date().getTime() >= expiryTime){ - return getTokenByHTTP(); + return getTokenByHTTP(secret); } } } - return cusToken.getAccess_token(); + return token.getAccess_token(); } /** @@ -60,19 +65,20 @@ public class TokenUtil { * @dateTime 2023/4/7 23:49 * @return token **/ - private static String getTokenByHTTP(){ + private static String getTokenByHTTP(String secret){ + log.info("getTokenByHTTP secret : " + secret); HashMap params = new HashMap<>(); // 接口调用地址 String tokenUrl = ShBigDataUtil.getPropertiesValByKey("tokenUrl"); // 密钥 - String corpSecret = ShBigDataUtil.getPropertiesValByKey("corpSecret"); - params.put("corpsecret", corpSecret); + params.put("corpsecret", secret); Map tokenMap = requestMasterPlate.apiGet(tokenUrl, params, new HashMap<>(), tokenCusSuccess); - cusToken = JSONObject.parseObject(JSONObject.toJSONString(tokenMap), CusToken.class); + CusToken token = JSONObject.parseObject(JSONObject.toJSONString(tokenMap), CusToken.class); long expiryBeforeTime = Util.getIntValue(ShBigDataUtil.getPropertiesValByKey("expiryBeforeTime"), 5); // 默认少5分钟过期 - cusToken.setExpiryTime(new Date().getTime() + (cusToken.getExpires_in() * 1000) - (60 * expiryBeforeTime * 1000)); - log.info("http token => " + JSONObject.toJSONString(cusToken)); - return cusToken.getAccess_token(); + token.setExpiryTime(new Date().getTime() + (token.getExpires_in() * 1000) - (60 * expiryBeforeTime * 1000)); + TOKEN_MAP.put(secret, token); + log.info("token maps : " + JSONObject.toJSONString(TOKEN_MAP)); + return token.getAccess_token(); } } diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/OrganizationHrmSyncFromOtherSys.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/OrganizationHrmSyncFromOtherSys.java index 7e2b8d2..c4e5c18 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/OrganizationHrmSyncFromOtherSys.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/OrganizationHrmSyncFromOtherSys.java @@ -1,9 +1,16 @@ package weaver.xuanran.wang.sh_bigdata.org_hrm_async; +import aiyh.utils.Util; +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; import weaver.hrm.resource.HrmSynDAO; import weaver.interfaces.hrm.*; +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.service.OrgHrmAsyncService; +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.service.impl.OrgHrmAsyncServiceImpl; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -15,17 +22,29 @@ import java.util.Map; public class OrganizationHrmSyncFromOtherSys implements HrmSynService { private HashMap synResult; + private final OrgHrmAsyncService asyncService = new OrgHrmAsyncServiceImpl(); + + private final Logger log = Util.getLogger(); + public OrganizationHrmSyncFromOtherSys(){ this.removeSynResult(); } @Override public String SynTimingToOASubCompany() { + List> subCompany = asyncService.asyncOrgDep(0); + List> list = buildItemList(subCompany); + this.synResult.put("1", list); + log.info("subCompany : \n" + JSONObject.toJSONString(list)); return null; } @Override public String SynTimingToOADepartment() { + List> subCompany = asyncService.asyncOrgDep(1); + List> list = buildItemList(subCompany); + this.synResult.put("2", list); + log.info("department : \n" + JSONObject.toJSONString(list)); return null; } @@ -36,6 +55,10 @@ public class OrganizationHrmSyncFromOtherSys implements HrmSynService { @Override public String SynTimingToOAHrmResource() { + List> hrmList = asyncService.asyncHrm(); + List> list = buildItemList(hrmList); + this.synResult.put("4", list); + log.info("hrmresource : \n" + JSONObject.toJSONString(list)); return null; } @@ -93,6 +116,18 @@ public class OrganizationHrmSyncFromOtherSys implements HrmSynService { this.synResult = new HashMap<>(); } + private List> buildItemList(List> list){ + List> synResultlist = new ArrayList<>(); + for (Map map : list) { + String id = Util.null2DefaultStr(map.get("id"), ""); + String name = Util.null2DefaultStr(map.get("name"), ""); + String code = Util.null2DefaultStr(map.get("code"), ""); + String msg = Util.null2DefaultStr(map.get("msg"), ""); + synResultlist.add(buildItemMap(id, id, name, code, msg)); + } + return synResultlist; + } + private Map buildItemMap(String pkCode, String pk, String memo, String success, String error) { //保存结果 Map res = new HashMap<>(); @@ -103,4 +138,6 @@ public class OrganizationHrmSyncFromOtherSys implements HrmSynService { res.put(HrmSynDAO.ErrorMessage, error); return res; } + + } diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/annotations/CusOrgHrmAsyncConvert.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/annotations/CusOrgHrmAsyncConvert.java new file mode 100644 index 0000000..53e47ea --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/annotations/CusOrgHrmAsyncConvert.java @@ -0,0 +1,16 @@ +package weaver.xuanran.wang.sh_bigdata.org_hrm_async.annotations; + +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OrgHrmAsyncCache; +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OrgHrmAsyncConfigDetail; + +import java.util.Map; + +/** + *

自定义转换接口

+ * + * @author xuanran.wang + * @date 2023/4/11 16:49 + */ +public interface CusOrgHrmAsyncConvert { + Object cusConvert(OrgHrmAsyncConfigDetail detail, OrgHrmAsyncCache cache, Map pathParam); +} diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/entity/OrgHrmAsyncCache.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/entity/OrgHrmAsyncCache.java new file mode 100644 index 0000000..56902e1 --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/entity/OrgHrmAsyncCache.java @@ -0,0 +1,43 @@ +package weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.HashMap; +import java.util.Map; + +/** + *

人员同步接口缓存对象

+ * + * @author xuanran.wang + * @date 2023/4/11 17:19 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class OrgHrmAsyncCache { + /** + *

分部缓存

+ **/ + private Map subCompanyCache; + /** + *

部门缓存

+ **/ + private Map departmentCache; + /** + *

接口数据

+ **/ + private Map interfaceVal; + /** + *

人员缓存

+ **/ + private Map hrmCache; + /** + *

岗位缓存

+ **/ + private Map jobTitleCache; + private int arrIndex; +} diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/entity/OrgHrmAsyncConfigDetail.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/entity/OrgHrmAsyncConfigDetail.java new file mode 100644 index 0000000..2a9b914 --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/entity/OrgHrmAsyncConfigDetail.java @@ -0,0 +1,30 @@ +package weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity; + +import aiyh.utils.annotation.recordset.SqlDbFieldAnn; +import aiyh.utils.annotation.recordset.SqlOracleDbFieldAnn; +import lombok.Data; + +/** + *

组织架构同步配置表-明细

+ * + * @author xuanran.wang + * @date 2023/4/11 15:08 + */ +@Data +public class OrgHrmAsyncConfigDetail { + @SqlDbFieldAnn("interfaceField") + @SqlOracleDbFieldAnn("INTERFACEFIELD") + private String interfaceField; + @SqlDbFieldAnn("oaField") + @SqlOracleDbFieldAnn("OAFIELD") + private String oaField; + @SqlDbFieldAnn("fieldType") + @SqlOracleDbFieldAnn("FIELDTYPE") + private int fieldType; + @SqlDbFieldAnn("convertType") + @SqlOracleDbFieldAnn("CONVERTTYPE") + private int convertType; + @SqlDbFieldAnn("cusText") + @SqlOracleDbFieldAnn("CUSTEXT") + private String cusText; +} diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/entity/OrgHrmAsyncConfigMain.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/entity/OrgHrmAsyncConfigMain.java new file mode 100644 index 0000000..3cb71be --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/entity/OrgHrmAsyncConfigMain.java @@ -0,0 +1,39 @@ +package weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity; + +import aiyh.utils.annotation.recordset.SqlDbFieldAnn; +import aiyh.utils.annotation.recordset.SqlOracleDbFieldAnn; +import lombok.Data; + +import java.util.List; + +/** + *

组织架构同步配置表

+ * + * @author xuanran.wang + * @date 2023/4/11 15:05 + */ +@Data +public class OrgHrmAsyncConfigMain { + @SqlDbFieldAnn("asyncType") + @SqlOracleDbFieldAnn("ASYNCTYPE") + private int asyncType; + @SqlDbFieldAnn("updateTableName") + @SqlOracleDbFieldAnn("UPDATETABLENAME") + private String updateTableName; + @SqlDbFieldAnn("cusWhere") + @SqlOracleDbFieldAnn("CUSWHERE") + private String cusWhere; + @SqlDbFieldAnn("primaryKey") + @SqlOracleDbFieldAnn("PRIMARYKEY") + private String primaryKey; + @SqlDbFieldAnn("foreignKey") + @SqlOracleDbFieldAnn("FOREIGNKEY") + private String foreignKey; + @SqlDbFieldAnn("cusDepartment") + @SqlOracleDbFieldAnn("CUSDEPARTMENT") + private String cusDepartment; + @SqlDbFieldAnn("cudSubCompany") + @SqlOracleDbFieldAnn("CUDSUBCOMPANY") + private String cudSubCompany; + private List orgHrmAsyncConfigDetailList; +} diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/entity/OtherSysDepartment.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/entity/OtherSysDepartment.java index aacf42a..a427ef4 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/entity/OtherSysDepartment.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/entity/OtherSysDepartment.java @@ -1,7 +1,9 @@ package weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity; import aiyh.utils.annotation.recordset.SqlDbFieldAnn; +import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; import weaver.xuanran.wang.sh_bigdata.org_hrm_async.annotations.CusDbEntityMapping; import java.util.List; @@ -14,6 +16,8 @@ import java.util.List; * @date 2023/4/4 11:03 */ @Data +@AllArgsConstructor +@NoArgsConstructor public class OtherSysDepartment { /** *

创建的部门id

@@ -37,17 +41,26 @@ public class OtherSysDepartment { **/ @CusDbEntityMapping(dbFiled = {"showorder"}) private int order; - /** - *

所属分部id

- **/ - @CusDbEntityMapping(dbFiled = {"supsubcomid","supsubcomid1"}) - private int subCompanyId; /** *

* 是否有子部门,0:否,1:是 *

**/ private int hasChild; + /** + *

层级

+ **/ + @CusDbEntityMapping(dbFiled = {"tlevel"}) + private int level; + /** + *

删除 0:有效

+ **/ + private int isDeleted; + /** + *

所属分部

+ **/ + @CusDbEntityMapping(dbFiled = {"","subcompanyid1"}) + private int division; private List childList; } diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/job/OrganizationHrmSyncJob.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/job/OrganizationHrmSyncJob.java new file mode 100644 index 0000000..c3b96d8 --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/job/OrganizationHrmSyncJob.java @@ -0,0 +1,146 @@ +package weaver.xuanran.wang.sh_bigdata.org_hrm_async.job; + +import aiyh.utils.ThreadPoolConfig; +import aiyh.utils.Util; +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import weaver.interfaces.schedule.BaseCronJob; +import weaver.xuanran.wang.common.util.CusInfoToOAUtil; +import weaver.xuanran.wang.sh_bigdata.common.util.ShBigDataUtil; +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.service.OrgHrmAsyncService; +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.service.impl.OrgHrmAsyncServiceImpl; + +import java.util.*; +import java.util.concurrent.ExecutorService; +import java.util.function.Function; + +/** + *

组织架构-人员同步 计划任务

+ * + * @author xuanran.wang + * @date 2023/4/14 11:51 + */ +public class OrganizationHrmSyncJob extends BaseCronJob { + private final OrgHrmAsyncService asyncService = new OrgHrmAsyncServiceImpl(); + private final Logger log = Util.getLogger(); + private String orgHrmAsyncLogModelId; + private final ExecutorService executorService = ThreadPoolConfig.createThreadPoolInstance(); + private String asyncType; + private static final String ALL_ASYNC = ""; + private static final String ORG_COMPANY_ASYNC = "1"; + private static final String HRMRESOURCE_ASYNC = "2"; + private final Map> maps = new HashMap<>(); + + { + try { + orgHrmAsyncLogModelId = ShBigDataUtil.getPropertiesValByKey("orgHrmAsyncLogModelId"); + }catch (Exception e){ + log.error("orgHrmAsyncLogModelId init error!"); + } + maps.put(ORG_COMPANY_ASYNC, (o)->{ + orgAsync(); + return ""; + }); + maps.put(ALL_ASYNC, (o)->{ + orgAsync(); + hrmAsync(); + return ""; + }); + maps.put(HRMRESOURCE_ASYNC, (o)->{ + hrmAsync(); + return ""; + }); + } + + @Override + public void execute() { + if(StringUtils.isNotBlank(orgHrmAsyncLogModelId)){ + try { + asyncType = Util.null2DefaultStr(asyncType, ""); + log.info("asyncType : [ " + asyncType + " ]"); + Function function = maps.get(asyncType); + if(function != null){ + function.apply(""); + } + }catch (Exception e){ + log.error("OrganizationHrmSyncJob execute error! " + e.getMessage()); + log.info(Util.getErrString(e)); + } + } + } + /** + *

组织架构同步

+ * @author xuanran.wang + * @dateTime 2023/4/14 16:12 + **/ + private void orgAsync(){ + List> subCompanyList = asyncService.asyncOrgDep(0); + poolExecute(subCompanyList, 0); + List> departmentList = asyncService.asyncOrgDep(1); + poolExecute(departmentList, 1); + } + + /** + *

人员同步

+ * @author xuanran.wang + * @dateTime 2023/4/14 16:12 + **/ + private void hrmAsync(){ + List> hrmList = asyncService.asyncHrm(); + poolExecute(hrmList, 2); + } + + /** + *

线程池提交任务

+ * @author xuanran.wang + * @dateTime 2023/4/14 14:11 + * @param list 数据 + **/ + private void poolExecute(List> list, int type){ + executorService.execute(()->{ + try { + log.info("subCompanyList : \n" + JSONObject.toJSONString(list)); + List> convert = convert(list, type); + CusInfoToOAUtil.executeBatch(Util.getIntValue(this.orgHrmAsyncLogModelId, -1), convert); + }catch (Exception e){ + log.info("写入日志建模异常! " + e.getMessage()); + } + }); + } + + /** + *

将同步数据转换成日志记录map对象

+ * @author xuanran.wang + * @dateTime 2023/4/14 14:12 + * @param dataList 数据集合 + * @param type 同步类型 + * @return 转换后的集合 + **/ + private List> convert(List> dataList, int type){ + List> res = new ArrayList<>(); + for (Map map : dataList) { + LinkedHashMap linkedHashMap = new LinkedHashMap<>(); + linkedHashMap.put("asyncType", type); + // 0 是失败 1是插入 2 是更新 + int success = Util.getIntValue(Util.null2DefaultStr(map.get("code"), ""), 0); + // 建模表 数据同步状态 成功是0 1是失败 + linkedHashMap.put("status", success == 0 ? 1 : 0); + // 建模表 更新/插入 更新是0 插入是1 + linkedHashMap.put("updateOrInsert", success == 2 ? 0 : 1); + linkedHashMap.put("msg", Util.null2DefaultStr(map.get("msg"), "")); + linkedHashMap.put("outPk", Util.null2DefaultStr(map.get("id"), "")); + linkedHashMap.put("dataName", Util.null2DefaultStr(map.get("name"), "")); + res.add(linkedHashMap); + } + return res; + } + + public String getAsyncType() { + return asyncType; + } + + public void setAsyncType(String asyncType) { + this.asyncType = asyncType; + } +} diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/mapper/OrgHrmAsyncMapper.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/mapper/OrgHrmAsyncMapper.java index 769ae6f..bd8943a 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/mapper/OrgHrmAsyncMapper.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/mapper/OrgHrmAsyncMapper.java @@ -1,11 +1,10 @@ package weaver.xuanran.wang.sh_bigdata.org_hrm_async.mapper; -import aiyh.utils.annotation.recordset.Select; -import aiyh.utils.annotation.recordset.SqlMapper; -import aiyh.utils.annotation.recordset.SqlString; -import aiyh.utils.annotation.recordset.Update; -import io.swagger.models.auth.In; +import aiyh.utils.annotation.recordset.*; +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OrgHrmAsyncConfigDetail; +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OrgHrmAsyncConfigMain; +import java.util.List; import java.util.Map; /** @@ -17,9 +16,80 @@ import java.util.Map; @SqlMapper public interface OrgHrmAsyncMapper { - @Select("select outkey, id from HrmSubCompany where outkey != '' and outkey is not null") - Map selectSubCompany(); + /** + *

查询配置表主表信息

+ * @author xuanran.wang + * @dateTime 2023/3/1 16:39 + * @return 主表配置对象 + **/ + @Select("select * from uf_org_hrm_async where asyncType = #{asyncType}") + @CollectionMappings({ + @CollectionMapping(property = "orgHrmAsyncConfigDetailList", + column = "id", + id = @Id(value = Integer.class, methodId = 1)) + }) + List selectSubCompanyAsyncConfig(@ParamMapper("asyncType") int asyncType); + + /** + *

查询配置表明细表信息

+ * @author xuanran.wang + * @dateTime 2023/3/1 16:39 + * @param mainId 主表数据id + * @return 配置集合 + **/ + @Select("select * from uf_org_hrm_async_dt1 where mainid = #{mainId}") + @CollectionMethod(1) + List selectSubCompanyAsyncConfigDetail(@ParamMapper("mainId") int mainId); + + @Select("select outkey, id from HrmSubCompany where outkey <> '' and outkey is not null") + List> selectSubCompanyAll(); + + @Select("select outkey, id from hrmdepartment where outkey <> '' and outkey is not null") + List> selectDepartmentAll(); + + @Select("select outkey, id, tlevel from HrmSubCompany where outkey <> '' and outkey is not null and canceled <> 1") + List> selectSubCompanyActive(); + + @Select("select outkey, id from hrmdepartment where outkey <> '' and outkey is not null and canceled <> 1") + List> selectDepartmentActive(); + + @Select("select jobtitlename,id from hrmjobtitles") + List> selectJobTitle(); + + @Select("select id from hrmjobtitles where jobtitlename = #{jobTitleName}") + String selectJobTitleByName(@ParamMapper("jobTitleName") String jobTitleName); + + @Insert("insert into hrmjobtitles(jobtitlemark, jobtitlename, creater, created) values(#{position}, #{position}, 1, #{jobCreateTime})") + boolean insertJobTitle(Map params); @Update(custom = true) - boolean updateSubInfo(@SqlString String sql, Map params); + boolean updateOrgInfo(@SqlString String sql, Map params); + + @Select("select interfaceDataId from uf_depart_or_sub where depOrSub = 0") + List selectCusSubCompany(); + + @Select("select interfaceDataId from uf_depart_or_sub where depOrSub = 1") + List selectCusDepart(); + + @Select(custom = true) + String selectCustomerSql(@SqlString String sql, Map map); + @Select(custom = true) + List selectCustomerSqlArr(@SqlString String sql, Map map); + @Update("update HrmSubCompany set canceled = 1 where outkey in (${outKeys})") + boolean updateHrmSubCompanyCanceled(List outKeys); + + @Update("update hrmdepartment set canceled = 1 where outkey in (${outKeys})") + boolean updateHrmDepartmentCanceled(List outKeys); + + @Select("select min(outkey) from hrmsubcompany where outkey <> '' and outkey is not null") + String selectTopLevelOutKey(); + + @Select("select outkey, id from hrmresource ") + List> selectHrmIdAndOutKey(); + + @Insert(custom = true) + boolean insertHrmInfo(@SqlString String sql, Map params); + + @Select("select 1 from hrmresource where departmentid = (select id from hrmdepartment where outkey = #{outKey})") + int selectDepartHasUser(@ParamMapper("outKey") String outKey); } diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/service/OrgHrmAsyncApiService.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/service/OrgHrmAsyncApiService.java index 8d23e7c..2474287 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/service/OrgHrmAsyncApiService.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/service/OrgHrmAsyncApiService.java @@ -1,8 +1,10 @@ package weaver.xuanran.wang.sh_bigdata.org_hrm_async.service; +import com.icbc.api.internal.apache.http.impl.cookie.S; import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OtherSysDepartment; import java.util.List; +import java.util.Map; /** *

上海大数据中心人员/组织架构同步 接口调用

@@ -14,12 +16,13 @@ public interface OrgHrmAsyncApiService { /** - *

获取用户信息

+ *

获取用户信息 通过传入顶级组织id 并且递归获取所有用户

* @author xuanran.wang * @dateTime 2023/4/4 11:13 + * @param topLevelId 三方系统顶级组织id * @return 响应对象 **/ - List getUserInfo(); + List> getUserInfo(int topLevelId); /** *

获取部门信息

@@ -29,4 +32,12 @@ public interface OrgHrmAsyncApiService { **/ List getDepartmentInfo(); + /** + *

获取部门信息

+ * @author xuanran.wang + * @dateTime 2023/4/4 11:13 + * @return 响应对象 + **/ + List> getDepartmentInfoMap(); + } diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/service/OrgHrmAsyncService.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/service/OrgHrmAsyncService.java index c7d1cf7..2a184a3 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/service/OrgHrmAsyncService.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/service/OrgHrmAsyncService.java @@ -1,6 +1,5 @@ package weaver.xuanran.wang.sh_bigdata.org_hrm_async.service; -import io.swagger.models.auth.In; import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OtherSysDepartment; import java.util.List; @@ -14,13 +13,6 @@ import java.util.Map; */ public interface OrgHrmAsyncService { - /** - *

获取分部表中 outKey 与 id对应到map集合

- * @author xuanran.wang - * @dateTime 2023/4/6 13:44 - * @return 分部表中 outKey 与 id对应到map集合 - **/ - Map initSubCompany(); /** *

部门数据同步

* @author xuanran.wang @@ -28,4 +20,13 @@ public interface OrgHrmAsyncService { **/ List asyncDepartment(); + /** + *

部门数据同步

+ * @author xuanran.wang + * @dateTime 2023/4/6 13:44 + **/ + List> asyncOrgDep(int type); + + List> asyncHrm(); + } diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/service/impl/OrgHrmAsyncApiServiceImpl.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/service/impl/OrgHrmAsyncApiServiceImpl.java index d4ba595..0f2ea17 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/service/impl/OrgHrmAsyncApiServiceImpl.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/service/impl/OrgHrmAsyncApiServiceImpl.java @@ -1,6 +1,8 @@ package weaver.xuanran.wang.sh_bigdata.org_hrm_async.service.impl; +import aiyh.utils.Util; import com.alibaba.fastjson.JSONObject; +import com.engine.common.service.impl.ThemeServiceImpl; import weaver.xuanran.wang.sh_bigdata.common.entity.CusSuccess; import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OtherSysDepartment; import weaver.xuanran.wang.sh_bigdata.org_hrm_async.service.OrgHrmAsyncApiService; @@ -22,23 +24,30 @@ import java.util.Map; */ public class OrgHrmAsyncApiServiceImpl implements OrgHrmAsyncApiService { private final RequestMasterPlate requestMasterPlate = new RequestMasterPlate(); - @Override - public List getUserInfo() { - return null; - } @Override - public List getDepartmentInfo() { - String departmentInfoUrl = ShBigDataUtil.getPropertiesValByKey("departmentInfoUrl"); + public List> getUserInfo(int topLevelId) { + String departmentInfoUrl = ShBigDataUtil.getPropertiesValByKey("userInfoUrl"); HashMap params = new HashMap<>(); params.put("access_token", ShBigDataUtil.getToken()); + params.put("department_id", topLevelId); + params.put("no_fetch_child", 1); + // 如果hrmUpdateTime则获取增量数据 + if(1 == Util.getIntValue(ShBigDataUtil.getPropertiesValByKey("hrmUpdateTime"),0)){ + params.put("updateTime", System.currentTimeMillis()); + } CusSuccess cusSuccess = CusSuccess.builder() .successField("code") .successValue(0) .errorMsg("msg") - .dataKey("data.department") + .dataKey("data.userList") .build(); - List> list = requestMasterPlate.apiGet(departmentInfoUrl, params, new HashMap<>(), cusSuccess); + return requestMasterPlate.apiGet(departmentInfoUrl, params, new HashMap<>(), cusSuccess); + } + + @Override + public List getDepartmentInfo() { + List> list = getDepartmentInfoMap(); List res = new ArrayList<>(); for (Object o : list) { res.add(JSONObject.parseObject(JSONObject.toJSONString(o), OtherSysDepartment.class)); @@ -46,4 +55,24 @@ public class OrgHrmAsyncApiServiceImpl implements OrgHrmAsyncApiService { return res; } + @Override + public List> getDepartmentInfoMap() { + String departmentInfoUrl = ShBigDataUtil.getPropertiesValByKey("departmentInfoUrl"); + HashMap params = new HashMap<>(); + params.put("access_token", ShBigDataUtil.getToken()); + params.put("no_fetch_child", Util.getIntValue(ShBigDataUtil.getPropertiesValByKey("orgNoFetchChild"),0)); + // orgUpdateTime = 1 进行增量数据同步 + if(1 == Util.getIntValue(ShBigDataUtil.getPropertiesValByKey("orgUpdateTime"),0)){ + params.put("updateTime", System.currentTimeMillis()); + } + CusSuccess cusSuccess = CusSuccess.builder() + .successField("code") + .successValue(0) + .errorMsg("msg") + .dataKey("data.department") + .build(); + return requestMasterPlate.apiGet(departmentInfoUrl, params, new HashMap<>(), cusSuccess); + } + + } diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/service/impl/OrgHrmAsyncEntityServiceImpl.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/service/impl/OrgHrmAsyncEntityServiceImpl.java new file mode 100644 index 0000000..e0f7cf7 --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/service/impl/OrgHrmAsyncEntityServiceImpl.java @@ -0,0 +1,265 @@ +package weaver.xuanran.wang.sh_bigdata.org_hrm_async.service.impl; + +import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.collections.CollectionUtils; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.matrix.MatrixUtil; +import weaver.xuanran.wang.sh_bigdata.common.util.ShBigDataUtil; +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OtherSysDepartment; +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.mapper.OrgHrmAsyncMapper; +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.service.OrgHrmAsyncApiService; +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.service.OrgHrmAsyncService; +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.util.OrgHrmAsyncUtil; + +import java.util.*; +import java.util.stream.Collectors; + +/** + *

组织架构同步

+ * + * @author xuanran.wang + * @date 2023/4/6 10:10 + */ +public class OrgHrmAsyncEntityServiceImpl implements OrgHrmAsyncService { + private final Logger log = Util.getLogger(); + private final OrgHrmAsyncApiService orgHrmAsyncApiService = new OrgHrmAsyncApiServiceImpl(); + private final OrgHrmAsyncMapper orgHrmAsyncMapper = Util.getMapper(OrgHrmAsyncMapper.class); + private final SubCompanyComInfo sci = new SubCompanyComInfo(); + /** + *

配置表中部门白名单

+ **/ + private final List departmentWhiteList; + /** + *

配置表中分部白名单

+ **/ + private final List subCompanyWhiteList; + /** + *

分部缓存

+ **/ + private Map subCompanyCache = new HashMap<>(); + /** + *

部门缓存

+ **/ + private Map departmentCache = new HashMap<>(); + /** + *

分部最大层级

+ **/ + int maxLevel; + /** + *

接口中 上级分部字段

+ **/ + private String interfaceSupSubCompany; + + { + departmentWhiteList = orgHrmAsyncMapper.selectCusDepart(); + subCompanyWhiteList = orgHrmAsyncMapper.selectCusSubCompany(); + + List> subCompany = orgHrmAsyncMapper.selectSubCompanyAll(); + subCompanyCache = OrgHrmAsyncUtil.parseListMap2Map(subCompany); + + List> department = orgHrmAsyncMapper.selectDepartmentAll(); + departmentCache = OrgHrmAsyncUtil.parseListMap2Map(department); + maxLevel = Util.getIntValue(ShBigDataUtil.getPropertiesValByKey("maxLevel"), 3); + + } + + + @Override + public List asyncDepartment() { + List departmentInfo = orgHrmAsyncApiService.getDepartmentInfo(); + // 将部门信息转换成树 + List convetList = Util.listToTree(departmentInfo, + OtherSysDepartment::getId, OtherSysDepartment::getParentid, + OtherSysDepartment::getChildList, OtherSysDepartment::setChildList, + parentid -> parentid == -1); + // 进行部门分部解析 + List hrmSubCompany = new ArrayList<>(); + List hrmDepartment = new ArrayList<>(); + // 解析是部门还是分部 + parseSubCompanyAndDepartment(convetList, 0, maxLevel, hrmSubCompany, hrmDepartment); + // 进行顺序排序 + hrmSubCompany = hrmSubCompany.stream().sorted(Comparator.comparingInt(OtherSysDepartment::getId)).collect(Collectors.toList()); + hrmDepartment = hrmDepartment.stream().sorted(Comparator.comparingInt(OtherSysDepartment::getId)).collect(Collectors.toList()); + System.out.println("hrmSubCompany => " + JSONObject.toJSONString(hrmSubCompany)); + System.out.println("hrmDepartment => " + JSONObject.toJSONString(hrmDepartment)); + // 同步 + addHrmSubCompany(hrmSubCompany); + addHrmDepartment(hrmDepartment); + + return departmentInfo; + } + + + /** + *

同步数据到分部

+ * @author xuanran.wang + * @dateTime 2023/4/6 13:37 + * @param departmentList 部门数据集合 + **/ + public void addHrmSubCompany(List departmentList){ + char separator = weaver.general.Util.getSeparator(); + RecordSet rsSch = new RecordSet(); + for (OtherSysDepartment department : departmentList) { + int subId = Util.getIntValue(Util.null2DefaultStr(subCompanyCache.get(department.getId()),""),-1); + if(subId < 0){ + String para = department.getName() + separator + department.getName() + separator + "1" + separator + + department.getId()+ separator + "" + separator +department.getOrder(); + rsSch.executeProc("HrmSubCompany_Insert", para); + if (rsSch.next()) { + subId = rsSch.getInt(1); + } + subCompanyCache.put(department.getId() + "", subId); + } + department.setParentid(Util.getIntValue(Util.null2DefaultStr(subCompanyCache.get(department.getParentid()),""),0)); + updateTable("HrmSubCompany", subId, 0, department); + } + //清除全部分部缓存 + sci.removeCompanyCache(); + } + + /** + *

同步数据到分部

+ * @author xuanran.wang + * @dateTime 2023/4/6 13:37 + * @param departmentList 部门数据集合 + **/ + public void addHrmDepartment(List departmentList){ + char separator = weaver.general.Util.getSeparator(); + RecordSet rsSch = new RecordSet(); + for (OtherSysDepartment department : departmentList) { + int id = Util.getIntValue(Util.null2DefaultStr(departmentCache.get(department.getId()), ""),-1); + if(id < 0){ + String para = department.getName() + separator + department.getName() + separator + + "" + separator + "" + separator + department.getParentid() + separator + department.getOrder() + separator + ""; + rsSch.executeProc("HrmDepartment_Insert", para); + if (rsSch.next()) { + id = rsSch.getInt(1); + } + departmentCache.put(department.getId() + "", id); + } + System.out.println("departmentCache => " + JSONObject.toJSONString(departmentCache)); + System.out.println("subCompanyCache => " + JSONObject.toJSONString(subCompanyCache)); + System.out.println("department => " + JSONObject.toJSONString(department)); + int parentid = department.getParentid(); + department.setParentid(Util.getIntValue(Util.null2DefaultStr(departmentCache.get(parentid),""),0)); + // 如果一个分部从 分部变成了部门 那么他下面所有的都是部门 在设置所属分部的时候要将 分部的所属分部替换 + int division = Util.getIntValue(Util.null2DefaultStr(subCompanyCache.get(parentid), ""), -1); + department.setDivision(division); + updateTable("HrmDepartment", id, 1, department); + } + //清除全部分部缓存 + sci.removeCompanyCache(); + } + + + /** + *

解析部门or分部

+ * @author xuanran.wang + * @dateTime 2023/4/10 12:13 + * @param list 树形集合 + * @param n 层级 + * @param hrmSubCompany 分部 + * @param hrmDepartment 部门 + **/ + public void parseSubCompanyAndDepartment(List list, int n, int maxLevel,List hrmSubCompany, List hrmDepartment){ + n++; + for (OtherSysDepartment department : list) { + department.setLevel(n); + List childList = department.getChildList(); + String departmentId = department.getId() + ""; + if(CollectionUtils.isNotEmpty(childList)){ + List collect = department.getChildList().stream().map(item -> Util.null2DefaultStr(item.getId(), "")).collect(Collectors.toList()); + if(departmentWhiteList.contains(departmentId)){ + departmentWhiteList.addAll(collect); + }else if(subCompanyWhiteList.contains(departmentId)){ + subCompanyWhiteList.addAll(collect); + } + parseSubCompanyAndDepartment(childList, n, maxLevel, hrmSubCompany, hrmDepartment); + department.setChildList(new ArrayList<>()); + } + if(n > maxLevel || departmentWhiteList.contains(departmentId)){ + hrmDepartment.add(department); + }else{ + hrmSubCompany.add(department); + } + } + } + + /** + *

更新表数据

+ * @author xuanran.wang + * @dateTime 2023/4/6 13:35 + * @param tableName 表名 + * @param id 数据id + * @param type 类型 + * @param o 对象 + **/ + public void updateTable(String tableName, int id, int type, Object o){ + StringBuilder sb = new StringBuilder("update "); + sb.append(tableName).append(" set "); + Map params; + try { + params = ShBigDataUtil.parseCusDbEntityMapping(type, o, true); + }catch (Exception e){ + throw new CustomerException("parseCusDbEntityMapping error!" + e.getMessage()); + } + for (Map.Entry entry : params.entrySet()) { + sb.append(entry.getKey()) + .append(" = #{") + .append(entry.getKey()) + .append("},"); + } + sb.deleteCharAt(sb.length() - 1); + sb.append(" where id = ").append(id); + boolean success = orgHrmAsyncMapper.updateOrgInfo(sb.toString(), params); + if(!success){ + log.error(Util.logStr("update {} sql error!", tableName)); + } + //同步分部数据到矩阵 + MatrixUtil.updateSubcompayData(String.valueOf(id)); + } + + @Override + public List> asyncOrgDep(int type) { + return new ArrayList<>(); + } + + @Override + public List> asyncHrm() { + return null; + } + + + /** + *

解析部门or分部

+ * @author xuanran.wang + * @dateTime 2023/4/10 12:13 + * @param list 树形集合 + * @param n 层级 + * @param hrmSubCompany 分部 + * @param hrmDepartment 部门 + **/ +// public void parseSubCompanyAndDepartment(List list, int n, int maxLevel,List hrmSubCompany, List hrmDepartment){ +// n++; +// for (OtherSysDepartment department : list) { +// department.setLevel(n); +// List childList = department.getChildList(); +// if(CollectionUtils.isNotEmpty(childList)){ +// parseSubCompanyAndDepartment(childList, n, maxLevel, hrmSubCompany, hrmDepartment); +// department.setChildList(null); +// } +// String departmentId = department.getId() + ""; +// if(n > maxLevel || departmentWhiteList.contains(departmentId)){ +// hrmDepartment.add(department); +// }else if(n < maxLevel || subCompanyWhiteList.contains(departmentId)){ +// hrmSubCompany.add(department); +// } +// } +// } + + +} diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/service/impl/OrgHrmAsyncServiceImpl.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/service/impl/OrgHrmAsyncServiceImpl.java index b3500d8..a44e23b 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/service/impl/OrgHrmAsyncServiceImpl.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/service/impl/OrgHrmAsyncServiceImpl.java @@ -1,21 +1,33 @@ package weaver.xuanran.wang.sh_bigdata.org_hrm_async.service.impl; +import aiyh.utils.ThreadPoolConfig; import aiyh.utils.Util; import aiyh.utils.excention.CustomerException; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.service.impl.ThemeServiceImpl; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.hrm.company.DepartmentComInfo; import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.resource.ResourceComInfo; import weaver.matrix.MatrixUtil; +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OrgHrmAsyncCache; +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OrgHrmAsyncConfigMain; import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OtherSysDepartment; import weaver.xuanran.wang.sh_bigdata.org_hrm_async.mapper.OrgHrmAsyncMapper; import weaver.xuanran.wang.sh_bigdata.org_hrm_async.service.OrgHrmAsyncApiService; import weaver.xuanran.wang.sh_bigdata.org_hrm_async.service.OrgHrmAsyncService; import weaver.xuanran.wang.sh_bigdata.common.util.ShBigDataUtil; +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.util.OrgHrmAsyncUtil; -import java.util.Comparator; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.concurrent.ExecutorService; +import java.util.function.Function; import java.util.stream.Collectors; +import ln.LN; /** *

组织架构同步

@@ -24,65 +36,346 @@ import java.util.stream.Collectors; * @date 2023/4/6 10:10 */ public class OrgHrmAsyncServiceImpl implements OrgHrmAsyncService { + private final Logger log = Util.getLogger(); private final OrgHrmAsyncApiService orgHrmAsyncApiService = new OrgHrmAsyncApiServiceImpl(); - private final OrgHrmAsyncMapper orgHrmAsyncMapper = Util.getMapper(OrgHrmAsyncMapper.class); - private final SubCompanyComInfo sci = new SubCompanyComInfo(); + private final DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + private ResourceComInfo comInfo = null; + /** + *

配置表中部门白名单

+ **/ + private final List departmentWhiteList; + /** + *

配置表中分部白名单

+ **/ + private final List subCompanyWhiteList; + /** + *

分部缓存

+ **/ + private final Map subCompanyCache; + /** + *

部门缓存

+ **/ + private final Map departmentCache; + /** + *

岗位缓存

+ **/ + private final Map jobTitleCache; + /** + *

人员缓存

+ **/ + private final Map hrmCache; + /** + *

分部最大层级

+ **/ + int maxLevel; + /** + *

分部同步配置表对象

+ **/ + private final List subCompanyConfig; + /** + *

部门同步配置表对象

+ **/ + private final List departmentConfig; + /** + *

人员同步配置表对象

+ **/ + private final List hrmReSourceConfig; + /** + *

分部同步记录

+ **/ + private final List> asyncHrmSubCompany = new ArrayList<>(); + /** + *

部门同步记录

+ **/ + private final List> asyncHrmDepartment = new ArrayList<>(); + private final Map typeTableName = new HashMap<>(); + private final HashMap> getNextIdTypeMap = new HashMap<>(); + private final Map subCompanyLevelCache; - @Override - public Map initSubCompany() { - return orgHrmAsyncMapper.selectSubCompany(); + // 创建按order值进行排序的比较器 + Comparator> orderByOrder = (o1, o2) -> { + int order1 = (int) o1.get("order"); + int order2 = (int) o2.get("order"); + if (order1 != order2) { + return Integer.compare(order2, order1); + } else { + int id1 = (int) o1.get("id"); + int id2 = (int) o2.get("id"); + return Integer.compare(id1, id2); + } + }; + + // 创建按id值进行排序的比较器 + Comparator> orderById = (o1, o2) -> { + int id1 = (int) o1.get("id"); + int id2 = (int) o2.get("id"); + return Integer.compare(id1, id2); + }; + + private RecordSet procRs = new RecordSet(); + + ExecutorService threadPoolInstance = ThreadPoolConfig.createThreadPoolInstance(); + + private final ThemeServiceImpl themeService = new ThemeServiceImpl(); + + { + // ========================= 白名单初始化 ========================= +// departmentWhiteList = orgHrmAsyncMapper.selectCusDepart(); + departmentWhiteList = new ArrayList<>(); +// subCompanyWhiteList = orgHrmAsyncMapper.selectCusSubCompany(); + subCompanyWhiteList = new ArrayList<>(); + // ================================================================ + + // ========================= 部门&分部&岗位&用户 缓存初始化 ========================= + List> subCompany = orgHrmAsyncMapper.selectSubCompanyActive(); + subCompanyCache = OrgHrmAsyncUtil.parseListMap2Map(subCompany); + subCompanyLevelCache = OrgHrmAsyncUtil.parseListMap2Map("outkey","tlevel", subCompany); + List> department = orgHrmAsyncMapper.selectDepartmentActive(); + departmentCache = OrgHrmAsyncUtil.parseListMap2Map(department); + List> jobTitle = orgHrmAsyncMapper.selectJobTitle(); + jobTitleCache = OrgHrmAsyncUtil.parseListMap2Map("jobtitlename","id", jobTitle); + List> hrm = orgHrmAsyncMapper.selectHrmIdAndOutKey(); + hrmCache = OrgHrmAsyncUtil.parseListMap2Map(hrm); + // ======================================================================= + + maxLevel = Util.getIntValue(ShBigDataUtil.getPropertiesValByKey("maxLevel"), 3); + + // ======================部门-分部-人员 同步配置表初始化 ===================== + subCompanyConfig = orgHrmAsyncMapper.selectSubCompanyAsyncConfig(0); + if(subCompanyConfig == null || CollectionUtils.isEmpty(subCompanyConfig.get(0).getOrgHrmAsyncConfigDetailList())){ + throw new CustomerException("subCompanyConfig can not be null!"); + } + departmentConfig = orgHrmAsyncMapper.selectSubCompanyAsyncConfig(1); + if(departmentConfig == null || CollectionUtils.isEmpty(departmentConfig.get(0).getOrgHrmAsyncConfigDetailList())){ + throw new CustomerException("departmentConfig can not be null!"); + } + hrmReSourceConfig = orgHrmAsyncMapper.selectSubCompanyAsyncConfig(2); + // ======================================================================= + typeTableName.put(0, "hrmsubcompany"); + typeTableName.put(1, "hrmdepartment"); + typeTableName.put(2, "hrmresource"); + + + getNextIdTypeMap.put(0, (o)-> getNextHrmSubCompanyId()); + getNextIdTypeMap.put(1, (o)-> getNextHrmDepartmentId()); + getNextIdTypeMap.put(2, (o)-> getNextHrmId()); + + try { + comInfo = new ResourceComInfo(); + }catch (Exception e){ + log.error("init ResourceComInfo error : " + e.getMessage()); + } } + private final OrgHrmAsyncCache orgHrmAsyncCache = OrgHrmAsyncCache.builder() + .departmentCache(departmentCache) + .subCompanyCache(subCompanyCache) + .hrmCache(hrmCache) + .jobTitleCache(jobTitleCache) + .arrIndex(0) + .build(); + + @Override public List asyncDepartment() { - List departmentInfo = orgHrmAsyncApiService.getDepartmentInfo(); - //TODO 分部(条件待确认) - List subList = departmentInfo - .stream() - .filter(item -> -1 == item.getParentid()) - .sorted(Comparator.comparing(OtherSysDepartment::getId)) - .collect(Collectors.toList()); - addHrmSubCompany(subList); - - // 过滤出父节点并根据id进行升序排序 - List rootDepList = departmentInfo - .stream() - .filter(item -> 0 == item.getHasChild() && -1 != item.getParentid()) - .sorted(Comparator.comparing(OtherSysDepartment::getId)) - .collect(Collectors.toList()); - return null; } - /** - *

同步数据到分部

- * @author xuanran.wang - * @dateTime 2023/4/6 13:37 - * @param departmentList 部门数据集合 - **/ - public void addHrmSubCompany(List departmentList){ - //新增的分部id - int subId; - char separator = weaver.general.Util.getSeparator(); - RecordSet rsSch = new RecordSet(); - // 分部数据 - Map subCompany = initSubCompany(); - for (OtherSysDepartment department : departmentList) { - subId = Util.getIntValue(Util.null2DefaultStr(subCompany.get(department.getId()),""),-1); - if(subId < 0){ - String para = department.getName() + separator + department.getName() + separator + "1" + separator - + department.getId()+ separator + "" + separator +department.getOrder(); - rsSch.executeProc("HrmSubCompany_Insert", para); - if (rsSch.next()) { - subId = rsSch.getInt(1); + @Override + public synchronized List> asyncOrgDep(int type) { + if(CollectionUtils.isEmpty(asyncHrmSubCompany) || CollectionUtils.isEmpty(asyncHrmDepartment)){ + initWhiteList(); + List> departmentInfoMap = orgHrmAsyncApiService.getDepartmentInfoMap(); + // 解析成树形 + List> tree = convertListToTree(departmentInfoMap); + if(CollectionUtils.isEmpty(tree)){ + subDepIncrementDataAsync(departmentInfoMap, asyncHrmSubCompany, asyncHrmDepartment); + }else { + asyncOrDepByTree(tree,0, maxLevel, asyncHrmSubCompany, asyncHrmDepartment); + } + asyncOrgExtraData(); + } + threadPoolInstance.execute(()->{ + departmentComInfo.removeCache(); + sci.removeCompanyCache(); + }); + return type == 0 ? asyncHrmSubCompany : asyncHrmDepartment; + } + + @Override + public List> asyncHrm() { + if(CollectionUtils.isEmpty(hrmReSourceConfig) ){ + throw new CustomerException("hrmReSourceConfig can not be null!"); + } + int topLevelOutKey = Util.getIntValue(orgHrmAsyncMapper.selectTopLevelOutKey(), -1); + if(topLevelOutKey < 0){ + return new ArrayList<>(); + } + List> userInfo = orgHrmAsyncApiService.getUserInfo(topLevelOutKey); + try { + List oaCacheOutKeys = new ArrayList<>(hrmCache.keySet()); + LN ln = new LN(); + int licenseNum = ln.CkHrmnum(); + log.info("当前可用license : " + licenseNum); + log.info("当前接口数据条数 : " + userInfo.size()); + log.info("当前oa缓存outKey条数 : " + oaCacheOutKeys.size()); + if(CollectionUtils.isEmpty(oaCacheOutKeys)){ + if(licenseNum < userInfo.size()){ + log.error("当前接口条数大于可用license!本次同步跳过!"); + return new ArrayList<>(); + } + }else { + List> notContains = userInfo.stream().filter(item -> !oaCacheOutKeys.contains(Util.null2DefaultStr(item.get("id"), ""))).collect(Collectors.toList()); + log.info("接口中存在oa中不存在数据条数 : " + notContains.size()); + if(oaCacheOutKeys.size() + notContains.size() > licenseNum){ + log.error("当前接口条数+oa人员数量大于可用license!本次同步跳过!"); + return new ArrayList<>(); } } - updateTable("HrmSubCompany", subId, 0, department); + }catch (Exception e){ + log.error("校验可用license数量失败! " + e.getMessage()); } - //清除全部分部缓存 - sci.removeCompanyCache(); + addHrmResourceMap(userInfo); + List hrmExtraConfig = hrmReSourceConfig.stream() + .filter(item -> StringUtils.isNotBlank(item.getUpdateTableName()) + && !"hrmresource".equalsIgnoreCase(item.getUpdateTableName())) + .collect(Collectors.toList()); + threadPoolInstance.execute(()-> asyncExtraData(userInfo, hrmExtraConfig)); + return userInfo; + } + + /** + *

同步非树形的数据

+ * @author xuanran.wang + * @dateTime 2023/4/14 15:14 + * @param list 接口数据 + * @param hrmSubCompany 分部数据 + * @param hrmDepartment 部门数据 + **/ + public void subDepIncrementDataAsync(List> list, List> hrmSubCompany, List> hrmDepartment){ + for (Map data : list) { + int parentid = Util.getIntValue(Util.null2DefaultStr(data.get("parentid"), ""), -1); + int parentLevel = Util.getIntValue(Util.null2DefaultStr(subCompanyLevelCache.get(parentid + ""),""), -1); + data.put("msg","success!"); + String departmentId = Util.null2DefaultStr(data.get("id"),""); + // 如果分部中不存在并且父节点的层级等于最大的层级 + boolean isDep = parentLevel < 0 || parentLevel == maxLevel; + if(departmentWhiteList.contains(departmentId)){ + isDep = true; + } + if(subCompanyWhiteList.contains(departmentId)){ + isDep = false; + } + if(isDep){ + try { + addHrmDepartmentMap(Collections.singletonList(data)); + hrmDepartment.add(data); + orgHrmAsyncMapper.updateHrmSubCompanyCanceled(Collections.singletonList(departmentId)); + }catch (Exception e){ + log.error(Util.logStr("async depart error!: {}, json: \n{}",e.getMessage(),JSONObject.toJSONString(data))); + data.put("code",0); + data.put("msg","async department error! " + e.getMessage()); + } + }else { + try { + addHrmSubCompanyMap(Collections.singletonList(data)); + hrmSubCompany.add(data); + orgHrmAsyncMapper.updateHrmDepartmentCanceled(Collections.singletonList(departmentId)); + }catch (Exception e){ + log.error(Util.logStr("async depart error!: {}, json: \n{}",e.getMessage(),JSONObject.toJSONString(data))); + data.put("code",0); + data.put("msg","async department error! " + e.getMessage()); + } + } + } + } + + /** + *

处理分部与部门别的表同步数据

+ * @author xuanran.wang + * @dateTime 2023/4/14 15:17 + **/ + public void asyncOrgExtraData(){ + List subCompanyAsyncOtherConfig = subCompanyConfig.stream() + .filter(item -> StringUtils.isNotBlank(item.getUpdateTableName()) && !"hrmsubcompany".equalsIgnoreCase(item.getUpdateTableName())) + .collect(Collectors.toList()); + List departOtherAsyncConfig = subCompanyConfig.stream() + .filter(item -> StringUtils.isNotBlank(item.getUpdateTableName()) && !"hrmdepartment".equalsIgnoreCase(item.getUpdateTableName())) + .collect(Collectors.toList()); + threadPoolInstance.execute(()->{ + // 同步部门其他表数据 + asyncExtraData(asyncHrmSubCompany, subCompanyAsyncOtherConfig); + // 同步分部其他表数据 + asyncExtraData(asyncHrmDepartment, departOtherAsyncConfig); + }); + } + + + /** + *

执行自定义表数据同步

+ * @author xuanran.wang + * @dateTime 2023/4/13 13:20 + * @param data 数据 + * @param configs 同步配置 + **/ + public void asyncExtraData(List> data, List configs){ + for (OrgHrmAsyncConfigMain config : configs) { + for (Map map : data) { + String updateTableName = config.getUpdateTableName(); + String primaryKey = config.getPrimaryKey(); + String cusWhere = config.getCusWhere(); + if(StringUtils.isNotBlank(cusWhere)){ + cusWhere = Util.sbc2dbcCase(cusWhere); + } + orgHrmAsyncCache.setInterfaceVal(map); + String id = orgHrmAsyncMapper.selectCustomerSql(cusWhere, map); + Map param = OrgHrmAsyncUtil.convertInterfaceValToOA(orgHrmAsyncCache, config, false); + if(StringUtils.isNotBlank(id)){ + executeSql(updateTableName, Util.getIntValue(id, -1), param, 0, primaryKey); + }else { + executeSql(updateTableName, Util.getIntValue(id, -1), param, 1); + } + } + } + } + + /** + *

初始化配置表中部门与分部的白名单

+ * @author xuanran.wang + * @dateTime 2023/4/14 15:16 + **/ + public void initWhiteList(){ + // 解析白名单数据 + subCompanyConfig.forEach(item->{ + String cudSubCompany = item.getCudSubCompany(); + if(StringUtils.isNotBlank(cudSubCompany)){ + subCompanyWhiteList.addAll(Arrays.asList(cudSubCompany.split(","))); + } + }); + departmentConfig.forEach(item->{ + String cusDepartment = item.getCusDepartment(); + if(StringUtils.isNotBlank(cusDepartment)){ + departmentWhiteList.addAll(Arrays.asList(cusDepartment.split(","))); + } + }); + log.info("departmentWhiteList : \n" + JSONObject.toJSONString(departmentWhiteList)); + log.info("subCompanyWhiteList : \n" + JSONObject.toJSONString(subCompanyWhiteList)); + } + + + + /** + *

同步数据到分部

+ * + * @param departmentList 部门数据集合 + * @author xuanran.wang + * @dateTime 2023/4/6 13:37 + **/ + public void addHrmSubCompanyMap(List> departmentList) { + List collect = subCompanyConfig.stream().filter(item -> StringUtils.isBlank(item.getUpdateTableName())).collect(Collectors.toList()); + baseAddOrgDepByMap(departmentList, 0, subCompanyCache, collect.get(0)); } /** @@ -91,73 +384,361 @@ public class OrgHrmAsyncServiceImpl implements OrgHrmAsyncService { * @dateTime 2023/4/6 13:37 * @param departmentList 部门数据集合 **/ - public void addHrmDepartment(List departmentList){ - //新增的分部id - int id = 0; - char separator = weaver.general.Util.getSeparator(); - RecordSet rsSch = new RecordSet(); - for (OtherSysDepartment department : departmentList) { - String para = department.getName() + separator + department.getName() + separator + "1" + separator - + department.getParentid() + separator + "" + separator +department.getOrder(); - rsSch.executeProc("HrmSubCompany_Insert", para); - if (rsSch.next()) { - id = rsSch.getInt(1); - updateTable("HrmSubCompany", id, 0, department); - } - } - //清除全部分部缓存 - sci.removeCompanyCache(); + public void addHrmDepartmentMap(List> departmentList){ + List collect = departmentConfig.stream().filter(item -> StringUtils.isBlank(item.getUpdateTableName())).collect(Collectors.toList()); + baseAddOrgDepByMap(departmentList, 1, departmentCache, collect.get(0)); } /** - *

更新分部数据

+ *

同步数据到人员信息

+ * @author xuanran.wang + * @dateTime 2023/4/6 13:37 + * @param hrmList 部门数据集合 + **/ + public void addHrmResourceMap(List> hrmList){ + List hrmAsyncConf = hrmReSourceConfig.stream() + .filter(item -> StringUtils.isBlank(item.getUpdateTableName()) || !"hrmresource".equalsIgnoreCase(item.getUpdateTableName())) + .collect(Collectors.toList()); + baseAddOrgDepByMap(hrmList, 2, hrmCache, hrmAsyncConf.get(0)); + } + + /** + *

同步数据

+ * @author xuanran.wang + * @dateTime 2023/4/12 10:36 + * @param dataList 集合 + * @param type 类型 0 分部 1 部门 + **/ + public void baseAddOrgDepByMap(List> dataList, + int type, Map cache, + OrgHrmAsyncConfigMain config){ + for (Map data : dataList) { + int interfaceId = Util.getIntValue(Util.null2DefaultStr(data.get("id"), ""), -1); + int oaId = Util.getIntValue(Util.null2DefaultStr(cache.get(interfaceId + ""),""), -1); + boolean insert = false; + // 如果不存在则需要新增 + if(oaId < 0){ + oaId = getNextIdTypeMap.get(type).apply(null); + if(oaId < 0){ + log.error("create " + typeTableName.get(type) + " id fail!"); + continue; + } + cache.put(interfaceId + "", oaId); + insert = true; + } + orgHrmAsyncCache.setInterfaceVal(data); + Map map = OrgHrmAsyncUtil.convertInterfaceValToOA(orgHrmAsyncCache, config, true); + if(insert){ + map.put("creater",1); + map.put("created", TimeUtil.getCurrentTimeString()); + } + if(type == 2 && insert){ + map.put("id", oaId); + executeSql(typeTableName.get(type), oaId, map, 1); + try { + int subcompanyid1 = Util.getIntValue(Util.null2DefaultStr(map.get("subcompanyid1"), ""), -1); + if(subcompanyid1 > 0){ + themeService.createSubCompanyMenu(oaId, subcompanyid1); + } + }catch (Exception e){ + log.error("为新员工创建默认的菜单权限 error " + e.getMessage()); + } + try { + comInfo.addResourceInfoCache(oaId + ""); + }catch (Exception e){ + log.error("添加人员缓存 error " + e.getMessage()); + } + }else { + if(type == 2){ + try { + comInfo.updateResourceInfoCache(oaId + ""); + }catch (Exception e){ + log.error("更新人员缓存 error " + e.getMessage()); + } + } + executeSql(typeTableName.get(type), oaId, map, 0); + } + if(insert){ + data.put("code", 1); + }else { + data.put("code", 2); + } + if(type == 0){ + //同步分部数据到矩阵 + MatrixUtil.updateSubcompayData(String.valueOf(oaId)); + } + } + } + + /** + *

获取下一个分部id

+ * @author xuanran.wang + * @dateTime 2023/4/12 13:25 + * @return 分部id + **/ + public int getNextHrmSubCompanyId(){ + char separator = weaver.general.Util.getSeparator(); + String uuid = UUID.randomUUID().toString(); + String para = uuid + separator + uuid + separator + "1" + separator + + 1 + separator + "" + separator + 1; + return executeProc("HrmSubCompany_Insert", para); + } + + /** + *

获取下一个部门id

+ * @author xuanran.wang + * @dateTime 2023/4/12 13:24 + * @return 部门id + **/ + public int getNextHrmDepartmentId(){ + char separator = weaver.general.Util.getSeparator(); + String uuid = UUID.randomUUID().toString(); + String para = uuid + separator +uuid + separator + + "" + separator + "" + separator + 1+ separator + 1 + separator + ""; + return executeProc("HrmDepartment_Insert", para); + } + + /** + *

获取下一个人员id

+ * @author xuanran.wang + * @dateTime 2023/4/12 13:24 + * @return 人员id + **/ + public int getNextHrmId(){ + procRs.executeProc("HrmResourceMaxId_Get", ""); + if (procRs.next()) { + return procRs.getInt(1); + } + return -1; + } + + /** + *

执行存储过程

+ * @author xuanran.wang + * @dateTime 2023/4/12 16:12 + * @param name 执行存储过程名称 + * @param para 参数 + * @return 下一个id + **/ + public int executeProc(String name, String para){ + if(procRs == null){ + procRs = new RecordSet(); + } + procRs.executeProc(name, para); + if (procRs.next()) { + return procRs.getInt(1); + } + return -1; + } + + /** + *

更新表数据

+ * + * @param tableName 表名 + * @param id 数据id + * @param params 参数 + * @param type 操作类型 0: 更新 1: 新增 * @author xuanran.wang * @dateTime 2023/4/6 13:35 - * @param tableName 表名 - * @param id 数据id - * @param type 类型 - * @param o 对象 **/ - public void updateTable(String tableName, int id, int type, Object o){ - StringBuilder sb = new StringBuilder("update "); - sb.append(tableName).append(" set "); - Map params; - try { - params = ShBigDataUtil.parseCusDbEntityMapping(type, o); - }catch (Exception e){ - throw new CustomerException("parseCusDbEntityMapping error!"); + public boolean executeSql(String tableName, int id, Map params, int type) { + return executeSql(tableName, id, params, type, "id"); + } + + /** + *

更新表数据

+ * + * @param tableName 表名 + * @param id 数据id + * @param params 参数 + * @param type 操作类型 0: 更新 1: 新增 + * @param primaryKey where主键 + * @author xuanran.wang + * @dateTime 2023/4/6 13:35 + **/ + public boolean executeSql(String tableName, int id, Map params, int type, String primaryKey) { + String operationType = "update "; + if(type == 1){ + operationType = "insert "; } + StringBuilder sqlSb = new StringBuilder(operationType) + .append(tableName) + .append(" set "); for (Map.Entry entry : params.entrySet()) { - sb.append(entry.getKey()) + sqlSb.append(entry.getKey()) .append(" = #{") .append(entry.getKey()) .append("},"); } - sb.deleteCharAt(sb.length() - 1); - sb.append(" where id = ").append(id); - boolean success = orgHrmAsyncMapper.updateSubInfo(sb.toString(), params); - if(!success){ - throw new CustomerException(Util.logStr("update {} sql error!", tableName)); + sqlSb.deleteCharAt(sqlSb.length() - 1); + if(type == 0){ + sqlSb.append(" where ") + .append(primaryKey) + .append(" = ") + .append(id); } - //同步分部数据到矩阵 - MatrixUtil.updateSubcompayData(String.valueOf(id)); + boolean success; + if(type == 1){ + success = orgHrmAsyncMapper.insertHrmInfo(sqlSb.toString(), params); + }else { + success = orgHrmAsyncMapper.updateOrgInfo(sqlSb.toString(), params); + } + if (!success) { + throw new CustomerException(operationType + tableName + " fail!"); + } + return true; } - public void setChildList(List departmentList){ - if(departmentList.size() == 0){ - return; - } - for (OtherSysDepartment department : departmentList) { - List childList = departmentList - .stream() - .filter(item -> department.getId() == item.getParentid()) - .collect(Collectors.toList()); - department.setChildList(childList); - if(CollectionUtils.isNotEmpty(childList)){ - setChildList(childList); + + /** + *

解析部门or分部

+ * + * @param list 树形集合 + * @param n 层级 + * @author xuanran.wang + * @dateTime 2023/4/10 12:13 + **/ + public void asyncOrDepByTree(List> list, int n, int maxLevel, List> hrmSubCompany, List> hrmDepartment) { + n++; + for (Map department : list) { + department.put("level", n); + List> childList = (List>) department.get("childList"); + String departmentId = Util.null2DefaultStr(department.get("id"), ""); + boolean dep = n > maxLevel; + if(departmentWhiteList.contains(departmentId)){ + dep = true; + } + if(subCompanyWhiteList.contains(departmentId)){ + dep = false; + } + department.put("msg","success!"); + if(dep){ + try { + addHrmDepartmentMap(Collections.singletonList(department)); + orgHrmAsyncMapper.updateHrmSubCompanyCanceled(Collections.singletonList(departmentId)); + }catch (Exception e){ + log.error(Util.logStr("async depart error!: {}, json: \n{}",e.getMessage(),JSONObject.toJSONString(department))); + department.put("code",0); + department.put("msg","async department error! " + e.getMessage()); + } + hrmDepartment.add(department); + }else { + try { + if(subCompanyWhiteList.contains(departmentId) && orgHrmAsyncMapper.selectDepartHasUser(departmentId) > 0){ + String error = "该部门下存在人员,无法同步成分部.本次同步不做更新请手动同步! json:\n" + JSONObject.toJSONString(department); + throw new CustomerException(error); + } + addHrmSubCompanyMap(Collections.singletonList(department)); + orgHrmAsyncMapper.updateHrmDepartmentCanceled(Collections.singletonList(departmentId)); + }catch (Exception e){ + log.error(Util.logStr("async subCompany error!: {}, json: \n{}",e.getMessage(),JSONObject.toJSONString(department))); + department.put("code",0); + department.put("msg","async subCompany error! " + e.getMessage()); + } + hrmSubCompany.add(department); + } + if (CollectionUtils.isNotEmpty(childList)) { + childList.sort(orderByOrder.thenComparing(orderById)); + List childIds = childList + .stream() + .map(item -> Util.null2DefaultStr(item.get("id"), "")) + .collect(Collectors.toList()); + if (departmentWhiteList.contains(departmentId)) { + departmentWhiteList.addAll(childIds); +// childIds.add(departmentId); +// if (!orgHrmAsyncMapper.updateHrmSubCompanyCanceled(childIds)) { +// log.error("updateHrmSubCompanyCanceled error!"); +// } + } +// else if (subCompanyWhiteList.contains(departmentId)) { +// orgHrmAsyncMapper.updateHrmDepartmentCanceled(Collections.singletonList(departmentId)); +// } + asyncOrDepByTree(childList, n, maxLevel, hrmSubCompany, hrmDepartment); + department.put("childList", new ArrayList<>()); } } } + /** + *

解析部门or分部(方法弃用)

+ * + * @param list 树形集合 + * @param n 层级 + * @param hrmSubCompany 分部 + * @param hrmDepartment 部门 + * @author xuanran.wang + * @dateTime 2023/4/10 12:13 + **/ + @Deprecated + public void parseSubCompanyAndDepartmentMap(List> list, int n, int maxLevel, List> hrmSubCompany, List> hrmDepartment) { + n++; + for (Map department : list) { + department.put("level", n); + List> childList = (List>) department.get("childList"); + String departmentId = Util.null2DefaultStr(department.get("id"), ""); + if (CollectionUtils.isNotEmpty(childList)) { + List collect = childList.stream() + .map(item -> Util.null2DefaultStr(item.get("id"), "")) + .collect(Collectors.toList()); + // 分部变成了部门则把子节点都变成部门 并将 当前数据和子数据以前是分部的全部封存 + if (departmentWhiteList.contains(departmentId)) { + departmentWhiteList.addAll(collect); + collect.add(departmentId); + if (!orgHrmAsyncMapper.updateHrmSubCompanyCanceled(collect)) { + log.error("updateHrmSubCompanyCanceled error!"); + } + } + // 如果部门变成了分部那么 把当前部门变成分部 然后把部门表中相应的数据进行封存 + else if (subCompanyWhiteList.contains(departmentId)) { +// subCompanyWhiteList.addAll(collect); + orgHrmAsyncMapper.updateHrmDepartmentCanceled(Collections.singletonList(departmentId)); + } + parseSubCompanyAndDepartmentMap(childList, n, maxLevel, hrmSubCompany, hrmDepartment); + department.put("childList", new ArrayList<>()); + } + if (n > maxLevel || departmentWhiteList.contains(departmentId)) { + hrmDepartment.add(department); + } else { + hrmSubCompany.add(department); + } + } + } + + /** + *

通过parentId将集合转成树

+ * + * @param list 接口返回集合 + * @return 树形结构 + * @author xuanran.wang + * @dateTime 2023/4/11 13:26 + **/ + public List> convertListToTree(List> list) { + Map> map = new HashMap<>(); + for (Map item : list) { + map.put((Integer) item.get("id"), item); + } + // 构建树形结构 + List> tree = new ArrayList<>(); + for (Map item : list) { + int parentId = (Integer) item.get("parentid"); + if (parentId == -1) { + // 添加根节点 + tree.add(item); + } else { + // 添加子节点 + Map parent = map.get(parentId); + if (parent != null) { + List> childList = (List>) parent.get("childList"); + if (childList == null) { + childList = new ArrayList<>(); + parent.put("childList", childList); + } + childList.add(item); + } + } + } + return tree; + } + } diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/util/OrgHrmAsyncUtil.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/util/OrgHrmAsyncUtil.java new file mode 100644 index 0000000..95c2b50 --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/util/OrgHrmAsyncUtil.java @@ -0,0 +1,102 @@ +package weaver.xuanran.wang.sh_bigdata.org_hrm_async.util; + +import aiyh.utils.Util; +import io.swagger.models.auth.In; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.general.TimeUtil; +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OrgHrmAsyncCache; +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OrgHrmAsyncConfigDetail; +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OrgHrmAsyncConfigMain; + +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + *

组织架构-人员同步

+ * + * @author xuanran.wang + * @date 2023/4/11 15:48 + */ +public class OrgHrmAsyncUtil { + + /** + *

将接口数据按照建模配置转成map

+ * @author xuanran.wang + * @dateTime 2023/4/11 18:21 + * @param orgHrmAsyncCache 缓存对象 + * @param hrmAsyncConfig 建模配置对象 + * @return 参数map + **/ + public static Map convertInterfaceValToOA(OrgHrmAsyncCache orgHrmAsyncCache, OrgHrmAsyncConfigMain hrmAsyncConfig){ + return convertInterfaceValToOA(orgHrmAsyncCache, hrmAsyncConfig, false); + } + + /** + *

将接口数据按照建模配置转成map

+ * @author xuanran.wang + * @dateTime 2023/4/11 18:21 + * @param orgHrmAsyncCache 缓存对象 + * @param hrmAsyncConfig 建模配置对象 + * @return 参数map + **/ + public static Map convertInterfaceValToOA(OrgHrmAsyncCache orgHrmAsyncCache, OrgHrmAsyncConfigMain hrmAsyncConfig, boolean addSystemParam){ + List configDetailList = hrmAsyncConfig.getOrgHrmAsyncConfigDetailList(); + LinkedHashMap res = new LinkedHashMap<>(); + for (OrgHrmAsyncConfigDetail detail : configDetailList) { + String oaField = detail.getOaField(); + Object value = ValueRuleMethod.VALUE_RULE_FUNCTION.get(detail.getConvertType()).apply(detail, orgHrmAsyncCache); + int fieldType = detail.getFieldType(); + if(0 == fieldType){ + value = Util.null2DefaultStr(value, ""); + }else { + value = Util.getIntValue(Util.null2DefaultStr(value, ""),0); + } + res.put(oaField, value); + } + if(addSystemParam){ + addSysParam(res); + } + return res; + } + + /** + *

将集合数据放到缓存中

+ * @author xuanran.wang + * @dateTime 2023/4/10 18:33 + * @param listMap 集合数据 + **/ + public static HashMap parseListMap2Map( List> listMap){ + return parseListMap2Map("outkey","id", listMap); + } + + /** + *

将集合数据放到缓存中

+ * @author xuanran.wang + * @dateTime 2023/4/10 18:33 + * @param listMap 集合数据 + **/ + public static HashMap parseListMap2Map(String key, String value, List> listMap){ + if(CollectionUtils.isEmpty(listMap)){ + return new HashMap<>(); + } + HashMap res = new HashMap<>(); + listMap.forEach(map -> { + String outKey = Util.null2DefaultStr(map.get(key),""); + if(StringUtils.isNotBlank(outKey)){ + int id = Util.getIntValue(Util.null2DefaultStr(map.get(value),""),-1); + res.put(outKey, id); + } + }); + return res; + } + + public static void addSysParam(Map res){ + String dateTime = TimeUtil.getCurrentTimeString(); + res.put("modifier", 1); + res.put("modified", dateTime); + } + +} diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/util/ValueRuleMethod.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/util/ValueRuleMethod.java new file mode 100644 index 0000000..ed69837 --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/util/ValueRuleMethod.java @@ -0,0 +1,178 @@ +package weaver.xuanran.wang.sh_bigdata.org_hrm_async.util; + +import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; +import com.alibaba.fastjson.JSONObject; +import com.google.common.base.Strings; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import weaver.general.TimeUtil; +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.annotations.CusOrgHrmAsyncConvert; +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OrgHrmAsyncCache; +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OrgHrmAsyncConfigDetail; +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.mapper.OrgHrmAsyncMapper; +import weaver.youhong.ai.haripijiu.action.sapdocking.config.mapper.SapConfigMapper; +import weaver.youhong.ai.haripijiu.action.sapdocking.config.pojo.SapConfigDetail; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.*; +import java.util.function.BiFunction; + +/** + *

值处理方法

+ * + *

create: 2023-02-02 15:15

+ * + * @author youHong.ai + */ + +public class ValueRuleMethod { + + + public static final Map> VALUE_RULE_FUNCTION = new HashMap<>(); + + private final OrgHrmAsyncMapper orgHrmAsyncMapper = Util.getMapper(OrgHrmAsyncMapper.class); + + private final Logger log = Util.getLogger(); + + static { + Class valueRuleMethodClass = ValueRuleMethod.class; + Method[] methods = valueRuleMethodClass.getMethods(); + for (Method method : methods) { + if (method.isAnnotationPresent(ValueRuleMethodNo.class)) { + ValueRuleMethodNo annotation = method.getAnnotation(ValueRuleMethodNo.class); + int value = annotation.value(); + VALUE_RULE_FUNCTION.put(value, (OrgHrmAsyncConfigDetail, orgHrmAsyncCache) -> { + try { + ValueRuleMethod valueRuleMethod = new ValueRuleMethod(); + return method.invoke(valueRuleMethod, OrgHrmAsyncConfigDetail, orgHrmAsyncCache); + } catch (IllegalAccessException | InvocationTargetException e) { + throw new RuntimeException(e); + } + }); + } + } + } + + @ValueRuleMethodNo(value = 0, desc = "不转换") + public Object getFixValue(OrgHrmAsyncConfigDetail configDetail,OrgHrmAsyncCache cache) { + return cache.getInterfaceVal().get(configDetail.getInterfaceField()); + } + + + @ValueRuleMethodNo(value = 1, desc = "默认值") + public Object getCusText(OrgHrmAsyncConfigDetail configDetail, OrgHrmAsyncCache cache) { + return configDetail.getCusText(); + } + + + @ValueRuleMethodNo(value = 2, desc = "自定义sql") + public Object getCustomerSqlValue(OrgHrmAsyncConfigDetail configDetail, OrgHrmAsyncCache cache) { + Map interfaceVal = cache.getInterfaceVal(); + String cusText = configDetail.getCusText(); + cusText = Util.sbc2dbcCase(cusText); + if (Strings.isNullOrEmpty(cusText)) { + return null; + } + if (!cusText.startsWith("select")) { + return null; + } + // 接口字段值判断 + String interfaceField = configDetail.getInterfaceField(); + String interfaceFieldVal = Util.null2DefaultStr(interfaceVal.get(interfaceField),""); + if(StringUtils.isBlank(interfaceFieldVal)){ + return ""; + } + Object val = interfaceVal.get(configDetail.getInterfaceField()); + // 如果接口参数是集合则转成'1,2'形式 放到参数中 + if(val instanceof List && ((List) val).size() > 0){ + ArrayList temp = new ArrayList<>(); + for (int i = 0; i < ((List) val).size(); i++) { + interfaceVal.put(interfaceField + "_" + i, ((List) val).get(i)); + temp.add("'" + ((List) val).get(i) + "'"); + } + interfaceVal.put(interfaceField,StringUtils.join(temp,",")); + } + String oaField = configDetail.getOaField(); + // 先从缓存中找数据 + int cacheVal = convertFromCache(interfaceVal, cache, oaField, interfaceFieldVal); + if(cacheVal > 0){ + return cacheVal; + } + if(StringUtils.isNotBlank(interfaceFieldVal)){ + cusText = cusText.replace("?", interfaceFieldVal); + } + List strings = orgHrmAsyncMapper.selectCustomerSqlArr(cusText, interfaceVal); + if(CollectionUtils.isNotEmpty(strings)){ + return StringUtils.join(strings,","); + } + return ""; + } + + @ValueRuleMethodNo(value = 3, desc = "自定义接口") + public Object getCusConvertInterface(OrgHrmAsyncConfigDetail configDetail, OrgHrmAsyncCache cache) { + String cusText = configDetail.getCusText(); + if(Strings.isNullOrEmpty(cusText)){ + return null; + } + try { + Class clazz = Class.forName(cusText); + if(!CusOrgHrmAsyncConvert.class.isAssignableFrom(clazz)){ + throw new CustomerException(cusText + " not implements weaver.xuanran.wang.sh_bigdata.org_hrm_async.annotations.CusOrgHrmAsyncConvert"); + } + CusOrgHrmAsyncConvert o = (CusOrgHrmAsyncConvert) clazz.newInstance(); + Map pathParam = Util.parseCusInterfacePathParam(cusText); + return o.cusConvert(configDetail, cache, pathParam); + }catch (Exception e){ + log.error("getCusConvertInterface error! " + e.getMessage()); + return null; + } + } + + /** + *

从缓存中找数据

+ * @author xuanran.wang + * @dateTime 2023/4/13 13:44 + * @param interfaceVal 接口参数map + * @param cache 缓存对象 + * @param oaField oa字段名 + * @param interfaceFieldVal 接口参数值 + * @return 数据id + **/ + public int convertFromCache(Map interfaceVal, OrgHrmAsyncCache cache, String oaField, String interfaceFieldVal){ + Map subCompanyCache = cache.getSubCompanyCache(); + Map departmentCache = cache.getDepartmentCache(); + Integer value = Util.getIntValue(Util.null2DefaultStr(interfaceVal.get("parentid"), ""),-1); + // 特殊处理 先从缓存中拿如果缓存中没有在执行sql + if("subcompanyid1".equalsIgnoreCase(oaField) || "supsubcomid".equalsIgnoreCase(oaField)){ + value = subCompanyCache.get(value + ""); + } else if("supdepId".equalsIgnoreCase(oaField)){ + value = departmentCache.get(value + ""); + } + if("jobtitle".equalsIgnoreCase(oaField)){ + Map jobTitleCache = cache.getJobTitleCache(); + value = Util.getIntValue(Util.null2DefaultStr(jobTitleCache.get(interfaceFieldVal), ""), -1); + if(value < 0){ + interfaceVal.put("jobCreateTime", TimeUtil.getCurrentTimeString()); + boolean success = orgHrmAsyncMapper.insertJobTitle(interfaceVal); + if(!success){ + log.error("insertJobTitle fail!"); + } + int id = Util.getIntValue(orgHrmAsyncMapper.selectJobTitleByName(interfaceFieldVal), -1); + if(id > 0){ + jobTitleCache.put(interfaceFieldVal, id); + } + } + } + + if(!Objects.isNull(value) && value > 0){ + return value; + } + + return -1; + } + + +} diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/util/ValueRuleMethodNo.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/util/ValueRuleMethodNo.java new file mode 100644 index 0000000..80179bb --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/org_hrm_async/util/ValueRuleMethodNo.java @@ -0,0 +1,19 @@ +package weaver.xuanran.wang.sh_bigdata.org_hrm_async.util; + +import java.lang.annotation.*; + +/** + *

值处理方法编号注解

+ * + *

create: 2023-02-02 15:18

+ * + * @author youHong.ai + */ + +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface ValueRuleMethodNo { + int value(); + String desc(); +} diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusDoneTask.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusDoneTask.java index a69e3e9..311a790 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusDoneTask.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusDoneTask.java @@ -19,5 +19,5 @@ public class CusDoneTask { @SqlFieldMapping private String taskNum; private int status; - private String appId; + private String agentid; } diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusTodoTask.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusTodoTask.java index fe8a8a8..1337e35 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusTodoTask.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusTodoTask.java @@ -18,7 +18,7 @@ import weaver.xuanran.wang.common.annocation.SqlUpdateWhereField; public class CusTodoTask { @SqlFieldMapping protected String taskNum; - protected String appId; + protected String agentid; @SqlFieldMapping protected String taskName; protected String taskDesc; diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/service/impl/SendTodoTaskServiceImpl.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/service/impl/SendTodoTaskServiceImpl.java index 748848b..581cd14 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/service/impl/SendTodoTaskServiceImpl.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/service/impl/SendTodoTaskServiceImpl.java @@ -33,7 +33,6 @@ import java.util.*; @Data public class SendTodoTaskServiceImpl implements SendTodoTaskService { private final Logger log = Util.getLogger(); - private String appId; private final SendTodoTaskUtil sendTodoTaskUtil = new SendTodoTaskUtil(); private String addTodoTaskUrl; private String updateTodoTaskUrl; @@ -45,7 +44,7 @@ public class SendTodoTaskServiceImpl implements SendTodoTaskService { { - sendTodoTaskUtil.setAppId(ShBigDataUtil.getPropertiesValByKey("appId")); + sendTodoTaskUtil.setAgentId(ShBigDataUtil.getPropertiesValByKey("agentId")); modelId = Util.getIntValue(ShBigDataUtil.getPropertiesValByKey("modelId"),-1); addTodoTaskUrl = ShBigDataUtil.getPropertiesValByKey("addTodoTaskUrl"); updateTodoTaskUrl = ShBigDataUtil.getPropertiesValByKey("updateTodoTaskUrl"); diff --git a/src/main/java/weaver/xuanran/wang/shyl/dataasync/entity/StudentClass.java b/src/main/java/weaver/xuanran/wang/shyl/dataasync/entity/StudentClass.java index 914d78b..7f4fef0 100644 --- a/src/main/java/weaver/xuanran/wang/shyl/dataasync/entity/StudentClass.java +++ b/src/main/java/weaver/xuanran/wang/shyl/dataasync/entity/StudentClass.java @@ -33,4 +33,6 @@ public class StudentClass { **/ @SqlFieldMapping() private int belongYear; + @SqlFieldMapping() + private String teacherId; } diff --git a/src/main/java/weaver/xuanran/wang/shyl/dataasync/job/CusDataAsyncJob.java b/src/main/java/weaver/xuanran/wang/shyl/dataasync/job/CusDataAsyncJob.java index 4778f42..52fd9b0 100644 --- a/src/main/java/weaver/xuanran/wang/shyl/dataasync/job/CusDataAsyncJob.java +++ b/src/main/java/weaver/xuanran/wang/shyl/dataasync/job/CusDataAsyncJob.java @@ -2,13 +2,12 @@ package weaver.xuanran.wang.shyl.dataasync.job; import aiyh.utils.Util; import lombok.Data; +import lombok.EqualsAndHashCode; import org.apache.log4j.Logger; import weaver.interfaces.schedule.BaseCronJob; import weaver.xuanran.wang.common.annocation.ParamNotNull; import weaver.xuanran.wang.common.annocation.ParamPrint; import weaver.xuanran.wang.common.util.CommonUtil; -import weaver.xuanran.wang.shyl.dataasync.entity.Student; -import weaver.xuanran.wang.shyl.dataasync.entity.StudentClass; import weaver.xuanran.wang.shyl.dataasync.service.CusDataAsyncService; import java.util.HashMap; @@ -19,7 +18,6 @@ import java.util.HashMap; * @author xuanran.wang * @date 2023/2/9 10:02 */ -@Data public class CusDataAsyncJob extends BaseCronJob { /** @@ -63,18 +61,42 @@ public class CusDataAsyncJob extends BaseCronJob { private final CusDataAsyncService dataAsyncService = new CusDataAsyncService(); -// private final Logger logger = Util.getLogger(); + private final Logger logger = Util.getLogger(); @Override public void execute() { try { CommonUtil.checkParamNotNull(this); // 数据同步 - dataAsyncService.asyncData(baseAddr + queryClassUrl, classModelId, StudentClass.class, updateClassSql,"data"); + dataAsyncService.asyncData(baseAddr + queryClassUrl, classModelId, updateClassSql,"data"); }catch (Exception e){ -// logger.error(Util.logStr("CusDataAsyncJob execute error! the error is :{}, " + -// "error stack trace msg is: \n{}", e.getMessage(), Util.getErrString(e))); + logger.error(Util.logStr("CusDataAsyncJob execute error! the error is :{}, " + + "error stack trace msg is: \n{}", e.getMessage(), Util.getErrString(e))); } } + + public String getBaseAddr() { + return baseAddr; + } + + public void setBaseAddr(String baseAddr) { + this.baseAddr = baseAddr; + } + + public String getQueryClassUrl() { + return queryClassUrl; + } + + public void setQueryClassUrl(String queryClassUrl) { + this.queryClassUrl = queryClassUrl; + } + + public String getClassModelId() { + return classModelId; + } + + public void setClassModelId(String classModelId) { + this.classModelId = classModelId; + } } diff --git a/src/main/java/weaver/xuanran/wang/shyl/dataasync/service/CusDataAsyncService.java b/src/main/java/weaver/xuanran/wang/shyl/dataasync/service/CusDataAsyncService.java index 91be9a6..8533560 100644 --- a/src/main/java/weaver/xuanran/wang/shyl/dataasync/service/CusDataAsyncService.java +++ b/src/main/java/weaver/xuanran/wang/shyl/dataasync/service/CusDataAsyncService.java @@ -11,7 +11,9 @@ import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; +import weaver.conn.RecordSet; import weaver.xuanran.wang.common.util.CusInfoToOAUtil; +import weaver.xuanran.wang.shyl.dataasync.entity.StudentClass; import javax.ws.rs.core.MediaType; import java.io.IOException; @@ -59,13 +61,49 @@ public class CusDataAsyncService { return; } ArrayList dataList = new ArrayList<>(); + ArrayList ids = new ArrayList<>(); for (Object o : array) { Object temp = JSONObject.parseObject(o.toString(), clazz); dataList.add(temp); + } CusInfoToOAUtil.executeBatchByEntity(Util.getIntValue(modelId, -1), dataList, updateSql); } + /** + *

数据同步

+ * @author xuanran.wang + * @dateTime 2023/2/9 10:10 + * @param url 请求地址 + * @param modelId 建模模块id + * @param updateSql 建模更新数据sql + **/ + public void asyncData(String url, String modelId, String updateSql, String key){ + Object data = getResponseDataByGet(url, new HashMap<>(), new HashMap<>(), key); + JSONArray array = JSONObject.parseArray(JSONObject.toJSONString(data)); + log.info("data : " + array); + if(CollectionUtils.isEmpty(array)){ + log.error("array is empty!"); + return; + } + ArrayList dataList = new ArrayList<>(); + ArrayList ids = new ArrayList<>(); + for (Object o : array) { + StudentClass temp = JSONObject.parseObject(o.toString(), StudentClass.class); + dataList.add(temp); + ids.add("'" + temp.getId() + "'"); + } + CusInfoToOAUtil.executeBatchByEntity(Util.getIntValue(modelId, -1), dataList, updateSql); + RecordSet updateRs = new RecordSet(); + if(CollectionUtils.isNotEmpty(ids)){ + String updateDelStatus = "update " + CusInfoToOAUtil.checkModelId(Util.getIntValue(modelId, -1)) + " set delStatus = 1 where " + + weaver.general.Util.getSubINClause(StringUtils.join(ids,","),"classId","not in"); + if (!updateRs.executeUpdate(updateDelStatus)) { + throw new CustomerException("更新删除状态失败!"); + } + } + } + /** *

获取token

* @author xuanran.wang diff --git a/src/main/java/weaver/xuanran/wang/shyl_mq/mapper/ConsumerMapper.java b/src/main/java/weaver/xuanran/wang/shyl_mq/mapper/ConsumerMapper.java index e1ec671..af8f3f8 100644 --- a/src/main/java/weaver/xuanran/wang/shyl_mq/mapper/ConsumerMapper.java +++ b/src/main/java/weaver/xuanran/wang/shyl_mq/mapper/ConsumerMapper.java @@ -50,7 +50,7 @@ public interface ConsumerMapper { * @param outKey 外部系统id * @return map key : id, val : 分部id **/ - @Select("select id departmentId, subcompanyid1 subCompanyId from hrmdepartment where outkey = #{outKey} and canceled != 1") + @Select("select id departmentId, subcompanyid1 subCompanyId from hrmdepartment where outkey = #{outKey} and ifnull(canceled,0) <> 1") Map getDepInfoByOutKey(@ParamMapper("outKey") String outKey); /** @@ -70,7 +70,7 @@ public interface ConsumerMapper { * @param outKey 外部系统id * @return id **/ - @Select("select id from hrmdepartment where outkey = #{outKey} and canceled != 1") + @Select("select id from hrmdepartment where outkey = #{outKey} and ifnull(canceled,0) <> 1") String getDepIdByOutKey(@ParamMapper("outKey") String outKey); /** diff --git a/src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/OrgServiceImpl.java b/src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/OrgServiceImpl.java index ddbf9e1..8b8f306 100644 --- a/src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/OrgServiceImpl.java +++ b/src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/OrgServiceImpl.java @@ -42,7 +42,7 @@ public class OrgServiceImpl extends CusInfoActionService { **/ @Override public ConsumeConcurrentlyStatus cusCreateAction(MQMessage message) { - int depId = 0; + int depId; try { String content = message.getContent(); Org org = JSONObject.parseObject(content, Org.class); diff --git a/src/main/java/weaver/xuanran/wang/shyl_mq/util/RocketConsumerUtil.java b/src/main/java/weaver/xuanran/wang/shyl_mq/util/RocketConsumerUtil.java index c6b564d..3227443 100644 --- a/src/main/java/weaver/xuanran/wang/shyl_mq/util/RocketConsumerUtil.java +++ b/src/main/java/weaver/xuanran/wang/shyl_mq/util/RocketConsumerUtil.java @@ -122,6 +122,7 @@ public class RocketConsumerUtil { log.error(Util.logStr("MQMessageId: {}, Already consumed!",mqMessageId)); return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; } + log.info("mqMessage : " + JSONObject.toJSONString(mqMessage)); // 业务类型 String actionType = mqMessage.getActionType(); switch (actionType){ diff --git a/src/main/resources/WEB-INF/prop/prop2map/ShBigdataConf.properties b/src/main/resources/WEB-INF/prop/prop2map/ShBigdataConf.properties index 448dd3f..e78577d 100644 --- a/src/main/resources/WEB-INF/prop/prop2map/ShBigdataConf.properties +++ b/src/main/resources/WEB-INF/prop/prop2map/ShBigdataConf.properties @@ -1,24 +1,54 @@ -# ??????? +# 应用的凭证密钥 corpSecret=5eab6957b4944d75acfa9cfcc8feff5a agentId=10000060 corpId=wwdbb6b075752cc1b9 -# ??token??? +# 获取token的地址 tokenUrl=http://ramos-develop.shdata.com:11080/uranus/cgi-bin/gettoken -# ?????? +# 人员信息接口 userInfoUrl=http://ramos-develop.shdata.com:11080/uranus/cgi-bin/request/user/get -# ?????? +# 部门信息接口 departmentInfoUrl=http://ramos-develop.shdata.com:11080/uranus/cgi-bin/request/department/list -# ?????? +# 新增待办接口 addTodoTaskUrl=http://ramos-develop.shdata.com:11080/uranus/cgi-bin/request/task/create -# ?????? +# 更新待办接口 updateTodoTaskUrl=http://ramos-develop.shdata.com:11080/uranus/cgi-bin/request/task/update -# ?????????appId +# 新增待办接口的appId appId=wwdbb6b075752cc1b9 -# ????????????ID +# 统一待办推送日志记录模块ID modelId=112 -# ???????????sql ????????outkey ??sql?? select outkey from hrmresource where id in (${ids}) ?? +# 新增待办接口发送人转换sql 如果后面要改成传outkey 则将sql改为 select outkey from hrmresource where id in (${ids}) 即可 hrmSenderConvertRuleSql=select lastname from hrmresource where id in (${ids}) -# ????? +# 与上面同理 hrmReceiveConvertRuleSql=select lastname from hrmresource where id in (${ids}) -# oa token?????????? -expiryBeforeTime=5 \ No newline at end of file +# 统一待办pc端链接地址 +taskPcUrl= +# 统一待办移动端链接地址 +taskMobileUrl= +# oa token缓存对象提前过期时间 +expiryBeforeTime=5 + +# ================ 组织架构同步新增 ================ +# 分部最大的层级 +maxLevel=3 +# 组织结架构同步时是否递归获取 0递归 1非递归 +orgNoFetchChild=0 +# 组织结架构同步时同步增量数据 0 全量 1增量 +orgUpdateTime=0 +# 人员同步时同步增量数据 0 全量 1增量 +hrmUpdateTime=0 +# 组织架构同步日志模块id +orgHrmAsyncLogModelId=115 + + +# ================ sso ================ +# 根据code获取用户信息接口地址 +getUserInfoByCodeUrl= +# 人员校验成功后oa跳转地址 +loginSuccessSendRedirectUrl=/wui/index.html#/main +# 人员校验失败后oa跳转地址 +loginErrorSendRedirectUrl=/login/login.jsp +#debug +getUserIdDebug= +#debug key +getUserIdDebugOutKey= + diff --git a/src/test/java/xuanran/wang/big_data/BigDataTest.java b/src/test/java/xuanran/wang/big_data/BigDataTest.java new file mode 100644 index 0000000..fb032cb --- /dev/null +++ b/src/test/java/xuanran/wang/big_data/BigDataTest.java @@ -0,0 +1,400 @@ +package xuanran.wang.big_data; + +import aiyh.utils.Util; +import basetest.BaseTest; +import com.alibaba.fastjson.JSONObject; +import com.icbc.api.internal.apache.http.impl.cookie.S; +import com.weaver.esb.server.cache.ResourceComInfo; +import emo.macro.ob.OB; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.junit.Test; +import weaver.email.EmailWorkRunnable; +import weaver.general.TimeUtil; +import weaver.xuanran.wang.common.util.CusInfoToOAUtil; +import weaver.xuanran.wang.sh_bigdata.common.entity.CusSuccess; +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.OrganizationHrmSyncFromOtherSys; +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OrgHrmAsyncConfigMain; +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OtherSysDepartment; +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.mapper.OrgHrmAsyncMapper; +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.service.OrgHrmAsyncApiService; +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.service.impl.OrgHrmAsyncApiServiceImpl; +import weaver.xuanran.wang.sh_bigdata.org_hrm_async.service.impl.OrgHrmAsyncServiceImpl; + +import java.io.IOException; +import java.util.*; +import java.util.stream.Collectors; + +/** + *

+ * + * @author xuanran.wang + * @date 2023/4/10 10:49 + */ +public class BigDataTest extends BaseTest { + private final OrgHrmAsyncServiceImpl orgHrmAsyncService = new OrgHrmAsyncServiceImpl(); + private final OrgHrmAsyncApiService orgHrmAsyncApiService = new OrgHrmAsyncApiServiceImpl(); + private final List departmentWhiteList; + private final List subCompanyWhiteList; + private final OrgHrmAsyncMapper orgHrmAsyncMapper = Util.getMapper(OrgHrmAsyncMapper.class); + + { + departmentWhiteList = orgHrmAsyncMapper.selectCusDepart(); + subCompanyWhiteList = orgHrmAsyncMapper.selectCusSubCompany(); + } + + @Test + public void testA() throws IOException { +// List rootDepList = departmentInfo +// .stream() +// .filter(item -> 1 == item.getHasChild()) +// .sorted(Comparator.comparing(OtherSysDepartment::getId)) +// .collect(Collectors.toList()); +// for (OtherSysDepartment department : rootDepList) { +// setChildList(department, departmentInfo); +// } +// List departmentInfo = orgHrmAsyncApiService.getDepartmentInfo(); +// List convert = Util.listToTree(departmentInfo, +// OtherSysDepartment::getId, OtherSysDepartment::getParentid, +// OtherSysDepartment::getChildList, OtherSysDepartment::setChildList, +// parentid -> parentid == -1); +// System.out.println("convert => " + JSONObject.toJSONString(convert, SerializerFeature.DisableCircularReferenceDetect)); +// List hrmSubCompany = new ArrayList<>(); +// List hrmDepartment = new ArrayList<>(); +// int maxLevel = Util.getIntValue(ShBigDataUtil.getPropertiesValByKey("maxLevel"), 3); +// System.out.println(countNodes(convert.get(0))); +// parseSubCompanyAndDepartment(convert, 0,maxLevel, hrmSubCompany, hrmDepartment); +// parseSubCompanyAndDepartment(convert, hrmSubCompany); +// System.out.println("hrmSubCompany => " + hrmSubCompany.size()); +// System.out.println("convertLevel => " + JSONObject.toJSONString(convert, SerializerFeature.DisableCircularReferenceDetect)); +// System.out.println("hrmSubCompany => " + JSONObject.toJSONString(hrmSubCompany)); +// System.out.println("hrmDepartment => " + JSONObject.toJSONString(hrmDepartment)); +// orgHrmAsyncService.asyncDepartment(); + Map res = JSONObject.parseObject("{\n" + + "\t\t\"code\":0,\n" + + "\t\t\"msg\":\"ok\",\n" + + "\t\t\"data\":{\n" + + "\t\t\t\"UserId\":\"13800000000\",\n" + + "\t\t\t\"errcode\":0,\n" + + "\t\t\t\"errmsg\":\"ok\",\n" + + "\t\t\t\"id\":109,\n" + + "\t\t\t\"userid\":\"13800000000\",\n" + + "\t\t\t\"name\":\"祝芳\",\n" + + "\t\t\t\"mobile\":\"13800000000\",\n" + + "\t\t\t\"gender\":1,\n" + + "\t\t\t\"department\":[\n" + + "\t\t\t\t539\n" + + "\t\t\t],\n" + + "\t\t\t\"order\":[\n" + + "\t\t\t\t6\n" + + "\t\t\t]\n" + + "\t\t}\n" + + "\t}", Map.class); + System.out.println(getRes(res)); + } + + public String getRes(Map res){ + return (String) parseRes(res, cusSuccess); + } + + private final CusSuccess cusSuccess = CusSuccess.builder() + .successField("code") + .successValue(0) + .errorMsg("msg") + .dataKey("data.id") + .build(); + + public T parseRes(Map response, CusSuccess cusSuccess){ + String[] split = Util.null2DefaultStr(cusSuccess.getDataKey(),"").split("\\."); + int len = split.length; + if(len == 0 || StringUtils.isBlank(cusSuccess.getDataKey())){ + return (T)response; + } + for (int i = 0; i < len - 1; i++) { + response = (Map) response.get(split[i]); + } + return (T) response.get(split[len - 1]); + } + + @Test + public void testMap(){ + List> list = orgHrmAsyncApiService.getDepartmentInfoMap(); + // 将列表转换为以id为键的Map + List> tree = convertListToTree(list); + List> department = new ArrayList<>(); + List> subCompany = new ArrayList<>(); + orgHrmAsyncService.parseSubCompanyAndDepartmentMap(tree, 0, 3, department, subCompany); + System.out.println(JSONObject.toJSONString(department)); + System.out.println(JSONObject.toJSONString(subCompany)); + } + + @Test + public void testMapper(){ +// System.setProperty("_isDebug", "false"); +// System.out.println("分部执行结果 => " + JSONObject.toJSONString(orgHrmAsyncService.asyncOrgDep(0))); +// System.out.println("部门执行结果 => " + JSONObject.toJSONString(orgHrmAsyncService.asyncOrgDep(1))); +// List orgHrmAsyncConfigMains = orgHrmAsyncMapper.selectSubCompanyAsyncConfig(2); +// System.out.println(JSONObject.toJSONString(orgHrmAsyncConfigMains)); + ArrayList ids = new ArrayList<>(); + for (int i = 0; i < 100; i++) { + ids.add("'" + UUID.randomUUID().toString().replace("-","") + "'"); + } + String updateDelStatus = "update cus_fielddata set field0 = 1 where " + + weaver.general.Util.getSubINClause(StringUtils.join(ids,","),"field2","not in"); + System.out.println(updateDelStatus); + } + + @Test + public void testAsync(){ + System.out.println(TimeUtil.getCurrentTimeString()); + OrganizationHrmSyncFromOtherSys async = new OrganizationHrmSyncFromOtherSys(); + async.SynTimingToOASubCompany(); + async.SynTimingToOADepartment(); + HashMap synResult = async.getSynResult(); + System.out.println("res => \n" + JSONObject.toJSONString(synResult)); + System.out.println(TimeUtil.getCurrentTimeString()); + } + + @Test + public void testExtra(){ + orgHrmAsyncService.asyncHrm(); + } + + public List> convertListToTree(List> list){ + Map> map = new HashMap<>(); + for (Map item : list) { + map.put((Integer) item.get("id"), item); + } + + // 构建树形结构 + List> tree = new ArrayList<>(); + for (Map item : list) { + int parentId = (Integer) item.get("parentid"); + if (parentId == -1) { + // 添加根节点 + tree.add(item); + } else { + // 添加子节点 + Map parent = map.get(parentId); + if (parent != null) { + List> childList = (List>) parent.get("childList"); + if (childList == null) { + childList = new ArrayList<>(); + parent.put("childList", childList); + } + childList.add(item); + } + } + } + return tree; + } + public int countNodes(OtherSysDepartment node) { + int count = 1; // 当前节点也算一条数据 + List childList = node.getChildList(); + if (CollectionUtils.isNotEmpty(childList)) { + for (OtherSysDepartment otherSysDepartment : childList) { + count += countNodes(otherSysDepartment); + } + } + return count; + } + + public int countNodes(Map node) { + int count = 1; // 当前节点也算一条数据 + List> childList = (List>) node.get("childList"); + if (CollectionUtils.isNotEmpty(childList)) { + for (Map map : childList) { + count += countNodes(map); + } + } + return count; + } + + + /** + *

解析部门or分部

+ * @author xuanran.wang + * @dateTime 2023/4/10 12:13 + * @param list 树形集合 + * @param hrmDepartment 部门 + **/ + public void parseSubCompanyAndDepartment(List list, List hrmDepartment){ + for (OtherSysDepartment department : list) { + List childList = department.getChildList(); + if(CollectionUtils.isNotEmpty(childList)){ + parseSubCompanyAndDepartment(childList,hrmDepartment); + department.setChildList(null); + } + hrmDepartment.add(department); + } + } + + + /** + *

解析部门or分部

+ * @author xuanran.wang + * @dateTime 2023/4/10 12:13 + * @param list 树形集合 + * @param n 层级 + * @param hrmSubCompany 分部 + * @param hrmDepartment 部门 + **/ + public void parseSubCompanyAndDepartment(List list, int n, int maxLevel,List hrmSubCompany, List hrmDepartment){ + n++; + for (OtherSysDepartment department : list) { + department.setLevel(n); + List childList = department.getChildList(); + String departmentId = department.getId() + ""; + if(CollectionUtils.isNotEmpty(childList)){ + List collect = department.getChildList().stream().map(item -> Util.null2DefaultStr(item.getId(), "")).collect(Collectors.toList()); + if(departmentWhiteList.contains(departmentId)){ + departmentWhiteList.addAll(collect); + }else if(subCompanyWhiteList.contains(departmentId)){ + subCompanyWhiteList.addAll(collect); + } + parseSubCompanyAndDepartment(childList, n, maxLevel, hrmSubCompany, hrmDepartment); + department.setChildList(null); + } + if(n > maxLevel || departmentWhiteList.contains(departmentId)){ + hrmDepartment.add(department); + }else { + hrmSubCompany.add(department); + } + + } + } + + @Test + public void testParseObj(){ + String json = "{\n" + + " \"code\":0,\n" + + " \"msg\":\"ok\",\n" + + " \"data\":\n" + + " {\n" + + " \"errcode\": 0,\n" + + " \"errmsg\": \"ok\",\n" + + " \"id\": \"1\",\n" + + " \"userid\": \"superAdmin\",\n" + + " \"name\": \"超级管理员\",\n" + + " \"mobile\":\"12345678911\",\n" + + " \"email\":\"123@321.com\",\n" + + " \"gender\":0,\n" + + " \"position\":\"position\",\n" + + " \"avatarImg\":\"avatarImg\",\n" + + " \"workPhone\":\"workPhone\",\n" + + " \"fixedTelephone\":\"fixedTelephone\",\n" + + " \"extName\":\"extName\",\n" + + " \"userType\":0,\n" + + " \"department\": [\n" + + " 1\n" + + " ],\n" + + " \"order\": [\n" + + " 0\n" + + " ],\n" + + " \"rank\":\"rank\"\n" + + " }\n" + + "}"; + Map response = JSONObject.parseObject(json, Map.class); + String obj = Util.null2DefaultStr(getObj("data.id", response),""); + System.out.println("obj => " + obj); + } + + public T getObj(String dataKey, Map response){ + String[] split = Util.null2DefaultStr(dataKey,"").split("\\."); + int len = split.length; + if(len == 0 || StringUtils.isBlank(dataKey)){ + return (T)response; + } + for (int i = 0; i < len - 1; i++) { + response = (Map) response.get(split[i]); + } + return (T) response.get(split[len - 1]); + } + + @Test + public void testMsg(){ + String html = "\n" + + "\n" + + "\n" + + "\tInvestment Calculator\n" + + "\t\n" + + "\n" + + "\n" + + "\t\n" + + "\t\t\n" + + "\t\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\n" + + "\t\t\n" + + " \t
投资试算(场外基金)
ABCDEFGHIJKLM
Cell A1Cell B1Cell C1Cell D1Cell E1Cell F1Cell G1Cell H1Cell I1Cell J1Cell K1Cell L1Cell M1
\n" + + " \n" + + "\n"; + EmailWorkRunnable.threadModeReminder("3055088966@qq.com,xuanran.wang@weaver.com.cn", "test11", html); + + } + + @Test + public void testG(){ +// String sql =" select case '$t{test1}' when '03' then '场外基金' when '04' then '基金赎回' else '测试下' end"; +// HashMap param = new HashMap<>(); +// param.put("test1","04"); +// String s = orgHrmAsyncMapper.selectCustomerSql(sql, param); +// System.out.println("s => " + s); + HashMap map = new HashMap<>(); + map.put("tiem", new Date()); + System.out.println("map => " + JSONObject.toJSONString(map)); + } +} diff --git a/src/test/java/xuanran/wang/cssc/FileTest.java b/src/test/java/xuanran/wang/cssc/FileTest.java new file mode 100644 index 0000000..4d558da --- /dev/null +++ b/src/test/java/xuanran/wang/cssc/FileTest.java @@ -0,0 +1,204 @@ +package xuanran.wang.cssc; + +import aiyh.utils.excention.CustomerException; +import basetest.BaseTest; +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.lang3.StringUtils; +import org.junit.Test; +import weaver.general.Util; +import weaver.xuanran.wang.cssc.cms.entity.CusSuccess; + +import java.io.*; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.*; +import java.util.stream.Collectors; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +/** + *

+ * + * @author xuanran.wang + * @date 2023/4/26 13:30 + */ +public class FileTest extends BaseTest { + @Test + public void testA(){ +// compressToZip("/Users/wangxuanran/company/test/1231233","/Users/wangxuanran/company/test/1231233","test.zip"); + try { +// File file = new File("/Users/wangxuanran/company/test/1231233/test.zip"); +// long length = file.length(); +// System.out.println("length => " + length); +// String md5 = DigestUtils.md5Hex(Files.newInputStream(Paths.get("/Users/wangxuanran/company/test/1231233/test.zip"))); +// String fileName = "hfsh.txt"; +// System.out.println(fileName.substring(fileName.lastIndexOf(".") + 1)); +// System.out.println("md5 => " + md5); +// System.out.println(System.currentTimeMillis()); + +// String xml = "\n" + +// "\n" + +// "\t\n" + +// "\t\tEIPPACK\t\t\n" + +// "\t\tP-TC____-20190821144756-1 \n" + +// "\t\tTC \n" + +// "\t\tTC \n" + +// "\t\t主机厂文件 \n" + +// "\t\t1 \n" + +// "\t\n" + +// "\t\n" + +// "\t\t \n" + +// "\t\t\t<公司代码>1001\n" + +// "\t\t\t<流程id>2341234123j8jhsu\n" + +// "\t\t\t<题名>我是用来测试归档接口123\n" + +// "\t\t\t<文号>[xin]129号\n" + +// "\t\t\t<成文日期>20230301\n" + +// "\t\t\t<主机厂名称>红旗\n" + +// "\t\t\n" + +// "\t\t \n" + +// "\t\t\t\n" + +// "\t\t\t\t1.pdf \n" + +// "\t\t\t\tOA审批结果 \n" + +// "\t\t\t\t81098 \n" + +// "\t\t\t\t20190821144756 \n" + +// "\t\t\t\t05cc9c29599ae67cf545fe380d679326 \n" + +// "\t\t\t\tpdf \n" + +// "\t\t\t\t1.pdf\n" + +// "\t\t\t\n" + +// "\t\t\t\n" + +// "\t\t\t\t1.pdf \n" + +// "\t\t\t\tOA审批结果 \n" + +// "\t\t\t\t81098 \n" + +// "\t\t\t\t20190821144756 \n" + +// "\t\t\t\t05cc9c29599ae67cf545fe380d679326 \n" + +// "\t\t\t\tpdf \n" + +// "\t\t\t\t1.pdf\n" + +// "\t\t\t\n" + +// "\t\t\n" + +// "\t\n" + +// "\n"; +// FileWriter fileWriter; +// try +// { +// fileWriter = new FileWriter("/Users/wangxuanran/company/test/1231233/test.xml", false); +// fileWriter.write(xml); +// fileWriter.flush(); +// fileWriter.close(); +// } catch (IOException e) +// { +// e.printStackTrace(); +// } + //按changerule排序 +// HashMap map = new HashMap<>(); +// map.put("success", false); +// HashMap token = new HashMap<>(); +// token.put("asscess", "121223213213"); +// map.put("result", token); +// map.put("error","报错了!!!!"); +// +// CusSuccess build = CusSuccess.builder().successField("success").successValue("true").errorMsg("error").dataKey("result.asscess").build(); +// Object response = getResponse(build, map); +// System.out.println("response => " + response ); + + String str = ",w1,w2,we"; + System.out.println(str.substring(1)); + testC("1"); + }catch (Exception e){ + + log.error("e => " + e.getMessage()); + } + } + + public void testC(String type){ + switch (type){ + case "1":{ + System.out.println("1"); + return; + } + case "2":{ + System.out.println("2"); + return; + } + case "3":{ + System.out.println("3"); + return; + } + } + } + + public T getResponse(CusSuccess cusSuccess, Map response){ + String responseValue = aiyh.utils.Util.null2DefaultStr(response.get(cusSuccess.getSuccessField()), ""); + if (!cusSuccess.getSuccessValue().equals(responseValue)) { + throw new CustomerException(aiyh.utils.Util.logStr("接口地址:[{}], 接口响应码不为: [{}], 接口响应信息: {}", "", cusSuccess.getSuccessValue(), aiyh.utils.Util.null2DefaultStr(response.get(cusSuccess.getErrorMsg()), ""))); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串 + } + String[] split = aiyh.utils.Util.null2DefaultStr(cusSuccess.getDataKey(),"").split("\\."); + int len = split.length; + if(len == 0 || StringUtils.isBlank(cusSuccess.getDataKey())){ + return (T)response; + } + for (int i = 0; i < len - 1; i++) { + response = (Map) response.get(split[i]); + } + return (T) response.get(split[len - 1]); + } + + /** + * 压缩文件 + * + * @param sourceFilePath 源文件路径 + * @param zipFilePath 压缩后文件存储路径 + * @param zipFilename 压缩文件名 + */ + public void compressToZip(String sourceFilePath, String zipFilePath, String zipFilename) { + File sourceFile = new File(sourceFilePath); + File zipPath = new File(zipFilePath); + if (!zipPath.exists()) { + zipPath.mkdirs(); + } + File zipFile = new File(zipPath + File.separator + zipFilename); + try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile))) { + writeZip(sourceFile, "", zos, zipFilename); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException(e.getMessage(), e.getCause()); + } + } + + /** + * 遍历所有文件,压缩 + * + * @param file 源文件目录 + * @param parentPath 压缩文件目录 + * @param zos 文件流 + */ + public void writeZip(File file, String parentPath, ZipOutputStream zos, String zipName) { + if (file.isDirectory()) { + //目录 + parentPath += file.getName() + File.separator; + File[] files = file.listFiles(); + for (File f : files) { + writeZip(f, parentPath, zos, zipName); + } + } else { + if(file.getName().equals(zipName)){ + return; + } + //文件 + try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file))) { + ZipEntry zipEntry = new ZipEntry(file.getName()); + zos.putNextEntry(zipEntry); + int len; + byte[] buffer = new byte[1024 * 10]; + while ((len = bis.read(buffer, 0, buffer.length)) != -1) { + zos.write(buffer, 0, len); + zos.flush(); + } + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException(e.getMessage(), e.getCause()); + } + } + } + +} diff --git a/src/test/java/xuanran/wang/eighty_five_degreec/SAPTest.java b/src/test/java/xuanran/wang/eighty_five_degreec/SAPTest.java new file mode 100644 index 0000000..da47043 --- /dev/null +++ b/src/test/java/xuanran/wang/eighty_five_degreec/SAPTest.java @@ -0,0 +1,52 @@ +package xuanran.wang.eighty_five_degreec; + +import aiyh.utils.tool.cn.hutool.core.lang.UUID; +import basetest.BaseTest; +import org.junit.Test; +import weaver.xuanran.wang.common.util.CusData2OA; +import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.MainRequestConfig; +import weaver.xuanran.wang.eighty_five_degreec.sap.util.ReadConfigUtil; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + *

+ * + * @author xuanran.wang + * @date 2023/4/19 15:50 + */ +public class SAPTest extends BaseTest { + + @Test + public void testXml(){ + ReadConfigUtil configUtil = new ReadConfigUtil(); + String uniqueCode = "test1"; + String tableName = "formtable_main_161"; + String requestId = "419420"; + MainRequestConfig config = configUtil.getConfigByUniqueCode(uniqueCode, tableName); + String xml = configUtil.getXml(config, requestId, tableName); + System.out.println("xml => \n " + xml); + } + + @Test + public void testSQl(){ + String modelId = "119"; + String sql = " select id from #{tableName} where reqId = #{reqId}"; + List> list = new ArrayList<>(); + HashMap param = new HashMap<>(); + param.put("reqId",222222222); + param.put("requestXml",""); + list.add(param); + for (int i = 0; i < 10; i++) { + HashMap params = new HashMap<>(); + params.put("reqId",i + "1232"); + params.put("requestXml", UUID.randomUUID().toString()); + list.add(params); + } + List strings = CusData2OA.batchWriteToModel(modelId, sql, list); + System.out.println("data => " + strings); + } +} diff --git a/src/test/java/xuanran/wang/immc/Kafka/MQTest.java b/src/test/java/xuanran/wang/immc/Kafka/MQTest.java index d2d69fe..76fc915 100644 --- a/src/test/java/xuanran/wang/immc/Kafka/MQTest.java +++ b/src/test/java/xuanran/wang/immc/Kafka/MQTest.java @@ -324,7 +324,15 @@ public class MQTest extends BaseTest { } + private final SendTodoTaskMapper sendTodoTaskMapper = Util.getMapper(SendTodoTaskMapper.class); + @Test + public void testE(){ + ArrayList list = new ArrayList<>(); + list.add("146723321680844588"); + list.add("146723321680844588"); + sendTodoTaskMapper.updateStatusByTaskNum(list); + } SendTodoTaskUtil sendTodoTaskUtil = new SendTodoTaskUtil(); @Test public void testToken(){ diff --git a/src/test/java/xuanran/wang/traffic_bank/EmailOutSendTest.java b/src/test/java/xuanran/wang/traffic_bank/EmailOutSendTest.java new file mode 100644 index 0000000..cb11acf --- /dev/null +++ b/src/test/java/xuanran/wang/traffic_bank/EmailOutSendTest.java @@ -0,0 +1,45 @@ +package xuanran.wang.traffic_bank; + +import aiyh.utils.ThreadPoolConfig; +import aiyh.utils.Util; +import basetest.BaseTest; +import cn.hutool.extra.ssh.Sftp; +import com.alibaba.fastjson.JSONObject; +import com.api.xuanran.wang.traffic_bank.email.entity.EmailOutConfigMain; +import com.api.xuanran.wang.traffic_bank.email.service.EmailOutSendService; +import com.api.xuanran.wang.traffic_bank.email.service.impl.EmailOutSendServiceImpl; +import org.junit.Test; + +import java.util.*; +import java.util.concurrent.ExecutorService; + +/** + *

+ * + * @author xuanran.wang + * @date 2023/4/18 16:31 + */ +public class EmailOutSendTest extends BaseTest { + private final EmailOutSendService service = new EmailOutSendServiceImpl(); + @Test + public void testA(){ + EmailOutConfigMain emailOutConfigMain = service.selectConfigByTransType(0); + log.info(JSONObject.toJSONString(emailOutConfigMain)); + HashMap param = new HashMap<>(); + HashMap param2 = new HashMap<>(); + List> list = new ArrayList<>(); + for (int i = 1; i <= 10; i++) { + param.put("a" + i, "测试记得回家的风刀霜剑方便的伤风败俗的肌肤都不舒服就不是的"+i); + param2.put("a"+i, "待会见阿富汗就啊好时机啊打开的健身卡的撒娇的v啊大把的挥洒都不会撒不对劲啊舍不得"+i); + } + list.add(param); + list.add(param2); + param.put("email",22); + param2.put("email",94); + ThreadPoolConfig.createThreadPoolInstance(); + param.put("type",0); + param.put("data", list); + service.sendEmail(param); + + } +} From 78140f7c3548aead27a575af671279a7ad8d4773 Mon Sep 17 00:00:00 2001 From: ic_excellent Date: Sat, 6 May 2023 13:51:21 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xiao/zscq/entity/SendFileEntity.java | 8 + .../bokang/xiao/zscq/entity/WeaverFile.java | 8 + .../bokang/xiao/zscq/mapper/QueryMapper.java | 8 + .../api/interfaces/liyi/DataCenterApi.java | 584 +++++++++++ .../api/interfaces/liyi/common/ApiResult.java | 59 ++ .../liyi/crod/HuilianyiTravelJob.java | 602 ++++++++++++ .../liyi/service/HuilianyiClientService.java | 23 + .../impl/HuilianyiClientServiceImpl.java | 76 ++ .../zenner/job/SyncAccountInfoFromSapJob.java | 155 +++ .../zenner/job/SyncAccountStatementJob.java | 259 +++++ .../zenner/job/SyncAccountTradeInfoJob.java | 332 +++++++ .../zenner/model/bank/DayBalance.java | 379 ++++++++ .../zenner/model/bank/TradeInfo.java | 582 +++++++++++ .../zenner/model/sap/PeriodBalance.java | 314 ++++++ .../service/bank/Bank_b2e0005_Service.java | 130 +++ .../service/bank/Bank_b2e0035_Service.java | 160 +++ .../zenner/utils/SAPWebserviceTool.java | 288 ++++++ .../zenner/utils/ZennerApiService.java | 20 + .../zenner/utils/ZennerUtil.java | 374 +++++++ .../GetFieldDefinedCmd.java | 309 ++++++ .../SaveFieldDefinedCmd.java | 213 ++++ .../GetDepartmentFormFieldCmd.java | 189 ++++ .../GetSubCompanyFormFieldCmd.java | 183 ++++ .../GetFieldDefinedCmd.java | 310 ++++++ .../SaveFieldDefinedCmd.java | 211 ++++ .../xiao/tbxc/mapper/FormFieldMapper.java | 8 + .../zscq/fun/WorkflowRepossessedSign.java | 8 + src/main/resources/ContractList(2).jsp | 499 ++++++++++ .../resources/ContractReportExport(1).jsp | 127 +++ src/main/resources/ajzx/ContractList.jsp | 499 ++++++++++ .../resources/ajzx/ContractReportExport.jsp | 127 +++ src/main/resources/ajzx/SalesContractList.jsp | 916 ++++++++++++++++++ .../ajzx/SalesContractListBacthExport.jsp | 138 +++ 33 files changed, 8098 insertions(+) create mode 100644 src/main/java/com/api/bokang/xiao/zscq/entity/SendFileEntity.java create mode 100644 src/main/java/com/api/bokang/xiao/zscq/entity/WeaverFile.java create mode 100644 src/main/java/com/api/bokang/xiao/zscq/mapper/QueryMapper.java create mode 100644 src/main/java/com/api/interfaces/liyi/DataCenterApi.java create mode 100644 src/main/java/com/api/interfaces/liyi/common/ApiResult.java create mode 100644 src/main/java/com/api/interfaces/liyi/crod/HuilianyiTravelJob.java create mode 100644 src/main/java/com/api/interfaces/liyi/service/HuilianyiClientService.java create mode 100644 src/main/java/com/api/interfaces/liyi/service/impl/HuilianyiClientServiceImpl.java create mode 100644 src/main/java/com/api/nonstandardext/zenner/job/SyncAccountInfoFromSapJob.java create mode 100644 src/main/java/com/api/nonstandardext/zenner/job/SyncAccountStatementJob.java create mode 100644 src/main/java/com/api/nonstandardext/zenner/job/SyncAccountTradeInfoJob.java create mode 100644 src/main/java/com/api/nonstandardext/zenner/model/bank/DayBalance.java create mode 100644 src/main/java/com/api/nonstandardext/zenner/model/bank/TradeInfo.java create mode 100644 src/main/java/com/api/nonstandardext/zenner/model/sap/PeriodBalance.java create mode 100644 src/main/java/com/api/nonstandardext/zenner/service/bank/Bank_b2e0005_Service.java create mode 100644 src/main/java/com/api/nonstandardext/zenner/service/bank/Bank_b2e0035_Service.java create mode 100644 src/main/java/com/api/nonstandardext/zenner/utils/SAPWebserviceTool.java create mode 100644 src/main/java/com/api/nonstandardext/zenner/utils/ZennerApiService.java create mode 100644 src/main/java/com/api/nonstandardext/zenner/utils/ZennerUtil.java create mode 100644 src/main/java/com/engine/hrm/cmd/departmentfielddefined/GetFieldDefinedCmd.java create mode 100644 src/main/java/com/engine/hrm/cmd/departmentfielddefined/SaveFieldDefinedCmd.java create mode 100644 src/main/java/com/engine/hrm/cmd/organization/GetDepartmentFormFieldCmd.java create mode 100644 src/main/java/com/engine/hrm/cmd/organization/GetSubCompanyFormFieldCmd.java create mode 100644 src/main/java/com/engine/hrm/cmd/subcompanyfielddefined/GetFieldDefinedCmd.java create mode 100644 src/main/java/com/engine/hrm/cmd/subcompanyfielddefined/SaveFieldDefinedCmd.java create mode 100644 src/main/java/weaver/bokang/xiao/tbxc/mapper/FormFieldMapper.java create mode 100644 src/main/java/weaver/bokang/xiao/zscq/fun/WorkflowRepossessedSign.java create mode 100644 src/main/resources/ContractList(2).jsp create mode 100644 src/main/resources/ContractReportExport(1).jsp create mode 100644 src/main/resources/ajzx/ContractList.jsp create mode 100644 src/main/resources/ajzx/ContractReportExport.jsp create mode 100644 src/main/resources/ajzx/SalesContractList.jsp create mode 100644 src/main/resources/ajzx/SalesContractListBacthExport.jsp diff --git a/src/main/java/com/api/bokang/xiao/zscq/entity/SendFileEntity.java b/src/main/java/com/api/bokang/xiao/zscq/entity/SendFileEntity.java new file mode 100644 index 0000000..5a61ceb --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/zscq/entity/SendFileEntity.java @@ -0,0 +1,8 @@ +package com.api.bokang.xiao.zscq.entity;/** + *@ClassName SendFileEntity + *@Author 肖博亢 + *@Date 2023/4/23 10:10 + *@Description

+ **/ +public class SendFileEntity { +} diff --git a/src/main/java/com/api/bokang/xiao/zscq/entity/WeaverFile.java b/src/main/java/com/api/bokang/xiao/zscq/entity/WeaverFile.java new file mode 100644 index 0000000..25efe04 --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/zscq/entity/WeaverFile.java @@ -0,0 +1,8 @@ +package com.api.bokang.xiao.zscq.entity;/** + *@ClassName WeaverFile + *@Author 肖博亢 + *@Date 2023/4/23 10:09 + *@Description

+ **/ +public class WeaverFile { +} diff --git a/src/main/java/com/api/bokang/xiao/zscq/mapper/QueryMapper.java b/src/main/java/com/api/bokang/xiao/zscq/mapper/QueryMapper.java new file mode 100644 index 0000000..4c2e603 --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/zscq/mapper/QueryMapper.java @@ -0,0 +1,8 @@ +package com.api.bokang.xiao.zscq.mapper;/** + *@ClassName QueryMapper + *@Author 肖博亢 + *@Date 2023/4/23 10:14 + *@Description

+ **/ +public interface QueryMapper { +} diff --git a/src/main/java/com/api/interfaces/liyi/DataCenterApi.java b/src/main/java/com/api/interfaces/liyi/DataCenterApi.java new file mode 100644 index 0000000..3e68f9e --- /dev/null +++ b/src/main/java/com/api/interfaces/liyi/DataCenterApi.java @@ -0,0 +1,584 @@ +package com.api.interfaces.liyi; + +import com.alibaba.fastjson.JSON; +import com.api.interfaces.liyi.common.ApiResult; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +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.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Path("/xsd/DataCenterApi") +public class DataCenterApi extends BaseBean { + + @GET + @Path("/getCompInfo") + @Produces(MediaType.TEXT_PLAIN) + public String getCompInfo(@Context HttpServletRequest request, @Context HttpServletResponse response){ + ApiResult> apiResult = new ApiResult<>(); + RecordSet rs = new RecordSet(); + String idCard = Util.null2String(request.getParameter("id_card")); + String tableName = getFormId("datacenter_table"); + HashMap comMap = new HashMap<>(); + try { + if(!idCard.equals("")){ + String id = ""; + String sql = "select top 1 * from "+tableName+" where field016 = '"+idCard+"' order by id desc"; + writeLog("------sql zb------"+sql); + rs.executeQuery(sql); + if(rs.next()){ + id = rs.getString("id"); + String ypgw = rs.getString("field055"); + String ypgw_xz = getSelectName(tableName,null,"field055",ypgw); + String djrq = rs.getString("field007"); + String xm = rs.getString("field008"); + String xb = rs.getString("field052"); + String xb_xz = getSelectName(tableName,null,"field052",xb); + String csrq = rs.getString("field010"); + String mz = rs.getString("field053"); + String mz_xz = getSelectName(tableName,null,"field053",mz); + String jg = rs.getString("field056"); + String jg_xz = getSelectName(tableName,null,"field056",jg); + String hy = rs.getString("field085"); + String hy_xz = getSelectName(tableName,null,"field085",hy); + String zzmm = rs.getString("field054"); + String zzmm_xz = getSelectName(tableName,null,"field054",zzmm); + String sj = rs.getString("field015"); + String yx = rs.getString("field017"); + String pro = rs.getString("field077"); + String city = rs.getString("field078"); + String qx = rs.getString("field079"); + String xxdz = rs.getString("field080"); + String xpro = rs.getString("field081"); + String xcity = rs.getString("field082"); + String xqx = rs.getString("field083"); + String xxxdz = rs.getString("field084"); + String jjlxr = rs.getString("field020"); + String jjlxrgx = rs.getString("field086"); + jjlxrgx = getSelectName(tableName,null,"field086",jjlxrgx); + String lxrdh = rs.getString("field022"); + String english = rs.getString("field023"); + english = getSelectName(tableName,null,"field023",english); + String cert = rs.getString("field061"); + String eng_fj = rs.getString("field058"); + String qtyz = rs.getString("field059"); + String djzs = rs.getString("field062"); + String qtyz_fj = rs.getString("field060"); + String zyzg = rs.getString("field063"); + String zyzgzs = rs.getString("field064"); + String zyzg_fj = rs.getString("field065"); + String qtjn = rs.getString("field066"); + String bgrj = rs.getString("field067"); + String qtjn_fj = rs.getString("field068"); + String xqah = rs.getString("field025"); + String gdxzsq = rs.getString("field026"); + String qwxzsq = rs.getString("field027"); + String sbyf = rs.getString("field028"); + String sbnf = rs.getString("field029"); + String gzlxdh = rs.getString("field030"); + String zmr = rs.getString("field031"); + String zmrgw = rs.getString("field032"); + String sfjcldht = rs.getString("field033"); + String sfjlcf = rs.getString("field034"); + String sfjb = rs.getString("field035"); + String sfss = rs.getString("field036"); + String sfyhjkgz = rs.getString("field037"); + String sfyytj = rs.getString("field038"); + String sftgbszy = rs.getString("field039"); + String tjrxm = rs.getString("field040"); + String tjrgx = rs.getString("field041"); + String bgsqs = rs.getString("field042"); + String gxr = rs.getString("field046"); + String gxrgx = rs.getString("field047"); + String tbr = rs.getString("field048"); + String sfty = rs.getString("field069"); + + comMap.put("ypgw",ypgw); + comMap.put("ypgw_xz",ypgw_xz); + comMap.put("djrq",djrq); + comMap.put("xm",xm); + comMap.put("xb",xb); + comMap.put("xb_xz",xb_xz); + comMap.put("csrq",csrq); + comMap.put("mz",mz); + comMap.put("mz_xz",mz_xz); + comMap.put("jg",jg); + comMap.put("jg_xz",jg_xz); + comMap.put("hy",hy); + comMap.put("hy_xz", hy_xz); + comMap.put("zzmm",zzmm); + comMap.put("zzmm_xz",zzmm_xz); + comMap.put("sj",sj); + comMap.put("yx",yx); + comMap.put("pro",pro); + comMap.put("city",city); + comMap.put("qx",qx); + comMap.put("xxdz",xxdz); + comMap.put("xpro",xpro); + comMap.put("xcity",xcity); + comMap.put("xqx",xqx); + comMap.put("xxxdz",xxxdz); + comMap.put("jjlxr",jjlxr); + comMap.put("jjlxrgx",jjlxrgx); + comMap.put("lxrdh",lxrdh); + comMap.put("english",english); + comMap.put("cert",cert); + comMap.put("eng_fj",eng_fj); + comMap.put("qtyz",qtyz); + comMap.put("djzs",djzs); + comMap.put("qtyz_fj",qtyz_fj); + comMap.put("zyzg",zyzg); + comMap.put("zyzgzs",zyzgzs); + comMap.put("zyzg_fj",zyzg_fj); + comMap.put("qtjn",qtjn); + comMap.put("bgrj",bgrj); + comMap.put("qtjn_fj",qtjn_fj); + comMap.put("xqah",xqah); + comMap.put("gdxzsq",gdxzsq); + comMap.put("qwxzsq",qwxzsq); + comMap.put("sbyf",sbyf); + comMap.put("sbnf",sbnf); + comMap.put("gzlxdh",gzlxdh); + comMap.put("zmr",zmr); + comMap.put("zmrgw",zmrgw); + comMap.put("sfjcldht",sfjcldht); + comMap.put("sfjlcf",sfjlcf); + comMap.put("sfjb",sfjb); + comMap.put("sfss",sfss); + comMap.put("sfyhjkgz",sfyhjkgz); + comMap.put("sfyytj",sfyytj); + comMap.put("sftgbszy",sftgbszy); + comMap.put("tjrxm",tjrxm); + comMap.put("tjrgx",tjrgx); + comMap.put("bgsqs",bgsqs); + comMap.put("gxr",gxr); + comMap.put("gxrgx",gxrgx); + comMap.put("sfty",sfty); + comMap.put("tbr",tbr); + } + List> dt1_list = new ArrayList<>(); + sql = "select * from "+tableName+"_dt1 where mainid = '"+id+"'"; + writeLog("------sql dt1------"+sql); + rs.executeQuery(sql); + while(rs.next()){ + HashMap dt1_map = new HashMap<>(); + String xl = rs.getString("field008"); + String xl_xz = getSelectName(tableName,tableName+"_dt1","field008",xl); + String start = rs.getString("field009"); + String end = rs.getString("field010"); + String xx = rs.getString("field004"); + String zy = rs.getString("field005"); + String xxxs = rs.getString("field011"); + String xxxs_xz = getSelectName(tableName,tableName+"_dt1","field011",xxxs); + String xw = rs.getString("field012"); + String xw_xz = getSelectName(tableName,tableName+"_dt1","field012",xw); + dt1_map.put("xl",xl); + dt1_map.put("xl_xz",xl_xz); + dt1_map.put("start",start); + dt1_map.put("end",end); + dt1_map.put("xx",xx); + dt1_map.put("zy",zy); + dt1_map.put("xxxs",xxxs); + dt1_map.put("xxxs_xz",xxxs_xz); + dt1_map.put("xw",xw); + dt1_map.put("xw_xz",xw_xz); + dt1_list.add(dt1_map); + } + writeLog("------sql dt1--data----"+dt1_list.toString()); + comMap.put("dt1",dt1_list); + List> dt2_list = new ArrayList<>(); + sql = "select * from "+tableName+"_dt2 where mainid = '"+id+"'"; + rs.executeQuery(sql); + writeLog("------sql dt2------"+sql); + while(rs.next()){ + HashMap dt2_map = new HashMap<>(); + String start = rs.getString("field008"); + String end = rs.getString("field009"); + String gzdw = rs.getString("field003"); + String gzdwdz = rs.getString("field004"); + String gw = rs.getString("field005"); + String lzyy = rs.getString("field006"); + String lxdh = rs.getString("field007"); + dt2_map.put("start",start); + dt2_map.put("end",end); + dt2_map.put("gzdw",gzdw); + dt2_map.put("gzdwdz",gzdwdz); + dt2_map.put("gw",gw); + dt2_map.put("lzyy",lzyy); + dt2_map.put("lxdh",lxdh); + dt2_list.add(dt2_map); + } + writeLog("------sql dt2--data----"+dt2_list.toString()); + comMap.put("dt2",dt2_list); + List> dt3_list = new ArrayList<>(); + sql = "select * from "+tableName+"_dt3 where mainid = '"+id+"'"; + writeLog("------sql dt3-----"+sql); + rs.executeQuery(sql); + while(rs.next()){ + HashMap dt3_map = new HashMap<>(); + String xm = rs.getString("field001"); + String gx = rs.getString("field005"); + String gx_xz = getSelectName(tableName,tableName+"_dt3","field005",gx); + String nl = rs.getString("field003"); + String gzdw = rs.getString("field004"); + dt3_map.put("xm",xm); + dt3_map.put("gx",gx); + dt3_map.put("gx_xz",gx_xz); + dt3_map.put("nl",nl); + dt3_map.put("gzdw",gzdw); + dt3_list.add(dt3_map); + } + writeLog("------sql dt3--data----"+dt3_list.toString()); + comMap.put("dt3",dt3_list); + List> dt4_list = new ArrayList<>(); + sql = "select * from "+tableName+"_dt4 where mainid = '"+id+"'"; + writeLog("------sql dt4------"+sql); + rs.executeQuery(sql); + while(rs.next()){ + HashMap dt4_map = new HashMap<>(); + String yz = rs.getString("field001"); + String cert = rs.getString("field002"); + dt4_map.put("qtyz",yz); + dt4_map.put("djzs",cert); + dt4_list.add(dt4_map); + } + writeLog("------sql dt4--data----"+dt4_list.toString()); + comMap.put("dt4",dt4_list); + List> dt5_list = new ArrayList<>(); + sql ="select * from "+tableName+"_dt5 where mainid = '"+id+"'"; + writeLog("------sql dt5------"+sql); + rs.executeQuery(sql); + while(rs.next()){ + HashMap dt5_map = new HashMap<>(); + String zgzs = rs.getString("field001"); + String bgrj = rs.getString("field002"); + dt5_map.put("zgzs",zgzs); + dt5_map.put("bgrj",bgrj); + dt5_list.add(dt5_map); + } + writeLog("------sql dt5--data----"+dt5_list.toString()); + comMap.put("dt5",dt5_list); + + List> dt6_list = new ArrayList<>(); + sql = "select * from "+tableName+"_dt6 where mainid = '"+id+"'"; + writeLog("------sql dt6------"+sql); + rs.executeQuery(sql); + while(rs.next()){ + HashMap dt6_map = new HashMap<>(); + String wbk = rs.getString("field001"); + dt6_map.put("wbk",wbk); + dt6_list.add(dt6_map); + } + writeLog("------sql dt6--data----"+dt6_list.toString()); + comMap.put("dt6",dt6_list); + + List> dt7_list = new ArrayList<>(); + sql = "select * from "+tableName+"_dt7 where mainid = '"+id+"'"; + writeLog("------sql dt7------"+sql); + rs.executeQuery(sql); + while(rs.next()){ + HashMap dt7_map = new HashMap<>(); + String kcmc = rs.getString("field001"); + String ksrq = rs.getString("field002"); + String jsrq = rs.getString("field003"); + dt7_map.put("kcmc",kcmc); + dt7_map.put("ksrq",ksrq); + dt7_map.put("jsrq",jsrq); + dt7_list.add(dt7_map); + } + writeLog("------sql dt7--data----"+dt7_list.toString()); + comMap.put("dt7",dt7_list); + + List> dt8_list = new ArrayList<>(); + sql = "select * from "+tableName+"_dt8 where mainid = '"+id+"'"; + writeLog("------sql dt8------"+sql); + rs.executeQuery(sql); + while(rs.next()){ + HashMap dt8_map = new HashMap<>(); + String jlqk = rs.getString("field001"); + String jlqk_xz = getSelectName(tableName,tableName+"_dt8","field001",jlqk); + String nr1 = rs.getString("field002"); + String nr2 = rs.getString("field003"); + dt8_map.put("jlqk",jlqk); + dt8_map.put("jlqk_xz",jlqk_xz); + dt8_map.put("nr1",nr1); + dt8_map.put("nr2",nr2); + dt8_list.add(dt8_map); + } + writeLog("------sql dt8--data----"+dt8_list.toString()); + comMap.put("dt8",dt8_list); + + List> dt9_list = new ArrayList<>(); + sql = "select * from "+tableName+"_dt9 where mainid = '"+id+"'"; + writeLog("------sql dt9------"+sql); + rs.executeQuery(sql); + while(rs.next()){ + HashMap dt9_map = new HashMap<>(); + String rq = rs.getString("field001"); + String nr = rs.getString("field002"); + String yy = rs.getString("field003"); + String lb = rs.getString("field004"); + String jb = rs.getString("field005"); + String dw = rs.getString("field006"); + String je = rs.getString("field007"); + String bz = rs.getString("field008"); + dt9_map.put("rq",rq); + dt9_map.put("nr",nr); + dt9_map.put("yy",yy); + dt9_map.put("lb",lb); + dt9_map.put("jb",jb); + dt9_map.put("dw",dw); + dt9_map.put("je",je); + dt9_map.put("bz",bz); + dt9_list.add(dt9_map); + } + writeLog("------sql dt9--data----"+dt9_list.toString()); + comMap.put("dt9",dt9_list); + + List> dt10_list = new ArrayList<>(); + sql = "select * from "+tableName+"_dt10 where mainid = '"+id+"'"; + writeLog("------sql dt10------"+sql); + rs.executeQuery(sql); + while(rs.next()){ + HashMap dt10_map = new HashMap<>(); + String rq = rs.getString("field001"); + String nr = rs.getString("field002"); + String yy = rs.getString("field003"); + String lb = rs.getString("field004"); + String jb = rs.getString("field005"); + String dw = rs.getString("field006"); + String je = rs.getString("field007"); + String bz = rs.getString("field008"); + dt10_map.put("rq",rq); + dt10_map.put("nr",nr); + dt10_map.put("yy",yy); + dt10_map.put("lb",lb); + dt10_map.put("jb",jb); + dt10_map.put("dw",dw); + dt10_map.put("je",je); + dt10_map.put("bz",bz); + dt10_list.add( dt10_map); + } + writeLog("------sql dt10--data----"+dt10_list.toString()); + comMap.put("dt10",dt10_list); + + List> dt11_list = new ArrayList<>(); + sql = "select * from "+tableName+"_dt11 where mainid = '"+id+"'"; + writeLog("------sql dt11------"+sql); + rs.executeQuery(sql); + while(rs.next()){ + HashMap dt11_map = new HashMap<>(); + String rq = rs.getString("field001"); + String cg = rs.getString("field002"); + String jg = rs.getString("field003"); + String zl = rs.getString("field004"); + String bz = rs.getString("field005"); + + dt11_map.put("rq",rq); + dt11_map.put("cg",cg); + dt11_map.put("jg",jg); + dt11_map.put("zl",zl); + dt11_map.put("bz",bz); + dt11_list.add( dt11_map); + } + writeLog("------sql dt11--data----"+dt11_list.toString()); + comMap.put("dt11",dt11_list); + + List> dt12_list = new ArrayList<>(); + sql = "select * from "+tableName+"_dt12 where mainid = '"+id+"'"; + writeLog("------sql dt12------"+sql); + rs.executeQuery(sql); + while(rs.next()){ + HashMap dt12_map = new HashMap<>(); + String rq = rs.getString("field001"); + String tm = rs.getString("field002"); + String cbs = rs.getString("field003"); + String mt = rs.getString("field004"); + String bz = rs.getString("field005"); + + dt12_map.put("rq",rq); + dt12_map.put("tm",tm); + dt12_map.put("cbs",cbs); + dt12_map.put("mt",mt); + dt12_map.put("bz",bz); + dt12_list.add( dt12_map); + } + writeLog("------sql dt12--data----"+dt12_list.toString()); + comMap.put("dt12",dt12_list); + + List> dt13_list = new ArrayList<>(); + sql = "select * from "+tableName+"_dt13 where mainid = '"+id+"'"; + writeLog("------sql dt13------"+sql); + rs.executeQuery(sql); + while(rs.next()){ + HashMap dt13_map = new HashMap<>(); + String ksrq = rs.getString("field001"); + String jsrq = rs.getString("field002"); + String mc = rs.getString("field003"); + String je = rs.getString("field004"); + String gj = rs.getString("field005"); + String gjly = rs.getString("field006"); + String zq = rs.getString("field007"); + String zw = rs.getString("field008"); + String bz = rs.getString("field009"); + + dt13_map.put("ksrq",ksrq); + dt13_map.put("jsrq",jsrq); + dt13_map.put("mc",mc); + dt13_map.put("je",je); + dt13_map.put("gj",gj); + dt13_map.put("gjly",gjly); + dt13_map.put("zq",zq); + dt13_map.put("zw",zw); + dt13_map.put("bz",bz); + dt13_list.add( dt13_map); + } + writeLog("------sql dt12--data----"+dt13_list.toString()); + comMap.put("dt13",dt13_list); + + writeLog("------sql data-----"+comMap.toString()); + apiResult.success(true,comMap,"success"); + }else { + apiResult.fail("id_card为空"); + } + } catch (Exception e) { + e.printStackTrace(); + apiResult.fail("error"); + } + return JSON.toJSONString(apiResult); + } + + @GET + @Path("/updateAcc") + @Produces(MediaType.TEXT_PLAIN) + public String updateAcc(@Context HttpServletRequest request, @Context HttpServletResponse response){ + ApiResult apiResult = new ApiResult<>(); + RecordSet rs = new RecordSet(); + String billid = Util.null2String(request.getParameter("id")); + String tableName = getFormId("datacenter_table"); + try { + //------请在下面编写业务逻辑代码------ + String sql = "select * from "+tableName+" where id = '"+billid+"'"; + new BaseBean().writeLog("----datacenter---sql-:"+sql); + rs.executeQuery(sql); + if(rs.next()){ + String confirm = rs.getString("field051"); + new BaseBean().writeLog("----datacenter---confirm--:"+confirm); + if(!confirm.equals("")){ + String eng_fj1 = rs.getString("field058"); + String qtyz_fj1 = rs.getString("field060"); + String zyzg_fj1 = rs.getString("field065"); + String qtjn_fj1 = rs.getString("field068"); + String eng_fj = rs.getString("field070"); + String qtyz_fj = rs.getString("field071"); + String zyzg_fj = rs.getString("field072"); + String qtjn_fj = rs.getString("field073"); + if(!eng_fj.equals("")){ + eng_fj1 += ","+eng_fj; + } + if(!qtyz_fj.equals("")){ + qtyz_fj1 += ","+qtyz_fj; + } + if(!zyzg_fj.equals("")){ + zyzg_fj1 += ","+zyzg_fj; + } + if(!qtjn_fj.equals("")){ + qtjn_fj1 += ","+qtjn_fj; + } + sql = "update "+tableName+" set field058=?,field060=?,field065=?,field068=? where id = '"+billid+"'"; + rs.executeUpdate(sql,eng_fj1,qtyz_fj1,zyzg_fj1,qtjn_fj1); + } + apiResult.success(true,true,"success"); + } + } catch (Exception e) { + e.printStackTrace(); + apiResult.fail("error"); + } + return JSON.toJSONString(apiResult); + } + + @GET + @Path("/updateData") + @Produces(MediaType.TEXT_PLAIN) + public String updateData(@Context HttpServletRequest request, @Context HttpServletResponse response){ + ApiResult apiResult = new ApiResult<>(); + RecordSet rs = new RecordSet(); + String billid = Util.null2String(request.getParameter("id")); + String tableName = getFormId("datacenter_table"); + try { + //------请在下面编写业务逻辑代码------ + String sql = "update "+tableName+" set field076 = '正式入职' where id = '"+billid+"'"; + new BaseBean().writeLog("----datacenter---sql-:"+sql); + rs.executeQuery(sql); + } catch (Exception e) { + e.printStackTrace(); + apiResult.fail("error"); + } + return JSON.toJSONString(apiResult); + } + + public static String getFormId(String name){ + RecordSet recordSet = new RecordSet(); + String sql = "select cs from uf_xtpzb1 where xtbs ='"+name+"'"; + recordSet.execute(sql); + if(recordSet.next()){ + return recordSet.getString("cs"); + }else { + return ""; + } + } + + /** + * 获取选择框的值 + * @param maintableName 主表表名 + * @param detailtableName 明细表表名 + * @param fieldName 字段名 + * @param selectValue 选择框值 + * @return 选择框名称 + */ + public String getSelectName(String maintableName, String detailtableName, String fieldName, String selectValue){ + //writeLog("CSX--enter getSelectName"); + RecordSet rs0 = new RecordSet(); + String choiceBoxName = ""; + StringBuffer sql= new StringBuffer(); + sql.append("select t1.selectname \n"); + sql.append("from workflow_SelectItem t1\n"); + sql.append(", workflow_billfield t2\n"); + sql.append(", workflow_bill t3\n"); + sql.append(" where t1.fieldid=t2.id "); + sql.append("and t2.billid=t3.id and t3.tablename='").append(maintableName).append("'"); + if(detailtableName==null){ + detailtableName=" "; + //writeLog("detailtableName->"+detailtableName); + } + //writeLog("!StringUtils.isNotBlank(detailtableName)->"+!org.apache.commons.lang.StringUtils.isNotBlank(detailtableName)); + if(!com.alipay.oceanbase.jdbc.StringUtils.isNotBlank(detailtableName)){ + if(rs0.getDBType().equalsIgnoreCase("oracle")){//判断数据库类型是不是Oracle + sql.append(" and t2.detailtable is null\n"); + }else{ + sql.append(" and t2.detailtable ='' \n"); + } + }else{ + sql.append(" and t2.detailtable ='").append(detailtableName).append("' \n"); + } + sql.append(" and t2.fieldname='").append(fieldName); + sql.append("'\n and t1.selectvalue='").append(selectValue).append("'"); + //writeLog("getChoiceBoxNameSql->\n"+sql.toString()); + rs0.execute(sql.toString()); + if(rs0.next()){ + choiceBoxName = rs0.getString("selectname"); + } + //writeLog("ChoiceBoxName->"+choiceBoxName); + return choiceBoxName; + } +} diff --git a/src/main/java/com/api/interfaces/liyi/common/ApiResult.java b/src/main/java/com/api/interfaces/liyi/common/ApiResult.java new file mode 100644 index 0000000..ae69f86 --- /dev/null +++ b/src/main/java/com/api/interfaces/liyi/common/ApiResult.java @@ -0,0 +1,59 @@ +package com.api.interfaces.liyi.common; + +public class ApiResult { + + private boolean success; + + private String message; + + private T data; + + public ApiResult() { + } + + public void success(boolean success, T data, String message) { + this.success = success; + this.data = data; + this.message = message; + } + + public ApiResult success(T data) { + this.data = data; + this.success = true; + this.message = ""; + return this; + } + + public ApiResult fail(String message) { + this.message = message; + this.success = false; + this.data = null; + return this; + } + + public boolean isSuccess() { + return this.success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public String getMessage() { + return this.message; + } + + public void setMessage(String message) { + this.message = message; + } + + public T getData() { + return this.data; + } + + public void setData(T data) { + this.data = data; + } + + +} diff --git a/src/main/java/com/api/interfaces/liyi/crod/HuilianyiTravelJob.java b/src/main/java/com/api/interfaces/liyi/crod/HuilianyiTravelJob.java new file mode 100644 index 0000000..9691e98 --- /dev/null +++ b/src/main/java/com/api/interfaces/liyi/crod/HuilianyiTravelJob.java @@ -0,0 +1,602 @@ +package com.api.interfaces.liyi.crod; + +import cn.hutool.http.HttpResponse; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONArray; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.api.interfaces.liyi.service.HuilianyiClientService; +import com.api.interfaces.liyi.service.impl.HuilianyiClientServiceImpl; +import com.engine.common.util.ServiceUtil; +import weaver.conn.RecordSet; +import weaver.formmode.exttools.impexp.common.DateUtils; +import weaver.general.BaseBean; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.interfaces.schedule.BaseCronJob; +import weaver.soa.workflow.request.*; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + +public class HuilianyiTravelJob extends BaseCronJob { + private HuilianyiClientService getHuilianyiClientService(){ + return ServiceUtil.getService(HuilianyiClientServiceImpl.class); + } + + @Override + public void execute() { + try { +// RecordSet rs = new RecordSet(); +// RequestService service = new RequestService(); +// String nowdate = TimeUtil.getCurrentTimeString(); + String ccsq_wfid = getFormId("ccsq_wfid"); + String ccbg_wfid = getFormId("ccbg_wfid"); + String ccsqTable = getFormId("ccsq_tablename"); + String ccbgTable = getFormId("ccbg_tablename"); + //String query_time = getFormId("query_time"); + String currentDateTime = DateUtils.getCurrentDateTime(); + String[] s = currentDateTime.split(" "); + String hour = s[1].split(":")[0]; + String startTime = ""; +// if(Integer.parseInt(hour)>0){ +// startTime = DateUtils.getCurrentDate() + " " + query_time; +// +// }else { +// startTime = DateUtils.getCurrentDate()+ " 12:00:00"; +// } + String cur_date = DateUtils.getCurrentDate(); + String cur_year = cur_date.split("-")[0]; + String cur_month = cur_date.split("-")[1]; + startTime = cur_year+"-"+cur_month+"-"+"01 00:00:00"; + //startTime = "2022-11-24 12:00:00"; + /** + * 获取token + */ + String resp = getHuilianyiClientService().getToken(); + JSONObject res = JSONUtil.parseObj(resp); + List resp_list = new ArrayList<>(); + if(null != res.get("access_token")){ + new BaseBean().writeLog("------token----:"+res.getStr("access_token")); + String token = res.getStr("access_token"); + /** + * 获取数据 + */ + HttpResponse response1 = getHuilianyiClientService(). + getTravelApplication(res.getStr("access_token"), startTime, currentDateTime, "1003,1012", "1", "100"); + resp = response1.body(); + String total = response1.header("X-Total-Count"); + new BaseBean().writeLog("------1st resp--"+resp); + if(resp.equals("[]")){ + new BaseBean().writeLog("------no resp--"); + } + else { + resp_list.add(resp); + } + new BaseBean().writeLog("----total----"+total); + int page = (Integer.parseInt(total)/100) + 1; + if(page > 1){ + for(int i = 2;i <= page;i++){ + /** + * 获取数据 + */ + HttpResponse response2 = getHuilianyiClientService(). + getTravelApplication(res.getStr("access_token"),startTime,currentDateTime,"1003,1012",String.valueOf(i),"100"); + String resp2 = response2.body(); + new BaseBean().writeLog("------either resp--"+resp2); + if(resp2.equals("[]")){ + new BaseBean().writeLog("------no resp--"); + } + else { + resp_list.add(resp2); + } + } + } + for (String result : resp_list) { + JSONArray jsonArray = JSONUtil.parseArray(result); + parseCreateReq(jsonArray,ccbg_wfid,ccsq_wfid,ccbgTable,ccsqTable,token); + } + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 组装创建流程数据并创建流程 + * @param jsonArray + * @param ccbg_wfid + * @param ccsq_wfid + * @param ccbgTable + * @param ccsqTable + */ + private void parseCreateReq(JSONArray jsonArray, String ccbg_wfid, String ccsq_wfid, String ccbgTable, String ccsqTable,String token) { + RecordSet rs = new RecordSet(); + RequestService service = new RequestService(); + String nowdate = TimeUtil.getCurrentTimeString(); + String tokenUrl = getFormId("hly_tokenUrl"); + jsonArray.stream().map(o -> (JSONObject) o).forEach(result -> { + try { + Set comp_uid = new HashSet<>(); + List emp_id = new ArrayList<>(); + String companions = ""; + JSONObject applicant = ((JSONObject) result).getJSONObject("applicant"); + String status = ((JSONObject) result).getStr("status"); + String employeeID =((JSONObject) applicant).getStr("employeeID"); + + String fullName = applicant.getStr("fullName"); + JSONArray custFormValues = ((JSONObject) result).getJSONArray("custFormValues"); + custFormValues.stream().map(o -> (JSONObject) o).forEach(data ->{ + String fieldName = ((JSONObject) data).getStr("fieldName"); + if(fieldName.equals("出差人员")){ + JSONArray comp_value = ((JSONObject) data).getJSONArray("value"); + comp_value.stream().map(o -> (JSONObject) o).forEach(comp ->{ + String userOID = ((JSONObject) comp).getStr("userOID"); + comp_uid.add(userOID); + }); + } + }); + + if(comp_uid.size()>0){ + for (String uid : comp_uid) { + HttpResponse user_res = HttpUtil.createGet(tokenUrl + "/api/open/user/"+uid) + .header("Authorization", "Bearer ".concat(token))//头信息,多个头信息多次调用此方法即可 + .header("Content-Type", "application/json") + .timeout(1000 * 120) + .execute(); + String user_resp = user_res.body(); + //out.println("----user_resp:"+user_resp); + JSONObject compInfo = JSONUtil.parseObj(user_resp); + String empid = compInfo.getStr("employeeID"); + if(empid==null){ + }else { + if(!emp_id.contains(empid)){ + emp_id.add(empid); + } + } + } + } + + if(emp_id.size()>0){ + if(emp_id.size()>1){ + List empids = emp_id; + for (String txr_id : empids) { + rs.executeQuery("select id from hrmresource where workcode = '"+txr_id+"'"); + while (rs.next()){ + if(companions.equals("")){ + companions = rs.getString("id"); + }else { + companions += ","+rs.getString("id"); + } + } + + } + } + } + String departmentNumber = ((JSONObject) result).getStr("departmentNumber"); + String version = ((JSONObject) result).getStr("version"); + String businessCode = ((JSONObject) result).getStr("businessCode"); + Boolean closed = ((JSONObject) result).getBool("closed"); + Boolean participantClosed = ((JSONObject) result).getBool("participantClosed"); + JSONObject travelApplication = ((JSONObject) result).getJSONObject("travelApplication"); + String startDate = travelApplication.getStr("startDate"); + startDate = startDate.replace("T", " "); + startDate = startDate.replace("Z", ""); + //转时区 + startDate = convertDateGMT(startDate); + String endDate = travelApplication.getStr("endDate"); + endDate = endDate.replace("T", " "); + endDate = endDate.replace("Z", ""); + //转时区 + endDate = convertDateGMT(endDate); + new BaseBean().writeLog("------result-1---:"+fullName+"---"+employeeID+"---txrids:"+companions+"---"+departmentNumber+"---"+version+"---"+businessCode+"---"+startDate+"---"+endDate+"---close---"+closed+"--partclose--"+participantClosed); + String fromDate = ""; + String fromTime = ""; + String toDate = ""; + String toTime = ""; + //2022-11-17 09:00 + if(startDate!=null){ + fromDate = startDate.split(" ")[0]; + String time = startDate.split(" ")[1]; + fromTime = time.split(":")[0]+":"+time.split(":")[1]; + } + if(endDate!=null){ + toDate = endDate.split(" ")[0]; + String time = endDate.split(" ")[1]; + toTime = time.split(":")[0]+":"+time.split(":")[1]; + } + String reqName_sq = ""; + String reqName_bg = ""; + String workflowname = ""; + String req_sql = ""; + + String id = ""; + req_sql = "select id,departmentid from hrmresource where workcode = '"+employeeID+"'"; + rs.executeQuery(req_sql); + if(rs.next()){ + id = rs.getString("id"); + departmentNumber = rs.getString("departmentid"); + } + //出差 及 变更逻辑 + if(status.equals("1003")){ + if(Integer.parseInt(version)==0){ + req_sql = "select workflowname from workflow_base where id = '"+ccsq_wfid+"'"; + rs.executeQuery(req_sql); + while (rs.next()){ + workflowname = rs.getString("workflowname"); + } + reqName_sq = workflowname+"-"+fullName+"-"+ DateUtils.getCurrentDate(); + + Map mainTable = new HashMap<>(); + mainTable.put("resourceId",id); + mainTable.put("gh",employeeID); + mainTable.put("departmentId",departmentNumber); + mainTable.put("fromDate",fromDate); + mainTable.put("fromTime",fromTime); + mainTable.put("toDate",toDate); + mainTable.put("toTime",toTime); + mainTable.put("status","1003"); + mainTable.put("version",version); + mainTable.put("sqdh",businessCode); + mainTable.put("companion",companions); + new BaseBean().writeLog("------data---:"+mainTable.toString()); + req_sql = "select count(id) as count from "+ccsqTable+" where sqdh = '"+businessCode+"' and version = 0"; + rs.executeQuery(req_sql); + if(rs.next()){ + int count = rs.getInt("count"); + if(count==0){ + String reqId = creatRequest("1", ccsq_wfid, reqName_sq, false, mainTable, null); + RequestInfo request = service.getRequest(Integer.valueOf(reqId)); + Boolean submit = service.nextNodeBySubmit(request, Integer.valueOf(reqId), 1, nowdate); + if (submit) { + new BaseBean().writeLog(reqId + "提交成功"); + } else { + new BaseBean().writeLog(reqId + "流程提交异常"); + } + } + } + + } + else if(Integer.parseInt(version)>=1){ + String changerequestid = ""; + String changetype = ""; + String ver = "1"; + String ccks_date = ""; + String ccks_time = ""; + String ccjs_date = ""; + String ccjs_time = ""; + String kqsc = ""; + String bgsc = ""; + String req_id = ""; + + /** + * 版本大于1 + * 查出差 版本号倒序 + * 有出差,先变更撤销 + * 创建出差(条件是同一单号不同版本号) + */ +// req_sql = "select top 1 requestid,id,changetype,version from "+ccbgTable+" where sqdh = '"+businessCode+"' and changetype='1' order by version desc,id desc"; +// rs.executeQuery(req_sql); +// if(rs.next()){ +// changerequestid = Util.null2String(rs.getString("requestid")); +// changetype = rs.getString("changetype"); +// req_id = rs.getString("id"); +// ver = rs.getString("version"); +// } +// //没有变更 +// if(changerequestid.equals("")){ + //先查出差 + req_sql = "select top 1 * from "+ccsqTable+" where sqdh = '"+businessCode+"' order by version desc "; + rs.executeQuery(req_sql); + if(rs.next()){ + ver = rs.getString("version"); + changerequestid = Util.null2String(rs.getString("requestid")); + ccks_date = rs.getString("fromDate"); + ccks_time = rs.getString("fromTime"); + ccjs_date = rs.getString("toDate"); + ccjs_time = rs.getString("toTime"); + } + //如果有 新建变更 撤销 + if(!changerequestid.equals("")){ + //只有 出差最大的版本比 获取的版本小 才需要变更撤销 + //如果第二天同样的数据进来 就不会重复撤销 + new BaseBean().writeLog("--new-:"+version+"---wf:"+ver); + if(Integer.parseInt(ver) < Integer.parseInt(version)){ + req_sql = "select top 1 requestid,id,version from "+ccbgTable+" where sqdh = '"+businessCode+"' and changetype='1' and status = '1003' order by version desc "; + rs.executeQuery(req_sql); + String bgversion = "0"; + String bgreq = ""; + if(rs.next()){ + bgversion = rs.getString("version"); + bgreq = rs.getString("requestid"); + } + if((!bgreq.equals("") && Integer.parseInt(bgversion)< Integer.parseInt(version)) || bgreq.equals("")){ + //如果未查到撤销对变更,但是有出差,先起变更撤销出差 + //获取流程名 + req_sql = "select workflowname from workflow_base where id = '"+ccbg_wfid+"'"; + rs.executeQuery(req_sql); + while (rs.next()){ + workflowname = rs.getString("workflowname"); + } + reqName_bg = workflowname+"-"+fullName+"-"+ DateUtils.getCurrentDate(); + Map mainTable = new HashMap<>(); + mainTable.put("resourceId",id); + mainTable.put("gh",employeeID); + mainTable.put("status","1003"); + mainTable.put("version",version); + mainTable.put("companion",companions); + mainTable.put("changetype","1"); + mainTable.put("sqdh",businessCode); + + mainTable.put("changerequestid",changerequestid); + LinkedHashMap>> detail = new LinkedHashMap<>(); + List> list = new ArrayList<>(); + Map map = new HashMap<>(); + map.put("detail_attendancefromDate",ccks_date); + map.put("detail_attendancefromTime",ccks_time); + map.put("detail_attendancetoDate",ccjs_date); + map.put("detail_attendancetoTime",ccjs_time); + //map.put("detail_attendanceduration",kqsc); + map.put("detail_changefromDate",fromDate); + map.put("detail_changefromTime",fromTime); + map.put("detail_changetoDate",toDate); + map.put("detail_changetoTime",toTime); + //map.put("detail_changeduration",bgsc); + list.add(map); + detail.put("1",list); + new BaseBean().writeLog("------data---:"+detail.toString()); + new BaseBean().writeLog("------create version---:"+version); + if(!version.equals("0")){ + String reqId = creatRequest("1", ccbg_wfid, reqName_bg, false, mainTable, detail); + RequestInfo request = service.getRequest(Integer.valueOf(reqId)); + Boolean submit = service.nextNodeBySubmit(request, Integer.valueOf(reqId), 1, nowdate); + if (submit) { + new BaseBean().writeLog(reqId + "提交成功"); + } else { + + new BaseBean().writeLog(reqId + "流程提交异常"); + } + + } + } + } + } +// } + req_sql = "select count(id) as count from "+ccsqTable+" where sqdh = '"+businessCode+"' and version = '"+version+"'"; + rs.executeQuery(req_sql); + if(rs.next()){ + int count = rs.getInt("count"); + if(count==0){ + req_sql = "select workflowname from workflow_base where id = '"+ccsq_wfid+"'"; + rs.executeQuery(req_sql); + while (rs.next()){ + workflowname = rs.getString("workflowname"); + } + reqName_sq = workflowname+"-"+fullName+"-"+ DateUtils.getCurrentDate(); + Map mainTable = new HashMap<>(); + mainTable.put("resourceId",id); + mainTable.put("gh",employeeID); + mainTable.put("departmentId",departmentNumber); + mainTable.put("fromDate",fromDate); + mainTable.put("fromTime",fromTime); + mainTable.put("toDate",toDate); + mainTable.put("toTime",toTime); + mainTable.put("status","1003"); + mainTable.put("version",version); + mainTable.put("sqdh",businessCode); + mainTable.put("companion",companions); + new BaseBean().writeLog("------data---:"+mainTable.toString()); + String reqId = creatRequest("1", ccsq_wfid, reqName_sq, false, mainTable, null); + RequestInfo request = service.getRequest(Integer.valueOf(reqId)); + Boolean submit = service.nextNodeBySubmit(request, Integer.valueOf(reqId), 1, nowdate); + if (submit) { + new BaseBean().writeLog(reqId + "提交成功"); + } else { + new BaseBean().writeLog(reqId + "流程提交异常"); + } + } + } + } + } + // 出差作废逻辑 + else if(status.equals("1012")){ + Map mainTable = new HashMap<>(); + mainTable.put("resourceId",id); + mainTable.put("gh",employeeID); + mainTable.put("status",status); + mainTable.put("version",version); + mainTable.put("changetype","1"); + mainTable.put("sqdh",businessCode); + String changerequestid = ""; + String req_id = "" ; + String changetype = ""; + String ccks_date = ""; + String ccks_time = ""; + String ccjs_date = ""; + String ccjs_time = ""; + String bgversion = "0"; + String ccversion = "0"; + req_sql = "select top 1 requestid,id,version from "+ccbgTable+" where sqdh = '"+businessCode+"' and changetype='1' and status = '1012' order by version desc "; + rs.executeQuery(req_sql); + if(rs.next()){ + changerequestid = Util.null2String(rs.getString("requestid")); + } + if(changerequestid.equals("")){ + req_sql = "select top 1 * from "+ccsqTable+" where sqdh = '"+businessCode+"' order by version desc"; + rs.executeQuery(req_sql); + if(rs.next()){ + changerequestid = Util.null2String(rs.getString("requestid")); + ccversion = rs.getString("version"); + ccks_date = rs.getString("fromDate"); + ccks_time = rs.getString("fromTime"); + ccjs_date = rs.getString("toDate"); + ccjs_time = rs.getString("toTime"); + } + //获取流程名 + req_sql = "select workflowname from workflow_base where id = '"+ccbg_wfid+"'"; + rs.executeQuery(req_sql); + while (rs.next()){ + workflowname = rs.getString("workflowname"); + } + reqName_bg = workflowname+"-"+fullName+"-"+ DateUtils.getCurrentDate(); + mainTable.put("changerequestid",changerequestid); + LinkedHashMap>> detail = new LinkedHashMap<>(); + List> list = new ArrayList<>(); + Map map = new HashMap<>(); + map.put("detail_attendancefromDate",ccks_date); + map.put("detail_attendancefromTime",ccks_time); + map.put("detail_attendancetoDate",ccjs_date); + map.put("detail_attendancetoTime",ccjs_time); + //map.put("detail_attendanceduration",kqsc); + map.put("detail_changefromDate",fromDate); + map.put("detail_changefromTime",fromTime); + map.put("detail_changetoDate",toDate); + map.put("detail_changetoTime",toTime); + //map.put("detail_changeduration",bgsc); + list.add(map); + detail.put("1",list); + new BaseBean().writeLog("------data---:"+detail.toString()); + //if(!changerequestid.equals("") && Integer.parseInt(version)>Integer.parseInt(bgversion) && Integer.parseInt(version)>Integer.parseInt(ccversion)){ + if(!changerequestid.equals("")){ + String reqId = creatRequest("1", ccbg_wfid, reqName_bg, false, mainTable, detail); + RequestInfo request = service.getRequest(Integer.valueOf(reqId)); + Boolean submit = service.nextNodeBySubmit(request, Integer.valueOf(reqId), 1, nowdate); + if (submit) { + new BaseBean().writeLog(reqId + "提交成功"); + } else { + new BaseBean().writeLog(reqId + "流程提交异常"); + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + }); + } + + /** + * 创建系统流程 + * + * @param createrId 创建人id + * @param workflowId 流程id + * @param requestName 流程标题 + * @param isNextFlow 是否提交下一节点 + * @param mainTable 主表信息 Map key: 字段名 value: 值 + * @param detail 明细信息(必须LinkedHashMap) Map key:明细表序号 value: List {Map key: 字段名 value: + * 值} + * @return + */ + public String creatRequest( + String createrId, + String workflowId, + String requestName, + boolean isNextFlow, + Map mainTable, + LinkedHashMap>> detail + ) throws Exception { + + if (mainTable == null || "0".equals(createrId) || "0".equals(workflowId)) { + return "0"; + } + + //请求基本信息 + RequestInfo requestInfo = new RequestInfo(); + requestInfo.setCreatorid(createrId); // 创建人 + requestInfo.setWorkflowid(workflowId); // 工作流id + requestInfo.setDescription(requestName); // 标题 + + if (!isNextFlow) { // 是否提交下一节点 + requestInfo.setIsNextFlow("0"); + } + + // 主表信息 + MainTableInfo mainTableInfo = new MainTableInfo(); + Property[] propertyArray = new Property[mainTable.size()]; + int p = 0; + + for (Map.Entry entry : mainTable.entrySet()) { + propertyArray[p] = new Property(); + propertyArray[p].setName(entry.getKey()); + propertyArray[p].setValue(entry.getValue()); + p++; + } + mainTableInfo.setProperty(propertyArray); + requestInfo.setMainTableInfo(mainTableInfo); + + // 明细信息 + DetailTableInfo detailTableInfo = new DetailTableInfo(); + if (detail != null) { + DetailTable[] detailTables = new DetailTable[detail.size()]; + int ds = 0; + for (Map.Entry>> entry : detail.entrySet()) { + DetailTable detailTable = new DetailTable(); + List> list = entry.getValue(); + for (Map map : list) { + Row row = new Row(); + for (Map.Entry rentry : map.entrySet()) { + Cell cell = new Cell(); + cell.setName("" + rentry.getKey()); + cell.setValue("" + rentry.getValue()); + row.addCell(cell); + } + detailTable.addRow(row); + } + detailTable.setId(entry.getKey()); + detailTables[ds] = detailTable; + ds++; + } + detailTableInfo.setDetailTable(detailTables); + requestInfo.setDetailTableInfo(detailTableInfo); // 明细表 + } + RequestService service = new RequestService(); + String requestid = service.createRequest(requestInfo); + // 创建请求id + if(requestid == null){ + throw new RuntimeException("创建流程失败"); + } + int requestidInt = Integer.valueOf(requestid); + if(requestidInt < 0){ + throw new RuntimeException("创建流程失败"); + } + return requestid; + } + + /** + * 获取系统配置表 + * @param name + * @return + */ + public static String getFormId(String name){ + RecordSet recordSet = new RecordSet(); + String sql = "select cs from uf_xtpzb1 where xtbs ='"+name+"'"; + recordSet.execute(sql); + if(recordSet.next()){ + return recordSet.getString("cs"); + }else { + return ""; + } + } + + /** + * 转换时区 + * @param dateStr + * @return + * @throws ParseException + */ + public String convertDateGMT(String dateStr) throws ParseException { + String sourceTimeZone = "GMT"; + String targetTimeZone = "GMT+8"; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + //获取传入的时间值 + Long time = new Date(sdf.parse(dateStr).getTime()).getTime(); + //获取源时区时间相对的GMT时间 + Long sourceRelativelyGMT = time - TimeZone.getTimeZone(sourceTimeZone).getRawOffset(); + //GMT时间+目标时间时区的偏移量获取目标时间 + Long targetTime = sourceRelativelyGMT + TimeZone.getTimeZone(targetTimeZone).getRawOffset(); + Date date = new Date(targetTime); + return sdf.format(date); + } +} diff --git a/src/main/java/com/api/interfaces/liyi/service/HuilianyiClientService.java b/src/main/java/com/api/interfaces/liyi/service/HuilianyiClientService.java new file mode 100644 index 0000000..1b81f81 --- /dev/null +++ b/src/main/java/com/api/interfaces/liyi/service/HuilianyiClientService.java @@ -0,0 +1,23 @@ +package com.api.interfaces.liyi.service; + +import cn.hutool.http.HttpResponse; + +import java.util.Map; + +public interface HuilianyiClientService { + + /** + * 获取token + * @return + */ + String getToken(); + + /** + * 增量差旅 + * @return + */ + HttpResponse getTravelApplication(String token, String startDate, String endDate, String status, String page, String size); + + HttpResponse getCompInfo(String token, String uid); + +} diff --git a/src/main/java/com/api/interfaces/liyi/service/impl/HuilianyiClientServiceImpl.java b/src/main/java/com/api/interfaces/liyi/service/impl/HuilianyiClientServiceImpl.java new file mode 100644 index 0000000..5778c1b --- /dev/null +++ b/src/main/java/com/api/interfaces/liyi/service/impl/HuilianyiClientServiceImpl.java @@ -0,0 +1,76 @@ +package com.api.interfaces.liyi.service.impl; + +import cn.hutool.http.HttpResponse; +import cn.hutool.http.HttpUtil; +import com.api.interfaces.liyi.service.HuilianyiClientService; +import com.engine.core.impl.Service; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.rsa.security.Base64; +import java.util.HashMap; +import java.util.Map; + + +public class HuilianyiClientServiceImpl extends Service implements HuilianyiClientService { + private static String clientId = "4b8b787c-40c1-4349-8217-5535a8327175";//需要替换 + private static String securet = "OTY4ZWJkZTQtOWRmZC00Y2QwLThmMTktNGQ3ZGFjNzUwMDI2";//需要替换 + private static String tokenUrl = "https://apistage.huilianyi.com/gateway";//需要替换 + + @Override + public String getToken() { + clientId = getFormId("hly_clientId"); + securet = getFormId("hly_securet"); + tokenUrl = getFormId("hly_tokenUrl"); + int MAX_TIME_OUT = 1000 * 120; + String authStr = clientId.concat(":").concat(securet); + String authStrEnc = new String(Base64.encodeBase64(authStr.getBytes())); + String response = HttpUtil.createPost(tokenUrl+"/oauth/token?grant_type=client_credentials&scope=write") + .header("Authorization", "Basic ".concat(authStrEnc))//头信息,多个头信息多次调用此方法即可 + .timeout(MAX_TIME_OUT) + .execute().body(); + return response; + } + + @Override + public HttpResponse getTravelApplication(String token, String startDate, String endDate, String status, String page, String size) { +// String url = tokenUrl+"/api/open/travelApplication?access_token={AccessToken}&startDate={startDate}&endDate={endDate}&status={status}" + +// "&page={page}&size={size}"; + int MAX_TIME_OUT = 1000 * 120; + tokenUrl = getFormId("hly_tokenUrl"); + HttpResponse resp = HttpUtil.createGet(tokenUrl + "/api/open/travelApplication?access_token=" + token + "" + + "&startDate=" + startDate + "&endDate=" + endDate + "&status=" + status + "&page=" + page + "&size=" + size + "") + .header("Authorization", "Bearer ".concat(token))//头信息,多个头信息多次调用此方法即可 + .header("Content-Type", "application/json") + .timeout(MAX_TIME_OUT) + .execute(); + String response = resp.body(); + String total = resp.header("X-Total-Count"); + new BaseBean().writeLog("-- hly--resp---:"+response); + Map resMap = new HashMap<>(); + resMap.put("total",total); + resMap.put("resp",response); + return resp; + } + + @Override + public HttpResponse getCompInfo(String token, String uid) { + int MAX_TIME_OUT = 1000 * 120; + HttpResponse user_res = HttpUtil.createGet(tokenUrl + "/api/open/user/"+uid) + .header("Authorization", "Bearer ".concat(token))//头信息,多个头信息多次调用此方法即可 + .header("Content-Type", "application/json") + .timeout(MAX_TIME_OUT) + .execute(); + return user_res; + } + + public static String getFormId(String name){ + RecordSet recordSet = new RecordSet(); + String sql = "select cs from uf_xtpzb1 where xtbs ='"+name+"'"; + recordSet.execute(sql); + if(recordSet.next()){ + return recordSet.getString("cs"); + }else { + return ""; + } + } +} diff --git a/src/main/java/com/api/nonstandardext/zenner/job/SyncAccountInfoFromSapJob.java b/src/main/java/com/api/nonstandardext/zenner/job/SyncAccountInfoFromSapJob.java new file mode 100644 index 0000000..8cdd361 --- /dev/null +++ b/src/main/java/com/api/nonstandardext/zenner/job/SyncAccountInfoFromSapJob.java @@ -0,0 +1,155 @@ +package com.api.nonstandardext.zenner.job; + +import com.api.nonstandardext.zenner.model.sap.PeriodBalance; +import com.api.nonstandardext.zenner.utils.SAPWebserviceTool; +import net.sf.json.JSONObject; +import weaver.conn.RecordSet; +import weaver.formmode.setup.ModeRightInfo; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.interfaces.schedule.BaseCronJob; +import java.util.Calendar; + +/** + * 对账单同步 + * + * 1. SAP数据 + * + * 2.银行数据 银行当日几张余额 b2e0005(当日) b2e0012(历史) + * 银行数据 银行收款单 b2e0035 + * 银行数据 银行付款单 b2e0035 + * + * 3.OA 流程数据 + */ +public class SyncAccountInfoFromSapJob extends BaseCronJob { + + BaseBean logger = new BaseBean(); + + private final static String JobName = " SyncAccountInfoFromSapJob "; + + private String interfaceName; + + private String theNearPeriod; + + private String comCodes; //6000 + private String sapAccount; //10020103 + + + public String getInterfaceName() { + return interfaceName; + } + + public void setInterfaceName(String interfaceName) { + this.interfaceName = interfaceName; + } + + public String getTheNearPeriod() { + return theNearPeriod; + } + + public void setTheNearPeriod(String theNearPeriod) { + this.theNearPeriod = theNearPeriod; + } + + public String getComCodes() { + return comCodes; + } + + public void setComCodes(String comCodes) { + this.comCodes = comCodes; + } + + public String getSapAccount() { + return sapAccount; + } + + public void setSapAccount(String sapAccount) { + this.sapAccount = sapAccount; + } + + public void execute() { + logger.writeLog("-----" + JobName + " Begin------"); + + RecordSet rs = new RecordSet(); + try { + logger.writeLog("-----" + JobName + " getInterfaceName------" + getInterfaceName()); + +// if (getInterfaceName().indexOf("syncGlaccPeriodBalancesFromSap") >= 0){ + + SAPWebserviceTool tool = new SAPWebserviceTool(); + String webserviceUrl = tool.getSystemParamValue("SAP_OA011_Webservice_URL"); + + Integer nearPeriod = Integer.parseInt(getTheNearPeriod()); + + String[] companyCodes = getComCodes().split(","); + for (int c = 0; c < companyCodes.length; c++){ + if ("".equals(companyCodes[c])){ + continue; + } + + Calendar cal = Calendar.getInstance(); + for (int i = 1; i <= nearPeriod; i++){ + syncGlaccPeriodBalancesFromSap(companyCodes[c], (cal.get(Calendar.MONTH) + 1) + "", cal.get(Calendar.YEAR) + "", getSapAccount(), tool); + cal.add(Calendar.MONTH, -1); + } + } +// } + + } catch (Exception e) { + logger.writeLog(JobName + " 获取异常: " + e.getMessage()); + e.printStackTrace(); + } + logger.writeLog("--------------------" + JobName + " End---------------------------"); + } + + public void syncGlaccPeriodBalancesFromSap(String comCode, String period, String year, String glAccount, SAPWebserviceTool tool) throws Exception { + + String params = tool.callParams_011(comCode, period, year, glAccount); + + JSONObject result = tool.callInterface_011(params); + + logger.writeLog(JobName + " syncGlaccPeriodBalancesFromSap result : " + result); + + JSONObject balanceResponse = result.getJSONObject("balanceResponse"); + PeriodBalance periodBalance = new PeriodBalance(); + periodBalance.setIvCompCode(comCode); + periodBalance.setIvFiscYear(year); + periodBalance.setIvFisPeriod(period); + periodBalance.setEvBalance(Util.null2String(balanceResponse.getString("EvBalance"))); + periodBalance.setEvPerSales(Util.null2String(balanceResponse.getString("EvPerSales"))); + periodBalance.setEvCreditPer(Util.null2String(balanceResponse.getString("EvCreditPer"))); + periodBalance.setEvDebitsPer(Util.null2String(balanceResponse.getString("EvDebitsPer"))); + periodBalance.setEvCurrency(Util.null2String(balanceResponse.getString("EvCurrency"))); + periodBalance.setGlAccount(glAccount); + + periodBalance.save(periodBalance, 52, "uf_period_balance"); + +// String result = ""; +//// String url = "http://127.0.0.1/uapws/service/nc65to63projectsysplugin";//这是接口地址,注意去掉.wsdl,否则会报错 +// Service service = new Service(); +// Call call = (Call) service.createCall(); +// call.setTargetEndpointAddress(webserviceUrl); +// String parametersName = "string";//设置参数名 +// call.setOperationName("ZoaGlGetglaccperiodbalances");//设置方法名 +// call.addParameter("IvComCode", XMLType.XSD_STRING, ParameterMode.IN);//方法参数,1参数名、2参数类型、3.入参 +// call.addParameter("IvFisPeriod", XMLType.XSD_STRING, ParameterMode.IN);//方法参数,1参数名、2参数类型、3.入参 +// call.addParameter("IvFiscYear", XMLType.XSD_STRING, ParameterMode.IN);//方法参数,1参数名、2参数类型、3.入参 +// call.addParameter("IvGlAccount", XMLType.XSD_STRING, ParameterMode.IN);//方法参数,1参数名、2参数类型、3.入参 +// call.setReturnType(XMLType.XSD_STRING);//返回类型 +// JSONObject keyParams = new JSONObject(); +// keyParams.put("IvComCode", 6000); +// keyParams.put("IvFisPeriod", 8); +// keyParams.put("IvFiscYear", 2022); +// keyParams.put("IvGlAccount", 12345); +// String str = keyParams.toString(); +// logger.writeLog(JobName + " syncSapData Service Call str : " + str); +// Object resultObject = call.invoke(new Object[] { 6000, 8, 2022, 12345 });//调用接口 +// result = (String) resultObject; + } + + public void setModeRight(int creater, int modeid, int sourceid) { + ModeRightInfo moderightinfo = new ModeRightInfo(); + moderightinfo.setNewRight(true); + moderightinfo.editModeDataShare(creater, modeid, sourceid); + } +} diff --git a/src/main/java/com/api/nonstandardext/zenner/job/SyncAccountStatementJob.java b/src/main/java/com/api/nonstandardext/zenner/job/SyncAccountStatementJob.java new file mode 100644 index 0000000..903db8d --- /dev/null +++ b/src/main/java/com/api/nonstandardext/zenner/job/SyncAccountStatementJob.java @@ -0,0 +1,259 @@ +package com.api.nonstandardext.zenner.job; + +import com.api.nonstandardext.zenner.model.bank.DayBalance; +import com.api.nonstandardext.zenner.service.bank.Bank_b2e0005_Service; +import com.api.nonstandardext.zenner.utils.ZennerApiService; +import com.api.nonstandardext.zenner.utils.ZennerUtil; +import org.dom4j.Document; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.interfaces.schedule.BaseCronJob; + +import java.io.File; +import java.util.*; + +/** + * 对账单同步 + * + * 1.银行数据 银行当日几张余额 b2e0005(当日) b2e0012(历史) + * 银行数据 银行收款单 b2e0035 + * 银行数据 银行付款单 b2e0035 + * + * 2. SAP数据 + * + * 3.OA 流程数据 + */ +public class SyncAccountStatementJob extends BaseCronJob { + + BaseBean logger = new BaseBean(); + + private String interfaceName; + + private final static String JobName = " SyncAccountStatementJob "; + + public String getInterfaceName() { + return interfaceName; + } + + public void setInterfaceName(String interfaceName) { + this.interfaceName = interfaceName; + } + + public void execute() { + logger.writeLog("-----" + JobName + " Begin------"); + + RecordSet rs = new RecordSet(); + ZennerApiService zennerApiService = new ZennerApiService(); + try { + logger.writeLog("-----" + JobName + " getInterfaceName------" + getInterfaceName()); + //银行 + String bankApiUrl = zennerApiService.getSystemConfigValue("BANK_API_URL"); + + String bankSql = "select * from uf_bank_account"; + rs.execute(bankSql); + while (rs.next()){ + syncBank_b2e0005(bankApiUrl, Util.null2String(rs.getString("lxh")), Util.null2String(rs.getString("yxzh"))); + } + } catch (Exception e) { + logger.writeLog(JobName + " 获取异常: " + e.getMessage()); + e.printStackTrace(); + } + logger.writeLog("--------------------" + JobName + " End---------------------------"); + } + + /** + * 当日账号余额 b2e0005 + * @param bankApiUrl + * @throws Exception + */ + public void syncBank_b2e0005(String bankApiUrl, String ibknum, String actacn) throws Exception { + + String dirPath = "E:\\WEAVER\\bank\\"; + File dir = new File(dirPath); + if (!dir.exists()) { + dir.mkdirs(); + } + logger.writeLog(JobName + "..syncBank_b2e0005......,,,bankApiUrl: " + bankApiUrl); + //当日账号余额 + Map xmlParams = new HashMap<>(); + + xmlParams.put("termid", "E192168000104"); + xmlParams.put("trnid", ""); + xmlParams.put("cusopr", "395169759"); + xmlParams.put("custid", "387679060"); + xmlParams.put("trncod", "b2e0005"); + xmlParams.put("token", ""); + + xmlParams.put("ibknum", ibknum); + xmlParams.put("actacn", actacn); + String xmlFileUrl = dirPath + "b2e0005_" + ZennerUtil.parseToDateString(Calendar.getInstance().getTime(), ZennerUtil.formatYYYYMMDD)+ ".xml"; + logger.writeLog(JobName + ".syncBank_b2e0005.......,,,xmlFileUrl: " + xmlFileUrl); + Bank_b2e0005_Service bankB2e0005Service = new Bank_b2e0005_Service(); + bankB2e0005Service.createXml(xmlFileUrl, xmlParams); + + String apiParams = bankB2e0005Service.getXmlString(xmlFileUrl); + + Integer pLen = apiParams.length(); + int ps = 500; + int logPageNum = pLen / ps; + int i = 0; + if (pLen <= ps){ + logger.writeLog(JobName + ".syncBank_b2e0005.......,,,voucherParams last: " + apiParams); + } else { + for (i = 0; i < logPageNum; i++){ + logger.writeLog(JobName + ".syncBank_b2e0005.......,,,,,,voucherParams " + i + " : " + apiParams.substring(i * ps, (i + 1) * 500)); + } + logger.writeLog(JobName + ".syncBank_b2e0005.......,,,voucherParams last: " + apiParams.substring((i-1) * 500)); + } + + logger.writeLog(JobName + " bankApiUrl : " + bankApiUrl); + + String result = ZennerUtil.httpPostToken(bankApiUrl, new HashMap<>(), apiParams); + logger.writeLog(JobName + " syncBank_b2e0005 result : " + result); + + Document doc = DocumentHelper.parseText(result); // 将xml转为dom对象 + Element root = doc.getRootElement(); // 获取根节点 + List elements = root.elements("trans");//获取名称为env:Body的子节点 + DayBalance dayBalance = new DayBalance(); + boolean statusOk = false; + for (Object l2 : elements) { //遍历子元素 + + Element l2Element = (Element) l2; + logger.writeLog("l2Element name :" + l2Element.getName()); + List elementsL3 = l2Element.elements(); + + for (Object l3 : elementsL3) { //遍历子元素 + + Element l3Element = (Element) l3; + List elementsL4 = l3Element.elements(); + + for (Object l4 : elementsL4) { //遍历子元素 + + Element dataElement = (Element) l4; + logger.writeLog("l4Element name :" + dataElement.getName()); + + if ("status".equals(dataElement.getName())){ + List elementsL5 = dataElement.elements(); + + for (Object l5 : elementsL5) { //遍历子元素 + Element l5Element = (Element) l5; + if ("rspcod".equals(l5Element.getName())) { + logger.writeLog("rspcod:" + l5Element.getStringValue()); + if (l5Element.getStringValue().equals("B001")){ + statusOk = true; + } else { + statusOk = false; + } + } + if ("rspmsg".equals(l5Element.getName())) { + logger.writeLog("rspmsg:" + l5Element.getStringValue()); + + } + } + } + logger.writeLog("statusOk:" + statusOk); + if (statusOk){ + logger.writeLog("dataElement.getName():" + dataElement.getName()); + if ("b2e0005-rs".equals(dataElement.getName())){ + List elementsData = dataElement.elements(); + + for (Object data : elementsData) { //遍历子元素 + Element l4Element = (Element) data; + if ("account".equals(l4Element.getName())){ + List elementsL5 = l4Element.elements(); + + for (Object l5 : elementsL5) { //遍历子元素 + Element l5Element = (Element) l5; + if ("ibknum".equals(l5Element.getName())) { + logger.writeLog("ibknum:" + l5Element.getStringValue()); + dayBalance.setIbknum(l5Element.getStringValue()); + } + if ("actacn".equals(l5Element.getName())) { + logger.writeLog("actacn:" + l5Element.getStringValue()); + dayBalance.setActacn(l5Element.getStringValue()); + } + if ("curcde".equals(l5Element.getName())) { + logger.writeLog("curcde:" + l5Element.getStringValue()); + dayBalance.setCurcde(l5Element.getStringValue()); + } + if ("actname".equals(l5Element.getName())) { + logger.writeLog("actname:" + l5Element.getStringValue()); + dayBalance.setActname(l5Element.getStringValue()); + } + } + } + + if ("balance".equals(l4Element.getName())) { + List elementsL5 = l4Element.elements(); + + for (Object l5 : elementsL5) { //遍历子元素 + Element l5Element = (Element) l5; + if ("bokbal".equals(l5Element.getName())) { + logger.writeLog("bokbal:" + l5Element.getStringValue()); + dayBalance.setBokbal(l5Element.getStringValue()); + } + if ("avabal".equals(l5Element.getName())) { + logger.writeLog("avabal:" + l5Element.getStringValue()); + dayBalance.setAvabal(l5Element.getStringValue()); + } + if ("currentavabal".equals(l5Element.getName())) { + logger.writeLog("currentavabal:" + l5Element.getStringValue()); + if ("".equals(l5Element.getStringValue())){ + dayBalance.setCurrentavabal("0"); + } else { + dayBalance.setCurrentavabal(l5Element.getStringValue()); + } + + } + if ("stpamt".equals(l5Element.getName())) { + logger.writeLog("stpamt:" + l5Element.getStringValue()); + if ("".equals(l5Element.getStringValue())){ + dayBalance.setStpamt("0"); + } else { + dayBalance.setStpamt(l5Element.getStringValue()); + } + } + if ("ovramt".equals(l5Element.getName())) { + logger.writeLog("ovramt:" + l5Element.getStringValue()); + dayBalance.setOvramt("".equals(l5Element.getStringValue()) ? "0" : l5Element.getStringValue()); + } + if ("frzamt".equals(l5Element.getName())) { + logger.writeLog("frzamt:" + l5Element.getStringValue()); + dayBalance.setFrzamt("".equals(l5Element.getStringValue()) ? "0" : l5Element.getStringValue()); + } + if ("effauthamt".equals(l5Element.getName())) { + logger.writeLog("effauthamt:" + l5Element.getStringValue()); + dayBalance.setEffauthamt("".equals(l5Element.getStringValue()) ? "0" : l5Element.getStringValue()); + } + if ("effusdoverbal".equals(l5Element.getName())) { + logger.writeLog("effusdoverbal:" + l5Element.getStringValue()); + dayBalance.setEffusdoverbal("".equals(l5Element.getStringValue()) ? "0" : l5Element.getStringValue()); + } + if ("effuseablequota".equals(l5Element.getName())) { + logger.writeLog("effuseablequota:" + l5Element.getStringValue()); + dayBalance.setEffuseablequota("".equals(l5Element.getStringValue()) ? "0" : l5Element.getStringValue()); + } + } + } + + if ("baldat".equals(l4Element.getName())) { + logger.writeLog("baldat:" + l4Element.getStringValue()); + + if (!"".equals(l4Element.getStringValue())){ + Date date = ZennerUtil.parseToDate(l4Element.getStringValue(), ZennerUtil.formatYYYYMMDD_NoSplit); + dayBalance.setBaldat(ZennerUtil.parseToDateString(date, ZennerUtil.formatYYYYMMDD)); + } + } + } + } + } + } + } + } + dayBalance.save(dayBalance, 50, "uf_bank_day_balance"); + logger.writeLog(JobName + " result dayBalance: " + dayBalance.toString()); + } +} diff --git a/src/main/java/com/api/nonstandardext/zenner/job/SyncAccountTradeInfoJob.java b/src/main/java/com/api/nonstandardext/zenner/job/SyncAccountTradeInfoJob.java new file mode 100644 index 0000000..3d7106d --- /dev/null +++ b/src/main/java/com/api/nonstandardext/zenner/job/SyncAccountTradeInfoJob.java @@ -0,0 +1,332 @@ +package com.api.nonstandardext.zenner.job; + +import com.api.nonstandardext.zenner.model.bank.TradeInfo; +import com.api.nonstandardext.zenner.service.bank.Bank_b2e0035_Service; +import com.api.nonstandardext.zenner.utils.ZennerApiService; +import com.api.nonstandardext.zenner.utils.ZennerUtil; +import org.dom4j.Document; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.interfaces.schedule.BaseCronJob; +import java.io.File; +import java.util.*; + +/** + * 对账单同步 + * + * 1.银行数据 银行当日几张余额 b2e0005(当日) b2e0012(历史) + * 银行数据 银行收款单 b2e0035 + * 银行数据 银行付款单 b2e0035 + * + * 2. SAP数据 + * + * 3.OA 流程数据 + */ +public class SyncAccountTradeInfoJob extends BaseCronJob { + + BaseBean logger = new BaseBean(); + + private String interfaceName; + + private final static String JobName = " SyncAccountTradeInfoJob "; + + public String getInterfaceName() { + return interfaceName; + } + + public void setInterfaceName(String interfaceName) { + this.interfaceName = interfaceName; + } + + public void execute() { + logger.writeLog("-----" + JobName + " Begin------"); + + RecordSet rs = new RecordSet(); + ZennerApiService zennerApiService = new ZennerApiService(); + try { + logger.writeLog("-----" + JobName + " getInterfaceName------" + getInterfaceName()); + //银行 + String bankApiUrl = zennerApiService.getSystemConfigValue("BANK_API_URL"); + + String bankSql = "select * from uf_bank_account"; + rs.execute(bankSql); + int pageSize = 50; + while (rs.next()){ + int total = syncBank_b2e0035(bankApiUrl, Util.null2String(rs.getString("lxh")), Util.null2String(rs.getString("yxzh")), 1, pageSize); + Integer totalPage = (total + pageSize - 1) / pageSize; + logger.writeLog(JobName + " totalPage:" + totalPage); + for (int pageNo = 2; pageNo <= totalPage; pageNo++) { + int startNo = (pageNo - 1) * pageSize; + int endNo = pageNo * pageSize; + + logger.writeLog(JobName + " startNo:" + startNo + " endNo:" + endNo); + int pageTotal = syncBank_b2e0035(bankApiUrl, Util.null2String(rs.getString("lxh")), Util.null2String(rs.getString("yxzh")), startNo, pageSize); + logger.writeLog(JobName + " total:" + pageTotal); + } + } + } catch (Exception e) { + logger.writeLog(JobName + " 获取异常: " + e.getMessage()); + e.printStackTrace(); + } + logger.writeLog("--------------------" + JobName + " End---------------------------"); + } + + /** + * 同步收付款数据 + * @param bankApiUrl + * @throws Exception + */ + public int syncBank_b2e0035(String bankApiUrl, String ibknum, String actacn, int start, int end) throws Exception { + + int notenum = 0; + String dirPath = "E:\\WEAVER\\bank\\"; + File dir = new File(dirPath); + if (!dir.exists()) { + dir.mkdirs(); + } + + //当日账号余额 + Map xmlParams = new HashMap<>(); + xmlParams.put("termid", "E192168000104"); + xmlParams.put("trnid", ""); + xmlParams.put("cusopr", "395169759"); + xmlParams.put("custid", "387679060"); + xmlParams.put("trncod", "b2e0035"); + xmlParams.put("token", ""); + + xmlParams.put("type", "2002"); + xmlParams.put("ibknum", ibknum); + xmlParams.put("actacn", actacn); + xmlParams.put("from", "20220919"); + Calendar cal = Calendar.getInstance(); + cal.set(Calendar.DAY_OF_MONTH, -1); + xmlParams.put("to", ZennerUtil.parseToDateString(cal.getTime(), ZennerUtil.formatYYYYMMDD_NoSplit)); + xmlParams.put("amountFrom", "1"); + xmlParams.put("amountTo", "100000"); + xmlParams.put("begnum", start + ""); + xmlParams.put("recnum", end + ""); + xmlParams.put("direction", "0"); + + String xmlFileUrl = dirPath + "b2e0035_" + ZennerUtil.parseToDateString(Calendar.getInstance().getTime(), ZennerUtil.formatYYYYMMDD)+ ".xml"; + logger.writeLog(JobName + " xmlFileUrl : " + xmlFileUrl); + Bank_b2e0035_Service bankB2e0035Service = new Bank_b2e0035_Service(); + bankB2e0035Service.createXml(xmlFileUrl, xmlParams); + + String apiParams = bankB2e0035Service.getXmlString(xmlFileUrl); + + Integer pLen = apiParams.length(); + int ps = 500; + int logPageNum = pLen / ps; + int i = 0; + if (pLen <= ps){ + logger.writeLog(JobName + "........,,,voucherParams last: " + apiParams); + } else { + for (i = 0; i < logPageNum; i++){ + logger.writeLog(JobName + "........,,,,,,voucherParams " + i + " : " + apiParams.substring(i * ps, (i + 1) * 500)); + } + logger.writeLog(JobName + "........,,,voucherParams last: " + apiParams.substring((i-1) * 500)); + } + + logger.writeLog(JobName + " bankApiUrl : " + bankApiUrl); + + String result = ZennerUtil.httpPostToken(bankApiUrl, new HashMap<>(), apiParams); + + logger.writeLog(JobName + " syncBank_b2e0035 result : " + result); + + Document doc = DocumentHelper.parseText(result); // 将xml转为dom对象 + Element root = doc.getRootElement(); // 获取根节点 + List elements = root.elements("trans");//获取名称为env:Body的子节点 + List tradeInfoList = new ArrayList<>(); + boolean statusOk = false; + for (Object l2 : elements) { //遍历子元素 + + Element l2Element = (Element) l2; + logger.writeLog(JobName + "l2Element name :" + l2Element.getName()); + List elementsL3 = l2Element.elements(); + + for (Object l3 : elementsL3) { //遍历子元素 + + Element l3Element = (Element) l3; + List elementsL4 = l3Element.elements(); + + for (Object l4 : elementsL4) { //遍历子元素 + + Element dataElement = (Element) l4; + logger.writeLog(JobName + "l4Element name :" + dataElement.getName()); + + if ("status".equals(dataElement.getName())){ + List elementsL5 = dataElement.elements(); + + for (Object l5 : elementsL5) { //遍历子元素 + Element l5Element = (Element) l5; + if ("rspcod".equals(l5Element.getName())) { + logger.writeLog("rspcod:" + l5Element.getStringValue()); + if (l5Element.getStringValue().equals("B001") || l5Element.getStringValue().equals("B002")){ + statusOk = true; + } else { + statusOk = false; + } + } + if ("rspmsg".equals(l5Element.getName())) { + logger.writeLog(JobName + "rspmsg:" + l5Element.getStringValue()); + + } + } + } + if ("totalnum".equals(dataElement.getName())){ + logger.writeLog("totalnum:" + dataElement.getStringValue()); + } + if ("notenum".equals(dataElement.getName())){ + logger.writeLog("notenum:" + dataElement.getStringValue()); + String notenumStr = Util.null2String(dataElement.getStringValue()); + if ("".equals(notenum)){ + notenumStr = "0"; + } + notenum = Integer.parseInt(notenumStr); + } + + logger.writeLog("statusOk:" + statusOk); + if (statusOk){ + logger.writeLog(JobName + "dataElement.getName():" + dataElement.getName()); + if ("b2e0035-rs".equals(dataElement.getName())){ + + TradeInfo tradeInfo = new TradeInfo(); + + List elementsData = dataElement.elements(); + + for (Object data : elementsData) { //遍历子元素 + Element l4Element = (Element) data; + if ("fractn".equals(l4Element.getName())){ + List elementsL5 = l4Element.elements(); + + for (Object l5 : elementsL5) { //遍历子元素 + Element l5Element = (Element) l5; + if ("ibknum".equals(l5Element.getName())) { + tradeInfo.setIbknum(l5Element.getStringValue()); + } + if ("actacn".equals(l5Element.getName())) { + tradeInfo.setActacn(l5Element.getStringValue()); + } + if ("acntname".equals(l5Element.getName())) { + tradeInfo.setAcntname(l5Element.getStringValue()); + } + if ("ibkname".equals(l5Element.getName())) { + tradeInfo.setIbkname(l5Element.getStringValue()); + } + if ("outref".equals(l5Element.getName())) { + tradeInfo.setOutref(l5Element.getStringValue()); + } + } + } + + if ("toactn".equals(l4Element.getName())) { + List elementsL5 = l4Element.elements(); + + for (Object l5 : elementsL5) { //遍历子元素 + Element l5Element = (Element) l5; + if ("toibkn".equals(l5Element.getName())) { + logger.writeLog(JobName + "toibkn:" + l5Element.getStringValue()); + tradeInfo.setToibkn(l5Element.getStringValue()); + } + if ("actacn".equals(l5Element.getName())) { + logger.writeLog(JobName + "actacn:" + l5Element.getStringValue()); + tradeInfo.setActacn_receipt(l5Element.getStringValue()); + } + if ("toname".equals(l5Element.getName())) { + logger.writeLog(JobName + "toname:" + l5Element.getStringValue()); + tradeInfo.setToname(l5Element.getStringValue()); + } + if ("tobank".equals(l5Element.getName())) { + logger.writeLog(JobName + "tobank:" + l5Element.getStringValue()); + tradeInfo.setTobank(l5Element.getStringValue()); + } + if ("tobref".equals(l5Element.getName())) { + logger.writeLog(JobName + "tobref:" + l5Element.getStringValue()); + tradeInfo.setTobref(l5Element.getStringValue()); + } + } + } + + if ("txndate".equals(l4Element.getName())) { + if (!"".equals(l4Element.getStringValue())){ + Date date = ZennerUtil.parseToDate(l4Element.getStringValue(), ZennerUtil.formatYYYYMMDD_NoSplit); + tradeInfo.setTxndate_time(ZennerUtil.parseToDateString(date, ZennerUtil.formatYYYYMMDD)); + } + } + if ("txnamt".equals(l4Element.getName())) { + if (!"".equals(l4Element.getStringValue())){ + tradeInfo.setTxnamt(l4Element.getStringValue()); + } + } + if ("acctbal".equals(l4Element.getName())) { + if (!"".equals(l4Element.getStringValue())){ + tradeInfo.setAcctbal(l4Element.getStringValue()); + } + } + if ("avlbal".equals(l4Element.getName())) { + if (!"".equals(l4Element.getStringValue())){ + tradeInfo.setAvlbal(l4Element.getStringValue()); + } + } + if ("frzamt".equals(l4Element.getName())) { + if (!"".equals(l4Element.getStringValue())){ + tradeInfo.setFrzamt(l4Element.getStringValue()); + } + } + if ("overdramt".equals(l4Element.getName())) { + if (!"".equals(l4Element.getStringValue())){ + tradeInfo.setOverdramt(l4Element.getStringValue()); + } + } + if ("avloverdramt".equals(l4Element.getName())) { + if (!"".equals(l4Element.getStringValue())){ + tradeInfo.setAvloverdramt(l4Element.getStringValue()); + } + } + if ("useinfo".equals(l4Element.getName())) { + if (!"".equals(l4Element.getStringValue())){ + tradeInfo.setUseinfo(l4Element.getStringValue()); + } + } + if ("furinfo".equals(l4Element.getName())) { + if (!"".equals(l4Element.getStringValue())){ + tradeInfo.setFy(l4Element.getStringValue()); + } + } + if ("transtype".equals(l4Element.getName())) { + if (!"".equals(l4Element.getStringValue())){ + tradeInfo.setTranstype(l4Element.getStringValue()); + } + } + if ("trncur".equals(l4Element.getName())) { + if (!"".equals(l4Element.getStringValue())){ + tradeInfo.setTrncur(l4Element.getStringValue()); + } + } + if ("direction".equals(l4Element.getName())) { + if (!"".equals(l4Element.getStringValue())){ + tradeInfo.setDirection(l4Element.getStringValue()); + } + } + } + + tradeInfoList.add(tradeInfo); + } + } + } + } + } + + logger.writeLog(JobName + " result tradeInfoList size: " + tradeInfoList.size()); + for (TradeInfo tradeInfo : tradeInfoList){ + if (!"".equals(tradeInfo.getIbknum())){ + tradeInfo.save(tradeInfo, 51, "uf_bank_trade_info"); + } + } + + return notenum; + } +} diff --git a/src/main/java/com/api/nonstandardext/zenner/model/bank/DayBalance.java b/src/main/java/com/api/nonstandardext/zenner/model/bank/DayBalance.java new file mode 100644 index 0000000..137baa5 --- /dev/null +++ b/src/main/java/com/api/nonstandardext/zenner/model/bank/DayBalance.java @@ -0,0 +1,379 @@ +package com.api.nonstandardext.zenner.model.bank; + +import weaver.conn.RecordSet; +import weaver.formmode.setup.ModeRightInfo; +import weaver.general.BaseBean; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * 当日余额 + */ +public class DayBalance extends BaseBean { + + private Integer formmodeid; + private String modedatacreater; + private String modedatacreatertype; + private String modedatacreatedate; + private String modedatacreatetime; + + //联行号 + private String ibknum; + + //账号 + private String actacn; + + //货币码 + private String curcde; + + //账户户名 + private String actname; + + //账面余额 + private String bokbal; + + //有效余额 + private String avabal; + + //一户通主账户活期账户余额 + private String currentavabal; + + //圈存金额 + private String stpamt; + + //透支额度 + private String ovramt; + + //冻结余额 + private String frzamt; + + //有效额度 + private String effauthamt; + + //有效已用额度 + private String effusdoverbal; + + //有效未用额度 + private String effuseablequota; + + //系统日期 + private String baldat; + + public Integer save(DayBalance ufModel, Integer formmodeid, String tableName) { + + String modelName = "银行当日余额"; + + Integer billId = 0; + + try { + RecordSet rs = new RecordSet(); + String fieldSql = ""; + String valueSql = ""; + boolean result = false; + String currentDateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + ufModel.setFormmodeid(formmodeid); + ufModel.setModedatacreater("1"); + ufModel.setModedatacreatertype("0"); + ufModel.setModedatacreatedate(currentDateTime.substring(0, 10)); + ufModel.setModedatacreatetime(currentDateTime.substring(11)); + + String existSql = "select id from " + tableName + " where ibknum='" + ufModel.getIbknum() + "' and actacn='" + ufModel.getActacn() + "' and curcde='" + ufModel.getCurcde() + "' and baldat='" + ufModel.getBaldat() + "'"; + rs.execute(existSql); + if (rs.next()) { + billId = rs.getInt("id"); + String msg = update(modelName, tableName, ufModel); + if (!"".equals(msg)){ + this.writeLog(modelName + ", 保存异常: " + msg); + } + return billId; + } + + // 获取实体类的所有属性,返回Field数组 + Field[] field = ufModel.getClass().getDeclaredFields(); + // 遍历所有属性 + for (int i = 0; i < field.length; i++) { + // 获取属性的名字,并将属性第一个字符大写 + String name = field[i].getName(); + name = name.substring(0, 1).toUpperCase() + name.substring(1); + // 得到属性类型 + String type = field[i].getGenericType().toString(); + if (type.equals("class java.lang.String")) { + Method m = ufModel.getClass().getMethod("get" + name); + // 调用getter方法获取属性值 + String value = (String) m.invoke(ufModel); + if (value != null) { + fieldSql += "," + name; + valueSql += ",'" + value.trim() + "'"; + } + } + if (type.equals("class java.lang.Integer")) { + Method m = ufModel.getClass().getMethod("get" + name); + // 调用getter方法获取属性值 + Integer value = (Integer) m.invoke(ufModel); + if (value != null) { + fieldSql += "," + name; + valueSql += "," + value + ""; + } + } + } + if (!"".equals(fieldSql)) { + fieldSql = fieldSql.substring(1); + valueSql = valueSql.substring(1); + String insertSql = "insert into " + tableName + " (" + fieldSql + ") values (" + valueSql + ")"; + result = rs.execute(insertSql); + if (!result) { + return -1; + } + RecordSet rightRs = new RecordSet(); + writeLog(modelName + ", insertSql ->" + insertSql + ", result:" + result + ", formmodeid: " + formmodeid); + rightRs.execute("SELECT id FROM " + tableName + " where ibknum='" + ufModel.getIbknum() + "' and actacn='" + ufModel.getActacn() + "' and curcde='" + ufModel.getCurcde() + "' and baldat='" + ufModel.getBaldat() + "'"); + if (rightRs.next()) { + billId = rightRs.getInt("id"); + this.setModeRight(1, formmodeid, billId); + } + } + } catch (Exception e) { + writeLog(modelName + ", 新增报错 ->" + e.getMessage()); + e.printStackTrace(); + return -1; + } + return billId; + } + + public String update(String modelName, String tableName, DayBalance ufModel) throws Exception{ + writeLog(modelName + ", update -> formmodeid: " + formmodeid); + RecordSet rs = new RecordSet(); + String setSql = ""; + boolean result = false; + + try { + // 获取实体类的所有属性,返回Field数组 + Field[] field = ufModel.getClass().getDeclaredFields(); + // 遍历所有属性 + for(int i = 0; i < field.length; i++) { + // 获取属性的名字,并将属性第一个字符大写 + String name = field[i].getName(); + name = name.substring(0, 1).toUpperCase() + name.substring(1); + // 主键不更新 + if("Ibknum".equals(name) || "Actacn".equals(name) || "Curcde".equals(name) || "Baldat".equals(name) || "Modedatacreatedate".equals(name) || "Modedatacreatetime".equals(name)) { + continue; + } + // 得到属性类型 + String type = field[i].getGenericType().toString(); + if (type.equals("class java.lang.String")) { + Method m = ufModel.getClass().getMethod("get" + name); + // 调用getter方法获取属性值 + String value = (String) m.invoke(ufModel); + if (value != null) { + setSql += "," + name + "='" + value + "'"; + } + } + + if (type.equals("class java.lang.Integer")) { + Method m = ufModel.getClass().getMethod("get" + name); + // 调用getter方法获取属性值 + Integer value = (Integer) m.invoke(ufModel); + if (value != null) { + setSql += "," + name + "=" + value; + } + } + } + if(!"".equals(setSql)) { + setSql = setSql.substring(1); + String updateSql = "update " + tableName + " set " + setSql + " where ibknum='" + ufModel.getIbknum() + "' and actacn='" + ufModel.getActacn() + "' and curcde='" + ufModel.getCurcde() + "' and baldat='" + ufModel.getBaldat() + "'"; + writeLog(modelName + ", updateSql ->" + updateSql); + result = rs.execute(updateSql); + if (!result){ + return "修改失败"; + } + } + } catch (Exception e){ + writeLog(modelName + ", 修改报错 ->" + e.getMessage()); + e.printStackTrace(); + return e.getMessage(); + } + return ""; + } + + public void setModeRight(int creater, int modeid, int sourceid) { + ModeRightInfo moderightinfo = new ModeRightInfo(); + moderightinfo.setNewRight(true); + moderightinfo.editModeDataShare(creater, modeid, sourceid); + } + + + public Integer getFormmodeid() { + return formmodeid; + } + + public void setFormmodeid(Integer formmodeid) { + this.formmodeid = formmodeid; + } + + public String getModedatacreater() { + return modedatacreater; + } + + public void setModedatacreater(String modedatacreater) { + this.modedatacreater = modedatacreater; + } + + public String getModedatacreatertype() { + return modedatacreatertype; + } + + public void setModedatacreatertype(String modedatacreatertype) { + this.modedatacreatertype = modedatacreatertype; + } + + public String getModedatacreatedate() { + return modedatacreatedate; + } + + public void setModedatacreatedate(String modedatacreatedate) { + this.modedatacreatedate = modedatacreatedate; + } + + public String getModedatacreatetime() { + return modedatacreatetime; + } + + public void setModedatacreatetime(String modedatacreatetime) { + this.modedatacreatetime = modedatacreatetime; + } + + public String getIbknum() { + return ibknum; + } + + public void setIbknum(String ibknum) { + this.ibknum = ibknum; + } + + public String getActacn() { + return actacn; + } + + public void setActacn(String actacn) { + this.actacn = actacn; + } + + public String getCurcde() { + return curcde; + } + + public void setCurcde(String curcde) { + this.curcde = curcde; + } + + public String getActname() { + return actname; + } + + public void setActname(String actname) { + this.actname = actname; + } + + public String getBokbal() { + return bokbal; + } + + public void setBokbal(String bokbal) { + this.bokbal = bokbal; + } + + public String getAvabal() { + return avabal; + } + + public void setAvabal(String avabal) { + this.avabal = avabal; + } + + public String getCurrentavabal() { + return currentavabal; + } + + public void setCurrentavabal(String currentavabal) { + this.currentavabal = currentavabal; + } + + public String getStpamt() { + return stpamt; + } + + public void setStpamt(String stpamt) { + this.stpamt = stpamt; + } + + public String getOvramt() { + return ovramt; + } + + public void setOvramt(String ovramt) { + this.ovramt = ovramt; + } + + public String getFrzamt() { + return frzamt; + } + + public void setFrzamt(String frzamt) { + this.frzamt = frzamt; + } + + public String getEffauthamt() { + return effauthamt; + } + + public void setEffauthamt(String effauthamt) { + this.effauthamt = effauthamt; + } + + public String getEffusdoverbal() { + return effusdoverbal; + } + + public void setEffusdoverbal(String effusdoverbal) { + this.effusdoverbal = effusdoverbal; + } + + public String getEffuseablequota() { + return effuseablequota; + } + + public void setEffuseablequota(String effuseablequota) { + this.effuseablequota = effuseablequota; + } + + public String getBaldat() { + return baldat; + } + + public void setBaldat(String baldat) { + this.baldat = baldat; + } + + @Override + public String toString() { + return "DayBalance{" + + "ibknum='" + ibknum + '\'' + + ", actacn='" + actacn + '\'' + + ", curcde='" + curcde + '\'' + + ", actname='" + actname + '\'' + + ", bokbal='" + bokbal + '\'' + + ", avabal='" + avabal + '\'' + + ", currentavabal='" + currentavabal + '\'' + + ", stpamt='" + stpamt + '\'' + + ", ovramt='" + ovramt + '\'' + + ", frzamt='" + frzamt + '\'' + + ", effauthamt='" + effauthamt + '\'' + + ", effusdoverbal='" + effusdoverbal + '\'' + + ", effuseablequota='" + effuseablequota + '\'' + + ", baldat='" + baldat + '\'' + + '}'; + } +} diff --git a/src/main/java/com/api/nonstandardext/zenner/model/bank/TradeInfo.java b/src/main/java/com/api/nonstandardext/zenner/model/bank/TradeInfo.java new file mode 100644 index 0000000..d8826eb --- /dev/null +++ b/src/main/java/com/api/nonstandardext/zenner/model/bank/TradeInfo.java @@ -0,0 +1,582 @@ +package com.api.nonstandardext.zenner.model.bank; + +import weaver.conn.RecordSet; +import weaver.formmode.setup.ModeRightInfo; +import weaver.general.BaseBean; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * 当日余额 + */ +public class TradeInfo extends BaseBean { + + private Integer formmodeid; + private String modedatacreater; + private String modedatacreatertype; + private String modedatacreatedate; + private String modedatacreatetime; + + //付款行号 + private String ibknum; + + //付款账号 + private String actacn; + + //货币码 + private String curcde; + + //账户户名 + private String actname; + + //付款人 + private String acntname; + + //付款人开户行名 + private String ibkname; + + //汇款行业务编号 + private String outref; + + //收款行号 + private String toibkn; + + //收款账号 + private String actacn_receipt; + + //收款行业务编号 + private String tobref; + + //收款人 + private String toname; + + //被代理行号 + private String mactibkn; + + //被代理账号 + private String mactacn; + + //被代理账户名 + private String mactname; + + //被代理账户开户行名 + private String mactbank; + + //凭证号或传票号 + private String vchnum; + + //记录标识号 + private String transid; + + //客户业务编号后12位 + private String insid; + + //交易时间 + private String txndate_time; + + //金额 + private String txnamt; + + //交易后余额 + private String acctbal; + + //可用余额 + private String avlbal; + + //冻结金额 + private String frzamt; + + //透支额度 + private String overdramt; + + //可用透支额度 + private String avloverdramt; + + //用途 + private String useinfo; + + //附言 + private String fy; + + //业务类型 + private String transtype; + + //货币名称 + private String trncur; + + //来往账标识 + private String direction; + + //收款人开户行名 + private String tobank; + + public Integer save(TradeInfo ufModel, Integer formmodeid, String tableName) { + + String modelName = "银行交易信息"; + + Integer billId = 0; + + try { + RecordSet rs = new RecordSet(); + String fieldSql = ""; + String valueSql = ""; + boolean result = false; + String currentDateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + ufModel.setFormmodeid(formmodeid); + ufModel.setModedatacreater("1"); + ufModel.setModedatacreatertype("0"); + ufModel.setModedatacreatedate(currentDateTime.substring(0, 10)); + ufModel.setModedatacreatetime(currentDateTime.substring(11)); + + String existSql = "select id from " + tableName + " where ibknum='" + ufModel.getIbknum() + "' and actacn='" + ufModel.getActacn() + "' and outref='" + ufModel.getOutref() + "'"; + rs.execute(existSql); + if (rs.next()) { + billId = rs.getInt("id"); + String msg = update(modelName, tableName, ufModel); + if (!"".equals(msg)){ + this.writeLog(modelName + ", 保存异常: " + msg); + } + return billId; + } + + // 获取实体类的所有属性,返回Field数组 + Field[] field = ufModel.getClass().getDeclaredFields(); + // 遍历所有属性 + for (int i = 0; i < field.length; i++) { + // 获取属性的名字,并将属性第一个字符大写 + String name = field[i].getName(); + name = name.substring(0, 1).toUpperCase() + name.substring(1); + // 得到属性类型 + String type = field[i].getGenericType().toString(); + if (type.equals("class java.lang.String")) { + Method m = ufModel.getClass().getMethod("get" + name); + // 调用getter方法获取属性值 + String value = (String) m.invoke(ufModel); + if (value != null) { + fieldSql += "," + name; + valueSql += ",'" + value.trim() + "'"; + } + } + if (type.equals("class java.lang.Integer")) { + Method m = ufModel.getClass().getMethod("get" + name); + // 调用getter方法获取属性值 + Integer value = (Integer) m.invoke(ufModel); + if (value != null) { + fieldSql += "," + name; + valueSql += "," + value + ""; + } + } + } + if (!"".equals(fieldSql)) { + fieldSql = fieldSql.substring(1); + valueSql = valueSql.substring(1); + String insertSql = "insert into " + tableName + " (" + fieldSql + ") values (" + valueSql + ")"; + result = rs.execute(insertSql); + if (!result) { + return -1; + } + RecordSet rightRs = new RecordSet(); + writeLog(modelName + ", insertSql ->" + insertSql + ", result:" + result + ", formmodeid: " + formmodeid); + rightRs.execute("SELECT id FROM " + tableName + " where ibknum='" + ufModel.getIbknum() + "' and actacn='" + ufModel.getActacn() + "' and outref='" + ufModel.getOutref() + "'"); + if (rightRs.next()) { + billId = rightRs.getInt("id"); + this.setModeRight(1, formmodeid, billId); + } + } + } catch (Exception e) { + writeLog(modelName + ", 新增报错 ->" + e.getMessage()); + e.printStackTrace(); + return -1; + } + return billId; + } + + public String update(String modelName, String tableName, TradeInfo ufModel) throws Exception{ + writeLog(modelName + ", update -> formmodeid: " + formmodeid); + RecordSet rs = new RecordSet(); + String setSql = ""; + boolean result = false; + + try { + // 获取实体类的所有属性,返回Field数组 + Field[] field = ufModel.getClass().getDeclaredFields(); + // 遍历所有属性 + for(int i = 0; i < field.length; i++) { + // 获取属性的名字,并将属性第一个字符大写 + String name = field[i].getName(); + name = name.substring(0, 1).toUpperCase() + name.substring(1); + // 主键不更新 + if("Ibknum".equals(name) || "Actacn".equals(name) || "Curcde".equals(name) || "Baldat".equals(name) || "Modedatacreatedate".equals(name) || "Modedatacreatetime".equals(name)) { + continue; + } + // 得到属性类型 + String type = field[i].getGenericType().toString(); + if (type.equals("class java.lang.String")) { + Method m = ufModel.getClass().getMethod("get" + name); + // 调用getter方法获取属性值 + String value = (String) m.invoke(ufModel); + if (value != null) { + setSql += "," + name + "='" + value + "'"; + } + } + + if (type.equals("class java.lang.Integer")) { + Method m = ufModel.getClass().getMethod("get" + name); + // 调用getter方法获取属性值 + Integer value = (Integer) m.invoke(ufModel); + if (value != null) { + setSql += "," + name + "=" + value; + } + } + } + if(!"".equals(setSql)) { + setSql = setSql.substring(1); + String updateSql = "update " + tableName + " set " + setSql + " where ibknum='" + ufModel.getIbknum() + "' and actacn='" + ufModel.getActacn() + "' and outref='" + ufModel.getOutref() + "'"; + writeLog(modelName + ", updateSql ->" + updateSql); + result = rs.execute(updateSql); + if (!result){ + return "修改失败"; + } + } + } catch (Exception e){ + writeLog(modelName + ", 修改报错 ->" + e.getMessage()); + e.printStackTrace(); + return e.getMessage(); + } + return ""; + } + + public void setModeRight(int creater, int modeid, int sourceid) { + ModeRightInfo moderightinfo = new ModeRightInfo(); + moderightinfo.setNewRight(true); + moderightinfo.editModeDataShare(creater, modeid, sourceid); + } + + + public Integer getFormmodeid() { + return formmodeid; + } + + public void setFormmodeid(Integer formmodeid) { + this.formmodeid = formmodeid; + } + + public String getModedatacreater() { + return modedatacreater; + } + + public void setModedatacreater(String modedatacreater) { + this.modedatacreater = modedatacreater; + } + + public String getModedatacreatertype() { + return modedatacreatertype; + } + + public void setModedatacreatertype(String modedatacreatertype) { + this.modedatacreatertype = modedatacreatertype; + } + + public String getModedatacreatedate() { + return modedatacreatedate; + } + + public void setModedatacreatedate(String modedatacreatedate) { + this.modedatacreatedate = modedatacreatedate; + } + + public String getModedatacreatetime() { + return modedatacreatetime; + } + + public void setModedatacreatetime(String modedatacreatetime) { + this.modedatacreatetime = modedatacreatetime; + } + + public String getIbknum() { + return ibknum; + } + + public void setIbknum(String ibknum) { + this.ibknum = ibknum; + } + + public String getActacn() { + return actacn; + } + + public void setActacn(String actacn) { + this.actacn = actacn; + } + + public String getCurcde() { + return curcde; + } + + public void setCurcde(String curcde) { + this.curcde = curcde; + } + + public String getActname() { + return actname; + } + + public void setActname(String actname) { + this.actname = actname; + } + + public String getAcntname() { + return acntname; + } + + public void setAcntname(String acntname) { + this.acntname = acntname; + } + + public String getIbkname() { + return ibkname; + } + + public void setIbkname(String ibkname) { + this.ibkname = ibkname; + } + + public String getOutref() { + return outref; + } + + public void setOutref(String outref) { + this.outref = outref; + } + + public String getToibkn() { + return toibkn; + } + + public void setToibkn(String toibkn) { + this.toibkn = toibkn; + } + + public String getActacn_receipt() { + return actacn_receipt; + } + + public void setActacn_receipt(String actacn_receipt) { + this.actacn_receipt = actacn_receipt; + } + + public String getTobref() { + return tobref; + } + + public void setTobref(String tobref) { + this.tobref = tobref; + } + + public String getToname() { + return toname; + } + + public void setToname(String toname) { + this.toname = toname; + } + + public String getMactibkn() { + return mactibkn; + } + + public void setMactibkn(String mactibkn) { + this.mactibkn = mactibkn; + } + + public String getMactacn() { + return mactacn; + } + + public void setMactacn(String mactacn) { + this.mactacn = mactacn; + } + + public String getMactname() { + return mactname; + } + + public void setMactname(String mactname) { + this.mactname = mactname; + } + + public String getMactbank() { + return mactbank; + } + + public void setMactbank(String mactbank) { + this.mactbank = mactbank; + } + + public String getVchnum() { + return vchnum; + } + + public void setVchnum(String vchnum) { + this.vchnum = vchnum; + } + + public String getTransid() { + return transid; + } + + public void setTransid(String transid) { + this.transid = transid; + } + + public String getInsid() { + return insid; + } + + public void setInsid(String insid) { + this.insid = insid; + } + + public String getTxndate_time() { + return txndate_time; + } + + public void setTxndate_time(String txndate_time) { + this.txndate_time = txndate_time; + } + + public String getTxnamt() { + return txnamt; + } + + public void setTxnamt(String txnamt) { + this.txnamt = txnamt; + } + + public String getAcctbal() { + return acctbal; + } + + public void setAcctbal(String acctbal) { + this.acctbal = acctbal; + } + + public String getAvlbal() { + return avlbal; + } + + public void setAvlbal(String avlbal) { + this.avlbal = avlbal; + } + + public String getFrzamt() { + return frzamt; + } + + public void setFrzamt(String frzamt) { + this.frzamt = frzamt; + } + + public String getOverdramt() { + return overdramt; + } + + public void setOverdramt(String overdramt) { + this.overdramt = overdramt; + } + + public String getAvloverdramt() { + return avloverdramt; + } + + public void setAvloverdramt(String avloverdramt) { + this.avloverdramt = avloverdramt; + } + + public String getUseinfo() { + return useinfo; + } + + public void setUseinfo(String useinfo) { + this.useinfo = useinfo; + } + + public String getFy() { + return fy; + } + + public void setFy(String fy) { + this.fy = fy; + } + + public String getTranstype() { + return transtype; + } + + public void setTranstype(String transtype) { + this.transtype = transtype; + } + + public String getTrncur() { + return trncur; + } + + public void setTrncur(String trncur) { + this.trncur = trncur; + } + + public String getDirection() { + return direction; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + public String getTobank() { + return tobank; + } + + public void setTobank(String tobank) { + this.tobank = tobank; + } + + @Override + public String toString() { + return "TradeInfo{" + + "ibknum='" + ibknum + '\'' + + ", actacn='" + actacn + '\'' + + ", curcde='" + curcde + '\'' + + ", actname='" + actname + '\'' + + ", acntname='" + acntname + '\'' + + ", ibkname='" + ibkname + '\'' + + ", outref='" + outref + '\'' + + ", toibkn='" + toibkn + '\'' + + ", actacn_receipt='" + actacn_receipt + '\'' + + ", tobref='" + tobref + '\'' + + ", toname='" + toname + '\'' + + ", mactibkn='" + mactibkn + '\'' + + ", mactacn='" + mactacn + '\'' + + ", mactname='" + mactname + '\'' + + ", mactbank='" + mactbank + '\'' + + ", vchnum='" + vchnum + '\'' + + ", transid='" + transid + '\'' + + ", insid='" + insid + '\'' + + ", txndate_time='" + txndate_time + '\'' + + ", txnamt='" + txnamt + '\'' + + ", acctbal='" + acctbal + '\'' + + ", avlbal='" + avlbal + '\'' + + ", frzamt='" + frzamt + '\'' + + ", overdramt='" + overdramt + '\'' + + ", avloverdramt='" + avloverdramt + '\'' + + ", useinfo='" + useinfo + '\'' + + ", fy='" + fy + '\'' + + ", transtype='" + transtype + '\'' + + ", trncur='" + trncur + '\'' + + ", direction='" + direction + '\'' + + ", tobank='" + tobank + '\'' + + '}'; + } +} diff --git a/src/main/java/com/api/nonstandardext/zenner/model/sap/PeriodBalance.java b/src/main/java/com/api/nonstandardext/zenner/model/sap/PeriodBalance.java new file mode 100644 index 0000000..c3cd35d --- /dev/null +++ b/src/main/java/com/api/nonstandardext/zenner/model/sap/PeriodBalance.java @@ -0,0 +1,314 @@ +package com.api.nonstandardext.zenner.model.sap; + +import weaver.conn.RecordSet; +import weaver.formmode.setup.ModeRightInfo; +import weaver.general.BaseBean; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * 期间余额 + */ +public class PeriodBalance extends BaseBean { + + private Integer formmodeid; + private String modedatacreater; + private String modedatacreatertype; + private String modedatacreatedate; + private String modedatacreatetime; + + private String IvCompCode; + private String IvFiscYear; + private String IvFisPeriod; + + //累计余额 + private String EvBalance; + + //期间余额 + private String EvPerSales; + + //期间贷方发生额 + private String EvCreditPer; + + //期间借方发生额 + private String EvDebitsPer; + + //币种 + private String EvCurrency; + + //科目 + private String glAccount; + + public Integer save(PeriodBalance ufModel, Integer formmodeid, String tableName) { + + String modelName = "期间余额"; + + Integer billId = 0; + + try { + RecordSet rs = new RecordSet(); + String fieldSql = ""; + String valueSql = ""; + boolean result = false; + String currentDateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + ufModel.setFormmodeid(formmodeid); + ufModel.setModedatacreater("1"); + ufModel.setModedatacreatertype("0"); + ufModel.setModedatacreatedate(currentDateTime.substring(0, 10)); + ufModel.setModedatacreatetime(currentDateTime.substring(11)); + + String existSql = "select id from " + tableName + " where IvCompCode='" + ufModel.getIvCompCode() + "' and IvFiscYear='" + ufModel.getIvFiscYear() + "' and IvFisPeriod='" + ufModel.getIvFisPeriod() + "'"; + rs.execute(existSql); + if (rs.next()) { + billId = rs.getInt("id"); + String msg = update(modelName, tableName, ufModel); + if (!"".equals(msg)){ + this.writeLog(modelName + ", 保存异常: " + msg); + } + return billId; + } + + // 获取实体类的所有属性,返回Field数组 + Field[] field = ufModel.getClass().getDeclaredFields(); + // 遍历所有属性 + for (int i = 0; i < field.length; i++) { + // 获取属性的名字,并将属性第一个字符大写 + String name = field[i].getName(); + name = name.substring(0, 1).toUpperCase() + name.substring(1); + // 得到属性类型 + String type = field[i].getGenericType().toString(); + if (type.equals("class java.lang.String")) { + Method m = ufModel.getClass().getMethod("get" + name); + // 调用getter方法获取属性值 + String value = (String) m.invoke(ufModel); + if (value != null) { + fieldSql += "," + name; + valueSql += ",'" + value.trim() + "'"; + } + } + if (type.equals("class java.lang.Integer")) { + Method m = ufModel.getClass().getMethod("get" + name); + // 调用getter方法获取属性值 + Integer value = (Integer) m.invoke(ufModel); + if (value != null) { + fieldSql += "," + name; + valueSql += "," + value + ""; + } + } + } + if (!"".equals(fieldSql)) { + fieldSql = fieldSql.substring(1); + valueSql = valueSql.substring(1); + String insertSql = "insert into " + tableName + " (" + fieldSql + ") values (" + valueSql + ")"; + result = rs.execute(insertSql); + if (!result) { + return -1; + } + RecordSet rightRs = new RecordSet(); + writeLog(modelName + ", insertSql ->" + insertSql + ", result:" + result + ", formmodeid: " + formmodeid); + rightRs.execute("SELECT id FROM " + tableName + " where IvCompCode='" + ufModel.getIvCompCode() + "' and IvFiscYear='" + ufModel.getIvFiscYear() + "' and IvFisPeriod='" + ufModel.getIvFisPeriod() + "'"); + if (rightRs.next()) { + billId = rightRs.getInt("id"); + this.setModeRight(1, formmodeid, billId); + } + } + } catch (Exception e) { + writeLog(modelName + ", 新增报错 ->" + e.getMessage()); + e.printStackTrace(); + return -1; + } + return billId; + } + + public String update(String modelName, String tableName, PeriodBalance ufModel) throws Exception{ + writeLog(modelName + ", update -> formmodeid: " + formmodeid); + RecordSet rs = new RecordSet(); + String setSql = ""; + boolean result = false; + + try { + // 获取实体类的所有属性,返回Field数组 + Field[] field = ufModel.getClass().getDeclaredFields(); + // 遍历所有属性 + for(int i = 0; i < field.length; i++) { + // 获取属性的名字,并将属性第一个字符大写 + String name = field[i].getName(); + name = name.substring(0, 1).toUpperCase() + name.substring(1); + // 主键不更新 + if("IvCompCode".equals(name) || "IvFiscYear".equals(name) || "IvFisPeriod".equals(name) || "Modedatacreatedate".equals(name) || "Modedatacreatetime".equals(name)) { + continue; + } + // 得到属性类型 + String type = field[i].getGenericType().toString(); + if (type.equals("class java.lang.String")) { + Method m = ufModel.getClass().getMethod("get" + name); + // 调用getter方法获取属性值 + String value = (String) m.invoke(ufModel); + if (value != null) { + setSql += "," + name + "='" + value + "'"; + } + } + + if (type.equals("class java.lang.Integer")) { + Method m = ufModel.getClass().getMethod("get" + name); + // 调用getter方法获取属性值 + Integer value = (Integer) m.invoke(ufModel); + if (value != null) { + setSql += "," + name + "=" + value; + } + } + } + if(!"".equals(setSql)) { + setSql = setSql.substring(1); + String updateSql = "update " + tableName + " set " + setSql + " where IvCompCode='" + ufModel.getIvCompCode() + "' and IvFiscYear='" + ufModel.getIvFiscYear() + "' and IvFisPeriod='" + ufModel.getIvFisPeriod() + "'"; + writeLog(modelName + ", updateSql ->" + updateSql); + result = rs.execute(updateSql); + if (!result){ + return "修改失败"; + } + } + } catch (Exception e){ + writeLog(modelName + ", 修改报错 ->" + e.getMessage()); + e.printStackTrace(); + return e.getMessage(); + } + return ""; + } + + public void setModeRight(int creater, int modeid, int sourceid) { + ModeRightInfo moderightinfo = new ModeRightInfo(); + moderightinfo.setNewRight(true); + moderightinfo.editModeDataShare(creater, modeid, sourceid); + } + + + public Integer getFormmodeid() { + return formmodeid; + } + + public void setFormmodeid(Integer formmodeid) { + this.formmodeid = formmodeid; + } + + public String getModedatacreater() { + return modedatacreater; + } + + public void setModedatacreater(String modedatacreater) { + this.modedatacreater = modedatacreater; + } + + public String getModedatacreatertype() { + return modedatacreatertype; + } + + public void setModedatacreatertype(String modedatacreatertype) { + this.modedatacreatertype = modedatacreatertype; + } + + public String getModedatacreatedate() { + return modedatacreatedate; + } + + public void setModedatacreatedate(String modedatacreatedate) { + this.modedatacreatedate = modedatacreatedate; + } + + public String getModedatacreatetime() { + return modedatacreatetime; + } + + public void setModedatacreatetime(String modedatacreatetime) { + this.modedatacreatetime = modedatacreatetime; + } + + public String getEvBalance() { + return EvBalance; + } + + public void setEvBalance(String evBalance) { + EvBalance = evBalance; + } + + public String getEvPerSales() { + return EvPerSales; + } + + public void setEvPerSales(String evPerSales) { + EvPerSales = evPerSales; + } + + public String getEvCreditPer() { + return EvCreditPer; + } + + public void setEvCreditPer(String evCreditPer) { + EvCreditPer = evCreditPer; + } + + public String getEvDebitsPer() { + return EvDebitsPer; + } + + public void setEvDebitsPer(String evDebitsPer) { + EvDebitsPer = evDebitsPer; + } + + public String getEvCurrency() { + return EvCurrency; + } + + public void setEvCurrency(String evCurrency) { + EvCurrency = evCurrency; + } + + public String getGlAccount() { + return glAccount; + } + + public void setGlAccount(String glAccount) { + this.glAccount = glAccount; + } + + public String getIvCompCode() { + return IvCompCode; + } + + public void setIvCompCode(String ivCompCode) { + IvCompCode = ivCompCode; + } + + public String getIvFiscYear() { + return IvFiscYear; + } + + public void setIvFiscYear(String ivFiscYear) { + IvFiscYear = ivFiscYear; + } + + public String getIvFisPeriod() { + return IvFisPeriod; + } + + public void setIvFisPeriod(String ivFisPeriod) { + IvFisPeriod = ivFisPeriod; + } + + @Override + public String toString() { + return "PeriodBalance{" + + "IvCompCode='" + IvCompCode + '\'' + + ", IvFiscYear='" + IvFiscYear + '\'' + + ", IvFisPeriod='" + IvFisPeriod + '\'' + + ", EvBalance='" + EvBalance + '\'' + + ", EvPerSales='" + EvPerSales + '\'' + + ", EvCreditPer='" + EvCreditPer + '\'' + + ", EvDebitsPer='" + EvDebitsPer + '\'' + + ", EvCurrency='" + EvCurrency + '\'' + + ", glAccount='" + glAccount + '\'' + + '}'; + } +} diff --git a/src/main/java/com/api/nonstandardext/zenner/service/bank/Bank_b2e0005_Service.java b/src/main/java/com/api/nonstandardext/zenner/service/bank/Bank_b2e0005_Service.java new file mode 100644 index 0000000..a199fd9 --- /dev/null +++ b/src/main/java/com/api/nonstandardext/zenner/service/bank/Bank_b2e0005_Service.java @@ -0,0 +1,130 @@ +package com.api.nonstandardext.zenner.service.bank; + +import org.xml.sax.helpers.AttributesImpl; +import weaver.general.BaseBean; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Result; +import javax.xml.transform.Transformer; +import javax.xml.transform.sax.SAXTransformerFactory; +import javax.xml.transform.sax.TransformerHandler; +import javax.xml.transform.stream.StreamResult; +import java.io.*; +import java.util.*; + +public class Bank_b2e0005_Service extends BaseBean { + + private final static String ServiceName = " Bank_b2e0005_Service "; + + public void createXml(String xmlFileUrl, Map params) throws Exception{ + + SAXTransformerFactory tff = (SAXTransformerFactory) SAXTransformerFactory.newInstance(); + // 2、通过SAXTransformerFactory创建一个TransformerHandler的对象 + TransformerHandler handler = tff.newTransformerHandler(); + + // 3、通过handler创建一个Transformer对象 + Transformer tr = handler.getTransformer(); + // 4、通过Transformer对象对生成的xml文件进行设置 + // 设置编码方式 + tr.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); + // 设置是否换行 + tr.setOutputProperty(OutputKeys.INDENT, "yes"); + // 5、创建一个Result对象 + + File f = new File(xmlFileUrl); + // 判断文件是否存在 + if (!f.exists()) { + f.createNewFile(); + } + Result result = new StreamResult(new FileOutputStream(f)); + // 6、使RESULT与handler关联 + handler.setResult(result); + + // 打开document + handler.startDocument(); + + AttributesImpl attrImpl = new AttributesImpl(); + + this.writeLog(ServiceName + "........,,,params: " + params.toString()); + + attrImpl.addAttribute("", "", "version", "", "100"); + attrImpl.addAttribute("", "", "security", "", "true"); + attrImpl.addAttribute("", "", "lang", "", "chs"); + + handler.startElement("", "", "bocb2e", attrImpl); + + attrImpl.clear(); + attrImpl.addAttribute("", "", "id", "", "11074E1000000000S6SL"); + handler.startElement("", "", "head", attrImpl); + + attrImpl.clear(); + handler.startElement("", "", "termid", attrImpl); + handler.characters(params.get("termid").toCharArray(), 0, params.get("termid").length()); + handler.endElement("", "", "termid"); + + handler.startElement("", "", "trnid", attrImpl); + handler.characters(params.get("trnid").toCharArray(), 0, params.get("trnid").length()); + handler.endElement("", "", "trnid"); + + handler.startElement("", "", "cusopr", attrImpl); + handler.characters(params.get("cusopr").toCharArray(), 0, params.get("cusopr").length()); + handler.endElement("", "", "cusopr"); + + handler.startElement("", "", "custid", attrImpl); + handler.characters(params.get("custid").toCharArray(), 0, params.get("custid").length()); + handler.endElement("", "", "custid"); + + handler.startElement("", "", "trncod", attrImpl); + handler.characters(params.get("trncod").toCharArray(), 0, params.get("trncod").length()); + handler.endElement("", "", "trncod"); + + handler.startElement("", "", "token", attrImpl); + handler.characters(params.get("token").toCharArray(), 0, params.get("token").length()); + handler.endElement("", "", "token"); + + handler.endElement("", "", "head"); + + attrImpl.clear(); + handler.startElement("", "", "trans", attrImpl); + this.writeLog(ServiceName + "........,,,params 2 : " + params.toString()); + handler.startElement("", "", "trn-b2e0005-rq", attrImpl); + handler.startElement("", "", "b2e0005-rq", attrImpl); + handler.startElement("", "", "account", attrImpl); + + handler.startElement("", "", "ibknum", attrImpl); + handler.characters(params.get("ibknum").toCharArray(), 0, params.get("ibknum").length()); + handler.endElement("", "", "ibknum"); + + handler.startElement("", "", "actacn", attrImpl); + handler.characters(params.get("actacn").toCharArray(), 0, params.get("actacn").length()); + handler.endElement("", "", "actacn"); + + handler.endElement("", "", "account"); + handler.endElement("", "", "b2e0005-rq"); + handler.endElement("", "", "trn-b2e0005-rq"); + + handler.endElement("", "", "trans"); + + handler.endElement("", "", "bocb2e"); + this.writeLog(ServiceName + "........,,,params 3 : " + params.toString()); + // 关闭document + handler.endDocument(); + } + + public String getXmlString(String xmlFileUrl) { + + StringBuilder sb = new StringBuilder(); + try { + InputStream inputStream = new FileInputStream(xmlFileUrl); + BufferedReader br=new BufferedReader(new InputStreamReader(inputStream)); + String line=""; + for(line=br.readLine();line!=null;line=br.readLine()) { + sb.append(line+"\n"); + } + } catch (FileNotFoundException e) { + this.writeLog(ServiceName + " e 1 : " + e.getMessage()); + } catch (IOException e) { + this.writeLog(ServiceName + " e 2 : " + e.getMessage()); + } + return sb.toString(); + } +} diff --git a/src/main/java/com/api/nonstandardext/zenner/service/bank/Bank_b2e0035_Service.java b/src/main/java/com/api/nonstandardext/zenner/service/bank/Bank_b2e0035_Service.java new file mode 100644 index 0000000..d45fa40 --- /dev/null +++ b/src/main/java/com/api/nonstandardext/zenner/service/bank/Bank_b2e0035_Service.java @@ -0,0 +1,160 @@ +package com.api.nonstandardext.zenner.service.bank; + +import org.xml.sax.helpers.AttributesImpl; +import weaver.general.BaseBean; + +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Result; +import javax.xml.transform.Transformer; +import javax.xml.transform.sax.SAXTransformerFactory; +import javax.xml.transform.sax.TransformerHandler; +import javax.xml.transform.stream.StreamResult; +import java.io.*; +import java.util.Map; + +public class Bank_b2e0035_Service extends BaseBean { + + private final static String ServiceName = " Bank_b2e0035_Service "; + + public void createXml(String xmlFileUrl, Map params) throws Exception{ + + SAXTransformerFactory tff = (SAXTransformerFactory) SAXTransformerFactory.newInstance(); + // 2、通过SAXTransformerFactory创建一个TransformerHandler的对象 + TransformerHandler handler = tff.newTransformerHandler(); + + // 3、通过handler创建一个Transformer对象 + Transformer tr = handler.getTransformer(); + // 4、通过Transformer对象对生成的xml文件进行设置 + // 设置编码方式 + tr.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); + // 设置是否换行 + tr.setOutputProperty(OutputKeys.INDENT, "yes"); + // 5、创建一个Result对象 + + File f = new File(xmlFileUrl); + // 判断文件是否存在 + if (!f.exists()) { + f.createNewFile(); + } + Result result = new StreamResult(new FileOutputStream(f)); + // 6、使RESULT与handler关联 + handler.setResult(result); + + // 打开document + handler.startDocument(); + + AttributesImpl attrImpl = new AttributesImpl(); + + attrImpl.addAttribute("", "", "version", "", "110"); + attrImpl.addAttribute("", "", "locale", "", "zh_CN"); + + handler.startElement("", "", "bocb2e", attrImpl); + + attrImpl.clear(); + handler.startElement("", "", "head", attrImpl); + + attrImpl.clear(); + handler.startElement("", "", "termid", attrImpl); + handler.characters(params.get("termid").toCharArray(), 0, params.get("termid").length()); + handler.endElement("", "", "termid"); + + handler.startElement("", "", "trnid", attrImpl); + handler.characters(params.get("trnid").toCharArray(), 0, params.get("trnid").length()); + handler.endElement("", "", "trnid"); + + handler.startElement("", "", "cusopr", attrImpl); + handler.characters(params.get("cusopr").toCharArray(), 0, params.get("cusopr").length()); + handler.endElement("", "", "cusopr"); + + handler.startElement("", "", "custid", attrImpl); + handler.characters(params.get("custid").toCharArray(), 0, params.get("custid").length()); + handler.endElement("", "", "custid"); + + handler.startElement("", "", "trncod", attrImpl); + handler.characters(params.get("trncod").toCharArray(), 0, params.get("trncod").length()); + handler.endElement("", "", "trncod"); + + handler.startElement("", "", "token", attrImpl); + handler.characters(params.get("token").toCharArray(), 0, params.get("token").length()); + handler.endElement("", "", "token"); + + handler.endElement("", "", "head"); + + attrImpl.clear(); + handler.startElement("", "", "trans", attrImpl); + + handler.startElement("", "", "trn-b2e0035-rq", attrImpl); + handler.startElement("", "", "b2e0035-rq", attrImpl); + + handler.startElement("", "", "ibknum", attrImpl); + handler.characters(params.get("ibknum").toCharArray(), 0, params.get("ibknum").length()); + handler.endElement("", "", "ibknum"); + + handler.startElement("", "", "actacn", attrImpl); + handler.characters(params.get("actacn").toCharArray(), 0, params.get("actacn").length()); + handler.endElement("", "", "actacn"); + + handler.startElement("", "", "type", attrImpl); + handler.characters(params.get("type").toCharArray(), 0, params.get("type").length()); + handler.endElement("", "", "type"); + + handler.startElement("", "", "datescope", attrImpl); + handler.startElement("", "", "from", attrImpl); + handler.characters(params.get("from").toCharArray(), 0, params.get("from").length()); + handler.endElement("", "", "from"); + + handler.startElement("", "", "to", attrImpl); + handler.characters(params.get("to").toCharArray(), 0, params.get("to").length()); + handler.endElement("", "", "to"); + handler.endElement("", "", "datescope"); + + handler.startElement("", "", "amountscope", attrImpl); + handler.startElement("", "", "from", attrImpl); + handler.characters(params.get("amountFrom").toCharArray(), 0, params.get("amountFrom").length()); + handler.endElement("", "", "from"); + + handler.startElement("", "", "to", attrImpl); + handler.characters(params.get("amountTo").toCharArray(), 0, params.get("amountTo").length()); + handler.endElement("", "", "to"); + handler.endElement("", "", "amountscope"); + + handler.startElement("", "", "begnum", attrImpl); + handler.characters(params.get("begnum").toCharArray(), 0, params.get("begnum").length()); + handler.endElement("", "", "begnum"); + + handler.startElement("", "", "recnum", attrImpl); + handler.characters(params.get("recnum").toCharArray(), 0, params.get("recnum").length()); + handler.endElement("", "", "recnum"); + + handler.startElement("", "", "direction", attrImpl); + handler.characters(params.get("direction").toCharArray(), 0, params.get("direction").length()); + handler.endElement("", "", "direction"); + handler.endElement("", "", "b2e0035-rq"); + handler.endElement("", "", "trn-b2e0035-rq"); + + handler.endElement("", "", "trans"); + + handler.endElement("", "", "bocb2e"); + + // 关闭document + handler.endDocument(); + } + + public String getXmlString(String xmlFileUrl) { + + StringBuilder sb = new StringBuilder(); + try { + InputStream inputStream = new FileInputStream(xmlFileUrl); + BufferedReader br=new BufferedReader(new InputStreamReader(inputStream)); + String line=""; + for(line=br.readLine();line!=null;line=br.readLine()) { + sb.append(line+"\n"); + } + } catch (FileNotFoundException e) { + this.writeLog(ServiceName + " e 1 : " + e.getMessage()); + } catch (IOException e) { + this.writeLog(ServiceName + " e 2 : " + e.getMessage()); + } + return sb.toString(); + } +} diff --git a/src/main/java/com/api/nonstandardext/zenner/utils/SAPWebserviceTool.java b/src/main/java/com/api/nonstandardext/zenner/utils/SAPWebserviceTool.java new file mode 100644 index 0000000..38eddc9 --- /dev/null +++ b/src/main/java/com/api/nonstandardext/zenner/utils/SAPWebserviceTool.java @@ -0,0 +1,288 @@ +package com.api.nonstandardext.zenner.utils; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; +import net.sf.json.xml.XMLSerializer; +import org.apache.http.HttpEntity; +import org.apache.http.auth.AuthScope; +import org.apache.http.auth.UsernamePasswordCredentials; +import org.apache.http.client.CredentialsProvider; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.BasicCredentialsProvider; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import java.io.IOException; + +/** + * + * 真诺-SAP工具类 + * @Date: 2022/9/09 10:06 + */ +public class SAPWebserviceTool extends BaseBean { + + //SAP接口日志表名称 + private String Logger_Mode_Table = this.getSystemParamValue("SAPInterface_Logger_Mode_TableName"); + + //SAP接口日志模块ID + private int Logger_Mode_ID = Util.getIntValue(this.getSystemParamValue("SAPInterface_Logger_Mode_ID"),0); + + //获取SAP接口认证头参数值(用户名) + private String authenticator_username = this.getSystemParamValue("SAP_Webservice_Authenticator_Username"); + //获取SAP接口认证头参数值(密码) + private String authenticator_password = this.getSystemParamValue("SAP_Webservice_Authenticator_Password"); + + public String getSystemParamValue(String uuid){ + String paramvalue = ""; + + if(!"".equals(uuid)){ + String select_sql = "select paramvalue from uf_systemconfig where uuid = ?"; + + RecordSet rs = new RecordSet(); + rs.executeQuery(select_sql,uuid); + if(rs.next()){ + paramvalue = Util.null2String(rs.getString(1)); + } + } + + return paramvalue; + } + + /** + * 无参数构造方法 + */ + public SAPWebserviceTool(){ + if("".equals(authenticator_username)){ + authenticator_username = this.getSystemParamValue("SAP_Webservice_Authenticator_Username"); + } + + if("".equals(authenticator_password)){ + authenticator_password = this.getSystemParamValue("SAP_Webservice_Authenticator_Password"); + } + } + + public String callParams_011(String comCode, String period, String year, String glAccount){ + + String params = "\n" + + " \n" + + " \n" + + " \n" + + " $comCode$\n" + + " $period$\n" + + " $year$\n" + + " $glAccount$\n" + + " \n" + + " \n" + + ""; + params = params.replace("$comCode$", comCode); + params = params.replace("$period$", period); + params = params.replace("$year$", year); + params = params.replace("$glAccount$", glAccount); + + + this.writeLog(" xml params:[" + params.toString() + "]"); + return params; + } + + /** + * { + * "@xmlns:n0": "urn:sap-com:document:sap:soap:functions:mc-style", + * "EsReturn": { + * "Type": [], + * "Code": [], + * "Message": [], + * "LogNo": [], + * "LogMsgNo": "000000", + * "MessageV1": [], + * "MessageV2": [], + * "MessageV3": [], + * "MessageV4": [] + * }, + * "EvBalance": "19715385.21", + * "EvCreditPer": "-220.0", + * "EvCurrency": "CNY", + * "EvDebitsPer": "15718007.26", + * "EvPerSales": "15717787.26", + * "EvRc": "S" + * } + * @param params + * @return + */ + public JSONObject callInterface_011(String params){ + JSONObject result = new JSONObject(); + + String webservice_url = this.getSystemParamValue("SAP_OA011_Webservice_URL");//"http://ashca160.minol.org:8004/sap/bc/srt/rfc/sap/zoa_outgoing_document_post1/400/s1/b1"; + this.writeLog("xml webservice_url:[" + webservice_url + "]"); + this.writeLog("authenticator_username:[" + authenticator_username + "] authenticator_password[" + authenticator_password + "]"); + try { + String webservice_result = sendPostData(webservice_url, params, authenticator_username, authenticator_password); + result.put("webservice_result", webservice_result); + this.writeLog("sap webservice_result:[" + webservice_result + "]"); + if(null != webservice_result && !"".equals(webservice_result)){ + + XMLSerializer xmlSerializer = new XMLSerializer(); + JSONObject results = (JSONObject) xmlSerializer.read(webservice_result); + JSONObject balanceResponse = results.getJSONObject("soap-env:Body").getJSONObject("n0:ZoaGlGetglaccperiodbalancesResponse"); + this.writeLog("balanceResponse toString:[" + balanceResponse.toString() + "]"); + + String evRc = balanceResponse.getString("EvRc");//返回代码 S 成功,E 错误,W 警告,I 信息,A 中断 + if ("S".equals(evRc)){ + result.put("balanceResponse", balanceResponse); + } else { + + String message = ""; + if(isJson(balanceResponse.getString("EtReturn"))){ + JSONObject EtReturn = balanceResponse.getJSONObject("EtReturn").getJSONObject("item"); + String TYPE = EtReturn.getString("TYPE"); + String MESSAGE = EtReturn.getString("MESSAGE"); + message = MESSAGE; + }else{ + JSONArray EtReturn = balanceResponse.getJSONArray("EtReturn"); + for(int k=0;k>>StatusCode["+StatusCode+"]"); + + //通过HttpResponse接口的getEntity方法返回响应信息,并进行相应的处理 + HttpEntity entity = response.getEntity(); + + reponsedata = EntityUtils.toString(entity); + + //最后关闭HttpClient资源. + client.close(); + } catch (IOException e) { + this.writeLog("====>>>sendPostData Exception["+e.getMessage() + "/" + e.toString()+"]"); + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return reponsedata; + } +} diff --git a/src/main/java/com/api/nonstandardext/zenner/utils/ZennerApiService.java b/src/main/java/com/api/nonstandardext/zenner/utils/ZennerApiService.java new file mode 100644 index 0000000..92cae0a --- /dev/null +++ b/src/main/java/com/api/nonstandardext/zenner/utils/ZennerApiService.java @@ -0,0 +1,20 @@ +package com.api.nonstandardext.zenner.utils; + +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; + +public class ZennerApiService extends BaseBean { + + //通过parambs配置标识查找系统参数配置表获取配置值 + public String getSystemConfigValue(String configKey){ + String configValue = ""; + RecordSet rs = new RecordSet(); + String corpSecretSql = "select paramvalue from uf_systemconfig where uuid = '" + configKey + "'"; + rs.execute(corpSecretSql); + if (rs.next()){ + configValue = Util.null2String(rs.getString("paramvalue")); + } + return configValue; + } +} diff --git a/src/main/java/com/api/nonstandardext/zenner/utils/ZennerUtil.java b/src/main/java/com/api/nonstandardext/zenner/utils/ZennerUtil.java new file mode 100644 index 0000000..af3749e --- /dev/null +++ b/src/main/java/com/api/nonstandardext/zenner/utils/ZennerUtil.java @@ -0,0 +1,374 @@ +package com.api.nonstandardext.zenner.utils; + +import com.api.nonstandardext.allist.utils.DefaultTmForAllist; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.HttpException; +import org.apache.commons.httpclient.methods.PostMethod; +import org.apache.http.client.utils.DateUtils; +import weaver.general.BaseBean; + +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSocketFactory; +import java.io.*; +import java.net.*; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.Map; +import java.util.Set; + +public class ZennerUtil { + + public final static SimpleDateFormat formatYYYYMMDDHHMMSS = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + public final static SimpleDateFormat formatYYYYMMDD = new SimpleDateFormat("yyyy-MM-dd"); + + public final static SimpleDateFormat formatYYYYMMDD_NoSplit = new SimpleDateFormat("yyyyMMdd"); + + public static boolean isJsonObject(String content) { + try { + JSONObject.fromObject(content); + return true; + } catch (Exception e) { + return false; + } + } + + public static boolean isJsonArray(String content) { + try { + JSONArray.fromObject(content);; + return true; + } catch (Exception e) { + return false; + } + } + + public static String parseToDateString(Date date, SimpleDateFormat formatInfo) { + if (date == null) { + return ""; + } + return formatInfo.format(date); + } + + public static Date parseToDate(String dateString, SimpleDateFormat formatInfo){ + try { + return formatInfo.parse(dateString); + } catch (ParseException e) { + e.printStackTrace(); + } + return null; + } + + public static String httpPostToken(String httpUrl, Map headParams, String bodyParams) { + BaseBean log = new BaseBean(); + log.writeLog(httpUrl); + log.writeLog(headParams); + log.writeLog(bodyParams); + String result = ""; + HttpClient httpClient = new HttpClient(); + PostMethod postMethod = new PostMethod(httpUrl); + Set keySet = headParams.keySet(); + for (String key : keySet) { + postMethod.setRequestHeader(key, headParams.get(key)); + } + postMethod.setRequestBody(bodyParams); + postMethod.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); + log.writeLog(postMethod); + try { + int httpStatus = httpClient.executeMethod(postMethod); + byte[] resultByte = postMethod.getResponseBody(); + result = new String(resultByte, "UTF-8"); + + } catch (HttpException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return result; + } + + public static String proxyHttp(boolean needProxy, String proxyIp, String proxyPort, String userId, String password, String url, String param, String encoding){ + OutputStreamWriter out = null; + BufferedReader in = null; + String result = ""; + + BaseBean logger = new BaseBean(); + + try { + URL realUrl = new URL(url); + HttpURLConnection conn = null; + + if (needProxy){ + @SuppressWarnings("static-access") + Proxy proxy = new Proxy(Proxy.Type.DIRECT.HTTP, new InetSocketAddress(proxyIp, Integer.parseInt(proxyPort))); + conn = (HttpURLConnection) realUrl.openConnection(proxy); + } else { + conn = (HttpURLConnection) realUrl.openConnection(); + } + + logger.writeLog("发送 POST needProxy : " +needProxy); + logger.writeLog("发送 POST conn : " +conn); + logger.writeLog("发送 POST userId : " +userId); + logger.writeLog("发送 POST no proxy : "); + + if (needProxy){ + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + if (getRequestorType().equals( RequestorType.PROXY )) { + return new PasswordAuthentication(userId, password.toCharArray() ); + } + return super.getPasswordAuthentication(); + } + }); + } + + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + conn.setRequestMethod("POST"); // POST方法 + + // 设置通用的请求属性 + if (needProxy){ + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + } +// conn.setRequestProperty("Authorization", "Basic " + encoding); + logger.writeLog("发送 POST encoding : "+ encoding); + conn.setRequestProperty("Content-Type", "text/xml;charset=UTF-8"); + conn.connect(); + + // 获取URLConnection对象对应的输出流 + out = new OutputStreamWriter(conn.getOutputStream(), "UTF-8"); + // 发送请求参数 + out.write(param); + + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + logger.writeLog("发送 POST line : "+ line); + result += line; + } + + logger.writeLog("发送 POST result : "+ result); + } catch (Exception e) { + logger.writeLog("发送 POST 请求出现异常!"+e); + e.printStackTrace(); + } finally{ + try{ + if(out!=null){ + out.close(); + } + if(in!=null){ + in.close(); + } + } + catch(IOException ex){ + ex.printStackTrace(); + } + } + return result; + } + + public static String httpsGet(String baseUrl,String encoderNum) { + BufferedReader in = null; + BaseBean baseBean = new BaseBean(); + try { + SSLContext sslContext = SSLContext.getInstance("TLSv1.2"); + javax.net.ssl.TrustManager[] truset = new javax.net.ssl.TrustManager[1]; + javax.net.ssl.TrustManager tm = new DefaultTmForAllist(); + truset[0] = tm; + sslContext.init(null, truset, null); + SSLSocketFactory factory = sslContext.getSocketFactory(); + URL u = new URL(baseUrl); + HttpsURLConnection huconn = (HttpsURLConnection) u.openConnection(); + huconn.setSSLSocketFactory(factory); + huconn.setRequestProperty("Authorization","Basic " + encoderNum); + StringBuilder result = new StringBuilder(); + huconn.connect(); +// baseBean.writeLog("httpsGet execute baseUrl..1." + baseUrl); + in = new BufferedReader(new InputStreamReader(huconn.getInputStream(), "UTF-8")); + String line; + while ((line = in.readLine()) != null) { + result.append(line); + } + if (in != null) { + in.close(); + } +// baseBean.writeLog("httpsGet execute result..1." + result.toString()); + // 打印返回结果 + return result.toString(); + } catch (Exception e) { + baseBean.writeLog("httpsGet execute exception...message:" + e.getMessage()); + if (in != null) { + try { + in.close(); + } catch (IOException ioException) { + ioException.printStackTrace(); + baseBean.writeLog("关闭报错"); + baseBean.writeLog(ioException.getMessage()); + } + } + return ""; + } + } + + + public static String httpGet(String baseUrl){ + String url = baseUrl; + try { + URL u = new URL(url); + HttpURLConnection huconn = (HttpURLConnection) u.openConnection(); + BufferedReader in = null; + StringBuilder result = new StringBuilder(); + huconn.connect(); + in = new BufferedReader(new InputStreamReader(huconn.getInputStream(), "UTF-8")); + String line; + while ((line = in.readLine()) != null) { + result.append(line); + } + if (in != null) { + in.close(); + } + return result.toString(); + } catch (Exception e) { + return ""; + } + } + + public static String httpsPost(String httpUrl, String content) throws Exception { + BufferedReader in = null; + SSLContext sslContext = SSLContext.getInstance("TLSv1.2"); + javax.net.ssl.TrustManager [] truset = new javax.net.ssl.TrustManager[1]; + javax.net.ssl.TrustManager tm = new DefaultTmForAllist(); + truset[0] = tm; + sslContext.init(null,truset,null); + SSLSocketFactory factory = sslContext.getSocketFactory(); +//https://blog.csdn.net/pk5454754/article/details/80092974?utm_medium=distribute.pc_relevant_download.none-task-blog-baidujs-1.nonecase&depth_1-utm_source=distribute.pc_relevant_download.none-task-blog-baidujs-1.nonecase + URL u = new URL(httpUrl); + HttpsURLConnection conn = (HttpsURLConnection) u.openConnection(); + conn.setDoOutput(true); + conn.addRequestProperty("connection", "Keep-Alive"); + conn.setRequestMethod("POST"); + conn.setSSLSocketFactory(factory); + StringBuilder result = new StringBuilder(); + conn.connect(); + DataOutputStream out = new DataOutputStream(conn.getOutputStream()); + out.write(content.getBytes("utf-8")); + // 刷新、关闭 + out.flush(); + out.close(); + in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8")); + String line; + while ((line = in.readLine()) != null) { + result.append(line); + } + if (in != null) { + in.close(); + } + return result.toString(); + } + + public static String httpPostForXwwwForm(String httpUrl, Map headParams, Map paramsMap){ + String result = ""; + + HttpClient httpClient = new HttpClient(); + PostMethod postMethod = new PostMethod(httpUrl); + Set keySet = headParams.keySet(); + for (String key : keySet) { + postMethod.setRequestHeader(key, headParams.get(key)); + } + + Set paramsSet = paramsMap.keySet(); + for (String key : paramsSet) { + postMethod.setParameter(key, paramsMap.get(key)); + } + + postMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + + try { + int httpStatus = httpClient.executeMethod(postMethod); + byte[] resultByte = postMethod.getResponseBody(); + result = new String(resultByte, "UTF-8"); + + } catch (HttpException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return result; + } + + /** + * 获取当前季度 + */ + public static int getQuarter() { + Calendar c = Calendar.getInstance(); + int month = c.get(c.MONTH) + 1; + int quarter = 0; + if (month >= 1 && month <= 3) { + quarter = 1; + } else if (month >= 4 && month <= 6) { + quarter = 2; + } else if (month >= 7 && month <= 9) { + quarter = 3; + } else { + quarter = 4; + } + return quarter; + } + + /** + * 获取某季度的第一天和最后一天 num第几季度 + */ + public static String[] getCurrQuarter(int num) { + String[] s = new String[2]; + String str = ""; + // 设置本年的季 + Calendar quarterCalendar = null; + switch (num) { + case 1: // 本年到现在经过了一个季度,在加上前4个季度 + quarterCalendar = Calendar.getInstance(); + quarterCalendar.set(Calendar.MONTH, 3); + quarterCalendar.set(Calendar.DATE, 1); + quarterCalendar.add(Calendar.DATE, -1); + str = DateUtils.formatDate(quarterCalendar.getTime(), "yyyy-MM-dd"); + s[0] = str.substring(0, str.length() - 5) + "01-01"; + s[1] = str; + break; + case 2: // 本年到现在经过了二个季度,在加上前三个季度 + quarterCalendar = Calendar.getInstance(); + quarterCalendar.set(Calendar.MONTH, 6); + quarterCalendar.set(Calendar.DATE, 1); + quarterCalendar.add(Calendar.DATE, -1); + str = DateUtils.formatDate(quarterCalendar.getTime(), "yyyy-MM-dd"); + s[0] = str.substring(0, str.length() - 5) + "04-01"; + s[1] = str; + break; + case 3:// 本年到现在经过了三个季度,在加上前二个季度 + quarterCalendar = Calendar.getInstance(); + quarterCalendar.set(Calendar.MONTH, 9); + quarterCalendar.set(Calendar.DATE, 1); + quarterCalendar.add(Calendar.DATE, -1); + str = DateUtils.formatDate(quarterCalendar.getTime(), "yyyy-MM-dd"); + s[0] = str.substring(0, str.length() - 5) + "07-01"; + s[1] = str; + break; + case 4:// 本年到现在经过了四个季度,在加上前一个季度 + quarterCalendar = Calendar.getInstance(); + str = DateUtils.formatDate(quarterCalendar.getTime(), "yyyy-MM-dd"); + s[0] = str.substring(0, str.length() - 5) + "10-01"; + s[1] = str.substring(0, str.length() - 5) + "12-31"; + break; + } + return s; + } +} diff --git a/src/main/java/com/engine/hrm/cmd/departmentfielddefined/GetFieldDefinedCmd.java b/src/main/java/com/engine/hrm/cmd/departmentfielddefined/GetFieldDefinedCmd.java new file mode 100644 index 0000000..0fc9e5b --- /dev/null +++ b/src/main/java/com/engine/hrm/cmd/departmentfielddefined/GetFieldDefinedCmd.java @@ -0,0 +1,309 @@ +package com.engine.hrm.cmd.departmentfielddefined; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.cloudstore.dev.api.util.TextUtil; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.EncryptConfigBiz; +import com.engine.common.entity.BizLogContext; +import com.engine.common.entity.EncryptFieldEntity; +import com.engine.common.enums.EncryptMould; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.LabelUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.definedfield.HrmDeptFieldManagerE9; +import weaver.hrm.definedfield.HrmFieldComInfo; +import weaver.matrix.MatrixUtil; +import weaver.systeminfo.SystemEnv; +import weaver.workflow.field.BrowserComInfo; + +/** + * 自定义字段 + * @author lvyi + * + */ + +public class GetFieldDefinedCmd extends AbstractCommonCommand> { + + public GetFieldDefinedCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List> lsFieldInfo = new ArrayList>(); + Map fieldInfo = null; + Map recordInfo = null; + Map propsInfo = null; + Map comInfo = null; + List fieldTypeInfo = null; + List lsComDetialInfo = null; + Map comDetialInfo = null; + try { + if (!HrmUserVarify.checkUserRight("DeptDefineInfo1:DeptMaintain1", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + int groupId = Util.getIntValue((String)params.get("groupId")); + boolean encryptEnable = EncryptConfigBiz.getEncryptEnable(EncryptMould.HRM.getCode()); + int scopeId = 5; + BrowserComInfo BrowserComInfo = new BrowserComInfo(); + HrmFieldComInfo HrmFieldComInfo = new HrmFieldComInfo(); + HrmDeptFieldManagerE9 hfm = new HrmDeptFieldManagerE9(scopeId); + List lsGroup = hfm.getLsGroup(); + lsGroup = hfm.getLsGroup(); + int idx = 0; + boolean canDel = false; + for (int i = 0; lsGroup != null && i < lsGroup.size(); i++) { + String groupid = (String) lsGroup.get(i); + List lsField = hfm.getLsField(groupid); + if(!groupid.equals(""+groupId)){ + continue; + } + if (lsField.size() == 0) + continue; + for (int j = 0; lsField != null && j < lsField.size(); j++) { + String fieldid = (String) lsField.get(j); + String issystem = HrmFieldComInfo.getIssystem(fieldid); + String fieldname = HrmFieldComInfo.getFieldname(fieldid); + boolean isUsed = false; + if (issystem.equals("1")) { + isUsed = true; + } else { + isUsed = hfm.getIsUsed(fieldid, fieldname); + } + String fieldlabel = HrmFieldComInfo.getLabel(fieldid); + String fieldfdbtype = HrmFieldComInfo.getFielddbtype(fieldid); + String fieldhtmltype = HrmFieldComInfo.getFieldhtmltype(fieldid); + String fieldtype = HrmFieldComInfo.getFieldType(fieldid); + String fielddmlurl = HrmFieldComInfo.getFieldDmlurl(fieldid); + String fieldstrlength = hfm.getStrLength(fieldfdbtype, fieldhtmltype, fieldtype); + String allowhide = HrmFieldComInfo.getAllowhide(fieldid); + String isUse = HrmFieldComInfo.getIsused(fieldid); + String isMand = HrmFieldComInfo.getIsmand(fieldid); + String dsporder = HrmFieldComInfo.getDsporder(fieldid); + String textheight = ""+HrmFieldComInfo.getTextheight(fieldid); + //判断人力资源类型 字段是否通过矩阵被流程引用 + boolean isUsed_ = false; + if (fieldtype.equals("1") || fieldtype.equals("17")) { + isUsed_ = MatrixUtil.isUsed(fieldname, "2"); + if (isUsed_) + isUsed = isUsed_; + } + + List fieldTypeObj = new ArrayList(); + String fieldType = ""; + if (fieldhtmltype.equals("1")) { + fieldTypeObj.add("input"); + fieldType = SystemEnv.getHtmlLabelName(688, user.getLanguage()); + if (fieldhtmltype.equals("1")) { + if (fieldtype.equals("1")) { + fieldTypeObj.add("text"); + fieldType += " " + SystemEnv.getHtmlLabelName(608, user.getLanguage()); + fieldType += " " + SystemEnv.getHtmlLabelName(608, user.getLanguage()) + ":" + fieldstrlength; + fieldTypeObj.add(fieldstrlength); + } else if (fieldtype.equals("2")) { + fieldTypeObj.add("int"); + fieldType += " " + SystemEnv.getHtmlLabelName(696, user.getLanguage()); + } else if (fieldtype.equals("3")) { + fieldTypeObj.add("float"); + fieldType += " " + SystemEnv.getHtmlLabelName(697, user.getLanguage()); + } + } + } else if (fieldhtmltype.equals("2")) { + fieldTypeObj.add("textarea"); + fieldType = SystemEnv.getHtmlLabelName(689, user.getLanguage()); + //fieldType += " " + SystemEnv.getHtmlLabelName(689, user.getLanguage())+textheight+" "+(fieldtype.equals("1")?"":""); + } else if (fieldhtmltype.equals("3")) { + fieldTypeObj.add("browser"); + List replaceDatas = new ArrayList(); + Map tmp = new HashMap(); + tmp.put("value", fieldtype); + tmp.put("valueSpan", SystemEnv.getHtmlLabelName(Util.getIntValue(BrowserComInfo.getBrowserlabelid(fieldtype), 0), user.getLanguage())); + Map tmp1 = new HashMap(); + tmp1.put("id", fieldtype); + tmp1.put("name", SystemEnv.getHtmlLabelName(Util.getIntValue(BrowserComInfo.getBrowserlabelid(fieldtype), 0), user.getLanguage())); + replaceDatas.add(tmp1); + tmp.put("replaceDatas", replaceDatas); + fieldTypeObj.add(tmp); + if(fieldtype.equals("161")||fieldtype.equals("162") || fieldtype.equals("256") || fieldtype.equals("257")){ + tmp = new HashMap(); + tmp.put("value", fielddmlurl); + tmp.put("valueSpan", getName(fielddmlurl)); + fieldTypeObj.add(tmp); + } + fieldType = SystemEnv.getHtmlLabelName(695, user.getLanguage()); + fieldType += " " + SystemEnv.getHtmlLabelName(Util.getIntValue(BrowserComInfo.getBrowserlabelid(fieldtype), 0), user.getLanguage()); + if ("emptyVal".equals(fielddmlurl) || "".equals(fielddmlurl)) { + } else { + fieldType += " " + getName(fielddmlurl); + } + } else if (fieldhtmltype.equals("4")) { + fieldTypeObj.add("check"); + fieldType = SystemEnv.getHtmlLabelName(691, user.getLanguage()); + } else if (fieldhtmltype.equals("5")) { + fieldTypeObj.add("select"); + fieldTypeObj.add("select"); + List datas = new ArrayList(); + Map tmp = new HashMap(); + Map data = null; + RecordSet rs = new RecordSet(); + rs.executeSql("select selectvalue, selectname, isdefault, cancel from hrm_selectitem where fieldid=" + fieldid + " order by listorder"); + int key = 0; + while (rs.next()) { + data = new HashMap(); + data.put("option", rs.getString("selectname")); + data.put("default", rs.getString("isdefault")); + data.put("unuse", rs.getString("cancel")); + datas.add(data); + } + tmp.put("datas", datas); + tmp.put("sort", "horizontal"); + fieldTypeObj.add(tmp); + fieldType = SystemEnv.getHtmlLabelName(690, user.getLanguage()); + } else if (fieldhtmltype.equals("6")) { + fieldTypeObj.add("upload"); + fieldTypeObj.add("file"); + fieldType = SystemEnv.getHtmlLabelName(17616, user.getLanguage()); + fieldType += " " + SystemEnv.getHtmlLabelName(20798, user.getLanguage()); + //fieldType += " " + (fieldtype.equals("1") ? SystemEnv.getHtmlLabelName(20798, user.getLanguage()) : SystemEnv.getHtmlLabelName(20001, user.getLanguage())); + } + + fieldInfo = new HashMap(); + recordInfo = new HashMap(); + recordInfo.put("id", fieldid); + recordInfo.put("fieldlabel", TextUtil.toBase64ForMultilang(new LabelUtil().getMultiLangLabel(fieldlabel))); + recordInfo.put("fieldname", fieldname); + recordInfo.put("fieldType", fieldType); + recordInfo.put("fieldTypeObj", fieldTypeObj); + recordInfo.put("enable", isUse); + recordInfo.put("required", isMand); + recordInfo.put("viewAttr", isUsed || issystem.equals("1") ? 1 : 2); + recordInfo.put("key", dsporder); + if (encryptEnable && ((fieldhtmltype.equals("1")||fieldhtmltype.equals("2")) && !issystem.equals("1")) ) { + //只支持单行文本,多行文本 + String tablename = "hrmdepartmentdefined"; + EncryptFieldEntity encryptFieldEntity = EncryptConfigBiz.getFieldEncryptConfig(tablename,fieldname); + recordInfo.put("encryptId", encryptFieldEntity!=null?encryptFieldEntity.getId():""); + recordInfo.put("tablename", tablename); + recordInfo.put("canEncrypt", "1"); + } + fieldInfo.put("record", recordInfo); + + propsInfo = new HashMap(); + Map checkPropsInfo = new HashMap(); + Map checkPropsDetialInfo = null; + checkPropsDetialInfo = new HashMap(); + checkPropsDetialInfo.put("viewAttr", allowhide.equals("1") ? 2 : 1); + checkPropsInfo.put("enable", checkPropsDetialInfo); + checkPropsInfo.put("required", checkPropsDetialInfo); + propsInfo.put("checkProps", checkPropsInfo); + fieldInfo.put("props", propsInfo); + + comInfo = new HashMap(); + + lsComDetialInfo = new ArrayList(); + comDetialInfo = new HashMap(); + comDetialInfo.put("label", ""); + comDetialInfo.put("type", "INPUT"); + comDetialInfo.put("width", "15%"); + comDetialInfo.put("key", "fieldlabel"); + comDetialInfo.put("viewAttr", "3"); + lsComDetialInfo.add(comDetialInfo); + comInfo.put("fieldlabel", lsComDetialInfo); + + lsComDetialInfo = new ArrayList(); + comDetialInfo = new HashMap(); + comDetialInfo.put("label", ""); + comDetialInfo.put("type", "TEXT"); + comDetialInfo.put("width", "15%"); + comDetialInfo.put("key", "fieldname"); + comDetialInfo.put("viewAttr", "3"); + lsComDetialInfo.add(comDetialInfo); + comInfo.put("fieldname", lsComDetialInfo); + + lsComDetialInfo = new ArrayList(); + comDetialInfo = new HashMap(); + comDetialInfo.put("label", ""); + comDetialInfo.put("type", fieldhtmltype.equals("5") ? "CUSTOMFIELD" : "TEXT"); + comDetialInfo.put("width", "60%"); + comDetialInfo.put("key", "fieldType"); + lsComDetialInfo.add(comDetialInfo); + comInfo.put("fieldType", lsComDetialInfo); + + fieldInfo.put("com", comInfo); + + fieldTypeInfo = new ArrayList(); + fieldTypeInfo.add("select"); + fieldTypeInfo.add("select"); + Map fieldTypeParamInfo = new HashMap(); + List lsFieldTypeParamDetialInfo = new ArrayList(); + Map fieldTypeParamDetialInfo = null; + + if (fieldhtmltype.equals("5")) { + //hfm.getSelectItem(fieldid); + RecordSet rs = new RecordSet(); + rs.executeSql("select selectvalue, selectname, isdefault, cancel from hrm_selectitem where fieldid=" + fieldid + " order by listorder"); + int key = 0; + while (rs.next()) { + fieldTypeParamDetialInfo = new HashMap(); + fieldTypeParamDetialInfo.put("key", key++); + fieldTypeParamDetialInfo.put("id", rs.getString("selectvalue")); + fieldTypeParamDetialInfo.put("option", rs.getString("selectname")); + fieldTypeParamDetialInfo.put("default", rs.getString("isdefault")); + fieldTypeParamDetialInfo.put("unuse", rs.getString("cancel")); + lsFieldTypeParamDetialInfo.add(fieldTypeParamDetialInfo); + } + fieldTypeParamInfo.put("datas", lsFieldTypeParamDetialInfo); + fieldTypeParamInfo.put("sort", "horizontal"); + fieldTypeInfo.add(fieldTypeParamInfo); + fieldInfo.put("fieldType", fieldTypeInfo); + } + lsFieldInfo.add(fieldInfo); + } + } + retmap.put("status", "1"); + retmap.put("data", lsFieldInfo); + retmap.put("encryptEnable",encryptEnable); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return retmap; + } + + private String getName(String showname) { + RecordSet rs = new RecordSet(); + if (showname != null && !"".equals(showname)) { + //兼容老数据,如果id有moduleid,则去掉 + int index = showname.indexOf("."); + if (index > 0) { + showname = showname.substring(index + 1); + } + String sql = "select name from datashowset where showname='" + showname + "'"; + rs.executeSql(sql); + if (rs.next()) { + return Util.null2String(rs.getString("name")); + } + } + return ""; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/main/java/com/engine/hrm/cmd/departmentfielddefined/SaveFieldDefinedCmd.java b/src/main/java/com/engine/hrm/cmd/departmentfielddefined/SaveFieldDefinedCmd.java new file mode 100644 index 0000000..6a55493 --- /dev/null +++ b/src/main/java/com/engine/hrm/cmd/departmentfielddefined/SaveFieldDefinedCmd.java @@ -0,0 +1,213 @@ +package com.engine.hrm.cmd.departmentfielddefined; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.hrm.entity.FieldBean; +import com.engine.hrm.entity.FieldSelectOptionBean; +import com.engine.hrm.util.HrmUtil; +import weaver.conn.RecordSet; +import weaver.docs.docs.FieldParam; +import weaver.general.LabelUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.common.database.dialect.DialectUtil; +import weaver.hrm.definedfield.HrmDeptFieldManagerE9; +import weaver.hrm.definedfield.HrmFieldComInfo; +import weaver.matrix.MatrixUtil; +import weaver.systeminfo.SystemEnv; + +/** + * 保存自定义字段 + * @author lvyi + * + */ +public class SaveFieldDefinedCmd extends AbstractCommonCommand>{ + + private SimpleBizLogger logger; + + public SaveFieldDefinedCmd(Map params, User user) { + this.user = user; + this.params = params; + + RecordSet rs = new RecordSet(); + String sql = ""; + String data = Util.null2String(params.get("data")); + JSONObject jsonObj = JSON.parseObject(data); + String groupId = Util.null2String(jsonObj.get("groupId")); + + this.logger = new SimpleBizLogger(); + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_DEPARTMENTFIELDDEFINED);//所属大类型 + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_DEPARTMENTFIELDDEFINED);//当前小类型 + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + String mainSql = "SELECT a.*, b.labelname FROM hrm_fieldgroup a, htmllabelinfo b WHERE a.grouplabel= b.indexid and a.id= "+groupId+" and b.languageid="+user.getLanguage(); + logger.setMainSql(mainSql,"id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("labelname");//当前targetName对应的列(对应日志中的对象名) + + SimpleBizLogger.SubLogInfo subLogInfo = logger.getNewSubLogInfo(); + String subSql = "SELECT * FROM hrm_formfield WHERE groupid = "+groupId; + subLogInfo.setSubSql(subSql,"fieldid"); + logger.addSubLogInfo(subLogInfo); + logger.before(bizLogContext); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + HrmFieldComInfo HrmFieldComInfo = new HrmFieldComInfo(); + String sql = ""; + try { + if(!HrmUserVarify.checkUserRight("DeptDefineInfo1:DeptMaintain1",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + String data = Util.null2String(params.get("data")); + JSONObject jsonObj = JSON.parseObject(data); + String groupId = Util.null2String(jsonObj.get("groupId")); + String groupType = ""; + + sql = "SELECT grouptype FROM hrm_fieldgroup WHERE id="+groupId; + rs.executeSql(sql); + if(rs.next()){ + groupType = rs.getString("groupType"); + } + + List listFieldLabel = new ArrayList(); + List listFieldName = new ArrayList(); + sql = " SELECT fieldlabel FROM hrm_formfield WHERE groupid IN (SELECT id FROM hrm_fieldgroup WHERE grouptype = "+groupType+") and groupid not in("+groupId+")"; + rs.executeQuery(sql); + while(rs.next()){ + listFieldLabel.add(SystemEnv.getHtmlLabelNames(rs.getString("fieldlabel"), user.getLanguage())); + } + + sql = " SELECT fieldname FROM hrm_formfield WHERE groupid IN (SELECT id FROM hrm_fieldgroup WHERE grouptype = "+groupType+") and groupid not in("+groupId+")"; + rs.executeQuery(sql); + while(rs.next()){ + listFieldName.add(rs.getString("fieldname").toLowerCase()); + } + + JSONArray records = (JSONArray)jsonObj.get("records"); + for(int i=0; i(listFieldLabel).size()|| + listFieldName.size() != new HashSet(listFieldName).size()){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(383055, user.getLanguage())); + return retmap; + } + + for(int i=0; i lsSelectOption = fieldBean.getFieldTypeBean().getLsSelectOption(); + hfm.checkSelectField(temId, lsSelectOption); + } + }catch (Exception e) { + writeLog(e); + } + } + + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + +} diff --git a/src/main/java/com/engine/hrm/cmd/organization/GetDepartmentFormFieldCmd.java b/src/main/java/com/engine/hrm/cmd/organization/GetDepartmentFormFieldCmd.java new file mode 100644 index 0000000..f32e54e --- /dev/null +++ b/src/main/java/com/engine/hrm/cmd/organization/GetDepartmentFormFieldCmd.java @@ -0,0 +1,189 @@ +package com.engine.hrm.cmd.organization; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.definedfield.HrmDeptFieldManager; +import weaver.hrm.definedfield.HrmDeptFieldManagerE9; +import weaver.hrm.definedfield.HrmFieldComInfo; +import weaver.hrm.definedfield.HrmFieldGroupComInfo; +import weaver.systeminfo.SystemEnv; + +import com.api.browser.bean.SearchConditionItem; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.hrm.util.HrmOrganizationUtil; + +public class GetDepartmentFormFieldCmd extends AbstractCommonCommand> { + + public GetDepartmentFormFieldCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + + Map retmap = new HashMap(); + List> grouplist = new ArrayList>(); + Map groupitem = null; + List itemlist = null; + try { + String id = Util.null2String(params.get("id")); + int viewattr = Util.getIntValue((String)params.get("viewattr"),1); + String nodeType = Util.null2String(params.get("type")); + String addType = Util.null2String(params.get("addType")); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + String subcompanyid1 = ""; + String supdepid = ""; + + if(addType.equals("normal")){ + if(nodeType.equals("subcompany")){ + subcompanyid1 = id; + }else{ + subcompanyid1 = departmentComInfo.getSubcompanyid1(id); + } + }else if(addType.equals("sibling")){ + subcompanyid1 = departmentComInfo.getSubcompanyid1(id); + supdepid = departmentComInfo.getDepartmentsupdepid(id); + }else if(addType.equals("child")){ + subcompanyid1 = departmentComInfo.getSubcompanyid1(id); + supdepid = id; + } + + HrmFieldGroupComInfo HrmFieldGroupComInfo = new HrmFieldGroupComInfo(); + HrmFieldComInfo HrmFieldComInfo = new HrmFieldComInfo(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + HrmDeptFieldManagerE9 hfm = new HrmDeptFieldManagerE9(5); + hfm.isReturnDecryptData(true); + hfm.getCustomData(Util.getIntValue(id)); + List lsGroup = hfm.getLsGroup(); + for (int tmp = 0; lsGroup != null && tmp < lsGroup.size(); tmp++) { + String groupid = (String) lsGroup.get(tmp); + List lsField = hfm.getLsField(groupid); + //if (lsField.size() == 0) continue; + //if (hfm.getGroupCount(lsField) == 0) continue; + //if(!Util.null2String(HrmFieldGroupComInfo.getIsShow(groupid)).equals("1"))continue; + + boolean groupHide = lsField.size() == 0 || hfm.getGroupCount(lsField) == 0 || !Util.null2String(HrmFieldGroupComInfo.getIsShow(groupid)).equals("1"); + String grouplabel = HrmFieldGroupComInfo.getLabel(groupid); + itemlist = new ArrayList(); + groupitem = new HashMap(); + groupitem.put("title", SystemEnv.getHtmlLabelNames(grouplabel, user.getLanguage())); + groupitem.put("hide", groupHide); + groupitem.put("defaultshow", true); + for (int j = 0; lsField != null && j < lsField.size(); j++) { + String fieldid = (String) lsField.get(j); + String fieldname = HrmFieldComInfo.getFieldname(fieldid); + String isuse = HrmFieldComInfo.getIsused(fieldid); + if (!isuse.equals("1"))continue; + int tmpViewattr = viewattr; + String rules = ""; + String fieldlabel = HrmFieldComInfo.getLabel(fieldid); + String fieldhtmltype = HrmFieldComInfo.getFieldhtmltype(fieldid); + String type = HrmFieldComInfo.getFieldType(fieldid); + String dmlurl = Util.null2String(HrmFieldComInfo.getFieldDmlurl(fieldid)); + String fieldValue = ""; + if(addType.length()>0) { + }else { + if (HrmFieldComInfo.getIssystem(fieldid).equals("1")) { + fieldValue = hfm.getData(fieldname); + } else { + fieldValue = hfm.getData("hrmdepartmentdefined", fieldname); + } + } + + if(!groupHide && tmpViewattr==2&&HrmFieldComInfo.getIsmand(fieldid).equals("1")){ + tmpViewattr=3; + if("1".equals(fieldhtmltype) && "2".equals(type)){ + rules = "required|integer"; + }else{ + rules = "required|string"; + } + } + + if(subcompanyid1.length()>0 && fieldname.equals("subcompanyid1")){ + fieldValue = subcompanyid1; + } + + if(supdepid.length()>0 && fieldname.equals("supdepid")){ + fieldValue = supdepid; + } + + if(fieldname.equals("showid")){ + if(addType.length()>0){ + continue; + }else{ + fieldValue = id; + tmpViewattr = 1; + } + } + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldid(fieldid); + hrmFieldBean.setFieldname(fieldname); + hrmFieldBean.setFieldlabel(fieldlabel); + hrmFieldBean.setFieldhtmltype(fieldhtmltype); + hrmFieldBean.setType(type); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setIssystem("1"); + hrmFieldBean.setFieldvalue(fieldValue); + hrmFieldBean.setDmlurl(dmlurl); + hrmFieldBean.setViewAttr(tmpViewattr); + hrmFieldBean.setRules(rules); + if(hrmFieldBean.getFieldname().equals("subcompanyid1")||hrmFieldBean.getFieldname().equals("supdepid")){ + hrmFieldBean.setHideVirtualOrg(true); + } + if(hrmFieldBean.getFieldname().equals("departmentcode")){ + hrmFieldBean.setMultilang(false); + } + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + if(searchConditionItem!=null){ + searchConditionItem.setLabelcol(8); + searchConditionItem.setFieldcol(16); + } + if(fieldname.equals("showorder")){ + searchConditionItem.setPrecision(2); + } + if(fieldname.equals("showid")){ + Map otherParams = new HashMap(); + otherParams.put("hasBorder", true); + searchConditionItem.setOtherParams(otherParams); + } + if("6".equals(fieldhtmltype)){//附件 + Map otherParams1 = new HashMap(); + otherParams1.put("showOrder", false); + searchConditionItem.setOtherParams(otherParams1); + } + itemlist.add(searchConditionItem); + } + groupitem.put("items", itemlist); + grouplist.add(groupitem); + } + retmap.put("status", "1"); + retmap.put("id", id); + retmap.put("titleInfo", HrmOrganizationUtil.getTitleInfo(id, "department", user)); + retmap.put("formField", grouplist); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } +} diff --git a/src/main/java/com/engine/hrm/cmd/organization/GetSubCompanyFormFieldCmd.java b/src/main/java/com/engine/hrm/cmd/organization/GetSubCompanyFormFieldCmd.java new file mode 100644 index 0000000..43e9b5e --- /dev/null +++ b/src/main/java/com/engine/hrm/cmd/organization/GetSubCompanyFormFieldCmd.java @@ -0,0 +1,183 @@ +package com.engine.hrm.cmd.organization; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.definedfield.HrmDeptFieldManager; +import weaver.hrm.definedfield.HrmDeptFieldManagerE9; +import weaver.hrm.definedfield.HrmFieldComInfo; +import weaver.hrm.definedfield.HrmFieldGroupComInfo; +import weaver.systeminfo.SystemEnv; +import com.api.browser.bean.SearchConditionItem; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.hrm.util.HrmOrganizationUtil; + +public class GetSubCompanyFormFieldCmd extends AbstractCommonCommand> { + + public GetSubCompanyFormFieldCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + + Map retmap = new HashMap(); + List> grouplist = new ArrayList>(); + Map groupitem = null; + List itemlist = null; + try { + String id = Util.null2String(params.get("id")); + int viewattr = Util.getIntValue((String)params.get("viewattr"),1); + + String addType = Util.null2String(params.get("addType")); + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + String supsubcomid = ""; + if(addType.equals("sibling")){ + supsubcomid = subCompanyComInfo.getSupsubcomid(id); + }else if(addType.equals("child")){ + supsubcomid = id; + } + if(addType.length()>0){ + id = ""; + } + + HrmFieldGroupComInfo HrmFieldGroupComInfo = new HrmFieldGroupComInfo(); + HrmFieldComInfo HrmFieldComInfo = new HrmFieldComInfo(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + HrmDeptFieldManagerE9 hfm = new HrmDeptFieldManagerE9(4); + hfm.isReturnDecryptData(true); + hfm.getCustomData(Util.getIntValue(id)); + List lsGroup = hfm.getLsGroup(); + for (int tmp = 0; lsGroup != null && tmp < lsGroup.size(); tmp++) { + String groupid = (String) lsGroup.get(tmp); + List lsField = hfm.getLsField(groupid); + //if (lsField.size() == 0) continue; + //if (hfm.getGroupCount(lsField) == 0) continue; + //if(!Util.null2String(HrmFieldGroupComInfo.getIsShow(groupid)).equals("1"))continue; + + boolean groupHide = lsField.size() == 0 || hfm.getGroupCount(lsField) == 0 || !Util.null2String(HrmFieldGroupComInfo.getIsShow(groupid)).equals("1"); + String grouplabel = HrmFieldGroupComInfo.getLabel(groupid); + itemlist = new ArrayList(); + groupitem = new HashMap(); + groupitem.put("title", SystemEnv.getHtmlLabelNames(grouplabel, user.getLanguage())); + groupitem.put("hide", groupHide); + groupitem.put("defaultshow", true); + for (int j = 0; lsField != null && j < lsField.size(); j++) { + String fieldid = (String) lsField.get(j); + String fieldname = HrmFieldComInfo.getFieldname(fieldid); + String isuse = HrmFieldComInfo.getIsused(fieldid); + if (!isuse.equals("1"))continue; + int tmpViewattr = viewattr; + String rules = ""; + String fieldlabel = HrmFieldComInfo.getLabel(fieldid); + String fieldhtmltype = HrmFieldComInfo.getFieldhtmltype(fieldid); + String type = HrmFieldComInfo.getFieldType(fieldid); + String dmlurl = Util.null2String(HrmFieldComInfo.getFieldDmlurl(fieldid)); + String fieldValue = ""; + if(addType.length()>0) { + }else{ + if (HrmFieldComInfo.getIssystem(fieldid).equals("1")) { + fieldValue = hfm.getData(fieldname); + } else { + fieldValue = hfm.getData("hrmsubcompanydefined", fieldname); + } + } + + if(!groupHide && tmpViewattr==2&&HrmFieldComInfo.getIsmand(fieldid).equals("1")){ + tmpViewattr=3; + if("1".equals(fieldhtmltype) && "2".equals(type)){ + rules = "required|integer"; + }else{ + rules = "required|string"; + } + } + + if ("84".equals(fieldid)) { + if (user.getUID() != 1) + continue; + fieldValue = fieldValue.equals("0") ? "" : fieldValue; + } + if(supsubcomid.length()>0 && fieldname.equals("supsubcomid")){ + fieldValue = supsubcomid; + } + + if(fieldname.equals("subshowid")){ + if(addType.length()>0){ + continue; + }else{ + fieldValue = id; + tmpViewattr = 1; + } + } + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldid(fieldid); + hrmFieldBean.setFieldname(fieldname); + hrmFieldBean.setFieldlabel(fieldlabel); + hrmFieldBean.setFieldhtmltype(fieldhtmltype); + hrmFieldBean.setType(type); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setFieldvalue(fieldValue); + hrmFieldBean.setDmlurl(dmlurl); + hrmFieldBean.setViewAttr(tmpViewattr); + hrmFieldBean.setRules(rules); + hrmFieldBean.setIssystem("1"); + if(hrmFieldBean.getFieldname().equals("supsubcomid")){ + hrmFieldBean.setHideVirtualOrg(true); + } + if(hrmFieldBean.getFieldname().equals("subcompanycode")) { + hrmFieldBean.setMultilang(false); + } + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + if(searchConditionItem!=null){ + searchConditionItem.setLabelcol(8); + searchConditionItem.setFieldcol(16); + } + if(hrmFieldBean.getFieldname().equals("showorder")){ + searchConditionItem.setPrecision(2); + } + if(fieldname.equals("subshowid")){ + Map otherParams = new HashMap(); + otherParams.put("hasBorder", true); + searchConditionItem.setOtherParams(otherParams); + } + + if("6".equals(fieldhtmltype)){//附件 + Map otherParams1 = new HashMap(); + otherParams1.put("showOrder", false); + searchConditionItem.setOtherParams(otherParams1); + } + + itemlist.add(searchConditionItem); + } + groupitem.put("items", itemlist); + grouplist.add(groupitem); + } + retmap.put("status", "1"); + retmap.put("id", id); + retmap.put("titleInfo", HrmOrganizationUtil.getTitleInfo(id, "subcompany", user)); + retmap.put("formField", grouplist); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } +} diff --git a/src/main/java/com/engine/hrm/cmd/subcompanyfielddefined/GetFieldDefinedCmd.java b/src/main/java/com/engine/hrm/cmd/subcompanyfielddefined/GetFieldDefinedCmd.java new file mode 100644 index 0000000..e97c23d --- /dev/null +++ b/src/main/java/com/engine/hrm/cmd/subcompanyfielddefined/GetFieldDefinedCmd.java @@ -0,0 +1,310 @@ +package com.engine.hrm.cmd.subcompanyfielddefined; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.cloudstore.dev.api.util.TextUtil; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.EncryptConfigBiz; +import com.engine.common.entity.BizLogContext; +import com.engine.common.entity.EncryptFieldEntity; +import com.engine.common.enums.EncryptMould; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.LabelUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.definedfield.HrmDeptFieldManagerE9; +import weaver.hrm.definedfield.HrmFieldComInfo; +import weaver.matrix.MatrixUtil; +import weaver.systeminfo.SystemEnv; +import weaver.workflow.field.BrowserComInfo; + +/** + * 自定义字段 + * @author lvyi + * + */ + +public class GetFieldDefinedCmd extends AbstractCommonCommand> { + + public GetFieldDefinedCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List> lsFieldInfo = new ArrayList>(); + Map fieldInfo = null; + Map recordInfo = null; + Map propsInfo = null; + Map comInfo = null; + List fieldTypeInfo = null; + List lsComDetialInfo = null; + Map comDetialInfo = null; + try { + if (!HrmUserVarify.checkUserRight("SubCompanyDefineInfo1:SubMaintain1", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + int groupId = Util.getIntValue((String)params.get("groupId")); + boolean encryptEnable = EncryptConfigBiz.getEncryptEnable(EncryptMould.HRM.getCode()); + int scopeId = 4; + BrowserComInfo BrowserComInfo = new BrowserComInfo(); + HrmFieldComInfo HrmFieldComInfo = new HrmFieldComInfo(); + HrmDeptFieldManagerE9 hfm = new HrmDeptFieldManagerE9(scopeId); + List lsGroup = hfm.getLsGroup(); + lsGroup = hfm.getLsGroup(); + int idx = 0; + boolean canDel = false; + for (int i = 0; lsGroup != null && i < lsGroup.size(); i++) { + String groupid = (String) lsGroup.get(i); + List lsField = hfm.getLsField(groupid); + if(!groupid.equals(""+groupId)){ + continue; + } + if (lsField.size() == 0) + continue; + for (int j = 0; lsField != null && j < lsField.size(); j++) { + String fieldid = (String) lsField.get(j); + String issystem = HrmFieldComInfo.getIssystem(fieldid); + String fieldname = HrmFieldComInfo.getFieldname(fieldid); + boolean isUsed = false; + if (issystem.equals("1")) { + isUsed = true; + } else { + isUsed = hfm.getIsUsed(fieldid, fieldname); + } + String fieldlabel = HrmFieldComInfo.getLabel(fieldid); + String fieldfdbtype = HrmFieldComInfo.getFielddbtype(fieldid); + String fieldhtmltype = HrmFieldComInfo.getFieldhtmltype(fieldid); + String fieldtype = HrmFieldComInfo.getFieldType(fieldid); + String fielddmlurl = HrmFieldComInfo.getFieldDmlurl(fieldid); + String fieldstrlength = hfm.getStrLength(fieldfdbtype, fieldhtmltype, fieldtype); + String allowhide = HrmFieldComInfo.getAllowhide(fieldid); + String isUse = HrmFieldComInfo.getIsused(fieldid); + String isMand = HrmFieldComInfo.getIsmand(fieldid); + String dsporder = HrmFieldComInfo.getDsporder(fieldid); + String textheight = ""+HrmFieldComInfo.getTextheight(fieldid); + //判断人力资源类型 字段是否通过矩阵被流程引用 + boolean isUsed_ = false; + if (fieldtype.equals("1") || fieldtype.equals("17")) { + isUsed_ = MatrixUtil.isUsed(fieldname, "1"); + if (isUsed_) + isUsed = isUsed_; + } + + List fieldTypeObj = new ArrayList(); + String fieldType = ""; + if (fieldhtmltype.equals("1")) { + fieldTypeObj.add("input"); + fieldType = SystemEnv.getHtmlLabelName(688, user.getLanguage()); + if (fieldhtmltype.equals("1")) { + if (fieldtype.equals("1")) { + fieldTypeObj.add("text"); + fieldType += " " + SystemEnv.getHtmlLabelName(608, user.getLanguage()); + fieldType += " " + SystemEnv.getHtmlLabelName(608, user.getLanguage()) + ":" + fieldstrlength; + fieldTypeObj.add(fieldstrlength); + } else if (fieldtype.equals("2")) { + fieldTypeObj.add("int"); + fieldType += " " + SystemEnv.getHtmlLabelName(696, user.getLanguage()); + } else if (fieldtype.equals("3")) { + fieldTypeObj.add("float"); + fieldType += " " + SystemEnv.getHtmlLabelName(697, user.getLanguage()); + } + } + } else if (fieldhtmltype.equals("2")) { + fieldTypeObj.add("textarea"); + fieldType = SystemEnv.getHtmlLabelName(689, user.getLanguage()); + //fieldType += " " + SystemEnv.getHtmlLabelName(689, user.getLanguage())+textheight+" "+(fieldtype.equals("1")?"":""); + } else if (fieldhtmltype.equals("3")) { + fieldTypeObj.add("browser"); + List replaceDatas = new ArrayList(); + Map tmp = new HashMap(); + tmp.put("value", fieldtype); + tmp.put("valueSpan", SystemEnv.getHtmlLabelName(Util.getIntValue(BrowserComInfo.getBrowserlabelid(fieldtype), 0), user.getLanguage())); + Map tmp1 = new HashMap(); + tmp1.put("id", fieldtype); + tmp1.put("name", SystemEnv.getHtmlLabelName(Util.getIntValue(BrowserComInfo.getBrowserlabelid(fieldtype), 0), user.getLanguage())); + replaceDatas.add(tmp1); + tmp.put("replaceDatas", replaceDatas); + fieldTypeObj.add(tmp); + + if(fieldtype.equals("161")||fieldtype.equals("162") || fieldtype.equals("256") || fieldtype.equals("257")){ + tmp = new HashMap(); + tmp.put("value", fielddmlurl); + tmp.put("valueSpan", getName(fielddmlurl)); + fieldTypeObj.add(tmp); + } + fieldType = SystemEnv.getHtmlLabelName(695, user.getLanguage()); + fieldType += " " + SystemEnv.getHtmlLabelName(Util.getIntValue(BrowserComInfo.getBrowserlabelid(fieldtype), 0), user.getLanguage()); + if ("emptyVal".equals(fielddmlurl) || "".equals(fielddmlurl)) { + } else { + fieldType += " " + getName(fielddmlurl); + } + } else if (fieldhtmltype.equals("4")) { + fieldTypeObj.add("check"); + fieldType = SystemEnv.getHtmlLabelName(691, user.getLanguage()); + } else if (fieldhtmltype.equals("5")) { + fieldTypeObj.add("select"); + fieldTypeObj.add("select"); + List datas = new ArrayList(); + Map tmp = new HashMap(); + Map data = null; + RecordSet rs = new RecordSet(); + rs.executeSql("select selectvalue, selectname, isdefault, cancel from hrm_selectitem where fieldid=" + fieldid + " order by listorder"); + int key = 0; + while (rs.next()) { + data = new HashMap(); + data.put("option", rs.getString("selectname")); + data.put("default", rs.getString("isdefault")); + data.put("unuse", rs.getString("cancel")); + datas.add(data); + } + tmp.put("datas", datas); + tmp.put("sort", "horizontal"); + fieldTypeObj.add(tmp); + fieldType = SystemEnv.getHtmlLabelName(690, user.getLanguage()); + } else if (fieldhtmltype.equals("6")) { + fieldTypeObj.add("upload"); + fieldTypeObj.add("file"); + fieldType = SystemEnv.getHtmlLabelName(17616, user.getLanguage()); + fieldType += " " + SystemEnv.getHtmlLabelName(20798, user.getLanguage()); + //fieldType += " " + (fieldtype.equals("1") ? SystemEnv.getHtmlLabelName(20798, user.getLanguage()) : SystemEnv.getHtmlLabelName(20001, user.getLanguage())); + } + + fieldInfo = new HashMap(); + recordInfo = new HashMap(); + recordInfo.put("id", fieldid); + recordInfo.put("fieldlabel", TextUtil.toBase64ForMultilang(new LabelUtil().getMultiLangLabel(fieldlabel))); + recordInfo.put("fieldname", fieldname); + recordInfo.put("fieldType", fieldType); + recordInfo.put("fieldTypeObj", fieldTypeObj); + recordInfo.put("enable", isUse); + recordInfo.put("required", isMand); + recordInfo.put("viewAttr", isUsed || issystem.equals("1") ? 1 : 2); + recordInfo.put("key", dsporder); + if (encryptEnable && ((fieldhtmltype.equals("1")||fieldhtmltype.equals("2")) && !issystem.equals("1")) ) { + //只支持单行文本,多行文本 + String tablename = "hrmsubcompanydefined"; + EncryptFieldEntity encryptFieldEntity = EncryptConfigBiz.getFieldEncryptConfig(tablename,fieldname); + recordInfo.put("encryptId", encryptFieldEntity!=null?encryptFieldEntity.getId():""); + recordInfo.put("tablename", tablename); + recordInfo.put("canEncrypt", "1"); + } + fieldInfo.put("record", recordInfo); + + propsInfo = new HashMap(); + Map checkPropsInfo = new HashMap(); + Map checkPropsDetialInfo = null; + checkPropsDetialInfo = new HashMap(); + checkPropsDetialInfo.put("viewAttr", allowhide.equals("1") ? 2 : 1); + checkPropsInfo.put("enable", checkPropsDetialInfo); + checkPropsInfo.put("required", checkPropsDetialInfo); + propsInfo.put("checkProps", checkPropsInfo); + fieldInfo.put("props", propsInfo); + + comInfo = new HashMap(); + + lsComDetialInfo = new ArrayList(); + comDetialInfo = new HashMap(); + comDetialInfo.put("label", ""); + comDetialInfo.put("type", "INPUT"); + comDetialInfo.put("width", "15%"); + comDetialInfo.put("key", "fieldlabel"); + comDetialInfo.put("viewAttr", 3); + lsComDetialInfo.add(comDetialInfo); + comInfo.put("fieldlabel", lsComDetialInfo); + + lsComDetialInfo = new ArrayList(); + comDetialInfo = new HashMap(); + comDetialInfo.put("label", ""); + comDetialInfo.put("type", "TEXT"); + comDetialInfo.put("width", "15%"); + comDetialInfo.put("key", "fieldname"); + comDetialInfo.put("viewAttr", 3); + lsComDetialInfo.add(comDetialInfo); + comInfo.put("fieldname", lsComDetialInfo); + + lsComDetialInfo = new ArrayList(); + comDetialInfo = new HashMap(); + comDetialInfo.put("label", ""); + comDetialInfo.put("type", fieldhtmltype.equals("5") ? "CUSTOMFIELD" : "TEXT"); + comDetialInfo.put("width", "60%"); + comDetialInfo.put("key", "fieldType"); + lsComDetialInfo.add(comDetialInfo); + comInfo.put("fieldType", lsComDetialInfo); + + fieldInfo.put("com", comInfo); + + fieldTypeInfo = new ArrayList(); + fieldTypeInfo.add("select"); + fieldTypeInfo.add("select"); + Map fieldTypeParamInfo = new HashMap(); + List lsFieldTypeParamDetialInfo = new ArrayList(); + Map fieldTypeParamDetialInfo = null; + + if (fieldhtmltype.equals("5")) { + //hfm.getSelectItem(fieldid); + RecordSet rs = new RecordSet(); + rs.executeSql("select selectvalue, selectname, isdefault, cancel from hrm_selectitem where fieldid=" + fieldid + " order by listorder"); + int key = 0; + while (rs.next()) { + fieldTypeParamDetialInfo = new HashMap(); + fieldTypeParamDetialInfo.put("key", key++); + fieldTypeParamDetialInfo.put("id", rs.getString("selectvalue")); + fieldTypeParamDetialInfo.put("option", rs.getString("selectname")); + fieldTypeParamDetialInfo.put("default", rs.getString("isdefault")); + fieldTypeParamDetialInfo.put("unuse", rs.getString("cancel")); + lsFieldTypeParamDetialInfo.add(fieldTypeParamDetialInfo); + } + fieldTypeParamInfo.put("datas", lsFieldTypeParamDetialInfo); + fieldTypeParamInfo.put("sort", "horizontal"); + fieldTypeInfo.add(fieldTypeParamInfo); + fieldInfo.put("fieldType", fieldTypeInfo); + } + lsFieldInfo.add(fieldInfo); + } + } + retmap.put("status", "1"); + retmap.put("data", lsFieldInfo); + retmap.put("encryptEnable",encryptEnable); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return retmap; + } + + private String getName(String showname) { + RecordSet rs = new RecordSet(); + if (showname != null && !"".equals(showname)) { + //兼容老数据,如果id有moduleid,则去掉 + int index = showname.indexOf("."); + if (index > 0) { + showname = showname.substring(index + 1); + } + String sql = "select name from datashowset where showname='" + showname + "'"; + rs.executeSql(sql); + if (rs.next()) { + return Util.null2String(rs.getString("name")); + } + } + return ""; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/main/java/com/engine/hrm/cmd/subcompanyfielddefined/SaveFieldDefinedCmd.java b/src/main/java/com/engine/hrm/cmd/subcompanyfielddefined/SaveFieldDefinedCmd.java new file mode 100644 index 0000000..37b0455 --- /dev/null +++ b/src/main/java/com/engine/hrm/cmd/subcompanyfielddefined/SaveFieldDefinedCmd.java @@ -0,0 +1,211 @@ +package com.engine.hrm.cmd.subcompanyfielddefined; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.hrm.entity.FieldBean; +import com.engine.hrm.entity.FieldSelectOptionBean; +import com.engine.hrm.util.HrmUtil; +import weaver.conn.RecordSet; +import weaver.docs.docs.FieldParam; +import weaver.general.LabelUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.common.database.dialect.DialectUtil; +import weaver.hrm.definedfield.HrmDeptFieldManagerE9; +import weaver.hrm.definedfield.HrmFieldComInfo; +import weaver.matrix.MatrixUtil; +import weaver.systeminfo.SystemEnv; + +/** + * 保存自定义字段 + * @author lvyi + * + */ +public class SaveFieldDefinedCmd extends AbstractCommonCommand>{ + + private SimpleBizLogger logger; + + public SaveFieldDefinedCmd(Map params, User user) { + this.user = user; + this.params = params; + + RecordSet rs = new RecordSet(); + String sql = ""; + String data = Util.null2String(params.get("data")); + JSONObject jsonObj = JSON.parseObject(data); + String groupId = Util.null2String(jsonObj.get("groupId")); + this.logger = new SimpleBizLogger(); + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_SUBCOMPANYFIELDDEFINED);//所属大类型 + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_SUBCOMPANYFIELDDEFINED);//当前小类型 + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + String mainSql = "SELECT a.*, b.labelname FROM hrm_fieldgroup a, htmllabelinfo b WHERE a.grouplabel= b.indexid and a.id= "+groupId+" and b.languageid="+user.getLanguage(); + logger.setMainSql(mainSql,"id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("labelname");//当前targetName对应的列(对应日志中的对象名) + + SimpleBizLogger.SubLogInfo subLogInfo = logger.getNewSubLogInfo(); + String subSql = "SELECT * FROM hrm_formfield WHERE groupid = "+groupId; + subLogInfo.setSubSql(subSql,"fieldid"); + logger.addSubLogInfo(subLogInfo); + logger.before(bizLogContext); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + HrmFieldComInfo HrmFieldComInfo = new HrmFieldComInfo(); + String sql = ""; + try { + if(!HrmUserVarify.checkUserRight("SubCompanyDefineInfo1:SubMaintain1",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + String data = Util.null2String(params.get("data")); + JSONObject jsonObj = JSON.parseObject(data); + String groupId = Util.null2String(jsonObj.get("groupId")); + String groupType = ""; + + sql = "SELECT grouptype FROM hrm_fieldgroup WHERE id="+groupId; + rs.executeSql(sql); + if(rs.next()){ + groupType = rs.getString("groupType"); + } + + List listFieldLabel = new ArrayList(); + List listFieldName = new ArrayList(); + sql = " SELECT fieldlabel FROM hrm_formfield WHERE groupid IN (SELECT id FROM hrm_fieldgroup WHERE grouptype = "+groupType+") and groupid not in("+groupId+")"; + rs.executeQuery(sql); + while(rs.next()){ + listFieldLabel.add(SystemEnv.getHtmlLabelNames(rs.getString("fieldlabel"), user.getLanguage())); + } + + sql = " SELECT fieldname FROM hrm_formfield WHERE groupid IN (SELECT id FROM hrm_fieldgroup WHERE grouptype = "+groupType+") and groupid not in("+groupId+")"; + rs.executeQuery(sql); + while(rs.next()){ + listFieldName.add(rs.getString("fieldname").toLowerCase()); + } + + JSONArray records = (JSONArray)jsonObj.get("records"); + for(int i=0; i(listFieldLabel).size()|| + listFieldName.size() != new HashSet(listFieldName).size()){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(383055, user.getLanguage())); + return retmap; + } + + for(int i=0; i lsSelectOption = fieldBean.getFieldTypeBean().getLsSelectOption(); + hfm.checkSelectField(temId, lsSelectOption); + } + }catch (Exception e) { + writeLog(e); + } + } + + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + +} diff --git a/src/main/java/weaver/bokang/xiao/tbxc/mapper/FormFieldMapper.java b/src/main/java/weaver/bokang/xiao/tbxc/mapper/FormFieldMapper.java new file mode 100644 index 0000000..8b82f66 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/tbxc/mapper/FormFieldMapper.java @@ -0,0 +1,8 @@ +package weaver.bokang.xiao.tbxc.mapper;/** + *@ClassName FormFieldMapper + *@Author 肖博亢 + *@Date 2023/4/26 17:22 + *@Description

+ **/ +public class FormFieldMapper { +} diff --git a/src/main/java/weaver/bokang/xiao/zscq/fun/WorkflowRepossessedSign.java b/src/main/java/weaver/bokang/xiao/zscq/fun/WorkflowRepossessedSign.java new file mode 100644 index 0000000..5e53421 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/zscq/fun/WorkflowRepossessedSign.java @@ -0,0 +1,8 @@ +package weaver.bokang.xiao.zscq.fun;/** + *@ClassName WorkflowRepossessedSign + *@Author 肖博亢 + *@Date 2023/4/24 11:11 + *@Description

+ **/ +public class WorkflowRepossessedSign { +} diff --git a/src/main/resources/ContractList(2).jsp b/src/main/resources/ContractList(2).jsp new file mode 100644 index 0000000..9070046 --- /dev/null +++ b/src/main/resources/ContractList(2).jsp @@ -0,0 +1,499 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<%@ include file="/systeminfo/init_wev8.jsp"%> +<%@ taglib uri="/WEB-INF/weaver.tld" prefix="wea"%> +<%@ taglib uri="/WEB-INF/tld/browser.tld" prefix="brow"%> + +<%@ page import="weaver.file.Prop" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="weaver.systeminfo.SystemEnv" %> + + + + + + + + + + + + + + + +<% + + String sqlwhere = " where 1=1 "; + + String subcompanyid1 = ResourceComInfo.getSubCompanyID(String.valueOf(user.getUID())); + + //是否采购部 + boolean isDep = false; + //是否是流程接收人 + boolean isShow = false; + //采购部的同事可以选择所有合同卡片;而本部门的人员(非采购部)只能选择本部门的合同卡片 + RecordSet_Dep.executeSql("select * from HrmDepartment where departmentname like '%采购%' and id="+user.getUserDepartment()); + if(RecordSet_Dep.next()) isDep = true; + + //是否合同流程接收人 + String sqlwhere_workflow = ""; + RecordSet_Dep.executeSql("select distinct requestId from workflow_currentoperator where workflowid in (79,148,133,128,118,108,98,153,167,316,470,514,532,543,600,717,719,739,832,927,929) and userid="+user.getUID()); + if(RecordSet_Dep.next()) isShow = true; + + if(!HrmUserVarify.checkUserRight("ContactInfo:Manager", user) && !HrmUserVarify.checkUserRight("ContactInfo:User", user) && !isShow && !isDep){ + response.sendRedirect("/notice/noright.jsp"); + } + + //如果是合同管理权限,则直接1=1 + if(HrmUserVarify.checkUserRight("ContactInfo:Manager", user)){ + sqlwhere += " and 1=1"; + }else if(isShow && HrmUserVarify.checkUserRight("ContactInfo:User", user)){ + //如果是流程接收人,并且有合同查看权限 + sqlwhere += " and (requestid in (select distinct requestId from workflow_currentoperator where workflowid in (79,148,133,128,118,108,98,153,167,316,470,514,532,543,600,717,719,739,832,927,929) and userid="+user.getUID()+") or reqDeptId = '"+user.getUserDepartment()+"')"; + + }else if(HrmUserVarify.checkUserRight("ContactInfo:User", user)){ + //如果只有合同查看权限 + sqlwhere += " and reqDeptId = '"+user.getUserDepartment()+"'"; + + }else if(isShow){ + //如果只是流程接收人 + sqlwhere += " and requestid in (select distinct requestId from workflow_currentoperator where workflowid in (79,148,133,128,118,108,98,153,167,316,470,514,532,543,600,717,719,739,832,927,929) and userid="+user.getUID()+")"; + } + + //如果没有查看全部的权限,加分部条件 + if(!HrmUserVarify.checkUserRight("ContactInfoList:ALL", user)){ + if (!subcompanyid1.equals("0")) {sqlwhere += " and CrmContractInfo.subcompanyid1 = '"+subcompanyid1+"' ";} + } + String imagefilename = "/images/hdReport.gif"; + String titlename = SystemEnv.getHtmlLabelName(614, user.getLanguage()) + SystemEnv.getHtmlLabelName(527, user.getLanguage()); + String needfav = "1"; + String needhelp = ""; +%> + + <%@ include file="/systeminfo/TopTitle_wev8.jsp"%> + <%@ include file="/systeminfo/RightClickMenuConent_wev8.jsp"%> + <% + RCMenu += "{" + SystemEnv.getHtmlLabelName(197, user.getLanguage()) + ",javascript:OnSearch(),_top} "; + RCMenuHeight += RCMenuHeightStep; + RCMenu += "{" + "Excel,javascript:ContractExport(),_top} "; + RCMenuHeight += RCMenuHeightStep; + RCMenu += "{" + SystemEnv.getHtmlLabelName(18363, user.getLanguage()) + ",javascript:_table.firstPage(),_self}"; + RCMenuHeight += RCMenuHeightStep; + RCMenu += "{" + SystemEnv.getHtmlLabelName(1258, user.getLanguage()) + ",javascript:_table.prePage(),_self}"; + RCMenuHeight += RCMenuHeightStep; + RCMenu += "{" + SystemEnv.getHtmlLabelName(1259, user.getLanguage()) + ",javascript:_table.nextPage(),_self}"; + RCMenuHeight += RCMenuHeightStep; + RCMenu += "{" + SystemEnv.getHtmlLabelName(18362, user.getLanguage()) + ",javascript:_table.lastPage(),_self}"; + RCMenuHeight += RCMenuHeightStep; + %> + <% + int pagenum = Util.getIntValue(request.getParameter("pagenum"), 1); + int perpage = Util.getPerpageLog(); + if (perpage <= 1) perpage = 10; + + String creator = Util.fromScreen(request.getParameter("creator"), user.getLanguage()); + String fromdate = Util.fromScreen(request.getParameter("fromdate"), user.getLanguage()); + String fromdate2 = Util.fromScreen(request.getParameter("fromdate2"), user.getLanguage()); + String enddate = Util.fromScreen(request.getParameter("enddate"), user.getLanguage()); + String enddate2 = Util.fromScreen(request.getParameter("enddate2"), user.getLanguage()); + String status_temp = Util.null2String(request.getParameter("status_temp")); + + String conNo = Util.fromScreen(request.getParameter("conNo"), user.getLanguage()); + String prNo = Util.fromScreen(request.getParameter("prNo"), user.getLanguage()); + String jpcNo = Util.fromScreen(request.getParameter("jpcNo"), user.getLanguage()); + String suppliersId = Util.fromScreen(request.getParameter("suppliersId"), user.getLanguage()); + String isOneSuppliers = Util.fromScreen(request.getParameter("isOneSuppliers"), user.getLanguage()); +// String reqDeptId = String.valueOf(user.getUserDepartment()); + String reqDeptId = Util.fromScreen(request.getParameter("reqDeptId"), user.getLanguage());; + //管理员组或采购部才能查询所有部门下合同,合同接收人查看接收的合同 +// if(HrmUserVarify.checkUserRight("ContactInfo:Manager", user) || isShow) reqDeptId = Util.fromScreen(request.getParameter("reqDeptId"), user.getLanguage()); + String isOverdue = Util.fromScreen(request.getParameter("isOverdue"), user.getLanguage()); + String status = Util.fromScreen(request.getParameter("status"), user.getLanguage()); + String isOverdueNext = Util.fromScreen(request.getParameter("isOverdueNext"), user.getLanguage()); + String conType = Util.fromScreen(request.getParameter("conType"), user.getLanguage()); + + String name = Util.fromScreen(request.getParameter("name"), user.getLanguage()); + String subCompanyId = Util.fromScreen(request.getParameter("subCompanyId"), user.getLanguage()); + String reNewStatus = Util.fromScreen(request.getParameter("reNewStatus"), user.getLanguage()); + String conStatus = Util.fromScreen(request.getParameter("conStatus"), user.getLanguage()); + String contractName = Util.fromScreen(request.getParameter("contractName"), user.getLanguage()); + String csstatus = Util.fromScreen(request.getParameter("csstatus"), user.getLanguage()); + + int opentype = Util.getIntValue(request.getParameter("opentype"),-1); + + //String sqlwhere = " where status = '' "; + //if(!"".equals(status_temp)) sqlwhere += " and status in ("+status_temp+") "; + + if (!fromdate.equals("")) sqlwhere += " and startDate>='" + fromdate + "'"; + if (!fromdate2.equals("")) sqlwhere += " and startDate<='" + fromdate2 + "'"; + if (!enddate.equals("")) sqlwhere += " and enddate>='" + enddate + "'"; + if (!enddate2.equals("")) sqlwhere += " and enddate<='" + enddate2 + "'"; + if (!conNo.equals("")) sqlwhere += " and conNo like '%" + conNo + "%'"; + if (!prNo.equals("")) sqlwhere += " and prNo='" + prNo + "'"; + if (!jpcNo.equals("")) sqlwhere += " and jpcNo='" + jpcNo + "'"; + if(!"".equals(suppliersId)) sqlwhere += " and suppliersId=" + suppliersId; + if (!isOneSuppliers.equals("")) sqlwhere += " and isOneSuppliers='" + isOneSuppliers + "'"; + if (!"".equals(creator) && !"0".equals(creator)) sqlwhere += " and CrmContractInfo.creator=" + creator; + if (!reqDeptId.equals("")) sqlwhere += " and reqDeptId=" + reqDeptId; + if (!isOverdue.equals("")) sqlwhere += " and isOverdue='" + isOverdue + "'"; + if (!status.equals("")) sqlwhere += " and CrmContractInfo.status='" + status + "'"; + if (!isOverdueNext.equals("")) sqlwhere += " and isOverdueNext='" + isOverdueNext + "'"; + if (!conType.equals("")) sqlwhere += " and conType='" + conType + "'"; + if (!csstatus.equals("")) sqlwhere += " and CrmSalesContractInfo.status='" + csstatus + "'"; + + if (!name.equals("")) sqlwhere += " and name like '%" + name + "%'"; + if (!subCompanyId.equals("")) sqlwhere += " and CrmContractInfo.subcompanyid1 = '" + subCompanyId + "'"; + if (!reNewStatus.equals("")) sqlwhere += " and conStatus = '" + reNewStatus + "'"; + + if (!contractName.equals("")) sqlwhere += " and contractName like '%" + contractName + "%'"; + + //if (reNewStatus2.equals("待续签")) sqlwhere += " and dbo.getReNewStatus2(2,CrmContractInfo.saleContract) > 0"; + //else if (reNewStatus2.equals("已续签")) sqlwhere += " and dbo.getReNewStatus2(1,CrmContractInfo.saleContract) > 0"; + //else if (reNewStatus2.equals("无需续签")) sqlwhere += " and dbo.getReNewStatus2(3,CrmContractInfo.saleContract) > 0"; + //System.out.println("sqlwhere:"+sqlwhere); + + + if(opentype > -1){ + sqlwhere += " and isnull(CrmContractInfo.opentype,0) = " + opentype; + } + + String orderStr = " order by startDate desc, CrmContractInfo.id desc "; + +// out.println("sqlwhere:" + sqlwhere); +// out.println("orderStr:" + orderStr); + +// session.setAttribute("sqlwhere", sqlwhere); +// session.setAttribute("orderStr", orderStr); + %> +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%if(HrmUserVarify.checkUserRight("ContactInfoList:ALL", user)){%> + + + <%}%> + + + + + + + + + + + + + + + + +
<%=SystemEnv.getHtmlLabelName(15774, user.getLanguage())%>
合同状态 + + <%=SystemEnv.getHtmlLabelName(1970, user.getLanguage())%> +   + <%=Util.toScreen(fromdate, user.getLanguage())%> -  +   + <%=Util.toScreen(fromdate2, user.getLanguage())%> + > + > + <%=SystemEnv.getHtmlLabelName(15236, user.getLanguage())%> +   + <%=Util.toScreen(enddate, user.getLanguage())%> -  +   + <%=Util.toScreen(enddate2, user.getLanguage())%> + > + > +
<%=SystemEnv.getHtmlLabelName(21282, user.getLanguage())%> + + PR<%=SystemEnv.getHtmlLabelName(403,user.getLanguage())%> + + JPC<%=SystemEnv.getHtmlLabelName(2171,user.getLanguage())%><%=SystemEnv.getHtmlLabelName(16992,user.getLanguage())%> + +
<%=SystemEnv.getHtmlLabelName(613002, user.getLanguage())%> + + + + + <%=SystemEnv.getHtmlLabelName(913, user.getLanguage())%> + + +
<%=SystemEnv.getHtmlLabelName(620002, user.getLanguage())%> + + + + +<%-- <%--%> +<%-- //管理员组才能查询所有部门下合同--%> +<%-- if(HrmUserVarify.checkUserRight("ContactInfo:Manager", user)){--%> +<%-- %>--%> +<%-- +<%-- id="reqDeptId"--%> +<%-- name="reqDeptId"--%> +<%-- browserValue="<%=reqDeptId %>"--%> +<%-- browserUrl="/systeminfo/BrowserMain.jsp?url=/hrm/company/DepartmentBrowser.jsp"--%> +<%-- hasInput="true"--%> +<%-- isSingle="true"--%> +<%-- hasBrowser = "true"--%> +<%-- isMustInput='1'--%> +<%-- width="165px"--%> +<%-- browserSpanValue="<%=Util.toScreen(DepartmentComInfo.getDepartmentname(reqDeptId),user.getLanguage())%>">--%> +<%-- --%> + +<%-- <%––%>--%> +<%-- <%}else{ %>--%> +<%-- <%=Util.toScreen(DepartmentComInfo.getDepartmentname(reqDeptId),user.getLanguage()) %>--%> +<%-- <%} %>--%> + 付款状态 + + <%=SystemEnv.getHtmlLabelName(620017, user.getLanguage())%> + +
<%=SystemEnv.getHtmlLabelName(15775, user.getLanguage())%> + + <%=SystemEnv.getHtmlLabelName(15142, user.getLanguage())%> + + <%=SystemEnv.getHtmlLabelName(141,user.getLanguage())%>: + + + "> + + + + <%-- + <%--_url="/systeminfo/BrowserMain.jsp?url=/hrm/company/SubcompanyBrowser.jsp"--%> + <%--_displayText="<%=SubCompanyComInfo.getSubCompanyname(subCompanyId+"")%>"--%> + <%-->--%> +
<%=SystemEnv.getHtmlLabelName(16404, user.getLanguage())%><%=SystemEnv.getHtmlLabelName(195, user.getLanguage())%> + + 销售合同状态 + + 开闭口类型 + +
+ +
+ +
+ + + + +
+ <% + + String tableString = ""; + String backfields = " CrmContractInfo.id,case CrmContractInfo.opentype when '0' then '闭口' when '1' then '开口' when '2' then '周期性' end opentype, reqDeptId, suppliersId, conNo, name, startDate, endDate, case isOverdue when 'Y' then '是' else '否' end as isOverdue, conAmount, content, ',' as str_temp, case isOverdueNext when 'Y' then '是' else '否' end as isOverdueNext, case CrmContractInfo.status when '0' then '执行中' when '1' then '已结清' end as status, CrmContractInfo.creator, CrmContractInfo.subcompanyid1, case conStatus when '0' then '执行' when '1' then '待续签' when '2' then '已续签' when '3' then '关闭' end as reNewStatus, contractName, saleContract, case when dbo.getReNewStatus2(1,CrmContractInfo.saleContract) > 0 then '已续签' when dbo.getReNewStatus2(2,CrmContractInfo.saleContract) > 0 then '待续签' when dbo.getReNewStatus2(3,CrmContractInfo.saleContract) > 0 then '无需续签' end as reNewStatus2,case CrmSalesContractInfo.status when '0' then '已签署' when '1' then '未签署' when '2' then '已续签' when '3' then '关闭' end as csstatus "; + String fromSql = " CrmContractInfo Left Join CrmSalesContractInfo On CrmSalesContractInfo.id=CrmContractInfo.saleContract "; + //out.print("select"+backfields+"from"+fromSql +sqlwhere); + String str_content = "content"+"str_temp"; + tableString = " " + "" + ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + //tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + //tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += "
"; + %> + + +
+
+ <%@ include file="/systeminfo/RightClickMenu_wev8.jsp"%> + + + + + + + \ No newline at end of file diff --git a/src/main/resources/ContractReportExport(1).jsp b/src/main/resources/ContractReportExport(1).jsp new file mode 100644 index 0000000..2590773 --- /dev/null +++ b/src/main/resources/ContractReportExport(1).jsp @@ -0,0 +1,127 @@ +<%@ page language="java" contentType="text/html; charset=GBK" %> +<%@ include file="/systeminfo/init.jsp" %> +<%@ page import="weaver.general.Util, weaver.file.ExcelSheet, weaver.file.ExcelRow" %> + + + + + + + + + + +<%! + public static String ToDBC(String input) { + char[] c = input.toCharArray(); + for (int i = 0; i < c.length; i++) { + if (c[i] == 12288) { + //ȫǿոΪ12288ǿոΪ32 + c[i] = (char) 32; + continue; + } + if (c[i] > 65280 && c[i] < 65375) + //ַ(33-126)ȫ(65281-65374)ĶӦϵǣ65248 + c[i] = (char) (c[i] - 65248); + } + return new String(c); + } + + +%> + +<% + // String sqlwhere=(String)session.getAttribute("sqlwhere"); +// String orderStr=(String)session.getAttribute("orderStr"); + + String sqlwhere = request.getParameter("sqlwhere"); + sqlwhere = ToDBC(sqlwhere); + String orderStr = request.getParameter("orderStr"); + orderStr = ToDBC(orderStr); + + String sqlstr = ""; + + if (RecordSet.getDBType().equals("oracle")) { + sqlstr = "select CrmContractInfo.id, reqDeptId, suppliersId, conNo, name, startDate, endDate, case isOverdue when 'Y' then '' else '' end as isOverdue, conAmount, content, case isOverdueNext when 'Y' then '' else '' end as isOverdueNext, case CrmContractInfo.status when '0' then 'ִ' when '1' then 'ѽ' end as status, case isOneSuppliers when 'Y' then '' when 'N' then '' else '' end as isOneSuppliers, prRequestId,jpcNo,jpcFile,prNo,prAmount,prAmountSum,conAmount,managerId,subject,giveDate,giveRemark,payRemark,content,CrmContractInfo.createDate,CrmContractInfo.creator,CrmContractInfo.subcompanyid1, case conStatus when '0' then 'ִ' when '1' then 'ǩ' when '2' then 'ǩ' when '3' then 'ر' end as reNewStatus,contractName, saleContract, case CrmSalesContractInfo.status when '0' then 'ǩ' when '1' then 'δǩ' when '2' then 'ǩ' when '3' then 'ر' end as reNewStatus2 from CrmContractInfo Left Join CrmSalesContractInfo On CrmSalesContractInfo.id=CrmContractInfo.saleContract" + sqlwhere + orderStr; + } else { + sqlstr = "select CrmContractInfo.id, reqDeptId, suppliersId, conNo, name, startDate, endDate, case isOverdue when 'Y' then '' else '' end as isOverdue, conAmount, content, case isOverdueNext when 'Y' then '' else '' end as isOverdueNext, case CrmContractInfo.status when '0' then 'ִ' when '1' then 'ѽ' end as status, case isOneSuppliers when 'Y' then '' when 'N' then '' else '' end as isOneSuppliers, prRequestId,jpcNo,jpcFile,prNo,prAmount,prAmountSum,conAmount,managerId,subject,giveDate,giveRemark,payRemark,content,CrmContractInfo.createDate,CrmContractInfo.creator,CrmContractInfo.subcompanyid1, case conStatus when '0' then 'ִ' when '1' then 'ǩ' when '2' then 'ǩ' when '3' then 'ر' end as reNewStatus,contractName, saleContract, case CrmSalesContractInfo.status when '0' then 'ǩ' when '1' then 'δǩ' when '2' then 'ǩ' when '3' then 'ر' end as reNewStatus2 from CrmContractInfo Left Join CrmSalesContractInfo On CrmSalesContractInfo.id=CrmContractInfo.saleContract" + sqlwhere + orderStr; + } + new BaseBean().writeLog(">>>>>>>>"+sqlstr); + RecordSet.executeQuery(sqlstr); + + ExcelSheet es = new ExcelSheet(); + + ExcelRow er = es.newExcelRow(); + er.addStringValue(SystemEnv.getHtmlLabelName(141,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620002,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(613002,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(21282,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(15142,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(1970,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(15236,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620016,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(6146,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620015,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620017,user.getLanguage())); + er.addStringValue("״̬"); + er.addStringValue(SystemEnv.getHtmlLabelName(913,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620009,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620003,user.getLanguage())); + er.addStringValue("JPC"+SystemEnv.getHtmlLabelName(16992,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620004,user.getLanguage())); + er.addStringValue("PR"+SystemEnv.getHtmlLabelName(403,user.getLanguage())); + er.addStringValue("PR"+SystemEnv.getHtmlLabelName(856,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620010,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620011,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620006,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620012,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620013,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620014,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620015,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(614,user.getLanguage())+SystemEnv.getHtmlLabelName(722,user.getLanguage())); + er.addStringValue("ͬ״̬"); + er.addStringValue("ۺͬ"); + er.addStringValue("ۺͬ״̬"); + + while (RecordSet.next()) { + ExcelRow erdetail = es.newExcelRow(); + erdetail.addStringValue(SubCompanyComInfo.getSubCompanyname(RecordSet.getString("subcompanyid1"))); + erdetail.addStringValue(DepartmentComInfo.getDepartmentname(RecordSet.getString("reqDeptId"))); + erdetail.addStringValue(CrmSupplierComInfo.getSuppliername(RecordSet.getString("suppliersId"))); + erdetail.addStringValue(RecordSet.getString("conNo")); + erdetail.addStringValue(RecordSet.getString("name")); + erdetail.addStringValue(RecordSet.getString("startDate")); + erdetail.addStringValue(RecordSet.getString("endDate")); + erdetail.addStringValue(RecordSet.getString("isOverdue")); + erdetail.addStringValue(RecordSet.getString("conAmount")); + erdetail.addStringValue(Util.toScreen(SptmForDoc.getDocName(RecordSet.getString("content")), user.getLanguage())); + erdetail.addStringValue(RecordSet.getString("isOverdueNext")); + erdetail.addStringValue(RecordSet.getString("status")); + erdetail.addStringValue(Util.toScreen(ResourceComInfo.getResourcename(RecordSet.getString("creator")), user.getLanguage())); + erdetail.addStringValue(RecordSet.getString("isOneSuppliers")); + erdetail.addStringValue(RequestComInfo.getRequestname(RecordSet.getString("prRequestId"))); + erdetail.addStringValue(RecordSet.getString("jpcNo")); + erdetail.addStringValue(DocComInfo.getDocname(RecordSet.getString("jpcFile"))); + erdetail.addStringValue(RecordSet.getString("prNo")); + erdetail.addStringValue(RecordSet.getString("prAmount")); + erdetail.addStringValue(RecordSet.getString("prAmountSum")); + erdetail.addStringValue(ResourceComInfo.getResourcename(RecordSet.getString("managerId"))); + erdetail.addStringValue(RecordSet.getString("subject")); + erdetail.addStringValue(RecordSet.getString("giveDate")); + erdetail.addStringValue(RecordSet.getString("giveRemark")); + erdetail.addStringValue(RecordSet.getString("payRemark")); + erdetail.addStringValue(DocComInfo.getDocname(RecordSet.getString("content"))); + erdetail.addStringValue(RecordSet.getString("createDate")); + erdetail.addStringValue(RecordSet.getString("reNewStatus")); + erdetail.addStringValue(RecordSet.getString("contractName")); + erdetail.addStringValue(RecordSet.getString("reNewStatus2")); + } + + ExcelFile.init(); + ExcelFile.setFilename("ͬ"); + ExcelFile.addSheet("ͬ", es); +%> + +<%----%> \ No newline at end of file diff --git a/src/main/resources/ajzx/ContractList.jsp b/src/main/resources/ajzx/ContractList.jsp new file mode 100644 index 0000000..9070046 --- /dev/null +++ b/src/main/resources/ajzx/ContractList.jsp @@ -0,0 +1,499 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<%@ include file="/systeminfo/init_wev8.jsp"%> +<%@ taglib uri="/WEB-INF/weaver.tld" prefix="wea"%> +<%@ taglib uri="/WEB-INF/tld/browser.tld" prefix="brow"%> + +<%@ page import="weaver.file.Prop" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="weaver.systeminfo.SystemEnv" %> + + + + + + + + + + + + + + + +<% + + String sqlwhere = " where 1=1 "; + + String subcompanyid1 = ResourceComInfo.getSubCompanyID(String.valueOf(user.getUID())); + + //是否采购部 + boolean isDep = false; + //是否是流程接收人 + boolean isShow = false; + //采购部的同事可以选择所有合同卡片;而本部门的人员(非采购部)只能选择本部门的合同卡片 + RecordSet_Dep.executeSql("select * from HrmDepartment where departmentname like '%采购%' and id="+user.getUserDepartment()); + if(RecordSet_Dep.next()) isDep = true; + + //是否合同流程接收人 + String sqlwhere_workflow = ""; + RecordSet_Dep.executeSql("select distinct requestId from workflow_currentoperator where workflowid in (79,148,133,128,118,108,98,153,167,316,470,514,532,543,600,717,719,739,832,927,929) and userid="+user.getUID()); + if(RecordSet_Dep.next()) isShow = true; + + if(!HrmUserVarify.checkUserRight("ContactInfo:Manager", user) && !HrmUserVarify.checkUserRight("ContactInfo:User", user) && !isShow && !isDep){ + response.sendRedirect("/notice/noright.jsp"); + } + + //如果是合同管理权限,则直接1=1 + if(HrmUserVarify.checkUserRight("ContactInfo:Manager", user)){ + sqlwhere += " and 1=1"; + }else if(isShow && HrmUserVarify.checkUserRight("ContactInfo:User", user)){ + //如果是流程接收人,并且有合同查看权限 + sqlwhere += " and (requestid in (select distinct requestId from workflow_currentoperator where workflowid in (79,148,133,128,118,108,98,153,167,316,470,514,532,543,600,717,719,739,832,927,929) and userid="+user.getUID()+") or reqDeptId = '"+user.getUserDepartment()+"')"; + + }else if(HrmUserVarify.checkUserRight("ContactInfo:User", user)){ + //如果只有合同查看权限 + sqlwhere += " and reqDeptId = '"+user.getUserDepartment()+"'"; + + }else if(isShow){ + //如果只是流程接收人 + sqlwhere += " and requestid in (select distinct requestId from workflow_currentoperator where workflowid in (79,148,133,128,118,108,98,153,167,316,470,514,532,543,600,717,719,739,832,927,929) and userid="+user.getUID()+")"; + } + + //如果没有查看全部的权限,加分部条件 + if(!HrmUserVarify.checkUserRight("ContactInfoList:ALL", user)){ + if (!subcompanyid1.equals("0")) {sqlwhere += " and CrmContractInfo.subcompanyid1 = '"+subcompanyid1+"' ";} + } + String imagefilename = "/images/hdReport.gif"; + String titlename = SystemEnv.getHtmlLabelName(614, user.getLanguage()) + SystemEnv.getHtmlLabelName(527, user.getLanguage()); + String needfav = "1"; + String needhelp = ""; +%> + + <%@ include file="/systeminfo/TopTitle_wev8.jsp"%> + <%@ include file="/systeminfo/RightClickMenuConent_wev8.jsp"%> + <% + RCMenu += "{" + SystemEnv.getHtmlLabelName(197, user.getLanguage()) + ",javascript:OnSearch(),_top} "; + RCMenuHeight += RCMenuHeightStep; + RCMenu += "{" + "Excel,javascript:ContractExport(),_top} "; + RCMenuHeight += RCMenuHeightStep; + RCMenu += "{" + SystemEnv.getHtmlLabelName(18363, user.getLanguage()) + ",javascript:_table.firstPage(),_self}"; + RCMenuHeight += RCMenuHeightStep; + RCMenu += "{" + SystemEnv.getHtmlLabelName(1258, user.getLanguage()) + ",javascript:_table.prePage(),_self}"; + RCMenuHeight += RCMenuHeightStep; + RCMenu += "{" + SystemEnv.getHtmlLabelName(1259, user.getLanguage()) + ",javascript:_table.nextPage(),_self}"; + RCMenuHeight += RCMenuHeightStep; + RCMenu += "{" + SystemEnv.getHtmlLabelName(18362, user.getLanguage()) + ",javascript:_table.lastPage(),_self}"; + RCMenuHeight += RCMenuHeightStep; + %> + <% + int pagenum = Util.getIntValue(request.getParameter("pagenum"), 1); + int perpage = Util.getPerpageLog(); + if (perpage <= 1) perpage = 10; + + String creator = Util.fromScreen(request.getParameter("creator"), user.getLanguage()); + String fromdate = Util.fromScreen(request.getParameter("fromdate"), user.getLanguage()); + String fromdate2 = Util.fromScreen(request.getParameter("fromdate2"), user.getLanguage()); + String enddate = Util.fromScreen(request.getParameter("enddate"), user.getLanguage()); + String enddate2 = Util.fromScreen(request.getParameter("enddate2"), user.getLanguage()); + String status_temp = Util.null2String(request.getParameter("status_temp")); + + String conNo = Util.fromScreen(request.getParameter("conNo"), user.getLanguage()); + String prNo = Util.fromScreen(request.getParameter("prNo"), user.getLanguage()); + String jpcNo = Util.fromScreen(request.getParameter("jpcNo"), user.getLanguage()); + String suppliersId = Util.fromScreen(request.getParameter("suppliersId"), user.getLanguage()); + String isOneSuppliers = Util.fromScreen(request.getParameter("isOneSuppliers"), user.getLanguage()); +// String reqDeptId = String.valueOf(user.getUserDepartment()); + String reqDeptId = Util.fromScreen(request.getParameter("reqDeptId"), user.getLanguage());; + //管理员组或采购部才能查询所有部门下合同,合同接收人查看接收的合同 +// if(HrmUserVarify.checkUserRight("ContactInfo:Manager", user) || isShow) reqDeptId = Util.fromScreen(request.getParameter("reqDeptId"), user.getLanguage()); + String isOverdue = Util.fromScreen(request.getParameter("isOverdue"), user.getLanguage()); + String status = Util.fromScreen(request.getParameter("status"), user.getLanguage()); + String isOverdueNext = Util.fromScreen(request.getParameter("isOverdueNext"), user.getLanguage()); + String conType = Util.fromScreen(request.getParameter("conType"), user.getLanguage()); + + String name = Util.fromScreen(request.getParameter("name"), user.getLanguage()); + String subCompanyId = Util.fromScreen(request.getParameter("subCompanyId"), user.getLanguage()); + String reNewStatus = Util.fromScreen(request.getParameter("reNewStatus"), user.getLanguage()); + String conStatus = Util.fromScreen(request.getParameter("conStatus"), user.getLanguage()); + String contractName = Util.fromScreen(request.getParameter("contractName"), user.getLanguage()); + String csstatus = Util.fromScreen(request.getParameter("csstatus"), user.getLanguage()); + + int opentype = Util.getIntValue(request.getParameter("opentype"),-1); + + //String sqlwhere = " where status = '' "; + //if(!"".equals(status_temp)) sqlwhere += " and status in ("+status_temp+") "; + + if (!fromdate.equals("")) sqlwhere += " and startDate>='" + fromdate + "'"; + if (!fromdate2.equals("")) sqlwhere += " and startDate<='" + fromdate2 + "'"; + if (!enddate.equals("")) sqlwhere += " and enddate>='" + enddate + "'"; + if (!enddate2.equals("")) sqlwhere += " and enddate<='" + enddate2 + "'"; + if (!conNo.equals("")) sqlwhere += " and conNo like '%" + conNo + "%'"; + if (!prNo.equals("")) sqlwhere += " and prNo='" + prNo + "'"; + if (!jpcNo.equals("")) sqlwhere += " and jpcNo='" + jpcNo + "'"; + if(!"".equals(suppliersId)) sqlwhere += " and suppliersId=" + suppliersId; + if (!isOneSuppliers.equals("")) sqlwhere += " and isOneSuppliers='" + isOneSuppliers + "'"; + if (!"".equals(creator) && !"0".equals(creator)) sqlwhere += " and CrmContractInfo.creator=" + creator; + if (!reqDeptId.equals("")) sqlwhere += " and reqDeptId=" + reqDeptId; + if (!isOverdue.equals("")) sqlwhere += " and isOverdue='" + isOverdue + "'"; + if (!status.equals("")) sqlwhere += " and CrmContractInfo.status='" + status + "'"; + if (!isOverdueNext.equals("")) sqlwhere += " and isOverdueNext='" + isOverdueNext + "'"; + if (!conType.equals("")) sqlwhere += " and conType='" + conType + "'"; + if (!csstatus.equals("")) sqlwhere += " and CrmSalesContractInfo.status='" + csstatus + "'"; + + if (!name.equals("")) sqlwhere += " and name like '%" + name + "%'"; + if (!subCompanyId.equals("")) sqlwhere += " and CrmContractInfo.subcompanyid1 = '" + subCompanyId + "'"; + if (!reNewStatus.equals("")) sqlwhere += " and conStatus = '" + reNewStatus + "'"; + + if (!contractName.equals("")) sqlwhere += " and contractName like '%" + contractName + "%'"; + + //if (reNewStatus2.equals("待续签")) sqlwhere += " and dbo.getReNewStatus2(2,CrmContractInfo.saleContract) > 0"; + //else if (reNewStatus2.equals("已续签")) sqlwhere += " and dbo.getReNewStatus2(1,CrmContractInfo.saleContract) > 0"; + //else if (reNewStatus2.equals("无需续签")) sqlwhere += " and dbo.getReNewStatus2(3,CrmContractInfo.saleContract) > 0"; + //System.out.println("sqlwhere:"+sqlwhere); + + + if(opentype > -1){ + sqlwhere += " and isnull(CrmContractInfo.opentype,0) = " + opentype; + } + + String orderStr = " order by startDate desc, CrmContractInfo.id desc "; + +// out.println("sqlwhere:" + sqlwhere); +// out.println("orderStr:" + orderStr); + +// session.setAttribute("sqlwhere", sqlwhere); +// session.setAttribute("orderStr", orderStr); + %> +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%if(HrmUserVarify.checkUserRight("ContactInfoList:ALL", user)){%> + + + <%}%> + + + + + + + + + + + + + + + + +
<%=SystemEnv.getHtmlLabelName(15774, user.getLanguage())%>
合同状态 + + <%=SystemEnv.getHtmlLabelName(1970, user.getLanguage())%> +   + <%=Util.toScreen(fromdate, user.getLanguage())%> -  +   + <%=Util.toScreen(fromdate2, user.getLanguage())%> + > + > + <%=SystemEnv.getHtmlLabelName(15236, user.getLanguage())%> +   + <%=Util.toScreen(enddate, user.getLanguage())%> -  +   + <%=Util.toScreen(enddate2, user.getLanguage())%> + > + > +
<%=SystemEnv.getHtmlLabelName(21282, user.getLanguage())%> + + PR<%=SystemEnv.getHtmlLabelName(403,user.getLanguage())%> + + JPC<%=SystemEnv.getHtmlLabelName(2171,user.getLanguage())%><%=SystemEnv.getHtmlLabelName(16992,user.getLanguage())%> + +
<%=SystemEnv.getHtmlLabelName(613002, user.getLanguage())%> + + + + + <%=SystemEnv.getHtmlLabelName(913, user.getLanguage())%> + + +
<%=SystemEnv.getHtmlLabelName(620002, user.getLanguage())%> + + + + +<%-- <%--%> +<%-- //管理员组才能查询所有部门下合同--%> +<%-- if(HrmUserVarify.checkUserRight("ContactInfo:Manager", user)){--%> +<%-- %>--%> +<%-- +<%-- id="reqDeptId"--%> +<%-- name="reqDeptId"--%> +<%-- browserValue="<%=reqDeptId %>"--%> +<%-- browserUrl="/systeminfo/BrowserMain.jsp?url=/hrm/company/DepartmentBrowser.jsp"--%> +<%-- hasInput="true"--%> +<%-- isSingle="true"--%> +<%-- hasBrowser = "true"--%> +<%-- isMustInput='1'--%> +<%-- width="165px"--%> +<%-- browserSpanValue="<%=Util.toScreen(DepartmentComInfo.getDepartmentname(reqDeptId),user.getLanguage())%>">--%> +<%-- --%> + +<%-- <%––%>--%> +<%-- <%}else{ %>--%> +<%-- <%=Util.toScreen(DepartmentComInfo.getDepartmentname(reqDeptId),user.getLanguage()) %>--%> +<%-- <%} %>--%> + 付款状态 + + <%=SystemEnv.getHtmlLabelName(620017, user.getLanguage())%> + +
<%=SystemEnv.getHtmlLabelName(15775, user.getLanguage())%> + + <%=SystemEnv.getHtmlLabelName(15142, user.getLanguage())%> + + <%=SystemEnv.getHtmlLabelName(141,user.getLanguage())%>: + + + "> + + + + <%-- + <%--_url="/systeminfo/BrowserMain.jsp?url=/hrm/company/SubcompanyBrowser.jsp"--%> + <%--_displayText="<%=SubCompanyComInfo.getSubCompanyname(subCompanyId+"")%>"--%> + <%-->--%> +
<%=SystemEnv.getHtmlLabelName(16404, user.getLanguage())%><%=SystemEnv.getHtmlLabelName(195, user.getLanguage())%> + + 销售合同状态 + + 开闭口类型 + +
+ +
+ +
+ + + + +
+ <% + + String tableString = ""; + String backfields = " CrmContractInfo.id,case CrmContractInfo.opentype when '0' then '闭口' when '1' then '开口' when '2' then '周期性' end opentype, reqDeptId, suppliersId, conNo, name, startDate, endDate, case isOverdue when 'Y' then '是' else '否' end as isOverdue, conAmount, content, ',' as str_temp, case isOverdueNext when 'Y' then '是' else '否' end as isOverdueNext, case CrmContractInfo.status when '0' then '执行中' when '1' then '已结清' end as status, CrmContractInfo.creator, CrmContractInfo.subcompanyid1, case conStatus when '0' then '执行' when '1' then '待续签' when '2' then '已续签' when '3' then '关闭' end as reNewStatus, contractName, saleContract, case when dbo.getReNewStatus2(1,CrmContractInfo.saleContract) > 0 then '已续签' when dbo.getReNewStatus2(2,CrmContractInfo.saleContract) > 0 then '待续签' when dbo.getReNewStatus2(3,CrmContractInfo.saleContract) > 0 then '无需续签' end as reNewStatus2,case CrmSalesContractInfo.status when '0' then '已签署' when '1' then '未签署' when '2' then '已续签' when '3' then '关闭' end as csstatus "; + String fromSql = " CrmContractInfo Left Join CrmSalesContractInfo On CrmSalesContractInfo.id=CrmContractInfo.saleContract "; + //out.print("select"+backfields+"from"+fromSql +sqlwhere); + String str_content = "content"+"str_temp"; + tableString = " " + "" + ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + //tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + //tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += "
"; + %> + + +
+
+ <%@ include file="/systeminfo/RightClickMenu_wev8.jsp"%> + + + + + + + \ No newline at end of file diff --git a/src/main/resources/ajzx/ContractReportExport.jsp b/src/main/resources/ajzx/ContractReportExport.jsp new file mode 100644 index 0000000..2590773 --- /dev/null +++ b/src/main/resources/ajzx/ContractReportExport.jsp @@ -0,0 +1,127 @@ +<%@ page language="java" contentType="text/html; charset=GBK" %> +<%@ include file="/systeminfo/init.jsp" %> +<%@ page import="weaver.general.Util, weaver.file.ExcelSheet, weaver.file.ExcelRow" %> + + + + + + + + + + +<%! + public static String ToDBC(String input) { + char[] c = input.toCharArray(); + for (int i = 0; i < c.length; i++) { + if (c[i] == 12288) { + //ȫǿոΪ12288ǿոΪ32 + c[i] = (char) 32; + continue; + } + if (c[i] > 65280 && c[i] < 65375) + //ַ(33-126)ȫ(65281-65374)ĶӦϵǣ65248 + c[i] = (char) (c[i] - 65248); + } + return new String(c); + } + + +%> + +<% + // String sqlwhere=(String)session.getAttribute("sqlwhere"); +// String orderStr=(String)session.getAttribute("orderStr"); + + String sqlwhere = request.getParameter("sqlwhere"); + sqlwhere = ToDBC(sqlwhere); + String orderStr = request.getParameter("orderStr"); + orderStr = ToDBC(orderStr); + + String sqlstr = ""; + + if (RecordSet.getDBType().equals("oracle")) { + sqlstr = "select CrmContractInfo.id, reqDeptId, suppliersId, conNo, name, startDate, endDate, case isOverdue when 'Y' then '' else '' end as isOverdue, conAmount, content, case isOverdueNext when 'Y' then '' else '' end as isOverdueNext, case CrmContractInfo.status when '0' then 'ִ' when '1' then 'ѽ' end as status, case isOneSuppliers when 'Y' then '' when 'N' then '' else '' end as isOneSuppliers, prRequestId,jpcNo,jpcFile,prNo,prAmount,prAmountSum,conAmount,managerId,subject,giveDate,giveRemark,payRemark,content,CrmContractInfo.createDate,CrmContractInfo.creator,CrmContractInfo.subcompanyid1, case conStatus when '0' then 'ִ' when '1' then 'ǩ' when '2' then 'ǩ' when '3' then 'ر' end as reNewStatus,contractName, saleContract, case CrmSalesContractInfo.status when '0' then 'ǩ' when '1' then 'δǩ' when '2' then 'ǩ' when '3' then 'ر' end as reNewStatus2 from CrmContractInfo Left Join CrmSalesContractInfo On CrmSalesContractInfo.id=CrmContractInfo.saleContract" + sqlwhere + orderStr; + } else { + sqlstr = "select CrmContractInfo.id, reqDeptId, suppliersId, conNo, name, startDate, endDate, case isOverdue when 'Y' then '' else '' end as isOverdue, conAmount, content, case isOverdueNext when 'Y' then '' else '' end as isOverdueNext, case CrmContractInfo.status when '0' then 'ִ' when '1' then 'ѽ' end as status, case isOneSuppliers when 'Y' then '' when 'N' then '' else '' end as isOneSuppliers, prRequestId,jpcNo,jpcFile,prNo,prAmount,prAmountSum,conAmount,managerId,subject,giveDate,giveRemark,payRemark,content,CrmContractInfo.createDate,CrmContractInfo.creator,CrmContractInfo.subcompanyid1, case conStatus when '0' then 'ִ' when '1' then 'ǩ' when '2' then 'ǩ' when '3' then 'ر' end as reNewStatus,contractName, saleContract, case CrmSalesContractInfo.status when '0' then 'ǩ' when '1' then 'δǩ' when '2' then 'ǩ' when '3' then 'ر' end as reNewStatus2 from CrmContractInfo Left Join CrmSalesContractInfo On CrmSalesContractInfo.id=CrmContractInfo.saleContract" + sqlwhere + orderStr; + } + new BaseBean().writeLog(">>>>>>>>"+sqlstr); + RecordSet.executeQuery(sqlstr); + + ExcelSheet es = new ExcelSheet(); + + ExcelRow er = es.newExcelRow(); + er.addStringValue(SystemEnv.getHtmlLabelName(141,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620002,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(613002,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(21282,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(15142,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(1970,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(15236,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620016,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(6146,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620015,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620017,user.getLanguage())); + er.addStringValue("״̬"); + er.addStringValue(SystemEnv.getHtmlLabelName(913,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620009,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620003,user.getLanguage())); + er.addStringValue("JPC"+SystemEnv.getHtmlLabelName(16992,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620004,user.getLanguage())); + er.addStringValue("PR"+SystemEnv.getHtmlLabelName(403,user.getLanguage())); + er.addStringValue("PR"+SystemEnv.getHtmlLabelName(856,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620010,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620011,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620006,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620012,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620013,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620014,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620015,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(614,user.getLanguage())+SystemEnv.getHtmlLabelName(722,user.getLanguage())); + er.addStringValue("ͬ״̬"); + er.addStringValue("ۺͬ"); + er.addStringValue("ۺͬ״̬"); + + while (RecordSet.next()) { + ExcelRow erdetail = es.newExcelRow(); + erdetail.addStringValue(SubCompanyComInfo.getSubCompanyname(RecordSet.getString("subcompanyid1"))); + erdetail.addStringValue(DepartmentComInfo.getDepartmentname(RecordSet.getString("reqDeptId"))); + erdetail.addStringValue(CrmSupplierComInfo.getSuppliername(RecordSet.getString("suppliersId"))); + erdetail.addStringValue(RecordSet.getString("conNo")); + erdetail.addStringValue(RecordSet.getString("name")); + erdetail.addStringValue(RecordSet.getString("startDate")); + erdetail.addStringValue(RecordSet.getString("endDate")); + erdetail.addStringValue(RecordSet.getString("isOverdue")); + erdetail.addStringValue(RecordSet.getString("conAmount")); + erdetail.addStringValue(Util.toScreen(SptmForDoc.getDocName(RecordSet.getString("content")), user.getLanguage())); + erdetail.addStringValue(RecordSet.getString("isOverdueNext")); + erdetail.addStringValue(RecordSet.getString("status")); + erdetail.addStringValue(Util.toScreen(ResourceComInfo.getResourcename(RecordSet.getString("creator")), user.getLanguage())); + erdetail.addStringValue(RecordSet.getString("isOneSuppliers")); + erdetail.addStringValue(RequestComInfo.getRequestname(RecordSet.getString("prRequestId"))); + erdetail.addStringValue(RecordSet.getString("jpcNo")); + erdetail.addStringValue(DocComInfo.getDocname(RecordSet.getString("jpcFile"))); + erdetail.addStringValue(RecordSet.getString("prNo")); + erdetail.addStringValue(RecordSet.getString("prAmount")); + erdetail.addStringValue(RecordSet.getString("prAmountSum")); + erdetail.addStringValue(ResourceComInfo.getResourcename(RecordSet.getString("managerId"))); + erdetail.addStringValue(RecordSet.getString("subject")); + erdetail.addStringValue(RecordSet.getString("giveDate")); + erdetail.addStringValue(RecordSet.getString("giveRemark")); + erdetail.addStringValue(RecordSet.getString("payRemark")); + erdetail.addStringValue(DocComInfo.getDocname(RecordSet.getString("content"))); + erdetail.addStringValue(RecordSet.getString("createDate")); + erdetail.addStringValue(RecordSet.getString("reNewStatus")); + erdetail.addStringValue(RecordSet.getString("contractName")); + erdetail.addStringValue(RecordSet.getString("reNewStatus2")); + } + + ExcelFile.init(); + ExcelFile.setFilename("ͬ"); + ExcelFile.addSheet("ͬ", es); +%> + +<%----%> \ No newline at end of file diff --git a/src/main/resources/ajzx/SalesContractList.jsp b/src/main/resources/ajzx/SalesContractList.jsp new file mode 100644 index 0000000..1238542 --- /dev/null +++ b/src/main/resources/ajzx/SalesContractList.jsp @@ -0,0 +1,916 @@ +<%@ page import="weaver.general.Util"%> +<%@ page import="java.util.*"%> + + + + + + + + +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<%@ include file="/systeminfo/init_wev8.jsp"%> +<%@ taglib uri="/WEB-INF/weaver.tld" prefix="wea"%> +<%@ taglib uri="/WEB-INF/tld/browser.tld" prefix="brow"%> + + + + + + +<% + + String sqlwhere = " where 1=1 "; + + //查看权限 + boolean hasViewRight = false; + if(HrmUserVarify.checkUserRight("xsht:view", user)) + { + hasViewRight = true; + } + if(!hasViewRight ){ + sqlwhere += " and (exists("; + sqlwhere += " select 1 from ("; + sqlwhere += " select requestid, htbh from formtable_main_29 where htbh is not null"; + sqlwhere += " union all"; + sqlwhere += " select requestid, htbh from formtable_main_31 where htbh is not null"; + sqlwhere += " ) t "; + sqlwhere += " where exists( "; + sqlwhere += " select 1 from workflow_currentoperator "; + sqlwhere += " where requestid = t.requestid and workflowid in(200,201,205,206,264,267,270,271,272,275,277,279,339,343,344,348,352,353,354,355,357,360,361,365,366,373,374,375,377,378,381,382,383,458,461,462,495,496,497,498,612,614,750,759,776,846,852,854,856,871,872,914,918,954,955,987,989,990,991,1080,1081) and userid = "+user.getUID(); + sqlwhere += " ) and htbh = mt.contractCode"; + sqlwhere += " ) or contractRemind='"+ user.getUID() +"'"; + //组合权限 + sqlwhere += " or exists(select a.id from CrmContractRights a join HrmRoleMembers b on a.roleId=b.roleid where a.propDeptId=mt.propDeptId and a.operationDeptId=mt.operationDeptId and b.resourceid='"+ user.getUID()+"')"; + sqlwhere += " )"; + } + +// if(!hasViewRight ){ +// sqlwhere += " and (exists("; +// sqlwhere += " select a.requestid from"; +// sqlwhere += " (select requestid from workflow_currentoperator"; +// sqlwhere += " where workflowid in(200,201,205,206,264,267,270,271,272,275,277,279,339,343,344,348,352,353,354,355,357,360,361,365,366,373,374,375,377,378,381,382,383,458,461,462,495,496,497,498,612,614,750,759,776,846,852,854,856,871,872,914,918,954,955,987,989,990,991,1080,1081) and userid = " + user.getUID(); +// sqlwhere += " )as a"; +// sqlwhere += " left join formtable_main_29 as c on c.requestid = a.requestId and c.htbh = mt.contractCode"; +// sqlwhere += " left join formtable_main_31 as d on d.requestid = a.requestId and d.htbh = mt.contractCode"; +// sqlwhere += " where"; +// sqlwhere += " (c.htbh is not null or"; +// sqlwhere += " d.htbh is not null"; +// sqlwhere += " )"; +// sqlwhere += " ) or contractRemind='"+ user.getUID() +"'"; +// //组合权限 +// sqlwhere += " or exists(select a.id from CrmContractRights a join HrmRoleMembers b on a.roleId=b.roleid where a.propDeptId=mt.propDeptId and a.operationDeptId=mt.operationDeptId and b.resourceid='"+ user.getUID()+"')"; +// sqlwhere += " )"; +// } + + //提醒人变更权限 + boolean hasHttxrbgRight = false; + if (HrmUserVarify.checkUserRight("httxr:edit", user)){ + hasHttxrbgRight = true; + } + + //是否采购部 + //boolean isDep = false; + //是否是流程接收人 + //boolean isShow = false; + //采购部的同事可以选择所有合同卡片;而本部门的人员(非采购部)只能选择本部门的合同卡片 + //RecordSet_Dep.executeSql("select * from HrmDepartment where departmentname like '%采购%' and id="+user.getUserDepartment()); + //if(RecordSet_Dep.next()) isDep = true; + + //是否合同流程接收人 + //String sqlwhere_workflow = ""; + //RecordSet_Dep.executeSql("select distinct requestId from workflow_currentoperator where workflowid in (79,148,133,128,118,108,98,153,167) and userid="+user.getUID()); + //if(RecordSet_Dep.next()) isShow = true; + + +// if(!HrmUserVarify.checkUserRight("ContactInfo:Manager", user) && !HrmUserVarify.checkUserRight("ContactInfo:User", user) && !isShow && !isDep){ +// response.sendRedirect("/notice/noright.jsp"); +// } + + //如果是合同管理权限,则直接1=1 +// if(HrmUserVarify.checkUserRight("ContactInfo:Manager", user)){//判断用户是否具有权限 +// // sqlwhere += " and 1=1"; +// }else if(isShow && HrmUserVarify.checkUserRight("ContactInfo:User", user)){ +// //如果是流程接收人,并且有合同查看权限 +// sqlwhere += " and requestid in (select distinct requestId from workflow_currentoperator where workflowid in (79,148,133,128,118,108,98,153,167) and userid="+user.getUID()+") or reqDeptId = '"+user.getUserDepartment()+"'"; +// }else if(HrmUserVarify.checkUserRight("ContactInfo:User", user)){ +// //如果只有合同查看权限 +// sqlwhere += " and reqDeptId = '"+user.getUserDepartment()+"'"; +// }else if(isShow){ +// //如果只是流程接收人 +// sqlwhere += " and requestid in (select distinct requestId from workflow_currentoperator where workflowid in (79,148,133,128,118,108,98,153,167) and userid="+user.getUID()+")"; +// } + + //如果没有查看全部的权限,加分部条件 ADD BY LIST 20141106 + String subcompanyid1 = ResourceComInfo.getSubCompanyID(String.valueOf(user.getUID())); + if(!HrmUserVarify.checkUserRight("SalesContractList:ALL", user)){ + if (!subcompanyid1.equals("0")) {sqlwhere += " and subcompanyid1='" + subcompanyid1 + "'";} + } + //如果没有查看全部的权限,加分部条件 ADD BY LIST 20141106 + + String imagefilename = "/images/hdReport.gif"; + String titlename = SystemEnv.getHtmlLabelName(614, user.getLanguage()) + SystemEnv.getHtmlLabelName(527, user.getLanguage()); + String needfav = "1"; + String needhelp = ""; +%> + + <%@ include file="/systeminfo/TopTitle_wev8.jsp"%> + <%@ include file="/systeminfo/RightClickMenuConent_wev8.jsp"%> + <% + RCMenu += "{" + "搜索" + ",javascript:doSubmit(this),_self} "; + RCMenuHeight += RCMenuHeightStep; + RCMenu += "{" + "Excel" + ",javascript:SalesContractListBacthExport(),_top}";//add by list 20150505 + RCMenuHeight += RCMenuHeightStep;//add by list 20150505 + RCMenu += "{" + SystemEnv.getHtmlLabelName(18363, user.getLanguage()) + ",javascript:_table.firstPage(),_self}"; + RCMenuHeight += RCMenuHeightStep; + RCMenu += "{" + SystemEnv.getHtmlLabelName(1258, user.getLanguage()) + ",javascript:_table.prePage(),_self}"; + RCMenuHeight += RCMenuHeightStep; + RCMenu += "{" + SystemEnv.getHtmlLabelName(1259, user.getLanguage()) + ",javascript:_table.nextPage(),_self}"; + RCMenuHeight += RCMenuHeightStep; + RCMenu += "{" + SystemEnv.getHtmlLabelName(18362, user.getLanguage()) + ",javascript:_table.lastPage(),_self}"; + RCMenuHeight += RCMenuHeightStep; + if(hasHttxrbgRight){ + RCMenu += "{" + "提醒人变更" + ",javascript:doOverBackMutil(this),_self}"; + RCMenuHeight += RCMenuHeightStep; + } + RCMenu += "{"+"返回"+",javascript:history.back(),_self} " ; + RCMenuHeight += RCMenuHeightStep ; + %> + + + + + + + + + + + + + + + + + +
+ + + + +
+ <% + int pagenum = Util.getIntValue(request.getParameter("pagenum"), 1); + int perpage = Util.getPerpageLog(); + if (perpage <= 1) perpage = 10; + String id = Util.fromScreen(request.getParameter("id"), user.getLanguage());//id + String isMainSell = Util.fromScreen(request.getParameter("isMainSell"), user.getLanguage());//是否主营销售类 + String contractType = Util.fromScreen(request.getParameter("contractType"), user.getLanguage());//合同类型 + String contractName = Util.fromScreen(request.getParameter("contractName"), user.getLanguage());//合同名称 + String contractCode = Util.fromScreen(request.getParameter("contractCode"), user.getLanguage());//合同编号 + String proposer = Util.fromScreen(request.getParameter("proposer"), user.getLanguage());//申请人 + String propDeptId = Util.fromScreen(request.getParameter("propDeptId"), user.getLanguage());//申请部门ID + String clientCode1 = Util.fromScreen(request.getParameter("clientCode1"), user.getLanguage());//客户编号 + String clientCode = Util.fromScreen(request.getParameter("clientCode"), user.getLanguage());//客户编号 + String clientName = Util.fromScreen(request.getParameter("clientName"), user.getLanguage());//客户名称 + String industryINOut = Util.fromScreen(request.getParameter("industryINOut"), user.getLanguage());//业内/业外 + String operationDeptId = Util.fromScreen(request.getParameter("operationDeptId"), user.getLanguage());//运作部门ID + String contractNewOld = Util.fromScreen(request.getParameter("contractNewOld"), user.getLanguage());//新/老合同 + String CLandFM = Util.fromScreen(request.getParameter("CLandFM"), user.getLanguage());//CL/FM + String serviceType = Util.fromScreen(request.getParameter("serviceType"), user.getLanguage());//服务种类 + String contractStartTimeFirst = Util.fromScreen(request.getParameter("contractStartTimeFirst"), user.getLanguage());//合同起始日期(开始) + String contractStartTimeEnd = Util.fromScreen(request.getParameter("contractStartTimeEnd"), user.getLanguage());//合同起始日期(结束) + String contractEndTimeFirst = Util.fromScreen(request.getParameter("contractEndTimeFirst"), user.getLanguage());//合同结束日期(开始) + String contractEndTimeEnd = Util.fromScreen(request.getParameter("contractEndTimeEnd"), user.getLanguage());//合同结束日期(结束) + String estimateStartTmeFirst = Util.fromScreen(request.getParameter("estimateStartTmeFirst"), user.getLanguage());//预估运作起始日期(开始) + String estimateStartTmeEnd = Util.fromScreen(request.getParameter("estimateStartTmeEnd"), user.getLanguage());//预估运作起始日期(结束) + String estimateEndTimeFirst = Util.fromScreen(request.getParameter("estimateEndTimeFirst"), user.getLanguage());//预估运作结束日期(开始) + String estimateEndTimeEnd = Util.fromScreen(request.getParameter("estimateEndTimeEnd"), user.getLanguage());//预估运作结束日期(结束) + String contractTotalMoney = Util.fromScreen(request.getParameter("contractTotalMoney"), user.getLanguage());//合同总金额 + String yearContractrTotMon = Util.fromScreen(request.getParameter("yearContractrTotMon"), user.getLanguage());//年合同总金额 + String yearAchieveIncome = Util.fromScreen(request.getParameter("yearAchieveIncome"), user.getLanguage());//当年可实现收入金额 + String creditPaymentDays = Util.fromScreen(request.getParameter("creditPaymentDays"), user.getLanguage());//信用账期(天) + String creditLimit = Util.fromScreen(request.getParameter("creditLimit"), user.getLanguage());//信用额度 + String settleAccountsUnit = Util.fromScreen(request.getParameter("settleAccountsUnit"), user.getLanguage());//结算单位 + String status = Util.fromScreen(request.getParameter("status"), user.getLanguage());//合同状态 + String contractBackFileTimeFirst = Util.fromScreen(request.getParameter("contractBackFileTimeFirst"), user.getLanguage());//合同流程归档日期(开始) + String contractBackFileTimeEnd = Util.fromScreen(request.getParameter("contractBackFileTimeEnd"), user.getLanguage());//合同流程归档日期(结束) + String contractTotalMoneys = Util.null2String(request.getParameter("contractTotalMoneys")); + String yearContractrTotMons = Util.null2String(request.getParameter("yearContractrTotMons")); + String yearAchieveIncomes = Util.null2String(request.getParameter("yearAchieveIncomes")); + String creditPaymentDayss = Util.null2String(request.getParameter("creditPaymentDayss")); + String creditLimits = Util.null2String(request.getParameter("creditLimits")); + // ADD BY LIST 20141106 + String subCompanyId = Util.fromScreen(request.getParameter("subCompanyId"), user.getLanguage()); + // ADD BY LIST 20141106 + //查询分部名称 + String subcompanyname = ""; + if(!"".equals(subCompanyId)){ + RecordSet.executeQuery("select subcompanyname from HrmSubCompany where id in ("+subCompanyId+")"); + while (RecordSet.next()){ + String subcompanyname_temp = Util.null2String(RecordSet.getString(1)); + if(!"".equals(subcompanyname_temp)){ + if("".equals(subcompanyname)){ + subcompanyname = subcompanyname_temp; + }else{ + subcompanyname += "," + subcompanyname_temp; + } + } + } + } + + + //ADD BY ZWL 20191122 + int opentype = Util.getIntValue(request.getParameter("opentype"),-1);//开闭口类型 0-闭口 1-开口 2-周期性 + + //sqlwhere = " 1=1 "; + //out.print("clientName="+clientName); + if(!"".equals(isMainSell)) sqlwhere += " and isMainSell = '"+isMainSell+"'"; + if (!contractType.equals("")) sqlwhere += " and contractType='" + contractType + "'"; + if (!contractName.equals("")) sqlwhere += " and contractName like '%" + contractName + "%'"; + if (!contractCode.equals("")) sqlwhere += " and contractCode like '%" + contractCode + "%'"; + if (!proposer.equals("")) sqlwhere += " and proposer='" + proposer + "'"; + if (!propDeptId.equals("")) sqlwhere += " and propDeptId='" + propDeptId + "'"; + if(!"".equals(clientName)){ + if(clientName.indexOf(",")!=-1){ + String arr[] = clientName.split(","); + sqlwhere += " and (clientName = '"+arr[0]+"'"; + for(int i = 1;i>creditPaymentDays====== :"+creditPaymentDays); + if(!"".equals(creditPaymentDays)) { + new BaseBean().writeLog(">>creditPaymentDayss====222== :"+creditPaymentDayss); + if("0".equals(creditPaymentDayss)){ + sqlwhere += " and ISNUMERIC(creditPaymentDays)=1 and (cast (isnull(nullif(creditPaymentDays,''),0) as decimal(19,2)))>=" + creditPaymentDays ; + } + if("1".equals(creditPaymentDayss)){ + sqlwhere += " and ISNUMERIC(creditPaymentDays)=1 and (cast (isnull(nullif(creditPaymentDays,''),0) as decimal(19,2)))=" + creditPaymentDays ; + } + if("2".equals(creditPaymentDayss)){ + sqlwhere += " and ISNUMERIC(creditPaymentDays)=1 and (cast (isnull(nullif(creditPaymentDays,''),0) as decimal(19,2)))<" + creditPaymentDays ; + } + } + if (!creditLimit.equals("")) { + if("0".equals(creditLimits)){ + sqlwhere += " and ISNUMERIC(creditLimit)=1 and (cast (isnull(nullif(creditLimit,''),0) as decimal(19,2)))>" + creditLimit ; + } + if("1".equals(creditLimits)){ + sqlwhere += " and ISNUMERIC(creditLimit)=1 and (cast (isnull(nullif(creditLimit,''),0) as decimal(19,2)))=" + creditLimit ; + } + if("2".equals(creditLimits)){ + sqlwhere += " and ISNUMERIC(creditLimit)=1 and (cast (isnull(nullif(creditLimit,''),0) as decimal(19,2)))<" + creditLimit ; + } + } + + if (!settleAccountsUnit.equals("")) sqlwhere += " and settleAccountsUnit like '%" + settleAccountsUnit + "%'"; + if (!status.equals("")) sqlwhere += " and status='" + status + "'"; + + if (!contractBackFileTimeFirst.equals("")) sqlwhere += " and CONVERT(varchar(100), contractBackFileTime, 23)>='" + contractBackFileTimeFirst + "'"; + if (!contractBackFileTimeEnd.equals("")) sqlwhere += " and CONVERT(varchar(100), contractBackFileTime, 23)<='" + contractBackFileTimeEnd + "'"; + // ADD BY LIST 20141106 + //if (!subCompanyId.equals("")) sqlwhere += " and subcompanyid1 = '" + subCompanyId + "'"; + if (!subCompanyId.equals("")) sqlwhere += " and subcompanyid1 in ("+subCompanyId+")"; + // ADD BY LIST 20141106 + //System.out.println("sqlwhere:"+sqlwhere); + + //ADD BY ZWL 20191122 + if(opentype > -1){ + sqlwhere += " and isnull(opentype,0) = " + opentype; + } + + String orderStr = " order by startDate desc, id desc "; + + session.setAttribute("sqlwhere", sqlwhere); + session.setAttribute("orderStr", orderStr); + + new BaseBean().writeLog(">>SalesContractList.jsp查询条件====== :"+sqlwhere); + %> +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%if(HrmUserVarify.checkUserRight("ContactInfoList:ALL", user)){%> + + + <%}%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
<%=SystemEnv.getHtmlLabelName(15774, user.getLanguage())%>
是否主营销售业务 + + 合同类型 + +
合同名称 + + <%=SystemEnv.getHtmlLabelName(21282, user.getLanguage())%> + +
申请人 + "> + + 申请部门 + "> + +
客户名称 + <%----%> + <%--<%=clientName%>--%> + <%----%> + <%----%> + + + <%-- + <%=clientName%> + + --%> + + <%-- + --%> + + 客户编号 + +
业内/业外 + + 运作部门 + "> + +
新/老合同 + + CL/FM + +
服务种类 + + <%=SystemEnv.getHtmlLabelName(141,user.getLanguage())%> + + <%-- " + > --%> + + " + browserUrl="/systeminfo/BrowserMain.jsp?url=/hrm/company/MutiSubcompanyBrowser.jsp" + hasInput="true" + isSingle="false" + hasBrowser = "true" + isMustInput='1' + width="165px" + browserSpanValue="<%=subcompanyname%>" > + +
合同起始日期 + + <%=contractStartTimeFirst %> + + -- + + <%=contractStartTimeEnd %> + + <%=SystemEnv.getHtmlLabelName(15236, user.getLanguage())%> + + <%=contractEndTimeFirst %> + + -- + + <%=contractEndTimeEnd %> + +
预估运作起始日期 + + <%=estimateStartTmeFirst %> + + -- + + <%=estimateStartTmeEnd %> + + 预估运作结束日期 + + <%=estimateEndTimeFirst %> + + -- + + <%=estimateEndTimeEnd %> + +
合同总金额 + + + 年合同总金额 + + +
当年可实现收入金额 + + + 信用账期(天) + + +
信用额度 + + + 结算单位 + +
合同状态 + + 合同流程归档日期 + + <%=contractBackFileTimeFirst %> + + -- + + <%=contractBackFileTimeEnd %> + +
+ + + + + +
+ <% + String para3="column:id"+id; + String tableString = ""; + String backfields = " id, clientCode, contractName, clientName, case contractType when '0' then '正式合同' when '1' then '延期协议' when '2' then '意向书及其他' end as contractType, "+ + "case status when '0' then '已签署' when '1' then '未签署' when '2' then '已续签' when '3' then '关闭' end as status, "+ + "propDeptId,"+ + "case industryINOut when '0' then '业内' else '业外' end as industryINOut, "+ + "case serviceType when '0' then '仓储' when '1' then '运输' when '2' then '其他' end as serviceType, "+ + "case contractNewOld when '0' then '新合同' when '1' then '老合同' when '2' then '老合同含新增' end as contractNewOld, "+ + "contractStartTime, contractEndTime, contractBackFileTime, yearContractrTotMon, "+ + "case earlyWarning when '0' then '是' when '1' then '否' end as earlyWarning,subcompanyid1 "; + String fromSql = " CrmSalesContractInfo as mt "; + session.setAttribute("fromSql", fromSql);//add by list 20150505 + +// out.println("backfields:"+backfields); +// +// out.println("sqlform:"+fromSql); +// +// out.println("sqlwhere:"+sqlwhere); + + tableString = " " + +"" + ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += "
"; + %> + + +
+ +
+ <%@ include file="/systeminfo/RightClickMenu_wev8.jsp"%> + +
+ +
+ + + + + + + + + + +<%----%> + + + + + \ No newline at end of file diff --git a/src/main/resources/ajzx/SalesContractListBacthExport.jsp b/src/main/resources/ajzx/SalesContractListBacthExport.jsp new file mode 100644 index 0000000..a946ced --- /dev/null +++ b/src/main/resources/ajzx/SalesContractListBacthExport.jsp @@ -0,0 +1,138 @@ + +<%@ page language="java" contentType="text/html; charset=GBK" %> <%@ include file="/systeminfo/init.jsp" %> +<%@ page import="weaver.general.Util, weaver.file.ExcelSheet, weaver.file.ExcelRow, weaver.file.Prop, java.util.Hashtable, java.math.BigDecimal +" %> + + + + + + +<% + //String receiptLists = request.getParameter("receiptLists"); + //new BaseBean().writeLog(">>>>>>>>>> ̨˱Żã "+receiptLists); + //String receiptLists2 = receiptLists; + //if(receiptLists.endsWith(",")){ + // receiptLists2 = receiptLists.substring(0, receiptLists.length() - 1); + //} + + String fromSql=(String)session.getAttribute("fromSql"); + String sqlwhere=(String)session.getAttribute("sqlwhere"); + String sqlorder=(String)session.getAttribute("orderStr"); + String sqlstr=""; + + String backfields = "select id, clientCode, contractName, clientName, case contractType when '0' then 'ʽͬ' when '1' then 'Э' when '2' then '鼰' end as contractType, "+ + "case contractState when '0' then '' when '1' then 'ر' when '2' then 'ǰֹ' end as contractState, "+ + "propDeptId,"+ + "case industryINOut when '0' then 'ҵ' else 'ҵ' end as industryINOut, "+ + "case serviceType when '0' then 'ִ' when '1' then '' when '2' then '' end as serviceType, "+ + "case contractNewOld when '0' then 'ºͬ' when '1' then 'Ϻͬ' end as contractNewOld, "+ + "contractStartTime, contractEndTime, contractBackFileTime, yearContractrTotMon, "+ + "case earlyWarning when '0' then '' when '1' then '' end as earlyWarning,subcompanyid1 "; + sqlstr = backfields; + sqlstr += " from" + fromSql; + sqlstr += sqlwhere; + //sqlstr += " and ParameterNumber in ('" + receiptLists2.replaceAll("," ,"','") + "')"; + sqlstr += " order by id desc "; + + new BaseBean().writeLog(">>>>>>>>>> ͬ "+sqlstr); + + RecordSet.executeSql(sqlstr); + + ExcelSheet es = new ExcelSheet(); + ExcelRow er = es.newExcelRow(); + er.addStringValue("ͬ"); + er.addStringValue("ͻ"); + er.addStringValue("ͬ"); + er.addStringValue("ͬ״̬"); + er.addStringValue("벿"); + er.addStringValue("ҵ/ҵ"); + er.addStringValue(""); + er.addStringValue("/Ϻͬ"); + er.addStringValue("ͬʼ"); + er.addStringValue("ͬ"); + er.addStringValue("ͬ鵵"); + er.addStringValue("ͬܽ"); + er.addStringValue("Ԥ"); + er.addStringValue("ֲ"); + + + //ͬϢ + int i=1; + String depId=""; + String sqlDepName= ""; + String depName= ""; + String subId=""; + String sqlSubName= ""; + String subName= ""; + while(RecordSet.next()){ + //ȡ + depId=RecordSet.getString("propDeptId"); + sqlDepName= "select departmentname from HrmDepartment where id ='"+depId+"'"; + RecordSetDepname.executeSql(sqlDepName); + RecordSetDepname.next(); + //new BaseBean().writeLog(">>>>>>>>>> sqlDepName "+sqlDepName); + depName=RecordSetDepname.getString("departmentname"); + //ȡֲ + subId=RecordSet.getString("subcompanyid1"); + sqlSubName= "select subcompanyname from HrmSubCompany where id ='"+subId+"'"; + RecordSetSubname.executeSql(sqlSubName); + RecordSetSubname.next(); + subName=RecordSetSubname.getString("subcompanyname"); + er = es.newExcelRow(); + //er.addStringValue(String.valueOf(i++));20141113 change by zhangy + er.addStringValue(RecordSet.getString("contractName")); + er.addStringValue(RecordSet.getString("clientName")); + er.addStringValue(RecordSet.getString("contractType")); + er.addStringValue(RecordSet.getString("contractState")); + er.addStringValue(depName); + er.addStringValue(RecordSet.getString("industryINOut")); + er.addStringValue(RecordSet.getString("serviceType")); + er.addStringValue(RecordSet.getString("contractNewOld")); + er.addStringValue(RecordSet.getString("contractStartTime")); + er.addStringValue(RecordSet.getString("contractEndTime")); + er.addStringValue(RecordSet.getString("contractBackFileTime")); + er.addStringValue(RecordSet.getString("yearContractrTotMon")); + er.addStringValue(RecordSet.getString("earlyWarning")); + er.addStringValue(subName); + + /* + er.addStringValue(Util.useSpecialTreat("weaver.hrm.resource.ResourceComInfo.getResourcename", Util.null2String(RecordSet.getString("gatheringCharge")))); + er.addStringValue(RecordSet.getString("clientName")); + er.addStringValue(RecordSet.getString("companyName")); + er.addStringValue(RecordSet.getString("contractCode")); + + String actualTotalAmountString = RecordSet.getString("actualTotalAmount"); + BigDecimal actualTotalAmount = new BigDecimal(actualTotalAmountString); + double actualTotalAmount2 = actualTotalAmount.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + er.addValue(actualTotalAmount2); + + er.addStringValue(RecordSet.getString("flowNumber")); + er.addStringValue(RecordSet.getString("invoiceMakeDate")); + + String moneyReceiptString = RecordSet.getString("moneyReceipt"); + BigDecimal moneyReceipt = new BigDecimal(moneyReceiptString); + double moneyReceipt2 = actualTotalAmount.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + er.addValue(moneyReceipt2); + + er.addStringValue(RecordSet.getString("status")); + */ + } + /* + er = es.newExcelRow(); + er.addStringValue("ǰɾɾ"); + er.addStringValue(""); + er.addStringValue("ƱһաYYYY/MM/DDʽ"); + er.addStringValue(""); + er.addStringValue(""); + er.addStringValue(""); + */ + ExcelFile.init() ; + ExcelFile.setFilename("ͬ") ; + ExcelFile.addSheet("ͬ", es) ; + +%> +success + \ No newline at end of file From a5f477ad9d19f743837e6072c60f44179f549955 Mon Sep 17 00:00:00 2001 From: ic_excellent Date: Sat, 6 May 2023 15:15:28 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ReserveSelectController.java | 122 ++--- .../xiao/zscq/entity/SendFileEntity.java | 30 +- .../bokang/xiao/zscq/entity/WeaverFile.java | 28 +- .../bokang/xiao/zscq/mapper/QueryMapper.java | 58 +- .../xiao/zscq/mapper/ReserveSelectMapper.java | 17 +- .../xiao/zscq/service/ReserveService.java | 23 + .../zscq/service/impl/ReserveServiceImpl.java | 122 ++++- .../api/interfaces/liyi/DataCenterApi.java | 34 ++ .../zenner/utils/ZennerUtil.java | 78 +-- .../GetFieldDefinedCmd.java | 15 + .../SaveFieldDefinedCmd.java | 93 +++- .../GetDepartmentFormFieldCmd.java | 10 + .../GetSubCompanyFormFieldCmd.java | 12 + .../GetFieldDefinedCmd.java | 15 + .../SaveFieldDefinedCmd.java | 93 +++- .../xiao/tbxc/mapper/FormFieldMapper.java | 42 +- .../zscq/config/entity/AssignmentEntity.java | 9 +- .../zscq/config/entity/ConditionEntity.java | 9 + .../zscq/config/entity/UpdateModeConf.java | 10 + .../zscq/config/mapper/UpdateModeMapper.java | 11 + .../process/ConditionTargetProcess.java | 52 +- .../config/process/ConditionValueProcess.java | 27 + .../zscq/config/process/DataTypeProcess.java | 28 +- .../config/process/ValueSelectProcess.java | 4 +- .../config/service/ModeChangeService.java | 30 +- .../xiao/zscq/expand/DataControlExpand.java | 2 +- .../xiao/zscq/fun/WorkflowOverOperate.java | 8 + .../zscq/fun/WorkflowRepossessedSign.java | 104 +++- .../bokang/xiao/zscq/mapper/StatusMapper.java | 11 +- .../xiao/zscq/store/TableNameStore.java | 26 +- src/main/resources/ContractList(2).jsp | 499 ------------------ .../resources/ContractReportExport(1).jsp | 127 ----- src/main/resources/ajzx/ContractList.jsp | 499 ------------------ .../resources/ajzx/ContractReportExport.jsp | 127 ----- src/test/java/bokang/xiao/NormalTest.java | 9 +- 35 files changed, 934 insertions(+), 1450 deletions(-) delete mode 100644 src/main/resources/ContractList(2).jsp delete mode 100644 src/main/resources/ContractReportExport(1).jsp delete mode 100644 src/main/resources/ajzx/ContractList.jsp delete mode 100644 src/main/resources/ajzx/ContractReportExport.jsp diff --git a/src/main/java/com/api/bokang/xiao/zscq/controller/ReserveSelectController.java b/src/main/java/com/api/bokang/xiao/zscq/controller/ReserveSelectController.java index 3be017f..ee75f63 100644 --- a/src/main/java/com/api/bokang/xiao/zscq/controller/ReserveSelectController.java +++ b/src/main/java/com/api/bokang/xiao/zscq/controller/ReserveSelectController.java @@ -6,6 +6,7 @@ import com.api.bokang.xiao.zscq.service.ReserveService; import com.api.bokang.xiao.zscq.service.impl.ReserveServiceImpl; import io.swagger.v3.oas.annotations.parameters.RequestBody; import org.apache.log4j.Logger; +import weaver.bokang.xiao.zscq.store.TableNameStore; import weaver.file.ImageFileManager; import weaver.hrm.HrmUserVarify; import weaver.hrm.User; @@ -17,7 +18,9 @@ import javax.ws.rs.*; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -48,77 +51,68 @@ public class ReserveSelectController { @Produces(MediaType.APPLICATION_JSON) public String reserveSelect(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map param) { try{ - log.info("====== into getReportData success ======="); + log.info("====== into reserveSelect success ======="); log.info("param:"+param); User loginUser = HrmUserVarify.getUser(request, response); - List> result = reserveService.reserveSelect(param); + List> result = reserveService.reserveTrigger(param); return ApiResult.success(result); }catch (Exception e){ - log.error("获取搜索组件信息 ==> "+ Util.getErrString(e)); + log.error("反选执行出现异常 reserveSelect execute error ==> "+ Util.getErrString(e)); return ApiResult.error(e.getMessage()); } } - //@GET - //@Path("/batch") - //@Produces(MediaType.APPLICATION_OCTET_STREAM) - //public void downloadFiles(@QueryParam("ids") String ids, @Context HttpServletResponse response) { - // try { - // log.info("Start downloading files: {}"+ids); - // // 解析文件ID列表 - // List idList = Arrays.stream(ids.split(",")) - // .map(Long::parseLong) - // .collect(Collectors.toList()); - // - // // 生成压缩文件名 - // String zipFileName = "attachments.zip"; - // - // // 设置响应头,告诉浏览器该响应体是一个附件,浏览器会自动下载该响应体 - // response.setContentType(MediaType.APPLICATION_OCTET_STREAM); - // response.setHeader("Content-Disposition", "attachment; filename=\"" + zipFileName + "\""); - // - // // 创建压缩输出流 - // try (ZipOutputStream zipOutputStream = new ZipOutputStream(response.getOutputStream())) { - // - // // 遍历文件ID列表,将对应的文件加入到压缩文件中 - // for (Long id : idList) { - // // 通过ID获取文件信息 - // WeaverFile file = WeaverFileUtil.getFileMsgById(id); - // - // // 获取文件名和后缀名 - // String fileName = file.getName(); - // String fileExtension = fileName.substring(fileName.lastIndexOf(".") + 1); - // - // // 创建一个ZipEntry,表示压缩文件中的一个文件 - // ZipEntry zipEntry = new ZipEntry(fileName); - // zipEntry.setSize(file.getSize()); - // zipEntry.setTime(System.currentTimeMillis()); - // - // // 将ZipEntry添加到压缩输出流中 - // zipOutputStream.putNextEntry(zipEntry); - // - // // 将文件内容写入到压缩输出流中 - // byte[] buffer = new byte[BUFFER_SIZE]; - // int len; - // try (InputStream inputStream = file.getInputStream()) { - // while ((len = inputStream.read(buffer)) > 0) { - // zipOutputStream.write(buffer, 0, len); - // } - // } - // zipOutputStream.closeEntry(); - // } - // - // // 刷新压缩输出流 - // zipOutputStream.flush(); - // } - // log.info("Finish downloading files: {}"+ids); - // } catch (Exception e) { - // log.error("下载附件异常: {}"+Util.getErrString(e)); - // // 如果出现异常,返回一个空的响应体 - // response.reset(); - // response.setContentType(MediaType.APPLICATION_OCTET_STREAM); - // response.setContentLength(0); - // } - //} + @GET + @Path("/batchDownload") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response downloadBatchFiles(@QueryParam("datePicker") String datePicker, + @QueryParam("checkResult") String checkResult, + @QueryParam("checkResultShow") String checkResultShow) { + log.info("====== into downloadBatchFiles success ======="); + log.info(String.format("====== datePicker:[%s] checkResult:[%s] checkResultShow:[%s] =======",datePicker,checkResult,checkResultShow)); + Map param = new HashMap<>(8); + param.put("datePicker",datePicker); + param.put("checkResult",checkResult); + param.put("checkResultShow",checkResultShow); + String zipFileName = reserveService.getFileName(param) + ".zip"; + StreamingOutput streamingOutput = outputStream -> { + try { + reserveService.batchDownload(param, outputStream); + } catch (Exception e) { + log.error("下载文件异常 download zip error ==>"+Util.getErrString(e)); + } + }; + log.info("zip file name ==>"+zipFileName); + return Response.ok(streamingOutput, MediaType.APPLICATION_OCTET_STREAM) + .header("Content-Disposition", "attachment; filename=\"" + zipFileName + "\"") + .build(); + } + + @GET + @Path("/refreshStore") + public String refreshStore(@Context HttpServletRequest request, @Context HttpServletResponse response){ + try{ + log.info("====== into refreshStore success ======="); + TableNameStore.getInstance().refresh(); + return ApiResult.successNoData(); + }catch (Exception e){ + log.error("refreshStore execute error ==> "+ Util.getErrString(e)); + return ApiResult.error(e.getMessage()); + } + } + + @GET + @Path("/doRepossessedSign") + public String doRepossessedSign(@QueryParam("requestId") String requestId){ + try{ + log.info("====== into doRepossessedSign success ======="); + log.info("requestId =>"+requestId); + new ReserveServiceImpl().doRepossessedSign(Util.getIntValue(requestId),new User(1)); + return ApiResult.successNoData(); + }catch (Exception e){ + log.error("refreshStore execute error ==> "+ Util.getErrString(e)); + return ApiResult.error(e.getMessage()); + } + } } diff --git a/src/main/java/com/api/bokang/xiao/zscq/entity/SendFileEntity.java b/src/main/java/com/api/bokang/xiao/zscq/entity/SendFileEntity.java index 5a61ceb..ac758fe 100644 --- a/src/main/java/com/api/bokang/xiao/zscq/entity/SendFileEntity.java +++ b/src/main/java/com/api/bokang/xiao/zscq/entity/SendFileEntity.java @@ -1,8 +1,28 @@ -package com.api.bokang.xiao.zscq.entity;/** - *@ClassName SendFileEntity - *@Author 肖博亢 - *@Date 2023/4/23 10:10 - *@Description

+package com.api.bokang.xiao.zscq.entity; + +import aiyh.utils.annotation.recordset.SqlOracleDbFieldAnn; +import lombok.Data; + +/** + * @ClassName SendFileEntity + * @Author 肖博亢 + * @Date 2023/4/23 10:10 + * @Description

**/ +@Data public class SendFileEntity { + + @SqlOracleDbFieldAnn(value = "ID") + private Integer id; + + @SqlOracleDbFieldAnn(value = "DEPART_ID") + private Integer departId; + + @SqlOracleDbFieldAnn(value = "DEPART_NAME") + private String departName; + + @SqlOracleDbFieldAnn(value = "SQH") + private String requestNumber; + + private WeaverFile weaverFile; } diff --git a/src/main/java/com/api/bokang/xiao/zscq/entity/WeaverFile.java b/src/main/java/com/api/bokang/xiao/zscq/entity/WeaverFile.java index 25efe04..80dcd6f 100644 --- a/src/main/java/com/api/bokang/xiao/zscq/entity/WeaverFile.java +++ b/src/main/java/com/api/bokang/xiao/zscq/entity/WeaverFile.java @@ -1,8 +1,26 @@ -package com.api.bokang.xiao.zscq.entity;/** - *@ClassName WeaverFile - *@Author 肖博亢 - *@Date 2023/4/23 10:09 - *@Description

+package com.api.bokang.xiao.zscq.entity; + +import aiyh.utils.annotation.recordset.SqlOracleDbFieldAnn; +import lombok.Data; + +/** + * @ClassName WeaverFile + * @Author 肖博亢 + * @Date 2023/4/23 10:09 + * @Description

**/ +@Data public class WeaverFile { + + @SqlOracleDbFieldAnn(value = "IMAGEFILEID") + private Integer imageFileId; + + @SqlOracleDbFieldAnn(value = "DOCID") + private Integer docId; + + @SqlOracleDbFieldAnn(value = "FILESIZE") + private Integer fileSize; + + @SqlOracleDbFieldAnn(value = "IMAGEFILENAME") + private String fileName; } diff --git a/src/main/java/com/api/bokang/xiao/zscq/mapper/QueryMapper.java b/src/main/java/com/api/bokang/xiao/zscq/mapper/QueryMapper.java index 4c2e603..ab2d464 100644 --- a/src/main/java/com/api/bokang/xiao/zscq/mapper/QueryMapper.java +++ b/src/main/java/com/api/bokang/xiao/zscq/mapper/QueryMapper.java @@ -1,8 +1,56 @@ -package com.api.bokang.xiao.zscq.mapper;/** - *@ClassName QueryMapper - *@Author 肖博亢 - *@Date 2023/4/23 10:14 - *@Description

+package com.api.bokang.xiao.zscq.mapper; + +import aiyh.utils.annotation.recordset.*; +import com.api.bokang.xiao.zscq.entity.SendFileEntity; +import com.api.bokang.xiao.zscq.entity.WeaverFile; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName QueryMapper + * @Author 肖博亢 + * @Date 2023/4/23 10:14 + * @Description

**/ +@SqlMapper public interface QueryMapper { + + /** + *

查询附件下载列表

+ * @param param 参数 + * @return 附件信息列表 + */ + @Select("select gjj.id as id,depart.id as depart_id,depart.DEPARTMENTNAME as depart_name,xgfj,sqh " + + " from uf_gjjtb gjj " + + " inner join hrmdepartment depart on gjj.xfqj = depart.id " + + " where concat(',',concat(sjpcdxk,',')) like concat('%,',concat(#{datePicker},',%')) " + + " and hcqkdx = #{checkResult} and gjj.xgfj is not null ") + @Associations( @Association(property = "weaverFile",column = "xgfj",id = @Id(value = Integer.class,methodId = 1))) + List queryDownloadList(Map param); + + /** + *

查询附件信息

+ * @param docId docId + * @return 附件信息 + */ + @AssociationMethod(value = 1) + @Select("select dm.docid,dm.imagefileid,dm.imagefilename,file.filesize " + + " from docimagefile dm inner join imagefile file on dm.imagefileid = file.imagefileid" + + " where docid = #{docId}") + WeaverFile queryFile(@ParamMapper("id")Integer docId); + + /** + *

获取下拉框信息

+ * @param tableName 表名 + * @param fieldName 字段名 + * @return 下拉框信息 + */ + @Select("select selectvalue,selectname " + + " from workflow_selectitem se " + + " inner join workflow_billfield bf on se.fieldid = bf.id " + + " inner join workflow_bill bi on bf.billid = bi.id " + + " where tablename = #{tableName} and bf.fieldname = #{fieldName} ") + List> querySelectItem(@ParamMapper("tableName") String tableName,@ParamMapper("fieldName") String fieldName); + } diff --git a/src/main/java/com/api/bokang/xiao/zscq/mapper/ReserveSelectMapper.java b/src/main/java/com/api/bokang/xiao/zscq/mapper/ReserveSelectMapper.java index 53d5086..d6619f8 100644 --- a/src/main/java/com/api/bokang/xiao/zscq/mapper/ReserveSelectMapper.java +++ b/src/main/java/com/api/bokang/xiao/zscq/mapper/ReserveSelectMapper.java @@ -19,7 +19,7 @@ public interface ReserveSelectMapper { * @param requestId 流程id * @return 操作人信息 */ - @Select("select operator userId,operatortype userType from workflow_requestlog where requestid=#{requestId}" + + @Select("select operator userid,operatortype usertype from workflow_requestlog where requestid=#{requestId}" + " and (logtype='2' or logtype='0' or logtype='3' or logtype='e') " + " and exists(select 1 from workflow_currentoperator where requestid=workflow_requestlog.requestid and userid=workflow_requestlog.operator and usertype=workflow_requestlog.operatortype and isremark='2' and preisremark='0' and operatedate is not null and operatedate>' ') " + " group by operator,operatortype order by max(logid) desc") @@ -30,7 +30,7 @@ public interface ReserveSelectMapper { * @param requestId 流程id * @return 操作人信息 */ - @Select("select userid userId,usertype userType from workflow_currentoperator where requestid = #{requestId} and isremark = '2' and preisremark='0' and operatedate is not null and operatedate>' ' order by operatedate desc ,operatetime desc") + @Select("select userid,usertype from workflow_currentoperator where requestid = #{requestId} and isremark = '2' and preisremark='0' and operatedate is not null and operatedate>' ' order by operatedate desc ,operatetime desc") Map queryOperator(@ParamMapper("requestId")String requestId); /** @@ -38,17 +38,26 @@ public interface ReserveSelectMapper { * @param param 参数信息 * @return 建模数据 */ - @Select("select id, $t{applicationNoField}, $t{workflowInfoField}, $t{checkResultField} from $t{modeTableName} where $t{dateField} = #{datePicker}") + @Select("select id, $t{applicationNoField}, $t{workflowInfoField}, $t{checkResultField} from $t{modeTableName} where concat(',',concat($t{dateField},',')) like #{datePicker} and ($t{markField} <> 0 or $t{markField} is not null)") @CaseConversion(value = false) List> queryModeList(Map param); + /** + *

更新检查结果

+ * @param param 参数信息 + * @return 更新结果 + */ + @Update("update $t{modeTableName} set $t{markField} = 1 " + + " where concat(',',concat($t{dateField},',')) like #{datePicker}") + boolean updateModeDataStatus(@ParamMapper("param") Map param); + /** *

更新检查结果

* @param forceOverList 强制归档流程id集合 * @param param 参数信息 * @return 更新结果 */ - @Update("update $t{param.modeTableName} set $t{param.checkResultField} = #{param.repossessedValue} " + + @Update("update $t{param.modeTableName} set $t{param.markField} = #{param.repossessedValue} " + " where $t{param.workflowInfoField} in (${doRepossessedList})") boolean updateRepossessed(@ParamMapper("doRepossessedList") List forceOverList, @ParamMapper("param") Map param); diff --git a/src/main/java/com/api/bokang/xiao/zscq/service/ReserveService.java b/src/main/java/com/api/bokang/xiao/zscq/service/ReserveService.java index 37f0d30..3006111 100644 --- a/src/main/java/com/api/bokang/xiao/zscq/service/ReserveService.java +++ b/src/main/java/com/api/bokang/xiao/zscq/service/ReserveService.java @@ -3,6 +3,7 @@ package com.api.bokang.xiao.zscq.service; import aiyh.utils.Util; import org.apache.log4j.Logger; +import java.io.OutputStream; import java.util.List; import java.util.Map; @@ -22,4 +23,26 @@ public interface ReserveService { * @return 操作结果 */ List> reserveSelect(Map param); + + /** + *

反选操作

+ * @param param 参数信息 + * @return 操作结果 + */ + List> reserveTrigger(Map param); + + /** + *

将附件信息合并

+ * @param param 查询参数 + * @param outputStream 输出流 + * @throws Exception 异常信息 + */ + void batchDownload(Map param, OutputStream outputStream) throws Exception; + + /** + *

获取文件名

+ * @param param 参数信息 + * @return 文件名 + */ + String getFileName(Map param); } diff --git a/src/main/java/com/api/bokang/xiao/zscq/service/impl/ReserveServiceImpl.java b/src/main/java/com/api/bokang/xiao/zscq/service/impl/ReserveServiceImpl.java index 96d6ef1..855b5b2 100644 --- a/src/main/java/com/api/bokang/xiao/zscq/service/impl/ReserveServiceImpl.java +++ b/src/main/java/com/api/bokang/xiao/zscq/service/impl/ReserveServiceImpl.java @@ -1,16 +1,27 @@ package com.api.bokang.xiao.zscq.service.impl; import aiyh.utils.Util; +import com.alibaba.fastjson.JSON; +import com.api.bokang.xiao.zscq.entity.SendFileEntity; +import com.api.bokang.xiao.zscq.entity.WeaverFile; +import com.api.bokang.xiao.zscq.mapper.QueryMapper; import com.api.bokang.xiao.zscq.mapper.ReserveSelectMapper; import com.api.bokang.xiao.zscq.service.ReserveService; +import weaver.bokang.xiao.zscq.config.service.ModeChangeService; +import weaver.conn.RecordSet; +import weaver.file.ImageFileManager; import weaver.hrm.User; import weaver.workflow.workflow.RequestForceDrawBack; import weaver.workflow.workflow.WfForceDrawBack; import weaver.workflow.workflow.WfForceOver; import weaver.workflow.workflow.WfFunctionManageUtil; +import java.io.*; +import java.nio.charset.StandardCharsets; import java.util.*; import java.util.stream.Collectors; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; /** @@ -23,6 +34,8 @@ public class ReserveServiceImpl implements ReserveService { private final ReserveSelectMapper reserveSelectMapper = Util.getMapper(ReserveSelectMapper.class); + private final QueryMapper queryMapper = Util.getMapper(QueryMapper.class); + private final WfForceOver wfForceOver = new WfForceOver(); private final WfFunctionManageUtil wfFunctionManageUtil = new WfFunctionManageUtil(); @@ -30,6 +43,11 @@ public class ReserveServiceImpl implements ReserveService { private final WfForceDrawBack wfForceDrawBack = new WfForceDrawBack(); private final RequestForceDrawBack requestForceDrawBack = new RequestForceDrawBack(); + private final ModeChangeService modeChangeService = new ModeChangeService(); + + private static final int BUFFER_SIZE = 4096; + + /** *

流程强制收回 * @param requestIdList 流程id集合 @@ -51,15 +69,19 @@ public class ReserveServiceImpl implements ReserveService { * @param user 用户信息 * @return 操作结果 */ - private boolean doRepossessedSign(int requestId,User user){ + public boolean doRepossessedSign(int requestId,User user){ //查询最后一个操作者 Map operateInfo = reserveSelectMapper.queryRequestMsg(String.valueOf(requestId)); - log.info(" doRepossessedSign operateInfo ==>"+operateInfo); if(Objects.isNull(operateInfo)){ operateInfo = reserveSelectMapper.queryOperator(String.valueOf(requestId)); } - int tempUser = operateInfo.get("userId"); - int tempUserType = operateInfo.get("userType"); + log.info(" doRepossessedSign operateInfo ==>"+operateInfo); + if(Objects.isNull(operateInfo)){ + log.error(String.format("流程 requestId:[%s] 操作者 operateInfo no find 流程可能未归档 !!!",requestId)); + return false; + } + int tempUser = operateInfo.get("userid"); + int tempUserType = operateInfo.get("usertype"); boolean canForceDrawBack = false; if(RequestForceDrawBack.isOldRequest(requestId) == RequestForceDrawBack.OLDDATA){ canForceDrawBack = wfForceDrawBack.isHavePurview(requestId, user.getUID(), Integer.parseInt(user.getLogintype()), tempUser, tempUserType); @@ -68,6 +90,7 @@ public class ReserveServiceImpl implements ReserveService { } if (canForceDrawBack && wfFunctionManageUtil.haveOtherOperationRight(requestId)) { int result = requestForceDrawBack.foreceDrawBack(user, requestId, true, tempUser, tempUserType); + log.info(String.format("流程 requestId:[%s] 撤回结果 drawBack result:[%d] message:[%s]",requestId,result,requestForceDrawBack.getMessage())); return requestForceDrawBack.isAddInOperateSuccess(); }else{ return false; @@ -97,9 +120,9 @@ public class ReserveServiceImpl implements ReserveService { String checkResult = Util.null2String(modeInfo.get(checkResultField)); int requestId = Util.getIntValue(Util.null2String(modeInfo.get(workflowInfoField))); if(checkResult.equals(checkResultValue)){ - forceOverList.add(requestId+""); - }else { doRepossessedList.add(requestId); + }else { + forceOverList.add(requestId+""); } } log.info(String.format("doRepossessedList ==> %s forceOverList ==> %s",doRepossessedList,forceOverList)); @@ -111,4 +134,91 @@ public class ReserveServiceImpl implements ReserveService { } return result; } + + @Override + public List> reserveTrigger(Map param) { + List> result = new ArrayList<>(); + String applicationNoField = Util.null2String(param.get("applicationNoField")); + String workflowInfoField = Util.null2String(param.get("workflowInfoField")); + String formId = Util.null2String(param.get("formId")); + List> modeList = reserveSelectMapper.queryModeList(param); + if(Objects.nonNull(modeList) && !modeList.isEmpty()){ + for (Map modeMap : modeList) { + Map dealResult = new HashMap<>(); + try{ + modeChangeService.changeOtherMode(modeMap,formId,2); + dealResult.put(Util.null2String(modeMap.get(applicationNoField)),true); + }catch (Exception e){ + log.error("执行异常 reserveTrigger error ==>"+modeMap); + dealResult.put(Util.null2String(modeMap.get(applicationNoField)),false); + } + result.add(dealResult); + } + reserveSelectMapper.updateModeDataStatus(param); + } + return result; + } + + @Override + public void batchDownload(Map param, OutputStream outputStream) throws IOException { + List sendList = queryMapper.queryDownloadList(param); + if(Objects.isNull(sendList) || sendList.isEmpty()){ + log.info("附件列表为空 attachment empty !!!"); + //throw new CustomerException("附件列表查询为空"); + return; + } + log.info("查询到的附件信息 query fileList ==>"+ JSON.toJSONString(sendList)); + // 1. 将 SendFileEntity 按照 departName 分组 + Map> sendMap = sendList.stream().collect(Collectors.groupingBy(SendFileEntity::getDepartName)); + // 2. 创建 ZipOutputStream + ZipOutputStream zipOutputStream = new ZipOutputStream(new BufferedOutputStream(outputStream)); + // 3. 遍历 SendFileEntity + for (Map.Entry> entry : sendMap.entrySet()) { + String departName = entry.getKey(); + List fileList = entry.getValue(); + // 4. 创建目录 + ZipEntry dirEntry = new ZipEntry(departName + File.separator); + zipOutputStream.putNextEntry(dirEntry); + // 5. 将附件信息合并成一个压缩包 + for (SendFileEntity sendFileEntity : fileList) { + WeaverFile fileMsg = sendFileEntity.getWeaverFile(); + int imageFileId = fileMsg.getImageFileId(); + String fileName = fileMsg.getFileName(); + String fileType = fileName.substring(fileName.lastIndexOf(".")); + String tempFileName = sendFileEntity.getRequestNumber() + fileType; + InputStream inputStream = ImageFileManager.getInputStreamById(imageFileId); + // 6. 将单个附件写入 ZipOutputStream + ZipEntry fileEntry = new ZipEntry(departName + File.separator + tempFileName); + zipOutputStream.putNextEntry(fileEntry); + + byte[] buffer = new byte[BUFFER_SIZE]; + int bytesRead = -1; + while ((bytesRead = inputStream.read(buffer)) != -1) { + zipOutputStream.write(buffer, 0, bytesRead); + } + inputStream.close(); + } + } + // 7. 关闭 ZipOutputStream + zipOutputStream.close(); + } + + @Override + public String getFileName(Map param) { + String fileName = ""; + List> selectItems = queryMapper.querySelectItem("uf_gjjtb", "sjpcdxk"); + if(Objects.nonNull(selectItems) && !selectItems.isEmpty()){ + Map map = selectItems.stream().collect(Collectors + .toMap( + item -> Util.null2String(item.get("selectvalue")), + item -> Util.null2String(item.get("selectname")) + ) + ); + String datePicker = Util.null2String(param.get("datePicker")); + String checkResultShow = new String(Util.null2String(param.get("checkResultShow")).getBytes(), StandardCharsets.UTF_8); + String datePickerShow = Util.null2String(map.get(datePicker)); + fileName = datePickerShow + checkResultShow; + } + return fileName; + } } diff --git a/src/main/java/com/api/interfaces/liyi/DataCenterApi.java b/src/main/java/com/api/interfaces/liyi/DataCenterApi.java index 3e68f9e..2f5fab0 100644 --- a/src/main/java/com/api/interfaces/liyi/DataCenterApi.java +++ b/src/main/java/com/api/interfaces/liyi/DataCenterApi.java @@ -103,6 +103,40 @@ public class DataCenterApi extends BaseBean { String tbr = rs.getString("field048"); String sfty = rs.getString("field069"); + /* update by bokang.xiao */ + //现居住地址 + String residentialAddress = rs.getString("field045"); + //现居地址邮编 + String residentialPostcode = rs.getString("field104"); + //家庭住址 + String familyAddress = rs.getString("field105"); + //法定联系地址 + String contactAddress = rs.getString("field106"); + //法定联系地址邮编 + String contactPostcode = rs.getString("field107"); + //紧急联系人地址 + String emergencyContactAddress = rs.getString("field108"); + //一寸照片 + String headPicture = rs.getString("field109"); + //公积金账户及所在城市 + String providentFundAccount = rs.getString("field110"); + //开户行 + String openingBank = rs.getString("field111"); + //银行卡号 + String bankCardNo = rs.getString("field112"); + + comMap.put("residentialAddress",residentialAddress); + comMap.put("residentialPostcode",residentialPostcode); + comMap.put("familyAddress",familyAddress); + comMap.put("contactAddress",contactAddress); + comMap.put("contactPostcode",contactPostcode); + comMap.put("emergencyContactAddress",emergencyContactAddress); + comMap.put("providentFundAccount",providentFundAccount); + comMap.put("openingBank",openingBank); + comMap.put("bankCardNo",bankCardNo); + comMap.put("headPicture",headPicture); + /* update by bokang.xiao */ + comMap.put("ypgw",ypgw); comMap.put("ypgw_xz",ypgw_xz); comMap.put("djrq",djrq); diff --git a/src/main/java/com/api/nonstandardext/zenner/utils/ZennerUtil.java b/src/main/java/com/api/nonstandardext/zenner/utils/ZennerUtil.java index af3749e..9497e2e 100644 --- a/src/main/java/com/api/nonstandardext/zenner/utils/ZennerUtil.java +++ b/src/main/java/com/api/nonstandardext/zenner/utils/ZennerUtil.java @@ -1,6 +1,5 @@ package com.api.nonstandardext.zenner.utils; -import com.api.nonstandardext.allist.utils.DefaultTmForAllist; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import org.apache.commons.httpclient.HttpClient; @@ -178,49 +177,6 @@ public class ZennerUtil { return result; } - public static String httpsGet(String baseUrl,String encoderNum) { - BufferedReader in = null; - BaseBean baseBean = new BaseBean(); - try { - SSLContext sslContext = SSLContext.getInstance("TLSv1.2"); - javax.net.ssl.TrustManager[] truset = new javax.net.ssl.TrustManager[1]; - javax.net.ssl.TrustManager tm = new DefaultTmForAllist(); - truset[0] = tm; - sslContext.init(null, truset, null); - SSLSocketFactory factory = sslContext.getSocketFactory(); - URL u = new URL(baseUrl); - HttpsURLConnection huconn = (HttpsURLConnection) u.openConnection(); - huconn.setSSLSocketFactory(factory); - huconn.setRequestProperty("Authorization","Basic " + encoderNum); - StringBuilder result = new StringBuilder(); - huconn.connect(); -// baseBean.writeLog("httpsGet execute baseUrl..1." + baseUrl); - in = new BufferedReader(new InputStreamReader(huconn.getInputStream(), "UTF-8")); - String line; - while ((line = in.readLine()) != null) { - result.append(line); - } - if (in != null) { - in.close(); - } -// baseBean.writeLog("httpsGet execute result..1." + result.toString()); - // 打印返回结果 - return result.toString(); - } catch (Exception e) { - baseBean.writeLog("httpsGet execute exception...message:" + e.getMessage()); - if (in != null) { - try { - in.close(); - } catch (IOException ioException) { - ioException.printStackTrace(); - baseBean.writeLog("关闭报错"); - baseBean.writeLog(ioException.getMessage()); - } - } - return ""; - } - } - public static String httpGet(String baseUrl){ String url = baseUrl; @@ -244,38 +200,6 @@ public class ZennerUtil { } } - public static String httpsPost(String httpUrl, String content) throws Exception { - BufferedReader in = null; - SSLContext sslContext = SSLContext.getInstance("TLSv1.2"); - javax.net.ssl.TrustManager [] truset = new javax.net.ssl.TrustManager[1]; - javax.net.ssl.TrustManager tm = new DefaultTmForAllist(); - truset[0] = tm; - sslContext.init(null,truset,null); - SSLSocketFactory factory = sslContext.getSocketFactory(); -//https://blog.csdn.net/pk5454754/article/details/80092974?utm_medium=distribute.pc_relevant_download.none-task-blog-baidujs-1.nonecase&depth_1-utm_source=distribute.pc_relevant_download.none-task-blog-baidujs-1.nonecase - URL u = new URL(httpUrl); - HttpsURLConnection conn = (HttpsURLConnection) u.openConnection(); - conn.setDoOutput(true); - conn.addRequestProperty("connection", "Keep-Alive"); - conn.setRequestMethod("POST"); - conn.setSSLSocketFactory(factory); - StringBuilder result = new StringBuilder(); - conn.connect(); - DataOutputStream out = new DataOutputStream(conn.getOutputStream()); - out.write(content.getBytes("utf-8")); - // 刷新、关闭 - out.flush(); - out.close(); - in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8")); - String line; - while ((line = in.readLine()) != null) { - result.append(line); - } - if (in != null) { - in.close(); - } - return result.toString(); - } public static String httpPostForXwwwForm(String httpUrl, Map headParams, Map paramsMap){ String result = ""; @@ -312,7 +236,7 @@ public class ZennerUtil { */ public static int getQuarter() { Calendar c = Calendar.getInstance(); - int month = c.get(c.MONTH) + 1; + int month = c.get(Calendar.MONTH) + 1; int quarter = 0; if (month >= 1 && month <= 3) { quarter = 1; diff --git a/src/main/java/com/engine/hrm/cmd/departmentfielddefined/GetFieldDefinedCmd.java b/src/main/java/com/engine/hrm/cmd/departmentfielddefined/GetFieldDefinedCmd.java index 0fc9e5b..6ac4a3a 100644 --- a/src/main/java/com/engine/hrm/cmd/departmentfielddefined/GetFieldDefinedCmd.java +++ b/src/main/java/com/engine/hrm/cmd/departmentfielddefined/GetFieldDefinedCmd.java @@ -5,6 +5,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import com.alibaba.fastjson.JSON; import com.cloudstore.dev.api.util.TextUtil; import com.engine.common.biz.AbstractCommonCommand; import com.engine.common.biz.EncryptConfigBiz; @@ -12,6 +13,8 @@ import com.engine.common.entity.BizLogContext; import com.engine.common.entity.EncryptFieldEntity; import com.engine.common.enums.EncryptMould; import com.engine.core.interceptor.CommandContext; +import org.apache.log4j.Logger; +import weaver.bokang.xiao.tbxc.mapper.FormFieldMapper; import weaver.conn.RecordSet; import weaver.general.LabelUtil; import weaver.general.Util; @@ -31,6 +34,10 @@ import weaver.workflow.field.BrowserComInfo; public class GetFieldDefinedCmd extends AbstractCommonCommand> { + private final FormFieldMapper formFieldMapper = aiyh.utils.Util.getMapper(FormFieldMapper.class); + + private final Logger log = aiyh.utils.Util.getLogger(); + public GetFieldDefinedCmd(Map params, User user) { this.user = user; this.params = params; @@ -190,6 +197,14 @@ public class GetFieldDefinedCmd extends AbstractCommonCommand groupId:%s fieldId:%s",groupId,fieldid)); + if(groupId == 6 || groupId == 7) { + recordInfo.put("isEdit", formFieldMapper.queryIsEdit(fieldid, groupId)); + } + log.info("recordInfo ==>"+ JSON.toJSONString(recordInfo)); + if (encryptEnable && ((fieldhtmltype.equals("1")||fieldhtmltype.equals("2")) && !issystem.equals("1")) ) { //只支持单行文本,多行文本 String tablename = "hrmdepartmentdefined"; diff --git a/src/main/java/com/engine/hrm/cmd/departmentfielddefined/SaveFieldDefinedCmd.java b/src/main/java/com/engine/hrm/cmd/departmentfielddefined/SaveFieldDefinedCmd.java index 6a55493..54d479e 100644 --- a/src/main/java/com/engine/hrm/cmd/departmentfielddefined/SaveFieldDefinedCmd.java +++ b/src/main/java/com/engine/hrm/cmd/departmentfielddefined/SaveFieldDefinedCmd.java @@ -17,6 +17,8 @@ import com.engine.core.interceptor.CommandContext; import com.engine.hrm.entity.FieldBean; import com.engine.hrm.entity.FieldSelectOptionBean; import com.engine.hrm.util.HrmUtil; +import org.apache.log4j.Logger; +import weaver.bokang.xiao.tbxc.mapper.FormFieldMapper; import weaver.conn.RecordSet; import weaver.docs.docs.FieldParam; import weaver.general.LabelUtil; @@ -38,6 +40,10 @@ public class SaveFieldDefinedCmd extends AbstractCommonCommand params, User user) { this.user = user; this.params = params; @@ -121,7 +127,13 @@ public class SaveFieldDefinedCmd extends AbstractCommonCommand"+groupId); + if("6".equals(groupId) || "7".equals(groupId)){ + this.save(fieldBean,groupId,records.getJSONObject(i)); + }else { + this.save(fieldBean, groupId); + } } HrmFieldComInfo.removeFieldCache(); @@ -135,7 +147,84 @@ public class SaveFieldDefinedCmd extends AbstractCommonCommand保存更新方法

+ * @author bokang.xiao + * @param fieldBean 字段信息实体类 + * @param groupId 组id + * @param fieldJson 字段JSON信息 + */ + private void save(FieldBean fieldBean, String groupId,JSONObject fieldJson){ + try { + HrmUtil hrmUtil = new HrmUtil(); + HrmDeptFieldManagerE9 hfm = new HrmDeptFieldManagerE9(5); + + String fieldId = Util.null2String(fieldBean.getId()); + String fieldLabel = Util.null2String(fieldBean.getFieldlabel()); + String fieldName = Util.null2String(fieldBean.getFieldname()); + String fieldHtmlType = ""; + String type = ""; + String typeDetial = ""; + String dmlUrl = ""; + if(fieldBean.getFieldTypeBean()!=null){ + fieldHtmlType = Util.null2String(fieldBean.getFieldTypeBean().getFieldHtmlType()); + type = Util.null2String(fieldBean.getFieldTypeBean().getFieldType()); + if(fieldHtmlType.equals("1")||fieldHtmlType.equals("2")){ + typeDetial = Util.null2String(fieldBean.getFieldTypeBean().getOtherParam()); + }else if(fieldHtmlType.equals("66") || fieldHtmlType.equals("67")){ + dmlUrl = Util.null2String(fieldBean.getFieldTypeBean().getOtherParam()); + } else if (type.equals("161") || type.equals("162") || type.equals("256")|| type.equals("257")) { + dmlUrl = Util.null2String(fieldBean.getFieldTypeBean().getOtherParam()); + } + } + + String isUse = Util.null2String(fieldBean.getEnable(),"0"); + String isMand = Util.null2String(fieldBean.getRequired(),"0"); + String fieldOrder = Util.null2String(fieldBean.getKey()); + + int temId = Util.getIntValue(fieldId,-1); + //int lableid = hrmUtil.getFieldLabelId(fieldLabel); + int lableid = new LabelUtil().getLabelId(fieldLabel); + + if(Util.null2String(fieldId).length()==0){ + FieldParam fp = new FieldParam(); + if(fieldHtmlType.equals("1")){ + fp.setSimpleText(Util.getIntValue(type,-1),typeDetial); + }else if(fieldHtmlType.equals("2")){ + fp.setText(); + }else if(fieldHtmlType.equals("3")){ + fp.setBrowser(Util.getIntValue(type,-1)); + }else if(fieldHtmlType.equals("4")){ + fp.setCheck(); + }else if(fieldHtmlType.equals("5")){ + fp.setSelect(); + }else if(fieldHtmlType.equals("6")){ + fp.setAttach(); + } + + temId = hfm.addField(fieldName, fp.getFielddbtype(), fieldHtmlType, type, ""+lableid, fieldOrder, isMand, isUse, groupId, dmlUrl); + //添加字段值isEdit + String isEdit = Util.null2String(fieldJson.getString("isEdit"),"1"); + formFieldMapper.updateHrmFormField(isEdit,temId+"",groupId); + }else{ + //只允许更改显示属性,数据库层面的不允许修改 + hfm.editField(fieldId, ""+lableid, fieldOrder, isMand, isUse, groupId); + //添加字段值isEdit + String isEdit = Util.null2String(fieldJson.getString("isEdit"),"1"); + formFieldMapper.updateHrmFormField(isEdit,fieldId,groupId); + } + + if(fieldHtmlType.equals("5")){ + List lsSelectOption = fieldBean.getFieldTypeBean().getLsSelectOption(); + hfm.checkSelectField(temId, lsSelectOption); + } + }catch (Exception e) { + writeLog(e); + } + } + + private void save(FieldBean fieldBean, String groupId){ try { HrmUtil hrmUtil = new HrmUtil(); diff --git a/src/main/java/com/engine/hrm/cmd/organization/GetDepartmentFormFieldCmd.java b/src/main/java/com/engine/hrm/cmd/organization/GetDepartmentFormFieldCmd.java index f32e54e..5dd2b6e 100644 --- a/src/main/java/com/engine/hrm/cmd/organization/GetDepartmentFormFieldCmd.java +++ b/src/main/java/com/engine/hrm/cmd/organization/GetDepartmentFormFieldCmd.java @@ -5,6 +5,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import weaver.bokang.xiao.tbxc.mapper.FormFieldMapper; import weaver.general.Util; import weaver.hrm.User; import weaver.hrm.company.DepartmentComInfo; @@ -24,6 +25,8 @@ import com.engine.hrm.util.HrmOrganizationUtil; public class GetDepartmentFormFieldCmd extends AbstractCommonCommand> { + private final FormFieldMapper formFieldMapper = aiyh.utils.Util.getMapper(FormFieldMapper.class); + public GetDepartmentFormFieldCmd(Map params, User user) { this.user = user; this.params = params; @@ -84,6 +87,13 @@ public class GetDepartmentFormFieldCmd extends AbstractCommonCommand> { + private final FormFieldMapper formFieldMapper = aiyh.utils.Util.getMapper(FormFieldMapper.class); + public GetSubCompanyFormFieldCmd(Map params, User user) { this.user = user; this.params = params; @@ -74,7 +78,15 @@ public class GetSubCompanyFormFieldCmd extends AbstractCommonCommand> { + private final FormFieldMapper formFieldMapper = aiyh.utils.Util.getMapper(FormFieldMapper.class); + + private final Logger log = aiyh.utils.Util.getLogger(); + public GetFieldDefinedCmd(Map params, User user) { this.user = user; this.params = params; @@ -191,6 +198,14 @@ public class GetFieldDefinedCmd extends AbstractCommonCommand groupId:%s fieldId:%s",groupId,fieldid)); + if(groupId == 6 || groupId == 7) { + recordInfo.put("isEdit", formFieldMapper.queryIsEdit(fieldid, groupId)); + } + log.info("recordInfo ==>"+ JSON.toJSONString(recordInfo)); + if (encryptEnable && ((fieldhtmltype.equals("1")||fieldhtmltype.equals("2")) && !issystem.equals("1")) ) { //只支持单行文本,多行文本 String tablename = "hrmsubcompanydefined"; diff --git a/src/main/java/com/engine/hrm/cmd/subcompanyfielddefined/SaveFieldDefinedCmd.java b/src/main/java/com/engine/hrm/cmd/subcompanyfielddefined/SaveFieldDefinedCmd.java index 37b0455..ec53258 100644 --- a/src/main/java/com/engine/hrm/cmd/subcompanyfielddefined/SaveFieldDefinedCmd.java +++ b/src/main/java/com/engine/hrm/cmd/subcompanyfielddefined/SaveFieldDefinedCmd.java @@ -17,6 +17,8 @@ import com.engine.core.interceptor.CommandContext; import com.engine.hrm.entity.FieldBean; import com.engine.hrm.entity.FieldSelectOptionBean; import com.engine.hrm.util.HrmUtil; +import org.apache.log4j.Logger; +import weaver.bokang.xiao.tbxc.mapper.FormFieldMapper; import weaver.conn.RecordSet; import weaver.docs.docs.FieldParam; import weaver.general.LabelUtil; @@ -36,6 +38,10 @@ import weaver.systeminfo.SystemEnv; */ public class SaveFieldDefinedCmd extends AbstractCommonCommand>{ + private final FormFieldMapper formFieldMapper = aiyh.utils.Util.getMapper(FormFieldMapper.class); + + private final Logger log = aiyh.utils.Util.getLogger(); + private SimpleBizLogger logger; public SaveFieldDefinedCmd(Map params, User user) { @@ -120,7 +126,13 @@ public class SaveFieldDefinedCmd extends AbstractCommonCommand"+groupId); + if("6".equals(groupId) || "7".equals(groupId)){ + this.save(fieldBean,groupId,records.getJSONObject(i)); + }else { + this.save(fieldBean, groupId); + } } HrmFieldComInfo.removeFieldCache(); //同步分部数据到矩阵 @@ -133,7 +145,84 @@ public class SaveFieldDefinedCmd extends AbstractCommonCommand保存更新方法 + * @author bokang.xiao + * @param fieldBean 字段信息实体类 + * @param groupId 组id + * @param fieldJson 字段JSON信息 + */ + private void save(FieldBean fieldBean, String groupId,JSONObject fieldJson){ + try { + HrmUtil hrmUtil = new HrmUtil(); + HrmDeptFieldManagerE9 hfm = new HrmDeptFieldManagerE9(4); + + String fieldId = Util.null2String(fieldBean.getId()); + String fieldLabel = Util.null2String(fieldBean.getFieldlabel()); + String fieldName = Util.null2String(fieldBean.getFieldname()); + String fieldHtmlType = ""; + String type = ""; + String typeDetial = ""; + String dmlUrl = ""; + if(fieldBean.getFieldTypeBean()!=null){ + fieldHtmlType = Util.null2String(fieldBean.getFieldTypeBean().getFieldHtmlType()); + type = Util.null2String(fieldBean.getFieldTypeBean().getFieldType()); + if(fieldHtmlType.equals("1")||fieldHtmlType.equals("2")){ + typeDetial = Util.null2String(fieldBean.getFieldTypeBean().getOtherParam()); + } else if(fieldHtmlType.equals("66") || fieldHtmlType.equals("67")){ + dmlUrl = Util.null2String(fieldBean.getFieldTypeBean().getOtherParam()); + } else if (type.equals("161") || type.equals("162") || type.equals("256")|| type.equals("257")) { + dmlUrl = Util.null2String(fieldBean.getFieldTypeBean().getOtherParam()); + } + } + + String isUse = Util.null2String(fieldBean.getEnable(),"0"); + String isMand = Util.null2String(fieldBean.getRequired(),"0"); + String fieldOrder = Util.null2String(fieldBean.getKey()); + + int temId = Util.getIntValue(fieldId,-1); + //int lableid = hrmUtil.getFieldLabelId(fieldLabel); + int lableid = new LabelUtil().getLabelId(fieldLabel); + + if(Util.null2String(fieldId).length()==0){ + FieldParam fp = new FieldParam(); + if(fieldHtmlType.equals("1")){ + fp.setSimpleText(Util.getIntValue(type,-1),typeDetial); + }else if(fieldHtmlType.equals("2")){ + fp.setText(); + }else if(fieldHtmlType.equals("3")){ + fp.setBrowser(Util.getIntValue(type,-1)); + }else if(fieldHtmlType.equals("4")){ + fp.setCheck(); + }else if(fieldHtmlType.equals("5")){ + fp.setSelect(); + }else if(fieldHtmlType.equals("6")){ + fp.setAttach(); + } + + temId = hfm.addField(fieldName, fp.getFielddbtype(), fieldHtmlType, type, ""+lableid, fieldOrder, isMand, isUse, groupId, dmlUrl); + //添加字段值isEdit + String isEdit = Util.null2String(fieldJson.getString("isEdit"),"1"); + formFieldMapper.updateHrmFormField(isEdit,temId+"",groupId); + }else{ + //只允许更改显示属性,数据库层面的不允许修改 + hfm.editField(fieldId, ""+lableid, fieldOrder, isMand, isUse, groupId); + //添加字段值isEdit + String isEdit = Util.null2String(fieldJson.getString("isEdit"),"1"); + formFieldMapper.updateHrmFormField(isEdit,fieldId,groupId); + } + + if(fieldHtmlType.equals("5")){ + List lsSelectOption = fieldBean.getFieldTypeBean().getLsSelectOption(); + hfm.checkSelectField(temId, lsSelectOption); + } + }catch (Exception e) { + writeLog(e); + } + } + + private void save(FieldBean fieldBean, String groupId){ try { HrmUtil hrmUtil = new HrmUtil(); diff --git a/src/main/java/weaver/bokang/xiao/tbxc/mapper/FormFieldMapper.java b/src/main/java/weaver/bokang/xiao/tbxc/mapper/FormFieldMapper.java index 8b82f66..45ee62a 100644 --- a/src/main/java/weaver/bokang/xiao/tbxc/mapper/FormFieldMapper.java +++ b/src/main/java/weaver/bokang/xiao/tbxc/mapper/FormFieldMapper.java @@ -1,8 +1,38 @@ -package weaver.bokang.xiao.tbxc.mapper;/** - *@ClassName FormFieldMapper - *@Author 肖博亢 - *@Date 2023/4/26 17:22 - *@Description

+package weaver.bokang.xiao.tbxc.mapper; + +import aiyh.utils.annotation.recordset.ParamMapper; +import aiyh.utils.annotation.recordset.Select; +import aiyh.utils.annotation.recordset.SqlMapper; +import aiyh.utils.annotation.recordset.Update; + +/** + * @ClassName FormFieldMapper + * @Author 肖博亢 + * @Date 2023/4/26 17:22 + * @Description

**/ -public class FormFieldMapper { +@SqlMapper +public interface FormFieldMapper { + + /** + *

更新字段列信息

+ * @param isEdit 值信息 + * @param formFieldId 字段id + * @param groupId 组id + * @return 更新结果 + */ + @Update("update hrm_formfield set is_edit = #{isEdit} where fieldid = #{formFieldId} and groupid = #{groupId}") + boolean updateHrmFormField(@ParamMapper("isEdit") String isEdit, + @ParamMapper("formFieldId") String formFieldId, + @ParamMapper("groupId") String groupId); + + /** + *

查询isEdit的值

+ * @param formFieldId 字段id + * @param groupId 组id + * @return 值 + */ + @Select("select is_edit from hrm_formfield where fieldid = #{formFieldId} and groupid = #{groupId}") + String queryIsEdit(@ParamMapper("formFieldId") String formFieldId, + @ParamMapper("groupId") int groupId); } diff --git a/src/main/java/weaver/bokang/xiao/zscq/config/entity/AssignmentEntity.java b/src/main/java/weaver/bokang/xiao/zscq/config/entity/AssignmentEntity.java index 9f01e39..5e1b59a 100644 --- a/src/main/java/weaver/bokang/xiao/zscq/config/entity/AssignmentEntity.java +++ b/src/main/java/weaver/bokang/xiao/zscq/config/entity/AssignmentEntity.java @@ -1,5 +1,6 @@ package weaver.bokang.xiao.zscq.config.entity; +import aiyh.utils.annotation.recordset.SqlOracleDbFieldAnn; import lombok.Data; /** @@ -12,20 +13,26 @@ import lombok.Data; public class AssignmentEntity { /** 赋值字段 */ + @SqlOracleDbFieldAnn("ASSIGNMENT_FIELD") private String assignmentField; /** 值选择 */ + @SqlOracleDbFieldAnn("VALUE_SELECT") private Integer valueSelect; /** 源字段 */ + @SqlOracleDbFieldAnn("SOURCE_FIELD") private String sourceField; /** 赋值字段名 */ + @SqlOracleDbFieldAnn("ASSIGNMENT_FIELD_NAME") private String assignmentFieldName; /** 源字段名 */ + @SqlOracleDbFieldAnn("SOURCE_FIELD_NAME") private String sourceFieldName; /** 文本框 */ - private String context; + @SqlOracleDbFieldAnn("CUS_CONTEXT") + private String cusContext; } diff --git a/src/main/java/weaver/bokang/xiao/zscq/config/entity/ConditionEntity.java b/src/main/java/weaver/bokang/xiao/zscq/config/entity/ConditionEntity.java index 4509aea..afe6fff 100644 --- a/src/main/java/weaver/bokang/xiao/zscq/config/entity/ConditionEntity.java +++ b/src/main/java/weaver/bokang/xiao/zscq/config/entity/ConditionEntity.java @@ -1,5 +1,6 @@ package weaver.bokang.xiao.zscq.config.entity; +import aiyh.utils.annotation.recordset.SqlOracleDbFieldAnn; import lombok.Data; /** @@ -12,26 +13,34 @@ import lombok.Data; public class ConditionEntity { /** 条件类型 */ + @SqlOracleDbFieldAnn("CONDITION_TYPE") private Integer conditionType; /** 条件 */ + @SqlOracleDbFieldAnn("CONDITION_VALUE") private Integer conditionValue; /** 源字段 */ + @SqlOracleDbFieldAnn("CONDITION_SOURCE_FIELD") private String conditionSourceField; /** 值类型 */ + @SqlOracleDbFieldAnn("VALUE_TYPE") private Integer valueType; /** 目标字段 */ + @SqlOracleDbFieldAnn("CONDITION_TARGET_FIELD") private String conditionTargetField; /** 源字段名 */ + @SqlOracleDbFieldAnn("CONDITION_SOURCE_FIELD_NAME") private String conditionSourceFieldName; /** 目标字段名 */ + @SqlOracleDbFieldAnn("CONDITION_TARGET_FIELD_NAME") private String conditionTargetFieldName; /** 文本框 */ + @SqlOracleDbFieldAnn("CUS_TEXT") private String cusText; } diff --git a/src/main/java/weaver/bokang/xiao/zscq/config/entity/UpdateModeConf.java b/src/main/java/weaver/bokang/xiao/zscq/config/entity/UpdateModeConf.java index 8489d61..e859310 100644 --- a/src/main/java/weaver/bokang/xiao/zscq/config/entity/UpdateModeConf.java +++ b/src/main/java/weaver/bokang/xiao/zscq/config/entity/UpdateModeConf.java @@ -1,5 +1,6 @@ package weaver.bokang.xiao.zscq.config.entity; +import aiyh.utils.annotation.recordset.SqlOracleDbFieldAnn; import lombok.Data; import java.util.List; @@ -14,30 +15,39 @@ import java.util.List; public class UpdateModeConf { /** 源建模 */ + @SqlOracleDbFieldAnn("SOURCE_MODE") private String sourceMode; /** 触发建模 */ + @SqlOracleDbFieldAnn("TARGET_MODE") private String targetMode; /** 说明 */ + @SqlOracleDbFieldAnn("DESCRIPTION") private String description; /** 唯一标识 */ + @SqlOracleDbFieldAnn("UNIQUE_CODE") private String uniqueCode; /** 源表名 */ + @SqlOracleDbFieldAnn("SOURCE_TABLE_NAME") private String sourceTableName; /** 触发表名 */ + @SqlOracleDbFieldAnn("TARGET_TABLE_NAME") private String targetTableName; /** 数据写入方式 */ + @SqlOracleDbFieldAnn("DATA_IN_TYPE") private Integer dataInType; /** 自定义操作类全路径 */ + @SqlOracleDbFieldAnn("OPERATE_PATH") private String operatePath; /** 无条件触发 */ + @SqlOracleDbFieldAnn("NO_RULE") private Integer noRule; /** 条件列表 */ diff --git a/src/main/java/weaver/bokang/xiao/zscq/config/mapper/UpdateModeMapper.java b/src/main/java/weaver/bokang/xiao/zscq/config/mapper/UpdateModeMapper.java index 8c9dd44..bb68a40 100644 --- a/src/main/java/weaver/bokang/xiao/zscq/config/mapper/UpdateModeMapper.java +++ b/src/main/java/weaver/bokang/xiao/zscq/config/mapper/UpdateModeMapper.java @@ -29,6 +29,17 @@ public interface UpdateModeMapper { }) List queryUpdateModeConfByFormId(@ParamMapper("formId")String formId); + /** + *

通过formId查询相关配置信息

+ * @return 配置列表 + */ + @Select("select * from uf_update_mode_conf") + @CollectionMappings({ + @CollectionMapping(property = "conditionList", column = "id", id = @Id(value = Integer.class, methodId = 1)), + @CollectionMapping(property = "assignmentList", column = "id", id = @Id(value = Integer.class, methodId = 2)), + }) + List queryUpdateModeConf(); + /** *

查询条件列表

* @param mainId 主数据id diff --git a/src/main/java/weaver/bokang/xiao/zscq/config/process/ConditionTargetProcess.java b/src/main/java/weaver/bokang/xiao/zscq/config/process/ConditionTargetProcess.java index 0161001..12d66eb 100644 --- a/src/main/java/weaver/bokang/xiao/zscq/config/process/ConditionTargetProcess.java +++ b/src/main/java/weaver/bokang/xiao/zscq/config/process/ConditionTargetProcess.java @@ -71,13 +71,61 @@ public class ConditionTargetProcess { */ @MethodRuleNo(value = 1, desc = "不等于") public static String noEquals(Map whereParam,Map param,String whereSql) { - String sourceFieldName = Util.null2String(param.get("sourceValue")); String conditionValue = Util.null2String(param.get("conditionValue")); String targetFieldName = Util.null2String(param.get("targetFieldName")); - String targetStr = " and "+sourceFieldName+" <> #{whereParam."+targetFieldName+"}"; + String targetStr = " and "+targetFieldName+" <> #{whereParam."+targetFieldName+"}"; whereSql += targetStr; whereParam.put(targetFieldName,conditionValue); return whereSql; } + /** + *

目标建模不等于处理方法

+ * @param whereParam 条件参数 + * @param param 参数信息 + * @param whereSql 条件sql + * @return 条件sql + */ + @MethodRuleNo(value = 6, desc = "in") + public static String in(Map whereParam,Map param,String whereSql) { + String conditionValue = Util.null2String(param.get("conditionValue")); + String targetFieldName = Util.null2String(param.get("targetFieldName")); + String targetStr = " and "+targetFieldName+" in ( $t{whereParam."+targetFieldName+"})"; + whereSql += targetStr; + whereParam.put(targetFieldName,conditionValue); + return whereSql; + } + + /** + *

目标建模不等于处理方法

+ * @param whereParam 条件参数 + * @param param 参数信息 + * @param whereSql 条件sql + * @return 条件sql + */ + @MethodRuleNo(value = 7, desc = "not in") + public static String notIn(Map whereParam,Map param,String whereSql) { + String conditionValue = Util.null2String(param.get("conditionValue")); + String targetFieldName = Util.null2String(param.get("targetFieldName")); + String targetStr = " and "+targetFieldName+" not in ( $t{whereParam."+targetFieldName+"})"; + whereSql += targetStr; + whereParam.put(targetFieldName,conditionValue); + return whereSql; + } + + /** + *

目标建模不等于处理方法

+ * @param whereParam 条件参数 + * @param param 参数信息 + * @param whereSql 条件sql + * @return 条件sql + */ + @MethodRuleNo(value = 8, desc = "自定义sql") + public static String cusSql(Map whereParam,Map param,String whereSql) { + String conditionValue = Util.null2String(param.get("conditionValue")); + String targetStr = " and "+Util.sbc2dbcCase(conditionValue); + whereSql += targetStr; + return whereSql; + } + } diff --git a/src/main/java/weaver/bokang/xiao/zscq/config/process/ConditionValueProcess.java b/src/main/java/weaver/bokang/xiao/zscq/config/process/ConditionValueProcess.java index f05f074..f99c2af 100644 --- a/src/main/java/weaver/bokang/xiao/zscq/config/process/ConditionValueProcess.java +++ b/src/main/java/weaver/bokang/xiao/zscq/config/process/ConditionValueProcess.java @@ -67,5 +67,32 @@ public class ConditionValueProcess { return !sourceValue.equals(value); } + /** + *

源建模不等于处理方法

+ * @param sourceValue 源建模值 + * @param value 目标值 + * @return 是否符合 + */ + @MethodRuleNo(value = 6, desc = "in") + public static boolean in(String sourceValue, String value) { + if("".equals(sourceValue) || "".equals(value)){ + return false; + } + String tempStr = ","+value+","; + sourceValue = "," + sourceValue + ","; + return tempStr.contains(sourceValue); + } + + /** + *

源建模不等于处理方法

+ * @param sourceValue 源建模值 + * @param value 目标值 + * @return 是否符合 + */ + @MethodRuleNo(value = 7, desc = "not in") + public static boolean notIn(String sourceValue, String value) { + return !in(sourceValue, value); + } + } diff --git a/src/main/java/weaver/bokang/xiao/zscq/config/process/DataTypeProcess.java b/src/main/java/weaver/bokang/xiao/zscq/config/process/DataTypeProcess.java index 55f2086..cac75ee 100644 --- a/src/main/java/weaver/bokang/xiao/zscq/config/process/DataTypeProcess.java +++ b/src/main/java/weaver/bokang/xiao/zscq/config/process/DataTypeProcess.java @@ -69,7 +69,7 @@ public class DataTypeProcess { whereSql = whereSql.replaceFirst(" and "," where "); } updateSql = updateSql + whereSql; - logger.info("updateSql ==>"+updateSql); + logger.info(String.format("updateSql ==> %s updateParam ==> %s whereParam ==> %s",updateSql,updateParam,whereParam)); return UPDATE_MODE_MAPPER.executeUpdateCusSql(updateSql, updateParam, whereParam); } @@ -90,7 +90,7 @@ public class DataTypeProcess { String updateSql = buildUpdateSql(tableName, updateParam); String whereSql = DataTypeProcess.buildWhereSql(whereParam); updateSql = updateSql + " " + whereSql; - logger.info("updateSql ==>"+updateSql); + logger.info(String.format("updateSql ==> %s updateParam ==> %s whereParam ==> %s",updateSql,updateParam,whereParam)); return UPDATE_MODE_MAPPER.executeUpdateCusSql(updateSql,updateParam,whereParam); } @@ -142,6 +142,30 @@ public class DataTypeProcess { return insert(updateParam,whereParam,param) && cusOperate(updateParam,whereParam,param); } + /** + *

更新并执行自定义处理方法

+ * @param updateParam 更新参数 + * @param whereParam 条件参数 + * @param param 表参数 + * @return 执行结果 + */ + @MethodRuleNo(value = 5,desc = "执行自定义操作并更新") + public static boolean updateAndCus(Map updateParam, Map whereParam,Map param) { + return cusOperate(updateParam,whereParam,param) && update(updateParam,whereParam,param); + } + + /** + *

插入并执行自定义处理方法

+ * @param updateParam 更新参数 + * @param whereParam 条件参数 + * @param param 表参数 + * @return 执行结果 + */ + @MethodRuleNo(value = 6,desc = "执行自定义操作并插入") + public static boolean insertAndCus(Map updateParam, Map whereParam,Map param) { + return cusOperate(updateParam,whereParam,param) && insert(updateParam,whereParam,param); + } + /** *

构建更新sql语句

* @param tableName 表名 diff --git a/src/main/java/weaver/bokang/xiao/zscq/config/process/ValueSelectProcess.java b/src/main/java/weaver/bokang/xiao/zscq/config/process/ValueSelectProcess.java index e0a570c..318b1cc 100644 --- a/src/main/java/weaver/bokang/xiao/zscq/config/process/ValueSelectProcess.java +++ b/src/main/java/weaver/bokang/xiao/zscq/config/process/ValueSelectProcess.java @@ -60,7 +60,7 @@ public class ValueSelectProcess { */ @MethodRuleNo(value = 0, desc = "默认值") public static String defaultValue(Map modeMap,AssignmentEntity assignment) { - return assignment.getContext(); + return assignment.getCusContext(); } /** @@ -82,7 +82,7 @@ public class ValueSelectProcess { */ @MethodRuleNo(value = 2, desc = "自定义sql") public static String cusSql(Map modeMap,AssignmentEntity assignment) { - String cusSqlStr = Util.null2String(assignment.getContext()); + String cusSqlStr = Util.null2String(assignment.getCusContext()); cusSqlStr = Util.dbc2sbcCase(cusSqlStr); if(StringUtils.isBlank(cusSqlStr)){ throw new CustomerException("选择自定义sql时,sql字符串不能为空"); diff --git a/src/main/java/weaver/bokang/xiao/zscq/config/service/ModeChangeService.java b/src/main/java/weaver/bokang/xiao/zscq/config/service/ModeChangeService.java index 3d3e562..b7e920b 100644 --- a/src/main/java/weaver/bokang/xiao/zscq/config/service/ModeChangeService.java +++ b/src/main/java/weaver/bokang/xiao/zscq/config/service/ModeChangeService.java @@ -9,6 +9,7 @@ import weaver.bokang.xiao.zscq.config.entity.UpdateModeConf; import weaver.bokang.xiao.zscq.config.function.ConditionFunction; import weaver.bokang.xiao.zscq.config.mapper.UpdateModeMapper; import weaver.bokang.xiao.zscq.config.process.*; +import weaver.bokang.xiao.zscq.store.TableNameStore; import java.util.HashMap; import java.util.List; @@ -33,23 +34,39 @@ public class ModeChangeService { *

更新其他建模信息

* @param modeMap 模块数据 * @param formId 表单id + * @param triggerType 触发方式 0:无条件触发; 1:建模更新触发; 2:其他触发 */ - public void changeOtherMode(Map modeMap, String formId){ - List updateModeConfList = updateModeMapper.queryUpdateModeConfByFormId(formId); + public void changeOtherMode(Map modeMap, String formId,int triggerType){ + Map> triggerStore = TableNameStore.getInstance().getTriggerStore(); + List updateModeConfList = triggerStore.get(formId); if(Objects.isNull(updateModeConfList) || updateModeConfList.isEmpty()){ logger.error(String.format("此表单建模[%s] 未配置相关更新信息,请检查!!!",formId)); return; } - logger.info("配置信息 updateModeConfList==>"+ JSON.toJSONString(updateModeConfList)); + List collect = updateModeConfList.stream().filter(item -> item.getNoRule() == triggerType).collect(Collectors.toList()); + if(collect.isEmpty()){ + logger.error(String.format("此表单建模[%s] 未配置相关更新信息,请检查!!!",formId)); + return; + } + doChange(modeMap,collect); + } + + /** + *

更新其他表数据的具体方法

+ * @param modeMap 源建模数据 + * @param updateModeConfList 配置参数列表 + */ + private void doChange(Map modeMap,List updateModeConfList){ for (UpdateModeConf updateModeConf : updateModeConfList) { List conditionList = updateModeConf.getConditionList(); List assignmentList = updateModeConf.getAssignmentList(); Integer dataInType = updateModeConf.getDataInType(); Integer noRule = updateModeConf.getNoRule(); - if(noRule == 0 && conditionList.isEmpty()){ + if(noRule == 1 && conditionList.isEmpty()){ logger.error(String.format("没有条件设置,不允许建模 %s 更新",updateModeConf.getTargetTableName())); continue; } + logger.info(String.format("处理配置 deal config [%s - %s]",updateModeConf.getUniqueCode(),updateModeConf.getDescription())); //条件sql String whereSql = ""; //条件数据 @@ -71,12 +88,13 @@ public class ModeChangeService { String sourceValue = Util.null2String(modeMap.get(sourceCondition.getConditionSourceFieldName())); String conditionValue = valueFunction.apply(modeMap, sourceCondition); Boolean result = conditionFunction.apply(sourceValue, conditionValue); - if (result) { + if (!result) { flag = true; break; } } if (flag) { + logger.info("源建模条件判断不通过,此条数据跳过 sourceMode condition fail !!! "+JSON.toJSONString(modeMap)); continue; } } @@ -113,4 +131,6 @@ public class ModeChangeService { logger.info("更新结果 executeFlag ==>"+executeFlag); } } + + } diff --git a/src/main/java/weaver/bokang/xiao/zscq/expand/DataControlExpand.java b/src/main/java/weaver/bokang/xiao/zscq/expand/DataControlExpand.java index 32a541f..5ae68ee 100644 --- a/src/main/java/weaver/bokang/xiao/zscq/expand/DataControlExpand.java +++ b/src/main/java/weaver/bokang/xiao/zscq/expand/DataControlExpand.java @@ -97,7 +97,7 @@ public class DataControlExpand extends AbstractModeExpandJavaCodeNew { queryParam.put("fieldValue",dataId); Map modeData = modeMapper.queryModeDataInfo(tableName, queryParam); if(Objects.nonNull(modeData)){ - modeChangeService.changeOtherMode(modeData,formId); + modeChangeService.changeOtherMode(modeData,formId,1); } } diff --git a/src/main/java/weaver/bokang/xiao/zscq/fun/WorkflowOverOperate.java b/src/main/java/weaver/bokang/xiao/zscq/fun/WorkflowOverOperate.java index 694534e..a99f5d2 100644 --- a/src/main/java/weaver/bokang/xiao/zscq/fun/WorkflowOverOperate.java +++ b/src/main/java/weaver/bokang/xiao/zscq/fun/WorkflowOverOperate.java @@ -3,6 +3,7 @@ package weaver.bokang.xiao.zscq.fun; import aiyh.utils.Util; import weaver.bokang.xiao.zscq.config.function.CusOperateInterface; import weaver.bokang.xiao.zscq.config.mapper.UpdateModeMapper; +import weaver.bokang.xiao.zscq.mapper.StatusMapper; import weaver.hrm.User; import weaver.workflow.workflow.WfForceOver; @@ -21,6 +22,8 @@ public class WorkflowOverOperate implements CusOperateInterface { private final UpdateModeMapper updateModeMapper = Util.getMapper(UpdateModeMapper.class); + private final StatusMapper statusMapper = Util.getMapper(StatusMapper.class); + @Override public void execute(Map whereParam, Map param, Map pathParam) { logger.info(String.format("WorkflowOverOperate 自定义处理 whereParam[%s],param:[%s],pathParam:[%s]",whereParam,param,pathParam)); @@ -35,6 +38,11 @@ public class WorkflowOverOperate implements CusOperateInterface { if(Objects.nonNull(modeData)){ String workflowField = Util.null2String(pathParam.get("workflowField")); String requestId = Util.null2String(modeData.get(workflowField)); + int status = statusMapper.queryWorkflowStatus(requestId); + if(status == 3){ + logger.error(String.format("此流程已归档,不再执行强制归档操作 this workflow is over!!! requestId:%s ",requestId)); + return; + } logger.info("流程强制归档 ==>"+requestId); //流程强制归档 WfForceOver wfForceOver = new WfForceOver(); diff --git a/src/main/java/weaver/bokang/xiao/zscq/fun/WorkflowRepossessedSign.java b/src/main/java/weaver/bokang/xiao/zscq/fun/WorkflowRepossessedSign.java index 5e53421..dcec3ad 100644 --- a/src/main/java/weaver/bokang/xiao/zscq/fun/WorkflowRepossessedSign.java +++ b/src/main/java/weaver/bokang/xiao/zscq/fun/WorkflowRepossessedSign.java @@ -1,8 +1,100 @@ -package weaver.bokang.xiao.zscq.fun;/** - *@ClassName WorkflowRepossessedSign - *@Author 肖博亢 - *@Date 2023/4/24 11:11 - *@Description

+package weaver.bokang.xiao.zscq.fun; + +import aiyh.utils.Util; +import com.api.bokang.xiao.zscq.service.impl.ReserveServiceImpl; +import weaver.bokang.xiao.zscq.config.function.CusOperateInterface; +import weaver.bokang.xiao.zscq.config.mapper.UpdateModeMapper; +import weaver.conn.RecordSet; +import weaver.hrm.User; +import weaver.workflow.workflow.RequestForceDrawBack; +import weaver.workflow.workflow.WfForceDrawBack; +import weaver.workflow.workflow.WfFunctionManageUtil; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * @ClassName WorkflowRepossessedSign + * @Author 肖博亢 + * @Date 2023/4/24 11:11 + * @Description

**/ -public class WorkflowRepossessedSign { +public class WorkflowRepossessedSign implements CusOperateInterface { + + private final UpdateModeMapper updateModeMapper = Util.getMapper(UpdateModeMapper.class); + + private final ReserveServiceImpl reserveService = new ReserveServiceImpl(); + + @Override + public void execute(Map whereParam, Map param, Map pathParam) { + logger.info(String.format("WorkflowRepossessedSign 自定义处理 whereParam[%s],param:[%s],pathParam:[%s]",whereParam,param,pathParam)); + String tableName = Util.null2String(param.get("tableName")); + String whereSql = Util.null2String(param.get("whereSql")); + if(!"".equals(whereSql)){ + whereSql = whereSql.replaceFirst(" and "," where "); + } + String querySql = "select * from " + tableName +whereSql; + Map modeData = updateModeMapper.executeCusSqlMap(querySql, whereParam,new HashMap<>()); + logger.info("modeData ==>"+modeData); + if(Objects.nonNull(modeData)){ + String workflowField = Util.null2String(pathParam.get("workflowField")); + String requestId = Util.null2String(modeData.get(workflowField)); + logger.info("流程强制收回 ==>"+requestId); + //流程强制收回 + reserveService.doRepossessedSign(Util.getIntValue(requestId),new User(1)); + //this.doRepossessedSign2(Util.getIntValue(requestId),new User(1)); + } + } + + /** + *

流程强制收回 + * @param requestId 流程id + * @param user 用户信息 + * @return 操作结果 + */ + public boolean doRepossessedSign2(int requestId,User user){ + WfFunctionManageUtil wfFunctionManageUtil = new WfFunctionManageUtil(); + //初始化 + RequestForceDrawBack requestForceDrawBack = new RequestForceDrawBack(); + WfForceDrawBack wfForceDrawBack = new WfForceDrawBack(); + if(requestId != -1){ + RecordSet recordSet = new RecordSet(); + //从日志中去找最后一个操作者 + recordSet.executeSql("select max(logid), operator,operatortype from workflow_requestlog where requestId=" + requestId + " and (logtype='2' or logtype='0' or logtype='3' or logtype='e') and exists(select 1 from workflow_currentoperator where requestId=workflow_requestlog.requestId and userid=workflow_requestlog.operator and usertype=workflow_requestlog.operatortype and isremark='2' and preisremark='0' and operatedate is not null and operatedate>' ') group by operator,operatortype order by max(logid) desc"); + int tempUser = -1; + int tempUserType = -1; + if (recordSet.next()) { + tempUser = Util.getIntValue(recordSet.getString("operator")); + tempUserType = Util.getIntValue(recordSet.getString("operatortype"), 0); + }else{ + recordSet.executeSql("select userid,usertype from workflow_currentoperator where requestId = " + requestId + " and isremark = '2' and preisremark='0' and operatedate is not null and operatedate>' ' order by operatedate desc ,operatetime desc"); + if (recordSet.next()) { + tempUser = recordSet.getInt("userid"); + tempUserType = recordSet.getInt("usertype"); + } + } + if(tempUser == -1 && tempUserType == -1){ + logger.error(String.format("流程 requestId:[%s] 操作者 operateInfo no find 流程可能未归档 !!!",requestId)); + return false; + } + //提交时针对流程再作一次权限判断 + boolean canForceDrawBack = RequestForceDrawBack.isHavePurview(user.getUID(), requestId, true); + if (canForceDrawBack && wfFunctionManageUtil.haveOtherOperationRight(requestId)) { + //int result = requestForceDrawBack.foreceDrawBack(user, requestId, true, tempUser, tempUserType); + ArrayList requestIds = new ArrayList<>(); + requestIds.add(requestId+""); + wfForceDrawBack.doForceDrawBack(requestIds,new User(1),-1,-1); + logger.info(String.format("流程 requestId:[%s] 撤回结果 drawBack result:[%d] message:[%s]",requestId,111,requestForceDrawBack.getMessage())); + //return result == 1; + return true; + }else{ + return false; + } + }else{ + return false; + } + } + } diff --git a/src/main/java/weaver/bokang/xiao/zscq/mapper/StatusMapper.java b/src/main/java/weaver/bokang/xiao/zscq/mapper/StatusMapper.java index 8e3616d..f424845 100644 --- a/src/main/java/weaver/bokang/xiao/zscq/mapper/StatusMapper.java +++ b/src/main/java/weaver/bokang/xiao/zscq/mapper/StatusMapper.java @@ -1,6 +1,7 @@ package weaver.bokang.xiao.zscq.mapper; import aiyh.utils.annotation.recordset.ParamMapper; +import aiyh.utils.annotation.recordset.Select; import aiyh.utils.annotation.recordset.SqlMapper; import aiyh.utils.annotation.recordset.Update; @@ -19,8 +20,16 @@ public interface StatusMapper { * @param userIds 用户id集合 * @return 操作结果 */ - @Update("update workflow_currentoperator set viewtype = -2,isremark = 2 " + + @Update("update workflow_currentoperator set isremark = 2 " + "where REQUESTID = #{requestId} and userid in ($t{userIds}) and isremark = 8") boolean changeWorkflowStatus(@ParamMapper("requestId")String requestId,@ParamMapper("userIds") String userIds); + /** + *

查询当前流程状态

+ * @param requestId 流程id + * @return 流程状态 + */ + @Select("select currentnodetype from workflow_requestbase where requestid = #{requestId}") + int queryWorkflowStatus(@ParamMapper("requestId")String requestId); + } diff --git a/src/main/java/weaver/bokang/xiao/zscq/store/TableNameStore.java b/src/main/java/weaver/bokang/xiao/zscq/store/TableNameStore.java index 7e9e532..5060621 100644 --- a/src/main/java/weaver/bokang/xiao/zscq/store/TableNameStore.java +++ b/src/main/java/weaver/bokang/xiao/zscq/store/TableNameStore.java @@ -6,6 +6,8 @@ import lombok.Getter; import org.apache.log4j.Logger; import weaver.bokang.xiao.xhny_report.entity.pojo.CompanyEntity; import weaver.bokang.xiao.xhny_report.mapper.VendorMapper; +import weaver.bokang.xiao.zscq.config.entity.UpdateModeConf; +import weaver.bokang.xiao.zscq.config.mapper.UpdateModeMapper; import weaver.general.StaticObj; import weaver.interfaces.datasource.DataSource; @@ -30,9 +32,31 @@ public class TableNameStore { private final Map tableNameStore = new HashMap<>(); + private final Map> triggerStore = new HashMap<>(); + + private final UpdateModeMapper updateModeMapper = Util.getMapper(UpdateModeMapper.class); + private static final Logger logger = Util.getLogger(); - private TableNameStore(){} + private TableNameStore(){init();} + + private void init(){ + try { + triggerStore.clear(); + List updateModeConfList = updateModeMapper.queryUpdateModeConf(); + if (Objects.nonNull(updateModeConfList) && !updateModeConfList.isEmpty()) { + Map> collect = updateModeConfList.stream().collect(Collectors.groupingBy(UpdateModeConf::getSourceMode)); + triggerStore.putAll(collect); + } + logger.info(String.format("TableNameStore init success!!! triggerStore:%s updateModeConfList:%s", JSON.toJSONString(triggerStore), JSON.toJSONString(updateModeConfList))); + }catch (Exception e){ + logger.error("TableNameStore init error !!!"+Util.getErrString(e)); + } + } + + public void refresh(){ + this.init(); + } public static TableNameStore getInstance(){ return VendorStoreHolder.VENDOR_STORE; diff --git a/src/main/resources/ContractList(2).jsp b/src/main/resources/ContractList(2).jsp deleted file mode 100644 index 9070046..0000000 --- a/src/main/resources/ContractList(2).jsp +++ /dev/null @@ -1,499 +0,0 @@ -<%@ page language="java" contentType="text/html; charset=UTF-8" %> -<%@ include file="/systeminfo/init_wev8.jsp"%> -<%@ taglib uri="/WEB-INF/weaver.tld" prefix="wea"%> -<%@ taglib uri="/WEB-INF/tld/browser.tld" prefix="brow"%> - -<%@ page import="weaver.file.Prop" %> -<%@ page import="weaver.hrm.HrmUserVarify" %> -<%@ page import="weaver.systeminfo.SystemEnv" %> - - - - - - - - - - - - - - - -<% - - String sqlwhere = " where 1=1 "; - - String subcompanyid1 = ResourceComInfo.getSubCompanyID(String.valueOf(user.getUID())); - - //是否采购部 - boolean isDep = false; - //是否是流程接收人 - boolean isShow = false; - //采购部的同事可以选择所有合同卡片;而本部门的人员(非采购部)只能选择本部门的合同卡片 - RecordSet_Dep.executeSql("select * from HrmDepartment where departmentname like '%采购%' and id="+user.getUserDepartment()); - if(RecordSet_Dep.next()) isDep = true; - - //是否合同流程接收人 - String sqlwhere_workflow = ""; - RecordSet_Dep.executeSql("select distinct requestId from workflow_currentoperator where workflowid in (79,148,133,128,118,108,98,153,167,316,470,514,532,543,600,717,719,739,832,927,929) and userid="+user.getUID()); - if(RecordSet_Dep.next()) isShow = true; - - if(!HrmUserVarify.checkUserRight("ContactInfo:Manager", user) && !HrmUserVarify.checkUserRight("ContactInfo:User", user) && !isShow && !isDep){ - response.sendRedirect("/notice/noright.jsp"); - } - - //如果是合同管理权限,则直接1=1 - if(HrmUserVarify.checkUserRight("ContactInfo:Manager", user)){ - sqlwhere += " and 1=1"; - }else if(isShow && HrmUserVarify.checkUserRight("ContactInfo:User", user)){ - //如果是流程接收人,并且有合同查看权限 - sqlwhere += " and (requestid in (select distinct requestId from workflow_currentoperator where workflowid in (79,148,133,128,118,108,98,153,167,316,470,514,532,543,600,717,719,739,832,927,929) and userid="+user.getUID()+") or reqDeptId = '"+user.getUserDepartment()+"')"; - - }else if(HrmUserVarify.checkUserRight("ContactInfo:User", user)){ - //如果只有合同查看权限 - sqlwhere += " and reqDeptId = '"+user.getUserDepartment()+"'"; - - }else if(isShow){ - //如果只是流程接收人 - sqlwhere += " and requestid in (select distinct requestId from workflow_currentoperator where workflowid in (79,148,133,128,118,108,98,153,167,316,470,514,532,543,600,717,719,739,832,927,929) and userid="+user.getUID()+")"; - } - - //如果没有查看全部的权限,加分部条件 - if(!HrmUserVarify.checkUserRight("ContactInfoList:ALL", user)){ - if (!subcompanyid1.equals("0")) {sqlwhere += " and CrmContractInfo.subcompanyid1 = '"+subcompanyid1+"' ";} - } - String imagefilename = "/images/hdReport.gif"; - String titlename = SystemEnv.getHtmlLabelName(614, user.getLanguage()) + SystemEnv.getHtmlLabelName(527, user.getLanguage()); - String needfav = "1"; - String needhelp = ""; -%> - - <%@ include file="/systeminfo/TopTitle_wev8.jsp"%> - <%@ include file="/systeminfo/RightClickMenuConent_wev8.jsp"%> - <% - RCMenu += "{" + SystemEnv.getHtmlLabelName(197, user.getLanguage()) + ",javascript:OnSearch(),_top} "; - RCMenuHeight += RCMenuHeightStep; - RCMenu += "{" + "Excel,javascript:ContractExport(),_top} "; - RCMenuHeight += RCMenuHeightStep; - RCMenu += "{" + SystemEnv.getHtmlLabelName(18363, user.getLanguage()) + ",javascript:_table.firstPage(),_self}"; - RCMenuHeight += RCMenuHeightStep; - RCMenu += "{" + SystemEnv.getHtmlLabelName(1258, user.getLanguage()) + ",javascript:_table.prePage(),_self}"; - RCMenuHeight += RCMenuHeightStep; - RCMenu += "{" + SystemEnv.getHtmlLabelName(1259, user.getLanguage()) + ",javascript:_table.nextPage(),_self}"; - RCMenuHeight += RCMenuHeightStep; - RCMenu += "{" + SystemEnv.getHtmlLabelName(18362, user.getLanguage()) + ",javascript:_table.lastPage(),_self}"; - RCMenuHeight += RCMenuHeightStep; - %> - <% - int pagenum = Util.getIntValue(request.getParameter("pagenum"), 1); - int perpage = Util.getPerpageLog(); - if (perpage <= 1) perpage = 10; - - String creator = Util.fromScreen(request.getParameter("creator"), user.getLanguage()); - String fromdate = Util.fromScreen(request.getParameter("fromdate"), user.getLanguage()); - String fromdate2 = Util.fromScreen(request.getParameter("fromdate2"), user.getLanguage()); - String enddate = Util.fromScreen(request.getParameter("enddate"), user.getLanguage()); - String enddate2 = Util.fromScreen(request.getParameter("enddate2"), user.getLanguage()); - String status_temp = Util.null2String(request.getParameter("status_temp")); - - String conNo = Util.fromScreen(request.getParameter("conNo"), user.getLanguage()); - String prNo = Util.fromScreen(request.getParameter("prNo"), user.getLanguage()); - String jpcNo = Util.fromScreen(request.getParameter("jpcNo"), user.getLanguage()); - String suppliersId = Util.fromScreen(request.getParameter("suppliersId"), user.getLanguage()); - String isOneSuppliers = Util.fromScreen(request.getParameter("isOneSuppliers"), user.getLanguage()); -// String reqDeptId = String.valueOf(user.getUserDepartment()); - String reqDeptId = Util.fromScreen(request.getParameter("reqDeptId"), user.getLanguage());; - //管理员组或采购部才能查询所有部门下合同,合同接收人查看接收的合同 -// if(HrmUserVarify.checkUserRight("ContactInfo:Manager", user) || isShow) reqDeptId = Util.fromScreen(request.getParameter("reqDeptId"), user.getLanguage()); - String isOverdue = Util.fromScreen(request.getParameter("isOverdue"), user.getLanguage()); - String status = Util.fromScreen(request.getParameter("status"), user.getLanguage()); - String isOverdueNext = Util.fromScreen(request.getParameter("isOverdueNext"), user.getLanguage()); - String conType = Util.fromScreen(request.getParameter("conType"), user.getLanguage()); - - String name = Util.fromScreen(request.getParameter("name"), user.getLanguage()); - String subCompanyId = Util.fromScreen(request.getParameter("subCompanyId"), user.getLanguage()); - String reNewStatus = Util.fromScreen(request.getParameter("reNewStatus"), user.getLanguage()); - String conStatus = Util.fromScreen(request.getParameter("conStatus"), user.getLanguage()); - String contractName = Util.fromScreen(request.getParameter("contractName"), user.getLanguage()); - String csstatus = Util.fromScreen(request.getParameter("csstatus"), user.getLanguage()); - - int opentype = Util.getIntValue(request.getParameter("opentype"),-1); - - //String sqlwhere = " where status = '' "; - //if(!"".equals(status_temp)) sqlwhere += " and status in ("+status_temp+") "; - - if (!fromdate.equals("")) sqlwhere += " and startDate>='" + fromdate + "'"; - if (!fromdate2.equals("")) sqlwhere += " and startDate<='" + fromdate2 + "'"; - if (!enddate.equals("")) sqlwhere += " and enddate>='" + enddate + "'"; - if (!enddate2.equals("")) sqlwhere += " and enddate<='" + enddate2 + "'"; - if (!conNo.equals("")) sqlwhere += " and conNo like '%" + conNo + "%'"; - if (!prNo.equals("")) sqlwhere += " and prNo='" + prNo + "'"; - if (!jpcNo.equals("")) sqlwhere += " and jpcNo='" + jpcNo + "'"; - if(!"".equals(suppliersId)) sqlwhere += " and suppliersId=" + suppliersId; - if (!isOneSuppliers.equals("")) sqlwhere += " and isOneSuppliers='" + isOneSuppliers + "'"; - if (!"".equals(creator) && !"0".equals(creator)) sqlwhere += " and CrmContractInfo.creator=" + creator; - if (!reqDeptId.equals("")) sqlwhere += " and reqDeptId=" + reqDeptId; - if (!isOverdue.equals("")) sqlwhere += " and isOverdue='" + isOverdue + "'"; - if (!status.equals("")) sqlwhere += " and CrmContractInfo.status='" + status + "'"; - if (!isOverdueNext.equals("")) sqlwhere += " and isOverdueNext='" + isOverdueNext + "'"; - if (!conType.equals("")) sqlwhere += " and conType='" + conType + "'"; - if (!csstatus.equals("")) sqlwhere += " and CrmSalesContractInfo.status='" + csstatus + "'"; - - if (!name.equals("")) sqlwhere += " and name like '%" + name + "%'"; - if (!subCompanyId.equals("")) sqlwhere += " and CrmContractInfo.subcompanyid1 = '" + subCompanyId + "'"; - if (!reNewStatus.equals("")) sqlwhere += " and conStatus = '" + reNewStatus + "'"; - - if (!contractName.equals("")) sqlwhere += " and contractName like '%" + contractName + "%'"; - - //if (reNewStatus2.equals("待续签")) sqlwhere += " and dbo.getReNewStatus2(2,CrmContractInfo.saleContract) > 0"; - //else if (reNewStatus2.equals("已续签")) sqlwhere += " and dbo.getReNewStatus2(1,CrmContractInfo.saleContract) > 0"; - //else if (reNewStatus2.equals("无需续签")) sqlwhere += " and dbo.getReNewStatus2(3,CrmContractInfo.saleContract) > 0"; - //System.out.println("sqlwhere:"+sqlwhere); - - - if(opentype > -1){ - sqlwhere += " and isnull(CrmContractInfo.opentype,0) = " + opentype; - } - - String orderStr = " order by startDate desc, CrmContractInfo.id desc "; - -// out.println("sqlwhere:" + sqlwhere); -// out.println("orderStr:" + orderStr); - -// session.setAttribute("sqlwhere", sqlwhere); -// session.setAttribute("orderStr", orderStr); - %> -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <%if(HrmUserVarify.checkUserRight("ContactInfoList:ALL", user)){%> - - - <%}%> - - - - - - - - - - - - - - - - -
<%=SystemEnv.getHtmlLabelName(15774, user.getLanguage())%>
合同状态 - - <%=SystemEnv.getHtmlLabelName(1970, user.getLanguage())%> -   - <%=Util.toScreen(fromdate, user.getLanguage())%> -  -   - <%=Util.toScreen(fromdate2, user.getLanguage())%> - > - > - <%=SystemEnv.getHtmlLabelName(15236, user.getLanguage())%> -   - <%=Util.toScreen(enddate, user.getLanguage())%> -  -   - <%=Util.toScreen(enddate2, user.getLanguage())%> - > - > -
<%=SystemEnv.getHtmlLabelName(21282, user.getLanguage())%> - - PR<%=SystemEnv.getHtmlLabelName(403,user.getLanguage())%> - - JPC<%=SystemEnv.getHtmlLabelName(2171,user.getLanguage())%><%=SystemEnv.getHtmlLabelName(16992,user.getLanguage())%> - -
<%=SystemEnv.getHtmlLabelName(613002, user.getLanguage())%> - - - - - <%=SystemEnv.getHtmlLabelName(913, user.getLanguage())%> - - -
<%=SystemEnv.getHtmlLabelName(620002, user.getLanguage())%> - - - - -<%-- <%--%> -<%-- //管理员组才能查询所有部门下合同--%> -<%-- if(HrmUserVarify.checkUserRight("ContactInfo:Manager", user)){--%> -<%-- %>--%> -<%-- -<%-- id="reqDeptId"--%> -<%-- name="reqDeptId"--%> -<%-- browserValue="<%=reqDeptId %>"--%> -<%-- browserUrl="/systeminfo/BrowserMain.jsp?url=/hrm/company/DepartmentBrowser.jsp"--%> -<%-- hasInput="true"--%> -<%-- isSingle="true"--%> -<%-- hasBrowser = "true"--%> -<%-- isMustInput='1'--%> -<%-- width="165px"--%> -<%-- browserSpanValue="<%=Util.toScreen(DepartmentComInfo.getDepartmentname(reqDeptId),user.getLanguage())%>">--%> -<%-- --%> - -<%-- <%––%>--%> -<%-- <%}else{ %>--%> -<%-- <%=Util.toScreen(DepartmentComInfo.getDepartmentname(reqDeptId),user.getLanguage()) %>--%> -<%-- <%} %>--%> - 付款状态 - - <%=SystemEnv.getHtmlLabelName(620017, user.getLanguage())%> - -
<%=SystemEnv.getHtmlLabelName(15775, user.getLanguage())%> - - <%=SystemEnv.getHtmlLabelName(15142, user.getLanguage())%> - - <%=SystemEnv.getHtmlLabelName(141,user.getLanguage())%>: - - - "> - - - - <%-- - <%--_url="/systeminfo/BrowserMain.jsp?url=/hrm/company/SubcompanyBrowser.jsp"--%> - <%--_displayText="<%=SubCompanyComInfo.getSubCompanyname(subCompanyId+"")%>"--%> - <%-->--%> -
<%=SystemEnv.getHtmlLabelName(16404, user.getLanguage())%><%=SystemEnv.getHtmlLabelName(195, user.getLanguage())%> - - 销售合同状态 - - 开闭口类型 - -
- -
- -
- - - - -
- <% - - String tableString = ""; - String backfields = " CrmContractInfo.id,case CrmContractInfo.opentype when '0' then '闭口' when '1' then '开口' when '2' then '周期性' end opentype, reqDeptId, suppliersId, conNo, name, startDate, endDate, case isOverdue when 'Y' then '是' else '否' end as isOverdue, conAmount, content, ',' as str_temp, case isOverdueNext when 'Y' then '是' else '否' end as isOverdueNext, case CrmContractInfo.status when '0' then '执行中' when '1' then '已结清' end as status, CrmContractInfo.creator, CrmContractInfo.subcompanyid1, case conStatus when '0' then '执行' when '1' then '待续签' when '2' then '已续签' when '3' then '关闭' end as reNewStatus, contractName, saleContract, case when dbo.getReNewStatus2(1,CrmContractInfo.saleContract) > 0 then '已续签' when dbo.getReNewStatus2(2,CrmContractInfo.saleContract) > 0 then '待续签' when dbo.getReNewStatus2(3,CrmContractInfo.saleContract) > 0 then '无需续签' end as reNewStatus2,case CrmSalesContractInfo.status when '0' then '已签署' when '1' then '未签署' when '2' then '已续签' when '3' then '关闭' end as csstatus "; - String fromSql = " CrmContractInfo Left Join CrmSalesContractInfo On CrmSalesContractInfo.id=CrmContractInfo.saleContract "; - //out.print("select"+backfields+"from"+fromSql +sqlwhere); - String str_content = "content"+"str_temp"; - tableString = " " + "" + ""; - tableString += ""; - tableString += ""; - tableString += ""; - tableString += ""; - tableString += ""; - tableString += ""; - //tableString += ""; - tableString += ""; - tableString += ""; - tableString += ""; - tableString += ""; - tableString += ""; - //tableString += ""; - tableString += ""; - tableString += ""; - tableString += ""; - tableString += ""; - tableString += ""; - tableString += ""; - tableString += "
"; - %> - - -
-
- <%@ include file="/systeminfo/RightClickMenu_wev8.jsp"%> - - - - - - - \ No newline at end of file diff --git a/src/main/resources/ContractReportExport(1).jsp b/src/main/resources/ContractReportExport(1).jsp deleted file mode 100644 index 2590773..0000000 --- a/src/main/resources/ContractReportExport(1).jsp +++ /dev/null @@ -1,127 +0,0 @@ -<%@ page language="java" contentType="text/html; charset=GBK" %> -<%@ include file="/systeminfo/init.jsp" %> -<%@ page import="weaver.general.Util, weaver.file.ExcelSheet, weaver.file.ExcelRow" %> - - - - - - - - - - -<%! - public static String ToDBC(String input) { - char[] c = input.toCharArray(); - for (int i = 0; i < c.length; i++) { - if (c[i] == 12288) { - //ȫǿոΪ12288ǿոΪ32 - c[i] = (char) 32; - continue; - } - if (c[i] > 65280 && c[i] < 65375) - //ַ(33-126)ȫ(65281-65374)ĶӦϵǣ65248 - c[i] = (char) (c[i] - 65248); - } - return new String(c); - } - - -%> - -<% - // String sqlwhere=(String)session.getAttribute("sqlwhere"); -// String orderStr=(String)session.getAttribute("orderStr"); - - String sqlwhere = request.getParameter("sqlwhere"); - sqlwhere = ToDBC(sqlwhere); - String orderStr = request.getParameter("orderStr"); - orderStr = ToDBC(orderStr); - - String sqlstr = ""; - - if (RecordSet.getDBType().equals("oracle")) { - sqlstr = "select CrmContractInfo.id, reqDeptId, suppliersId, conNo, name, startDate, endDate, case isOverdue when 'Y' then '' else '' end as isOverdue, conAmount, content, case isOverdueNext when 'Y' then '' else '' end as isOverdueNext, case CrmContractInfo.status when '0' then 'ִ' when '1' then 'ѽ' end as status, case isOneSuppliers when 'Y' then '' when 'N' then '' else '' end as isOneSuppliers, prRequestId,jpcNo,jpcFile,prNo,prAmount,prAmountSum,conAmount,managerId,subject,giveDate,giveRemark,payRemark,content,CrmContractInfo.createDate,CrmContractInfo.creator,CrmContractInfo.subcompanyid1, case conStatus when '0' then 'ִ' when '1' then 'ǩ' when '2' then 'ǩ' when '3' then 'ر' end as reNewStatus,contractName, saleContract, case CrmSalesContractInfo.status when '0' then 'ǩ' when '1' then 'δǩ' when '2' then 'ǩ' when '3' then 'ر' end as reNewStatus2 from CrmContractInfo Left Join CrmSalesContractInfo On CrmSalesContractInfo.id=CrmContractInfo.saleContract" + sqlwhere + orderStr; - } else { - sqlstr = "select CrmContractInfo.id, reqDeptId, suppliersId, conNo, name, startDate, endDate, case isOverdue when 'Y' then '' else '' end as isOverdue, conAmount, content, case isOverdueNext when 'Y' then '' else '' end as isOverdueNext, case CrmContractInfo.status when '0' then 'ִ' when '1' then 'ѽ' end as status, case isOneSuppliers when 'Y' then '' when 'N' then '' else '' end as isOneSuppliers, prRequestId,jpcNo,jpcFile,prNo,prAmount,prAmountSum,conAmount,managerId,subject,giveDate,giveRemark,payRemark,content,CrmContractInfo.createDate,CrmContractInfo.creator,CrmContractInfo.subcompanyid1, case conStatus when '0' then 'ִ' when '1' then 'ǩ' when '2' then 'ǩ' when '3' then 'ر' end as reNewStatus,contractName, saleContract, case CrmSalesContractInfo.status when '0' then 'ǩ' when '1' then 'δǩ' when '2' then 'ǩ' when '3' then 'ر' end as reNewStatus2 from CrmContractInfo Left Join CrmSalesContractInfo On CrmSalesContractInfo.id=CrmContractInfo.saleContract" + sqlwhere + orderStr; - } - new BaseBean().writeLog(">>>>>>>>"+sqlstr); - RecordSet.executeQuery(sqlstr); - - ExcelSheet es = new ExcelSheet(); - - ExcelRow er = es.newExcelRow(); - er.addStringValue(SystemEnv.getHtmlLabelName(141,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620002,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(613002,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(21282,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(15142,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(1970,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(15236,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620016,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(6146,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620015,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620017,user.getLanguage())); - er.addStringValue("״̬"); - er.addStringValue(SystemEnv.getHtmlLabelName(913,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620009,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620003,user.getLanguage())); - er.addStringValue("JPC"+SystemEnv.getHtmlLabelName(16992,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620004,user.getLanguage())); - er.addStringValue("PR"+SystemEnv.getHtmlLabelName(403,user.getLanguage())); - er.addStringValue("PR"+SystemEnv.getHtmlLabelName(856,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620010,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620011,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620006,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620012,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620013,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620014,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620015,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(614,user.getLanguage())+SystemEnv.getHtmlLabelName(722,user.getLanguage())); - er.addStringValue("ͬ״̬"); - er.addStringValue("ۺͬ"); - er.addStringValue("ۺͬ״̬"); - - while (RecordSet.next()) { - ExcelRow erdetail = es.newExcelRow(); - erdetail.addStringValue(SubCompanyComInfo.getSubCompanyname(RecordSet.getString("subcompanyid1"))); - erdetail.addStringValue(DepartmentComInfo.getDepartmentname(RecordSet.getString("reqDeptId"))); - erdetail.addStringValue(CrmSupplierComInfo.getSuppliername(RecordSet.getString("suppliersId"))); - erdetail.addStringValue(RecordSet.getString("conNo")); - erdetail.addStringValue(RecordSet.getString("name")); - erdetail.addStringValue(RecordSet.getString("startDate")); - erdetail.addStringValue(RecordSet.getString("endDate")); - erdetail.addStringValue(RecordSet.getString("isOverdue")); - erdetail.addStringValue(RecordSet.getString("conAmount")); - erdetail.addStringValue(Util.toScreen(SptmForDoc.getDocName(RecordSet.getString("content")), user.getLanguage())); - erdetail.addStringValue(RecordSet.getString("isOverdueNext")); - erdetail.addStringValue(RecordSet.getString("status")); - erdetail.addStringValue(Util.toScreen(ResourceComInfo.getResourcename(RecordSet.getString("creator")), user.getLanguage())); - erdetail.addStringValue(RecordSet.getString("isOneSuppliers")); - erdetail.addStringValue(RequestComInfo.getRequestname(RecordSet.getString("prRequestId"))); - erdetail.addStringValue(RecordSet.getString("jpcNo")); - erdetail.addStringValue(DocComInfo.getDocname(RecordSet.getString("jpcFile"))); - erdetail.addStringValue(RecordSet.getString("prNo")); - erdetail.addStringValue(RecordSet.getString("prAmount")); - erdetail.addStringValue(RecordSet.getString("prAmountSum")); - erdetail.addStringValue(ResourceComInfo.getResourcename(RecordSet.getString("managerId"))); - erdetail.addStringValue(RecordSet.getString("subject")); - erdetail.addStringValue(RecordSet.getString("giveDate")); - erdetail.addStringValue(RecordSet.getString("giveRemark")); - erdetail.addStringValue(RecordSet.getString("payRemark")); - erdetail.addStringValue(DocComInfo.getDocname(RecordSet.getString("content"))); - erdetail.addStringValue(RecordSet.getString("createDate")); - erdetail.addStringValue(RecordSet.getString("reNewStatus")); - erdetail.addStringValue(RecordSet.getString("contractName")); - erdetail.addStringValue(RecordSet.getString("reNewStatus2")); - } - - ExcelFile.init(); - ExcelFile.setFilename("ͬ"); - ExcelFile.addSheet("ͬ", es); -%> - -<%----%> \ No newline at end of file diff --git a/src/main/resources/ajzx/ContractList.jsp b/src/main/resources/ajzx/ContractList.jsp deleted file mode 100644 index 9070046..0000000 --- a/src/main/resources/ajzx/ContractList.jsp +++ /dev/null @@ -1,499 +0,0 @@ -<%@ page language="java" contentType="text/html; charset=UTF-8" %> -<%@ include file="/systeminfo/init_wev8.jsp"%> -<%@ taglib uri="/WEB-INF/weaver.tld" prefix="wea"%> -<%@ taglib uri="/WEB-INF/tld/browser.tld" prefix="brow"%> - -<%@ page import="weaver.file.Prop" %> -<%@ page import="weaver.hrm.HrmUserVarify" %> -<%@ page import="weaver.systeminfo.SystemEnv" %> - - - - - - - - - - - - - - - -<% - - String sqlwhere = " where 1=1 "; - - String subcompanyid1 = ResourceComInfo.getSubCompanyID(String.valueOf(user.getUID())); - - //是否采购部 - boolean isDep = false; - //是否是流程接收人 - boolean isShow = false; - //采购部的同事可以选择所有合同卡片;而本部门的人员(非采购部)只能选择本部门的合同卡片 - RecordSet_Dep.executeSql("select * from HrmDepartment where departmentname like '%采购%' and id="+user.getUserDepartment()); - if(RecordSet_Dep.next()) isDep = true; - - //是否合同流程接收人 - String sqlwhere_workflow = ""; - RecordSet_Dep.executeSql("select distinct requestId from workflow_currentoperator where workflowid in (79,148,133,128,118,108,98,153,167,316,470,514,532,543,600,717,719,739,832,927,929) and userid="+user.getUID()); - if(RecordSet_Dep.next()) isShow = true; - - if(!HrmUserVarify.checkUserRight("ContactInfo:Manager", user) && !HrmUserVarify.checkUserRight("ContactInfo:User", user) && !isShow && !isDep){ - response.sendRedirect("/notice/noright.jsp"); - } - - //如果是合同管理权限,则直接1=1 - if(HrmUserVarify.checkUserRight("ContactInfo:Manager", user)){ - sqlwhere += " and 1=1"; - }else if(isShow && HrmUserVarify.checkUserRight("ContactInfo:User", user)){ - //如果是流程接收人,并且有合同查看权限 - sqlwhere += " and (requestid in (select distinct requestId from workflow_currentoperator where workflowid in (79,148,133,128,118,108,98,153,167,316,470,514,532,543,600,717,719,739,832,927,929) and userid="+user.getUID()+") or reqDeptId = '"+user.getUserDepartment()+"')"; - - }else if(HrmUserVarify.checkUserRight("ContactInfo:User", user)){ - //如果只有合同查看权限 - sqlwhere += " and reqDeptId = '"+user.getUserDepartment()+"'"; - - }else if(isShow){ - //如果只是流程接收人 - sqlwhere += " and requestid in (select distinct requestId from workflow_currentoperator where workflowid in (79,148,133,128,118,108,98,153,167,316,470,514,532,543,600,717,719,739,832,927,929) and userid="+user.getUID()+")"; - } - - //如果没有查看全部的权限,加分部条件 - if(!HrmUserVarify.checkUserRight("ContactInfoList:ALL", user)){ - if (!subcompanyid1.equals("0")) {sqlwhere += " and CrmContractInfo.subcompanyid1 = '"+subcompanyid1+"' ";} - } - String imagefilename = "/images/hdReport.gif"; - String titlename = SystemEnv.getHtmlLabelName(614, user.getLanguage()) + SystemEnv.getHtmlLabelName(527, user.getLanguage()); - String needfav = "1"; - String needhelp = ""; -%> - - <%@ include file="/systeminfo/TopTitle_wev8.jsp"%> - <%@ include file="/systeminfo/RightClickMenuConent_wev8.jsp"%> - <% - RCMenu += "{" + SystemEnv.getHtmlLabelName(197, user.getLanguage()) + ",javascript:OnSearch(),_top} "; - RCMenuHeight += RCMenuHeightStep; - RCMenu += "{" + "Excel,javascript:ContractExport(),_top} "; - RCMenuHeight += RCMenuHeightStep; - RCMenu += "{" + SystemEnv.getHtmlLabelName(18363, user.getLanguage()) + ",javascript:_table.firstPage(),_self}"; - RCMenuHeight += RCMenuHeightStep; - RCMenu += "{" + SystemEnv.getHtmlLabelName(1258, user.getLanguage()) + ",javascript:_table.prePage(),_self}"; - RCMenuHeight += RCMenuHeightStep; - RCMenu += "{" + SystemEnv.getHtmlLabelName(1259, user.getLanguage()) + ",javascript:_table.nextPage(),_self}"; - RCMenuHeight += RCMenuHeightStep; - RCMenu += "{" + SystemEnv.getHtmlLabelName(18362, user.getLanguage()) + ",javascript:_table.lastPage(),_self}"; - RCMenuHeight += RCMenuHeightStep; - %> - <% - int pagenum = Util.getIntValue(request.getParameter("pagenum"), 1); - int perpage = Util.getPerpageLog(); - if (perpage <= 1) perpage = 10; - - String creator = Util.fromScreen(request.getParameter("creator"), user.getLanguage()); - String fromdate = Util.fromScreen(request.getParameter("fromdate"), user.getLanguage()); - String fromdate2 = Util.fromScreen(request.getParameter("fromdate2"), user.getLanguage()); - String enddate = Util.fromScreen(request.getParameter("enddate"), user.getLanguage()); - String enddate2 = Util.fromScreen(request.getParameter("enddate2"), user.getLanguage()); - String status_temp = Util.null2String(request.getParameter("status_temp")); - - String conNo = Util.fromScreen(request.getParameter("conNo"), user.getLanguage()); - String prNo = Util.fromScreen(request.getParameter("prNo"), user.getLanguage()); - String jpcNo = Util.fromScreen(request.getParameter("jpcNo"), user.getLanguage()); - String suppliersId = Util.fromScreen(request.getParameter("suppliersId"), user.getLanguage()); - String isOneSuppliers = Util.fromScreen(request.getParameter("isOneSuppliers"), user.getLanguage()); -// String reqDeptId = String.valueOf(user.getUserDepartment()); - String reqDeptId = Util.fromScreen(request.getParameter("reqDeptId"), user.getLanguage());; - //管理员组或采购部才能查询所有部门下合同,合同接收人查看接收的合同 -// if(HrmUserVarify.checkUserRight("ContactInfo:Manager", user) || isShow) reqDeptId = Util.fromScreen(request.getParameter("reqDeptId"), user.getLanguage()); - String isOverdue = Util.fromScreen(request.getParameter("isOverdue"), user.getLanguage()); - String status = Util.fromScreen(request.getParameter("status"), user.getLanguage()); - String isOverdueNext = Util.fromScreen(request.getParameter("isOverdueNext"), user.getLanguage()); - String conType = Util.fromScreen(request.getParameter("conType"), user.getLanguage()); - - String name = Util.fromScreen(request.getParameter("name"), user.getLanguage()); - String subCompanyId = Util.fromScreen(request.getParameter("subCompanyId"), user.getLanguage()); - String reNewStatus = Util.fromScreen(request.getParameter("reNewStatus"), user.getLanguage()); - String conStatus = Util.fromScreen(request.getParameter("conStatus"), user.getLanguage()); - String contractName = Util.fromScreen(request.getParameter("contractName"), user.getLanguage()); - String csstatus = Util.fromScreen(request.getParameter("csstatus"), user.getLanguage()); - - int opentype = Util.getIntValue(request.getParameter("opentype"),-1); - - //String sqlwhere = " where status = '' "; - //if(!"".equals(status_temp)) sqlwhere += " and status in ("+status_temp+") "; - - if (!fromdate.equals("")) sqlwhere += " and startDate>='" + fromdate + "'"; - if (!fromdate2.equals("")) sqlwhere += " and startDate<='" + fromdate2 + "'"; - if (!enddate.equals("")) sqlwhere += " and enddate>='" + enddate + "'"; - if (!enddate2.equals("")) sqlwhere += " and enddate<='" + enddate2 + "'"; - if (!conNo.equals("")) sqlwhere += " and conNo like '%" + conNo + "%'"; - if (!prNo.equals("")) sqlwhere += " and prNo='" + prNo + "'"; - if (!jpcNo.equals("")) sqlwhere += " and jpcNo='" + jpcNo + "'"; - if(!"".equals(suppliersId)) sqlwhere += " and suppliersId=" + suppliersId; - if (!isOneSuppliers.equals("")) sqlwhere += " and isOneSuppliers='" + isOneSuppliers + "'"; - if (!"".equals(creator) && !"0".equals(creator)) sqlwhere += " and CrmContractInfo.creator=" + creator; - if (!reqDeptId.equals("")) sqlwhere += " and reqDeptId=" + reqDeptId; - if (!isOverdue.equals("")) sqlwhere += " and isOverdue='" + isOverdue + "'"; - if (!status.equals("")) sqlwhere += " and CrmContractInfo.status='" + status + "'"; - if (!isOverdueNext.equals("")) sqlwhere += " and isOverdueNext='" + isOverdueNext + "'"; - if (!conType.equals("")) sqlwhere += " and conType='" + conType + "'"; - if (!csstatus.equals("")) sqlwhere += " and CrmSalesContractInfo.status='" + csstatus + "'"; - - if (!name.equals("")) sqlwhere += " and name like '%" + name + "%'"; - if (!subCompanyId.equals("")) sqlwhere += " and CrmContractInfo.subcompanyid1 = '" + subCompanyId + "'"; - if (!reNewStatus.equals("")) sqlwhere += " and conStatus = '" + reNewStatus + "'"; - - if (!contractName.equals("")) sqlwhere += " and contractName like '%" + contractName + "%'"; - - //if (reNewStatus2.equals("待续签")) sqlwhere += " and dbo.getReNewStatus2(2,CrmContractInfo.saleContract) > 0"; - //else if (reNewStatus2.equals("已续签")) sqlwhere += " and dbo.getReNewStatus2(1,CrmContractInfo.saleContract) > 0"; - //else if (reNewStatus2.equals("无需续签")) sqlwhere += " and dbo.getReNewStatus2(3,CrmContractInfo.saleContract) > 0"; - //System.out.println("sqlwhere:"+sqlwhere); - - - if(opentype > -1){ - sqlwhere += " and isnull(CrmContractInfo.opentype,0) = " + opentype; - } - - String orderStr = " order by startDate desc, CrmContractInfo.id desc "; - -// out.println("sqlwhere:" + sqlwhere); -// out.println("orderStr:" + orderStr); - -// session.setAttribute("sqlwhere", sqlwhere); -// session.setAttribute("orderStr", orderStr); - %> -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <%if(HrmUserVarify.checkUserRight("ContactInfoList:ALL", user)){%> - - - <%}%> - - - - - - - - - - - - - - - - -
<%=SystemEnv.getHtmlLabelName(15774, user.getLanguage())%>
合同状态 - - <%=SystemEnv.getHtmlLabelName(1970, user.getLanguage())%> -   - <%=Util.toScreen(fromdate, user.getLanguage())%> -  -   - <%=Util.toScreen(fromdate2, user.getLanguage())%> - > - > - <%=SystemEnv.getHtmlLabelName(15236, user.getLanguage())%> -   - <%=Util.toScreen(enddate, user.getLanguage())%> -  -   - <%=Util.toScreen(enddate2, user.getLanguage())%> - > - > -
<%=SystemEnv.getHtmlLabelName(21282, user.getLanguage())%> - - PR<%=SystemEnv.getHtmlLabelName(403,user.getLanguage())%> - - JPC<%=SystemEnv.getHtmlLabelName(2171,user.getLanguage())%><%=SystemEnv.getHtmlLabelName(16992,user.getLanguage())%> - -
<%=SystemEnv.getHtmlLabelName(613002, user.getLanguage())%> - - - - - <%=SystemEnv.getHtmlLabelName(913, user.getLanguage())%> - - -
<%=SystemEnv.getHtmlLabelName(620002, user.getLanguage())%> - - - - -<%-- <%--%> -<%-- //管理员组才能查询所有部门下合同--%> -<%-- if(HrmUserVarify.checkUserRight("ContactInfo:Manager", user)){--%> -<%-- %>--%> -<%-- -<%-- id="reqDeptId"--%> -<%-- name="reqDeptId"--%> -<%-- browserValue="<%=reqDeptId %>"--%> -<%-- browserUrl="/systeminfo/BrowserMain.jsp?url=/hrm/company/DepartmentBrowser.jsp"--%> -<%-- hasInput="true"--%> -<%-- isSingle="true"--%> -<%-- hasBrowser = "true"--%> -<%-- isMustInput='1'--%> -<%-- width="165px"--%> -<%-- browserSpanValue="<%=Util.toScreen(DepartmentComInfo.getDepartmentname(reqDeptId),user.getLanguage())%>">--%> -<%-- --%> - -<%-- <%––%>--%> -<%-- <%}else{ %>--%> -<%-- <%=Util.toScreen(DepartmentComInfo.getDepartmentname(reqDeptId),user.getLanguage()) %>--%> -<%-- <%} %>--%> - 付款状态 - - <%=SystemEnv.getHtmlLabelName(620017, user.getLanguage())%> - -
<%=SystemEnv.getHtmlLabelName(15775, user.getLanguage())%> - - <%=SystemEnv.getHtmlLabelName(15142, user.getLanguage())%> - - <%=SystemEnv.getHtmlLabelName(141,user.getLanguage())%>: - - - "> - - - - <%-- - <%--_url="/systeminfo/BrowserMain.jsp?url=/hrm/company/SubcompanyBrowser.jsp"--%> - <%--_displayText="<%=SubCompanyComInfo.getSubCompanyname(subCompanyId+"")%>"--%> - <%-->--%> -
<%=SystemEnv.getHtmlLabelName(16404, user.getLanguage())%><%=SystemEnv.getHtmlLabelName(195, user.getLanguage())%> - - 销售合同状态 - - 开闭口类型 - -
- -
- -
- - - - -
- <% - - String tableString = ""; - String backfields = " CrmContractInfo.id,case CrmContractInfo.opentype when '0' then '闭口' when '1' then '开口' when '2' then '周期性' end opentype, reqDeptId, suppliersId, conNo, name, startDate, endDate, case isOverdue when 'Y' then '是' else '否' end as isOverdue, conAmount, content, ',' as str_temp, case isOverdueNext when 'Y' then '是' else '否' end as isOverdueNext, case CrmContractInfo.status when '0' then '执行中' when '1' then '已结清' end as status, CrmContractInfo.creator, CrmContractInfo.subcompanyid1, case conStatus when '0' then '执行' when '1' then '待续签' when '2' then '已续签' when '3' then '关闭' end as reNewStatus, contractName, saleContract, case when dbo.getReNewStatus2(1,CrmContractInfo.saleContract) > 0 then '已续签' when dbo.getReNewStatus2(2,CrmContractInfo.saleContract) > 0 then '待续签' when dbo.getReNewStatus2(3,CrmContractInfo.saleContract) > 0 then '无需续签' end as reNewStatus2,case CrmSalesContractInfo.status when '0' then '已签署' when '1' then '未签署' when '2' then '已续签' when '3' then '关闭' end as csstatus "; - String fromSql = " CrmContractInfo Left Join CrmSalesContractInfo On CrmSalesContractInfo.id=CrmContractInfo.saleContract "; - //out.print("select"+backfields+"from"+fromSql +sqlwhere); - String str_content = "content"+"str_temp"; - tableString = " " + "" + ""; - tableString += ""; - tableString += ""; - tableString += ""; - tableString += ""; - tableString += ""; - tableString += ""; - //tableString += ""; - tableString += ""; - tableString += ""; - tableString += ""; - tableString += ""; - tableString += ""; - //tableString += ""; - tableString += ""; - tableString += ""; - tableString += ""; - tableString += ""; - tableString += ""; - tableString += ""; - tableString += "
"; - %> - - -
-
- <%@ include file="/systeminfo/RightClickMenu_wev8.jsp"%> - - - - - - - \ No newline at end of file diff --git a/src/main/resources/ajzx/ContractReportExport.jsp b/src/main/resources/ajzx/ContractReportExport.jsp deleted file mode 100644 index 2590773..0000000 --- a/src/main/resources/ajzx/ContractReportExport.jsp +++ /dev/null @@ -1,127 +0,0 @@ -<%@ page language="java" contentType="text/html; charset=GBK" %> -<%@ include file="/systeminfo/init.jsp" %> -<%@ page import="weaver.general.Util, weaver.file.ExcelSheet, weaver.file.ExcelRow" %> - - - - - - - - - - -<%! - public static String ToDBC(String input) { - char[] c = input.toCharArray(); - for (int i = 0; i < c.length; i++) { - if (c[i] == 12288) { - //ȫǿոΪ12288ǿոΪ32 - c[i] = (char) 32; - continue; - } - if (c[i] > 65280 && c[i] < 65375) - //ַ(33-126)ȫ(65281-65374)ĶӦϵǣ65248 - c[i] = (char) (c[i] - 65248); - } - return new String(c); - } - - -%> - -<% - // String sqlwhere=(String)session.getAttribute("sqlwhere"); -// String orderStr=(String)session.getAttribute("orderStr"); - - String sqlwhere = request.getParameter("sqlwhere"); - sqlwhere = ToDBC(sqlwhere); - String orderStr = request.getParameter("orderStr"); - orderStr = ToDBC(orderStr); - - String sqlstr = ""; - - if (RecordSet.getDBType().equals("oracle")) { - sqlstr = "select CrmContractInfo.id, reqDeptId, suppliersId, conNo, name, startDate, endDate, case isOverdue when 'Y' then '' else '' end as isOverdue, conAmount, content, case isOverdueNext when 'Y' then '' else '' end as isOverdueNext, case CrmContractInfo.status when '0' then 'ִ' when '1' then 'ѽ' end as status, case isOneSuppliers when 'Y' then '' when 'N' then '' else '' end as isOneSuppliers, prRequestId,jpcNo,jpcFile,prNo,prAmount,prAmountSum,conAmount,managerId,subject,giveDate,giveRemark,payRemark,content,CrmContractInfo.createDate,CrmContractInfo.creator,CrmContractInfo.subcompanyid1, case conStatus when '0' then 'ִ' when '1' then 'ǩ' when '2' then 'ǩ' when '3' then 'ر' end as reNewStatus,contractName, saleContract, case CrmSalesContractInfo.status when '0' then 'ǩ' when '1' then 'δǩ' when '2' then 'ǩ' when '3' then 'ر' end as reNewStatus2 from CrmContractInfo Left Join CrmSalesContractInfo On CrmSalesContractInfo.id=CrmContractInfo.saleContract" + sqlwhere + orderStr; - } else { - sqlstr = "select CrmContractInfo.id, reqDeptId, suppliersId, conNo, name, startDate, endDate, case isOverdue when 'Y' then '' else '' end as isOverdue, conAmount, content, case isOverdueNext when 'Y' then '' else '' end as isOverdueNext, case CrmContractInfo.status when '0' then 'ִ' when '1' then 'ѽ' end as status, case isOneSuppliers when 'Y' then '' when 'N' then '' else '' end as isOneSuppliers, prRequestId,jpcNo,jpcFile,prNo,prAmount,prAmountSum,conAmount,managerId,subject,giveDate,giveRemark,payRemark,content,CrmContractInfo.createDate,CrmContractInfo.creator,CrmContractInfo.subcompanyid1, case conStatus when '0' then 'ִ' when '1' then 'ǩ' when '2' then 'ǩ' when '3' then 'ر' end as reNewStatus,contractName, saleContract, case CrmSalesContractInfo.status when '0' then 'ǩ' when '1' then 'δǩ' when '2' then 'ǩ' when '3' then 'ر' end as reNewStatus2 from CrmContractInfo Left Join CrmSalesContractInfo On CrmSalesContractInfo.id=CrmContractInfo.saleContract" + sqlwhere + orderStr; - } - new BaseBean().writeLog(">>>>>>>>"+sqlstr); - RecordSet.executeQuery(sqlstr); - - ExcelSheet es = new ExcelSheet(); - - ExcelRow er = es.newExcelRow(); - er.addStringValue(SystemEnv.getHtmlLabelName(141,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620002,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(613002,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(21282,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(15142,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(1970,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(15236,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620016,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(6146,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620015,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620017,user.getLanguage())); - er.addStringValue("״̬"); - er.addStringValue(SystemEnv.getHtmlLabelName(913,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620009,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620003,user.getLanguage())); - er.addStringValue("JPC"+SystemEnv.getHtmlLabelName(16992,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620004,user.getLanguage())); - er.addStringValue("PR"+SystemEnv.getHtmlLabelName(403,user.getLanguage())); - er.addStringValue("PR"+SystemEnv.getHtmlLabelName(856,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620010,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620011,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620006,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620012,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620013,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620014,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620015,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(614,user.getLanguage())+SystemEnv.getHtmlLabelName(722,user.getLanguage())); - er.addStringValue("ͬ״̬"); - er.addStringValue("ۺͬ"); - er.addStringValue("ۺͬ״̬"); - - while (RecordSet.next()) { - ExcelRow erdetail = es.newExcelRow(); - erdetail.addStringValue(SubCompanyComInfo.getSubCompanyname(RecordSet.getString("subcompanyid1"))); - erdetail.addStringValue(DepartmentComInfo.getDepartmentname(RecordSet.getString("reqDeptId"))); - erdetail.addStringValue(CrmSupplierComInfo.getSuppliername(RecordSet.getString("suppliersId"))); - erdetail.addStringValue(RecordSet.getString("conNo")); - erdetail.addStringValue(RecordSet.getString("name")); - erdetail.addStringValue(RecordSet.getString("startDate")); - erdetail.addStringValue(RecordSet.getString("endDate")); - erdetail.addStringValue(RecordSet.getString("isOverdue")); - erdetail.addStringValue(RecordSet.getString("conAmount")); - erdetail.addStringValue(Util.toScreen(SptmForDoc.getDocName(RecordSet.getString("content")), user.getLanguage())); - erdetail.addStringValue(RecordSet.getString("isOverdueNext")); - erdetail.addStringValue(RecordSet.getString("status")); - erdetail.addStringValue(Util.toScreen(ResourceComInfo.getResourcename(RecordSet.getString("creator")), user.getLanguage())); - erdetail.addStringValue(RecordSet.getString("isOneSuppliers")); - erdetail.addStringValue(RequestComInfo.getRequestname(RecordSet.getString("prRequestId"))); - erdetail.addStringValue(RecordSet.getString("jpcNo")); - erdetail.addStringValue(DocComInfo.getDocname(RecordSet.getString("jpcFile"))); - erdetail.addStringValue(RecordSet.getString("prNo")); - erdetail.addStringValue(RecordSet.getString("prAmount")); - erdetail.addStringValue(RecordSet.getString("prAmountSum")); - erdetail.addStringValue(ResourceComInfo.getResourcename(RecordSet.getString("managerId"))); - erdetail.addStringValue(RecordSet.getString("subject")); - erdetail.addStringValue(RecordSet.getString("giveDate")); - erdetail.addStringValue(RecordSet.getString("giveRemark")); - erdetail.addStringValue(RecordSet.getString("payRemark")); - erdetail.addStringValue(DocComInfo.getDocname(RecordSet.getString("content"))); - erdetail.addStringValue(RecordSet.getString("createDate")); - erdetail.addStringValue(RecordSet.getString("reNewStatus")); - erdetail.addStringValue(RecordSet.getString("contractName")); - erdetail.addStringValue(RecordSet.getString("reNewStatus2")); - } - - ExcelFile.init(); - ExcelFile.setFilename("ͬ"); - ExcelFile.addSheet("ͬ", es); -%> - -<%----%> \ No newline at end of file diff --git a/src/test/java/bokang/xiao/NormalTest.java b/src/test/java/bokang/xiao/NormalTest.java index 7b03a1d..7227bb1 100644 --- a/src/test/java/bokang/xiao/NormalTest.java +++ b/src/test/java/bokang/xiao/NormalTest.java @@ -305,7 +305,7 @@ public class NormalTest extends BaseTest { queryParam.put("fieldValue","mqErrorLogModelId"); ModeMapper mapper = Util.getMapper(ModeMapper.class); Map modeData = mapper.queryModeDataInfo("uf_systemconfig", queryParam); - modeChangeService.changeOtherMode(modeData,"-18"); + modeChangeService.changeOtherMode(modeData,"-18",1); } @Test @@ -341,4 +341,11 @@ public class NormalTest extends BaseTest { String s = customSearchDepart.generateSqlCondition(param); } + @Test + public void testSub(){ + String sourceStr = ",0,1,2,"; + String value = ",0,"; + System.out.println(sourceStr.contains(value)); + } + } From 3ed657ebec068a1472affbf244607b72f22f330d Mon Sep 17 00:00:00 2001 From: ic_excellent <2570192571@qq.com> Date: Sat, 6 May 2023 15:17:47 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- .../zenner/utils/ZennerUtil.java | 149 +++--- src/main/resources/ContractList(2).jsp | 499 ------------------ .../resources/ContractReportExport(1).jsp | 127 ----- 4 files changed, 75 insertions(+), 702 deletions(-) delete mode 100644 src/main/resources/ContractList(2).jsp delete mode 100644 src/main/resources/ContractReportExport(1).jsp diff --git a/.gitignore b/.gitignore index b580d99..e4ee4f5 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ bin-release/ # Executables -#.gitignore +#.gitigno re log *.swf *.air diff --git a/src/main/java/com/api/nonstandardext/zenner/utils/ZennerUtil.java b/src/main/java/com/api/nonstandardext/zenner/utils/ZennerUtil.java index af3749e..9182431 100644 --- a/src/main/java/com/api/nonstandardext/zenner/utils/ZennerUtil.java +++ b/src/main/java/com/api/nonstandardext/zenner/utils/ZennerUtil.java @@ -1,6 +1,5 @@ package com.api.nonstandardext.zenner.utils; -import com.api.nonstandardext.allist.utils.DefaultTmForAllist; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import org.apache.commons.httpclient.HttpClient; @@ -178,48 +177,48 @@ public class ZennerUtil { return result; } - public static String httpsGet(String baseUrl,String encoderNum) { - BufferedReader in = null; - BaseBean baseBean = new BaseBean(); - try { - SSLContext sslContext = SSLContext.getInstance("TLSv1.2"); - javax.net.ssl.TrustManager[] truset = new javax.net.ssl.TrustManager[1]; - javax.net.ssl.TrustManager tm = new DefaultTmForAllist(); - truset[0] = tm; - sslContext.init(null, truset, null); - SSLSocketFactory factory = sslContext.getSocketFactory(); - URL u = new URL(baseUrl); - HttpsURLConnection huconn = (HttpsURLConnection) u.openConnection(); - huconn.setSSLSocketFactory(factory); - huconn.setRequestProperty("Authorization","Basic " + encoderNum); - StringBuilder result = new StringBuilder(); - huconn.connect(); -// baseBean.writeLog("httpsGet execute baseUrl..1." + baseUrl); - in = new BufferedReader(new InputStreamReader(huconn.getInputStream(), "UTF-8")); - String line; - while ((line = in.readLine()) != null) { - result.append(line); - } - if (in != null) { - in.close(); - } -// baseBean.writeLog("httpsGet execute result..1." + result.toString()); - // 打印返回结果 - return result.toString(); - } catch (Exception e) { - baseBean.writeLog("httpsGet execute exception...message:" + e.getMessage()); - if (in != null) { - try { - in.close(); - } catch (IOException ioException) { - ioException.printStackTrace(); - baseBean.writeLog("关闭报错"); - baseBean.writeLog(ioException.getMessage()); - } - } - return ""; - } - } +// public static String httpsGet(String baseUrl,String encoderNum) { +// BufferedReader in = null; +// BaseBean baseBean = new BaseBean(); +// try { +// SSLContext sslContext = SSLContext.getInstance("TLSv1.2"); +// javax.net.ssl.TrustManager[] truset = new javax.net.ssl.TrustManager[1]; +// javax.net.ssl.TrustManager tm = new DefaultTmForAllist(); +// truset[0] = tm; +// sslContext.init(null, truset, null); +// SSLSocketFactory factory = sslContext.getSocketFactory(); +// URL u = new URL(baseUrl); +// HttpsURLConnection huconn = (HttpsURLConnection) u.openConnection(); +// huconn.setSSLSocketFactory(factory); +// huconn.setRequestProperty("Authorization","Basic " + encoderNum); +// StringBuilder result = new StringBuilder(); +// huconn.connect(); +//// baseBean.writeLog("httpsGet execute baseUrl..1." + baseUrl); +// in = new BufferedReader(new InputStreamReader(huconn.getInputStream(), "UTF-8")); +// String line; +// while ((line = in.readLine()) != null) { +// result.append(line); +// } +// if (in != null) { +// in.close(); +// } +//// baseBean.writeLog("httpsGet execute result..1." + result.toString()); +// // 打印返回结果 +// return result.toString(); +// } catch (Exception e) { +// baseBean.writeLog("httpsGet execute exception...message:" + e.getMessage()); +// if (in != null) { +// try { +// in.close(); +// } catch (IOException ioException) { +// ioException.printStackTrace(); +// baseBean.writeLog("关闭报错"); +// baseBean.writeLog(ioException.getMessage()); +// } +// } +// return ""; +// } +// } public static String httpGet(String baseUrl){ @@ -244,38 +243,38 @@ public class ZennerUtil { } } - public static String httpsPost(String httpUrl, String content) throws Exception { - BufferedReader in = null; - SSLContext sslContext = SSLContext.getInstance("TLSv1.2"); - javax.net.ssl.TrustManager [] truset = new javax.net.ssl.TrustManager[1]; - javax.net.ssl.TrustManager tm = new DefaultTmForAllist(); - truset[0] = tm; - sslContext.init(null,truset,null); - SSLSocketFactory factory = sslContext.getSocketFactory(); -//https://blog.csdn.net/pk5454754/article/details/80092974?utm_medium=distribute.pc_relevant_download.none-task-blog-baidujs-1.nonecase&depth_1-utm_source=distribute.pc_relevant_download.none-task-blog-baidujs-1.nonecase - URL u = new URL(httpUrl); - HttpsURLConnection conn = (HttpsURLConnection) u.openConnection(); - conn.setDoOutput(true); - conn.addRequestProperty("connection", "Keep-Alive"); - conn.setRequestMethod("POST"); - conn.setSSLSocketFactory(factory); - StringBuilder result = new StringBuilder(); - conn.connect(); - DataOutputStream out = new DataOutputStream(conn.getOutputStream()); - out.write(content.getBytes("utf-8")); - // 刷新、关闭 - out.flush(); - out.close(); - in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8")); - String line; - while ((line = in.readLine()) != null) { - result.append(line); - } - if (in != null) { - in.close(); - } - return result.toString(); - } +// public static String httpsPost(String httpUrl, String content) throws Exception { +// BufferedReader in = null; +// SSLContext sslContext = SSLContext.getInstance("TLSv1.2"); +// javax.net.ssl.TrustManager [] truset = new javax.net.ssl.TrustManager[1]; +// javax.net.ssl.TrustManager tm = new DefaultTmForAllist(); +// truset[0] = tm; +// sslContext.init(null,truset,null); +// SSLSocketFactory factory = sslContext.getSocketFactory(); +////https://blog.csdn.net/pk5454754/article/details/80092974?utm_medium=distribute.pc_relevant_download.none-task-blog-baidujs-1.nonecase&depth_1-utm_source=distribute.pc_relevant_download.none-task-blog-baidujs-1.nonecase +// URL u = new URL(httpUrl); +// HttpsURLConnection conn = (HttpsURLConnection) u.openConnection(); +// conn.setDoOutput(true); +// conn.addRequestProperty("connection", "Keep-Alive"); +// conn.setRequestMethod("POST"); +// conn.setSSLSocketFactory(factory); +// StringBuilder result = new StringBuilder(); +// conn.connect(); +// DataOutputStream out = new DataOutputStream(conn.getOutputStream()); +// out.write(content.getBytes("utf-8")); +// // 刷新、关闭 +// out.flush(); +// out.close(); +// in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8")); +// String line; +// while ((line = in.readLine()) != null) { +// result.append(line); +// } +// if (in != null) { +// in.close(); +// } +// return result.toString(); +// } public static String httpPostForXwwwForm(String httpUrl, Map headParams, Map paramsMap){ String result = ""; diff --git a/src/main/resources/ContractList(2).jsp b/src/main/resources/ContractList(2).jsp deleted file mode 100644 index 9070046..0000000 --- a/src/main/resources/ContractList(2).jsp +++ /dev/null @@ -1,499 +0,0 @@ -<%@ page language="java" contentType="text/html; charset=UTF-8" %> -<%@ include file="/systeminfo/init_wev8.jsp"%> -<%@ taglib uri="/WEB-INF/weaver.tld" prefix="wea"%> -<%@ taglib uri="/WEB-INF/tld/browser.tld" prefix="brow"%> - -<%@ page import="weaver.file.Prop" %> -<%@ page import="weaver.hrm.HrmUserVarify" %> -<%@ page import="weaver.systeminfo.SystemEnv" %> - - - - - - - - - - - - - - - -<% - - String sqlwhere = " where 1=1 "; - - String subcompanyid1 = ResourceComInfo.getSubCompanyID(String.valueOf(user.getUID())); - - //是否采购部 - boolean isDep = false; - //是否是流程接收人 - boolean isShow = false; - //采购部的同事可以选择所有合同卡片;而本部门的人员(非采购部)只能选择本部门的合同卡片 - RecordSet_Dep.executeSql("select * from HrmDepartment where departmentname like '%采购%' and id="+user.getUserDepartment()); - if(RecordSet_Dep.next()) isDep = true; - - //是否合同流程接收人 - String sqlwhere_workflow = ""; - RecordSet_Dep.executeSql("select distinct requestId from workflow_currentoperator where workflowid in (79,148,133,128,118,108,98,153,167,316,470,514,532,543,600,717,719,739,832,927,929) and userid="+user.getUID()); - if(RecordSet_Dep.next()) isShow = true; - - if(!HrmUserVarify.checkUserRight("ContactInfo:Manager", user) && !HrmUserVarify.checkUserRight("ContactInfo:User", user) && !isShow && !isDep){ - response.sendRedirect("/notice/noright.jsp"); - } - - //如果是合同管理权限,则直接1=1 - if(HrmUserVarify.checkUserRight("ContactInfo:Manager", user)){ - sqlwhere += " and 1=1"; - }else if(isShow && HrmUserVarify.checkUserRight("ContactInfo:User", user)){ - //如果是流程接收人,并且有合同查看权限 - sqlwhere += " and (requestid in (select distinct requestId from workflow_currentoperator where workflowid in (79,148,133,128,118,108,98,153,167,316,470,514,532,543,600,717,719,739,832,927,929) and userid="+user.getUID()+") or reqDeptId = '"+user.getUserDepartment()+"')"; - - }else if(HrmUserVarify.checkUserRight("ContactInfo:User", user)){ - //如果只有合同查看权限 - sqlwhere += " and reqDeptId = '"+user.getUserDepartment()+"'"; - - }else if(isShow){ - //如果只是流程接收人 - sqlwhere += " and requestid in (select distinct requestId from workflow_currentoperator where workflowid in (79,148,133,128,118,108,98,153,167,316,470,514,532,543,600,717,719,739,832,927,929) and userid="+user.getUID()+")"; - } - - //如果没有查看全部的权限,加分部条件 - if(!HrmUserVarify.checkUserRight("ContactInfoList:ALL", user)){ - if (!subcompanyid1.equals("0")) {sqlwhere += " and CrmContractInfo.subcompanyid1 = '"+subcompanyid1+"' ";} - } - String imagefilename = "/images/hdReport.gif"; - String titlename = SystemEnv.getHtmlLabelName(614, user.getLanguage()) + SystemEnv.getHtmlLabelName(527, user.getLanguage()); - String needfav = "1"; - String needhelp = ""; -%> - - <%@ include file="/systeminfo/TopTitle_wev8.jsp"%> - <%@ include file="/systeminfo/RightClickMenuConent_wev8.jsp"%> - <% - RCMenu += "{" + SystemEnv.getHtmlLabelName(197, user.getLanguage()) + ",javascript:OnSearch(),_top} "; - RCMenuHeight += RCMenuHeightStep; - RCMenu += "{" + "Excel,javascript:ContractExport(),_top} "; - RCMenuHeight += RCMenuHeightStep; - RCMenu += "{" + SystemEnv.getHtmlLabelName(18363, user.getLanguage()) + ",javascript:_table.firstPage(),_self}"; - RCMenuHeight += RCMenuHeightStep; - RCMenu += "{" + SystemEnv.getHtmlLabelName(1258, user.getLanguage()) + ",javascript:_table.prePage(),_self}"; - RCMenuHeight += RCMenuHeightStep; - RCMenu += "{" + SystemEnv.getHtmlLabelName(1259, user.getLanguage()) + ",javascript:_table.nextPage(),_self}"; - RCMenuHeight += RCMenuHeightStep; - RCMenu += "{" + SystemEnv.getHtmlLabelName(18362, user.getLanguage()) + ",javascript:_table.lastPage(),_self}"; - RCMenuHeight += RCMenuHeightStep; - %> - <% - int pagenum = Util.getIntValue(request.getParameter("pagenum"), 1); - int perpage = Util.getPerpageLog(); - if (perpage <= 1) perpage = 10; - - String creator = Util.fromScreen(request.getParameter("creator"), user.getLanguage()); - String fromdate = Util.fromScreen(request.getParameter("fromdate"), user.getLanguage()); - String fromdate2 = Util.fromScreen(request.getParameter("fromdate2"), user.getLanguage()); - String enddate = Util.fromScreen(request.getParameter("enddate"), user.getLanguage()); - String enddate2 = Util.fromScreen(request.getParameter("enddate2"), user.getLanguage()); - String status_temp = Util.null2String(request.getParameter("status_temp")); - - String conNo = Util.fromScreen(request.getParameter("conNo"), user.getLanguage()); - String prNo = Util.fromScreen(request.getParameter("prNo"), user.getLanguage()); - String jpcNo = Util.fromScreen(request.getParameter("jpcNo"), user.getLanguage()); - String suppliersId = Util.fromScreen(request.getParameter("suppliersId"), user.getLanguage()); - String isOneSuppliers = Util.fromScreen(request.getParameter("isOneSuppliers"), user.getLanguage()); -// String reqDeptId = String.valueOf(user.getUserDepartment()); - String reqDeptId = Util.fromScreen(request.getParameter("reqDeptId"), user.getLanguage());; - //管理员组或采购部才能查询所有部门下合同,合同接收人查看接收的合同 -// if(HrmUserVarify.checkUserRight("ContactInfo:Manager", user) || isShow) reqDeptId = Util.fromScreen(request.getParameter("reqDeptId"), user.getLanguage()); - String isOverdue = Util.fromScreen(request.getParameter("isOverdue"), user.getLanguage()); - String status = Util.fromScreen(request.getParameter("status"), user.getLanguage()); - String isOverdueNext = Util.fromScreen(request.getParameter("isOverdueNext"), user.getLanguage()); - String conType = Util.fromScreen(request.getParameter("conType"), user.getLanguage()); - - String name = Util.fromScreen(request.getParameter("name"), user.getLanguage()); - String subCompanyId = Util.fromScreen(request.getParameter("subCompanyId"), user.getLanguage()); - String reNewStatus = Util.fromScreen(request.getParameter("reNewStatus"), user.getLanguage()); - String conStatus = Util.fromScreen(request.getParameter("conStatus"), user.getLanguage()); - String contractName = Util.fromScreen(request.getParameter("contractName"), user.getLanguage()); - String csstatus = Util.fromScreen(request.getParameter("csstatus"), user.getLanguage()); - - int opentype = Util.getIntValue(request.getParameter("opentype"),-1); - - //String sqlwhere = " where status = '' "; - //if(!"".equals(status_temp)) sqlwhere += " and status in ("+status_temp+") "; - - if (!fromdate.equals("")) sqlwhere += " and startDate>='" + fromdate + "'"; - if (!fromdate2.equals("")) sqlwhere += " and startDate<='" + fromdate2 + "'"; - if (!enddate.equals("")) sqlwhere += " and enddate>='" + enddate + "'"; - if (!enddate2.equals("")) sqlwhere += " and enddate<='" + enddate2 + "'"; - if (!conNo.equals("")) sqlwhere += " and conNo like '%" + conNo + "%'"; - if (!prNo.equals("")) sqlwhere += " and prNo='" + prNo + "'"; - if (!jpcNo.equals("")) sqlwhere += " and jpcNo='" + jpcNo + "'"; - if(!"".equals(suppliersId)) sqlwhere += " and suppliersId=" + suppliersId; - if (!isOneSuppliers.equals("")) sqlwhere += " and isOneSuppliers='" + isOneSuppliers + "'"; - if (!"".equals(creator) && !"0".equals(creator)) sqlwhere += " and CrmContractInfo.creator=" + creator; - if (!reqDeptId.equals("")) sqlwhere += " and reqDeptId=" + reqDeptId; - if (!isOverdue.equals("")) sqlwhere += " and isOverdue='" + isOverdue + "'"; - if (!status.equals("")) sqlwhere += " and CrmContractInfo.status='" + status + "'"; - if (!isOverdueNext.equals("")) sqlwhere += " and isOverdueNext='" + isOverdueNext + "'"; - if (!conType.equals("")) sqlwhere += " and conType='" + conType + "'"; - if (!csstatus.equals("")) sqlwhere += " and CrmSalesContractInfo.status='" + csstatus + "'"; - - if (!name.equals("")) sqlwhere += " and name like '%" + name + "%'"; - if (!subCompanyId.equals("")) sqlwhere += " and CrmContractInfo.subcompanyid1 = '" + subCompanyId + "'"; - if (!reNewStatus.equals("")) sqlwhere += " and conStatus = '" + reNewStatus + "'"; - - if (!contractName.equals("")) sqlwhere += " and contractName like '%" + contractName + "%'"; - - //if (reNewStatus2.equals("待续签")) sqlwhere += " and dbo.getReNewStatus2(2,CrmContractInfo.saleContract) > 0"; - //else if (reNewStatus2.equals("已续签")) sqlwhere += " and dbo.getReNewStatus2(1,CrmContractInfo.saleContract) > 0"; - //else if (reNewStatus2.equals("无需续签")) sqlwhere += " and dbo.getReNewStatus2(3,CrmContractInfo.saleContract) > 0"; - //System.out.println("sqlwhere:"+sqlwhere); - - - if(opentype > -1){ - sqlwhere += " and isnull(CrmContractInfo.opentype,0) = " + opentype; - } - - String orderStr = " order by startDate desc, CrmContractInfo.id desc "; - -// out.println("sqlwhere:" + sqlwhere); -// out.println("orderStr:" + orderStr); - -// session.setAttribute("sqlwhere", sqlwhere); -// session.setAttribute("orderStr", orderStr); - %> -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <%if(HrmUserVarify.checkUserRight("ContactInfoList:ALL", user)){%> - - - <%}%> - - - - - - - - - - - - - - - - -
<%=SystemEnv.getHtmlLabelName(15774, user.getLanguage())%>
合同状态 - - <%=SystemEnv.getHtmlLabelName(1970, user.getLanguage())%> -   - <%=Util.toScreen(fromdate, user.getLanguage())%> -  -   - <%=Util.toScreen(fromdate2, user.getLanguage())%> - > - > - <%=SystemEnv.getHtmlLabelName(15236, user.getLanguage())%> -   - <%=Util.toScreen(enddate, user.getLanguage())%> -  -   - <%=Util.toScreen(enddate2, user.getLanguage())%> - > - > -
<%=SystemEnv.getHtmlLabelName(21282, user.getLanguage())%> - - PR<%=SystemEnv.getHtmlLabelName(403,user.getLanguage())%> - - JPC<%=SystemEnv.getHtmlLabelName(2171,user.getLanguage())%><%=SystemEnv.getHtmlLabelName(16992,user.getLanguage())%> - -
<%=SystemEnv.getHtmlLabelName(613002, user.getLanguage())%> - - - - - <%=SystemEnv.getHtmlLabelName(913, user.getLanguage())%> - - -
<%=SystemEnv.getHtmlLabelName(620002, user.getLanguage())%> - - - - -<%-- <%--%> -<%-- //管理员组才能查询所有部门下合同--%> -<%-- if(HrmUserVarify.checkUserRight("ContactInfo:Manager", user)){--%> -<%-- %>--%> -<%-- -<%-- id="reqDeptId"--%> -<%-- name="reqDeptId"--%> -<%-- browserValue="<%=reqDeptId %>"--%> -<%-- browserUrl="/systeminfo/BrowserMain.jsp?url=/hrm/company/DepartmentBrowser.jsp"--%> -<%-- hasInput="true"--%> -<%-- isSingle="true"--%> -<%-- hasBrowser = "true"--%> -<%-- isMustInput='1'--%> -<%-- width="165px"--%> -<%-- browserSpanValue="<%=Util.toScreen(DepartmentComInfo.getDepartmentname(reqDeptId),user.getLanguage())%>">--%> -<%-- --%> - -<%-- <%––%>--%> -<%-- <%}else{ %>--%> -<%-- <%=Util.toScreen(DepartmentComInfo.getDepartmentname(reqDeptId),user.getLanguage()) %>--%> -<%-- <%} %>--%> - 付款状态 - - <%=SystemEnv.getHtmlLabelName(620017, user.getLanguage())%> - -
<%=SystemEnv.getHtmlLabelName(15775, user.getLanguage())%> - - <%=SystemEnv.getHtmlLabelName(15142, user.getLanguage())%> - - <%=SystemEnv.getHtmlLabelName(141,user.getLanguage())%>: - - - "> - - - - <%-- - <%--_url="/systeminfo/BrowserMain.jsp?url=/hrm/company/SubcompanyBrowser.jsp"--%> - <%--_displayText="<%=SubCompanyComInfo.getSubCompanyname(subCompanyId+"")%>"--%> - <%-->--%> -
<%=SystemEnv.getHtmlLabelName(16404, user.getLanguage())%><%=SystemEnv.getHtmlLabelName(195, user.getLanguage())%> - - 销售合同状态 - - 开闭口类型 - -
- -
- -
- - - - -
- <% - - String tableString = ""; - String backfields = " CrmContractInfo.id,case CrmContractInfo.opentype when '0' then '闭口' when '1' then '开口' when '2' then '周期性' end opentype, reqDeptId, suppliersId, conNo, name, startDate, endDate, case isOverdue when 'Y' then '是' else '否' end as isOverdue, conAmount, content, ',' as str_temp, case isOverdueNext when 'Y' then '是' else '否' end as isOverdueNext, case CrmContractInfo.status when '0' then '执行中' when '1' then '已结清' end as status, CrmContractInfo.creator, CrmContractInfo.subcompanyid1, case conStatus when '0' then '执行' when '1' then '待续签' when '2' then '已续签' when '3' then '关闭' end as reNewStatus, contractName, saleContract, case when dbo.getReNewStatus2(1,CrmContractInfo.saleContract) > 0 then '已续签' when dbo.getReNewStatus2(2,CrmContractInfo.saleContract) > 0 then '待续签' when dbo.getReNewStatus2(3,CrmContractInfo.saleContract) > 0 then '无需续签' end as reNewStatus2,case CrmSalesContractInfo.status when '0' then '已签署' when '1' then '未签署' when '2' then '已续签' when '3' then '关闭' end as csstatus "; - String fromSql = " CrmContractInfo Left Join CrmSalesContractInfo On CrmSalesContractInfo.id=CrmContractInfo.saleContract "; - //out.print("select"+backfields+"from"+fromSql +sqlwhere); - String str_content = "content"+"str_temp"; - tableString = " " + "" + ""; - tableString += ""; - tableString += ""; - tableString += ""; - tableString += ""; - tableString += ""; - tableString += ""; - //tableString += ""; - tableString += ""; - tableString += ""; - tableString += ""; - tableString += ""; - tableString += ""; - //tableString += ""; - tableString += ""; - tableString += ""; - tableString += ""; - tableString += ""; - tableString += ""; - tableString += ""; - tableString += "
"; - %> - - -
-
- <%@ include file="/systeminfo/RightClickMenu_wev8.jsp"%> - - - - - - - \ No newline at end of file diff --git a/src/main/resources/ContractReportExport(1).jsp b/src/main/resources/ContractReportExport(1).jsp deleted file mode 100644 index 2590773..0000000 --- a/src/main/resources/ContractReportExport(1).jsp +++ /dev/null @@ -1,127 +0,0 @@ -<%@ page language="java" contentType="text/html; charset=GBK" %> -<%@ include file="/systeminfo/init.jsp" %> -<%@ page import="weaver.general.Util, weaver.file.ExcelSheet, weaver.file.ExcelRow" %> - - - - - - - - - - -<%! - public static String ToDBC(String input) { - char[] c = input.toCharArray(); - for (int i = 0; i < c.length; i++) { - if (c[i] == 12288) { - //ȫǿոΪ12288ǿոΪ32 - c[i] = (char) 32; - continue; - } - if (c[i] > 65280 && c[i] < 65375) - //ַ(33-126)ȫ(65281-65374)ĶӦϵǣ65248 - c[i] = (char) (c[i] - 65248); - } - return new String(c); - } - - -%> - -<% - // String sqlwhere=(String)session.getAttribute("sqlwhere"); -// String orderStr=(String)session.getAttribute("orderStr"); - - String sqlwhere = request.getParameter("sqlwhere"); - sqlwhere = ToDBC(sqlwhere); - String orderStr = request.getParameter("orderStr"); - orderStr = ToDBC(orderStr); - - String sqlstr = ""; - - if (RecordSet.getDBType().equals("oracle")) { - sqlstr = "select CrmContractInfo.id, reqDeptId, suppliersId, conNo, name, startDate, endDate, case isOverdue when 'Y' then '' else '' end as isOverdue, conAmount, content, case isOverdueNext when 'Y' then '' else '' end as isOverdueNext, case CrmContractInfo.status when '0' then 'ִ' when '1' then 'ѽ' end as status, case isOneSuppliers when 'Y' then '' when 'N' then '' else '' end as isOneSuppliers, prRequestId,jpcNo,jpcFile,prNo,prAmount,prAmountSum,conAmount,managerId,subject,giveDate,giveRemark,payRemark,content,CrmContractInfo.createDate,CrmContractInfo.creator,CrmContractInfo.subcompanyid1, case conStatus when '0' then 'ִ' when '1' then 'ǩ' when '2' then 'ǩ' when '3' then 'ر' end as reNewStatus,contractName, saleContract, case CrmSalesContractInfo.status when '0' then 'ǩ' when '1' then 'δǩ' when '2' then 'ǩ' when '3' then 'ر' end as reNewStatus2 from CrmContractInfo Left Join CrmSalesContractInfo On CrmSalesContractInfo.id=CrmContractInfo.saleContract" + sqlwhere + orderStr; - } else { - sqlstr = "select CrmContractInfo.id, reqDeptId, suppliersId, conNo, name, startDate, endDate, case isOverdue when 'Y' then '' else '' end as isOverdue, conAmount, content, case isOverdueNext when 'Y' then '' else '' end as isOverdueNext, case CrmContractInfo.status when '0' then 'ִ' when '1' then 'ѽ' end as status, case isOneSuppliers when 'Y' then '' when 'N' then '' else '' end as isOneSuppliers, prRequestId,jpcNo,jpcFile,prNo,prAmount,prAmountSum,conAmount,managerId,subject,giveDate,giveRemark,payRemark,content,CrmContractInfo.createDate,CrmContractInfo.creator,CrmContractInfo.subcompanyid1, case conStatus when '0' then 'ִ' when '1' then 'ǩ' when '2' then 'ǩ' when '3' then 'ر' end as reNewStatus,contractName, saleContract, case CrmSalesContractInfo.status when '0' then 'ǩ' when '1' then 'δǩ' when '2' then 'ǩ' when '3' then 'ر' end as reNewStatus2 from CrmContractInfo Left Join CrmSalesContractInfo On CrmSalesContractInfo.id=CrmContractInfo.saleContract" + sqlwhere + orderStr; - } - new BaseBean().writeLog(">>>>>>>>"+sqlstr); - RecordSet.executeQuery(sqlstr); - - ExcelSheet es = new ExcelSheet(); - - ExcelRow er = es.newExcelRow(); - er.addStringValue(SystemEnv.getHtmlLabelName(141,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620002,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(613002,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(21282,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(15142,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(1970,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(15236,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620016,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(6146,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620015,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620017,user.getLanguage())); - er.addStringValue("״̬"); - er.addStringValue(SystemEnv.getHtmlLabelName(913,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620009,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620003,user.getLanguage())); - er.addStringValue("JPC"+SystemEnv.getHtmlLabelName(16992,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620004,user.getLanguage())); - er.addStringValue("PR"+SystemEnv.getHtmlLabelName(403,user.getLanguage())); - er.addStringValue("PR"+SystemEnv.getHtmlLabelName(856,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620010,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620011,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620006,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620012,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620013,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620014,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(620015,user.getLanguage())); - er.addStringValue(SystemEnv.getHtmlLabelName(614,user.getLanguage())+SystemEnv.getHtmlLabelName(722,user.getLanguage())); - er.addStringValue("ͬ״̬"); - er.addStringValue("ۺͬ"); - er.addStringValue("ۺͬ״̬"); - - while (RecordSet.next()) { - ExcelRow erdetail = es.newExcelRow(); - erdetail.addStringValue(SubCompanyComInfo.getSubCompanyname(RecordSet.getString("subcompanyid1"))); - erdetail.addStringValue(DepartmentComInfo.getDepartmentname(RecordSet.getString("reqDeptId"))); - erdetail.addStringValue(CrmSupplierComInfo.getSuppliername(RecordSet.getString("suppliersId"))); - erdetail.addStringValue(RecordSet.getString("conNo")); - erdetail.addStringValue(RecordSet.getString("name")); - erdetail.addStringValue(RecordSet.getString("startDate")); - erdetail.addStringValue(RecordSet.getString("endDate")); - erdetail.addStringValue(RecordSet.getString("isOverdue")); - erdetail.addStringValue(RecordSet.getString("conAmount")); - erdetail.addStringValue(Util.toScreen(SptmForDoc.getDocName(RecordSet.getString("content")), user.getLanguage())); - erdetail.addStringValue(RecordSet.getString("isOverdueNext")); - erdetail.addStringValue(RecordSet.getString("status")); - erdetail.addStringValue(Util.toScreen(ResourceComInfo.getResourcename(RecordSet.getString("creator")), user.getLanguage())); - erdetail.addStringValue(RecordSet.getString("isOneSuppliers")); - erdetail.addStringValue(RequestComInfo.getRequestname(RecordSet.getString("prRequestId"))); - erdetail.addStringValue(RecordSet.getString("jpcNo")); - erdetail.addStringValue(DocComInfo.getDocname(RecordSet.getString("jpcFile"))); - erdetail.addStringValue(RecordSet.getString("prNo")); - erdetail.addStringValue(RecordSet.getString("prAmount")); - erdetail.addStringValue(RecordSet.getString("prAmountSum")); - erdetail.addStringValue(ResourceComInfo.getResourcename(RecordSet.getString("managerId"))); - erdetail.addStringValue(RecordSet.getString("subject")); - erdetail.addStringValue(RecordSet.getString("giveDate")); - erdetail.addStringValue(RecordSet.getString("giveRemark")); - erdetail.addStringValue(RecordSet.getString("payRemark")); - erdetail.addStringValue(DocComInfo.getDocname(RecordSet.getString("content"))); - erdetail.addStringValue(RecordSet.getString("createDate")); - erdetail.addStringValue(RecordSet.getString("reNewStatus")); - erdetail.addStringValue(RecordSet.getString("contractName")); - erdetail.addStringValue(RecordSet.getString("reNewStatus2")); - } - - ExcelFile.init(); - ExcelFile.setFilename("ͬ"); - ExcelFile.addSheet("ͬ", es); -%> - -<%----%> \ No newline at end of file