diff --git a/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/PasswordDTO.java b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/PasswordDTO.java index 7f3dec5314..7559bad559 100644 --- a/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/PasswordDTO.java +++ b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/PasswordDTO.java @@ -23,7 +23,10 @@ import java.io.Serializable; @Data public class PasswordDTO implements Serializable { private static final long serialVersionUID = 1L; - + /** + * 旧密码 + */ + private String oldPassword; @NotBlank(message="{sysuser.password.require}") private String password; diff --git a/epmet-auth/pom.xml b/epmet-auth/pom.xml index d14d863674..1822235cdc 100644 --- a/epmet-auth/pom.xml +++ b/epmet-auth/pom.xml @@ -138,6 +138,16 @@ epmet-auth-client 2.0.0 + + dingtalk-spring-boot-starter + com.taobao + 1.0.0 + + + commons-codec + commons-codec + 1.15 + diff --git a/epmet-auth/src/main/java/com/epmet/AuthApplication.java b/epmet-auth/src/main/java/com/epmet/AuthApplication.java index 0bf685bd5b..07d85a0d5f 100644 --- a/epmet-auth/src/main/java/com/epmet/AuthApplication.java +++ b/epmet-auth/src/main/java/com/epmet/AuthApplication.java @@ -8,6 +8,7 @@ package com.epmet; +import com.taobao.dingtalk.spring.annotations.EnableDingTalk; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.ServletComponentScan; @@ -20,6 +21,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; * @author Mark sunlightcs@gmail.com * @since 1.0.0 */ +@EnableDingTalk @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients diff --git a/epmet-auth/src/main/java/com/epmet/controller/DingdingLoginController.java b/epmet-auth/src/main/java/com/epmet/controller/DingdingLoginController.java new file mode 100644 index 0000000000..538060a391 --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/controller/DingdingLoginController.java @@ -0,0 +1,79 @@ +package com.epmet.controller; + +import com.dingtalk.api.DefaultDingTalkClient; +import com.dingtalk.api.DingTalkClient; +import com.dingtalk.api.request.OapiGettokenRequest; +import com.dingtalk.api.request.OapiSnsGetuserinfoBycodeRequest; +import com.dingtalk.api.request.OapiUserGetbyunionidRequest; +import com.dingtalk.api.request.OapiV2UserGetRequest; +import com.dingtalk.api.response.OapiGettokenResponse; +import com.dingtalk.api.response.OapiSnsGetuserinfoBycodeResponse; +import com.dingtalk.api.response.OapiUserGetbyunionidResponse; +import com.dingtalk.api.response.OapiV2UserGetResponse; +import com.epmet.commons.tools.utils.Result; +import com.taobao.api.ApiException; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * 免登第三方网站 + * + * @author openapi@dingtalk + */ +@RestController("dingtalk") +public class DingdingLoginController { + + /** + * 获取授权用户的个人信息 openapi@dingtalk + * + * @return + * @throws Exception ServiceResult> 2020-11-4 + */ + @RequestMapping(value = "/auth", method = RequestMethod.GET) + public Result getDdScan(@RequestParam("code") String code) throws Exception { + // 获取access_token,注意正式代码要有异常流处理 + String access_token = this.getToken(); + + // 通过临时授权码获取授权用户的个人信息 + DefaultDingTalkClient client2 = new DefaultDingTalkClient("https://oapi.dingtalk.com/sns/getuserinfo_bycode"); + OapiSnsGetuserinfoBycodeRequest reqBycodeRequest = new OapiSnsGetuserinfoBycodeRequest(); + + reqBycodeRequest.setTmpAuthCode(code); + OapiSnsGetuserinfoBycodeResponse bycodeResponse = client2.execute(reqBycodeRequest, "yourAppId", "yourAppSecret"); + + // 根据unionid获取userid + String unionid = bycodeResponse.getUserInfo().getUnionid(); + DingTalkClient clientDingTalkClient = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/user/getbyunionid"); + OapiUserGetbyunionidRequest reqGetbyunionidRequest = new OapiUserGetbyunionidRequest(); + reqGetbyunionidRequest.setUnionid(unionid); + OapiUserGetbyunionidResponse oapiUserGetbyunionidResponse = clientDingTalkClient.execute(reqGetbyunionidRequest, access_token); + + // 根据userId获取用户信息 + String userid = oapiUserGetbyunionidResponse.getResult().getUserid(); + DingTalkClient clientDingTalkClient2 = new DefaultDingTalkClient( + "https://oapi.dingtalk.com/topapi/v2/user/get"); + OapiV2UserGetRequest reqGetRequest = new OapiV2UserGetRequest(); + reqGetRequest.setUserid(userid); + //reqGetRequest.setLang("zh_CN"); + OapiV2UserGetResponse rspGetResponse = clientDingTalkClient2.execute(reqGetRequest, access_token); + System.out.println(rspGetResponse.getBody()); + return new Result().ok(rspGetResponse.getBody()); + } + private String getToken() throws RuntimeException { + try { + DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken"); + OapiGettokenRequest request = new OapiGettokenRequest(); + + request.setAppkey("dingiopfbtn8mktfoaf0"); + request.setAppsecret("RcmHIoP5KFLZSM5wzpYhvCKMMKEzLoWPtqu3OqOEBD6myg4IT8oVw4AwvRkKYKJz"); + request.setHttpMethod("GET"); + OapiGettokenResponse response = client.execute(request); + return response.getAccessToken(); + } catch (ApiException e) { + throw new RuntimeException(); + } + + } +} diff --git a/epmet-auth/src/main/java/com/epmet/controller/GovLoginController.java b/epmet-auth/src/main/java/com/epmet/controller/GovLoginController.java index 386e162c02..3ed824f33f 100644 --- a/epmet-auth/src/main/java/com/epmet/controller/GovLoginController.java +++ b/epmet-auth/src/main/java/com/epmet/controller/GovLoginController.java @@ -83,6 +83,20 @@ public class GovLoginController { return new Result().ok(userTokenResultDTO); } + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author zhy + * @Description 4、选择组织,进入首页 + * @Date 2020/4/20 13:07 + **/ + @PostMapping(value = "/loginwxmp/enterorgbyaccount") + public Result enterOrgByAccount(@RequestBody GovWxmpEnteOrgByAccountFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO,GovWxmpEnteOrgByAccountFormDTO.AddUserShowGroup.class,GovWxmpEnteOrgByAccountFormDTO.AddUserInternalGroup.class); + UserTokenResultDTO userTokenResultDTO=govLoginService.enterOrgByAccount(formDTO); + return new Result().ok(userTokenResultDTO); + } + /** * @param tokenDto * @return com.epmet.commons.tools.utils.Result @@ -121,5 +135,19 @@ public class GovLoginController { List staffOrgs = govLoginService.getMyOrgByPassword(formDTO); return new Result>().ok(staffOrgs); } + + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result> + * @author zhy + * @description 6、账户密码获取组织 + * @Date 2020/6/30 22:43 + **/ + @PostMapping(value = "/getmyorgbyaccount") + public Result> getMyOrgByAccount(@RequestBody StaffOrgByAccountFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, StaffOrgByAccountFormDTO.AddUserShowGroup.class, StaffOrgByAccountFormDTO.GetMyOrgByPassWordGroup.class); + List staffOrgs = govLoginService.getMyOrgByAccount(formDTO); + return new Result>().ok(staffOrgs); + } } diff --git a/epmet-auth/src/main/java/com/epmet/controller/GovWebController.java b/epmet-auth/src/main/java/com/epmet/controller/GovWebController.java index 43b2719dc8..a3a36c9588 100644 --- a/epmet-auth/src/main/java/com/epmet/controller/GovWebController.java +++ b/epmet-auth/src/main/java/com/epmet/controller/GovWebController.java @@ -1,6 +1,7 @@ package com.epmet.controller; import com.epmet.auth.dto.result.BlockChainStaffAuthResultDTO; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.utils.RSASignature; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; @@ -9,6 +10,7 @@ import com.epmet.dto.form.GovWebLoginFormDTO; import com.epmet.dto.result.UserTokenResultDTO; import com.epmet.service.GovWebService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.PostMapping; @@ -44,10 +46,14 @@ public class GovWebController { ValidatorUtils.validateEntity(formDTO); try { - if (formDTO.getPassword().length() > 50) { + if (StringUtils.isNotBlank(formDTO.getPassword())&&formDTO.getPassword().length() > NumConstant.FIFTY) { String newPassword = RSASignature.decryptByPrivateKey(formDTO.getPassword(), privateKey); formDTO.setPassword(newPassword); } + if (StringUtils.isNotBlank(formDTO.getPhone())&&formDTO.getPhone().length() > NumConstant.FIFTY) { + String phone = RSASignature.decryptByPrivateKey(formDTO.getPhone(), privateKey); + formDTO.setPhone(phone); + } } catch (Exception e) { log.error("method exception", e); diff --git a/epmet-auth/src/main/java/com/epmet/controller/LoginController.java b/epmet-auth/src/main/java/com/epmet/controller/LoginController.java index 36c4d2a8d0..08e40eb99d 100644 --- a/epmet-auth/src/main/java/com/epmet/controller/LoginController.java +++ b/epmet-auth/src/main/java/com/epmet/controller/LoginController.java @@ -1,8 +1,10 @@ package com.epmet.controller; import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.exception.ErrorCode; import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.RSASignature; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; @@ -15,6 +17,7 @@ import com.epmet.service.LoginService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.*; import javax.imageio.ImageIO; @@ -36,6 +39,8 @@ import java.util.Arrays; @RestController @RequestMapping("login") public class LoginController { + @Value("${epmet.login.privateKey}") + private String privateKey; @Autowired private CaptchaService captchaService; @@ -90,11 +95,23 @@ public class LoginController { * @Date 2020/3/14 19:46 **/ @PostMapping("/operweb/loginbypassword") - public Result loginByPassword(@RequestBody LoginByPassWordFormDTO formDTO) { + public Result loginByPassword(@RequestBody LoginByPassWordFormDTO formDTO) throws Exception { //效验数据 ValidatorUtils.validateEntity(formDTO); - Result result = loginService.loginByPassword(formDTO); - return result; + //解密密码 + if (StringUtils.isNotBlank(formDTO.getPhone())&&formDTO.getPhone().length() > NumConstant.FIFTY) { + String phone = RSASignature.decryptByPrivateKey(formDTO.getPhone(), privateKey); + formDTO.setPhone(phone); + } + if (StringUtils.isNotBlank(formDTO.getMobile())&&formDTO.getMobile().length() > NumConstant.FIFTY) { + String phone = RSASignature.decryptByPrivateKey(formDTO.getMobile(), privateKey); + formDTO.setMobile(phone); + } + if (StringUtils.isNotBlank(formDTO.getPassword())&&formDTO.getPassword().length() > NumConstant.FIFTY) { + String confirmNewPassWord = RSASignature.decryptByPrivateKey(formDTO.getPassword(), privateKey); + formDTO.setPassword(confirmNewPassWord); + } + return loginService.loginByPassword(formDTO); } /** diff --git a/epmet-auth/src/main/java/com/epmet/controller/ThirdLoginController.java b/epmet-auth/src/main/java/com/epmet/controller/ThirdLoginController.java index 144e18d024..44ca89df30 100644 --- a/epmet-auth/src/main/java/com/epmet/controller/ThirdLoginController.java +++ b/epmet-auth/src/main/java/com/epmet/controller/ThirdLoginController.java @@ -3,6 +3,7 @@ package com.epmet.controller; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.form.*; +import com.epmet.dto.result.ResiDingAppLoginResDTO; import com.epmet.dto.result.StaffOrgsResultDTO; import com.epmet.dto.result.UserTokenResultDTO; import com.epmet.service.ThirdLoginService; @@ -63,6 +64,19 @@ public class ThirdLoginController { return new Result().ok(userTokenResultDTO); } + /** + * @param formDTO + * @return + * @Author zhy + * @Description 单客户-选择组织,进入首页 + **/ + @PostMapping(value = "enterorgbyaccount") + public Result enterOrgByAccount(@RequestBody ThirdWxmpEnteOrgByAccountFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO,ThirdWxmpEnteOrgFormDTO.AddUserShowGroup.class,ThirdWxmpEnteOrgFormDTO.AddUserInternalGroup.class); + UserTokenResultDTO userTokenResultDTO=thirdLoginService.enterOrgByAccount(formDTO); + return new Result().ok(userTokenResultDTO); + } + /** * @param formDTO * @return @@ -89,6 +103,19 @@ public class ThirdLoginController { return new Result>().ok(staffOrgs); } + /** + * @param formDTO + * @return + * @author zhy + * @description 单客户-账号密码获取组织 + **/ + @PostMapping(value = "/getmyorgbyaccount") + public Result> getMyOrgByAccount(@RequestBody ThirdStaffOrgByAccountFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, StaffOrgByAccountFormDTO.AddUserShowGroup.class, StaffOrgByAccountFormDTO.GetMyOrgByPassWordGroup.class); + List staffOrgs = thirdLoginService.getMyOrgByAccount(formDTO); + return new Result>().ok(staffOrgs); + } + /** * @param formDTO * @return @@ -116,4 +143,80 @@ public class ThirdLoginController { return new Result(); } + /** + * 钉钉应用的登录-居民端 + * 产品服务商建立第三方企业应用 + * 参考文档:https://open.dingtalk.com/document/isvapp-server/unified-authorization-suite-access-process + * @param formDTO + * @return + */ + /** + * 接入流程:https://open.dingtalk.com/document/isvapp-server/unified-authorization-suite-access-process + * 1、获取个人用户token:https://open.dingtalk.com/document/isvapp-server/obtain-user-token + * 2、获取用户通讯录个人信息:https://open.dingtalk.com/document/isvapp-server/dingtalk-retrieve-user-information + * 接口逻辑: + * (1)根据clientId去XXX表找到customerId + * (2)通过1、2拿到手机号之后,根据mobile+customerId去user_base_info表找userId, + * 是否注册居民:register_relation + * (3)没有则生成user、user_Base_info表记录 + * @param formDTO + * @return + */ + @PostMapping("resilogin-ding") + public Result resiLoginDing(@RequestBody ResiDingAppLoginFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO,ResiDingAppLoginFormDTO.InnerMiniApp.class); + return new Result().ok(thirdLoginService.resiLoginDing(formDTO)); + } + + /** + * 烟台建立应用,授权给我们,走企业免登 + * 企业简历内部应用授权给第三方 + * 可参考文档: 获取第三方应用授权企业的accessToken https://open.dingtalk.com/document/orgapp-server/obtain-the-access_token-of-the-authorized-enterprise + * https://open.dingtalk.com/document/orgapp-server/enterprise-internal-application-logon-free + * @param formDTO + * @return + */ + @PostMapping("resilogin-ding-md") + public Result resiLoginDingMd(@RequestBody DingAppLoginMdFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + return new Result().ok(thirdLoginService.resiLoginDingMd(formDTO)); + } + + /** + * 企业内部应用开发,不授权了 文档地址:https://open.dingtalk.com/document/orgapp-server/enterprise-internal-application-logon-free + * https://open.dingtalk.com/document/orgapp-server/enterprise-internal-application-logon-free + * 建议用户信息保存在前端缓存中(dd.setStorage)或者cookie中,避免每次进入应用都调用钉钉接口进行免登。 + * + * 获取免登授权码。 + * 小程序免登 + * 微应用免登 + * 获取AccessToken。 + * 调用接口获取access_token,详情请参考获取企业内部应用的access_token。 + * + * 获取userid。 + * 调用接口获取用户的userid,详情请参考通过免登码获取用户信息。 + * + * 获取用户详情。 + * 调用接口获取用户详细信息,详情请参考根据userId获取用户详情。 + * + * @param formDTO + * @return + */ + @PostMapping("resilogin-internalding") + public Result resiLoginInternalDing(@RequestBody DingAppLoginMdFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + return new Result().ok(thirdLoginService.resiLoginInternalDing(formDTO)); + } + + /** + * 根据免登授权码, 获取登录用户身份 + * + * @param formDTO 免登授权码 + * @return + */ + @PostMapping("govlogin-internalding") + public Result login(@RequestBody DingAppLoginMdFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + return new Result().ok(thirdLoginService.govLoginInternalDing(formDTO)); + } } diff --git a/epmet-auth/src/main/java/com/epmet/dto/dingres/DingUserDetailDTO.java b/epmet-auth/src/main/java/com/epmet/dto/dingres/DingUserDetailDTO.java new file mode 100644 index 0000000000..4a46922590 --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/dto/dingres/DingUserDetailDTO.java @@ -0,0 +1,73 @@ +package com.epmet.dto.dingres; + +import lombok.Data; + +/** + * @Description + * @Author yzm + * @Date 2022/9/22 14:16 + */ +@Data +public class DingUserDetailDTO { + // 接口文档:https://open.dingtalk.com/document/isvapp-server/query-user-details + /** + * 员工的userId。 + */ + private String userid; + + /** + * 员工在当前开发者企业账号范围内的唯一标识。 + */ + private String unionid; + + /** + * 员工姓名。 + */ + private String name; + /** + * 头像。 + *

+ * 说明 员工使用默认头像,不返回该字段,手动设置头像会返回 + */ + private String avatar; + /** + * 国际电话区号。 + *

+ * 说明 第三方企业应用不返回该字段;如需获取state_code,可以使用钉钉统一授权套件方式获取。 + */ + private String state_code; + /** + * 手机号码。 + *

+ * 说明 + * 企业内部应用,只有应用开通通讯录邮箱等个人信息权限,才会返回该字段。 + * 第三方企业应用不返回该字段,如需获取mobile,可以使用钉钉统一授权套件方式获取。 + */ + private String mobile; + /** + * 是否号码隐藏: + *

+ * true:隐藏 + *

+ * false:不隐藏 + *

+ * 说明 隐藏手机号后,手机号在个人资料页隐藏,但仍可对其发DING、发起钉钉免费商务电话。 + */ + private String hide_mobile; + /** + * 分机号。 + *

+ * 说明 第三方企业应用不返回该参数。 + */ + private String telephone; + + /** + * 员工的企业邮箱。 + * + * 如果员工的企业邮箱没有开通,返回信息中不包含该数据。 + * + * 说明 第三方企业应用不返回该参数。 + */ + private String org_email; +} + diff --git a/epmet-auth/src/main/java/com/epmet/dto/dingres/V2UserGetuserinfoResDTO.java b/epmet-auth/src/main/java/com/epmet/dto/dingres/V2UserGetuserinfoResDTO.java new file mode 100644 index 0000000000..ea9eb3b46b --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/dto/dingres/V2UserGetuserinfoResDTO.java @@ -0,0 +1,54 @@ +package com.epmet.dto.dingres; + +import lombok.Data; + +/** + * @Description + * @Author yzm + * @Date 2022/9/22 14:08 + */ +@Data +public class V2UserGetuserinfoResDTO { + // 接口返参:https://open.dingtalk.com/document/orgapp-server/obtain-the-userid-of-a-user-by-using-the-log-free + /** + * 用户的userid。 + */ + private String userid; + /** + * 设备ID。 + */ + private String device_id; + /** + * 是否是管理员。 + *

+ * true:是 + *

+ * false:不是 + */ + private Boolean sys; + /** + * 级别。 + *

+ * 1:主管理员 + *

+ * 2:子管理员 + *

+ * 100:老板 + *

+ * 0:其他(如普通员工) + */ + private Number sys_level; + /** + * 用户关联的unionId。 + */ + private String associated_unionid; + /** + * 用户unionId。 + */ + private String unionid; + /** + * 用户名字。 + */ + private String name; +} + diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/DingAppLoginMdFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/DingAppLoginMdFormDTO.java new file mode 100644 index 0000000000..1a8840e949 --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/dto/form/DingAppLoginMdFormDTO.java @@ -0,0 +1,23 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * @Description + * @Author yzm + * @Date 2022/9/22 10:42 + */ +@Data +public class DingAppLoginMdFormDTO { + @NotBlank(message = "authCode不能为空") + private String authCode; + /** + * 第三方企业应用传应用的SuiteKey + */ + @NotBlank(message = "miniAppId不能为空") + private String miniAppId; + +} + diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpEnteOrgByAccountFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpEnteOrgByAccountFormDTO.java new file mode 100644 index 0000000000..4996c0cd50 --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpEnteOrgByAccountFormDTO.java @@ -0,0 +1,48 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description 选择组织,进入首页入参Dto + * @Author yinzuomei + * @Date 2020/4/20 13:03 + */ +@Data +public class GovWxmpEnteOrgByAccountFormDTO implements Serializable { + public interface AddUserInternalGroup {} + public interface AddUserShowGroup extends CustomerClientShowGroup {} + /** + * wxCode + */ + @NotBlank(message = "wxCode不能为空",groups = {AddUserInternalGroup.class}) + private String wxCode; + + /** + * 手机号 + */ + @NotBlank(message = "账号不能为空",groups = {AddUserShowGroup.class}) + private String userAccount; + + /** + * 选择的组织所属的id + */ + @NotBlank(message = "客户id不能为空",groups = {AddUserInternalGroup.class}) + private String customerId; + + /** + * 选择的要进入的组织(根组织id) + */ + @NotBlank(message = "组织id不能为空",groups = {AddUserInternalGroup.class}) + private String rootAgencyId; + + /** + * desc:小程序appId + */ + private String appId; + +} + diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/ResiDingAppLoginFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/ResiDingAppLoginFormDTO.java new file mode 100644 index 0000000000..b18e95478a --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/dto/form/ResiDingAppLoginFormDTO.java @@ -0,0 +1,41 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * @Description + * @Author yzm + * @Date 2022/9/14 17:11 + */ +@Data +public class ResiDingAppLoginFormDTO { + public interface InnerMiniApp {} + public interface ThirdMiniApp {} + /** + * 授权统一后的authCode + */ + @NotBlank(message = "authCode不能为空",groups = InnerMiniApp.class) + private String authCode; +// /** +// * 第三方企业应用传应用的SuiteKey +// */ +// @NotBlank(message = "clientId不能为空") +// private String clientId; + /** + * 第三方企业应用传应用的SuiteKey + */ + @NotBlank(message = "miniAppId不能为空",groups = InnerMiniApp.class) + private String miniAppId; + + // @NotBlank(message = "当前访问用户的企业corpId不能为空") + // private String corpId; + + /** + * third:第三方应用 + * company_customize:企业定制应用 + */ + private String appType="company_customize"; +} + diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/StaffOrgByAccountFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/StaffOrgByAccountFormDTO.java new file mode 100644 index 0000000000..669a0e7998 --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/dto/form/StaffOrgByAccountFormDTO.java @@ -0,0 +1,43 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description 手机验证码获取组织接口入参 + * @Author zhy + * @Date 2020/4/18 10:38 + */ +@Data +public class StaffOrgByAccountFormDTO implements Serializable { + private static final long serialVersionUID = 4193133227120225342L; + /** + * 添加用户操作的用户可见异常分组 + * 该分组用于校验需要返回给前端错误信息提示的列,需要继承CustomerClientShowGroup + * 返回错误码为8999,提示信息为DTO中具体的列的校验注解message的内容 + */ + public interface AddUserShowGroup extends CustomerClientShowGroup { + } + + public interface GetMyOrgByPassWordGroup extends CustomerClientShowGroup { + } + public interface GetMyOrgByLoginWxmp extends CustomerClientShowGroup{} + /** + * 手机号 + */ + @NotBlank(message = "手机号不能为空", groups = {AddUserShowGroup.class}) + private String userAccount; + + /** + * 验证码 + */ + @NotBlank(message="验证码不能为空", groups = {GetMyOrgByLoginWxmp.class}) + private String smsCode; + + @NotBlank(message = "密码不能为空",groups ={GetMyOrgByPassWordGroup.class}) + private String password; +} + diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/ThirdStaffOrgByAccountFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/ThirdStaffOrgByAccountFormDTO.java new file mode 100644 index 0000000000..3cad308ab6 --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/dto/form/ThirdStaffOrgByAccountFormDTO.java @@ -0,0 +1,48 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description appId、账号、验证码获取组织-接口入参 + * @Author zhy + */ +@Data +public class ThirdStaffOrgByAccountFormDTO implements Serializable { + private static final long serialVersionUID = 4193133227120225342L; + /** + * 添加用户操作的用户可见异常分组 + * 该分组用于校验需要返回给前端错误信息提示的列,需要继承CustomerClientShowGroup + * 返回错误码为8999,提示信息为DTO中具体的列的校验注解message的内容 + */ + public interface AddUserShowGroup extends CustomerClientShowGroup { + } + + public interface GetMyOrgByPassWordGroup extends CustomerClientShowGroup { + } + public interface GetMyOrgByLoginWxmp extends CustomerClientShowGroup{} + /** + * 小程序appId + */ + @NotBlank(message = "appId不能为空", groups = {AddUserShowGroup.class}) + private String appId; + + /** + * 手机号 + */ + @NotBlank(message = "账号不能为空", groups = {AddUserShowGroup.class}) + private String userAccount; + + /** + * 验证码 + */ + @NotBlank(message="验证码不能为空", groups = {GetMyOrgByLoginWxmp.class}) + private String smsCode; + + @NotBlank(message = "密码不能为空",groups ={GetMyOrgByPassWordGroup.class}) + private String password; +} + diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/ThirdWxmpEnteOrgByAccountFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/ThirdWxmpEnteOrgByAccountFormDTO.java new file mode 100644 index 0000000000..e89028eb4c --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/dto/form/ThirdWxmpEnteOrgByAccountFormDTO.java @@ -0,0 +1,47 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description 单客户-选择组织,进入首页入参Dto + * @Author sun + */ +@Data +public class ThirdWxmpEnteOrgByAccountFormDTO implements Serializable { + public interface AddUserInternalGroup {} + public interface AddUserShowGroup extends CustomerClientShowGroup {} + /** + * wxCode + */ + @NotBlank(message = "wxCode不能为空",groups = {AddUserInternalGroup.class}) + private String wxCode; + + /** + * 手机号 + */ + @NotBlank(message = "账号不能为空",groups = {AddUserShowGroup.class}) + private String userAccount; + + /** + * 选择的组织所属的id + */ + @NotBlank(message = "客户id不能为空",groups = {AddUserInternalGroup.class}) + private String customerId; + + /** + * 选择的要进入的组织(根组织id) + */ + @NotBlank(message = "组织id不能为空",groups = {AddUserInternalGroup.class}) + private String rootAgencyId; + + /** + * 客户appId(exJson文件中获取) + */ + @NotBlank(message = "appId不能为空",groups = {AddUserInternalGroup.class}) + private String appId; +} + diff --git a/epmet-auth/src/main/java/com/epmet/dto/result/ResiDingAppLoginResDTO.java b/epmet-auth/src/main/java/com/epmet/dto/result/ResiDingAppLoginResDTO.java new file mode 100644 index 0000000000..6658ab5770 --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/dto/result/ResiDingAppLoginResDTO.java @@ -0,0 +1,44 @@ +package com.epmet.dto.result; + +import lombok.Data; + +/** + * @Description + * @Author yzm + * @Date 2022/9/14 17:20 + */ +@Data +public class ResiDingAppLoginResDTO { + private String authorization; + private String customerId; + private String gridId; + /** + * 网格名 + */ + private String gridName; + /** + * 网格所属的组织id + */ + private String agencyId; + /** + * 居民端用户id + */ + private String epmetUserId; + + /** + * 5.获取用户手机号。使用用户个人access_token调用获取用户通讯录个人信息接口获取 + * 返参信息 + * 接口文档:https://open.dingtalk.com/document/isvapp-server/dingtalk-retrieve-user-information + */ + private String extInfo; + + /** + * 是否注册居民 + * true:已注册 + * false:未注册 + */ + private Boolean regFlag; + + private String realName; +} + diff --git a/epmet-auth/src/main/java/com/epmet/feign/EpmetUserFeignClient.java b/epmet-auth/src/main/java/com/epmet/feign/EpmetUserFeignClient.java index 44c7d9d3ab..af33d8c632 100644 --- a/epmet-auth/src/main/java/com/epmet/feign/EpmetUserFeignClient.java +++ b/epmet-auth/src/main/java/com/epmet/feign/EpmetUserFeignClient.java @@ -70,6 +70,17 @@ public interface EpmetUserFeignClient { @GetMapping(value = "epmetuser/customerstaff/getcustsomerstaffbyphone/{mobile}") Result> checkCustomerStaff(@PathVariable("mobile") String mobile); + /** + * @param account + * @return com.epmet.commons.tools.utils.Result + * @Author zhy + * @Description 根据账户查询政府端工作人员基本信息,校验用户是否存在 + * @Date 2020/4/18 14:03 + **/ + @GetMapping(value = "epmetuser/customerstaff/getcustsomerstaffbyaccount/{account}") + Result> checkCustomerStaffByAccount(@PathVariable("account") String account); + + /** * @param staffWechatFormDTO * @return com.epmet.commons.tools.utils.Result @@ -100,6 +111,17 @@ public interface EpmetUserFeignClient { @PostMapping(value = "epmetuser/customerstaff/getcustomerstaffinfo", consumes = MediaType.APPLICATION_JSON_VALUE) Result getCustomerStaffInfo(@RequestBody CustomerStaffFormDTO customerStaffFormDTO); + /** + * @param customerStaffFormDTO + * @return com.epmet.commons.tools.utils.Result + * @Author zhy + * @Description 根据手机号+客户id获取工作人员基本信息 + * @Date 2020/4/20 14:16 + **/ + @PostMapping(value = "epmetuser/customerstaff/getcustomerstaffinfobyaccount", consumes = MediaType.APPLICATION_JSON_VALUE) + Result getCustomerStaffInfoByAccount(@RequestBody CustomerStaffByAccountFormDTO customerStaffFormDTO); + + /** * @param staffLoginHistoryFormDTO * @return com.epmet.commons.tools.utils.Result diff --git a/epmet-auth/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java b/epmet-auth/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java index 59623a7dc7..d0ce30ab99 100644 --- a/epmet-auth/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java +++ b/epmet-auth/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java @@ -44,6 +44,10 @@ public class EpmetUserFeignClientFallback implements EpmetUserFeignClient { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getCustsomerStaffByPhone", phone); } + @Override + public Result> checkCustomerStaffByAccount(String account) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getCustsomerStaffByAccount", account); + } @Override public Result saveStaffWechat(StaffWechatFormDTO staffWechatFormDTO) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "saveStaffWechat", staffWechatFormDTO); @@ -59,6 +63,11 @@ public class EpmetUserFeignClientFallback implements EpmetUserFeignClient { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getCustomerStaffInfo", customerStaffFormDTO); } + @Override + public Result getCustomerStaffInfoByAccount(CustomerStaffByAccountFormDTO customerStaffFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getCustomerStaffInfoByAccount", customerStaffFormDTO); + } + @Override public Result saveStaffLoginRecord(StaffLoginAgencyRecordFormDTO staffLoginHistoryFormDTO) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "saveStaffLoginRecord", staffLoginHistoryFormDTO); diff --git a/epmet-auth/src/main/java/com/epmet/service/GovLoginService.java b/epmet-auth/src/main/java/com/epmet/service/GovLoginService.java index ea6329ceda..8ec5697a60 100644 --- a/epmet-auth/src/main/java/com/epmet/service/GovLoginService.java +++ b/epmet-auth/src/main/java/com/epmet/service/GovLoginService.java @@ -1,10 +1,7 @@ package com.epmet.service; import com.epmet.commons.tools.security.dto.TokenDto; -import com.epmet.dto.form.GovWxmpEnteOrgFormDTO; -import com.epmet.dto.form.GovWxmpFormDTO; -import com.epmet.dto.form.SendSmsCodeFormDTO; -import com.epmet.dto.form.StaffOrgsFormDTO; +import com.epmet.dto.form.*; import com.epmet.dto.result.StaffOrgsResultDTO; import com.epmet.dto.result.UserTokenResultDTO; @@ -52,6 +49,15 @@ public interface GovLoginService { **/ UserTokenResultDTO enterOrg(GovWxmpEnteOrgFormDTO formDTO); + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author zhy + * @Description 4、选择组织,进入首页 + * @Date 2020/4/20 13:08 + **/ + UserTokenResultDTO enterOrgByAccount(GovWxmpEnteOrgByAccountFormDTO formDTO); + /** * @return com.epmet.commons.tools.utils.Result * @param tokenDto @@ -76,4 +82,13 @@ public interface GovLoginService { * @Date 2020/6/30 22:43 **/ List getMyOrgByPassword(StaffOrgsFormDTO formDTO); + + /** + * @return java.util.List + * @param formDTO + * @author zhy + * @description 6、账户密码获取组织 + * @Date 2020/6/30 22:43 + **/ + List getMyOrgByAccount(StaffOrgByAccountFormDTO formDTO); } diff --git a/epmet-auth/src/main/java/com/epmet/service/GovWebService.java b/epmet-auth/src/main/java/com/epmet/service/GovWebService.java index 10d86c20b4..6bee4b24b3 100644 --- a/epmet-auth/src/main/java/com/epmet/service/GovWebService.java +++ b/epmet-auth/src/main/java/com/epmet/service/GovWebService.java @@ -18,6 +18,14 @@ public interface GovWebService { **/ UserTokenResultDTO login(GovWebLoginFormDTO formDTO); + /** + * @param formDTO + * @return + * @Author sun + * @Description PC工作端-工作人员 通过第三方系统登录 + **/ + UserTokenResultDTO loginByThirdPlatform(GovWebLoginFormDTO formDTO); + /** * 区块链系统通过用户密码认证身份 * @param mobile diff --git a/epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java b/epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java index c79a67d41c..dff5e129e5 100644 --- a/epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java +++ b/epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java @@ -1,6 +1,7 @@ package com.epmet.service; import com.epmet.dto.form.*; +import com.epmet.dto.result.ResiDingAppLoginResDTO; import com.epmet.dto.result.StaffOrgsResultDTO; import com.epmet.dto.result.UserTokenResultDTO; @@ -36,6 +37,15 @@ public interface ThirdLoginService { **/ UserTokenResultDTO enterOrg(ThirdWxmpEnteOrgFormDTO formDTO); + + /** + * @param formDTO + * @return + * @Author zhy + * @Description 单客户-选择组织,进入首页 + **/ + UserTokenResultDTO enterOrgByAccount(ThirdWxmpEnteOrgByAccountFormDTO formDTO); + /** * @param formDTO * @return @@ -52,6 +62,15 @@ public interface ThirdLoginService { **/ List getMyOrgByPassword(ThirdStaffOrgsFormDTO formDTO); + /** + * @param formDTO + * @return + * @author zhy + * @description 单客户-手机号密码获取组织 + **/ + List getMyOrgByAccount(ThirdStaffOrgByAccountFormDTO formDTO); + + /** * @param formDTO * @return @@ -66,4 +85,36 @@ public interface ThirdLoginService { * @description 单客户-工作端微信小程序登录-发送验证码 **/ void sendSmsCode(ThirdSendSmsCodeFormDTO formDTO); + + /** + * 钉钉应用的登录-居民端 + * 产品服务商建立第三方企业应用 + * 参考文档:https://open.dingtalk.com/document/isvapp-server/unified-authorization-suite-access-process + * @param formDTO + * @return + */ + ResiDingAppLoginResDTO resiLoginDing(ResiDingAppLoginFormDTO formDTO); + + /** + * 企业简历内部应用授权给第三方 + * 可参考文档: 获取第三方应用授权企业的accessToken https://open.dingtalk.com/document/orgapp-server/obtain-the-access_token-of-the-authorized-enterprise + * https://open.dingtalk.com/document/orgapp-server/enterprise-internal-application-logon-free + * @param formDTO + * @return + */ + ResiDingAppLoginResDTO resiLoginDingMd(DingAppLoginMdFormDTO formDTO); + + /** + * 企业内部应用免登 文档地址:https://open.dingtalk.com/document/orgapp-server/enterprise-internal-application-logon-free + * @param formDTO + * @return + */ + ResiDingAppLoginResDTO resiLoginInternalDing(DingAppLoginMdFormDTO formDTO); + + /** + * desc:企业内部应用 工作端登录 + * @param formDTO + * @return + */ + UserTokenResultDTO govLoginInternalDing(DingAppLoginMdFormDTO formDTO); } diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java index cbc46e33f1..24267debd1 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java @@ -289,6 +289,36 @@ public class GovLoginServiceImpl implements GovLoginService, ResultDataResolver return userTokenResultDTO; } + @Override + public UserTokenResultDTO enterOrgByAccount(GovWxmpEnteOrgByAccountFormDTO formDTO) { + //1、需要校验要登录的客户,是否被禁用 + CustomerStaffByAccountFormDTO customerStaffFormDTO = new CustomerStaffByAccountFormDTO(); + customerStaffFormDTO.setCustomerId(formDTO.getCustomerId()); + customerStaffFormDTO.setUserAccount(formDTO.getUserAccount()); + Result customerStaffDTOResult = epmetUserFeignClient.getCustomerStaffInfoByAccount(customerStaffFormDTO); + if (!customerStaffDTOResult.success() || null == customerStaffDTOResult.getData()) { + logger.warn(String.format("获取工作人员信息失败,账户[%s],客户id:[%s],code[%s],msg[%s]", formDTO.getUserAccount(), formDTO.getCustomerId(), customerStaffDTOResult.getCode(), customerStaffDTOResult.getMsg())); + throw new RenException(customerStaffDTOResult.getCode()); + } + CustomerStaffDTO customerStaff = customerStaffDTOResult.getData(); + //2、解析微信用户 + WxMaJscode2SessionResult wxMaJscode2SessionResult = loginService.getWxMaUser(LoginConstant.APP_GOV, formDTO.getWxCode(), formDTO.getAppId()); + + //3、记录staff_wechat,并记录用户激活状态,激活时间 + this.savestaffwechat(customerStaff.getUserId(), wxMaJscode2SessionResult.getOpenid(), formDTO.getCustomerId()); + //4、记录登录日志 + GovWxmpEnteOrgFormDTO orgDTO = ConvertUtils.sourceToTarget(formDTO, GovWxmpEnteOrgFormDTO.class); + orgDTO.setMobile(customerStaff.getMobile()); + this.saveStaffLoginRecord(orgDTO, customerStaff.getUserId(), wxMaJscode2SessionResult.getOpenid()); + //5.1、获取用户token + String token = this.generateGovWxmpToken(customerStaff.getUserId()); + //5.2、保存到redis + this.saveGovTokenDto(formDTO.getRootAgencyId(), formDTO.getCustomerId(), customerStaff.getUserId(), wxMaJscode2SessionResult, token); + UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO(); + userTokenResultDTO.setToken(token); + return userTokenResultDTO; + } + @Override public void loginOut(TokenDto tokenDto) { if(null == tokenDto){ @@ -381,6 +411,63 @@ public class GovLoginServiceImpl implements GovLoginService, ResultDataResolver return new ArrayList<>(); } + @Override + public List getMyOrgByAccount(StaffOrgByAccountFormDTO formDTO) { + //1、根据手机号查询到用户信息 + Result> customerStaffResult = epmetUserFeignClient.checkCustomerStaffByAccount(formDTO.getUserAccount()); + if (!customerStaffResult.success()) { + logger.warn(String.format("账户密码登录异常,手机号[%s],code[%s],msg[%s]", formDTO.getUserAccount(), customerStaffResult.getCode(), customerStaffResult.getMsg())); + throw new RenException(customerStaffResult.getCode()); + } + //2、密码是否正确 + List customerStaffList=customerStaffResult.getData(); + //3、查询用户所有的组织信息 + List customerIdList = new ArrayList<>(); + //是否设置过密码 + boolean havePasswordFlag=false; + //密码是否正确 + boolean passwordRightFlag=false; + for (CustomerStaffDTO customerStaffDTO : customerStaffList) { + if(StringUtils.isNotBlank(customerStaffDTO.getPassword())){ + havePasswordFlag=true; + }else{ + logger.warn(String.format("当前用户:账户%s,客户Id%s下未设置密码.",formDTO.getUserAccount(),customerStaffDTO.getCustomerId())); + continue; + } + if (!PasswordUtils.matches(formDTO.getPassword(), customerStaffDTO.getPassword())) { + logger.warn(String.format("当前用户:账户%s,客户Id%s密码匹配错误.",formDTO.getUserAccount(),customerStaffDTO.getCustomerId())); + + }else{ + logger.warn(String.format("当前用户:账户%s,客户Id%s密码匹配正确.",formDTO.getUserAccount(),customerStaffDTO.getCustomerId())); + passwordRightFlag=true; + customerIdList.add(customerStaffDTO.getCustomerId()); + } + } + //根据手机号查出来所有用户,密码都为空,表明用户未激活账户,未设置密码 + if(!havePasswordFlag){ + logger.warn(String.format("当前账户(%s)下所有账户都未设置密码,请先使用验证码登录激活账户",formDTO.getUserAccount())); + throw new RenException(EpmetErrorCode.PASSWORD_ERROR.getCode()); + } + //密码错误 + if(!passwordRightFlag){ + logger.warn(String.format("根据当前账户(%s)密码未找到所属组织,密码错误",formDTO.getUserAccount())); + throw new RenException(EpmetErrorCode.PASSWORD_ERROR.getCode()); + } + StaffOrgFormDTO staffOrgFormDTO = new StaffOrgFormDTO(); + staffOrgFormDTO.setCustomerIdList(customerIdList); + Result> result = govOrgFeignClient.getStaffOrgList(staffOrgFormDTO); + if(result.success()&&null!=result.getData()){ + return result.getData(); + } + logger.warn(String .format("手机验证码获取组织,调用%s服务失败,入参账户%s,密码%s,返回错误码%s,错误提示信息%s", + ServiceConstant.GOV_ORG_SERVER, + formDTO.getUserAccount(), + formDTO.getPassword(), + result.getCode(), + result.getMsg())); + return new ArrayList<>(); + } + //保存登录日志 private Result saveStaffLoginRecord(GovWxmpEnteOrgFormDTO formDTO, String staffId, String openId) { StaffLoginAgencyRecordFormDTO staffLoginAgencyRecordFormDTO = new StaffLoginAgencyRecordFormDTO(); diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/GovWebServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/GovWebServiceImpl.java index eab142e6a5..92e1de27a5 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/GovWebServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/GovWebServiceImpl.java @@ -100,6 +100,33 @@ public class GovWebServiceImpl implements GovWebService, ResultDataResolver { } + @Override + public UserTokenResultDTO loginByThirdPlatform(GovWebLoginFormDTO formDTO) { + formDTO.setApp(LoginConstant.APP_GOV); + formDTO.setClient(LoginConstant.CLIENT_WEB); +// //1.参数校验 +// if (!(LoginConstant.APP_GOV.equals(formDTO.getApp()) && LoginConstant.CLIENT_WEB.equals(formDTO.getClient()))) { +// logger.error("当前接口只适用于PC工作端运营管理后台"); +// throw new RenException("当前接口只适用于PC工作端运营管理后台"); +// } + //3.校验登陆账号是否存在 + //根据客户Id和手机号查询登陆用户信息(此处不需要判断登陆人是否是有效客户以及是否是客户的根管理员,前一接口获取登陆手机号对应客户列表已经判断了) + GovWebOperLoginFormDTO form = new GovWebOperLoginFormDTO(); + form.setCustomerId(formDTO.getCustomerId()); + form.setMobile(formDTO.getPhone()); + Result result = epmetUserFeignClient.getStaffIdAndPwd(form); + if (!result.success() || null == result.getData() || null == result.getData().getUserId()) { + logger.warn("根据手机号查询PC工作端登陆人员信息失败,返回10003账号不存在"); + throw new RenException(EpmetErrorCode.ERR10003.getCode()); + } + GovWebOperLoginResultDTO resultDTO = result.getData(); + + //5.生成token存到redis并返回 + UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO(); + userTokenResultDTO.setToken(this.packagingUserToken(formDTO, resultDTO.getUserId())); + return userTokenResultDTO; + } + /** * 生成PC工作端token * @author sun diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/LoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/LoginServiceImpl.java index 211fce084e..3e1e580fce 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/LoginServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/LoginServiceImpl.java @@ -6,8 +6,10 @@ import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; import cn.binarywang.wx.miniapp.bean.WxMaUserInfo; import com.alibaba.fastjson.JSON; import com.epmet.common.token.constant.LoginConstant; +import com.epmet.commons.tools.constant.AppClientConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.password.PasswordUtils; import com.epmet.commons.tools.utils.CpUserDetailRedis; @@ -130,13 +132,13 @@ public class LoginServiceImpl implements LoginService { } } } catch (WxErrorException e) { - log.error("->[getMaOpenId]::error[{}]", "解析微信code失败",e); + log.warn("->[getMaOpenId]::error[{}]", "解析微信code失败",e); } if (null == wxMaJscode2SessionResult) { - log.error(String.format("解析微信用户信息失败,app[%s],wxCode[%s],result:[%S]",app,wxCode, JSON.toJSONString(wxMaJscode2SessionResult))); + log.warn(String.format("解析微信用户信息失败,app[%s],wxCode[%s],result:[%S]",app,wxCode, JSON.toJSONString(wxMaJscode2SessionResult))); throw new RenException("解析微信用户信息失败"); } else if (StringUtils.isBlank(wxMaJscode2SessionResult.getOpenid())) { - log.error(String.format("获取微信openid失败,app[%s],wxCode[%s]",app,wxCode)); + log.warn(String.format("获取微信openid失败,app[%s],wxCode[%s]",app,wxCode)); throw new RenException("获取微信openid失败"); } return wxMaJscode2SessionResult; @@ -366,6 +368,10 @@ public class LoginServiceImpl implements LoginService { } else { logger.error(String.format("运营人员%s退出成功,清空菜单和权限redis异常", tokenDto.getUserId())); } + //如果是工作端退出,删除当前工作人员缓存 + if(AppClientConstant.APP_GOV.equals(tokenDto.getApp())){ + CustomerStaffRedis.delStaffInfoFormCache(tokenDto.getCustomerId(),tokenDto.getUserId()); + } return new Result(); } diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java index dd48a5577f..c7c79bb575 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java @@ -5,15 +5,21 @@ import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.aliyun.dingtalk.module.DingTalkResult; import com.epmet.auth.constants.AuthOperationConstants; import com.epmet.common.token.constant.LoginConstant; import com.epmet.commons.rocketmq.messages.LoginMQMsg; import com.epmet.commons.tools.constant.AppClientConstant; import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.enums.EnvEnum; import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.feign.ResultDataResolver; +import com.epmet.commons.tools.redis.common.CustomerDingDingRedis; +import com.epmet.commons.tools.redis.common.bean.DingMiniInfoCache; import com.epmet.commons.tools.security.dto.GovTokenDto; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.password.PasswordUtils; @@ -23,15 +29,24 @@ import com.epmet.commons.tools.validator.PhoneValidatorUtils; import com.epmet.constant.AuthHttpUrlConstant; import com.epmet.constant.SmsTemplateConstant; import com.epmet.dto.*; +import com.epmet.dto.dingres.DingUserDetailDTO; +import com.epmet.dto.dingres.V2UserGetuserinfoResDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.feign.EpmetMessageOpenFeignClient; +import com.epmet.feign.EpmetUserFeignClient; import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.jwt.JwtTokenProperties; import com.epmet.jwt.JwtTokenUtils; import com.epmet.redis.CaptchaRedis; +import com.epmet.service.GovWebService; import com.epmet.service.ThirdLoginService; +import com.taobao.api.ApiException; +import com.taobao.dingtalk.client.DingTalkClientToken; +import com.taobao.dingtalk.client.DingTalkClientUser; +import com.taobao.dingtalk.vo.result.AccessTokenResult; +import com.taobao.dingtalk.vo.result.UserBaseInfo; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; @@ -73,6 +88,14 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol private EpmetMessageOpenFeignClient messageOpenFeignClient; @Autowired private LoginUserUtil loginUserUtil; + @Autowired + private DingTalkClientToken dingTalkClientToken; + @Autowired + private DingTalkClientUser dingTalkClientUser; + @Autowired + private EpmetUserFeignClient epmetUserFeignClient; + @Autowired + private GovWebService govWebService; /** * @param formDTO @@ -425,6 +448,68 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol return userTokenResultDTO; } + /** + * @param formDTO + * @return + * @Author sun + * @Description 单客户-选择组织,进入首页 + **/ + @Override + public UserTokenResultDTO enterOrgByAccount(ThirdWxmpEnteOrgByAccountFormDTO formDTO) { + //1、需要校验要登录的客户,是否被禁用 + CustomerStaffByAccountFormDTO customerStaffFormDTO = new CustomerStaffByAccountFormDTO(); + customerStaffFormDTO.setCustomerId(formDTO.getCustomerId()); + customerStaffFormDTO.setUserAccount(formDTO.getUserAccount()); + Result customerStaffDTOResult = epmetUserOpenFeignClient.getCustomerStaffInfoByAccount(customerStaffFormDTO); + if (!customerStaffDTOResult.success() || null == customerStaffDTOResult.getData()) { + logger.error(String.format("获取工作人员信息失败,账户[%s],客户id:[%s],code[%s],msg[%s]", formDTO.getUserAccount(), formDTO.getCustomerId(), customerStaffDTOResult.getCode(), customerStaffDTOResult.getMsg())); + throw new RenException(customerStaffDTOResult.getCode()); + } + CustomerStaffDTO customerStaff = customerStaffDTOResult.getData(); + //2020.7.24 获取微信信息接口调整,改调用微信api的方式 sun start + //2.调用epmet_third服务,校验appId是否有效以及是否授权,校验通过的调用微信API获取用户基本信息 + WxLoginFormDTO resiLoginFormDTO = new WxLoginFormDTO(); + resiLoginFormDTO.setAppId(formDTO.getAppId()); + resiLoginFormDTO.setWxCode(formDTO.getWxCode()); + UserWechatDTO userWechatDTO = this.getUserWeChat(resiLoginFormDTO); + WxMaJscode2SessionResult wxMaJscode2SessionResult = new WxMaJscode2SessionResult(); + wxMaJscode2SessionResult.setOpenid(userWechatDTO.getWxOpenId()); + wxMaJscode2SessionResult.setSessionKey(userWechatDTO.getSessionKey()); + wxMaJscode2SessionResult.setUnionid(""); + // end + //3、记录staff_wechat,并记录用户激活状态,激活时间 + this.savestaffwechat(customerStaff.getUserId(), userWechatDTO.getWxOpenId(), formDTO.getCustomerId()); + //4、记录登录日志 + StaffLatestAgencyResultDTO staffLatestAgencyResultDTO = new StaffLatestAgencyResultDTO(); + staffLatestAgencyResultDTO.setCustomerId(formDTO.getCustomerId()); + staffLatestAgencyResultDTO.setStaffId(customerStaff.getUserId()); + staffLatestAgencyResultDTO.setWxOpenId(userWechatDTO.getWxOpenId()); + staffLatestAgencyResultDTO.setMobile(customerStaff.getMobile()); + staffLatestAgencyResultDTO.setAgencyId(formDTO.getRootAgencyId()); + this.saveStaffLoginRecord(staffLatestAgencyResultDTO); + //5.1、获取用户token + String token = this.generateGovWxmpToken(customerStaff.getUserId()); + //5.2、保存到redis + StaffLatestAgencyResultDTO staffLatestAgency = new StaffLatestAgencyResultDTO(); + staffLatestAgency.setAgencyId(formDTO.getRootAgencyId()); + staffLatestAgency.setCustomerId(formDTO.getCustomerId()); + staffLatestAgency.setStaffId(customerStaff.getUserId()); + this.saveLatestGovTokenDto(staffLatestAgency, userWechatDTO, token); + + UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO(); + userTokenResultDTO.setToken(token); + + //6.发送登录事件 + try { + sendLoginEvent(customerStaff.getUserId(), formDTO.getAppId(), AppClientConstant.APP_GOV, AppClientConstant.CLIENT_WXMP); + } catch (RenException e) { + log.error(e.getInternalMsg()); + } catch (Exception e) { + log.error("【工作端enterOrg登录】发送登录事件失败,程序继续执行。错误信息"); + } + return userTokenResultDTO; + } + /** * @param formDTO * @return @@ -538,6 +623,69 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol return new ArrayList<>(); } + @Override + public List getMyOrgByAccount(ThirdStaffOrgByAccountFormDTO formDTO) { + //0.根据appId查询对应客户Id + PaCustomerDTO customer = this.getCustomerInfo(formDTO.getAppId()); + //7.28 上边根据appId只能锁定一条客户id,后边的批量循环操作暂不做调整,还是使用之前的代码 sun + //1、根据手机号查询到用户信息 + ThirdCustomerStaffByAccountFormDTO dto = new ThirdCustomerStaffByAccountFormDTO(); + dto.setCustomerId(customer.getId()); + dto.setUserAccount(formDTO.getUserAccount()); + Result> customerStaffResult = epmetUserOpenFeignClient.getCustsomerStaffByIdAndAccount(dto); + if (!customerStaffResult.success()) { + logger.warn(String.format("账户密码登录异常,账户[%s],code[%s],msg[%s]", formDTO.getUserAccount(), customerStaffResult.getCode(), customerStaffResult.getMsg())); + throw new RenException(customerStaffResult.getCode()); + } + //2、密码是否正确 + List customerStaffList=customerStaffResult.getData(); + //3、查询用户所有的组织信息 + List customerIdList = new ArrayList<>(); + //是否设置过密码 + boolean havePasswordFlag=false; + //密码是否正确 + boolean passwordRightFlag=false; + for (CustomerStaffDTO customerStaffDTO : customerStaffList) { + if(StringUtils.isNotBlank(customerStaffDTO.getPassword())){ + havePasswordFlag=true; + }else{ + logger.warn(String.format("当前用户:账户%s,客户Id%s下未设置密码.",formDTO.getUserAccount(),customerStaffDTO.getCustomerId())); + continue; + } + if (!PasswordUtils.matches(formDTO.getPassword(), customerStaffDTO.getPassword())) { + logger.warn(String.format("当前用户:账户%s,客户Id%s密码匹配错误.",formDTO.getUserAccount(),customerStaffDTO.getCustomerId())); + + }else{ + logger.warn(String.format("当前用户:账户%s,客户Id%s密码匹配正确.",formDTO.getUserAccount(),customerStaffDTO.getCustomerId())); + passwordRightFlag=true; + customerIdList.add(customerStaffDTO.getCustomerId()); + } + } + //根据手机号查出来所有用户,密码都为空,表明用户未激活账户,未设置密码 + if(!havePasswordFlag){ + logger.warn(String.format("当前账户(%s)下所有账户都未设置密码,请先使用验证码登录激活账户",formDTO.getUserAccount())); + throw new RenException(EpmetErrorCode.PASSWORD_ERROR.getCode()); + } + //密码错误 + if(!passwordRightFlag){ + logger.warn(String.format("根据当前账户(%s)密码未找到所属组织,密码错误",formDTO.getUserAccount())); + throw new RenException(EpmetErrorCode.PASSWORD_ERROR.getCode()); + } + StaffOrgFormDTO staffOrgFormDTO = new StaffOrgFormDTO(); + staffOrgFormDTO.setCustomerIdList(customerIdList); + Result> result = govOrgOpenFeignClient.getStaffOrgList(staffOrgFormDTO); + if(result.success()&&null!=result.getData()){ + return result.getData(); + } + logger.warn(String .format("手机验证码获取组织,调用%s服务失败,入参账户%s,密码%s,返回错误码%s,错误提示信息%s", + ServiceConstant.GOV_ORG_SERVER, + formDTO.getUserAccount(), + formDTO.getPassword(), + result.getCode(), + result.getMsg())); + return new ArrayList<>(); + } + /** * @Description 获取客户信息 * @param appId @@ -690,4 +838,318 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol //getResultDataOrThrowsException(result, ServiceConstant.EPMET_MESSAGE_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "调用Message服务,发送登录事件到MQ失败"); } +// 接入流程:https://open.dingtalk.com/document/isvapp-server/unified-authorization-suite-access-process +// 1、获取个人用户token:https://open.dingtalk.com/document/isvapp-server/obtain-user-token +// 2、获取用户通讯录个人信息:https://open.dingtalk.com/document/isvapp-server/dingtalk-retrieve-user-information +// 接口逻辑: +// (1)根据clientId去XXX表找到customerId +// (2)通过1、2拿到手机号之后,根据mobile+customerId去user_base_info表找userId, +// 是否注册居民:register_relation +// (3)没有则生成user、user_Base_info表记录 + /** + * 钉钉应用的登录-居民端 + * + * @param formDTO + * @return + */ + @Override + public ResiDingAppLoginResDTO resiLoginDing(ResiDingAppLoginFormDTO formDTO) { + //获取用户手机号 + log.info("1、钉钉居民端应用登录入参:"+ JSON.toJSONString(formDTO)); + ResiDingAppLoginResDTO resDTO= null; + try { + resDTO = new ResiDingAppLoginResDTO(); + resDTO.setCustomerId(getCurrentCustomerId()); + //1、获取用户手机号 + String miniAppId = formDTO.getMiniAppId(); + DingMiniInfoCache dingMiniInfo = CustomerDingDingRedis.getDingMiniInfo(miniAppId); + DingTalkResult userAccessToken = dingTalkClientToken.getUserAccessToken(formDTO.getAuthCode(), dingMiniInfo.getSuiteKey(), dingMiniInfo.getSuiteSecret()); + log.info("2、resiLoginDing userAccessToken:{}",JSON.toJSONString(userAccessToken)); + if (!userAccessToken.success() || null == userAccessToken.getData()) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "调用微信api异常:" + JSON.toJSONString(userAccessToken), EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getMsg()); + } + DingTalkResult me = dingTalkClientUser.getUserInfo("me", userAccessToken.getData().getAccessToken()); + log.info("3、resiLoginDing me:{}",JSON.toJSONString(me)); + resDTO.setExtInfo(JSON.toJSONString(me.getData())); + if (!me.success() || StringUtils.isBlank(me.getData().getMobile())) { + log.error("resilogin-ding登录接口报错,入参:" + JSON.toJSONString(formDTO) + ";获取手机号为空, userAccessToken.getData().getAccessToken()=" + userAccessToken.getData().getAccessToken()); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取手机号为空", "获取手机号为空"); + } + // 2、调用userfeign接口获取userId、注册网格相关信息 todo + DingLoginResiFormDTO dingLoginResiFormDTO=ConvertUtils.sourceToTarget(me.getData(),DingLoginResiFormDTO.class); + dingLoginResiFormDTO.setCustomerId(resDTO.getCustomerId()); + Result loginResiResDTOResult = epmetUserOpenFeignClient.dingResiLogin(dingLoginResiFormDTO); + if (!loginResiResDTOResult.success() || null == loginResiResDTOResult.getData()) { + //临时打个日志 + log.error(String.format("resilogin-ding获取epmetUserId异常,入参:%s,user服务返参:%s", JSON.toJSONString(formDTO), JSON.toJSONString(loginResiResDTOResult))); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取epmetUserId异常:" + JSON.toJSONString(loginResiResDTOResult), EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getMsg()); + } + DingLoginResiResDTO resiResDTO=loginResiResDTOResult.getData(); + resDTO.setGridId(resiResDTO.getGridId()); + resDTO.setGridName(resiResDTO.getGridName()); + resDTO.setAgencyId(resiResDTO.getAgencyId()); + resDTO.setEpmetUserId(resiResDTO.getEpmetUserId()); + resDTO.setRegFlag(resiResDTO.getRegFlag()); + + //3.生成token,并且存放Redis + String token=this.saveTokenDtoDing(formDTO.getMiniAppId(),AppClientConstant.APP_RESI,AppClientConstant.MINI_DING, resDTO.getEpmetUserId(), resDTO.getCustomerId()); + resDTO.setAuthorization(token); + + } catch (ApiException e) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), e.getErrMsg(), EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getMsg()); + } + return resDTO; + } + + private String saveTokenDtoDing(String miniAppId,String app,String client, String userId,String customerId) { + //生成token串 + Map map = new HashMap<>(); + map.put(AppClientConstant.APP, app); + // map.put(AppClientConstant.CLIENT, client); + // 第三方企业应用传应用的SuiteKey 作为client + map.put(AppClientConstant.CLIENT, client.concat(miniAppId)); + map.put("userId", userId); + String token = jwtTokenUtils.createToken(map); + int expire = jwtTokenProperties.getExpire(); + TokenDto tokenDto = new TokenDto(); + tokenDto.setCustomerId(customerId); + tokenDto.setApp(app); + tokenDto.setClient(client.concat(miniAppId)); + tokenDto.setUserId(userId); + tokenDto.setToken(token); + tokenDto.setUpdateTime(System.currentTimeMillis()); + tokenDto.setExpireTime(jwtTokenUtils.getExpiration(token).getTime()); + cpUserDetailRedis.set(tokenDto, expire); + // cpUserDetailRedis.setForDingApp(miniAppId,tokenDto, expire); + logger.info("截止时间:" + DateUtils.format(jwtTokenUtils.getExpiration(token), "yyyy-MM-dd HH:mm:ss")); + return token; + } + + @Override + public ResiDingAppLoginResDTO resiLoginDingMd(DingAppLoginMdFormDTO formDTO) { + // 获取用户手机号 + log.info("1、钉钉居民端应用登录入参:" + JSON.toJSONString(formDTO)); + ResiDingAppLoginResDTO resDTO = null; + resDTO = new ResiDingAppLoginResDTO(); + resDTO.setCustomerId(getCurrentCustomerId()); + // 1、获取用户手机号 + DingLoginResiFormDTO dingLoginResiFormDTO = getDingLoginResiFormDTOMd(formDTO.getMiniAppId(), formDTO.getAuthCode()); + dingLoginResiFormDTO.setCustomerId(resDTO.getCustomerId()); + // 2、调用userfeign接口获取userId、注册网格相关信息 + Result loginResiResDTOResult = epmetUserOpenFeignClient.dingResiLogin(dingLoginResiFormDTO); + if (!loginResiResDTOResult.success() || null == loginResiResDTOResult.getData()) { + // 临时打个日志 + log.error(String.format("resiLoginDingMd获取epmetUserId异常,入参:%s,user服务返参:%s", JSON.toJSONString(formDTO), JSON.toJSONString(loginResiResDTOResult))); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取epmetUserId异常:" + JSON.toJSONString(loginResiResDTOResult), EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getMsg()); + } + DingLoginResiResDTO resiResDTO = loginResiResDTOResult.getData(); + resDTO.setGridId(resiResDTO.getGridId()); + resDTO.setGridName(resiResDTO.getGridName()); + resDTO.setAgencyId(resiResDTO.getAgencyId()); + resDTO.setEpmetUserId(resiResDTO.getEpmetUserId()); + resDTO.setRegFlag(resiResDTO.getRegFlag()); + + // 3.生成token,并且存放Redis + String token = this.saveTokenDtoDing(formDTO.getMiniAppId(), AppClientConstant.APP_RESI, AppClientConstant.MINI_DING, resDTO.getEpmetUserId(), resDTO.getCustomerId()); + resDTO.setAuthorization(token); + + return resDTO; + } + + private DingLoginResiFormDTO getDingLoginResiFormDTOMd(String miniAppId, String authCode) { + DingMiniInfoCache dingMiniInfo = CustomerDingDingRedis.getDingMiniInfo(miniAppId); + + // 1、服务商获取第三方应用授权企业的access_token,文档地址:https://open.dingtalk.com/document/orgapp-server/obtains-the-enterprise-authorized-credential + // 烟台的CorpId: dingaae55cbc47a96845f5bf40eda33b7ba0 + String yantaiCorpId = "dingaae55cbc47a96845f5bf40eda33b7ba0"; + DingTalkResult res = dingTalkClientToken.getThirdAuthCorpAccessToken(dingMiniInfo.getSuiteKey(), dingMiniInfo.getSuiteSecret(), "abc", yantaiCorpId); + if (!res.success() || StringUtils.isBlank(res.getData())) { + log.error(String.format("企业内部应用免登服务商获取第三方应用授权企业的access_token失败,customKey:%s,customSecret:%s,corpId:%s", dingMiniInfo.getSuiteSecret(), dingMiniInfo.getSuiteSecret(), yantaiCorpId)); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "服务商获取第三方应用授权企业的access_token", "服务商获取第三方应用授权企业的access_token"); + } + String accessToken = res.getData(); + log.info(String.format("1、服务商获取第三方应用授权企业的access_token返参:%s", accessToken)); + + // 2、通过免登码获取用户信息,文档地址:https://open.dingtalk.com/document/orgapp-server/obtain-the-userid-of-a-user-by-using-the-log-free + DingTalkResult v2UserGetuserinfoRes = dingTalkClientToken.getUserInfo(accessToken, authCode); + if (!v2UserGetuserinfoRes.success() || StringUtils.isBlank(v2UserGetuserinfoRes.getData())) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "通过免登码获取用户信息异常", "通过免登码获取用户信息异常"); + } + log.info(String.format("2、通过免登码获取用户信息返参:%s", v2UserGetuserinfoRes.getData())); + V2UserGetuserinfoResDTO v2UserGetuserinfoResDTO = JSON.parseObject(v2UserGetuserinfoRes.getData(), V2UserGetuserinfoResDTO.class); + if (null == v2UserGetuserinfoResDTO || StringUtils.isBlank(v2UserGetuserinfoResDTO.getUserid())) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取钉钉用户userid为空", "获取钉钉用户userid为空"); + } + + + // 3、查询用户详情,文档地址:https://open.dingtalk.com/document/isvapp-server/query-user-details + DingTalkResult v2UserGetRes = dingTalkClientToken.getUserDetail(v2UserGetuserinfoResDTO.getUserid(), accessToken); + if (!v2UserGetRes.success() || StringUtils.isBlank(v2UserGetRes.getData())) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "根据userId查询用户详情失败", "根据userId查询用户详情失败"); + } + log.info(String.format("3、查询用户详情:%s", v2UserGetRes.getData())); + DingUserDetailDTO dingUserDetailDTO = JSON.parseObject(v2UserGetRes.getData(), DingUserDetailDTO.class); + if (null == dingUserDetailDTO || StringUtils.isBlank(dingUserDetailDTO.getMobile())) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取手机号为空", "获取手机号为空"); + } + + DingLoginResiFormDTO dingLoginResiFormDTO = new DingLoginResiFormDTO(); + dingLoginResiFormDTO.setAvatarUrl(dingUserDetailDTO.getAvatar()); + dingLoginResiFormDTO.setEmail(dingUserDetailDTO.getOrg_email()); + dingLoginResiFormDTO.setMobile(dingUserDetailDTO.getMobile()); + dingLoginResiFormDTO.setNick(dingUserDetailDTO.getName()); + dingLoginResiFormDTO.setOpenId(StrConstant.EPMETY_STR); + dingLoginResiFormDTO.setStateCode(dingUserDetailDTO.getState_code()); + dingLoginResiFormDTO.setUnionId(dingUserDetailDTO.getUnionid()); + return dingLoginResiFormDTO; + } + + + /** + * 企业内部应用开发,不授权了 + * https://open.dingtalk.com/document/orgapp-server/enterprise-internal-application-logon-free + * 建议用户信息保存在前端缓存中(dd.setStorage)或者cookie中,避免每次进入应用都调用钉钉接口进行免登。 + * + * 获取免登授权码。 + * 小程序免登 + * 微应用免登 + * 获取AccessToken。 + * 调用接口获取access_token,详情请参考获取企业内部应用的access_token。 + * + * 获取userid。 + * 调用接口获取用户的userid,详情请参考通过免登码获取用户信息。 + * + * 获取用户详情。 + * 调用接口获取用户详细信息,详情请参考根据userId获取用户详情。 + * + * @param formDTO + * @return + */ + @Override + public ResiDingAppLoginResDTO resiLoginInternalDing(DingAppLoginMdFormDTO formDTO) { + // 获取用户手机号 + log.info("1、钉钉居民端应用登录入参:" + JSON.toJSONString(formDTO)); + ResiDingAppLoginResDTO resDTO = new ResiDingAppLoginResDTO(); + resDTO.setCustomerId(getCurrentCustomerId()); + + // 1、获取用户手机号 + DingLoginResiFormDTO dingLoginResiFormDTO = getDingLoginResiFormDTOInternal(formDTO.getMiniAppId(), formDTO.getAuthCode()); + dingLoginResiFormDTO.setCustomerId(resDTO.getCustomerId()); + resDTO.setRealName(dingLoginResiFormDTO.getNick()); + // 2、调用userfeign接口获取userId、注册网格相关信息 + Result loginResiResDTOResult = epmetUserOpenFeignClient.dingResiLogin(dingLoginResiFormDTO); + if (!loginResiResDTOResult.success() || null == loginResiResDTOResult.getData()) { + // 临时打个日志 + log.error(String.format("resiLoginInternalDing获取epmetUserId异常,入参:%s", JSON.toJSONString(dingLoginResiFormDTO))); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取epmetUserId异常:"+ JSON.toJSONString(loginResiResDTOResult), "获取epmetUserId异常"); + } + DingLoginResiResDTO resiResDTO = loginResiResDTOResult.getData(); + resDTO.setGridId(resiResDTO.getGridId()); + resDTO.setGridName(resiResDTO.getGridName()); + resDTO.setAgencyId(resiResDTO.getAgencyId()); + resDTO.setEpmetUserId(resiResDTO.getEpmetUserId()); + resDTO.setRegFlag(resiResDTO.getRegFlag()); + + // 3.生成token,并且存放Redis + String token = this.saveTokenDtoDing(formDTO.getMiniAppId(), AppClientConstant.APP_RESI, AppClientConstant.MINI_DING, resDTO.getEpmetUserId(), resDTO.getCustomerId()); + resDTO.setAuthorization(token); + + return resDTO; + } + + @Override + public UserTokenResultDTO govLoginInternalDing(DingAppLoginMdFormDTO formDTO) { + // 获取用户手机号 + log.info("1、钉钉居民端应用登录入参:" + JSON.toJSONString(formDTO)); + ResiDingAppLoginResDTO resDTO = null; + resDTO = new ResiDingAppLoginResDTO(); + resDTO.setCustomerId(getCurrentCustomerId()); + + // 1、获取用户手机号 + DingLoginResiFormDTO dingLoginResiFormDTO = getDingLoginResiFormDTOInternal(formDTO.getMiniAppId(), formDTO.getAuthCode()); + dingLoginResiFormDTO.setCustomerId(resDTO.getCustomerId()); + + + GovWebLoginFormDTO loginGovParam = new GovWebLoginFormDTO(); + loginGovParam.setCustomerId(dingLoginResiFormDTO.getCustomerId()); + loginGovParam.setPhone(dingLoginResiFormDTO.getMobile()); + + return govWebService.loginByThirdPlatform(loginGovParam); + } + + /** + * 最原始的企业内部应用开发,不授权给产品服务商 + * @param miniAppId + * @param authCode + * @return + */ + private DingLoginResiFormDTO getDingLoginResiFormDTOInternal(String miniAppId, String authCode) { + DingMiniInfoCache dingMiniInfo = CustomerDingDingRedis.getDingMiniInfo(miniAppId); + if (dingMiniInfo == null){ + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取钉钉应用配置异常", "获取钉钉应用配置异常"); + } + // 1、获取企业内部应用的accessToken文档地址:https://open.dingtalk.com/document/orgapp-server/obtain-the-access_token-of-an-internal-app + String accessToken = ""; + DingTalkResult dingTalkResult = dingTalkClientToken.getAppAccessTokenToken(dingMiniInfo.getSuiteKey(), dingMiniInfo.getSuiteSecret()); + if (!dingTalkResult.success() || StringUtils.isBlank(dingTalkResult.getData())) { + log.error(String.format("获取企业内部应用的accessToken失败,customKey:%s,customSecret:%s", dingMiniInfo.getSuiteKey(), dingMiniInfo.getSuiteSecret())); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取企业内部应用的accessToken异常", "获取企业内部应用的accessToken"); + } + accessToken = dingTalkResult.getData(); + log.info(String.format("1、获取企业内部应用的accessToken返参:%s", accessToken)); + + + // 2、通过免登码获取用户信息,文档地址:https://open.dingtalk.com/document/orgapp-server/obtain-the-userid-of-a-user-by-using-the-log-free + DingTalkResult v2UserGetuserinfoRes = dingTalkClientToken.getUserInfo(accessToken, authCode); + if (!v2UserGetuserinfoRes.success() || StringUtils.isBlank(v2UserGetuserinfoRes.getData())) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "通过免登码获取用户信息异常", "通过免登码获取用户信息异常"); + } + log.info(String.format("2、通过免登码获取用户信息返参:%s", v2UserGetuserinfoRes.getData())); + V2UserGetuserinfoResDTO v2UserGetuserinfoResDTO = JSON.parseObject(v2UserGetuserinfoRes.getData(), V2UserGetuserinfoResDTO.class); + if (null == v2UserGetuserinfoResDTO || StringUtils.isBlank(v2UserGetuserinfoResDTO.getUserid())) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取钉钉用户userid为空", "获取钉钉用户userid为空"); + } + + + // 3、查询用户详情,文档地址:https://open.dingtalk.com/document/isvapp-server/query-user-details + DingTalkResult v2UserGetRes = dingTalkClientToken.getUserDetail(v2UserGetuserinfoResDTO.getUserid(), accessToken); + if (!v2UserGetRes.success() || StringUtils.isBlank(v2UserGetRes.getData())) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "根据userId查询用户详情失败", "根据userId查询用户详情失败"); + } + log.info(String.format("3、查询用户详情:%s", v2UserGetRes.getData())); + DingUserDetailDTO dingUserDetailDTO = JSON.parseObject(v2UserGetRes.getData(), DingUserDetailDTO.class); + if (null == dingUserDetailDTO || StringUtils.isBlank(dingUserDetailDTO.getMobile())) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取手机号为空", "获取手机号为空"); + } + + DingLoginResiFormDTO dingLoginResiFormDTO = new DingLoginResiFormDTO(); + dingLoginResiFormDTO.setAvatarUrl(dingUserDetailDTO.getAvatar()); + dingLoginResiFormDTO.setEmail(dingUserDetailDTO.getOrg_email()); + dingLoginResiFormDTO.setMobile(dingUserDetailDTO.getMobile()); + dingLoginResiFormDTO.setNick(dingUserDetailDTO.getName()); + dingLoginResiFormDTO.setOpenId(StrConstant.EPMETY_STR); + dingLoginResiFormDTO.setStateCode(dingUserDetailDTO.getState_code()); + dingLoginResiFormDTO.setUnionId(dingUserDetailDTO.getUnionid()); + return dingLoginResiFormDTO; + } + + /** + * 客户写死吧 + * @return + */ + private String getCurrentCustomerId() { + String customerId=""; + EnvEnum currentEnv = EnvEnum.getCurrentEnv(); + if (EnvEnum.PROD.getCode().equals(currentEnv.getCode())) { + // 烟台的客户id + customerId="1535072605621841922"; + } else if (EnvEnum.TEST.getCode().equals(currentEnv.getCode())) { + // 最美琴岛 + customerId="0c41b272ee9ee95ac6f184ad548a30eb"; + } else { + // 其余统一走开发环境 + customerId="45687aa479955f9d06204d415238f7cc"; + } + return customerId; + } } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/AppClientConstant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/AppClientConstant.java index 0b42461f6e..049f335aa4 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/AppClientConstant.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/AppClientConstant.java @@ -32,6 +32,11 @@ public interface AppClientConstant { */ String CLIENT_WXMP = "wxmp"; + /** + * 钉钉小程序 + */ + String MINI_DING = "mini_ding"; + /** * 客户来源App * */ diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java index 1f0d76e14f..d3e34b119d 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java @@ -85,6 +85,7 @@ public interface NumConstant { String POSITIVE_EIGHT_STR = "+8"; String EMPTY_STR = ""; String ONE_NEG_STR = "-1"; + String ONE_HUNDRED_STR = "100"; String FIFTY_STR="50"; } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/DingMiniInfoFormDTO.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/DingMiniInfoFormDTO.java new file mode 100644 index 0000000000..bd36526985 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/DingMiniInfoFormDTO.java @@ -0,0 +1,26 @@ +package com.epmet.commons.tools.dto.form; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2022/9/15 10:25 + * @DESC + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class DingMiniInfoFormDTO implements Serializable { + + private static final long serialVersionUID = 2661531490851265637L; + + public interface DingMiniInfoForm{} + + @NotBlank(message = "miniAppId不能为空",groups = DingMiniInfoForm.class) + private String miniAppId; +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/HasOperPermissionFormDTO.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/HasOperPermissionFormDTO.java new file mode 100644 index 0000000000..62faa45150 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/HasOperPermissionFormDTO.java @@ -0,0 +1,24 @@ +package com.epmet.commons.tools.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +@Data +public class HasOperPermissionFormDTO { + + /** + * uri + */ + @NotBlank(message = "uri不能为空") + private String uri; + + /** + * http方法 + */ + @NotBlank(message = "请求http方法不能为空") + private String method; + + @NotBlank(message = "操作者ID不能为空") + private String operId; +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/OperResouce.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/OperResouce.java new file mode 100644 index 0000000000..632f013746 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/OperResouce.java @@ -0,0 +1,13 @@ +package com.epmet.commons.tools.dto.result; + +import lombok.Data; + +@Data +public class OperResouce { + + private String userId; + private String resourceUrl; + private String ResourceMethod; + + +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/YtHsjcResDTO.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/YtHsjcResDTO.java new file mode 100644 index 0000000000..4dcf8869a1 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/YtHsjcResDTO.java @@ -0,0 +1,22 @@ +package com.epmet.commons.tools.dto.result; + +import lombok.Data; + +import java.util.List; + + +/** + * @Description + * @Author yzm + * @Date 2022/9/26 17:04 + */ +@Data +public class YtHsjcResDTO { + private int code = 200; + private String msg = "请求成功"; + /** + * 响应数据 + */ + private List data; + private int total; +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/YtHsjcResDetailDTO.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/YtHsjcResDetailDTO.java new file mode 100644 index 0000000000..4a958a3cf7 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/YtHsjcResDetailDTO.java @@ -0,0 +1,48 @@ +package com.epmet.commons.tools.dto.result; + +import lombok.Data; + +/** + * @Description + * @Author yzm + * @Date 2022/9/26 17:10 + */ +@Data +public class YtHsjcResDetailDTO { + private String id; + private String name; + private String card_no; + private String telephone; + private String address; + private String test_time; + private String depart_name; + private String county; + private String upload_time; + private String sample_result_pcr; + private String sample_time; + private String sampling_org_pcr; + + /* { + "code":"200", + "msg":"请求成功", + "data":[ + { + "id":"6a31eb2d38c011eda054fa163ebc7ff4", + "name":"杨冠中",// 姓名 + "card_no":"372527198404130813",// 证件号码 + "telephone":"13697890860",// 电话 + "address":"保利香榭里公馆18-1-302",// 联系地址 + "test_time":"2022-09-20 12:52:28",// 检测时间 + "depart_name":"天仁医学检验实验室有限公司",// varchar + "county":"莱山区",// 所属区县 + "upload_time":"2022-09-20 21:23:10",// 时间戳 + "sample_result_pcr":"2",// 核酸检测结果 1:阳性,2:阴性 + "sample_time":"2022-09-20 06:48:28",// 采样时间 + "sampling_org_pcr":"采样点327"// 核酸采样机构 + }, + ] + "total":1 + } +*/ +} + diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/DingMiniAppEnum.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/DingMiniAppEnum.java new file mode 100644 index 0000000000..b0c0054ebb --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/DingMiniAppEnum.java @@ -0,0 +1,79 @@ +package com.epmet.commons.tools.enums; + +/** + * @Description + * @Author yzm + * @Date 2022/9/14 19:11 + */ +public enum DingMiniAppEnum { + // 亿联云盘CorpId:dingd1e19e397c754c7735c2f4657eb6378f + // + // //各应用秘钥 + // 随手拍 + // SuiteId:27501006 + // AppId:119450 + // MiniAppId:5000000002934668 + // SuiteKey:suitew6ccvkquinmrghqy + // SuiteSecret:TooAxiegdsE5BPP6xo1AxK1LdmaUoMpPMyomOcGcBSXtnsxRc8dEfyOlG56oSmEB + // + // 随时讲 + // SuiteId:27564007 + // AppId:119451 + // MiniAppId:5000000002934374 + // SuiteKey:suitezhyj12glsrp8em0f + // SuiteSecret:-z5Q_lvMP6l7fTzlArEzUT8D_-5pvqBQaJMuTGHoXnz0nuiqGQMZ8aeya_cxTsN- + // + // 我的报事 + // SuiteId:27569006 + // AppId:119452 + // MiniAppId:5000000002934456 + // SuiteKey:suite5yxliro6wawv514w + // SuiteSecret:aQxiPi7DwJSUa9HlbUU_L7Q4wGCLEDmgf__Ffx75cTn3jZwuHy9vdl-9Iv5FeyJU + // + // 实时动态 + // SuiteId:27458011 + // AppId:119453 + // MiniAppId:5000000002934488 + // SuiteKey:suitemcestnonr6y0xigc + // SuiteSecret:kKCNCkfDhmLoVnl_wuAiScyDG4776mkTevuSBuiYhHg-Bvz1-vhb_4IA-Km7nK2I + SSP("suitew6ccvkquinmrghqy", "随手拍", "TooAxiegdsE5BPP6xo1AxK1LdmaUoMpPMyomOcGcBSXtnsxRc8dEfyOlG56oSmEB"), + SSJ("suitezhyj12glsrp8em0f", "随时讲", "-z5Q_lvMP6l7fTzlArEzUT8D_-5pvqBQaJMuTGHoXnz0nuiqGQMZ8aeya_cxTsN-"), + MY_REPORT_EVENT("suite5yxliro6wawv514w", "我的报事", "aQxiPi7DwJSUa9HlbUU_L7Q4wGCLEDmgf__Ffx75cTn3jZwuHy9vdl-9Iv5FeyJU"), + SSDT("suitemcestnonr6y0xigc", "实时动态", "kKCNCkfDhmLoVnl_wuAiScyDG4776mkTevuSBuiYhHg-Bvz1-vhb_4IA-Km7nK2I"); + + private String suiteKey; + private String name; + private String suiteSecret; + + + DingMiniAppEnum(String suiteKey, String name, String suiteSecret) { + this.suiteKey = suiteKey; + this.name = name; + this.suiteSecret = suiteSecret; + } + + public static DingMiniAppEnum getEnum(String suiteKey) { + DingMiniAppEnum[] values = DingMiniAppEnum.values(); + for (DingMiniAppEnum value : values) { + if (value.getSuiteKey().equals(suiteKey)) { + return value; + } + } + return null; + } + + + public String getSuiteKey() { + return suiteKey; + } + + public String getName() { + return name; + } + + public String getSuiteSecret() { + return suiteSecret; + } + +} + diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index 405d84d4ae..64688c8990 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -40,6 +40,7 @@ public enum EpmetErrorCode { PASSWORD_NOT_FIT(8010,"两次填写的密码不一致"), PASSWORD_OUT_OF_ORDER(8011,"密码必须8-20个字符,而且同时包含大小写字母和数字"), PASSWORD_UPDATE_FAILED(8012,"密码修改失败"), + GOV_STAFF_ACCOUNT_NOT_EXISTS(8013,"账户未注册,请联系贵单位管理员"), MOBILE_HAS_BEEN_USED(8101, "该手机号已注册,请更换手机号或使用原绑定的微信账号登录"), MOBILE_CODE_ERROR(8102, "验证码错误"), AUTO_CONFIRM_FAILED(8103, "党员注册失败"), @@ -100,6 +101,7 @@ public enum EpmetErrorCode { EXIT_PEND_PROJECT(8408,"该工作人员有项目尚在处理,处理完毕方可操作"), EXIT_PUBLISHED_ACTIVITY(8409,"该工作人员有活动尚在进行,等活动完成方可操作"), CAN_NOT_SELF(8410,"无法对自己进行操作"), + ACCOUNT_USED(8411,"该账号已注册"), PATROL_IS_NOT_OVER(8520,"巡查尚未结束"), ALREADY_EVALUATE(8501,"您已评价"), diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonOperAccessOpenFeignClient.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonOperAccessOpenFeignClient.java new file mode 100644 index 0000000000..15f76dcb62 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonOperAccessOpenFeignClient.java @@ -0,0 +1,46 @@ +package com.epmet.commons.tools.feign; + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.dto.form.HasOperPermissionFormDTO; +import com.epmet.commons.tools.dto.result.OperResouce; +import com.epmet.commons.tools.feign.fallback.CommonOperAccessOpenFeignClientFallbackFactory; +import com.epmet.commons.tools.utils.Result; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.List; + +/** + * @Description 运营端权限模块 + * @Author yinzuomei + * @Date 2020/5/21 15:17 本服务对外开放的API,其他服务通过引用此client调用该服务 + */ +@FeignClient(name = ServiceConstant.OPER_ACCESS_SERVER, fallbackFactory = CommonOperAccessOpenFeignClientFallbackFactory.class) +//@FeignClient(name = ServiceConstant.OPER_ACCESS_SERVER, fallbackFactory = CommonOperAccessOpenFeignClientFallbackFactory.class, url = "http://localhost:8093") +public interface CommonOperAccessOpenFeignClient { + /** + * @param + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 清空运营人员权限信息、菜单信息 + * @Date 2020/5/21 17:08 + **/ + @GetMapping("/oper/access/menu/clearoperuseraccess") + Result clearOperUserAccess(); + + /** + * 是否有该接口的权限 + * @return + */ + @PostMapping("/oper/access/menu/hasPermission") + Result hasOperPermission(@RequestBody HasOperPermissionFormDTO form); + + /** + * 需要验证的菜单资源 + * @return + */ + @PostMapping("/oper/access/menu/getExamineResourceUrls") + Result> getExamineResourceUrls(); +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonThirdFeignClient.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonThirdFeignClient.java new file mode 100644 index 0000000000..6bc986aca0 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonThirdFeignClient.java @@ -0,0 +1,24 @@ +package com.epmet.commons.tools.feign; + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.dto.form.DingMiniInfoFormDTO; +import com.epmet.commons.tools.feign.fallback.CommonThirdFeignClientFallBackFactory; +import com.epmet.commons.tools.redis.common.bean.DingMiniInfoCache; +import com.epmet.commons.tools.utils.Result; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + + +/** + * @Description + * @Author zxc + */ +@FeignClient(name = ServiceConstant.EPMET_THIRD_SERVER, fallbackFactory = CommonThirdFeignClientFallBackFactory.class) +// @FeignClient(name = ServiceConstant.EPMET_THIRD_SERVER, fallbackFactory = CommonAggFeignClientFallBackFactory.class,url = "localhost:8110") +public interface CommonThirdFeignClient { + + @PostMapping("/third/dingTalk/getDingMiniInfo") + Result getDingMiniInfo(@RequestBody DingMiniInfoFormDTO formDTO); + +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonOperAccessOpenFeignClientFallback.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonOperAccessOpenFeignClientFallback.java new file mode 100644 index 0000000000..ba047f1ada --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonOperAccessOpenFeignClientFallback.java @@ -0,0 +1,35 @@ +package com.epmet.commons.tools.feign.fallback; + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.dto.form.HasOperPermissionFormDTO; +import com.epmet.commons.tools.dto.result.OperResouce; +import com.epmet.commons.tools.feign.CommonOperAccessOpenFeignClient; +import com.epmet.commons.tools.utils.ModuleUtils; +import com.epmet.commons.tools.utils.Result; + +import java.util.List; + +/** + * @Description 运营端权限模块 + * @Author yinzuomei + * @Date 2020/5/21 15:47 + */ +//@Component +public class CommonOperAccessOpenFeignClientFallback implements CommonOperAccessOpenFeignClient { + @Override + public Result clearOperUserAccess() { + return ModuleUtils.feignConError(ServiceConstant.OPER_ACCESS_SERVER, "clearOperUserAccess"); + + } + + @Override + public Result hasOperPermission(HasOperPermissionFormDTO form) { + return ModuleUtils.feignConError(ServiceConstant.OPER_ACCESS_SERVER, "hasOperPermission"); + } + + @Override + public Result> getExamineResourceUrls() { + return ModuleUtils.feignConError(ServiceConstant.OPER_ACCESS_SERVER, "getExamineResourceUrls"); + } +} + diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonOperAccessOpenFeignClientFallbackFactory.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonOperAccessOpenFeignClientFallbackFactory.java new file mode 100644 index 0000000000..d62f24900c --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonOperAccessOpenFeignClientFallbackFactory.java @@ -0,0 +1,19 @@ +package com.epmet.commons.tools.feign.fallback; + +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.commons.tools.feign.CommonOperAccessOpenFeignClient; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class CommonOperAccessOpenFeignClientFallbackFactory implements FallbackFactory { + private CommonOperAccessOpenFeignClientFallback fallback = new CommonOperAccessOpenFeignClientFallback(); + + @Override + public CommonOperAccessOpenFeignClient create(Throwable cause) { + log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause))); + return fallback; + } +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonThirdFeignClientFallBackFactory.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonThirdFeignClientFallBackFactory.java new file mode 100644 index 0000000000..4a43935086 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonThirdFeignClientFallBackFactory.java @@ -0,0 +1,20 @@ +package com.epmet.commons.tools.feign.fallback; + +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.commons.tools.feign.CommonThirdFeignClient; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class CommonThirdFeignClientFallBackFactory implements FallbackFactory { + + private CommonThirdFeignClientFallback fallback = new CommonThirdFeignClientFallback(); + + @Override + public CommonThirdFeignClient create(Throwable cause) { + log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause))); + return fallback; + } +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonThirdFeignClientFallback.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonThirdFeignClientFallback.java new file mode 100644 index 0000000000..47e278f846 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonThirdFeignClientFallback.java @@ -0,0 +1,24 @@ +package com.epmet.commons.tools.feign.fallback; + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.dto.form.DingMiniInfoFormDTO; +import com.epmet.commons.tools.feign.CommonThirdFeignClient; +import com.epmet.commons.tools.redis.common.bean.DingMiniInfoCache; +import com.epmet.commons.tools.utils.ModuleUtils; +import com.epmet.commons.tools.utils.Result; +import org.springframework.stereotype.Component; + +/** + * + * @Author zxc + * @Description + * @Date + **/ +@Component +public class CommonThirdFeignClientFallback implements CommonThirdFeignClient { + + @Override + public Result getDingMiniInfo(DingMiniInfoFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "getDingMiniInfo", formDTO); + } +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java index bb7edb3e2a..c09f13f2f4 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java @@ -104,6 +104,10 @@ public class RedisKeys { return rootPrefix.concat("sys:security:user:").concat(app).concat(StrConstant.COLON).concat(client).concat(StrConstant.COLON).concat(userId); } + public static String getCpUserKeyForDingApp(String suiteKey,String app, String client, String userId) { + return rootPrefix.concat("sys:security:user:").concat(app).concat(StrConstant.COLON).concat(client).concat(StrConstant.COLON).concat(suiteKey).concat(StrConstant.COLON).concat(userId); + } + /** * 拼接手机验证码key---后面需要改!!! * @@ -871,4 +875,39 @@ public class RedisKeys { public static String getDhToken() { return rootPrefix.concat("dh:token"); } + + /** + * Desc: 票据 + * @param suiteKey + * @author zxc + * @date 2022/9/14 10:46 + */ + public static String getSuiteTicketKey(String suiteKey) { + return rootPrefix.concat("ding:suiteTicket:" + suiteKey); + } + + public static String getDingMiniInfoKey(String suiteKey) { + return rootPrefix.concat("ding:miniInfo:" + suiteKey); + } + + /** + * 运营人员-资源权限 + * @param operId + * @return + */ + public static String operResourcesBaseDir() { + return rootPrefix.concat("oper:access:resources:"); + } + + public static String operResourcesByUserId(String operId) { + return operResourcesBaseDir().concat(operId); + } + + /** + * 获取需要检查的资源url + * @return + */ + public static String getOperExamineResourceUrls() { + return rootPrefix.concat("oper:access:examineresources"); + } } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerDingDingRedis.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerDingDingRedis.java new file mode 100644 index 0000000000..8a57fb1ca7 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerDingDingRedis.java @@ -0,0 +1,58 @@ +package com.epmet.commons.tools.redis.common; + +import com.epmet.commons.tools.dto.form.DingMiniInfoFormDTO; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.feign.CommonThirdFeignClient; +import com.epmet.commons.tools.redis.RedisKeys; +import com.epmet.commons.tools.redis.RedisUtils; +import com.epmet.commons.tools.redis.common.bean.DingMiniInfoCache; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.Result; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import javax.annotation.PostConstruct; +import java.util.Map; + +/** + * @Author zxc + * @DateTime 2022/9/15 10:01 + * @DESC + */ +@Slf4j +@Component +public class CustomerDingDingRedis { + + @Autowired + private CommonThirdFeignClient thirdFeignClient; + @Autowired + private RedisUtils redisUtils; + + private static CustomerDingDingRedis customerDingDingRedis; + + @PostConstruct + public void init() { + customerDingDingRedis = this; + customerDingDingRedis.thirdFeignClient = this.thirdFeignClient; + customerDingDingRedis.redisUtils = this.redisUtils; + } + + public static DingMiniInfoCache getDingMiniInfo(String miniAppId){ + String key = RedisKeys.getDingMiniInfoKey(miniAppId); + Map miniInfoMap = customerDingDingRedis.redisUtils.hGetAll(key); + if (!CollectionUtils.isEmpty(miniInfoMap)){ + return ConvertUtils.mapToEntity(miniInfoMap,DingMiniInfoCache.class); + } + Result dingMiniInfoResult = customerDingDingRedis.thirdFeignClient.getDingMiniInfo(new DingMiniInfoFormDTO(miniAppId)); + if (!dingMiniInfoResult.success()){ + throw new EpmetException("查询dingMiniInfo失败..."); + } + if (null == dingMiniInfoResult.getData()){ + return null; + } + return dingMiniInfoResult.getData(); + } + +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/DingMiniInfoCache.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/DingMiniInfoCache.java new file mode 100644 index 0000000000..bd656c9a7e --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/DingMiniInfoCache.java @@ -0,0 +1,52 @@ +package com.epmet.commons.tools.redis.common.bean; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2022/9/15 10:11 + * @DESC + */ +@Data +public class DingMiniInfoCache implements Serializable { + + private static final long serialVersionUID = -6956910978074595334L; + + private String id; + + /** + * + */ + private String suiteId; + + /** + * + */ + private String appId; + + /** + * + */ + private String miniAppId; + + /** + * + */ + private String suiteName; + + /** + * + */ + private String suiteKey; + + /** + * + */ + private String suiteSecret; + + private String token; + + private String aesKey; +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/password/PasswordUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/password/PasswordUtils.java index d7a685b2f2..fdae188e6b 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/password/PasswordUtils.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/password/PasswordUtils.java @@ -37,6 +37,43 @@ public class PasswordUtils { return passwordEncoder.matches(str, password); } + /** + * desc:校验密码规则是否 + * 校验密码规则:密码必须8-20个字符,而且同时包含大小写字母和数字 + * @param password + * @return + */ + public static boolean checkPassWordRule(String password) { + boolean flag=false; + if(password.length()<8||password.length()>20){ + return flag; + } + boolean numFlag=false; + boolean bigLetter=false; + boolean smallLetter=false; + char[] passwordArray = password.toCharArray(); + for(int i=0;i < passwordArray.length;i++) { + char currentStr=passwordArray[i]; + // 判断ch是否是数字字符,如'1','2‘,是返回true。否则返回false + if(Character.isDigit(currentStr)){ + numFlag=true; + continue; + } + // 判断ch是否是字母字符,如'a','b‘,是返回true。否则返回false + if(Character.isUpperCase(currentStr)){ + bigLetter=true; + continue; + } + if(Character.isLowerCase(currentStr)){ + smallLetter=true; + } + } + if(numFlag&&bigLetter&&smallLetter){ + flag=true; + } + return flag; + } + public static void main(String[] args) { String str = "wangqing"; diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/CpUserDetailRedis.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/CpUserDetailRedis.java index 4c0845fc6c..856cb6449d 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/CpUserDetailRedis.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/CpUserDetailRedis.java @@ -41,6 +41,15 @@ public class CpUserDetailRedis { redisUtils.hMSet(key, map, expire); } + public void setForDingApp(String suiteKey,TokenDto user, long expire) { + if (user == null) { + return; + } + String key = RedisKeys.getCpUserKeyForDingApp(suiteKey,user.getApp(), user.getClient(), user.getUserId()); + //bean to map + Map map = BeanUtil.beanToMap(user, false, true); + redisUtils.hMSet(key, map, expire); + } /** * 获取token信息 * diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/NameUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/NameUtils.java new file mode 100644 index 0000000000..8dec710c4a --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/NameUtils.java @@ -0,0 +1,89 @@ +package com.epmet.commons.tools.utils; + +import com.epmet.commons.tools.constant.NumConstant; + +import java.util.HashMap; +import java.util.Map; + +/** + * @Description + * @Author zhaoqifeng + * @Date 2022/9/14 14:40 + */ +public class NameUtils { + /** + * 复姓(两字),国内现存81个。末尾添加三字以上的部分满姓 + */ + private static final String[] SURNAME_NOW = {"百里", "北堂", "北野", "北宫", "辟闾", "孛尔", "淳于", "成公", "陈生", "褚师", + "端木", "东方", "东郭", "东野", "东门", "第五", "大狐", "段干", "段阳", "带曰", "第二", "东宫", "公孙", "公冶", "公羊", + "公良", "公西", "公孟", "高堂", "高阳", "公析", "公肩", "公坚", "郭公", "谷梁", "毌将", "公乘", "毌丘", "公户", "公广", + "公仪", "公祖", "皇甫", "黄龙", "胡母", "何阳", "夹谷", "九方", "即墨", "梁丘", "闾丘", "洛阳", "陵尹", "冷富", "龙丘", + "令狐", "林彭", "南宫", "南郭", "女娲", "南伯", "南容", "南门", "南野", "欧阳", "欧侯", "濮阳", "青阳", "漆雕", "亓官", + "渠丘", "壤驷", "上官", "少室", "少叔", "司徒", "司马", "司空", "司寇", "士孙", "申屠", "申徒", "申鲜", "申叔", "夙沙", + "叔先", "叔仲", "侍其", "叔孙", "澹台", "太史", "太叔", "太公", "屠岸", "唐古", "闻人", "巫马", "微生", "王孙", "无庸", + "夏侯", "西门", "信平", "鲜于", "轩辕", "相里", "新垣", "徐离", "羊舌", "羊角", "延陵", "於陵", "伊祁", "吾丘", "乐正", + "只斤", "诸葛", "颛孙", "仲孙", "仲长", "钟离", "宗政", "主父", "中叔", "左人", "左丘", "宰父", "长儿", "仉督", "单于", + "叱干", "叱利", "车非", "车公", "车侯", "车长", "车绵", "独孤", "大野", "独吉", "达奚", "达官", "达仲", "达品", "哥舒", + "哥夜", "哥翰", "哥汗", "赫连", "呼延", "贺兰", "黑齿", "斛律", "斛粟", "贺若", "贺奴", "贺远", "贺元", "夹谷", "吉胡", + "吉利", "吉家", "可频", "慕容", "万俟", "万红", "万中", "抹捻", "纳兰", "纳西", "纳吉", "纳罕", "纳塞", "纳博", "纳称", + "纳勉", "普周", "仆固", "仆散", "蒲察", "屈突", "屈卢", "钳耳", "是云", "索卢", "厍狄", "拓跋", "同蹄", "秃发", "完颜", + "完明", "完忠", "宇文", "尉迟", "耶律", "耶红", "也先", "耶鲜", "耶闻", "长孙", "长南", "长北", "长西", "长红", "长元", + "长秋", "长寸", "长李", "长云", "萨嘛喇","赫舍里","萨克达","钮祜禄","他塔喇","喜塔腊","库雅喇","瓜尔佳","舒穆禄","索绰络", + "叶赫那拉","依尔觉罗","额尔德特","讷殷富察","叶赫那兰","爱新觉罗","依尔根觉罗"}; + + /** + * 获取复姓,非单字姓氏。未匹配上则依旧返回单字姓氏 + * @param name + * @return + */ + public static String getSurNameComplex(String name){ + for (String s : SURNAME_NOW) { + if (name.startsWith(s)) { + return name.substring(0, s.length()); + } + } + return name.substring(0,1); + } + + /** + * 获取复姓名,去除姓氏后名 + * @param name + * @return + */ + public static String getNameComplex(String name){ + for (String s : SURNAME_NOW) { + if (name.startsWith(s)) { + return name.substring(s.length()); + } + } + return name.substring(1); + } + + /** + * 获取姓氏与姓名
+ * 姓名在两字时,首字为姓。
+ * 姓名大于两字时,优先匹配复姓。
+ * 姓氏未匹配且姓名多于5字时,姓与名均在姓氏中,名为空;少于5字时则采用第一个字为姓。
+ * @param name 姓名 + * @return map类型数据,姓氏为key值“X”,名字为value值“M” + */ + public static Map getSurName(String name) { + Map mapData = new HashMap<>(NumConstant.TWO); + if (name.length() > NumConstant.ZERO && name.length() <= NumConstant.TWO){ + mapData.put("X", name.substring(NumConstant.ZERO, NumConstant.ONE)); + mapData.put("M", name.substring(NumConstant.ONE)); + } else if (name.length() > NumConstant.TWO) { + for (String s : SURNAME_NOW) {//遍历复姓数组 + if (name.startsWith(s)) { + mapData.put("X", s); + mapData.put("M", name.substring(s.length())); + return mapData; + } + } + //姓氏没有匹配时采用第一个字为姓 + mapData.put("X", name.substring(NumConstant.ZERO, NumConstant.ONE)); + mapData.put("M", name.substring(NumConstant.ONE)); + } + return mapData; + } +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YtHsResUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YtHsResUtils.java new file mode 100644 index 0000000000..0ea496de19 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YtHsResUtils.java @@ -0,0 +1,53 @@ +package com.epmet.commons.tools.utils; + +import com.alibaba.fastjson.JSON; +import com.epmet.commons.tools.dto.result.YtHsjcResDTO; +import lombok.extern.slf4j.Slf4j; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +/** + * @Description + * @Author yzm + * @Date 2022/9/26 16:56 + */ +@Slf4j +public class YtHsResUtils { + private static String URL = "http://10.2.2.60:8191/sjzt/server/hsjcxx"; + private static final String APP_KEY_VALUE = "DR4jF5Be7sCsqDmCamq2tmYCl"; + private static final String APP_KEY = "appkey"; + private static final String CARD_NO = "card_no"; + private static final String ROW_NUM = "ROWNUM"; + private static final String PAGE_SIZE = "PAGESIZE"; + /** + * desc:图片同步扫描 + * + * @return + */ + public static YtHsjcResDTO hsjc(String cardNo, Integer rowNum, Integer pageSize) { + try { + //String param = String.format("&card_no=%s&ROWNUM=%s&PAGESIZE=%s", cardNo, rowNum, pageSize); + //String apiUrl = url.concat(param); + Map param = new HashMap<>(); + param.put(APP_KEY,APP_KEY_VALUE); + param.put(CARD_NO,cardNo); + param.put(ROW_NUM,rowNum); + param.put(PAGE_SIZE,pageSize); + log.info("hsjc api param:{}",param); + Result result = HttpClientManager.getInstance().sendGet(URL, param); + log.info("hsjc api result:{}",JSON.toJSONString(result)); + if (result.success()) { + return JSON.parseObject(result.getData(), YtHsjcResDTO.class); + } + } catch (Exception e) { + e.printStackTrace(); + log.warn(String.format("烟台核酸检测结果查询异常cardNo:%s,异常信息:%s", cardNo, e.getMessage())); + } + YtHsjcResDTO resultResult = new YtHsjcResDTO(); + resultResult.setData(new ArrayList<>()); + return resultResult; + } +} + diff --git a/epmet-gateway/src/main/java/com/epmet/GatewayApplication.java b/epmet-gateway/src/main/java/com/epmet/GatewayApplication.java index cf7493a300..399f574dd9 100644 --- a/epmet-gateway/src/main/java/com/epmet/GatewayApplication.java +++ b/epmet-gateway/src/main/java/com/epmet/GatewayApplication.java @@ -8,9 +8,15 @@ package com.epmet; +import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.aspect.ServletExceptionHandler; import com.epmet.commons.tools.config.RedissonConfig; import com.epmet.commons.tools.config.ThreadDispatcherConfig; +import com.epmet.commons.tools.redis.RedisKeys; +import com.epmet.commons.tools.redis.RedisUtils; +import com.epmet.filter.CpProperty; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; @@ -18,6 +24,9 @@ import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.FilterType; +import javax.annotation.PostConstruct; +import java.util.List; + /** * 网关服务 * @@ -31,7 +40,24 @@ import org.springframework.context.annotation.FilterType; @ComponentScan(basePackages = {"com.epmet.*"}, excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {RedissonConfig.class, ThreadDispatcherConfig.class, ServletExceptionHandler.class})) public class GatewayApplication { + @Autowired + private CpProperty cpProperty; + + @Autowired + private RedisUtils redisUtils; + public static void main(String[] args) { SpringApplication.run(GatewayApplication.class, args); } + + /** + * 初始化运营端校验资源列表 + */ +// @PostConstruct +// public void initOperExamineResources() { +// if (!redisUtils.hasKey(RedisKeys.getOperExamineResourceUrls())) { +// List operExamineResourceUrls = cpProperty.getOperExamineResourceUrls(); +// redisUtils.setString(RedisKeys.getOperExamineResourceUrls(), JSON.toJSONString(operExamineResourceUrls)); +// } +// } } diff --git a/epmet-gateway/src/main/java/com/epmet/auth/InternalAuthProcessor.java b/epmet-gateway/src/main/java/com/epmet/auth/InternalAuthProcessor.java index 305bf2b3a4..c857f97159 100644 --- a/epmet-gateway/src/main/java/com/epmet/auth/InternalAuthProcessor.java +++ b/epmet-gateway/src/main/java/com/epmet/auth/InternalAuthProcessor.java @@ -1,11 +1,22 @@ package com.epmet.auth; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; import com.epmet.commons.tools.constant.AppClientConstant; import com.epmet.commons.tools.constant.Constant; +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.dto.form.HasOperPermissionFormDTO; +import com.epmet.commons.tools.dto.result.OperResouce; import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.feign.CommonOperAccessOpenFeignClient; +import com.epmet.commons.tools.feign.ResultDataResolver; +import com.epmet.commons.tools.redis.RedisKeys; +import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.security.dto.BaseTokenDto; import com.epmet.commons.tools.utils.CpUserDetailRedis; +import com.epmet.commons.tools.utils.Result; import com.epmet.filter.CpProperty; import com.epmet.jwt.JwtTokenUtils; import io.jsonwebtoken.Claims; @@ -15,18 +26,20 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.gateway.filter.GatewayFilterChain; import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.stereotype.Component; import org.springframework.util.AntPathMatcher; import org.springframework.web.server.ServerWebExchange; import java.util.Date; +import java.util.List; /** * 内部认证处理器 */ @Component -public class InternalAuthProcessor extends AuthProcessor { +public class InternalAuthProcessor extends AuthProcessor implements ResultDataResolver { private Logger logger = LoggerFactory.getLogger(getClass()); @@ -41,6 +54,12 @@ public class InternalAuthProcessor extends AuthProcessor { @Autowired private CpProperty cpProperty; + @Autowired + private CommonOperAccessOpenFeignClient operAccessOpenFeignClient; + + @Autowired + private RedisUtils redisUtils; + @Override public ServerWebExchange auth(ServerWebExchange exchange, GatewayFilterChain chain) { ServerHttpRequest request = exchange.getRequest(); @@ -104,10 +123,59 @@ public class InternalAuthProcessor extends AuthProcessor { builder.header(AppClientConstant.CUSTOMER_ID, customerId); } + // 针对运营端的url拦截和校验 + if (AppClientConstant.APP_OPER.equals(app)) { + HttpMethod method = request.getMethod(); + Boolean hasAccess = checkRequestOperResource(userId, requestUri, method.toString()); + if (!hasAccess) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "资源未授权", "资源未授权"); + } + } + ServerHttpRequest shr = builder.build(); return exchange.mutate().request(shr).build(); } + /** + * 校验运营端用户是否有权访问该资源 + * @param uri + * @param method + * @return + */ + private Boolean checkRequestOperResource(String userId, String uri, String method) { + String resourceJsonString = redisUtils.getString(RedisKeys.getOperExamineResourceUrls()); + List resources = JSON.parseObject(resourceJsonString, new TypeReference>() {}); + + if (resources == null) { + // redis中没有缓存,需要api获取 + resources = getResultDataOrThrowsException(operAccessOpenFeignClient.getExamineResourceUrls(), ServiceConstant.OPER_ACCESS_SERVER, + EpmetErrorCode.SERVER_ERROR.getCode(), "调用operaccess获取要校验的资源失败", "调用operaccess获取要校验的资源失败"); + + // 缓存 + redisUtils.setString(RedisKeys.getOperExamineResourceUrls(), JSON.toJSONString(resources)); + } + + for (OperResouce resource : resources) { + if (antPathMatcher.match(resource.getResourceUrl(), uri) + && resource.getResourceMethod().equals(method)) { + + //需要校验权限的url + HasOperPermissionFormDTO form = new HasOperPermissionFormDTO(); + form.setUri(uri); + form.setMethod(method); + form.setOperId(userId); + Result result = operAccessOpenFeignClient.hasOperPermission(form); + if (result == null || !result.success()) { + return false; + } + return true; + } + } + + // 如果当前请求url不需要校验权限,那么返回true + return true; + } + /** * 是否需要认证 * @param requestUri diff --git a/epmet-gateway/src/main/java/com/epmet/filter/CpProperty.java b/epmet-gateway/src/main/java/com/epmet/filter/CpProperty.java index 2ea01e1c32..71dce075fe 100644 --- a/epmet-gateway/src/main/java/com/epmet/filter/CpProperty.java +++ b/epmet-gateway/src/main/java/com/epmet/filter/CpProperty.java @@ -42,4 +42,15 @@ public class CpProperty { */ private List swaggerUrls; + /** + * 运营端,需要校验的url资源列表 + */ + private List operExamineResourceUrls; + + @Data + public static class OperExamineResource { + private String resourceUrl; + private String resourceMethod; + } + } diff --git a/epmet-gateway/src/main/java/com/epmet/filter/EpmetGatewayFilter.java b/epmet-gateway/src/main/java/com/epmet/filter/EpmetGatewayFilter.java index 7cca3c4b36..ea02f75376 100644 --- a/epmet-gateway/src/main/java/com/epmet/filter/EpmetGatewayFilter.java +++ b/epmet-gateway/src/main/java/com/epmet/filter/EpmetGatewayFilter.java @@ -5,6 +5,7 @@ import com.epmet.auth.ExternalAuthProcessor; import com.epmet.auth.InternalAuthProcessor; import com.epmet.commons.tools.constant.AppClientConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.IpUtils; @@ -64,6 +65,10 @@ public class EpmetGatewayFilter implements GatewayFilter { } return doFilter(exchange, chain); + } catch (EpmetException re) { + // 人为抛出,则携带错误码和错误信息响应给前端 + log.error("EpmetGatewayFilter认证出错RenException,错误信息:{}", ExceptionUtils.getErrorStackTrace(re)); + return response(exchange, new Result<>().error(re.getCode(), re.getMessage())); } catch (RenException re) { // 人为抛出,则携带错误码和错误信息响应给前端 log.error("EpmetGatewayFilter认证出错RenException,错误信息:{}", ExceptionUtils.getErrorStackTrace(re)); diff --git a/epmet-gateway/src/main/resources/bootstrap-urls.yml b/epmet-gateway/src/main/resources/bootstrap-urls.yml new file mode 100644 index 0000000000..dded0b1b86 --- /dev/null +++ b/epmet-gateway/src/main/resources/bootstrap-urls.yml @@ -0,0 +1,5 @@ +epmet: + oper-examine-resource-urls: + # 角色编辑 + - resourceUrl: /oper/access/operrole + resourceMethod: PUT \ No newline at end of file diff --git a/epmet-gateway/src/main/resources/bootstrap.yml b/epmet-gateway/src/main/resources/bootstrap.yml index b0b2492d33..483f545f43 100644 --- a/epmet-gateway/src/main/resources/bootstrap.yml +++ b/epmet-gateway/src/main/resources/bootstrap.yml @@ -12,6 +12,7 @@ spring: name: epmet-gateway-server #环境 dev|test|prod profiles: + include: urls active: @spring.profiles.active@ messages: encoding: UTF-8 @@ -498,6 +499,7 @@ epmet: - /resi/voice/** - /point/** - /heart/** + - /oss/** # 内部认证url白名单(在白名单中的,就不会再校验登录了) internalAuthUrlsWhiteList: diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java index 58109b1b89..a8621ce09d 100644 --- a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java +++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java @@ -73,4 +73,9 @@ public interface ImportTaskConstants { * 社会组织 */ String IC_SOCIETY_ORG="ic_society_org"; + + /** + * 未做核酸比对 + */ + String IC_NAT_COMPARE_RECORD="ic_nat_compare_record"; } diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/AreaCodeServiceImpl.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/AreaCodeServiceImpl.java index b0f519a3ac..418b3dc251 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/AreaCodeServiceImpl.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/AreaCodeServiceImpl.java @@ -833,7 +833,7 @@ public class AreaCodeServiceImpl extends BaseServiceImpl uploadResiEventFile(@RequestPart(value = "file") MultipartFile file, @RequestParam("customerId") String customerId) { - + public Result uploadResiEventFile(@LoginUser TokenDto tokenDto, @RequestPart(value = "file") MultipartFile file, @RequestParam(value = "customerId",required = false) String customerId) { + if (StringUtils.isBlank(customerId)){ + customerId = tokenDto.getCustomerId(); + } // 体积限制 int sizeMb = 10; int sizeThreshold = sizeMb * 1024 * 1024; // 大小限制10m diff --git a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/service/impl/OssServiceImpl.java b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/service/impl/OssServiceImpl.java index d55751762c..140d57ead6 100644 --- a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/service/impl/OssServiceImpl.java +++ b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/service/impl/OssServiceImpl.java @@ -279,6 +279,7 @@ public class OssServiceImpl extends BaseServiceImpl implement UploadImgResultDTO dto = new UploadImgResultDTO(); dto.setUrl(url); dto.setDomain(ossDomain); + dto.setFileName(file.getOriginalFilename()); return new Result().ok(dto); } diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/DingMiniInfoDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/DingMiniInfoDTO.java new file mode 100644 index 0000000000..19ebfacdd9 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/DingMiniInfoDTO.java @@ -0,0 +1,89 @@ +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 钉钉小程序信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-09-14 + */ +@Data +public class DingMiniInfoDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * ID + */ + private String id; + + /** + * + */ + private String suiteId; + + /** + * + */ + private String appId; + + /** + * + */ + private String miniAppId; + + /** + * + */ + private String suiteName; + + /** + * + */ + private String suiteKey; + + /** + * + */ + private String suiteSecret; + + private String token; + + private String aesKey; + + /** + * + */ + private Integer delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/OpenSyncBizDataDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/OpenSyncBizDataDTO.java new file mode 100644 index 0000000000..12dac445f0 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/OpenSyncBizDataDTO.java @@ -0,0 +1,99 @@ +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-09-14 + */ +@Data +public class OpenSyncBizDataDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * + */ + private String id; + + /** + * 第三方企业应用的suiteid加下划线0 + */ + private String subscribeId; + + private String suiteKey; + + /** + * 第三方企业应用的corpid + */ + private String corpId; + + /** + * 第三方企业应用的suiteid + */ + private String bizId; + + /** + * 数据为Json格式 + */ + private String bizData; + + /** + * 2:第三方企业应用票据; +4:企业授权变更,包含授权、解除授权、授权变更; +7:第三方企业应用变更,包含停用、启用、删除(删除保留授权); +13:企业用户变更,包含用户添加、修改、删除; +14:企业部门变更,包含部门添加、修改、删除; +15:企业角色变更,包含角色添加、修改、删除; +16:企业变更,包含企业修改、删除; +17:市场订单; +20:企业外部联系人变更,包含添加、修改、删除; +22:ISV自定义审批; +25:家校通讯录1.0(Deprecated)信息变更。家校通讯录升级,请查看家校通讯录2.0数据推送; +32:智能硬件绑定类型; +37:因订单到期或者用户退款等导致的服务关闭,目前仅推送因退款等导致的服务关闭; +50:家校通讯录2.0,部门信息变更; +51:家校通讯录2.0,人员信息变更; +63:应用试用记录回调信息; +66:工作台组件变更回调事件; +67:钉钉假期相关回调事件; +133:CRM客户动态相关数据回调事件; +137:人事平台员工异动V2相关数据回调事件; +139:异步转译通讯录id任务完成通知; +165:人事平台员工档案变动事件相关数据的回调事件; +175:人事解决方案变更事件; + */ + private String bizType; + + /** + * + */ + private Integer delFlag; + + /** + * + */ + private Date createdTime; + + /** + * + */ + private String createdBy; + + /** + * + */ + private Date updatedTime; + + /** + * + */ + private String updatedBy; + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/ExemptLoginUserDetailFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/ExemptLoginUserDetailFormDTO.java new file mode 100644 index 0000000000..7e84993d2f --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/ExemptLoginUserDetailFormDTO.java @@ -0,0 +1,28 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2022/9/14 14:52 + * @DESC + */ +@Data +public class ExemptLoginUserDetailFormDTO implements Serializable { + + private static final long serialVersionUID = -4333806195203619201L; + + public interface ExemptLoginUserDetailForm{} + + @NotBlank(message = "code不能为空",groups = ExemptLoginUserDetailForm.class) + private String code; + + @NotBlank(message = "corpId不能为空",groups = ExemptLoginUserDetailForm.class) + private String corpId; + + @NotBlank(message = "miniAppId不能为空",groups = ExemptLoginUserDetailForm.class) + private String miniAppId; +} diff --git a/epmet-module/epmet-third/epmet-third-server/pom.xml b/epmet-module/epmet-third/epmet-third-server/pom.xml index e991b981f3..a70d2ac789 100644 --- a/epmet-module/epmet-third/epmet-third-server/pom.xml +++ b/epmet-module/epmet-third/epmet-third-server/pom.xml @@ -157,7 +157,16 @@ rocketmq-acl 4.9.2 - + + dingtalk-spring-boot-starter + com.taobao + 1.0.0 + + + commons-codec + commons-codec + 1.15 + @@ -229,7 +238,7 @@ SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd - + diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/EpmetThirdApplication.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/EpmetThirdApplication.java index 3efd642c87..21c518e033 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/EpmetThirdApplication.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/EpmetThirdApplication.java @@ -1,6 +1,7 @@ package com.epmet; import com.epmet.mq.properties.RocketMQProperties; +import com.taobao.dingtalk.spring.annotations.EnableDingTalk; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -8,6 +9,7 @@ import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; +@EnableDingTalk @EnableConfigurationProperties(RocketMQProperties.class) @SpringBootApplication @EnableDiscoveryClient diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/DingMiniInfoController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/DingMiniInfoController.java new file mode 100644 index 0000000000..ada1f1d0ff --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/DingMiniInfoController.java @@ -0,0 +1,71 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.aop.NoRepeatSubmit; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.dto.DingMiniInfoDTO; +import com.epmet.service.DingMiniInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + + +/** + * 钉钉小程序信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-09-14 + */ +@RestController +@RequestMapping("dingMiniInfo") +public class DingMiniInfoController { + + @Autowired + private DingMiniInfoService dingMiniInfoService; + + @RequestMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = dingMiniInfoService.page(params); + return new Result>().ok(page); + } + + @RequestMapping(value = "{id}",method = {RequestMethod.POST,RequestMethod.GET}) + public Result get(@PathVariable("id") String id){ + DingMiniInfoDTO data = dingMiniInfoService.get(id); + return new Result().ok(data); + } + + @NoRepeatSubmit + @PostMapping("save") + public Result save(@RequestBody DingMiniInfoDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + dingMiniInfoService.save(dto); + return new Result(); + } + + @NoRepeatSubmit + @PostMapping("update") + public Result update(@RequestBody DingMiniInfoDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + dingMiniInfoService.update(dto); + return new Result(); + } + + @PostMapping("delete") + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + dingMiniInfoService.delete(ids); + return new Result(); + } + + +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/dingtalk/CallbackController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/dingtalk/CallbackController.java new file mode 100644 index 0000000000..8164c4cdbe --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/dingtalk/CallbackController.java @@ -0,0 +1,155 @@ +package com.epmet.controller.dingtalk; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.aliyun.dingtalk.util.DingCallbackCrypto; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.dto.form.DingMiniInfoFormDTO; +import com.epmet.commons.tools.redis.common.bean.DingMiniInfoCache; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dao.OpenSyncBizDataDao; +import com.epmet.dto.DingMiniInfoDTO; +import com.epmet.dto.form.ExemptLoginUserDetailFormDTO; +import com.epmet.entity.OpenSyncBizDataEntity; +import com.epmet.redis.DingDingCallbackRedis; +import com.epmet.service.DingTalkService; +import com.epmet.service.OpenSyncBizDataService; +import org.apache.commons.collections4.CollectionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * ISV 小程序回调信息处理 + */ +@RestController +@RequestMapping("/dingTalk") +public class CallbackController { + + private final Logger log = LoggerFactory.getLogger(getClass()); + + /** + * 创建应用,验证回调URL创建有效事件(第一次保存回调URL之前) + */ + private static final String EVENT_CHECK_CREATE_SUITE_URL = "check_create_suite_url"; + + /** + * 创建应用,验证回调URL变更有效事件(第一次保存回调URL之后) + */ + private static final String EVENT_CHECK_UPADTE_SUITE_URL = "check_update_suite_url"; + + /** + * suite_ticket推送事件 + */ + private static final String EVENT_SUITE_TICKET = "suite_ticket"; + + /** + * 企业授权开通应用事件 + */ + private static final String EVENT_TMP_AUTH_CODE = "tmp_auth_code"; + + private static final String EVENT_SYNC_HTTP_PUSH_HIGH = "SYNC_HTTP_PUSH_HIGH"; + + @Autowired + private OpenSyncBizDataService openSyncBizDataService; + @Autowired + private OpenSyncBizDataDao openSyncBizDataDao; + @Autowired + private DingDingCallbackRedis dingCallbackRedis; + @Autowired + private DingTalkService dingTalkService; + + @PostMapping(value = "dingCallback") + public Object dingCallback( + @RequestParam(value = "signature") String signature, + @RequestParam(value = "timestamp") Long timestamp, + @RequestParam(value = "nonce") String nonce, + @RequestParam(value = "suiteKey") String suiteKey, + @RequestBody(required = false) JSONObject body + ) { + String params = "signature:" + signature + " timestamp:" + timestamp + " nonce:" + nonce + " body:" + body + "suiteKey::"+suiteKey; + try { + log.info("begin callback:" + params); + DingMiniInfoDTO dingMiniInfo = openSyncBizDataDao.getDingMiniInfo(suiteKey); + DingCallbackCrypto dingTalkEncryptor = new DingCallbackCrypto(dingMiniInfo.getToken(), dingMiniInfo.getAesKey(), suiteKey); + + // 从post请求的body中获取回调信息的加密数据进行解密处理 + String encrypt = body.getString("encrypt"); + String plainText = dingTalkEncryptor.getDecryptMsg(signature, timestamp.toString(), nonce, encrypt); + JSONObject callBackContent = JSON.parseObject(plainText); + + log.info("推来的消息体:"+plainText); + + // 根据回调事件类型做不同的业务处理 + String eventType = callBackContent.getString("EventType"); + if (EVENT_CHECK_CREATE_SUITE_URL.equals(eventType)) { + log.info("验证新创建的回调URL有效性: " + plainText); + } else if (EVENT_CHECK_UPADTE_SUITE_URL.equals(eventType)) { + log.info("验证更新回调URL有效性: " + plainText); + } else if (EVENT_SUITE_TICKET.equals(eventType)) { + // suite_ticket用于用签名形式生成accessToken(访问钉钉服务端的凭证),需要保存到应用的db。 + // 钉钉会定期向本callback url推送suite_ticket新值用以提升安全性。 + // 应用在获取到新的时值时,保存db成功后,返回给钉钉success加密串(如本demo的return) + log.info("应用suite_ticket数据推送: " + plainText); + } else if (EVENT_TMP_AUTH_CODE.equals(eventType)) { + // 本事件应用应该异步进行授权开通企业的初始化,目的是尽最大努力快速返回给钉钉服务端。用以提升企业管理员开通应用体验 + // 即使本接口没有收到数据或者收到事件后处理初始化失败都可以后续再用户试用应用时从前端获取到corpId并拉取授权企业信息,进而初始化开通及企业。 + log.info("企业授权开通应用事件: " + plainText); + } else if (EVENT_SYNC_HTTP_PUSH_HIGH.equals(eventType)){ + List> bizData = (List>) callBackContent.get("bizData"); + if (CollectionUtils.isNotEmpty(bizData)){ + List list = new ArrayList<>(); + bizData.forEach(b -> { + OpenSyncBizDataEntity e = new OpenSyncBizDataEntity(); + e.setSuiteKey(suiteKey); + e.setSubscribeId(b.get("subscribe_id").toString()); + e.setCorpId(b.get("corp_id").toString()); + e.setBizId(b.get("biz_id").toString()); + e.setBizData(b.get("biz_data").toString()); + e.setBizType(b.get("biz_type").toString()); + list.add(e); + openSyncBizDataService.delete(e); + if (e.getBizType().equals(NumConstant.TWO_STR)){ + Map ticketMap = JSON.parseObject(e.getBizData(), Map.class); + dingCallbackRedis.set(suiteKey,ticketMap.get("suiteTicket")); + } + }); + openSyncBizDataService.insertBatch(list); + } + } else{ + // 其他类型事件处理 + } + + // 返回success的加密信息表示回调处理成功 + return dingTalkEncryptor.getEncryptedMap("success", timestamp, nonce); + } catch (Exception e) { + //失败的情况,应用的开发者应该通过告警感知,并干预修复 + log.error("process callback fail." + params, e); + return "fail"; + } + } + + @PostMapping("getExemptLoginUserDetail") + public Result getExemptLoginUserDetail(@RequestBody ExemptLoginUserDetailFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO, ExemptLoginUserDetailFormDTO.ExemptLoginUserDetailForm.class); + return new Result().ok(dingTalkService.getExemptLoginUserDetail(formDTO)); + } + + /** + * Desc: 获取钉钉小程序信息 + * @param formDTO + * @author zxc + * @date 2022/9/15 10:46 + */ + @PostMapping("getDingMiniInfo") + public Result getDingMiniInfo(@RequestBody DingMiniInfoFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO, DingMiniInfoFormDTO.DingMiniInfoForm.class); + return new Result().ok(dingTalkService.getDingMiniInfo(formDTO)); + } +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/DingMiniInfoDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/DingMiniInfoDao.java new file mode 100644 index 0000000000..3e3d84793b --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/DingMiniInfoDao.java @@ -0,0 +1,16 @@ +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.DingMiniInfoEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 钉钉小程序信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-09-14 + */ +@Mapper +public interface DingMiniInfoDao extends BaseDao { + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/OpenSyncBizDataDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/OpenSyncBizDataDao.java new file mode 100644 index 0000000000..4737dabf93 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/OpenSyncBizDataDao.java @@ -0,0 +1,29 @@ +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.DingMiniInfoDTO; +import com.epmet.dto.OpenSyncBizDataDTO; +import com.epmet.entity.OpenSyncBizDataEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-09-14 + */ +@Mapper +public interface OpenSyncBizDataDao extends BaseDao { + + DingMiniInfoDTO getDingMiniInfo(@Param("suiteKey")String suiteKey); + + DingMiniInfoDTO getDingMiniInfoByAppId(@Param("miniAppId")String miniAppId); + + Integer delOpenSyncData(OpenSyncBizDataEntity e); + + List getOpenSyncData(@Param("suiteKey")String suiteKey, @Param("bizType")String bizType,@Param("corpId")String corpId); + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/DingMiniInfoEntity.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/DingMiniInfoEntity.java new file mode 100644 index 0000000000..e2be67a8a4 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/DingMiniInfoEntity.java @@ -0,0 +1,55 @@ +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 钉钉小程序信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-09-14 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("ding_mini_info") +public class DingMiniInfoEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * + */ + private String suiteId; + + /** + * + */ + private String appId; + + /** + * + */ + private String miniAppId; + + /** + * + */ + private String suiteName; + + /** + * + */ + private String suiteKey; + + /** + * + */ + private String suiteSecret; + + private String token; + + private String aesKey; + +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/OpenSyncBizDataEntity.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/OpenSyncBizDataEntity.java new file mode 100644 index 0000000000..b881b457bb --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/OpenSyncBizDataEntity.java @@ -0,0 +1,70 @@ +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-09-14 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("open_sync_biz_data") +public class OpenSyncBizDataEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 第三方企业应用的suiteid加下划线0 + */ + private String subscribeId; + + private String suiteKey; + + /** + * 第三方企业应用的corpid + */ + private String corpId; + + /** + * 第三方企业应用的suiteid + */ + private String bizId; + + /** + * 数据为Json格式 + */ + private String bizData; + + /** + * 2:第三方企业应用票据; +4:企业授权变更,包含授权、解除授权、授权变更; +7:第三方企业应用变更,包含停用、启用、删除(删除保留授权); +13:企业用户变更,包含用户添加、修改、删除; +14:企业部门变更,包含部门添加、修改、删除; +15:企业角色变更,包含角色添加、修改、删除; +16:企业变更,包含企业修改、删除; +17:市场订单; +20:企业外部联系人变更,包含添加、修改、删除; +22:ISV自定义审批; +25:家校通讯录1.0(Deprecated)信息变更。家校通讯录升级,请查看家校通讯录2.0数据推送; +32:智能硬件绑定类型; +37:因订单到期或者用户退款等导致的服务关闭,目前仅推送因退款等导致的服务关闭; +50:家校通讯录2.0,部门信息变更; +51:家校通讯录2.0,人员信息变更; +63:应用试用记录回调信息; +66:工作台组件变更回调事件; +67:钉钉假期相关回调事件; +133:CRM客户动态相关数据回调事件; +137:人事平台员工异动V2相关数据回调事件; +139:异步转译通讯录id任务完成通知; +165:人事平台员工档案变动事件相关数据的回调事件; +175:人事解决方案变更事件; + */ + private String bizType; + +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/DingDingCallbackRedis.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/DingDingCallbackRedis.java new file mode 100644 index 0000000000..c6b02998f9 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/DingDingCallbackRedis.java @@ -0,0 +1,46 @@ +package com.epmet.redis; + +import com.alibaba.fastjson.JSON; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.redis.RedisKeys; +import com.epmet.commons.tools.redis.RedisUtils; +import com.epmet.dao.OpenSyncBizDataDao; +import com.epmet.dto.OpenSyncBizDataDTO; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.Map; + +/** + * @Author zxc + * @DateTime 2022/9/14 10:32 + * @DESC + */ +@Component +public class DingDingCallbackRedis { + @Autowired + private RedisUtils redisUtils; + @Autowired + private OpenSyncBizDataDao openSyncBizDataDao; + + public void set(String suiteKey,String suiteTicket){ + String key = RedisKeys.getSuiteTicketKey(suiteKey); + redisUtils.set(key,suiteTicket,-1); + } + + public String get(String suiteKey){ + String ticket = redisUtils.getString(RedisKeys.getSuiteTicketKey(suiteKey)); + if (StringUtils.isNotBlank(ticket)){ + return ticket; + } + List openSyncData = openSyncBizDataDao.getOpenSyncData(suiteKey, NumConstant.TWO_STR, null); + if (null == openSyncData){ + throw new EpmetException("未查询到"+suiteKey+"的ticket"); + } + Map map = JSON.parseObject(openSyncData.get(NumConstant.ZERO).getBizData(), Map.class); + return map.get("suiteTicket").toString(); + } +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/DingMiniInfoService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/DingMiniInfoService.java new file mode 100644 index 0000000000..a57b3b3cfa --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/DingMiniInfoService.java @@ -0,0 +1,78 @@ +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.DingMiniInfoDTO; +import com.epmet.entity.DingMiniInfoEntity; + +import java.util.List; +import java.util.Map; + +/** + * 钉钉小程序信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-09-14 + */ +public interface DingMiniInfoService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2022-09-14 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2022-09-14 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return DingMiniInfoDTO + * @author generator + * @date 2022-09-14 + */ + DingMiniInfoDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2022-09-14 + */ + void save(DingMiniInfoDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2022-09-14 + */ + void update(DingMiniInfoDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2022-09-14 + */ + void delete(String[] ids); +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/DingTalkService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/DingTalkService.java new file mode 100644 index 0000000000..ca0ba390f8 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/DingTalkService.java @@ -0,0 +1,24 @@ +package com.epmet.service; + +import com.epmet.commons.tools.dto.form.DingMiniInfoFormDTO; +import com.epmet.commons.tools.redis.common.bean.DingMiniInfoCache; +import com.epmet.dto.form.ExemptLoginUserDetailFormDTO; + +/** + * @Author zxc + * @DateTime 2022/9/14 14:56 + * @DESC + */ +public interface DingTalkService { + + Object getExemptLoginUserDetail(ExemptLoginUserDetailFormDTO formDTO); + + /** + * Desc: 获取钉钉小程序信息 + * @param formDTO + * @author zxc + * @date 2022/9/15 10:46 + */ + DingMiniInfoCache getDingMiniInfo(DingMiniInfoFormDTO formDTO); + +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/OpenSyncBizDataService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/OpenSyncBizDataService.java new file mode 100644 index 0000000000..64f3668e38 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/OpenSyncBizDataService.java @@ -0,0 +1,80 @@ +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.OpenSyncBizDataDTO; +import com.epmet.entity.OpenSyncBizDataEntity; + +import java.util.List; +import java.util.Map; + +/** + * + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-09-14 + */ +public interface OpenSyncBizDataService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2022-09-14 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2022-09-14 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return OpenSyncBizDataDTO + * @author generator + * @date 2022-09-14 + */ + OpenSyncBizDataDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2022-09-14 + */ + void save(OpenSyncBizDataDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2022-09-14 + */ + void update(OpenSyncBizDataDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2022-09-14 + */ + void delete(String[] ids); + + void delete(OpenSyncBizDataEntity condition); +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/DingMiniInfoServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/DingMiniInfoServiceImpl.java new file mode 100644 index 0000000000..7e8579d139 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/DingMiniInfoServiceImpl.java @@ -0,0 +1,82 @@ +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.dao.DingMiniInfoDao; +import com.epmet.dto.DingMiniInfoDTO; +import com.epmet.entity.DingMiniInfoEntity; +import com.epmet.service.DingMiniInfoService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 钉钉小程序信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-09-14 + */ +@Service +public class DingMiniInfoServiceImpl extends BaseServiceImpl implements DingMiniInfoService { + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, DingMiniInfoDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, DingMiniInfoDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public DingMiniInfoDTO get(String id) { + DingMiniInfoEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, DingMiniInfoDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(DingMiniInfoDTO dto) { + DingMiniInfoEntity entity = ConvertUtils.sourceToTarget(dto, DingMiniInfoEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(DingMiniInfoDTO dto) { + DingMiniInfoEntity entity = ConvertUtils.sourceToTarget(dto, DingMiniInfoEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/DingTalkServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/DingTalkServiceImpl.java new file mode 100644 index 0000000000..ec239a3ee9 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/DingTalkServiceImpl.java @@ -0,0 +1,68 @@ +package com.epmet.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import com.aliyun.dingtalk.module.DingTalkResult; +import com.epmet.commons.tools.dto.form.DingMiniInfoFormDTO; +import com.epmet.commons.tools.redis.RedisKeys; +import com.epmet.commons.tools.redis.RedisUtils; +import com.epmet.commons.tools.redis.common.bean.DingMiniInfoCache; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.dao.OpenSyncBizDataDao; +import com.epmet.dto.DingMiniInfoDTO; +import com.epmet.dto.form.ExemptLoginUserDetailFormDTO; +import com.epmet.redis.DingDingCallbackRedis; +import com.epmet.service.DingTalkService; +import com.taobao.dingtalk.client.DingTalkClientToken; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.Map; + +/** + * @Author zxc + * @DateTime 2022/9/14 14:57 + * @DESC + */ +@Service +@Slf4j +public class DingTalkServiceImpl implements DingTalkService { + + @Autowired + private DingTalkClientToken dingTalkClientToken; + @Autowired + private OpenSyncBizDataDao openSyncBizDataDao; + @Autowired + private DingDingCallbackRedis dingCallbackRedis; + @Autowired + private RedisUtils redisUtils; + + @Override + public Object getExemptLoginUserDetail(ExemptLoginUserDetailFormDTO formDTO) { + DingMiniInfoDTO dingMiniInfo = openSyncBizDataDao.getDingMiniInfoByAppId(formDTO.getMiniAppId()); + DingTalkResult exemptLoginUserDetail = dingTalkClientToken.getExemptLoginUserDetail(formDTO.getCorpId(), dingMiniInfo.getSuiteKey(), dingMiniInfo.getSuiteSecret(), dingCallbackRedis.get(dingMiniInfo.getSuiteKey()), formDTO.getCode()); + return exemptLoginUserDetail.getData(); + } + + /** + * Desc: 获取钉钉小程序信息 + * @param formDTO + * @author zxc + * @date 2022/9/15 10:46 + */ + @Override + public DingMiniInfoCache getDingMiniInfo(DingMiniInfoFormDTO formDTO) { + String key = RedisKeys.getDingMiniInfoKey(formDTO.getMiniAppId()); + Map dingMiniInfoMap = redisUtils.hGetAll(key); + if (!CollectionUtils.isEmpty(dingMiniInfoMap)) { + return ConvertUtils.mapToEntity(dingMiniInfoMap,DingMiniInfoCache.class); + } + DingMiniInfoDTO dingMiniInfo = openSyncBizDataDao.getDingMiniInfoByAppId(formDTO.getMiniAppId()); + if (null != dingMiniInfo){ + redisUtils.hMSet(key, BeanUtil.beanToMap(dingMiniInfo)); + return ConvertUtils.sourceToTarget(dingMiniInfo,DingMiniInfoCache.class); + } + return null; + } +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/OpenSyncBizDataServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/OpenSyncBizDataServiceImpl.java new file mode 100644 index 0000000000..85d508cbe4 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/OpenSyncBizDataServiceImpl.java @@ -0,0 +1,88 @@ +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.dao.OpenSyncBizDataDao; +import com.epmet.dto.OpenSyncBizDataDTO; +import com.epmet.entity.OpenSyncBizDataEntity; +import com.epmet.service.OpenSyncBizDataService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-09-14 + */ +@Service +public class OpenSyncBizDataServiceImpl extends BaseServiceImpl implements OpenSyncBizDataService { + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, OpenSyncBizDataDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, OpenSyncBizDataDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public OpenSyncBizDataDTO get(String id) { + OpenSyncBizDataEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, OpenSyncBizDataDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(OpenSyncBizDataDTO dto) { + OpenSyncBizDataEntity entity = ConvertUtils.sourceToTarget(dto, OpenSyncBizDataEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(OpenSyncBizDataDTO dto) { + OpenSyncBizDataEntity entity = ConvertUtils.sourceToTarget(dto, OpenSyncBizDataEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(OpenSyncBizDataEntity condition) { + baseDao.delOpenSyncData(condition); + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/bootstrap.yml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/bootstrap.yml index 67cbb2570e..225c468573 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/bootstrap.yml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/bootstrap.yml @@ -146,6 +146,9 @@ third: - https://epmet-ext10.elinkservice.cn dingTalk: + appKey: dingo53zvltapzrstzbo + appsecret: o1hjFvWKwLG1GIuivX0nbynqFvFDZiI3CoqLyhdZXhghXMEsr34LKCud0Rz2Hd16 + agentid: 1880131092 robot: webHook: @dingTalk.robot.webHook@ secret: @dingTalk.robot.secret@ diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/db/migration/V0.0.14__add_ding_table.sql b/epmet-module/epmet-third/epmet-third-server/src/main/resources/db/migration/V0.0.14__add_ding_table.sql new file mode 100644 index 0000000000..8187e01d08 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/db/migration/V0.0.14__add_ding_table.sql @@ -0,0 +1,51 @@ +CREATE TABLE `ding_mini_info` ( + `ID` varchar(64) NOT NULL COMMENT 'ID', + `SUITE_ID` varchar(255) NOT NULL, + `APP_ID` varchar(255) NOT NULL, + `MINI_APP_ID` varchar(255) NOT NULL, + `SUITE_NAME` varchar(255) NOT NULL, + `SUITE_KEY` varchar(255) NOT NULL, + `SUITE_SECRET` varchar(255) NOT NULL, + `TOKEN` varchar(255) NOT NULL, + `AES_KEY` varchar(255) DEFAULT NULL, + `DEL_FLAG` int(11) NOT NULL, + `REVISION` int(11) NOT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='钉钉小程序信息'; + +INSERT INTO `epmet_third`.`ding_mini_info` (`ID`, `SUITE_ID`, `APP_ID`, `MINI_APP_ID`, `SUITE_NAME`, `SUITE_KEY`, `SUITE_SECRET`, `TOKEN`, `AES_KEY`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('1', '1903117866', '119453', '5000000003010492', '随时讲', 'suiter5nqmiwzwq4lodee', 'hHKnno_nGouRjB5LVFn0k11O20CCEhf9gaiErLNN0lKUExe5VzZrB8tN9hdRrhPA', '', '', 0, 0, '授权给亿联科技', '2022-09-14 11:11:13', '授权给亿联科技', '2022-09-14 11:11:13'); +INSERT INTO `epmet_third`.`ding_mini_info` (`ID`, `SUITE_ID`, `APP_ID`, `MINI_APP_ID`, `SUITE_NAME`, `SUITE_KEY`, `SUITE_SECRET`, `TOKEN`, `AES_KEY`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('1001', '1905492491', '', '5000000003022462', '随手拍', 'dingu6fdnlcqbyr1fdxu', 'r-Fi8awDyD5rBCPS1NnoBEqkrq0InheNMkc0xAOKvkD0-47oDFiClbJRiFQy-JO1', '', NULL, 0, 0, '烟台企业内部应用', '2022-09-22 16:54:09', '烟台企业内部应用', '2022-09-22 16:54:16'); +INSERT INTO `epmet_third`.`ding_mini_info` (`ID`, `SUITE_ID`, `APP_ID`, `MINI_APP_ID`, `SUITE_NAME`, `SUITE_KEY`, `SUITE_SECRET`, `TOKEN`, `AES_KEY`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('1002', '1905441943', '', '5000000003021766', '随时讲', 'dinguizzwnfnvjs6nntz', 'uUqJYGyoOjOBcc1bC5jCD2lipOaUxbrdZyeXSWKq1JfX7tWQYNz6ZfvvybWBENKS', '', NULL, 0, 0, '烟台企业内部应用', '2022-09-22 16:55:25', '烟台企业内部应用', '2022-09-22 16:55:28'); +INSERT INTO `epmet_third`.`ding_mini_info` (`ID`, `SUITE_ID`, `APP_ID`, `MINI_APP_ID`, `SUITE_NAME`, `SUITE_KEY`, `SUITE_SECRET`, `TOKEN`, `AES_KEY`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('1003', '1905455843', '', '5000000003022737', '我的报事', 'dingllzzs6g8u7htteg5', 'fjTJe31Ot4FylmO_hWY-aRckikdPKA2u640GjiW68R4JItFG8picnwFd8d9gLFm_', '', NULL, 0, 0, '烟台企业内部应用', '2022-09-22 16:56:29', '烟台企业内部应用', '2022-09-22 16:56:37'); +INSERT INTO `epmet_third`.`ding_mini_info` (`ID`, `SUITE_ID`, `APP_ID`, `MINI_APP_ID`, `SUITE_NAME`, `SUITE_KEY`, `SUITE_SECRET`, `TOKEN`, `AES_KEY`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('1004', '1905486539', '', '5000000003022522', '实时动态', 'dingf8hpd485mlgaov7c', 'CmUSLH-M-tDgpwRTmiAXf9p3v-hLZ27J1kscxUg3118EKX4mV-JLJ073PMxC6We1', '', NULL, 0, 0, '烟台企业内部应用', '2022-09-22 16:57:21', '烟台企业内部应用', '2022-09-22 16:57:24'); +INSERT INTO `epmet_third`.`ding_mini_info` (`ID`, `SUITE_ID`, `APP_ID`, `MINI_APP_ID`, `SUITE_NAME`, `SUITE_KEY`, `SUITE_SECRET`, `TOKEN`, `AES_KEY`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('2', '1903003033', '', '5000000003009021', '随手拍', 'suite44k7hacfbfx4zazi', 'EtamucmdHdQMe5nM7YW0qwn2b3m6UJXEk3JAr3ICoisZdZdcIBXsFI1uUHf9xUrl', '', '', 0, 0, '授权给亿联科技', '2022-09-14 11:11:13', '授权给亿联科技', '2022-09-14 11:11:13'); +INSERT INTO `epmet_third`.`ding_mini_info` (`ID`, `SUITE_ID`, `APP_ID`, `MINI_APP_ID`, `SUITE_NAME`, `SUITE_KEY`, `SUITE_SECRET`, `TOKEN`, `AES_KEY`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('27805834197073948', '27501006', '119450', '5000000002934668', '随手拍', 'suitew6ccvkquinmrghqy', 'TooAxiegdsE5BPP6xo1AxK1LdmaUoMpPMyomOcGcBSXtnsxRc8dEfyOlG56oSmEB', 'qN6Mg1XljdeHzVg2KeZGmBgY5', 'CzBxlN3uVCo6S3AzB8gfkUMBQxYsrRUdXRqX4XcYcyw', 0, 0, '亿联第三方企业应用', '2022-09-14 11:09:15', '亿联第三方企业应用', '2022-09-14 11:09:15'); +INSERT INTO `epmet_third`.`ding_mini_info` (`ID`, `SUITE_ID`, `APP_ID`, `MINI_APP_ID`, `SUITE_NAME`, `SUITE_KEY`, `SUITE_SECRET`, `TOKEN`, `AES_KEY`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('27805834197073949', '27501007', '119451', '5000000002934374', '随时讲', 'suitezhyj12glsrp8em0f', '-z5Q_lvMP6l7fTzlArEzUT8D_-5pvqBQaJMuTGHoXnz0nuiqGQMZ8aeya_cxTsN-', 'rKs2lIN1Oe6K34AtASGOQDh', 'a7hsIIHVTiIB7SQwOiGNgxVo7zAigGUk4InTUNIikWy', 0, 0, '亿联第三方企业应用', '2022-09-14 11:11:13', '亿联第三方企业应用', '2022-09-14 11:11:13'); +INSERT INTO `epmet_third`.`ding_mini_info` (`ID`, `SUITE_ID`, `APP_ID`, `MINI_APP_ID`, `SUITE_NAME`, `SUITE_KEY`, `SUITE_SECRET`, `TOKEN`, `AES_KEY`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('27805834197073950', '27501008', '119452', '5000000002934456', '我的报事', 'suite5yxliro6wawv514w', 'aQxiPi7DwJSUa9HlbUU_L7Q4wGCLEDmgf__Ffx75cTn3jZwuHy9vdl-9Iv5FeyJU', 'vTUvaf6QtOJZsa1h7Wkoteo', 'csRpvVFGL7Cf1N9ubajix8tDWhCllROhaxCHKFnbuAz', 0, 0, '亿联第三方企业应用', '2022-09-14 11:11:13', '亿联第三方企业应用', '2022-09-14 11:11:13'); +INSERT INTO `epmet_third`.`ding_mini_info` (`ID`, `SUITE_ID`, `APP_ID`, `MINI_APP_ID`, `SUITE_NAME`, `SUITE_KEY`, `SUITE_SECRET`, `TOKEN`, `AES_KEY`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('27805834197073951', '27501009', '119453', '5000000002934488', '实时动态', 'suitemcestnonr6y0xigc', 'kKCNCkfDhmLoVnl_wuAiScyDG4776mkTevuSBuiYhHg-Bvz1-vhb_4IA-Km7nK2I', 'MvWLkZGbC', 'iSVLw69AeNXS8jgGefTG2ulkKWDQjcSsMBgkFMgfPuB', 0, 0, '亿联第三方企业应用', '2022-09-14 11:11:13', '亿联第三方企业应用', '2022-09-14 11:11:13'); +INSERT INTO `epmet_third`.`ding_mini_info` (`ID`, `SUITE_ID`, `APP_ID`, `MINI_APP_ID`, `SUITE_NAME`, `SUITE_KEY`, `SUITE_SECRET`, `TOKEN`, `AES_KEY`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('3', '1903155647', '', '5000000003010470', '我的报事', 'suitedwccu2wbepxvdebi', 'OHbAMPBzPWnTL-VqPuJ4ngnwBGLVoxKkkl12uY1CPvIhfX0NqcNJMGl21gQqNpd2', '', '', 0, 0, '授权给亿联科技', '2022-09-14 11:11:13', '授权给亿联科技', '2022-09-14 11:11:13'); +INSERT INTO `epmet_third`.`ding_mini_info` (`ID`, `SUITE_ID`, `APP_ID`, `MINI_APP_ID`, `SUITE_NAME`, `SUITE_KEY`, `SUITE_SECRET`, `TOKEN`, `AES_KEY`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('4', '1903147702', '', '5000000003010661', '实时动态', 'suitekcbekxzjnlrlgft2', 'fMKaF1UsORAftH7LdqR-CpHOCLzA56Q8S5WN6fRAOAI7E7T-p-96SspOyc-8CdnO', '', '', 0, 0, '授权给亿联科技', '2022-09-14 11:11:13', '授权给亿联科技', '2022-09-14 11:11:13'); + + +CREATE TABLE `open_sync_biz_data` +( + `ID` varchar(64) NOT NULL, + `SUITE_KEY` varchar(255) DEFAULT NULL, + `SUBSCRIBE_ID` varchar(255) NOT NULL COMMENT '第三方企业应用的suiteid加下划线0', + `CORP_ID` varchar(255) NOT NULL COMMENT '第三方企业应用的corpid', + `BIZ_ID` varchar(255) NOT NULL COMMENT '第三方企业应用的suiteid', + `BIZ_DATA` json NOT NULL COMMENT '数据为Json格式', + `BIZ_TYPE` varchar(10) NOT NULL COMMENT '2:第三方企业应用票据;\n4:企业授权变更,包含授权、解除授权、授权变更;\n7:第三方企业应用变更,包含停用、启用、删除(删除保留授权);\n13:企业用户变更,包含用户添加、修改、删除;\n14:企业部门变更,包含部门添加、修改、删除;\n15:企业角色变更,包含角色添加、修改、删除;\n16:企业变更,包含企业修改、删除;\n17:市场订单;\n20:企业外部联系人变更,包含添加、修改、删除;\n22:ISV自定义审批;\n25:家校通讯录1.0(Deprecated)信息变更。家校通讯录升级,请查看家校通讯录2.0数据推送;\n32:智能硬件绑定类型;\n37:因订单到期或者用户退款等导致的服务关闭,目前仅推送因退款等导致的服务关闭;\n50:家校通讯录2.0,部门信息变更;\n51:家校通讯录2.0,人员信息变更;\n63:应用试用记录回调信息;\n66:工作台组件变更回调事件;\n67:钉钉假期相关回调事件;\n133:CRM客户动态相关数据回调事件;\n137:人事平台员工异动V2相关数据回调事件;\n139:异步转译通讯录id任务完成通知;\n165:人事平台员工档案变动事件相关数据的回调事件;\n175:人事解决方案变更事件;', + `DEL_FLAG` int(1) NOT NULL, + `REVISION` int(1) NOT NULL, + `CREATED_TIME` datetime NOT NULL, + `CREATED_BY` varchar(255) NOT NULL, + `UPDATED_TIME` datetime NOT NULL, + `UPDATED_BY` varchar(255) NOT NULL, + PRIMARY KEY (`ID`) USING BTREE +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4; diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/db/migration/V0.0.15__other3app.sql b/epmet-module/epmet-third/epmet-third-server/src/main/resources/db/migration/V0.0.15__other3app.sql new file mode 100644 index 0000000000..0904d7bff2 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/db/migration/V0.0.15__other3app.sql @@ -0,0 +1,3 @@ +INSERT INTO `epmet_third`.`ding_mini_info` (`ID`, `SUITE_ID`, `APP_ID`, `MINI_APP_ID`, `SUITE_NAME`, `SUITE_KEY`, `SUITE_SECRET`, `TOKEN`, `AES_KEY`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('1005', '1912268145', '', '5000000003054196', '信息登记', 'dingtbmsztg41nmbclzi', '6mdIbt8xWkKOkGasxqQt44uNEri-KQWSmMX1u7weTMEuoGWwQsoYSyc0hBeoQGEj', '', NULL, 0, 0, '烟台企业内部应用', '2022-09-26 14:03:32', '烟台企业内部应用', '2022-09-26 14:03:40'); +INSERT INTO `epmet_third`.`ding_mini_info` (`ID`, `SUITE_ID`, `APP_ID`, `MINI_APP_ID`, `SUITE_NAME`, `SUITE_KEY`, `SUITE_SECRET`, `TOKEN`, `AES_KEY`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('1006', '1912172899', '', '5000000003054651', '疫情防控', 'dingye4npkwn5l8gate0', 'iOqq_5nURdTr-69DKukTfpzmkJIN5UBCQNlOdB-g6PucCC2UG-wrXmyC2XEylkuE', '', NULL, 0, 0, '烟台企业内部应用', '2022-09-26 14:04:39', '烟台企业内部应用', '2022-09-26 14:04:46'); +INSERT INTO `epmet_third`.`ding_mini_info` (`ID`, `SUITE_ID`, `APP_ID`, `MINI_APP_ID`, `SUITE_NAME`, `SUITE_KEY`, `SUITE_SECRET`, `TOKEN`, `AES_KEY`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('1007', '1912176853', '', '5000000003054757', '议事厅', 'ding56hee9xi5kxlmpbp', 'Y16WoB0qD0k8N7NY2J7HLyHGGAkhlBj9Bxkpa1cFuUUrTZlH2SfLvP4ZYnsvxC7f', '', NULL, 0, 0, '烟台企业内部应用', '2022-09-26 14:05:40', '烟台企业内部应用', '2022-09-26 14:05:43'); diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/db/migration/V0.0.16__shenli4app.sql b/epmet-module/epmet-third/epmet-third-server/src/main/resources/db/migration/V0.0.16__shenli4app.sql new file mode 100644 index 0000000000..de86515689 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/db/migration/V0.0.16__shenli4app.sql @@ -0,0 +1,4 @@ +INSERT INTO `epmet_third`.`ding_mini_info` (`ID`, `SUITE_ID`, `APP_ID`, `MINI_APP_ID`, `SUITE_NAME`, `SUITE_KEY`, `SUITE_SECRET`, `TOKEN`, `AES_KEY`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('1008', '1914273833', '', '5000000003069546', '随手拍', 'dingpvk106h0eca7btlm', 'zLF8ld6pF40NLUxC2aRKP7yfXreRpSRJTCN48_kyAQtretSLBfSpFMX6prUOaH_Z', '', NULL, 0, 0, '烟台企业内部应用_慎礼社区', '2022-09-27 13:03:32', '烟台企业内部应用_慎礼社区', '2022-09-27 13:03:40'); +INSERT INTO `epmet_third`.`ding_mini_info` (`ID`, `SUITE_ID`, `APP_ID`, `MINI_APP_ID`, `SUITE_NAME`, `SUITE_KEY`, `SUITE_SECRET`, `TOKEN`, `AES_KEY`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('1009', '1914301613', '', '5000000003069487', '随时讲', 'ding1ept2iaynjxu2w6o', 'xSXSennTbJG8nc-IjjsrG1zEugNoCp2rLhT7pS0vInT7OnPZ5FgY3974aR9D-xd2', '', NULL, 0, 0, '烟台企业内部应用_慎礼社区', '2022-09-27 13:03:32', '烟台企业内部应用_慎礼社区', '2022-09-27 13:03:40'); +INSERT INTO `epmet_third`.`ding_mini_info` (`ID`, `SUITE_ID`, `APP_ID`, `MINI_APP_ID`, `SUITE_NAME`, `SUITE_KEY`, `SUITE_SECRET`, `TOKEN`, `AES_KEY`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('1010', '1914266905', '', '5000000003069391', '我的报事', 'dingpzsyljcsbu3fbac5', 'fWRzS2W59fwx__istOF23mHq1S0hAs64nZhcmljrSLLMYrceZVsz7GhgG4izZvhy', '', NULL, 0, 0, '烟台企业内部应用_慎礼社区', '2022-09-27 13:03:32', '烟台企业内部应用_慎礼社区', '2022-09-27 13:03:40'); +INSERT INTO `epmet_third`.`ding_mini_info` (`ID`, `SUITE_ID`, `APP_ID`, `MINI_APP_ID`, `SUITE_NAME`, `SUITE_KEY`, `SUITE_SECRET`, `TOKEN`, `AES_KEY`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('1011', '1914338340', '', '5000000003069669', '实时动态', 'dingflbhlrd1epy11irl', '47OE8jNuSj-JoOPBx7ZCqEii4fycnWtY2x97ndu3Mk2BOh9ElKMNuOGNU0zzshVn', '', NULL, 0, 0, '烟台企业内部应用_慎礼社区', '2022-09-27 13:03:32', '烟台企业内部应用_慎礼社区', '2022-09-27 13:03:40'); diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/logback-spring.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/logback-spring.xml index 31d6de459d..c95ac8b0f3 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/logback-spring.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/logback-spring.xml @@ -145,6 +145,7 @@ + @@ -158,6 +159,7 @@ + diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/DingMiniInfoDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/DingMiniInfoDao.xml new file mode 100644 index 0000000000..e812ece013 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/DingMiniInfoDao.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/OpenSyncBizDataDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/OpenSyncBizDataDao.xml new file mode 100644 index 0000000000..d6bec2cfa5 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/OpenSyncBizDataDao.xml @@ -0,0 +1,30 @@ + + + + + + DELETE + FROM open_sync_biz_data + WHERE biz_id = #{bizId} + AND biz_type = #{bizType} + AND subscribe_id = #{subscribeId} + AND corp_id = #{corpId} + AND DEL_FLAG = 0 + + + + + + diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/test/java/com/epmet/ThirdPlatformTest.java b/epmet-module/epmet-third/epmet-third-server/src/main/test/java/com/epmet/ThirdPlatformTest.java new file mode 100644 index 0000000000..bd5671a8cf --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/test/java/com/epmet/ThirdPlatformTest.java @@ -0,0 +1,28 @@ +package com.epmet; + +import com.taobao.dingtalk.client.DingTalkClientToken; +import lombok.extern.slf4j.Slf4j; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +/** + * desc:redisson测试类 + */ +@Slf4j +@RunWith(value = SpringRunner.class) +@SpringBootTest(classes = {EpmetThirdApplication.class}) +public class ThirdPlatformTest { + + + @Autowired + DingTalkClientToken dingTalkClientToken; + + @Test + public void sendText(){ + /* DingTalkResult appAccessTokenToken = dingTalkClientToken.getAppAccessTokenToken(); + System.out.println("=======:"+JSON.toJSONString(appAccessTokenToken));*/ + } +} diff --git a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/GovMenuDTO.java b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/GovMenuDTO.java index 91ef00b75a..d5ca9f7008 100644 --- a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/GovMenuDTO.java +++ b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/GovMenuDTO.java @@ -65,6 +65,10 @@ public class GovMenuDTO extends TreeStringNode implements Serializab * 菜单图标 */ private String icon; + /** + * 菜单颜色 + */ + private String color; /** * 权限标识,如:sys:menu:save diff --git a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/OftenUseFunctionListResultDTO.java b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/OftenUseFunctionListResultDTO.java index 73ff018a10..46698701ed 100644 --- a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/OftenUseFunctionListResultDTO.java +++ b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/OftenUseFunctionListResultDTO.java @@ -38,4 +38,9 @@ public class OftenUseFunctionListResultDTO implements Serializable { * 排序 */ private String sort; + + /** + * 菜单颜色 + */ + private String color; } diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/GovMenuEntity.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/GovMenuEntity.java index 9c1c3922ed..6eba2e36d1 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/GovMenuEntity.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/GovMenuEntity.java @@ -47,6 +47,10 @@ public class GovMenuEntity extends BaseEpmetEntity { * 菜单图标 */ private String icon; + /** + * 菜单颜色 + */ + private String color; /** * 权限标识,如:sys:menu:save */ diff --git a/epmet-module/gov-access/gov-access-server/src/main/resources/db/migration/V0.0.9__alter_menu_color.sql b/epmet-module/gov-access/gov-access-server/src/main/resources/db/migration/V0.0.9__alter_menu_color.sql new file mode 100644 index 0000000000..78036e8f34 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/resources/db/migration/V0.0.9__alter_menu_color.sql @@ -0,0 +1,2 @@ +ALTER TABLE `epmet_gov_access`.`gov_menu` + ADD COLUMN `color` varchar(16) DEFAULT '' COMMENT '菜单颜色' AFTER `icon`; diff --git a/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/IcOftenUseFunctionDao.xml b/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/IcOftenUseFunctionDao.xml index 5f25af85fc..35d01fb929 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/IcOftenUseFunctionDao.xml +++ b/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/IcOftenUseFunctionDao.xml @@ -15,7 +15,8 @@ ic.MENU_ID, gm.url, gm.icon, - gl.field_value AS menuName + gl.field_value AS menuName, + gm.color FROM ic_often_use_function ic INNER JOIN gov_customer_menu gc ON (gc.TABLE_ID = ic.MENU_ID AND gc.DEL_FLAG = '0' AND ic.CUSTOMER_ID = gc.CUSTOMER_ID) INNER JOIN gov_menu gm ON (gc.TABLE_ID = gm.id AND gm.DEL_FLAG = 0 AND gm.SHOW_FLAG = 1) @@ -24,4 +25,4 @@ AND ic.USER_ID = #{userId} ORDER BY ic.SORT - \ No newline at end of file + diff --git a/epmet-module/gov-mine/gov-mine-client/src/main/java/com/epmet/dto/form/StaffResetPassWordFormDTO.java b/epmet-module/gov-mine/gov-mine-client/src/main/java/com/epmet/dto/form/StaffResetPassWordFormDTO.java index 7fe2d7bf6c..755a12a89a 100644 --- a/epmet-module/gov-mine/gov-mine-client/src/main/java/com/epmet/dto/form/StaffResetPassWordFormDTO.java +++ b/epmet-module/gov-mine/gov-mine-client/src/main/java/com/epmet/dto/form/StaffResetPassWordFormDTO.java @@ -22,6 +22,10 @@ public class StaffResetPassWordFormDTO implements Serializable { public interface AddUserShowGroup extends CustomerClientShowGroup { } + /** + * 旧密码 + */ + private String oldPassword; @NotBlank(message = "新密码不能为空", groups = {AddUserShowGroup.class}) private String newPassword; @NotBlank(message = "确认新密码不能为空", groups = {AddUserShowGroup.class}) diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/controller/MineController.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/controller/MineController.java index cc9a8c9e94..3191db2685 100644 --- a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/controller/MineController.java +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/controller/MineController.java @@ -2,12 +2,15 @@ package com.epmet.controller; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.RSASignature; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.form.StaffResetPassWordFormDTO; import com.epmet.dto.result.MineResultDTO; import com.epmet.service.MineService; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -21,6 +24,8 @@ import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("mine") public class MineController { + @Value("${epmet.login.privateKey}") + private String privateKey; @Autowired private MineService mineService; @@ -45,9 +50,27 @@ public class MineController { * @Date 2020/7/1 9:59 **/ @PostMapping("resetpassword") - public Result resetPassword(@LoginUser TokenDto tokenDto, @RequestBody StaffResetPassWordFormDTO formDTO) { + public Result resetPassword(@LoginUser TokenDto tokenDto, @RequestBody StaffResetPassWordFormDTO formDTO) throws Exception { formDTO.setStaffId(tokenDto.getUserId()); ValidatorUtils.validateEntity(formDTO, StaffResetPassWordFormDTO.AddUserShowGroup.class, StaffResetPassWordFormDTO.AddUserInternalGroup.class); + //解密密码 + if (formDTO.getConfirmNewPassword().length() > 50) { + String confirmNewPassWord = RSASignature.decryptByPrivateKey(formDTO.getConfirmNewPassword(), privateKey); + String newPassword = RSASignature.decryptByPrivateKey(formDTO.getNewPassword(), privateKey); + formDTO.setConfirmNewPassword(confirmNewPassWord); + formDTO.setNewPassword(newPassword); + if (StringUtils.isNotBlank(formDTO.getOldPassword())){ + String oldPassWord = RSASignature.decryptByPrivateKey(formDTO.getOldPassword(), privateKey); + formDTO.setOldPassword(oldPassWord); + } + } return mineService.resetPassword(formDTO); } + + public static void main(String[] args) throws Exception { + String p= "R16c3yJqCMyRFTxElBeBexTVlW1GArItaVqEEyF3o3jXVwq0G08ck8wEdBAEyQI1y4uCsw3UBgx1mqiMbIfvdg=="; + String privateKey= "MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEAqOANodapaCq6hq1sLjPNAKCoTwLjblUg7LMlVWAfUdRgIem41ScYK/ccECXZGzOJZCpCB3XHGXQLdrkngnr2jwIDAQABAkAyYaWvgrtHuHetdk+v+QRQC54q9FGluP/5nfilX+f4IUf8j92o/ZohTtmJn9qcDiAP4wxCLIsfy4IW3psST78BAiEA0A/E0WvtI7spWnjfw+wMDhdVMIbIJvDbj/cqMwRZInUCIQDPyO2sbXpwDjmAvyn0jpGJJxU5POWYdI37rTf9fScMcwIhAMkWNHbjBHKANVuHb10ACjakPmWEHnXkW5AspdBg53TxAiARPbzq99KXBbcjxbj3f/T3inSqYTEz60f0wDTLJd1dnQIhAIFe6Jd1TduIxGk1PDh/b/3q0jNGgVXkFnUBnKWDaL9N"; + String newPassword = RSASignature.decryptByPrivateKey(p, privateKey); + System.out.println(newPassword); + } } diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/impl/MineServiceImpl.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/impl/MineServiceImpl.java index 77c8502971..44fb7f61a4 100644 --- a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/impl/MineServiceImpl.java +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/impl/MineServiceImpl.java @@ -5,6 +5,7 @@ import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.security.password.PasswordUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.StaffInfoFromDTO; import com.epmet.dto.form.StaffResetPassWordFormDTO; @@ -50,7 +51,7 @@ public class MineServiceImpl implements MineService { throw new RenException(EpmetErrorCode.PASSWORD_NOT_FIT.getCode()); } //2、校验密码规则:密码必须8-20个字符,而且同时包含大小写字母和数字 - boolean flag=this.checkPassWord(formDTO.getNewPassword()); + boolean flag= PasswordUtils.checkPassWordRule(formDTO.getNewPassword()); if(!flag){ throw new RenException(EpmetErrorCode.PASSWORD_OUT_OF_ORDER.getCode()); } @@ -59,50 +60,15 @@ public class MineServiceImpl implements MineService { staffResetPwFormDTO.setNewPassword(formDTO.getNewPassword()); staffResetPwFormDTO.setConfirmNewPassword(formDTO.getConfirmNewPassword()); staffResetPwFormDTO.setStaffId(formDTO.getStaffId()); + staffResetPwFormDTO.setOldPassword(formDTO.getOldPassword()); Result updatePassWordResult=epmetUserOpenFeignClient.resetStaffPassword(staffResetPwFormDTO); if(updatePassWordResult.success()){ logger.info(String.format("调用%s服务,修改密码成功", ServiceConstant.EPMET_USER_SERVER)); }else{ logger.warn(String.format("调用%s服务,修改密码失败,返参:%s", ServiceConstant.EPMET_USER_SERVER, JSON.toJSONString(updatePassWordResult))); - return new Result().error(EpmetErrorCode.PASSWORD_UPDATE_FAILED.getCode()); + return new Result().error(EpmetErrorCode.PASSWORD_UPDATE_FAILED.getCode(),updatePassWordResult.getMsg()); } return new Result(); } - - private boolean checkPassWord(String password) { - boolean flag=false; - if(password.length()<8||password.length()>20){ - logger.warn(String.format("密码长度应为8-20位,当前输入密码%s,长度为%s",password,password.length())); - return flag; - } - boolean numFlag=false; - boolean bigLetter=false; - boolean smallLetter=false; - char[] passwordArray = password.toCharArray(); - for(int i=0;i < passwordArray.length;i++) { - char currentStr=passwordArray[i]; - logger.info(String.format("当前字符%s",currentStr)); - // 判断ch是否是数字字符,如'1','2‘,是返回true。否则返回false - if(Character.isDigit(currentStr)){ - numFlag=true; - continue; - } - // 判断ch是否是字母字符,如'a','b‘,是返回true。否则返回false - if(Character.isUpperCase(currentStr)){ - bigLetter=true; - continue; - } - if(Character.isLowerCase(currentStr)){ - smallLetter=true; - continue; - } - } - if(numFlag&&bigLetter&&smallLetter){ - flag=true; - }else{ - logger.warn(String.format("当前密码%s,是否包含数字%s,是否包含大写字母%s,是否包含小写字母%s",password,numFlag,bigLetter,smallLetter)); - } - return flag; - } } diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/resources/bootstrap.yml b/epmet-module/gov-mine/gov-mine-server/src/main/resources/bootstrap.yml index 88eabe8772..0537c64f52 100644 --- a/epmet-module/gov-mine/gov-mine-server/src/main/resources/bootstrap.yml +++ b/epmet-module/gov-mine/gov-mine-server/src/main/resources/bootstrap.yml @@ -119,3 +119,8 @@ thread: keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ threadNamePrefix: @thread.threadPool.thread-name-prefix@ rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ +epmet: + login: + publicKey: MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKjgDaHWqWgquoatbC4zzQCgqE8C425VIOyzJVVgH1HUYCHpuNUnGCv3HBAl2RsziWQqQgd1xxl0C3a5J4J69o8CAwEAAQ== + privateKey: MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEAqOANodapaCq6hq1sLjPNAKCoTwLjblUg7LMlVWAfUdRgIem41ScYK/ccECXZGzOJZCpCB3XHGXQLdrkngnr2jwIDAQABAkAyYaWvgrtHuHetdk+v+QRQC54q9FGluP/5nfilX+f4IUf8j92o/ZohTtmJn9qcDiAP4wxCLIsfy4IW3psST78BAiEA0A/E0WvtI7spWnjfw+wMDhdVMIbIJvDbj/cqMwRZInUCIQDPyO2sbXpwDjmAvyn0jpGJJxU5POWYdI37rTf9fScMcwIhAMkWNHbjBHKANVuHb10ACjakPmWEHnXkW5AspdBg53TxAiARPbzq99KXBbcjxbj3f/T3inSqYTEz60f0wDTLJd1dnQIhAIFe6Jd1TduIxGk1PDh/b/3q0jNGgVXkFnUBnKWDaL9N + diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddStaffPyFromDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddStaffPyFromDTO.java new file mode 100644 index 0000000000..9aa774bd31 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddStaffPyFromDTO.java @@ -0,0 +1,87 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import java.io.Serializable; +import java.util.List; + +/** + * @author sun + * @dscription + */ +@NoArgsConstructor +@Data +public class AddStaffPyFromDTO implements Serializable { + private static final long serialVersionUID = 1L; + /** + * 新增人员所属类型Id + */ + private String orgId; + /** + * 客户ID + */ + private String customerId; + /** + * 新增人员所属类型【组织:agency;部门:dept;网格:grid】】 + */ + private String orgType; + /** + * 姓名 + */ + @NotBlank(message = "姓名不能为空", groups = AddStaffPyFromDTO.AddStaff.class) + @Length(max = 15, message = "姓名仅允许输入15个字符", groups = AddStaffPyFromDTO.AddStaff.class) + private String name; + /** + * 人员ID + */ + private String staffId; + /** + * 手机 + */ + @NotBlank(message = "手机号不能为空", groups = AddStaffPyFromDTO.AddStaff.class) + @Pattern(regexp = "^[1][3,4,5,6,7,8,9][0-9]{9}$", message = "请输入正确的手机号", groups = AddStaffPyFromDTO.AddStaff.class) + private String mobile; + /** + * 性别 + */ + @NotNull(message = "性别不能为空", groups = AddStaffPyFromDTO.AddStaff.class) + private Integer gender; + /** + * 专兼职 + */ + @NotBlank(message = "专兼职不能为空", groups = AddStaffPyFromDTO.AddStaff.class) + private String workType; + + /** + * 账户 + */ + @NotBlank(message = "账号不能为空", groups = AddStaffPyFromDTO.AddStaff.class) + private String userAccount; + + /** + * 密码 + */ + @NotBlank(message = "密码不能为空", groups = AddStaffPyFromDTO.AddStaff.class) + private String pwd; + + /** + * 角色id列表 + */ + @NotNull(message = "角色不能为空", groups = AddStaffPyFromDTO.AddStaff.class) + private List roles; + public interface AddStaff extends CustomerClientShowGroup {} + /** + * 来源app(政府端:gov、居民端:resi、运营端:oper) + */ + private String app; + /** + * 来源client(PC端:web、微信小程序:wxmp) + */ + private String client; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffSubmitAccountFromDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffSubmitAccountFromDTO.java new file mode 100644 index 0000000000..7e0bf7e36c --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffSubmitAccountFromDTO.java @@ -0,0 +1,82 @@ +package com.epmet.dto.form; + +import lombok.Data; +import lombok.NoArgsConstructor; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import java.io.Serializable; +import java.util.List; + +/** + * @author zhy + * @dscription + * @date 2020/4/24 10:43 + */ +@NoArgsConstructor +@Data +public class StaffSubmitAccountFromDTO implements Serializable { + private static final long serialVersionUID = 1L; + /** + * 客户ID + */ + private String customerId; + /** + * 机关ID + */ + private String agencyId; + /** + * 人员ID + */ + private String staffId; + /** + * 姓名 + */ + @NotBlank(message = "姓名不能为空") + @Length(max = 15, message = "姓名仅允许输入15个字符") + private String name; + /** + * 手机 + */ + @NotBlank(message = "手机号不能为空") + @Pattern(regexp = "^[1][3,4,5,6,7,8,9][0-9]{9}$", message = "请输入正确的手机号") + private String mobile; + /** + * 性别 + */ + @NotNull(message = "性别不能为空") + private Integer gender; + /** + * 性别 + */ + @NotNull(message = "账号不能为空") + private String userAccount; + /** + * 密码 + */ + private String pwd; + /** + * 专兼职 + */ + @NotBlank(message = "专兼职不能为空") + private String workType; + /** + * 角色id列表 + */ + @NotNull(message = "角色不能为空") + private List roles; + /** + * 来源app(政府端:gov、居民端:resi、运营端:oper) + */ + private String app; + /** + * 来源client(PC端:web、微信小程序:wxmp) + */ + private String client; + /** + * 身份证号 + */ + private String idCard; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcBulidingDetailDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcBulidingDetailDTO.java index 910044f9cb..10e8e09477 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcBulidingDetailDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcBulidingDetailDTO.java @@ -57,6 +57,10 @@ public class IcBulidingDetailDTO implements Serializable { */ private String type; + /** + * --楼栋类型,1商品房,2自建房,3别墅 + */ + private String typeName; /** * 排序 diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcNeighborHoodDetailDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcNeighborHoodDetailDTO.java new file mode 100644 index 0000000000..2ed20afbfa --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcNeighborHoodDetailDTO.java @@ -0,0 +1,111 @@ +package com.epmet.dto.result; + +import com.epmet.dto.IcPropertyManagementDTO; +import lombok.Data; + +import java.util.List; + +/** + * @Description + * @Author yzm + * @Date 2022/9/21 9:19 + */ +@Data +public class IcNeighborHoodDetailDTO { + private String id; + /** + * 客户id + */ + private String customerId; + + /** + * 小区名称 + */ + private String neighborHoodName; + + /** + * 组织id + */ + private String agencyId; + + /** + * 组织名称--新版详情页面用于显示 + */ + private String agencyName; + + /** + * 上级组织id + */ + private String parentAgencyId; + + /** + * 组织的所有上级组织id + */ + private String agencyPids; + + /** + * 网格id + */ + private String gridId; + + /** + * 详细地址 + */ + private String address; + + /** + * 备注 + */ + private String remark; + + /** + * 中心点位:经度 + */ + private String longitude; + + /** + * 中心点位:纬度 + */ + private String latitude; + + /** + * 坐标区域 + */ + private String coordinates; + + /** + * 坐标位置 + */ + private String location; + + /** + * 网格名称--新版详情页面用于显示 + */ + private String gridName; + + /** + * 物业名称--新版详情页面用于显示 + */ + private List propertyList; + + /** + * 小区编码 + */ + private String coding; + + /** + * 小区系统编码 + */ + private String sysCoding; + + /** + * 实有楼栋数 + */ + private Integer realBuilding; + + /** + * 二维码地址 + */ + private String qrcodeUrl; +} + diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffInitResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffInitResultDTO.java index c3d0f85a22..36cc283268 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffInitResultDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffInitResultDTO.java @@ -25,6 +25,10 @@ public class StaffInitResultDTO implements Serializable { * 手机号 */ private String mobile; + /** + * 手机号 + */ + private String userAccount; /** * 性别 */ @@ -33,6 +37,10 @@ public class StaffInitResultDTO implements Serializable { * 专兼职 */ private String workType; + /** + * 身份证号 + */ + private String idCard; /** * 职责列表 */ diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseInformationController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseInformationController.java index 21ca6fb933..21cddd9951 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseInformationController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseInformationController.java @@ -23,7 +23,6 @@ import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.HouseInformationFormDTO; import com.epmet.dto.result.*; -import com.epmet.entity.IcNeighborHoodEntity; import com.epmet.service.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -64,7 +63,7 @@ public class HouseInformationController { * @return com.epmet.commons.tools.utils.Result */ @PostMapping("neighborhoodDetail/{neighborhoodId}") - public Result neighborhoodDetail(@PathVariable("neighborhoodId") String neighborhoodId){ + public Result neighborhoodDetail(@PathVariable("neighborhoodId") String neighborhoodId){ return icNeighborHoodService.neighborhoodDetail(neighborhoodId); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java index 6d3b50b408..939f740fc1 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java @@ -101,6 +101,19 @@ public class StaffController { return staffService.editStaff(tokenDto, fromDTO); } + /** + * 人员编辑 + * + * @param fromDTO 参数 + * @return Result + */ + @PostMapping("editstaffpy") + @RequirePermission(requirePermission = RequirePermissionEnum.ORG_STAFF_UPDATE) + public Result editStaffPy(@LoginUser TokenDto tokenDto, @RequestBody StaffSubmitAccountFromDTO fromDTO){ + ValidatorUtils.validateEntity(fromDTO); + return staffService.editStaffByAccount(tokenDto, fromDTO); + } + /** * 人员详情 * @@ -195,6 +208,20 @@ public class StaffController { return staffService.addStaffV2(fromDTO); } + /** + * 【通讯录】人员添加-平阴 + * @author zhy + */ + + @PostMapping("addstaffpy") + @RequirePermission(requirePermission = RequirePermissionEnum.ORG_STAFF_CREATE) + public Result addStaffPy(@RequestBody StaffSubmitAccountFromDTO fromDTO){ + fromDTO.setApp("gov"); + fromDTO.setClient("wxmp"); + ValidatorUtils.validateEntity(fromDTO); + return staffService.addStaffByAccount(fromDTO); + } + /** * @Description 用户所属组织 * @Param tokenDto diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcPropertyManagementDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcPropertyManagementDao.java index 24bd9b22e2..52a038ab3b 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcPropertyManagementDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcPropertyManagementDao.java @@ -18,6 +18,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.IcPropertyManagementDTO; import com.epmet.entity.IcPropertyManagementEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -50,4 +51,11 @@ public interface IcPropertyManagementDao extends BaseDao selectIdByName(@Param("names")List names); + + /** + * 查询小区关联物业id,name + * @param neighborhoodId + * @return + */ + List selectPropertyNameList(String neighborhoodId); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java index 8190c9418d..9f2c94e49c 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java @@ -91,6 +91,16 @@ public interface EpmetUserFeignClient { @PostMapping("/epmetuser/customerstaff/addstaff") Result addStaff(@RequestBody StaffSubmitFromDTO fromDTO); + /** + * 人员添加 + * + * @param fromDTO 参数 + * @return Result + */ + @PostMapping("/epmetuser/customerstaff/addstaffaccount") + Result addStaffByAccount(@RequestBody StaffSubmitAccountFromDTO fromDTO); + + /** * 人员编辑 * @@ -100,6 +110,16 @@ public interface EpmetUserFeignClient { @PostMapping("/epmetuser/customerstaff/editstaff") Result editStaff(@RequestBody StaffSubmitFromDTO fromDTO); + /** + * 人员编辑 + * + * @param fromDTO 参数 + * @return Result + */ + @PostMapping("/epmetuser/customerstaff/editstaffaccount") + Result editStaffByAccount(@RequestBody StaffSubmitAccountFromDTO fromDTO); + + /** * 人员详情 * diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java index 4594d36a60..5b5e7fc04e 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java @@ -62,11 +62,21 @@ public class EpmetUserFeignClientFallBack implements EpmetUserFeignClient { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "addStaff", fromDTO); } + @Override + public Result addStaffByAccount(StaffSubmitAccountFromDTO fromDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "addStaffByAccount", fromDTO); + } + @Override public Result editStaff(StaffSubmitFromDTO fromDTO) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "editStaff", fromDTO); } + @Override + public Result editStaffByAccount(StaffSubmitAccountFromDTO fromDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "editStaffByAccount", fromDTO); + } + @Override public Result getStaffDetail(StaffInfoFromDTO fromDTO) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getStaffDetail", fromDTO); diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java index 913b4496c4..266d0f9b41 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java @@ -28,11 +28,11 @@ import com.epmet.dto.NeighborHoodAndManagementDTO; import com.epmet.dto.form.IcNeighborHoodAddFormDTO; import com.epmet.dto.form.ImportInfoFormDTO; import com.epmet.dto.result.BuildingResultDTO; +import com.epmet.dto.result.IcNeighborHoodDetailDTO; import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.entity.IcNeighborHoodEntity; import com.epmet.entity.IcNeighborHoodPropertyEntity; import com.epmet.entity.IcPropertyManagementEntity; -import org.springframework.web.bind.annotation.RequestBody; import java.io.IOException; import java.io.InputStream; @@ -194,5 +194,5 @@ public interface IcNeighborHoodService extends BaseService * @params [neighborhoodId] * @return com.epmet.commons.tools.utils.Result */ - Result neighborhoodDetail(String neighborhoodId); + Result neighborhoodDetail(String neighborhoodId); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java index 2c11cd6444..fc2f954b02 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java @@ -64,6 +64,14 @@ public interface StaffService { */ Result editStaff(TokenDto tokenDto,StaffSubmitFromDTO fromDTO); + /** + * 人员编辑 + * + * @param fromDTO 参数 + * @return Result + */ + Result editStaffByAccount(TokenDto tokenDto, StaffSubmitAccountFromDTO fromDTO); + /** * 人员详情 * @@ -130,6 +138,13 @@ public interface StaffService { */ Result addStaffV2(AddStaffV2FromDTO fromDTO); + + /** + * 【通讯录】人员添加-平阴 + * @author zhy + */ + Result addStaffByAccount(StaffSubmitAccountFromDTO fromDTO); + /** * @Description 工作人员所属组织 * @Param tokenDto diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java index 66658f83f2..e14ea745ab 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java @@ -30,6 +30,7 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.dto.result.OptionResultDTO; import com.epmet.commons.tools.exception.EpmetErrorCode; @@ -50,10 +51,7 @@ import com.epmet.dto.*; import com.epmet.dto.form.IcNeighborHoodAddFormDTO; import com.epmet.dto.form.ImportInfoFormDTO; import com.epmet.dto.form.ImportTaskCommonFormDTO; -import com.epmet.dto.result.BuildingResultDTO; -import com.epmet.dto.result.ImportTaskCommonResultDTO; -import com.epmet.dto.result.InfoByNamesResultDTO; -import com.epmet.dto.result.UploadImgResultDTO; +import com.epmet.dto.result.*; import com.epmet.entity.*; import com.epmet.excel.IcNeighborHoodExcel; import com.epmet.feign.EpmetCommonServiceOpenFeignClient; @@ -808,12 +806,22 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl neighborhoodDetail(String neighborhoodId) { - IcNeighborHoodEntity result = baseDao.selectById(neighborhoodId); - if(null != result && null == result.getRemark()){ - result.setRemark(""); + public Result neighborhoodDetail(String neighborhoodId) { + IcNeighborHoodEntity icNeighborHoodEntity = baseDao.selectById(neighborhoodId); + if (null == icNeighborHoodEntity) { + return new Result<>(); } - return new Result().ok(result); + IcNeighborHoodDetailDTO result = ConvertUtils.sourceToTarget(icNeighborHoodEntity, IcNeighborHoodDetailDTO.class); + if(null == result.getRemark()){ + result.setRemark(StrConstant.EPMETY_STR); + } + GridInfoCache gridInfoCache=CustomerOrgRedis.getGridInfo(result.getGridId()); + if (null != gridInfoCache) { + result.setAgencyName(gridInfoCache.getAgencyName()); + result.setGridName(gridInfoCache.getGridName()); + } + result.setPropertyList(propertyManagementDao.selectPropertyNameList(neighborhoodId)); + return new Result().ok(result); } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java index e62100cf8d..6950cbcc3c 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java @@ -204,6 +204,25 @@ public class StaffServiceImpl implements StaffService { return result; } + @Override + public Result editStaffByAccount(TokenDto tokenDto, StaffSubmitAccountFromDTO fromDTO) { + CustomerAgencyEntity customerAgencyEntity = customerAgencyService.selectById(fromDTO.getAgencyId()); + fromDTO.setCustomerId(customerAgencyEntity.getCustomerId()); + fromDTO.setApp(tokenDto.getApp()); + fromDTO.setClient(tokenDto.getClient()); + + Result result = epmetUserFeignClient.editStaffByAccount(fromDTO); + if (!result.success()) { + if (result.getCode() != EpmetErrorCode.SERVER_ERROR.getCode()) { + return new Result().error(result.getCode(), result.getMsg()); + } + return new Result().error(EpmetErrorCode.STAFF_EDIT_FAILED.getCode(), EpmetErrorCode.STAFF_EDIT_FAILED.getMsg()); + } + //2021.8.24 sun 人员信息编辑时删除工作人员的缓存信息 + CustomerStaffRedis.delStaffInfoFormCache(fromDTO.getCustomerId(), fromDTO.getStaffId()); + return result; + } + @Override public Result getStaffDetail(StaffInfoFromDTO fromDTO) { CustomerAgencyEntity customerAgencyEntity = customerAgencyService.selectById(fromDTO.getAgencyId()); @@ -597,6 +616,45 @@ public class StaffServiceImpl implements StaffService { return new Result(); } + + @Override + @Transactional(rollbackFor = Exception.class) + public Result addStaffByAccount(StaffSubmitAccountFromDTO fromDTO) { + CustomerAgencyEntity customerAgencyEntity = customerAgencyService.selectById(fromDTO.getAgencyId()); + //fromDTO.setApp(tokenDto.getApp()); + //fromDTO.setClient(tokenDto.getClient()); + fromDTO.setCustomerId(customerAgencyEntity.getCustomerId()); + Result result = epmetUserFeignClient.addStaffByAccount(fromDTO); + + if (!result.success()) { + if (result.getCode() != EpmetErrorCode.SERVER_ERROR.getCode()) { + return new Result().error(result.getCode(), result.getMsg()); + } + return new Result().error(EpmetErrorCode.STAFF_ADD_FAILED.getCode(), EpmetErrorCode.STAFF_ADD_FAILED.getMsg()); + } + //人员机关关系表 + CustomerStaffAgencyEntity customerStaffAgencyEntity = new CustomerStaffAgencyEntity(); + customerStaffAgencyEntity.setCustomerId(customerAgencyEntity.getCustomerId()); + customerStaffAgencyEntity.setUserId(result.getData().getUserId()); + customerStaffAgencyEntity.setAgencyId(customerAgencyEntity.getId()); + customerStaffAgencyService.insert(customerStaffAgencyEntity); + //机关总人数加一 + customerAgencyEntity.setTotalUser(customerAgencyEntity.getTotalUser() + 1); + customerAgencyService.updateById(customerAgencyEntity); + + //2021.8.25 sun 新增一张工作人员注册组织关系表,所以旧接口新增人员时关系表赋值关系数据 + //工作人员注册组织关系表新增数据 + StaffOrgRelationEntity staffOrgRelationEntity = new StaffOrgRelationEntity(); + staffOrgRelationEntity.setCustomerId(fromDTO.getCustomerId()); + staffOrgRelationEntity.setPids(("".equals(customerAgencyEntity.getPids()) ? "" : customerAgencyEntity.getPids())); + staffOrgRelationEntity.setStaffId(result.getData().getUserId()); + staffOrgRelationEntity.setOrgId(customerAgencyEntity.getId()); + staffOrgRelationEntity.setOrgType("agency"); + staffOrgRelationService.insert(staffOrgRelationEntity); + + return new Result(); + } + /** * @param tokenDto * @Description 工作人员所属组织 diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml index aaebe3cf78..a825c2538a 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml @@ -458,6 +458,13 @@ b.LONGITUDE, b.COORDINATE_POSITION, b.TYPE, + ( + case when b.TYPE='1' then '商品房' + when b.TYPE='2' then '自建房' + when b.TYPE='3' then '别墅' + else '' + end + ) as typeName, h.GRID_ID, h.AGENCY_ID, b.BUILDING_LEADER_NAME, diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcPropertyManagementDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcPropertyManagementDao.xml index 5a5cf172a3..0b0aba046c 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcPropertyManagementDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcPropertyManagementDao.xml @@ -48,4 +48,21 @@ ) + \ No newline at end of file diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/IcEventServiceImpl.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/IcEventServiceImpl.java index 6f4d7afe6e..dda3a90647 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/IcEventServiceImpl.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/IcEventServiceImpl.java @@ -940,7 +940,7 @@ public class IcEventServiceImpl extends BaseServiceImpl e.CUSTOMER_ID = #{customerId} + AND e.DEL_FLAG = '0' and e.HAPPEN_TIME >= #{queryStartTime} and e.HAPPEN_TIME #{queryEndTime} @@ -72,7 +73,7 @@ and c.CATEGORY_CODE like CONCAT(#{categoryCode},'%') - order by e.CREATED_TIME desc + order by e.happen_time desc + + + + diff --git a/epmet-module/oper-access/oper-access-server/src/main/resources/mapper/OperRoleMenuDao.xml b/epmet-module/oper-access/oper-access-server/src/main/resources/mapper/OperRoleMenuDao.xml index b9075fceda..17f9602254 100644 --- a/epmet-module/oper-access/oper-access-server/src/main/resources/mapper/OperRoleMenuDao.xml +++ b/epmet-module/oper-access/oper-access-server/src/main/resources/mapper/OperRoleMenuDao.xml @@ -4,7 +4,7 @@ diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java index 95b136c9ac..493d176a07 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java @@ -1171,7 +1171,7 @@ public class ResiGroupServiceImpl extends BaseServiceImpl scopeList; + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/DataSyncScopeDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/DataSyncScopeDTO.java new file mode 100644 index 0000000000..626b3d966c --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/DataSyncScopeDTO.java @@ -0,0 +1,94 @@ +package com.epmet.dto; + +import com.epmet.dto.form.ScopeSaveFormDTO; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.Date; + + +/** + * 数据更新范围表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-09-26 + */ +@Data +public class DataSyncScopeDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 客户ID。如果该角色由客户定制,其下的机关和部门都不再各自定制自己的角色,这个字段会比较有用。包括通用角色以及客户定制角色。 + */ + private String customerId; + + /** + * 数据更新配置表主键 + */ + private String dataSyncConfigId; + + /** + * 网格:grid, +社区级:community, +乡(镇、街道)级:street, +区县级: district, +市级: city +省级:province + */ + @NotBlank(message = "orgType不能为空",groups = ScopeSaveFormDTO.ScopeSaveForm.class) + private String orgType; + + /** + * 组织或者网格id + */ + @NotBlank(message = "orgId不能为空",groups = ScopeSaveFormDTO.ScopeSaveForm.class) + private String orgId; + + /** + * org_id的上级 + */ + private String pid; + + /** + * org_id的全路径,包含自身 + */ + private String orgIdPath; + + /** + * 删除标识:0.未删除 1.已删除 + */ + private Integer delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcBirthRecordDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcBirthRecordDTO.java index 9215512142..46bee9f321 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcBirthRecordDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcBirthRecordDTO.java @@ -71,7 +71,11 @@ public class IcBirthRecordDTO implements Serializable { @NotBlank(message = "所属家庭不能为空", groups = {AddGroup.class}) private String homeId; private String home; - + /** + * 所属房屋全路径名称 + * 详情回显 + */ + private String homeAllName; /** * 姓名 */ @@ -84,10 +88,9 @@ public class IcBirthRecordDTO implements Serializable { private String mobile; /** - * 性别 + * 性别 1男2女 */ private String gender; - /** * 身份证号 */ @@ -139,6 +142,12 @@ public class IcBirthRecordDTO implements Serializable { */ private String householderRelation; + /** + * 与户主关系【字典表】 + * 详情回显 + */ + private String householderRelationName; + /** * 是否勾选补充居民信息0否 1是 */ diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcEpidemicSpecialAttentionDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcEpidemicSpecialAttentionDTO.java index 9b2a5274b6..5d880153a6 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcEpidemicSpecialAttentionDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcEpidemicSpecialAttentionDTO.java @@ -28,7 +28,8 @@ public class IcEpidemicSpecialAttentionDTO implements Serializable { /** * ID */ - private String id; + @NotBlank(message = "id不能为空",groups = {IcEpidemicSpecialAttentionUpdate.class}) + private String id; /** * 客户ID @@ -56,7 +57,21 @@ public class IcEpidemicSpecialAttentionDTO implements Serializable { private Integer isAttention; /** - * 关注类型,核酸检测:2,疫苗接种:1,行程上报:0 + * 是否历史关注,1是0否 + */ + private String isHistory; + + /** + * 隔离类型,来自字典表;集中隔离:0;居家隔离1;居家健康监测2;已出隔离期3 + */ + // @NotBlank(message = "isolatedState不能为空",groups = {IcEpidemicSpecialAttentionAdd.class,IcEpidemicSpecialAttentionUpdate.class}) + private String isolatedState; + + /** + * 关注类型, + * 核酸检测:2, + * 疫苗接种:1, + * 行程上报:0 */ @NotNull(message = "attentionType不能为空",groups = {IcEpidemicSpecialAttentionAdd.class,IcEpidemicSpecialAttentionUpdate.class}) private Integer attentionType; diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcNatCompareRecordDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcNatCompareRecordDTO.java new file mode 100644 index 0000000000..9bde2314d1 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcNatCompareRecordDTO.java @@ -0,0 +1,121 @@ +package com.epmet.dto; + +import com.alibaba.excel.annotation.ExcelIgnore; +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 核酸比对记录 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-09-26 + */ +@Data +public class IcNatCompareRecordDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + @ExcelIgnore + private String customerId; + + /** + * 主键 + */ + @ExcelIgnore + private String relationId; + + /** + * 姓名 + */ + @ColumnWidth(15) + @ExcelProperty("姓名") + private String name; + + /** + * 真实身份证号 + */ + @ColumnWidth(20) + @ExcelProperty("身份证号") + private String realIdCard; + + /** + * 身份证 + */ + @ExcelIgnore + private String idCard; + + /** + * 手机号 + */ + @ExcelIgnore + private String mobile; + + /** + * 真实手机号 + */ + @ColumnWidth(20) + @ExcelProperty("联系方式") + private String realMobile; + + /** + * 是否客户下居民(0:否 1:是) + */ + @ExcelIgnore + private String isAgencyUser; + + @ColumnWidth(10) + @ExcelProperty("本辖区居民") + private String isAgencyUserDesc; + + /** + * 是本辖区的居民时候,ic_resi_user.id + */ + @ExcelIgnore + private String icResiUserId; + + /** + * 最近一次核酸时间:接口填入 + */ + @ColumnWidth(30) + @ExcelProperty("最近一次核酸时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date latestNatTime; + + /** + * 检测结果(0:阴性 1:阳性):接口填入 + */ + @ExcelIgnore + private String natResult; + + + /** + * 检测地点:接口填入 + */ + @ColumnWidth(50) + @ExcelProperty("检测地点") + private String natAddress; + + + @ColumnWidth(15) + @ExcelProperty("检测结果") + private String natResultDesc; + + @ExcelIgnore + private String importDate; + + + @ColumnWidth(30) + @ExcelProperty("导入时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date importTime; + + @ColumnWidth(30) + @ExcelProperty("导入组织") + private String agencyName; +} \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcNoticeDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcNoticeDTO.java index 72520ef800..d4184734a9 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcNoticeDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcNoticeDTO.java @@ -106,4 +106,8 @@ public class IcNoticeDTO implements Serializable { @JsonIgnore private Date updatedTime; + /** + * 发送结果:1成功,0失败 + */ + private String sendRes; } \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcTripReportRecordDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcTripReportRecordDTO.java index 508f8dc2ad..9d2ab97099 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcTripReportRecordDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcTripReportRecordDTO.java @@ -35,6 +35,9 @@ public class IcTripReportRecordDTO implements Serializable { @ExcelIgnore private String id; + @ExcelIgnore + private String epidemicId; + /** * 居民端用户所在网格id,数字社区居民所属网格id */ @@ -73,6 +76,11 @@ public class IcTripReportRecordDTO implements Serializable { @ExcelProperty("手机号") private String mobile; + /** + * 真实手机号不打码 + */ + private String realMobile; + /** * 身份证号 */ @@ -80,6 +88,11 @@ public class IcTripReportRecordDTO implements Serializable { @ExcelProperty("身份证号") private String idCard; + /** + * 真实身份证号 + */ + private String realIdCard; + /** * 用户id */ diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CollectDetailResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CollectDetailResultDTO.java index 3f2f2f728b..5a6d58d685 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CollectDetailResultDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CollectDetailResultDTO.java @@ -1,5 +1,7 @@ package com.epmet.dto.form; +import com.epmet.dto.result.OrgInfoIdAndNameResultDTO; +import com.epmet.dto.result.OrgInfoResultDTO; import lombok.Data; import java.io.Serializable; @@ -73,4 +75,8 @@ public class CollectDetailResultDTO implements Serializable { private String checkReason; private List memberList; + + private String orgIdPath; + + private List orgIdPathList; } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/ConfigSwitchFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/ConfigSwitchFormDTO.java new file mode 100644 index 0000000000..1ff6b9bcf4 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/ConfigSwitchFormDTO.java @@ -0,0 +1,26 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2022/9/26 14:34 + * @DESC + */ +@Data +public class ConfigSwitchFormDTO implements Serializable { + + private static final long serialVersionUID = 7510856043372376415L; + + public interface ConfigSwitchForm{} + + @NotBlank(message = "deptCode不能为空",groups = ConfigSwitchForm.class) + private String deptCode; + + @NotBlank(message = "dataSyncConfigId不能为空",groups = ConfigSwitchForm.class) + private String dataSyncConfigId; + private String updatedBy; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CustomerStaffByAccountFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CustomerStaffByAccountFormDTO.java new file mode 100644 index 0000000000..75153c3305 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CustomerStaffByAccountFormDTO.java @@ -0,0 +1,36 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.List; + +/** + * @Description 根据手机号+客户id获取工作人员基本信息 + * @Author yinzuomei + * @Date 2020/4/20 14:02 + */ +@Data +public class CustomerStaffByAccountFormDTO implements Serializable { + private static final long serialVersionUID = 7619815083427853431L; + + // 根据手机号+客户id获取工作人员基本信息 + public interface GetCustomerStaffInfo {} + + @NotBlank(message = "账号不能为空", groups = { GetCustomerStaffInfo.class }) + private String userAccount; + @NotBlank(message = "客户id不能为空", groups = { GetCustomerStaffInfo.class }) + private String customerId; + + /** + * 姓名 + */ + private String realName; + + /** + * 用户id集合 + */ + private List userIds; +} + diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DingLoginResiFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DingLoginResiFormDTO.java new file mode 100644 index 0000000000..7f756f2ed9 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DingLoginResiFormDTO.java @@ -0,0 +1,60 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * @Description 钉钉居民端应用注册 // 接口逻辑: + * // (1)根据clientId去XXX表找到customerId + * // (2)通过1、2拿到手机号之后,根据mobile+customerId去user_base_info表找userId, + * // 是否注册居民:register_relation + * // (3)没有则生成user、user_Base_info表记录 + * @Author yzm + * @Date 2022/9/15 9:28 + */ +@Data +public class DingLoginResiFormDTO { + public interface AddUserInternalGroup { + } + + public interface AddUserShowGroup extends CustomerClientShowGroup { + } + + @NotBlank(message = "customerId不能为空", groups = AddUserShowGroup.class) + private String customerId; + + // 以下参数是微信返回的 + /** + * 头像URL。 + */ + public String avatarUrl; + /** + * 用户的个人邮箱。 + */ + public String email; + /** + * 用户的手机号。 + * 说明 如果要获取用户手机号,需要在开发者后台申请个人手机号信息权限,如下图。 + */ + @NotBlank(message = "手机号不能为空", groups = AddUserShowGroup.class) + public String mobile; + /** + * 用户的钉钉昵称。 + */ + public String nick; + /** + * + */ + public String openId; + /** + * 手机号对应的国家号。 + */ + public String stateCode; + /** + * + */ + public String unionId; +} + diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/NatInfoScanTaskFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/NatInfoScanTaskFormDTO.java new file mode 100644 index 0000000000..6d642b2e90 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/NatInfoScanTaskFormDTO.java @@ -0,0 +1,21 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @Author zxc + * @DateTime 2022/9/26 17:04 + * @DESC + */ +@Data +public class NatInfoScanTaskFormDTO implements Serializable { + + private static final long serialVersionUID = 3053943501957102943L; + + private String customerId; + + private List idCards; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/ScopeSaveFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/ScopeSaveFormDTO.java new file mode 100644 index 0000000000..738ed51b59 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/ScopeSaveFormDTO.java @@ -0,0 +1,29 @@ +package com.epmet.dto.form; + +import com.epmet.dto.DataSyncScopeDTO; +import lombok.Data; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.List; + +/** + * @Author zxc + * @DateTime 2022/9/26 15:35 + * @DESC + */ +@Data +public class ScopeSaveFormDTO implements Serializable { + + private static final long serialVersionUID = -489844541905303736L; + + public interface ScopeSaveForm{} + + @NotBlank(message = "dataSyncConfigId不能为空",groups = ScopeSaveForm.class) + private String dataSyncConfigId; + private String customerId; + + @Valid + private List scopeList; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/SendNoticeFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/SendNoticeFormDTO.java index 75a2eee8e0..56bdcc0fea 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/SendNoticeFormDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/SendNoticeFormDTO.java @@ -60,5 +60,8 @@ public class SendNoticeFormDTO implements Serializable { * 身份证 */ private String idCard; + + + private String realIdCard; } } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/SendNoticeV2FormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/SendNoticeV2FormDTO.java new file mode 100644 index 0000000000..23e77ed29c --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/SendNoticeV2FormDTO.java @@ -0,0 +1,50 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Size; +import java.util.List; + +/** + * @Description + * @Author yzm + * @Date 2022/9/21 17:06 + */ +@Data +public class SendNoticeV2FormDTO { + // token获取 + private String customerId; + private String staffId; + // 前端传入 + /** + * 用户列表 + */ + @NotEmpty(message = "业务数据id不能为空", groups = CustomerClientShowGroup.class) + private List bdIds; + /** + * 通知渠道通知渠道 0小程序通知,1短信通知 + */ + @NotEmpty(message = "请选择通知渠道", groups = CustomerClientShowGroup.class) + private List channel; + /** + * v1:通知来源 0 行程上报,1 疫苗接种,2 核酸检测 + * v2:0行程上报,1疫苗接种关注名单,2重点人群关注名单-隔离防疫(原核酸检测关注名单) + */ + @NotEmpty(message = "通知来源不能为空", groups = CustomerClientShowGroup.class) + private String origin; + /** + * 通知内容 + */ + @Size(min = 1, max = 500, message = "通知内容不超过500字", groups = CustomerClientShowGroup.class) + private String content; + + // 接口内赋值 + /** + * 组织名 + */ + private String orgName; + +} + diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StaffResetPwFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StaffResetPwFormDTO.java index 9d21502254..f3ecdc99c0 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StaffResetPwFormDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StaffResetPwFormDTO.java @@ -22,7 +22,10 @@ public class StaffResetPwFormDTO implements Serializable { public interface AddUserShowGroup extends CustomerClientShowGroup { } - + /** + * 旧密码 + */ + private String oldPassword; @NotBlank(message = "新密码不能为空", groups = {AddUserShowGroup.class}) private String newPassword; @NotBlank(message = "确认新密码不能为空", groups = {AddUserShowGroup.class}) diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/ThirdCustomerStaffByAccountFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/ThirdCustomerStaffByAccountFormDTO.java new file mode 100644 index 0000000000..72eacbd9a1 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/ThirdCustomerStaffByAccountFormDTO.java @@ -0,0 +1,24 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description 根据客户ID、手机号查询政府端工作人员基本信息 + * @Author zhy + */ +@Data +public class ThirdCustomerStaffByAccountFormDTO implements Serializable{ + private static final long serialVersionUID = -7994579456530273809L; + + /** + * 客户Id + * */ + private String customerId; + + /** + * 账号 + * */ + private String userAccount; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/VaccinationListFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/VaccinationListFormDTO.java index c50649b4a9..cc06182a72 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/VaccinationListFormDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/VaccinationListFormDTO.java @@ -24,6 +24,12 @@ public class VaccinationListFormDTO extends PageFormDTO implements Serializable @NotNull(message = "attentionType不能为空",groups = VaccinationListForm.class) private Integer attentionType; + /** + * 隔离类型,来自字典表;集中隔离:0;居家隔离1;居家健康监测2;已出隔离期3 + */ + private String isolatedState; + private String isHistory; + /** * 手机号 */ diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/yqfk/IcNatCompareRecordPageFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/yqfk/IcNatCompareRecordPageFormDTO.java new file mode 100644 index 0000000000..c5f6ddd53e --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/yqfk/IcNatCompareRecordPageFormDTO.java @@ -0,0 +1,42 @@ +package com.epmet.dto.form.yqfk; + +import com.epmet.commons.tools.dto.form.PageFormDTO; +import lombok.Data; + +/** + * @Description + * @Author yzm + * @Date 2022/9/26 15:55 + */ +@Data +public class IcNatCompareRecordPageFormDTO extends PageFormDTO { + /** + * 是否客户下居民(0:否 1:是) + */ + private String isResiUser; + /** + * 导入时间 yyyyMMdd + */ + private String importDate; + + /** + * 姓名 + */ + private String name; + + /** + * 身份证 + */ + private String idCard; + + /** + * 手机号 + */ + private String mobile; + + + private String customerId; + private String userId; + private String agencyId; +} + diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/DingAutoRegResDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/DingAutoRegResDTO.java new file mode 100644 index 0000000000..dd1be77a56 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/DingAutoRegResDTO.java @@ -0,0 +1,27 @@ +package com.epmet.dto.result; + +import lombok.Data; + +/** + * @Description + * @Author yzm + * @Date 2022/9/15 14:31 + */ +@Data +public class DingAutoRegResDTO { + private String customerId; + private String gridId; + /** + * 网格名 + */ + private String gridName; + /** + * 网格所属的组织id + */ + private String agencyId; + /** + * 居民端用户id + */ + private String epmetUserId; +} + diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/DingLoginResiResDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/DingLoginResiResDTO.java new file mode 100644 index 0000000000..a9ca3d693a --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/DingLoginResiResDTO.java @@ -0,0 +1,34 @@ +package com.epmet.dto.result; + +import lombok.Data; + +/** + * @Description + * @Author yzm + * @Date 2022/9/15 9:33 + */ +@Data +public class DingLoginResiResDTO { + private String customerId; + private String gridId; + /** + * XXX社区-网格名 + */ + private String gridName; + /** + * 网格所属的组织id + */ + private String agencyId; + /** + * 居民端用户id + */ + private String epmetUserId; + + /** + * 是否注册居民 + * true:已注册 + * false:未注册 + */ + private Boolean regFlag; +} + diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/NatPieResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/NatPieResultDTO.java new file mode 100644 index 0000000000..084599de93 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/NatPieResultDTO.java @@ -0,0 +1,30 @@ +package com.epmet.dto.result; + +import com.epmet.commons.tools.constant.NumConstant; +import lombok.Data; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * @Author zxc + * @DateTime 2022/9/19 15:47 + * @DESC + */ +@Data +public class NatPieResultDTO implements Serializable { + + private static final long serialVersionUID = -1617454069928624020L; + + private List isolatedList = new ArrayList<>(); + private List historyList = new ArrayList<>(); + + @Data + public static class IsolatedList{ + private Integer total = NumConstant.ZERO; + private String categoryCode; + private String categoryName; + private String color; + } +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/NatUserInfoResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/NatUserInfoResultDTO.java new file mode 100644 index 0000000000..10e611aa46 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/NatUserInfoResultDTO.java @@ -0,0 +1,24 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2022/9/27 10:23 + * @DESC + */ +@Data +public class NatUserInfoResultDTO implements Serializable { + + private static final long serialVersionUID = 8904940082452398136L; + + private String idCard; + + private String userId; + + private String agencyId; + + private String pids; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/OrgInfoIdAndNameResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/OrgInfoIdAndNameResultDTO.java new file mode 100644 index 0000000000..53223ed6ad --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/OrgInfoIdAndNameResultDTO.java @@ -0,0 +1,23 @@ +package com.epmet.dto.result; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2022/10/11 13:41 + * @DESC + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class OrgInfoIdAndNameResultDTO implements Serializable { + + private static final long serialVersionUID = 7478605833438304330L; + + private String id; + private String name; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/VaccinationListResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/VaccinationListResultDTO.java index 29ebb13231..7099e1650b 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/VaccinationListResultDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/VaccinationListResultDTO.java @@ -1,6 +1,7 @@ package com.epmet.dto.result; import com.epmet.commons.tools.constant.NumConstant; +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; import org.apache.commons.lang3.StringUtils; @@ -37,10 +38,21 @@ public class VaccinationListResultDTO implements Serializable { */ private String mobile; + /** + * 真实手机号 + */ + private String realMobile; + /** * 身份证 */ private String idCard; + + /** + * 真实的身份证 + */ + private String realIdCard; + private String sex; /** @@ -57,6 +69,7 @@ public class VaccinationListResultDTO implements Serializable { * 最后一次通知时间 */ private String lastInformTime; + private String lastNatTime; /** * 所属小区ID @@ -72,6 +85,8 @@ public class VaccinationListResultDTO implements Serializable { * 所属楼宇Id */ private String buildId; + private String gridId; + private String gridName; /** * 所属楼宇名称 @@ -102,7 +117,15 @@ public class VaccinationListResultDTO implements Serializable { * 小区名+楼栋名+单元名+房屋名 */ private String allName; + /** + * 隔离类型,来自字典表;集中隔离:0;居家隔离1;居家健康监测2;已出隔离期3 + */ + private String isolatedState; private String id; + private String userId; + + @JsonIgnore + private String customerId; public VaccinationListResultDTO() { this.vaccinationCount = NumConstant.ZERO; diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/enums/NatPieColorEnum.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/enums/NatPieColorEnum.java new file mode 100644 index 0000000000..6f6b58f854 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/enums/NatPieColorEnum.java @@ -0,0 +1,47 @@ +package com.epmet.enums; + +import com.epmet.commons.tools.constant.NumConstant; +import org.apache.commons.lang3.StringUtils; + +/** + * @Author zxc + * @DateTime 2022/3/29 16:17 + * @DESC + */ +public enum NatPieColorEnum { + + REd("0","#ee6666"), + YELLOW("2","#fac858"), + ORANGE("1","#fc8452"), + THREE("3","#73c0de"), + GREEN("100","#91cc75"), + ; + + private String key; + private String value; + + NatPieColorEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public static String getValueByKey(String key){ + if (StringUtils.isBlank(key)){ + return NumConstant.ZERO_STR; + } + for (NatPieColorEnum a : NatPieColorEnum.values()) { + if (a.getKey().equals(key)){ + return a.getValue(); + } + } + return NumConstant.ZERO_STR; + } + + public String getKey() { + return key; + } + + public String getValue() { + return value; + } +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java index 73d770a411..a2398b2d92 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java @@ -153,6 +153,16 @@ public interface EpmetUserOpenFeignClient { @PostMapping(value = "epmetuser/customerstaff/getcustomerstaffinfo", consumes = MediaType.APPLICATION_JSON_VALUE) Result getCustomerStaffInfo(@RequestBody CustomerStaffFormDTO customerStaffFormDTO); + /** + * @param customerStaffFormDTO + * @return + * @Author sun + * @Description 根据账户+客户id获取工作人员基本信息 + **/ + @PostMapping(value = "epmetuser/customerstaff/getcustomerstaffinfobyaccount", consumes = MediaType.APPLICATION_JSON_VALUE) + Result getCustomerStaffInfoByAccount(@RequestBody CustomerStaffByAccountFormDTO customerStaffFormDTO); + + /** * @param userIdList * @return com.epmet.commons.tools.utils.Result> @@ -234,6 +244,16 @@ public interface EpmetUserOpenFeignClient { @GetMapping(value = "epmetuser/customerstaff/getCustsomerStaffByIdAndPhone") Result> getCustsomerStaffByIdAndPhone(@RequestBody ThirdCustomerStaffFormDTO formDTO); + /** + * @param formDTO + * @return + * @Author zhy + * @Description 根据客户ID、手机号查询政府端工作人员基本信息,校验用户是否存在 + **/ + @GetMapping(value = "epmetuser/customerstaff/getCustsomerStaffByIdAndAccount") + Result> getCustsomerStaffByIdAndAccount(@RequestBody ThirdCustomerStaffByAccountFormDTO formDTO); + + /** * 获取用户基础信息 * @@ -885,4 +905,23 @@ public interface EpmetUserOpenFeignClient { @PostMapping("/epmetuser/icresiuser/updateYlfn") Result updateYlfn(); + + /** + * 钉钉居民端登录 + * // 接入流程:https://open.dingtalk.com/document/isvapp-server/unified-authorization-suite-access-process + * // 1、获取个人用户token:https://open.dingtalk.com/document/isvapp-server/obtain-user-token + * // 2、获取用户通讯录个人信息:https://open.dingtalk.com/document/isvapp-server/dingtalk-retrieve-user-information + * // 接口逻辑: + * // (1)根据clientId去XXX表找到customerId + * // (2)通过1、2拿到手机号之后,根据mobile+customerId去user_base_info表找userId, + * // 是否注册居民:register_relation + * // (3)没有则生成user、user_Base_info表记录 + * @param formDTO + * @return + */ + @PostMapping("/epmetuser/userbaseinfo/dingResiLogin") + Result dingResiLogin(@RequestBody DingLoginResiFormDTO formDTO); + + @PostMapping("/epmetuser/dataSyncConfig/natInfoScanTask") + Result natInfoScanTask(@RequestBody NatInfoScanTaskFormDTO formDTO); } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java index 2de7371623..4601ca1ef3 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java @@ -99,6 +99,11 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getCustomerStaffInfo", customerStaffFormDTO); } + @Override + public Result getCustomerStaffInfoByAccount(CustomerStaffByAccountFormDTO customerStaffFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getCustomerStaffInfoByAccount", customerStaffFormDTO); + } + /** * @param userIdList * @return com.epmet.commons.tools.utils.Result> @@ -174,6 +179,10 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getCustsomerStaffByIdAndPhone", formDTO); } + @Override + public Result> getCustsomerStaffByIdAndAccount(ThirdCustomerStaffByAccountFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getCustsomerStaffByIdAndAccount", formDTO); + } @Override public Result selectUserBaseInfo(TokenDto tokenDTO) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "selectUserBaseInfo", tokenDTO); @@ -683,4 +692,28 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien public Result updateYlfn() { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "updateYlfn", null); } + + /** + * 钉钉居民端登录 + * // 接入流程:https://open.dingtalk.com/document/isvapp-server/unified-authorization-suite-access-process + * // 1、获取个人用户token:https://open.dingtalk.com/document/isvapp-server/obtain-user-token + * // 2、获取用户通讯录个人信息:https://open.dingtalk.com/document/isvapp-server/dingtalk-retrieve-user-information + * // 接口逻辑: + * // (1)根据clientId去XXX表找到customerId + * // (2)通过1、2拿到手机号之后,根据mobile+customerId去user_base_info表找userId, + * // 是否注册居民:register_relation + * // (3)没有则生成user、user_Base_info表记录 + * + * @param formDTO + * @return + */ + @Override + public Result dingResiLogin(DingLoginResiFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "dingResiLogin", formDTO); + } + + @Override + public Result natInfoScanTask(NatInfoScanTaskFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "natInfoScanTask", formDTO); + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserConstant.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserConstant.java index b9b1c5c87d..a51390f16f 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserConstant.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserConstant.java @@ -38,6 +38,7 @@ public interface UserConstant { */ String CLIENT_WX = "wxmp"; + /** * 居民角色 */ diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java index 215af4eab1..6c9d46dbb5 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java @@ -26,6 +26,7 @@ import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.user.LoginUserUtil; import com.epmet.commons.tools.utils.ExcelUtils; +import com.epmet.commons.tools.utils.RSASignature; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; @@ -39,7 +40,9 @@ import com.epmet.excel.CustomerStaffExcel; import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.send.SendMqMsgUtil; import com.epmet.service.CustomerStaffService; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; @@ -57,7 +60,8 @@ import java.util.Map; @RestController @RequestMapping("customerstaff") public class CustomerStaffController { - + @Value("${epmet.login.privateKey}") + private String privateKey; @Autowired private CustomerStaffService customerStaffService; @Autowired @@ -119,6 +123,18 @@ public class CustomerStaffController { return customerStaffService.getCustsomerStaffByPhone(mobile); } + /** + * @param account 账户 + * @return com.epmet.commons.tools.utils.Result + * @Author zhy + * @Description 根据账户查询政府端工作人员基本信息,校验用户是否存在 + * @Date 2020/4/18 14:07 + **/ + @GetMapping(value = "getcustsomerstaffbyaccount/{account}") + public Result> getCustsomerStaffByAccount(@PathVariable("account") String account) { + return customerStaffService.getCustsomerStaffByAccount(account); + } + /** * @param formDTO * @return com.epmet.commons.tools.utils.Result @@ -132,6 +148,19 @@ public class CustomerStaffController { return customerStaffService.getCustomerStaffInfo(formDTO); } + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author zhy + * @Description 根据账户+客户id获取工作人员基本信息 + * @Date 2020/4/20 14:04 + **/ + @PostMapping(value = "getcustomerstaffinfobyaccount") + public Result getCustomerStaffInfoByAccount(@RequestBody CustomerStaffByAccountFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, CustomerStaffFormDTO.GetCustomerStaffInfo.class); + return customerStaffService.getCustomerStaffInfoByAccount(formDTO); + } + /** * 根据userId查询网格下用户信息 * @param customerStaffGridDTOS @@ -234,6 +263,31 @@ public class CustomerStaffController { return result; } + + /** + * 人员添加 + * + * @param fromDTO 参数 + * @return Result + */ + @PostMapping("addstaffaccount") + public Result addStaffByAccount(@RequestBody StaffSubmitAccountFromDTO fromDTO){ + Result result = customerStaffService.addStaffByAccount(fromDTO); + + //2021-10-18 推送mq,数据同步到中介库 start + if (result.success()) { + OrgOrStaffMQMsg mq = new OrgOrStaffMQMsg(); + mq.setCustomerId(fromDTO.getCustomerId()); + mq.setOrgId(result.getData().getUserId()); + mq.setOrgType("staff"); + mq.setType("staff_create"); + SendMqMsgUtil.build().openFeignClient(epmetMessageOpenFeignClient).sendOrgStaffMqMsg(mq); + } + //2021-10-18 end + + return result; + } + /** * 人员编辑 * @@ -260,6 +314,30 @@ public class CustomerStaffController { return result; } + /** + * 人员编辑 + * + * @param fromDTO 参数 + * @return Result + */ + @PostMapping("editstaffaccount") + public Result editStaffByAccount(@RequestBody StaffSubmitAccountFromDTO fromDTO){ + Result result = customerStaffService.editStaffByAccount(fromDTO); + + //2021-10-18 推送mq,数据同步到中介库 start + if (result.success()) { + OrgOrStaffMQMsg mq = new OrgOrStaffMQMsg(); + mq.setCustomerId(fromDTO.getCustomerId()); + mq.setOrgId(fromDTO.getStaffId()); + mq.setOrgType("staff"); + mq.setType("staff_change"); + SendMqMsgUtil.build().openFeignClient(epmetMessageOpenFeignClient).sendOrgStaffMqMsg(mq); + } + //2021-10-18 end + + return result; + } + /** * 人员详情 * @@ -366,6 +444,17 @@ public class CustomerStaffController { return new Result>().ok(customerStaffService.getCustsomerStaffByIdAndPhone(formDTO)); } + /** + * @param formDTO + * @return + * @Author zhy + * @Description 根据客户ID、账户查询政府端工作人员基本信息,校验用户是否存在 + **/ + @GetMapping(value = "getCustsomerStaffByIdAndAccount") + public Result> getCustsomerStaffByIdAndAccount(@RequestBody ThirdCustomerStaffByAccountFormDTO formDTO) { + return new Result>().ok(customerStaffService.getCustsomerStaffByIdAndAccount(formDTO)); + } + /** * @Description 查询工作人员的信息 * @param formDTO @@ -415,7 +504,12 @@ public class CustomerStaffController { * @Date 10:03 2020-08-25 **/ @PostMapping(value = "customerlist") - public Result> customerList(@RequestBody CustomerListFormDTO formDTO){ + public Result> customerList(@RequestBody CustomerListFormDTO formDTO) throws Exception { + //解密密码 + if (StringUtils.isNotBlank(formDTO.getPhone())&&formDTO.getPhone().length() > 50) { + String phone = RSASignature.decryptByPrivateKey(formDTO.getPhone(), privateKey); + formDTO.setPhone(phone); + } return customerStaffService.selectCustomerList(formDTO); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/DataSyncConfigController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/DataSyncConfigController.java new file mode 100644 index 0000000000..950de6f573 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/DataSyncConfigController.java @@ -0,0 +1,115 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.aop.NoRepeatSubmit; +import com.epmet.commons.tools.dto.form.PageFormDTO; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.dto.DataSyncConfigDTO; +import com.epmet.dto.form.ConfigSwitchFormDTO; +import com.epmet.dto.form.NatInfoScanTaskFormDTO; +import com.epmet.dto.form.ScopeSaveFormDTO; +import com.epmet.service.DataSyncConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + + +/** + * 数据更新配置表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-09-26 + */ +@RestController +@RequestMapping("dataSyncConfig") +public class DataSyncConfigController { + + @Autowired + private DataSyncConfigService dataSyncConfigService; + + @RequestMapping(value = "{id}",method = {RequestMethod.POST,RequestMethod.GET}) + public Result get(@PathVariable("id") String id){ + DataSyncConfigDTO data = dataSyncConfigService.get(id); + return new Result().ok(data); + } + + @NoRepeatSubmit + @PostMapping("save") + public Result save(@RequestBody DataSyncConfigDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + dataSyncConfigService.save(dto); + return new Result(); + } + + @NoRepeatSubmit + @PostMapping("update") + public Result update(@RequestBody DataSyncConfigDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + dataSyncConfigService.update(dto); + return new Result(); + } + + @PostMapping("delete") + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + dataSyncConfigService.delete(ids); + return new Result(); + } + + /** + * Desc: 【数据配置】配置开关 + * @param formDTO + * @author zxc + * @date 2022/9/26 14:36 + */ + @PostMapping("configSwitch") + public Result configSwitch(@RequestBody ConfigSwitchFormDTO formDTO, @LoginUser TokenDto tokenDto){ + ValidatorUtils.validateEntity(formDTO, ConfigSwitchFormDTO.ConfigSwitchForm.class); + formDTO.setUpdatedBy(tokenDto.getUserId()); + dataSyncConfigService.configSwitch(formDTO); + return new Result(); + } + + /** + * Desc: 【数据配置】列表 + * @param tokenDto + * @author zxc + * @date 2022/9/26 15:04 + */ + @PostMapping("list") + public Result list(@LoginUser TokenDto tokenDto, @RequestBody PageFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO,PageFormDTO.AddUserInternalGroup.class); + return new Result().ok(dataSyncConfigService.list(tokenDto,formDTO)); + } + + /** + * Desc: 【数据配置】范围保存 + * @param tokenDto + * @param formDTO + * @author zxc + * @date 2022/9/26 15:40 + */ + @PostMapping("scopeSave") + public Result scopeSave(@LoginUser TokenDto tokenDto,@RequestBody ScopeSaveFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO,ScopeSaveFormDTO.ScopeSaveForm.class); + formDTO.setCustomerId(tokenDto.getCustomerId()); + dataSyncConfigService.scopeSave(formDTO); + return new Result(); + } + + @PostMapping("natInfoScanTask") + public Result natInfoScanTask(@RequestBody NatInfoScanTaskFormDTO formDTO){ + dataSyncConfigService.natInfoScanTask(formDTO); + return new Result(); + } + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/DataSyncScopeController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/DataSyncScopeController.java new file mode 100644 index 0000000000..e7e3980574 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/DataSyncScopeController.java @@ -0,0 +1,70 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.aop.NoRepeatSubmit; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.dto.DataSyncScopeDTO; +import com.epmet.service.DataSyncScopeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + + +/** + * 数据更新范围表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-09-26 + */ +@RestController +@RequestMapping("dataSyncScope") +public class DataSyncScopeController { + + @Autowired + private DataSyncScopeService dataSyncScopeService; + + @RequestMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = dataSyncScopeService.page(params); + return new Result>().ok(page); + } + + @RequestMapping(value = "{id}",method = {RequestMethod.POST,RequestMethod.GET}) + public Result get(@PathVariable("id") String id){ + DataSyncScopeDTO data = dataSyncScopeService.get(id); + return new Result().ok(data); + } + + @NoRepeatSubmit + @PostMapping("save") + public Result save(@RequestBody DataSyncScopeDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + dataSyncScopeService.save(dto); + return new Result(); + } + + @NoRepeatSubmit + @PostMapping("update") + public Result update(@RequestBody DataSyncScopeDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + dataSyncScopeService.update(dto); + return new Result(); + } + + @PostMapping("delete") + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + dataSyncScopeService.delete(ids); + return new Result(); + } + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcEpidemicSpecialAttentionController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcEpidemicSpecialAttentionController.java index e2e046a047..3ebd6d4f84 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcEpidemicSpecialAttentionController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcEpidemicSpecialAttentionController.java @@ -15,13 +15,13 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.constants.ImportTaskConstants; import com.epmet.dto.IcEpidemicSpecialAttentionDTO; +import com.epmet.dto.SysDictDataDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.ImportTaskCommonResultDTO; +import com.epmet.dto.result.NatPieResultDTO; import com.epmet.dto.result.VaccinationListResultDTO; -import com.epmet.excel.NatExportExcel; -import com.epmet.excel.NatImportExcel; -import com.epmet.excel.VaccinationExportExcel; -import com.epmet.excel.VaccinationImportExcel; +import com.epmet.excel.*; +import com.epmet.feign.EpmetAdminOpenFeignClient; import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.service.IcEpidemicSpecialAttentionService; import lombok.extern.slf4j.Slf4j; @@ -34,7 +34,9 @@ import javax.servlet.http.HttpServletResponse; import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** @@ -52,6 +54,8 @@ public class IcEpidemicSpecialAttentionController { private IcEpidemicSpecialAttentionService icEpidemicSpecialAttentionService; @Autowired private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient; + @Autowired + private EpmetAdminOpenFeignClient epmetAdminOpenFeignClient; /** * Desc: 【疫苗接种关注名单,疫苗接种关注名单】列表 @@ -68,6 +72,15 @@ public class IcEpidemicSpecialAttentionController { return new Result().ok(icEpidemicSpecialAttentionService.vaccinationList(formDTO)); } + @PostMapping("historyList") + @MaskResponse(fieldNames = { "mobile", "idCard" }, fieldsMaskType = { MaskResponse.MASK_TYPE_MOBILE, MaskResponse.MASK_TYPE_ID_CARD }) + public Result historyList(@RequestBody VaccinationListFormDTO formDTO, @LoginUser TokenDto tokenDto){ + ValidatorUtils.validateEntity(formDTO, PageFormDTO.AddUserInternalGroup.class, VaccinationListFormDTO.VaccinationListForm.class); + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setUserId(tokenDto.getUserId()); + return new Result().ok(icEpidemicSpecialAttentionService.historyList(formDTO)); + } + /** * Desc: 【疫苗接种关注名单,疫苗接种关注名单】详情 * @param formDTO @@ -185,12 +198,24 @@ public class IcEpidemicSpecialAttentionController { formDTO.setCustomerId(tokenDto.getCustomerId()); formDTO.setUserId(tokenDto.getUserId()); formDTO.setIsPage(false); - PageData pageData = icEpidemicSpecialAttentionService.vaccinationList(formDTO); - // 关注类型,核酸检测:2,疫苗接种:1,行程上报:0 + PageData pageData = icEpidemicSpecialAttentionService.vaccinationList(formDTO); + // 关注类型,核酸检测:2,疫苗接种:1,行程上报:0,历史核酸检测关注:99 if (formDTO.getAttentionType().equals(NumConstant.ONE)){ ExcelUtils.exportExcelToTarget(response, null, pageData.getList(), VaccinationExportExcel.class); }else { - ExcelUtils.exportExcelToTarget(response, null, pageData.getList(), NatExportExcel.class); + Result> isolatedState = epmetAdminOpenFeignClient.dictDataList("isolatedState"); + if (!isolatedState.success()){ + throw new EpmetException("查询字典表数据失败..."+"isolatedState"); + } + Map dictMap = isolatedState.getData().stream().collect(Collectors.toMap(SysDictDataDTO::getDictValue, SysDictDataDTO::getDictLabel)); + pageData.getList().forEach(l -> { + l.setIsolatedState(dictMap.get(l.getIsolatedState())); + }); + if (formDTO.getIsHistory().equals(NumConstant.ONE_STR)){ + ExcelUtils.exportExcelToTarget(response, null, pageData.getList(), NatHistoryExportExcel.class); + }else { + ExcelUtils.exportExcelToTarget(response, null, pageData.getList(), NatExportExcel.class); + } } } @@ -213,4 +238,9 @@ public class IcEpidemicSpecialAttentionController { ExcelPoiUtils.exportExcel(templatePath ,map,fileName,response); } + @PostMapping("pie") + public Result pie(@LoginUser TokenDto tokenDto){ + return new Result().ok(icEpidemicSpecialAttentionService.pie(tokenDto)); + } + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNatCompareRecordController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNatCompareRecordController.java new file mode 100644 index 0000000000..aa611e8252 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNatCompareRecordController.java @@ -0,0 +1,194 @@ +package com.epmet.controller; + +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.write.metadata.WriteSheet; +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.annotation.MaskResponse; +import com.epmet.commons.tools.aop.NoRepeatSubmit; +import com.epmet.commons.tools.constant.AppClientConstant; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.commons.tools.feign.ResultDataResolver; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.*; +import com.epmet.commons.tools.utils.poi.excel.handler.FreezeAndFilter; +import com.epmet.constants.ImportTaskConstants; +import com.epmet.dto.IcNatCompareRecordDTO; +import com.epmet.dto.form.ImportTaskCommonFormDTO; +import com.epmet.dto.form.yqfk.IcNatCompareRecordPageFormDTO; +import com.epmet.dto.result.ImportTaskCommonResultDTO; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; +import com.epmet.service.IcNatCompareRecordService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.io.IOUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpHeaders; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URLEncoder; +import java.nio.file.Path; +import java.util.Date; +import java.util.UUID; + + +/** + * 核算比对记录 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-09-26 + */ +@Slf4j +@RestController +@RequestMapping("icNatCompareRecord") +public class IcNatCompareRecordController implements ResultDataResolver { + + @Autowired + private IcNatCompareRecordService icNatCompareRecordService; + @Autowired + private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient; + + /** + * 未做核酸比对-分页查询 + * @param tokenDto + * @param formDTO + * @return + */ + @RequestMapping("page") + @MaskResponse(fieldNames = { "mobile", "idCard" }, fieldsMaskType = { MaskResponse.MASK_TYPE_MOBILE, MaskResponse.MASK_TYPE_ID_CARD }) + public Result> page(@LoginUser TokenDto tokenDto, @RequestBody IcNatCompareRecordPageFormDTO formDTO){ + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setUserId(tokenDto.getUserId()); + PageData page = icNatCompareRecordService.page(formDTO); + return new Result>().ok(page); + } + + /** + * pc:未做核酸比对-导出 + * @param tokenDto + * @param formDTO + * @param response + */ + @NoRepeatSubmit + @PostMapping("export") + public void export(@LoginUser TokenDto tokenDto, @RequestBody IcNatCompareRecordPageFormDTO formDTO, HttpServletResponse response) { + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setUserId(tokenDto.getUserId()); + // formDTO.setCustomerId("45687aa479955f9d06204d415238f7cc"); + // formDTO.setUserId("35005df15fb0f7c791344f0b424870b7"); + formDTO.setIsPage(false); + ExcelWriter excelWriter = null; + formDTO.setPageSize(NumConstant.TEN_THOUSAND); + int pageNo = formDTO.getPageNo(); + try { + // 这里 需要指定写用哪个class去写 + String today= DateUtils.format(new Date(),DateUtils.DATE_PATTERN_MMDD); + String fileName = "核酸比对".concat(today); + excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), IcNatCompareRecordDTO.class).build(); + WriteSheet writeSheet = EasyExcel.writerSheet("Sheet1").registerWriteHandler(new FreezeAndFilter()).build(); + PageData data = null; + do { + data = icNatCompareRecordService.page(formDTO); + formDTO.setPageNo(++pageNo); + excelWriter.write(data.getList(), writeSheet); + } while (CollectionUtils.isNotEmpty(data.getList()) && data.getList().size() == formDTO.getPageSize()); + + } catch (Exception e) { + log.error("export exception", e); + } finally { + // 千万别忘记finish 会帮忙关闭流 + if (excelWriter != null) { + excelWriter.finish(); + } + } + } + + + /** + * 导入excel + * @return + */ + @NoRepeatSubmit + @PostMapping("import") + public Result importExcel(@LoginUser TokenDto tokenDto, @RequestPart("file") MultipartFile file) { + String userId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID); + + // 1.暂存文件 + String originalFilename = file.getOriginalFilename(); + String extName = originalFilename.substring(originalFilename.lastIndexOf(".")); + + Path fileSavePath; + try { + Path importPath = FileUtils.getAndCreateDirUnderEpmetFilesDir("ic_nat_compare_record", "import"); + fileSavePath = importPath.resolve(UUID.randomUUID().toString().concat(extName)); + } catch (IOException e) { + String errorMsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【未做核酸比对】创建临时存储文件失败:{}", errorMsg); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "文件上传失败", "文件上传失败"); + } + + InputStream is = null; + FileOutputStream os = null; + + try { + is = file.getInputStream(); + os = new FileOutputStream(fileSavePath.toString()); + IOUtils.copy(is, os); + } catch (Exception e) { + log.error("method exception", e); + } finally { + org.apache.poi.util.IOUtils.closeQuietly(is); + org.apache.poi.util.IOUtils.closeQuietly(os); + } + + // 2.生成导入任务记录 + ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO(); + importTaskForm.setOperatorId(userId); + importTaskForm.setBizType(ImportTaskConstants.IC_NAT_COMPARE_RECORD); + importTaskForm.setOriginFileName(originalFilename); + + ImportTaskCommonResultDTO rstData = getResultDataOrThrowsException(commonServiceOpenFeignClient.createImportTask(importTaskForm), + ServiceConstant.EPMET_COMMON_SERVICE, + EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), + "excel未做核酸比对导入文件错误", + "未做核酸比对导入文件失败"); + + // 3.执行导入 + icNatCompareRecordService.execAsyncExcelImport(fileSavePath, rstData.getTaskId(),tokenDto.getCustomerId(),tokenDto.getUserId()); + return new Result(); + } + + /** + * @param response + * @throws IOException + */ + @RequestMapping(value = "template-download", method = {RequestMethod.GET, RequestMethod.POST}) + public void downloadTemplate(HttpServletResponse response) throws IOException { + response.setCharacterEncoding("UTF-8"); + response.addHeader(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS, "Content-Disposition"); + //response.setHeader(HttpHeaders.CONTENT_TYPE, "application/vnd.ms-excel"); + response.setHeader(HttpHeaders.CONTENT_TYPE, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + URLEncoder.encode("未做核酸比对", "UTF-8") + ".xlsx"); + + InputStream is = this.getClass().getClassLoader().getResourceAsStream("excel/ic_nat_compare_record_template.xlsx"); + try { + ServletOutputStream os = response.getOutputStream(); + IOUtils.copy(is, os); + } finally { + if (is != null) { + is.close(); + } + } + } +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNoticeController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNoticeController.java index 325eb71c31..ada0124d86 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNoticeController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNoticeController.java @@ -4,7 +4,6 @@ import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.aop.NoRepeatSubmit; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; -import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; @@ -15,6 +14,7 @@ import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.IcNoticeDTO; import com.epmet.dto.form.IcNoticeFormDTO; import com.epmet.dto.form.SendNoticeFormDTO; +import com.epmet.dto.form.SendNoticeV2FormDTO; import com.epmet.dto.form.SendPointNoticeFormDTO; import com.epmet.dto.result.CommunityInfoResultDTO; import com.epmet.feign.GovOrgFeignClient; @@ -108,4 +108,18 @@ public class IcNoticeController { return new Result(); } + /** + * 行程上报、重点人群关注名单、疫苗接种关注名单这几个页面的发送通知 + * @param tokenDto + * @param formDTO + * @return + */ + @PostMapping("sendNoticeV2") + public Result sendNoticeV2(@LoginUser TokenDto tokenDto, @RequestBody SendNoticeV2FormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, CustomerClientShowGroup.class); + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setStaffId(tokenDto.getUserId()); + icNoticeService.sendNoticeV2(formDTO); + return new Result(); + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcTripReportRecordController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcTripReportRecordController.java index cfc1313c69..aea630040c 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcTripReportRecordController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcTripReportRecordController.java @@ -251,6 +251,7 @@ public class IcTripReportRecordController implements ResultDataResolver { * 导入excel * @return */ + @NoRepeatSubmit @PostMapping("import") public Result importExcel(@LoginUser TokenDto tokenDto, MultipartFile file) { String userId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/OperUserController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/OperUserController.java index 02d15a0b46..a1c2ceb6e8 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/OperUserController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/OperUserController.java @@ -19,12 +19,14 @@ package com.epmet.controller; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.constant.AppClientConstant; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ExcelUtils; +import com.epmet.commons.tools.utils.RSASignature; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; @@ -38,6 +40,7 @@ import com.epmet.excel.OperUserExcel; import com.epmet.service.OperUserService; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; @@ -54,6 +57,8 @@ import java.util.Map; @RestController @RequestMapping("operuser") public class OperUserController { + @Value("${epmet.login.privateKey}") + private String privateKey; @Autowired private OperUserService operUserService; @@ -72,17 +77,43 @@ public class OperUserController { } @PostMapping - public Result save(@RequestBody OperUserDTO dto) { + public Result save(@RequestBody OperUserDTO dto) throws Exception { //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + //解密密码 + if (StringUtils.isNotBlank(dto.getPassword()) && dto.getPassword().length() > NumConstant.FIFTY) { + String password = RSASignature.decryptByPrivateKey(dto.getPassword(), privateKey); + dto.setPassword(password); + } + if (StringUtils.isNotBlank(dto.getEmail()) && dto.getEmail().length() > NumConstant.FIFTY) { + String email = RSASignature.decryptByPrivateKey(dto.getEmail(), privateKey); + dto.setEmail(email); + } + if (StringUtils.isNotBlank(dto.getPhone()) && dto.getPhone().length() > NumConstant.FIFTY) { + String phone = RSASignature.decryptByPrivateKey(dto.getPhone(), privateKey); + dto.setPhone(phone); + } operUserService.save(dto); return new Result(); } @PutMapping - public Result update(@RequestBody OperUserDTO dto) { + public Result update(@RequestBody OperUserDTO dto) throws Exception { //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + //解密密码 + if (StringUtils.isNotBlank(dto.getPassword()) && dto.getPassword().length() > NumConstant.FIFTY) { + String password = RSASignature.decryptByPrivateKey(dto.getPassword(), privateKey); + dto.setPassword(password); + } + if (StringUtils.isNotBlank(dto.getEmail()) && dto.getEmail().length() > NumConstant.FIFTY) { + String email = RSASignature.decryptByPrivateKey(dto.getEmail(), privateKey); + dto.setEmail(email); + } + if (StringUtils.isNotBlank(dto.getPhone()) && dto.getPhone().length() > NumConstant.FIFTY) { + String phone = RSASignature.decryptByPrivateKey(dto.getPhone(), privateKey); + dto.setPhone(phone); + } operUserService.update(dto); return new Result(); } @@ -94,10 +125,22 @@ public class OperUserController { * @return */ @PostMapping(value = "updatePwd") - public Result updatePwd(@LoginUser TokenDto tokenDto,@RequestBody PasswordDTO dto) { + public Result updatePwd(@LoginUser TokenDto tokenDto,@RequestBody PasswordDTO dto) throws Exception { if (StringUtils.isBlank(dto.getNewPassword()) && AppClientConstant.APP_OPER.equals(tokenDto.getClient())){ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"参数错误","参数错误"); } + //解密密码 + if (dto.getPassword().length() > 50) { + String confirmNewPassWord = RSASignature.decryptByPrivateKey(dto.getPassword(), privateKey); + String newPassword = RSASignature.decryptByPrivateKey(dto.getNewPassword(), privateKey); + dto.setPassword(confirmNewPassWord); + dto.setNewPassword(newPassword); + if (StringUtils.isNotBlank(dto.getOldPassword())){ + String oldPassWord = RSASignature.decryptByPrivateKey(dto.getOldPassword(), privateKey); + dto.setOldPassword(oldPassWord); + } + } + //校验长度和 密码是否一致。 operUserService.updatePwd(tokenDto.getUserId(),dto); return new Result(); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBaseInfoController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBaseInfoController.java index a60efed8cc..edd488e9e4 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBaseInfoController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBaseInfoController.java @@ -31,12 +31,10 @@ import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.RegisterRelationDTO; import com.epmet.dto.UserBaseInfoDTO; import com.epmet.dto.form.CommonUserIdFormDTO; +import com.epmet.dto.form.DingLoginResiFormDTO; import com.epmet.dto.form.IssueInitiatorFormDTO; import com.epmet.dto.form.VolunteerRegResiFormDTO; -import com.epmet.dto.result.CustomerUserDetailResultDTO; -import com.epmet.dto.result.ExtUserInfoResultDTO; -import com.epmet.dto.result.ResiUserBaseInfoResultDTO; -import com.epmet.dto.result.UserBaseInfoResultDTO; +import com.epmet.dto.result.*; import com.epmet.entity.UserBaseInfoEntity; import com.epmet.excel.UserBaseInfoExcel; import com.epmet.service.UserBaseInfoService; @@ -221,5 +219,24 @@ public class UserBaseInfoController { public Result getUserInfo(@PathVariable("userId") String userId){ return new Result().ok(userBaseInfoService.getUserInfo(userId)); } + +// 接入流程:https://open.dingtalk.com/document/isvapp-server/unified-authorization-suite-access-process +// 1、获取个人用户token:https://open.dingtalk.com/document/isvapp-server/obtain-user-token +// 2、获取用户通讯录个人信息:https://open.dingtalk.com/document/isvapp-server/dingtalk-retrieve-user-information +// 接口逻辑: +// (1)根据clientId去XXX表找到customerId +// (2)通过1、2拿到手机号之后,根据mobile+customerId去user_base_info表找userId, +// 是否注册居民:register_relation +// (3)没有则生成user、user_Base_info表记录 + /** + * yapi: http://yapi.elinkservice.cn/project/245/interface/api/8118 + * + * @param formDTO + * @return + */ + @PostMapping("dingResiLogin") + public Result dingResiLogin(@RequestBody DingLoginResiFormDTO formDTO){ + return new Result().ok(userBaseInfoService.dingResiLogin(formDTO)); + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserResiInfoController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserResiInfoController.java index 5f8a5ca171..de6daad253 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserResiInfoController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserResiInfoController.java @@ -29,6 +29,7 @@ import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.UserResiInfoDTO; import com.epmet.dto.form.*; +import com.epmet.dto.result.DingAutoRegResDTO; import com.epmet.dto.result.IssueInitiatorResultDTO; import com.epmet.dto.result.StaffAndResiResultDTO; import com.epmet.dto.result.UserResiInfoResultDTO; @@ -243,4 +244,21 @@ public class UserResiInfoController { return new Result>().ok(userResiInfoService.getStaffAndResi(userIds)); } + /** + * 进入网格,自动注册居民 + * + * @Param tokenDto + * @Param userResiInfoDTO + * @Return {@link Result} + * @Author zhaoqifeng + * @Date 2022/9/14 15:34 + */ + @PostMapping("autoreguser-ding") + public Result autoRegister(@LoginUser TokenDto tokenDto, @RequestBody UserResiInfoDTO userResiInfoDTO) { + userResiInfoDTO.setCustomerId(tokenDto.getCustomerId()); + userResiInfoDTO.setUserId(tokenDto.getUserId()); + userResiInfoDTO.setApp(tokenDto.getApp()); + return new Result().ok( userResiInfoService.autoRegister(userResiInfoDTO)); + } + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java index b34065223f..1c127d7aa5 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java @@ -45,6 +45,8 @@ public interface CustomerStaffDao extends BaseDao { **/ List selectListCustomerStaffDTO(String mobile); + List listCustomerStaffByAccount(@Param("userAccount") String userAccount); + /** * @param formDTO * @return com.epmet.dto.CustomerStaffDTO @@ -54,6 +56,15 @@ public interface CustomerStaffDao extends BaseDao { **/ CustomerStaffDTO selectListCustomerStaffInfo(CustomerStaffFormDTO formDTO); + /** + * @param formDTO + * @return com.epmet.dto.CustomerStaffDTO + * @Author zhy + * @Description 根据账户+客户id获取工作人员基本信息 + * @Date 2020/4/20 14:08 + **/ + CustomerStaffDTO selectListCustomerStaffInfoByAccount(CustomerStaffByAccountFormDTO formDTO); + CustomerStaffDTO selectStaffInfoByUserId(CustomerStaffDTO formDTO); /** @@ -147,6 +158,14 @@ public interface CustomerStaffDao extends BaseDao { **/ List selectStaff(ThirdCustomerStaffFormDTO formDTO); + /** + * @param formDTO + * @return + * @Author zhy + * @Description 根据客户ID、账户查询政府端工作人员基本信息 + **/ + List selectStaffByAccount(ThirdCustomerStaffByAccountFormDTO formDTO); + /** * @Description 查询工作人员的信息 * @param userIds diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/DataSyncConfigDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/DataSyncConfigDao.java new file mode 100644 index 0000000000..d3a2c600ef --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/DataSyncConfigDao.java @@ -0,0 +1,59 @@ +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.DataSyncConfigDTO; +import com.epmet.dto.DataSyncScopeDTO; +import com.epmet.dto.form.ConfigSwitchFormDTO; +import com.epmet.dto.result.NatUserInfoResultDTO; +import com.epmet.entity.DataSyncConfigEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 数据更新配置表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-09-26 + */ +@Mapper +public interface DataSyncConfigDao extends BaseDao { + + /** + * Desc: 【数据配置】配置开关 + * @param formDTO + * @author zxc + * @date 2022/9/26 14:36 + */ + void configSwitch(ConfigSwitchFormDTO formDTO); + + /** + * Desc: 【数据配置】列表 + * @param customerId + * @author zxc + * @date 2022/9/26 15:04 + */ + List list(@Param("customerId")String customerId); + + List scopeList(@Param("id")String id); + + /** + * Desc: 删除范围 + * @param dataSyncConfigId + * @author zxc + * @date 2022/9/26 15:46 + */ + void delScope(@Param("dataSyncConfigId")String dataSyncConfigId); + + /** + * Desc: 根据范围查询居民证件号 + * @param list + * @author zxc + * @date 2022/9/27 09:23 + */ + List getIdCardsByScope(@Param("list") List list); + + List getUserIdByIdCard(@Param("list") List list); + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/DataSyncScopeDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/DataSyncScopeDao.java new file mode 100644 index 0000000000..d9f41befd1 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/DataSyncScopeDao.java @@ -0,0 +1,16 @@ +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.DataSyncScopeEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 数据更新范围表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-09-26 + */ +@Mapper +public interface DataSyncScopeDao extends BaseDao { + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcEpidemicSpecialAttentionDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcEpidemicSpecialAttentionDao.java index 0fb3e579d1..d57e5b7f94 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcEpidemicSpecialAttentionDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcEpidemicSpecialAttentionDao.java @@ -3,6 +3,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.form.AttentionDetailFormDTO; import com.epmet.dto.form.VaccinationListFormDTO; +import com.epmet.dto.result.NatPieResultDTO; import com.epmet.dto.result.VaccinationListResultDTO; import com.epmet.entity.IcEpidemicSpecialAttentionEntity; import org.apache.ibatis.annotations.Mapper; @@ -51,6 +52,8 @@ public interface IcEpidemicSpecialAttentionDao extends BaseDao list,@Param("attentionType")Integer attentionType); + void addAttention(@Param("list")List list,@Param("attentionType")Integer attentionType); + void addExistAttention(@Param("list") List list,@Param("attentionType")Integer attentionType); /** * Desc: 查询已经存在的关注 @@ -69,4 +72,8 @@ public interface IcEpidemicSpecialAttentionDao extends BaseDao getIdCardList(@Param("customerId") String customerId,@Param("idCardSet") List idCardSet, @Param("attentionType") Integer attentionType); + + List isolatedList(@Param("agencyId")String agencyId); + + Integer getHistoryCount(@Param("agencyId")String agencyId); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcNatCompareRecRelationDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcNatCompareRecRelationDao.java new file mode 100644 index 0000000000..391127cfb3 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcNatCompareRecRelationDao.java @@ -0,0 +1,29 @@ +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.IcNatCompareRecRelationEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * 核酸比对组织关系表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-09-27 + */ +@Mapper +public interface IcNatCompareRecRelationDao extends BaseDao { + + /** + * + * @param customerId + * @param compareRecId + * @param agencyId + * @param importDate yyyyMMdd + * @return + */ + IcNatCompareRecRelationEntity selectExist(@Param("customerId") String customerId, + @Param("compareRecId") String compareRecId, + @Param("agencyId") String agencyId, + @Param("importDate") String importDate); +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcNatCompareRecordDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcNatCompareRecordDao.java new file mode 100644 index 0000000000..ef0273fc0f --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcNatCompareRecordDao.java @@ -0,0 +1,30 @@ +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.IcNatCompareRecordDTO; +import com.epmet.dto.form.yqfk.IcNatCompareRecordPageFormDTO; +import com.epmet.entity.IcNatCompareRecordEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 核算比对记录 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-09-26 + */ +@Mapper +public interface IcNatCompareRecordDao extends BaseDao { + + /** + * 分页查询 + * @param formDTO + * @return + */ + List pageList(IcNatCompareRecordPageFormDTO formDTO); + + + IcNatCompareRecordEntity selectByIdCard(@Param("customerId") String customerId, @Param("idCard")String idCard); +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcNatDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcNatDao.java index 31ef9ec667..3507473187 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcNatDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcNatDao.java @@ -5,6 +5,7 @@ import com.epmet.dto.IcNatDTO; import com.epmet.dto.form.MyNatListFormDTO; import com.epmet.dto.result.MyNatListResultDTO; import com.epmet.dto.result.NatListResultDTO; +import com.epmet.dto.result.NatUserInfoResultDTO; import com.epmet.entity.IcNatEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -59,4 +60,6 @@ public interface IcNatDao extends BaseDao { */ int updateIsResiFlag(@Param("customerId") String customerId, @Param("icResiUserId") String icResiUserId); + List getExistNatInfo(@Param("list") List entities); + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBaseInfoDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBaseInfoDao.java index ab4ca3ec5c..b415ca67c8 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBaseInfoDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBaseInfoDao.java @@ -92,4 +92,6 @@ public interface UserBaseInfoDao extends BaseDao { @Param("excludeUserId")String excludeUserId); String selectIdCard(String userId); + + UserBaseInfoEntity selectUserByMobile(@Param("customerId") String customerId, @Param("mobile")String mobile); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/CustomerStaffEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/CustomerStaffEntity.java index 690bf326c2..aa19464f9e 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/CustomerStaffEntity.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/CustomerStaffEntity.java @@ -42,6 +42,11 @@ public class CustomerStaffEntity extends BaseEpmetEntity { */ private String userId; + /** + * 账户 + */ + private String userAccount; + /** * 真实姓名 */ diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/DataSyncConfigEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/DataSyncConfigEntity.java new file mode 100644 index 0000000000..bcacb6ab95 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/DataSyncConfigEntity.java @@ -0,0 +1,53 @@ +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 数据更新配置表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-09-26 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("data_sync_config") +public class DataSyncConfigEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID。如果该角色由客户定制,其下的机关和部门都不再各自定制自己的角色,这个字段会比较有用。包括通用角色以及客户定制角色。 + */ + private String customerId; + + /** + * 部门编码 + */ + private String deptCode; + + /** + * 部门名称 + */ + private String deptName; + + /** + * 数据名称 + */ + private String dataName; + + /** + * 开启:open;关闭:closed + */ + private String switchStatus; + + private String dataCode; + + /** + * 排序 + */ + private Integer sort; + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/DataSyncScopeEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/DataSyncScopeEntity.java new file mode 100644 index 0000000000..a106b7e7db --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/DataSyncScopeEntity.java @@ -0,0 +1,52 @@ +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 数据更新范围表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-09-26 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("data_sync_scope") +public class DataSyncScopeEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID。如果该角色由客户定制,其下的机关和部门都不再各自定制自己的角色,这个字段会比较有用。包括通用角色以及客户定制角色。 + */ + private String customerId; + + /** + * 数据更新配置表主键 + */ + private String dataSyncConfigId; + + /** + * 网格:grid, + * 组织:agency + */ + private String orgType; + + /** + * 组织或者网格id + */ + private String orgId; + + /** + * org_id的上级 + */ + private String pid; + + /** + * org_id的全路径,包含自身 + */ + private String orgIdPath; + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcEpidemicSpecialAttentionEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcEpidemicSpecialAttentionEntity.java index 25a853dd55..a22f3f3537 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcEpidemicSpecialAttentionEntity.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcEpidemicSpecialAttentionEntity.java @@ -43,6 +43,16 @@ public class IcEpidemicSpecialAttentionEntity extends BaseEpmetEntity { */ private Integer isAttention; + /** + * 是否历史关注,1是0否 + */ + private String isHistory; + + /** + * 隔离类型,来自字典表;集中隔离:0;居家隔离1;居家健康监测2;已出隔离期3 + */ + private String isolatedState; + /** * 关注类型,核酸检测:2,疫苗接种:1,行程上报:0 */ diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcNatCompareRecRelationEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcNatCompareRecRelationEntity.java new file mode 100644 index 0000000000..daffebedd9 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcNatCompareRecRelationEntity.java @@ -0,0 +1,77 @@ +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 核酸比对组织关系表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-09-27 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("ic_nat_compare_rec_relation") +public class IcNatCompareRecRelationEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户Id + */ + private String customerId; + + /** + * ic_nat_compare_record.id + */ + private String compareRecId; + + /** + * 导入日期:yyyyMMdd + */ + private String importDate; + + /** + * 导入时间,同一天内导入多次需要更新此列值 + */ + private Date importTime; + + /** + * 操作人员所属组织id + */ + private String agencyId; + /** + * 组织名称 + */ + private String agencyName; + /** + * agency_id的上级 + */ + private String pid; + + /** + * agency_id组织的所有上级 + */ + private String pids; + + /** + * 最近一次操作人 + */ + private String staffId; + + /** + * 最近一次操作人姓名 + */ + private String staffName; + + /** + * 是否本社区(agency_id)下居民(0:否 1:是) + */ + private String isAgencyUser; + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcNatCompareRecordEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcNatCompareRecordEntity.java new file mode 100644 index 0000000000..0110312ed9 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcNatCompareRecordEntity.java @@ -0,0 +1,71 @@ +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 核酸比对记录 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-09-26 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("ic_nat_compare_record") +public class IcNatCompareRecordEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + private String customerId; + /** + * 姓名 + */ + private String name; + + /** + * 身份证 + */ + private String idCard; + + /** + * 手机号 + */ + private String mobile; + + /** + * 是否客户下居民(0:否 1:是) + */ + private String isResiUser; + + /** + * 是否客户下居民,ic_resi_user.id + */ + private String icResiUserId; + + /** + * 最近一次核酸时间:接口填入 + */ + private Date latestNatTime; + + /** + * 检测结果(0:阴性 1:阳性):接口填入 + */ + private String natResult; + + /** + * 检测地点:接口填入 + */ + private String natAddress; + /** + * 联系地址:接口填入 + */ + private String contactAddress; + /** + * 最新一次导入时间,对应ic_nat_compare_rec_relation.IMPORT_TIME + */ + private Date latestImportTime; +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcNatEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcNatEntity.java index 7744ce67c6..50a9eed8e7 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcNatEntity.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcNatEntity.java @@ -89,4 +89,13 @@ public class IcNatEntity extends BaseEpmetEntity { */ private String attachmentUrl; + @TableField(exist = false) + private String agencyId; + + @TableField(exist = false) + private String pids; + + @TableField(exist = false) + private Boolean existStatus = false; + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcNoticeEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcNoticeEntity.java index 133d56dfcd..41deda8a70 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcNoticeEntity.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcNoticeEntity.java @@ -57,4 +57,8 @@ public class IcNoticeEntity extends BaseEpmetEntity { */ private String orgName; + /** + * 发送结果:1成功,0失败 + */ + private String sendRes; } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/ImportEpidemicSpecialAttention.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/ImportEpidemicSpecialAttention.java index 2f690d2d7c..52135be6e5 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/ImportEpidemicSpecialAttention.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/ImportEpidemicSpecialAttention.java @@ -45,6 +45,9 @@ public class ImportEpidemicSpecialAttention extends ExcelVerifyInfo { @Excel(name = "备注") private String remark; + @Excel(name = "隔离状态") + private String isolatedState; + @ExcelIgnore private Integer attentionType; diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/NatExportExcel.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/NatExportExcel.java index cc3d827af0..fd404ca278 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/NatExportExcel.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/NatExportExcel.java @@ -29,7 +29,10 @@ public class NatExportExcel { @Excel(name = "关注原因",width = 40) private String reason; - @Excel(name = "最近一次通知时间",width = 20) - private String lastInformTime; + @Excel(name = "最后一次核酸时间",width = 20) + private String lastNatTime; + + @Excel(name = "隔离状态",width = 20) + private String isolatedState; } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/NatHistoryExportExcel.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/NatHistoryExportExcel.java new file mode 100644 index 0000000000..74bbd41676 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/NatHistoryExportExcel.java @@ -0,0 +1,40 @@ +package com.epmet.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +/** + * @Author zxc + * @DateTime 2022/3/29 10:24 + * @DESC + */ +@Data +public class NatHistoryExportExcel { + + @Excel(name = "排序",width = 10) + private Integer sort; + + @Excel(name = "姓名",width = 20) + private String name; + + @Excel(name = "电话",width = 20) + private String mobile; + @Excel(name = "所属房屋",width = 20) + private String allName; + + @Excel(name = "身份证",width = 30) + private String idCard; + + @Excel(name = "备注",width = 40) + private String remark; + + @Excel(name = "关注原因",width = 40) + private String reason; + + @Excel(name = "最后一次核酸时间",width = 20) + private String lastNatTime; + + @Excel(name = "隔离状态",width = 20) + private String isolatedState; + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/data/IcNatCompareRecordExcelData.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/data/IcNatCompareRecordExcelData.java new file mode 100644 index 0000000000..0a1e02cbf7 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/data/IcNatCompareRecordExcelData.java @@ -0,0 +1,48 @@ +package com.epmet.excel.data; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * @Description + * @Author yzm + * @Date 2022/9/27 9:41 + */ +@Data +public class IcNatCompareRecordExcelData { + @NotBlank(message = "姓名为必填项") + @ExcelProperty("姓名") + private String name; + + @NotBlank(message = "身份证号为必填项") + @ExcelProperty("身份证号") + private String idCard; + + @NotBlank(message = "联系方式为必填项") + @ExcelProperty("联系方式") + private String mobile; + + @Data + public static class ErrorRow { + + @ExcelProperty("姓名") + @ColumnWidth(20) + private String name; + + @ColumnWidth(20) + @ExcelProperty("身份证号") + private String idCard; + + @ExcelProperty("联系方式") + @ColumnWidth(20) + private String mobile; + + @ColumnWidth(60) + @ExcelProperty("错误信息") + private String errorInfo; + } +} + diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/IcNatCompareRecordExcelImportListener.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/IcNatCompareRecordExcelImportListener.java new file mode 100644 index 0000000000..03c01a2f37 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/IcNatCompareRecordExcelImportListener.java @@ -0,0 +1,165 @@ +package com.epmet.excel.handler; + +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.read.listener.ReadListener; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; +import com.epmet.commons.tools.dto.result.YtHsjcResDTO; +import com.epmet.commons.tools.dto.result.YtHsjcResDetailDTO; +import com.epmet.commons.tools.enums.EnvEnum; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.commons.tools.exception.ValidateException; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.commons.tools.utils.ObjectUtil; +import com.epmet.commons.tools.utils.YtHsResUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.entity.IcNatCompareRecordEntity; +import com.epmet.excel.data.IcNatCompareRecordExcelData; +import com.epmet.service.impl.IcNatCompareRecordServiceImpl; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * @Description + * @Author yzm + * @Date 2022/9/27 9:42 + */ +@Slf4j +public class IcNatCompareRecordExcelImportListener implements ReadListener { + + /** + * 最大条数阈值 + */ + public static final int MAX_THRESHOLD = 200; + /** + * 当前操作用户 + */ + private CustomerStaffInfoCacheResult staffInfo; + private String customerId; + private IcNatCompareRecordServiceImpl icNatCompareRecordService; + /** + * 数据 + */ + private List datas = new ArrayList<>(); + + /** + * 错误项列表 + */ + private List errorRows = new ArrayList<>(); + private Date importTime; + /** + * 导入日期:yyyyMMdd + */ + private String importDate; + public IcNatCompareRecordExcelImportListener(String customerId, CustomerStaffInfoCacheResult staffInfo,String importDate,Date importTime, IcNatCompareRecordServiceImpl icNatCompareRecordService) { + this.customerId = customerId; + this.staffInfo = staffInfo; + this.icNatCompareRecordService = icNatCompareRecordService; + this.importDate=importDate; + this.importTime=importTime; + } + + + @Override + public void invoke(IcNatCompareRecordExcelData data, AnalysisContext analysisContext) { + try { + // log.warn("有数据吗?"+JSON.toJSONString(data)); + // 不能为空先校验数据 + ValidatorUtils.validateEntity(data); + // 去除空格 + ObjectUtil.objectToTrim(data); + IcNatCompareRecordEntity compareRecordEntity = ConvertUtils.sourceToTarget(data, IcNatCompareRecordEntity.class); + compareRecordEntity.setCustomerId(customerId); + compareRecordEntity.setLatestNatTime(null); + compareRecordEntity.setNatAddress(StrConstant.EPMETY_STR); + compareRecordEntity.setNatResult(StrConstant.EPMETY_STR); + // 开发和测试没法测试,只能写死只有生产才去调用了 烟台客户id:1535072605621841922 + EnvEnum currentEnv = EnvEnum.getCurrentEnv(); + if (EnvEnum.PROD.getCode().equals(currentEnv.getCode()) && "1535072605621841922".equals(customerId)) { + // 调用烟台api获取核酸检测结果 + YtHsjcResDTO hsjcResDTO = YtHsResUtils.hsjc(data.getIdCard(), 1, 1); + if (null != hsjcResDTO && CollectionUtils.isNotEmpty(hsjcResDTO.getData()) && null != hsjcResDTO.getData().get(0)) { + YtHsjcResDetailDTO ytHsjcResDetailDTO = hsjcResDTO.getData().get(0); + String testTime = ytHsjcResDetailDTO.getTest_time(); + if (StringUtils.isNotBlank(testTime)) { + // 赋值最近一次核酸时间 + compareRecordEntity.setLatestNatTime(DateUtils.parse(testTime, DateUtils.DATE_TIME_PATTERN)); + } + // 赋值检测地点 + compareRecordEntity.setNatAddress(StringUtils.isNotBlank(ytHsjcResDetailDTO.getSampling_org_pcr()) ? ytHsjcResDetailDTO.getSampling_org_pcr() : StrConstant.EPMETY_STR); + + // "sample_result_pcr":"2",// 核酸检测结果 1:阳性,2:阴性 + String sample_result_pcr = ytHsjcResDetailDTO.getSample_result_pcr(); + if (NumConstant.ONE_STR.equals(sample_result_pcr)) { + // 检测结果(0:阴性 1:阳性):接口填入 + compareRecordEntity.setNatResult(NumConstant.ONE_STR); + } else if (NumConstant.TWO_STR.equals(sample_result_pcr)) { + compareRecordEntity.setNatResult(NumConstant.ZERO_STR); + } + compareRecordEntity.setContactAddress(StringUtils.isNotBlank(ytHsjcResDetailDTO.getAddress()) ? ytHsjcResDetailDTO.getAddress() : StrConstant.EPMETY_STR); + } + } + datas.add(compareRecordEntity); + + if (datas.size() == MAX_THRESHOLD) { + execPersist(); + } + } catch (Exception e) { + String errorMsg = null; + if (e instanceof ValidateException) { + errorMsg = ((ValidateException) e).getMsg(); + } else if (e instanceof EpmetException) { + errorMsg = ((EpmetException) e).getMsg(); + } else { + errorMsg = "未知错误"; + log.error("【未做核酸比对导入】出错:{}", ExceptionUtils.getErrorStackTrace(e)); + } + IcNatCompareRecordExcelData.ErrorRow errorRow = new IcNatCompareRecordExcelData.ErrorRow(); + errorRow.setIdCard(data.getIdCard()); + errorRow.setName(data.getName()); + errorRow.setMobile(data.getMobile()); + errorRow.setErrorInfo(errorMsg); + errorRows.add(errorRow); + } + } + + @Override + public void doAfterAllAnalysed(AnalysisContext analysisContext) { + // 最后几条达不到阈值,这里必须再调用一次 + execPersist(); + } + + + /** + * 执行持久化 + */ + private void execPersist() { + // ic_nat_compare_record、ic_nat_compare_rec_relation + try { + if (datas != null && datas.size() > 0) { + icNatCompareRecordService.batchPersist(datas, staffInfo,importDate,importTime, this); + } + } finally { + datas.clear(); + } + } + + + /** + * 获取错误行 + * + * @return + */ + public List getErrorRows() { + return errorRows; + } +} + diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java index f6ca859101..b2a3442172 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java @@ -105,6 +105,15 @@ public interface CustomerStaffService extends BaseService { **/ Result> getCustsomerStaffByPhone(String mobile); + /** + * @param account 账户 + * @return com.epmet.commons.tools.utils.Result + * @Author zhy + * @Description 根据账户查询政府端工作人员基本信息,校验用户是否存在 + * @Date 2020/4/18 14:07 + **/ + Result> getCustsomerStaffByAccount(String account); + /** * @param formDTO * @return com.epmet.commons.tools.utils.Result @@ -114,6 +123,15 @@ public interface CustomerStaffService extends BaseService { **/ Result getCustomerStaffInfo(CustomerStaffFormDTO formDTO); + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author zhy + * @Description 根据账户+客户id获取工作人员基本信息 + * @Date 2020/4/20 14:05 + **/ + Result getCustomerStaffInfoByAccount(CustomerStaffByAccountFormDTO formDTO); + /** * 根据用户ID获取工作人员基本信息 * @@ -169,6 +187,15 @@ public interface CustomerStaffService extends BaseService { */ Result addStaff(StaffSubmitFromDTO fromDTO); + /** + * 人员添加 + * + * @param fromDTO 参数 + * @return Result + */ + Result addStaffByAccount(StaffSubmitAccountFromDTO fromDTO); + + /** * 人员编辑 * @@ -177,6 +204,14 @@ public interface CustomerStaffService extends BaseService { */ Result editStaff(StaffSubmitFromDTO fromDTO); + /** + * 人员编辑 + * + * @param fromDTO 参数 + * @return Result + */ + Result editStaffByAccount(StaffSubmitAccountFromDTO fromDTO); + /** * 人员详情 * @@ -259,6 +294,14 @@ public interface CustomerStaffService extends BaseService { **/ List getCustsomerStaffByIdAndPhone(ThirdCustomerStaffFormDTO formDTO); + /** + * @param formDTO + * @return + * @Author zhy + * @Description 根据客户ID、手机号查询政府端工作人员基本信息,校验用户是否存在 + **/ + List getCustsomerStaffByIdAndAccount(ThirdCustomerStaffByAccountFormDTO formDTO); + /** * @Description 查询工作人员的信息 * @param formDTO diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/DataSyncConfigService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/DataSyncConfigService.java new file mode 100644 index 0000000000..1e0ad7162b --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/DataSyncConfigService.java @@ -0,0 +1,86 @@ +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.dto.form.PageFormDTO; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.dto.DataSyncConfigDTO; +import com.epmet.dto.form.ConfigSwitchFormDTO; +import com.epmet.dto.form.NatInfoScanTaskFormDTO; +import com.epmet.dto.form.ScopeSaveFormDTO; +import com.epmet.entity.DataSyncConfigEntity; + +/** + * 数据更新配置表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-09-26 + */ +public interface DataSyncConfigService extends BaseService { + + /** + * 单条查询 + * + * @param id + * @return DataSyncConfigDTO + * @author generator + * @date 2022-09-26 + */ + DataSyncConfigDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2022-09-26 + */ + void save(DataSyncConfigDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2022-09-26 + */ + void update(DataSyncConfigDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2022-09-26 + */ + void delete(String[] ids); + + /** + * Desc: 【数据配置】配置开关 + * @param formDTO + * @author zxc + * @date 2022/9/26 14:36 + */ + void configSwitch(ConfigSwitchFormDTO formDTO); + + /** + * Desc: 【数据配置】列表 + * @param tokenDto + * @author zxc + * @date 2022/9/26 15:04 + */ + PageData list(TokenDto tokenDto, PageFormDTO formDTO); + + /** + * Desc: 【数据配置】范围保存 + * @param formDTO + * @author zxc + * @date 2022/9/26 15:41 + */ + void scopeSave(ScopeSaveFormDTO formDTO); + + void natInfoScanTask(NatInfoScanTaskFormDTO formDTO); +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/DataSyncScopeService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/DataSyncScopeService.java new file mode 100644 index 0000000000..d0588c10d9 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/DataSyncScopeService.java @@ -0,0 +1,78 @@ +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.DataSyncScopeDTO; +import com.epmet.entity.DataSyncScopeEntity; + +import java.util.List; +import java.util.Map; + +/** + * 数据更新范围表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-09-26 + */ +public interface DataSyncScopeService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2022-09-26 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2022-09-26 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return DataSyncScopeDTO + * @author generator + * @date 2022-09-26 + */ + DataSyncScopeDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2022-09-26 + */ + void save(DataSyncScopeDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2022-09-26 + */ + void update(DataSyncScopeDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2022-09-26 + */ + void delete(String[] ids); +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcEpidemicSpecialAttentionService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcEpidemicSpecialAttentionService.java index 5391f1c1ae..8986660ec2 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcEpidemicSpecialAttentionService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcEpidemicSpecialAttentionService.java @@ -8,6 +8,7 @@ import com.epmet.dto.form.AttentionDetailFormDTO; import com.epmet.dto.form.CancelAttentionPackageFormDTO; import com.epmet.dto.form.VaccinationAddFormDTO; import com.epmet.dto.form.VaccinationListFormDTO; +import com.epmet.dto.result.NatPieResultDTO; import com.epmet.dto.result.VaccinationListResultDTO; import com.epmet.entity.IcEpidemicSpecialAttentionEntity; @@ -90,6 +91,7 @@ public interface IcEpidemicSpecialAttentionService extends BaseService { + + /** + * 默认分页 + * + * @param formDTO + * @return PageData + * @author generator + * @date 2022-09-26 + */ + PageData page(IcNatCompareRecordPageFormDTO formDTO); + + void execAsyncExcelImport(Path fileSavePath, String taskId, String customerId, String userId); +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNoticeService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNoticeService.java index 9c65229972..9be6485b37 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNoticeService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNoticeService.java @@ -5,6 +5,7 @@ import com.epmet.commons.tools.page.PageData; import com.epmet.dto.IcNoticeDTO; import com.epmet.dto.form.IcNoticeFormDTO; import com.epmet.dto.form.SendNoticeFormDTO; +import com.epmet.dto.form.SendNoticeV2FormDTO; import com.epmet.dto.form.SendPointNoticeFormDTO; import com.epmet.entity.IcNoticeEntity; @@ -115,4 +116,10 @@ public interface IcNoticeService extends BaseService { * @return */ Map getUserLatestNoticeTime(String customerId,List idCardSet); + + /** + * 行程上报、重点人群关注名单、疫苗接种关注名单这几个页面的发送通知 + * @param formDTO + */ + void sendNoticeV2(SendNoticeV2FormDTO formDTO); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBaseInfoService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBaseInfoService.java index f66453c243..ccd55f362c 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBaseInfoService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBaseInfoService.java @@ -24,11 +24,9 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.RegisterRelationDTO; import com.epmet.dto.UserBaseInfoDTO; import com.epmet.dto.form.CommonUserIdFormDTO; +import com.epmet.dto.form.DingLoginResiFormDTO; import com.epmet.dto.form.VolunteerRegResiFormDTO; -import com.epmet.dto.result.CustomerUserDetailResultDTO; -import com.epmet.dto.result.ExtUserInfoResultDTO; -import com.epmet.dto.result.ResiUserBaseInfoResultDTO; -import com.epmet.dto.result.UserBaseInfoResultDTO; +import com.epmet.dto.result.*; import com.epmet.entity.UserBaseInfoEntity; import java.util.List; @@ -213,4 +211,13 @@ public interface UserBaseInfoService extends BaseService { * @Date 2022/6/15 16:09 */ ResiUserInfoCache getUserInfo(String userId); + + /** + * 钉钉用户注册 + * @Param formDTO + * @Return {@link DingLoginResiResDTO} + * @Author zhaoqifeng + * @Date 2022/9/15 11:17 + */ + DingLoginResiResDTO dingResiLogin(DingLoginResiFormDTO formDTO); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserResiInfoService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserResiInfoService.java index 9e3a9f86fe..d29db102e1 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserResiInfoService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserResiInfoService.java @@ -22,6 +22,7 @@ import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.UserResiInfoDTO; import com.epmet.dto.form.*; +import com.epmet.dto.result.DingAutoRegResDTO; import com.epmet.dto.result.IssueInitiatorResultDTO; import com.epmet.dto.result.StaffAndResiResultDTO; import com.epmet.dto.result.UserResiInfoResultDTO; @@ -213,4 +214,14 @@ public interface UserResiInfoService extends BaseService { */ List getStaffAndResi(List userIds); + /** + * 进入网格,自动注册居民 + * + * @Param userResiInfoDTO + * @Return + * @Author zhaoqifeng + * @Date 2022/9/14 14:19 + */ + DingAutoRegResDTO autoRegister(UserResiInfoDTO userResiInfoDTO); + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java index ecfcade3fd..2a4585eb8a 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java @@ -170,6 +170,16 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl>().ok(customerStaffDTOList); } + @Override + public Result> getCustsomerStaffByAccount(String userAccount) { + //判断用户是否存在 + List customerStaffDTOList = baseDao.listCustomerStaffByAccount(userAccount); + if (null == customerStaffDTOList || customerStaffDTOList.size() == 0) { + logger.warn(String.format("根据账户查询用户异常,账户:[%s],code[%s],msg[%s]", userAccount, EpmetErrorCode.GOV_STAFF_ACCOUNT_NOT_EXISTS.getCode(), EpmetErrorCode.GOV_STAFF_ACCOUNT_NOT_EXISTS.getMsg())); + return new Result().error(EpmetErrorCode.GOV_STAFF_ACCOUNT_NOT_EXISTS.getCode()); + } + return new Result>().ok(customerStaffDTOList); + } @Override public Result getCustomerStaffInfo(CustomerStaffFormDTO formDTO) { @@ -186,6 +196,21 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl().ok(customerStaffDTO); } + @Override + public Result getCustomerStaffInfoByAccount(CustomerStaffByAccountFormDTO formDTO) { + CustomerStaffDTO customerStaffDTO = baseDao.selectListCustomerStaffInfoByAccount(formDTO); + if (null == customerStaffDTO) { + logger.warn(String.format("根据账户查询用户异常,账户:[%s],code[%s],msg[%s]", formDTO.getUserAccount(), EpmetErrorCode.GOV_STAFF_ACCOUNT_NOT_EXISTS.getCode(), EpmetErrorCode.GOV_STAFF_ACCOUNT_NOT_EXISTS.getMsg())); + return new Result().error(EpmetErrorCode.GOV_STAFF_ACCOUNT_NOT_EXISTS.getCode()); + } + //判断用户是否已被禁用 + if (null != customerStaffDTO && UserConstant.DISABLED.equals(customerStaffDTO.getEnableFlag())) { + logger.warn(String.format("根据账户查询用户异常,账户:[%s],客户id:[%s],code[%s],msg[%s]", formDTO.getUserAccount(), formDTO.getCustomerId(), EpmetErrorCode.GOV_STAFF_DISABLED.getCode(), EpmetErrorCode.GOV_STAFF_DISABLED.getMsg())); + return new Result().error(EpmetErrorCode.GOV_STAFF_DISABLED.getCode()); + } + return new Result().ok(customerStaffDTO); + } + @Override public Result getCustomerStaffInfoByUserId(CustomerStaffDTO formDTO) { CustomerStaffDTO customerStaffDTO = baseDao.selectStaffInfoByUserId(formDTO); @@ -265,11 +290,16 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl().ok(ConvertUtils.sourceToTarget(staffEntity, CustomerStaffDTO.class)); } + + @Override + @Transactional(rollbackFor = Exception.class) + public Result addStaffByAccount(StaffSubmitAccountFromDTO fromDTO) { + CustomerStaffFormDTO customerStaffFormDTO = new CustomerStaffFormDTO(); + customerStaffFormDTO.setCustomerId(fromDTO.getCustomerId()); + customerStaffFormDTO.setMobile(fromDTO.getMobile()); + CustomerStaffDTO customerStaffDTO = baseDao.selectListCustomerStaffInfo(customerStaffFormDTO); + if (null != customerStaffDTO) { + return new Result().error(EpmetErrorCode.MOBILE_USED.getCode(), EpmetErrorCode.MOBILE_USED.getMsg()); + } + CustomerStaffByAccountFormDTO customerStaffAccountFormDTO = new CustomerStaffByAccountFormDTO(); + customerStaffAccountFormDTO.setCustomerId(fromDTO.getCustomerId()); + customerStaffAccountFormDTO.setUserAccount(fromDTO.getUserAccount()); + customerStaffDTO = baseDao.selectListCustomerStaffInfoByAccount(customerStaffAccountFormDTO); + if (null != customerStaffDTO) { + return new Result().error(EpmetErrorCode.ACCOUNT_USED.getCode(), EpmetErrorCode.ACCOUNT_USED.getMsg()); + } + //USER表插入数据 + UserEntity userEntity = new UserEntity(); + userEntity.setFromApp(fromDTO.getApp()); + userEntity.setFromClient(fromDTO.getClient()); + userEntity.setCustomerId(fromDTO.getCustomerId()); + userService.insert(userEntity); + //Customer_Staff表插入数据 + CustomerStaffEntity staffEntity = new CustomerStaffEntity(); + staffEntity.setCustomerId(fromDTO.getCustomerId()); + staffEntity.setUserId(userEntity.getId()); + staffEntity.setUserAccount(fromDTO.getUserAccount()); + staffEntity.setRealName(fromDTO.getName()); + staffEntity.setMobile(fromDTO.getMobile()); + staffEntity.setActiveFlag(CustomerStaffConstant.INACTIVE); + staffEntity.setGender(fromDTO.getGender()); + staffEntity.setWorkType(fromDTO.getWorkType()); + staffEntity.setEnableFlag(CustomerStaffConstant.ENABLE); + staffEntity.setPassword(PasswordUtils.encode(fromDTO.getPwd())); + staffEntity.setIdCard(fromDTO.getIdCard()); + baseDao.insert(staffEntity); + + //工作人员角色关联表 + fromDTO.getRoles().forEach(role -> { + StaffRoleEntity staffRoleEntity = new StaffRoleEntity(); + staffRoleEntity.setStaffId(userEntity.getId()); + staffRoleEntity.setRoleId(role); + staffRoleEntity.setOrgId(fromDTO.getAgencyId()); + staffRoleEntity.setCustomerId(fromDTO.getCustomerId()); + staffRoleService.insert(staffRoleEntity); + }); + + // 角色放缓存 + CustomerAgencyUserRoleDTO dto = new CustomerAgencyUserRoleDTO(); + List roleKeyValue = govStaffRoleDao.selectRoleKeyName(fromDTO.getRoles()); + dto.setCustomerId(fromDTO.getCustomerId()); + dto.setStaffId(userEntity.getId()); + dto.setAgencyId(fromDTO.getAgencyId()); + Map m = new HashMap(16); + roleKeyValue.forEach(r -> { + m.put(r.getRoleKey(), r.getRoleName()); + }); + dto.setRoles(m); + CustomerStaffRedis.delStaffInfoFormCache(dto.getCustomerId(), dto.getStaffId()); + + return new Result().ok(ConvertUtils.sourceToTarget(staffEntity, CustomerStaffDTO.class)); + } + @Override @Transactional(rollbackFor = Exception.class) public Result editStaff(StaffSubmitFromDTO fromDTO) { @@ -437,11 +532,99 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl().error(EpmetErrorCode.MOBILE_USED.getCode(), EpmetErrorCode.MOBILE_USED.getMsg()); + } + CustomerStaffByAccountFormDTO customerStaffAccountFormDTO = new CustomerStaffByAccountFormDTO(); + customerStaffAccountFormDTO.setCustomerId(fromDTO.getCustomerId()); + customerStaffAccountFormDTO.setUserAccount(fromDTO.getUserAccount()); + customerStaffDTO = baseDao.selectListCustomerStaffInfoByAccount(customerStaffAccountFormDTO); + if (null != customerStaffDTO && !fromDTO.getStaffId().equals(customerStaffDTO.getUserId())) { + return new Result().error(EpmetErrorCode.ACCOUNT_USED.getCode(), EpmetErrorCode.ACCOUNT_USED.getMsg()); + } + CustomerStaffEntity customerStaffEntity = baseDao.selectByUserId(fromDTO.getStaffId()); + //Customer_Staff表插入数据 + CustomerStaffEntity staffEntity = new CustomerStaffEntity(); + staffEntity.setId(customerStaffEntity.getId()); + staffEntity.setRealName(fromDTO.getName()); + staffEntity.setMobile(fromDTO.getMobile()); + staffEntity.setGender(fromDTO.getGender()); + staffEntity.setUserAccount(fromDTO.getUserAccount()); + staffEntity.setWorkType(fromDTO.getWorkType()); + if (StringUtils.isNotBlank(fromDTO.getPwd())){ + staffEntity.setPassword(PasswordUtils.encode(fromDTO.getPwd())); + } + staffEntity.setIdCard(fromDTO.getIdCard()); + baseDao.updateById(staffEntity); + + //清空权限关联 + StaffRoleDTO staffRoleDTO = new StaffRoleDTO(); + staffRoleDTO.setStaffId(fromDTO.getStaffId()); + staffRoleDTO.setOrgId(fromDTO.getAgencyId()); + staffRoleService.clearStaffRoles(staffRoleDTO); + //重新添加角色关联 + fromDTO.getRoles().forEach(role -> { + StaffRoleEntity staffRoleEntity = new StaffRoleEntity(); + staffRoleEntity.setStaffId(fromDTO.getStaffId()); + staffRoleEntity.setRoleId(role); + staffRoleEntity.setOrgId(fromDTO.getAgencyId()); + staffRoleService.insert(staffRoleEntity); + }); + + // 重新查询用户的角色列表(可以取到前端没有传过来的角色,例如根管理员) + List staffRoleEntytiesByStaffIdAndOrgId = staffRoleService.getStaffRoleEntytiesByStaffIdAndOrgId(fromDTO.getAgencyId(), fromDTO.getStaffId()); + List roleIds = new ArrayList<>(); + if (!CollectionUtils.isEmpty(staffRoleEntytiesByStaffIdAndOrgId)) { + roleIds = staffRoleEntytiesByStaffIdAndOrgId.stream().map(sr -> sr.getRoleId()).collect(Collectors.toList()); + } + + // redis缓存角色修改 + UpdateCachedRolesFormDTO updateRolesForm = new UpdateCachedRolesFormDTO(); + updateRolesForm.setOrgId(fromDTO.getAgencyId()); + updateRolesForm.setStaffId(fromDTO.getStaffId()); + updateRolesForm.setRoleIds(roleIds); + try { + Result result = authFeignClient.updateCachedRoles(updateRolesForm); + if (!result.success()) { + logger.error("修改用户信息:修改用户已缓存的角色列表失败:{}", result.getInternalMsg()); + } + logger.info("修改用户信息:修改用户已缓存的角色列表成功"); + } catch (Exception e) { + log.error("method exception", e); + logger.error("修改用户信息:修改用户已缓存的角色列表异常:{}", ExceptionUtils.getErrorStackTrace(e)); + } + + // 角色放缓存 + CustomerAgencyUserRoleDTO dto = new CustomerAgencyUserRoleDTO(); + List roleKeyValue = govStaffRoleDao.selectRoleKeyName(fromDTO.getRoles()); + dto.setCustomerId(fromDTO.getCustomerId()); + dto.setStaffId(fromDTO.getStaffId()); + dto.setAgencyId(fromDTO.getAgencyId()); + Map m = new HashMap(16); + roleKeyValue.forEach(r -> { + m.put(r.getRoleKey(), r.getRoleName()); + }); + dto.setRoles(m); + CustomerStaffRedis.delStaffInfoFormCache(dto.getCustomerId(), dto.getStaffId()); + + return new Result(); + } + @Override public Result getStaffDetail(StaffInfoFromDTO fromDTO) { StaffDetailResultDTO resultDTO = new StaffDetailResultDTO(); //获取工作人员信息 CustomerStaffDTO customerStaffDTO = baseDao.selectStaffInfo(fromDTO); + if (StringUtils.isBlank(customerStaffDTO.getHeadPhoto())) { + customerStaffDTO.setHeadPhoto(""); + } resultDTO.setStaffId(customerStaffDTO.getUserId()); resultDTO.setName(customerStaffDTO.getRealName()); resultDTO.setMobile(customerStaffDTO.getMobile()); @@ -556,7 +739,16 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl getCustsomerStaffByIdAndAccount(ThirdCustomerStaffByAccountFormDTO formDTO) { + //根据客户Id和手机号查询工作人员信息 + List customerStaffDTOList = baseDao.selectStaffByAccount(formDTO); + if (null == customerStaffDTOList || customerStaffDTOList.size() < NumConstant.ONE) { + logger.warn(String.format("根据客户Id和账户查询用户异常,客户Id:[%s],账户:[%s],code[%s],msg[%s]", + formDTO.getCustomerId(), formDTO.getUserAccount(), EpmetErrorCode.GOV_STAFF_ACCOUNT_NOT_EXISTS.getCode(), + EpmetErrorCode.GOV_STAFF_ACCOUNT_NOT_EXISTS.getMsg())); + throw new RenException(EpmetErrorCode.GOV_STAFF_ACCOUNT_NOT_EXISTS.getCode()); + } + return customerStaffDTOList; + } + /** * @param formDTO * @Description 查询工作人员的信息 diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/DataSyncConfigServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/DataSyncConfigServiceImpl.java new file mode 100644 index 0000000000..d4de7ebcbe --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/DataSyncConfigServiceImpl.java @@ -0,0 +1,272 @@ +package com.epmet.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.dto.form.PageFormDTO; +import com.epmet.commons.tools.dto.result.YtHsjcResDTO; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.redis.common.CustomerOrgRedis; +import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; +import com.epmet.commons.tools.redis.common.bean.GridInfoCache; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.commons.tools.utils.YtHsResUtils; +import com.epmet.dao.DataSyncConfigDao; +import com.epmet.dao.IcNatDao; +import com.epmet.dto.DataSyncConfigDTO; +import com.epmet.dto.form.ConfigSwitchFormDTO; +import com.epmet.dto.form.NatInfoScanTaskFormDTO; +import com.epmet.dto.form.ScopeSaveFormDTO; +import com.epmet.dto.result.NatUserInfoResultDTO; +import com.epmet.entity.DataSyncConfigEntity; +import com.epmet.entity.DataSyncScopeEntity; +import com.epmet.entity.IcNatEntity; +import com.epmet.entity.IcNatRelationEntity; +import com.epmet.service.DataSyncConfigService; +import com.epmet.service.DataSyncScopeService; +import com.epmet.service.IcNatRelationService; +import com.epmet.service.IcNatService; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.ListUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 数据更新配置表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-09-26 + */ +@Service +public class DataSyncConfigServiceImpl extends BaseServiceImpl implements DataSyncConfigService { + + @Autowired + private DataSyncScopeService dataSyncScopeService; + @Autowired + private IcNatDao icNatDao; + @Autowired + private IcNatService icNatService; + @Autowired + private IcNatRelationService icNatRelationService; + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public DataSyncConfigDTO get(String id) { + DataSyncConfigEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, DataSyncConfigDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(DataSyncConfigDTO dto) { + DataSyncConfigEntity entity = ConvertUtils.sourceToTarget(dto, DataSyncConfigEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(DataSyncConfigDTO dto) { + DataSyncConfigEntity entity = ConvertUtils.sourceToTarget(dto, DataSyncConfigEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + /** + * Desc: 【数据配置】配置开关 + * @param formDTO + * @author zxc + * @date 2022/9/26 14:36 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void configSwitch(ConfigSwitchFormDTO formDTO) { + baseDao.configSwitch(formDTO); + } + + /** + * Desc: 【数据配置】列表 + * @param tokenDto + * @author zxc + * @date 2022/9/26 15:04 + */ + @Override + public PageData list(TokenDto tokenDto, PageFormDTO formDTO) { + PageData result = new PageData<>(new ArrayList<>(), NumConstant.ZERO_L); + PageInfo pageInfo = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.list(tokenDto.getCustomerId())); + if (CollectionUtils.isNotEmpty(pageInfo.getList())){ + result.setList(pageInfo.getList()); + result.setTotal(Integer.valueOf(String.valueOf(pageInfo.getTotal()))); + } + return result; + } + + /** + * Desc: 【数据配置】范围保存 + * @param formDTO + * @author zxc + * @date 2022/9/26 15:41 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void scopeSave(ScopeSaveFormDTO formDTO) { + baseDao.delScope(formDTO.getDataSyncConfigId()); + if (CollectionUtils.isNotEmpty(formDTO.getScopeList())){ + formDTO.getScopeList().forEach(o -> { + o.setCustomerId(formDTO.getCustomerId()); + o.setDataSyncConfigId(formDTO.getDataSyncConfigId()); + if (o.getOrgType().equals("grid")){ + GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(o.getOrgId()); + if (null == gridInfo){ + throw new EpmetException("查询网格信息失败"+o.getOrgId()); + } + o.setPid(gridInfo.getPid()); + o.setOrgIdPath(gridInfo.getPids() + ":" + gridInfo.getId()); + }else { + AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(o.getOrgId()); + if (null == agencyInfo){ + throw new EpmetException("查询组织信息失败"+o.getOrgId()); + } + o.setPid(agencyInfo.getPid()); + o.setOrgIdPath(agencyInfo.getPids().equals(NumConstant.EMPTY_STR) || agencyInfo.getPids().equals(NumConstant.ZERO_STR) ? agencyInfo.getId() : agencyInfo.getPids() + ":" + agencyInfo.getId()); + } + }); + dataSyncScopeService.insertBatch(ConvertUtils.sourceToTarget(formDTO.getScopeList(), DataSyncScopeEntity.class)); + } + } + + /** + * Desc: + * 大数据局部门配置on + * 根据范围搜索居民,调接口查询最近一次核酸检测记录 + * 检测时间 + 身份证 不存在就插入 + * @param formDTO + * @author zxc + * @date 2022/9/26 17:16 + */ + @Override + public void natInfoScanTask(NatInfoScanTaskFormDTO formDTO) { + if (CollectionUtils.isNotEmpty(formDTO.getIdCards())){ + List userIdByIdCard = baseDao.getUserIdByIdCard(formDTO.getIdCards()); + List collect = formDTO.getIdCards().stream().map(id -> { + NatUserInfoResultDTO e = new NatUserInfoResultDTO(); + e.setIdCard(id); + e.setUserId(""); + return e; + }).collect(Collectors.toList()); + collect.forEach(c -> userIdByIdCard.stream().filter(u -> u.getIdCard().equals(c.getIdCard())).forEach(u -> c.setUserId(u.getUserId()))); + hsjc(collect,formDTO.getCustomerId()); + return; + } + List allConfigList = baseDao.list(StringUtils.isNotBlank(formDTO.getCustomerId()) ? formDTO.getCustomerId() : null); + if (CollectionUtils.isEmpty(allConfigList)){ + return; + } + List configList = allConfigList.stream().filter(l -> l.getDeptCode().equals("dsjj") && l.getSwitchStatus().equals("open")).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(configList)){ + configList.forEach(c -> { + if (CollectionUtils.isNotEmpty(c.getScopeList())){ + Integer no = NumConstant.ONE; + Integer size; + do { + PageInfo pageInfo = PageHelper.startPage(no, NumConstant.ONE_THOUSAND).doSelectPageInfo(() -> baseDao.getIdCardsByScope(c.getScopeList())); + size = pageInfo.getList().size(); + hsjc(pageInfo.getList(),c.getCustomerId()); + no++; + }while (size.compareTo(NumConstant.ONE_THOUSAND) == NumConstant.ZERO); + } + }); + } + } + + /** + * Desc: 根据证件号 查询nat 存在 ? 不处理 : 新增 + * @param idCards + * @param customerId + * @author zxc + * @date 2022/9/27 11:08 + */ + private void hsjc(List idCards,String customerId){ + if (CollectionUtils.isNotEmpty(idCards)){ + List entities = new ArrayList<>(); + idCards.forEach(idCard -> { + YtHsjcResDTO natInfoResult = YtHsResUtils.hsjc(idCard.getIdCard(), NumConstant.ONE, NumConstant.ONE); + if (CollectionUtils.isNotEmpty(natInfoResult.getData())){ + natInfoResult.getData().forEach(natInfo -> { + IcNatEntity e = new IcNatEntity(); + e.setCustomerId(customerId); + e.setIsResiUser(StringUtils.isBlank(idCard.getUserId()) ? NumConstant.ZERO_STR : NumConstant.ONE_STR); + e.setUserId(idCard.getUserId()); + e.setUserType("sync"); + e.setName(StringUtils.isNotBlank(natInfo.getName()) ? natInfo.getName() : ""); + e.setMobile(StringUtils.isNotBlank(natInfo.getTelephone()) ? natInfo.getTelephone() : ""); + e.setIdCard(StringUtils.isNotBlank(natInfo.getCard_no()) ? natInfo.getCard_no() : ""); + e.setNatTime(DateUtils.parseDate(natInfo.getTest_time(),DateUtils.DATE_TIME_PATTERN)); + e.setNatResult(natInfo.getSample_result_pcr()); + e.setNatAddress(natInfo.getSampling_org_pcr()); + e.setAgencyId(idCard.getAgencyId()); + e.setPids(idCard.getPids()); + e.setAttachmentType(""); + e.setAttachmentUrl(""); + entities.add(e); + }); + } + }); + if (CollectionUtils.isNotEmpty(entities)){ + List existNatInfos = icNatDao.getExistNatInfo(entities); + entities.forEach(e -> existNatInfos.stream().filter(i -> i.getUserId().equals(e.getUserId()) && i.getIdCard().equals(e.getIdCard())).forEach(i -> e.setExistStatus(true))); + Map> groupByStatus = entities.stream().collect(Collectors.groupingBy(IcNatEntity::getExistStatus)); + if (CollectionUtils.isNotEmpty(groupByStatus.get(false))){ + for (List icNatEntities : ListUtils.partition(groupByStatus.get(false), 500)) { + icNatService.insertBatch(icNatEntities); + } + } + //组织关系表 + List relationEntities = new ArrayList<>(); + entities.forEach(ne -> { + // 不是居民的先不加关系表吧 + if (ne.getIsResiUser().equals(NumConstant.ONE_STR)){ + IcNatRelationEntity e = new IcNatRelationEntity(); + e.setCustomerId(customerId); + e.setAgencyId(ne.getAgencyId()); + e.setPids(ne.getPids()); + e.setIcNatId(ne.getId()); + e.setUserType("sync"); + relationEntities.add(e); + } + }); + if (CollectionUtils.isNotEmpty(relationEntities)){ + for (List icNatRelationEntities : ListUtils.partition(relationEntities, 500)) { + icNatRelationService.insertBatch(icNatRelationEntities); + } + } + } + } + } +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/DataSyncScopeServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/DataSyncScopeServiceImpl.java new file mode 100644 index 0000000000..4e6e0843d2 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/DataSyncScopeServiceImpl.java @@ -0,0 +1,82 @@ +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.dao.DataSyncScopeDao; +import com.epmet.dto.DataSyncScopeDTO; +import com.epmet.entity.DataSyncScopeEntity; +import com.epmet.service.DataSyncScopeService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 数据更新范围表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-09-26 + */ +@Service +public class DataSyncScopeServiceImpl extends BaseServiceImpl implements DataSyncScopeService { + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, DataSyncScopeDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, DataSyncScopeDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public DataSyncScopeDTO get(String id) { + DataSyncScopeEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, DataSyncScopeDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(DataSyncScopeDTO dto) { + DataSyncScopeEntity entity = ConvertUtils.sourceToTarget(dto, DataSyncScopeEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(DataSyncScopeDTO dto) { + DataSyncScopeEntity entity = ConvertUtils.sourceToTarget(dto, DataSyncScopeEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcBirthRecordServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcBirthRecordServiceImpl.java index 37a65965d7..dc737eed05 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcBirthRecordServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcBirthRecordServiceImpl.java @@ -5,14 +5,15 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; -import com.epmet.commons.tools.enums.GenderEnum; -import com.epmet.commons.tools.enums.IcResiUserSubStatusEnum; -import com.epmet.commons.tools.enums.IdCardTypeEnum; -import com.epmet.commons.tools.enums.RelationshipEnum; +import com.epmet.commons.tools.enums.*; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.redis.common.CustomerIcHouseRedis; +import com.epmet.commons.tools.redis.common.CustomerOrgRedis; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; +import com.epmet.commons.tools.redis.common.bean.GridInfoCache; +import com.epmet.commons.tools.redis.common.bean.HouseInfoCache; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.IdCardRegexUtils; @@ -29,6 +30,7 @@ import com.epmet.dto.result.HouseInfoDTO; import com.epmet.dto.result.SyncResiResDTO; import com.epmet.entity.IcBirthRecordEntity; import com.epmet.entity.IcResiUserEntity; +import com.epmet.feign.EpmetAdminOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.service.ChangeWelfareService; import com.epmet.service.IcBirthRecordService; @@ -37,6 +39,7 @@ import com.epmet.service.IcUserTransferRecordService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; import org.springframework.stereotype.Service; @@ -65,6 +68,8 @@ public class IcBirthRecordServiceImpl extends BaseServiceImpl page(BirthRecordFormDTO formDTO) { @@ -118,7 +123,24 @@ public class IcBirthRecordServiceImpl extends BaseServiceImpl> relationshipRes = epmetAdminOpenFeignClient.dictMap(DictTypeEnum.RELATIONSHIP.getCode()); + if (relationshipRes.success() && MapUtils.isNotEmpty(relationshipRes.getData())) { + String householderRelationName = relationshipRes.getData().containsKey(recordDTO.getHouseholderRelation()) ? relationshipRes.getData().get(recordDTO.getHouseholderRelation()) : StrConstant.EPMETY_STR; + recordDTO.setHouseholderRelationName(householderRelationName); + } + return recordDTO; } @Override diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcEpidemicSpecialAttentionServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcEpidemicSpecialAttentionServiceImpl.java index 0258f583ad..65070ee096 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcEpidemicSpecialAttentionServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcEpidemicSpecialAttentionServiceImpl.java @@ -15,6 +15,7 @@ import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.redis.common.CustomerOrgRedis; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; +import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ExcelPoiUtils; @@ -22,14 +23,18 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.IcEpidemicSpecialAttentionDao; import com.epmet.dto.IcEpidemicSpecialAttentionDTO; +import com.epmet.dto.SysDictDataDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.HouseInfoDTO; +import com.epmet.dto.result.NatPieResultDTO; import com.epmet.dto.result.UploadImgResultDTO; import com.epmet.dto.result.VaccinationListResultDTO; import com.epmet.entity.IcEpidemicSpecialAttentionEntity; import com.epmet.enums.ChannelEnum; +import com.epmet.enums.NatPieColorEnum; import com.epmet.excel.ImportEpidemicSpecialAttention; import com.epmet.excel.error.EpidemicSpecialAttentionErrorModel; +import com.epmet.feign.EpmetAdminOpenFeignClient; import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.feign.OssFeignClient; @@ -76,6 +81,8 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl page(Map params) { @@ -155,6 +162,9 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl pageInfo = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.natList(formDTO)); result.setList(pageInfo.getList()); @@ -164,6 +174,65 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl { + if (StringUtils.isNotBlank(r.getGridId())){ + GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(r.getGridId()); + if (null == gridInfo){ + throw new EpmetException("查询网格失败:"+r.getGridId()); + } + r.setGridName(gridInfo.getGridNamePath()); + } + }); + } + } + if (CollectionUtils.isNotEmpty(result.getList())){ + result.getList().forEach(v -> { + v.setSex(); + }); + } + //需求调整 列表和导出增加所属房屋(小区+楼栋+单元+房间)一列值 sun + Map houseInfoMap = new HashMap<>(); + //查询房屋信息 + if (result.getList().size() > NumConstant.ZERO) { + Set houseIds = result.getList().stream().filter(l -> StringUtils.isNotBlank(l.getHomeId())).map(m -> m.getHomeId()).collect(Collectors.toSet()); + Result> houseInfoRes = govOrgOpenFeignClient.queryListHouseInfo(houseIds, formDTO.getCustomerId()); + List houseInfoDTOList = houseInfoRes.success() && !CollectionUtils.isEmpty(houseInfoRes.getData()) ? houseInfoRes.getData() : new ArrayList<>(); + houseInfoMap = houseInfoDTOList.stream().collect(Collectors.toMap(HouseInfoDTO::getHomeId, Function.identity())); + } + + int i = (formDTO.getPageNo() - NumConstant.ONE) * formDTO.getPageSize(); + for (VaccinationListResultDTO v : result.getList()) { + i += 1; + v.setSort(i); + if (null != houseInfoMap && houseInfoMap.containsKey(v.getHomeId())) { + v.setVillageName(houseInfoMap.get(v.getHomeId()).getNeighborHoodName()); + v.setBuildName(houseInfoMap.get(v.getHomeId()).getBuildingName()); + v.setUnitName(houseInfoMap.get(v.getHomeId()).getUnitName()); + v.setHomeName(houseInfoMap.get(v.getHomeId()).getDoorName()); + v.setAllName(houseInfoMap.get(v.getHomeId()).getAllName()); + } + } + return result; + } + + @Override + public PageData historyList(VaccinationListFormDTO formDTO) { + PageData result = new PageData(new ArrayList(), NumConstant.ZERO_L); + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getUserId()); + if (null == staffInfo){ + throw new EpmetException("未查询到工作人员信息"+formDTO.getUserId()); + } + formDTO.setOrgId(staffInfo.getAgencyId()); + formDTO.setIsHistory(NumConstant.ONE_STR); + if (formDTO.getIsPage()){ + PageInfo pageInfo = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.natList(formDTO)); + result.setList(pageInfo.getList()); + result.setTotal(Integer.valueOf(String.valueOf(pageInfo.getTotal()))); + }else { + List list = baseDao.natList(formDTO); + result.setList(list); + result.setTotal(list.size()); } if (CollectionUtils.isNotEmpty(result.getList())){ result.getList().forEach(v -> { @@ -212,19 +281,26 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl entities = ConvertUtils.sourceToTarget(formDTO.getList(), IcEpidemicSpecialAttentionEntity.class); List idCards = entities.stream().map(m -> m.getIdCard()).collect(Collectors.toList()); Integer attentionType = entities.get(NumConstant.ZERO).getAttentionType(); List existList = baseDao.getExistList(attentionType, idCards); + List existsEntities = new ArrayList<>(); if (CollectionUtils.isNotEmpty(existList)){ for (String s : existList) { for (int i = NumConstant.ZERO; i < entities.size(); i++) { if (s.equals(entities.get(i).getIdCard())){ + existsEntities.add(entities.get(i)); entities.remove(i); continue; } } } + baseDao.addExistAttention(existsEntities,attentionType); } entities.forEach(e -> { e.setIsAttention(NumConstant.ONE); @@ -232,8 +308,10 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl w = new LambdaQueryWrapper<>(); IcEpidemicSpecialAttentionEntity e = new IcEpidemicSpecialAttentionEntity(); - w.eq(IcEpidemicSpecialAttentionEntity::getIdCard,formDTO.getIdCard()) + w.eq(IcEpidemicSpecialAttentionEntity::getId,formDTO.getId()) .eq(IcEpidemicSpecialAttentionEntity::getAttentionType,formDTO.getAttentionType()); e.setMobile(formDTO.getMobile()); e.setReason(formDTO.getReason()); e.setRemark(formDTO.getRemark()); + e.setIsolatedState(formDTO.getIsolatedState()); update(e,w); if (CollectionUtils.isNotEmpty(formDTO.getChannel())){ SendNoticeFormDTO dto = new SendNoticeFormDTO(); @@ -311,7 +390,6 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl errorInfo = new ArrayList<>(); - try { List list = ExcelPoiUtils.importExcel(inputStream, 0,1,ImportEpidemicSpecialAttention.class); if (CollectionUtils.isEmpty(list)){ @@ -336,7 +414,7 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl> isolatedState = epmetAdminOpenFeignClient.dictDataList("isolatedState"); + if (!isolatedState.success()){ + throw new EpmetException("查询字典表数据失败..."+"isolatedState"); + } + Map dictMap = isolatedState.getData().stream().collect(Collectors.toMap(SysDictDataDTO::getDictLabel, SysDictDataDTO::getDictValue)); if (list.size() > errorInfo.size()){ - Map groupByIdCard = list.stream().collect(Collectors.groupingBy(ImportEpidemicSpecialAttention::getIdCard, Collectors.counting())); + Map groupByIdCard = list.stream().filter(l -> StringUtils.isNotBlank(l.getIdCard())).collect(Collectors.groupingBy(ImportEpidemicSpecialAttention::getIdCard, Collectors.counting())); groupByIdCard.forEach((idCard,count) -> { if (Integer.valueOf(count.toString()).compareTo(1) != 0){ for (ImportEpidemicSpecialAttention i : list) { @@ -359,6 +447,7 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl idCards = list.stream().map(m -> m.getIdCard()).collect(Collectors.toList()); + List existsEntities = new ArrayList<>(); List existList = baseDao.getExistList(attentionType, idCards); if (CollectionUtils.isNotEmpty(existList)){ for (String s : existList) { @@ -367,10 +456,17 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl> groupByStatus = list.stream().collect(Collectors.groupingBy(ImportEpidemicSpecialAttention::getAddStatus)); @@ -378,6 +474,9 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl entities = ConvertUtils.sourceToTarget(needInsert, IcEpidemicSpecialAttentionEntity.class); entities.forEach(e -> { + if (attentionType.compareTo(NumConstant.TWO) == NumConstant.ZERO){ + e.setIsolatedState(dictMap.get(e.getIsolatedState())); + } e.setIsAttention(NumConstant.ONE); e.setOrgId(agencyInfo.getId()); e.setPid(agencyInfo.getPid()); @@ -482,6 +581,41 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl> isolatedState = epmetAdminOpenFeignClient.dictDataList("isolatedState"); + if (!isolatedState.success()){ + throw new EpmetException("查询字典表数据失败..."+"isolatedState"); + } + List data = isolatedState.getData(); + if (CollectionUtils.isEmpty(data)){ + return result; + } + List conResult = new ArrayList<>(); + data.forEach(d -> { + NatPieResultDTO.IsolatedList dto = new NatPieResultDTO.IsolatedList(); + dto.setCategoryCode(d.getDictValue()); + dto.setCategoryName(d.getDictLabel()); + dto.setColor(NatPieColorEnum.getValueByKey(d.getDictValue())); + conResult.add(dto); + }); + List isolatedLists = baseDao.isolatedList(staffInfo.getAgencyId()); + conResult.forEach(c -> isolatedLists.stream().filter(i -> i.getCategoryCode().equals(c.getCategoryCode())).forEach(i -> c.setTotal(i.getTotal()))); + NatPieResultDTO.IsolatedList dto = new NatPieResultDTO.IsolatedList(); + dto.setCategoryCode(""); + dto.setCategoryName("历史关注人数"); + dto.setColor(NatPieColorEnum.getValueByKey(NumConstant.ONE_HUNDRED_STR)); + dto.setTotal(baseDao.getHistoryCount(staffInfo.getAgencyId())); + result.setIsolatedList(conResult); + result.setHistoryList(Arrays.asList(dto)); + return result; + } + /** * Desc: 文件上传并返回url * @param errorRows diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNatCompareRecordServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNatCompareRecordServiceImpl.java new file mode 100644 index 0000000000..2ac1d18b47 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNatCompareRecordServiceImpl.java @@ -0,0 +1,305 @@ +package com.epmet.service.impl; + +import com.alibaba.excel.EasyExcel; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.redis.common.CustomerOrgRedis; +import com.epmet.commons.tools.redis.common.CustomerStaffRedis; +import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; +import com.epmet.commons.tools.utils.*; +import com.epmet.constants.ImportTaskConstants; +import com.epmet.dao.IcNatCompareRecRelationDao; +import com.epmet.dao.IcNatCompareRecordDao; +import com.epmet.dto.IcNatCompareRecordDTO; +import com.epmet.dto.IcResiUserDTO; +import com.epmet.dto.form.ImportTaskCommonFormDTO; +import com.epmet.dto.form.yqfk.IcNatCompareRecordPageFormDTO; +import com.epmet.dto.result.UploadImgResultDTO; +import com.epmet.entity.IcNatCompareRecRelationEntity; +import com.epmet.entity.IcNatCompareRecordEntity; +import com.epmet.excel.data.IcNatCompareRecordExcelData; +import com.epmet.excel.handler.IcNatCompareRecordExcelImportListener; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; +import com.epmet.feign.OssFeignClient; +import com.epmet.service.IcNatCompareRecordService; +import com.epmet.service.IcResiUserService; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileItemFactory; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; +import org.apache.commons.lang3.StringUtils; +import org.apache.http.entity.ContentType; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.commons.CommonsMultipartFile; + +import java.io.IOException; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Date; +import java.util.List; +import java.util.UUID; + +/** + * 核算比对记录 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-09-26 + */ +@Slf4j +@Service +public class IcNatCompareRecordServiceImpl extends BaseServiceImpl implements IcNatCompareRecordService { + @Autowired + private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient; + @Autowired + private OssFeignClient ossFeignClient; + @Autowired + private IcNatCompareRecRelationDao icNatCompareRecRelationDao; + + private CustomerStaffInfoCacheResult queryCurrentStaff(String customerId, String userId) { + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(customerId, userId); + if (null == staffInfo) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询工作人员缓存信息异常", EpmetErrorCode.SERVER_ERROR.getMsg()); + } + return staffInfo; + } + + + /** + * 列表分页查询 + * @param formDTO + * @return + */ + @Override + public PageData page(IcNatCompareRecordPageFormDTO formDTO) { + //1.获取工作人员缓存信息 + CustomerStaffInfoCacheResult staffInfo=queryCurrentStaff(formDTO.getCustomerId(),formDTO.getUserId()); + formDTO.setAgencyId(staffInfo.getAgencyId()); + //2.按条件查询业务数据 + PageInfo data = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage()) + .doSelectPageInfo(() -> baseDao.pageList(formDTO)); + List list = data.getList(); + return new PageData(list, data.getTotal()); + } + + /** + * 未做核酸比对导入文件 + * @param filePath + * @param importTaskId + * @param customerId + * @param userId + */ + @Override + public void execAsyncExcelImport(Path filePath, String importTaskId, String customerId, String userId) { + try { + //获取当前登录用户所属组织id + CustomerStaffInfoCacheResult staffInfo= queryCurrentStaff(customerId,userId); + Date importTime=new Date(); + String importDate= DateUtils.format(importTime,DateUtils.DATE_PATTERN_YYYYMMDD); + IcNatCompareRecordExcelImportListener listener = new IcNatCompareRecordExcelImportListener(customerId, staffInfo, importDate, importTime, this); + + EasyExcel.read(filePath.toFile(), IcNatCompareRecordExcelData.class, listener).headRowNumber(1).sheet(0).doRead(); + + Path errorDescFile = null; + String errorDesFileUrl = null; + List errorRows = listener.getErrorRows(); + + boolean failed = errorRows.size() > 0; + if (failed) { + // 生成并上传错误文件 + try { + // 文件生成 + Path errorDescDir = FileUtils.getAndCreateDirUnderEpmetFilesDir("ic_nat_compare_record", "import", "error_des"); + String fileName = UUID.randomUUID().toString().concat(".xlsx"); + errorDescFile = errorDescDir.resolve(fileName); + + FileItemFactory factory = new DiskFileItemFactory(16, errorDescDir.toFile()); + FileItem fileItem = factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, fileName); + OutputStream os = fileItem.getOutputStream(); + + EasyExcel.write(os, IcNatCompareRecordExcelData.ErrorRow.class).sheet("导入失败列表").doWrite(errorRows); + + // 文件上传oss + Result errorDesFileUploadResult = ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem)); + if (errorDesFileUploadResult.success()) { + errorDesFileUrl = errorDesFileUploadResult.getData().getUrl(); + } + } finally { + if (Files.exists(errorDescFile)) { + Files.delete(errorDescFile); + } + } + } + + ImportTaskCommonFormDTO importFinishTaskForm = new ImportTaskCommonFormDTO(); + importFinishTaskForm.setTaskId(importTaskId); + importFinishTaskForm.setProcessStatus(failed ? ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL : ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS); + importFinishTaskForm.setOperatorId(userId); + importFinishTaskForm.setResultDesc(""); + importFinishTaskForm.setResultDescFilePath(errorDesFileUrl); + + Result result = commonServiceOpenFeignClient.finishImportTask(importFinishTaskForm); + if (!result.success()) { + log.error("【未做核酸比对】finishImportTask失败"); + } + } catch (Exception e) { + String errorMsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【未做核酸比对】出错:{}", errorMsg); + + ImportTaskCommonFormDTO importFinishTaskForm = new ImportTaskCommonFormDTO(); + importFinishTaskForm.setTaskId(importTaskId); + importFinishTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); + importFinishTaskForm.setOperatorId(userId); + importFinishTaskForm.setResultDesc("导入失败"); + + Result result = commonServiceOpenFeignClient.finishImportTask(importFinishTaskForm); + if (!result.success()) { + log.error("【未做核酸比对】导入记录状态修改为'完成'失败"); + } + } finally { + // 删除临时文件 + if (Files.exists(filePath)) { + try { + Files.delete(filePath); + } catch (IOException e) { + log.error("method exception", e); + } + } + } + + } + + + /** + * + * @param datas + * @param staffInfo 当前操作人 + * @param importDate yyyyMMdd + * @param importTime 导入时间yyyy-MM-dd HH:mm:ss + * @param listener + */ + public void batchPersist(List datas,CustomerStaffInfoCacheResult staffInfo,String importDate,Date importTime, IcNatCompareRecordExcelImportListener listener) { + datas.forEach(entity -> { + try { + persisNat(entity, staffInfo,importDate,importTime); + } catch (Exception exception) { + String errorMsg = ExceptionUtils.getErrorStackTrace(exception); + log.error(errorMsg); + + IcNatCompareRecordExcelData.ErrorRow errorRow = new IcNatCompareRecordExcelData.ErrorRow(); + errorRow.setName(entity.getName()); + errorRow.setMobile(entity.getMobile()); + errorRow.setIdCard(entity.getIdCard()); + errorRow.setErrorInfo("batchPersist未知系统错误"); + listener.getErrorRows().add(errorRow); + } + }); + } + + + /** + * + * @param data + * @param staffInfo 当前操作人 + * @param importDate yyyyMMdd + * @param importTime 导入时间yyyy-MM-dd HH:mm:ss + */ + @Transactional(rollbackFor = Exception.class) + public void persisNat(IcNatCompareRecordEntity data, CustomerStaffInfoCacheResult staffInfo, String importDate, Date importTime) { + // 查询是否本辖区居民 + IcResiUserDTO icResiUserDTO = SpringContextUtils.getBean(IcResiUserService.class).getByIdCard(data.getCustomerId(), data.getIdCard(), null); + AgencyInfoCache agencyInfoCache = CustomerOrgRedis.getAgencyInfo(staffInfo.getAgencyId()); + //根据身份证号判断是否存在基础信息 + IcNatCompareRecordEntity existEntity=baseDao.selectByIdCard(data.getCustomerId(),data.getIdCard()); + if (null == existEntity) { + // 1、不存在该身份证的基础记录,直接插入ic_nat_compare_record 、ic_nat_compare_rec_relation 插入记录 + IcNatCompareRecordEntity compareRecordEntity = ConvertUtils.sourceToTarget(data, IcNatCompareRecordEntity.class); + compareRecordEntity.setIcResiUserId(null == icResiUserDTO ? StrConstant.EPMETY_STR : icResiUserDTO.getId()); + // 是否客户下居民(0:否 1:是) + compareRecordEntity.setIsResiUser(StringUtils.isNotBlank(compareRecordEntity.getIcResiUserId()) ? NumConstant.ONE_STR : NumConstant.ZERO_STR); + compareRecordEntity.setLatestImportTime(importTime); + //插入基础信息 + insert(compareRecordEntity); + + IcNatCompareRecRelationEntity relationEntity = new IcNatCompareRecRelationEntity(); + relationEntity.setCustomerId(data.getCustomerId()); + relationEntity.setCompareRecId(compareRecordEntity.getId()); + relationEntity.setImportDate(importDate); + relationEntity.setImportTime(importTime); + relationEntity.setAgencyId(staffInfo.getAgencyId()); + relationEntity.setAgencyName(staffInfo.getAgencyName()); + relationEntity.setStaffId(staffInfo.getStaffId()); + relationEntity.setStaffName(staffInfo.getRealName()); + if (null != agencyInfoCache) { + relationEntity.setPid(agencyInfoCache.getPid()); + relationEntity.setPids(agencyInfoCache.getPids()); + } + // 是否本社区(agency_id)下居民(0:否 1:是) + if (null != icResiUserDTO && icResiUserDTO.getAgencyId().equals(staffInfo.getAgencyId())) { + relationEntity.setIsAgencyUser(NumConstant.ONE_STR); + } else { + relationEntity.setIsAgencyUser(NumConstant.ZERO_STR); + } + //插入关系表 + icNatCompareRecRelationDao.insert(relationEntity); + } else { + IcNatCompareRecordEntity origin = ConvertUtils.sourceToTarget(data, IcNatCompareRecordEntity.class); + origin.setId(existEntity.getId()); + origin.setIcResiUserId(null == icResiUserDTO ? StrConstant.EPMETY_STR : icResiUserDTO.getId()); + // 是否客户下居民(0:否 1:是) + origin.setIsResiUser(StringUtils.isNotBlank(origin.getIcResiUserId()) ? NumConstant.ONE_STR : NumConstant.ZERO_STR); + origin.setLatestImportTime(importTime); + baseDao.updateById(origin); + IcNatCompareRecRelationEntity existRelationEntity=icNatCompareRecRelationDao.selectExist(data.getCustomerId(),origin.getId(),staffInfo.getAgencyId(),importDate); + if(null!=existRelationEntity){ + // 是否本社区(agency_id)下居民(0:否 1:是) + if (null != icResiUserDTO && icResiUserDTO.getAgencyId().equals(staffInfo.getAgencyId())) { + existRelationEntity.setIsAgencyUser(NumConstant.ONE_STR); + } else { + existRelationEntity.setIsAgencyUser(NumConstant.ZERO_STR); + } + //记录最后一次导入时间、最近一次操作人id,最近一次操作人姓名 + existRelationEntity.setImportTime(importTime); + existRelationEntity.setStaffId(staffInfo.getStaffId()); + existRelationEntity.setStaffName(staffInfo.getRealName()); + existRelationEntity.setAgencyName(staffInfo.getAgencyName()); + icNatCompareRecRelationDao.updateById(existRelationEntity); + }else{ + IcNatCompareRecRelationEntity relationEntity = new IcNatCompareRecRelationEntity(); + relationEntity.setCustomerId(data.getCustomerId()); + relationEntity.setCompareRecId(origin.getId()); + relationEntity.setImportDate(importDate); + relationEntity.setImportTime(importTime); + relationEntity.setAgencyId(staffInfo.getAgencyId()); + relationEntity.setAgencyName(staffInfo.getAgencyName()); + relationEntity.setStaffId(staffInfo.getStaffId()); + relationEntity.setStaffName(staffInfo.getRealName()); + if (null != agencyInfoCache) { + relationEntity.setPid(agencyInfoCache.getPid()); + relationEntity.setPids(agencyInfoCache.getPids()); + } + // 是否本社区(agency_id)下居民(0:否 1:是) + if (null != icResiUserDTO && icResiUserDTO.getAgencyId().equals(staffInfo.getAgencyId())) { + relationEntity.setIsAgencyUser(NumConstant.ONE_STR); + } else { + relationEntity.setIsAgencyUser(NumConstant.ZERO_STR); + } + //插入关系表 + icNatCompareRecRelationDao.insert(relationEntity); + } + } + + } + + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNoticeServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNoticeServiceImpl.java index 1abb00b5f3..1d2af49a28 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNoticeServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNoticeServiceImpl.java @@ -7,17 +7,23 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.*; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.enums.ChannelEnum; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.SmsTemplateConstant; import com.epmet.constant.UserMessageTypeConstant; +import com.epmet.dao.IcEpidemicSpecialAttentionDao; import com.epmet.dao.IcNoticeDao; +import com.epmet.dao.IcTripReportRecordDao; import com.epmet.dto.IcNoticeDTO; import com.epmet.dto.UserBaseInfoDTO; import com.epmet.dto.form.*; +import com.epmet.entity.IcEpidemicSpecialAttentionEntity; import com.epmet.entity.IcNoticeEntity; +import com.epmet.entity.IcTripReportRecordEntity; import com.epmet.feign.MessageFeignClient; import com.epmet.service.IcNoticeService; import com.epmet.service.UserBaseInfoService; @@ -26,6 +32,7 @@ import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -47,6 +54,10 @@ public class IcNoticeServiceImpl extends BaseServiceImpl page(IcNoticeFormDTO formDTO) { @@ -144,9 +155,11 @@ public class IcNoticeServiceImpl extends BaseServiceImpl { if (StringUtils.isNotBlank(item.getIdCard())) { - //根据身份证获取居民ID + //根据身份证获取居民ID 如果一个客户下,存在多个身份证号相同的而用户,该接口只返回一个 List userList = userBaseInfoService.getCommonIdNumUser(item.getCustomerId(), item.getIdCard()); if (CollectionUtils.isNotEmpty(userList)) { - userList.forEach(user -> { + // userList.forEach(user -> { + UserBaseInfoDTO userBaseInfoDTO=userList.get(NumConstant.ZERO); UserMessageFormDTO messageFormDTO = new UserMessageFormDTO(); messageFormDTO.setCustomerId(item.getCustomerId()); messageFormDTO.setApp(AppClientConstant.APP_GOV); messageFormDTO.setGridId(StrConstant.STAR); - messageFormDTO.setUserId(user.getUserId()); + messageFormDTO.setUserId(userBaseInfoDTO.getUserId()); messageFormDTO.setTitle("您有一条通知消息!"); messageFormDTO.setMessageContent(item.getContent()); messageFormDTO.setReadFlag(Constant.UNREAD); messageFormDTO.setMessageType(UserMessageTypeConstant.ANTIEPIDEMIC); messageFormDTO.setTargetId(item.getId()); msgList.add(messageFormDTO); - }); + item.setUserId(userBaseInfoDTO.getUserId()); + // }); + }else{ + // 没有找到居民端的用户id,发送失败 + item.setSendRes(NumConstant.ZERO_STR); } + baseDao.updateById(item); } //TODO 短信消息 - if (StringUtils.isNotBlank(item.getMobile())) { + /*if (StringUtils.isNotBlank(item.getMobile())) { ProjectSendMsgFormDTO sms = new ProjectSendMsgFormDTO(); sms.setCustomerId(item.getCustomerId()); sms.setMobile(item.getMobile()); sms.setAliyunTemplateCode(SmsTemplateConstant.PROJECT_OVERDUE); sms.setParameterKey("send_msg"); smsList.add(sms); - } + }*/ }); //发送小程序消息 Result result = messageFeignClient.saveUserMessageList(msgList); if (!result.success()) { log.error("发送小程序消息失败" + JSON.toJSONString(result)); } - //TODO 发送短信 } /** @@ -326,4 +344,102 @@ public class IcNoticeServiceImpl extends BaseServiceImpl userBeanList = null; + List entityList = new ArrayList<>(); + for (String bdId : formDTO.getBdIds()) { + IcNoticeEntity entity = new IcNoticeEntity(); + entity.setCustomerId(formDTO.getCustomerId()); + entity.setChannel(channel); + entity.setContent(formDTO.getContent()); + entity.setOrigin(formDTO.getOrigin()); + // 这时候还不知道居民端的用户id + entity.setUserId(StrConstant.EPMETY_STR); + entity.setOrgName(finalOrgName); + // 发送结果:1成功,0失败 默认插入发送成功。下面没有找到居民端的用户id,会更新 + entity.setSendRes(NumConstant.ONE_STR); + // v2:0行程上报,1疫苗接种关注名单,2隔离防疫原核酸检测 + // 身份证号手机号 + if (NumConstant.ZERO_STR.equals(formDTO.getOrigin())) { + IcTripReportRecordEntity icTripReportRecordEntity = icTripReportRecordDao.selectById(bdId); + if(null==icTripReportRecordEntity){ + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "ic_trip_report_record不存在id=" + bdId + "的记录", "获取身份证手机号为空"); + } + entity.setMobile(icTripReportRecordEntity.getMobile()); + entity.setIdCard(icTripReportRecordEntity.getIdCard()); + } else if (NumConstant.ONE_STR.equals(formDTO.getOrigin()) || NumConstant.TWO_STR.equals(formDTO.getOrigin())) { + IcEpidemicSpecialAttentionEntity icEpidemicSpecialAttentionEntity = icEpidemicSpecialAttentionDao.selectById(bdId); + if (null == icEpidemicSpecialAttentionEntity) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "ic_epidemic_special_attention不存在id=" + bdId + "的记录", "获取身份证手机号为空"); + } + entity.setMobile(icEpidemicSpecialAttentionEntity.getMobile()); + entity.setIdCard(icEpidemicSpecialAttentionEntity.getIdCard()); + } + entityList.add(entity); + } + if (CollectionUtils.isEmpty(entityList)) { + return; + } + insertBatch(entityList); + + // 通知渠道通知渠道 0小程序通知,1短信通知 + for (String channelValue : formDTO.getChannel()) { + if ("0".equals(channelValue)) { + // 小程序通知 + List msgList = new ArrayList<>(); + entityList.forEach(item -> { + // 根据身份证获取居民ID 如果一个客户下,存在多个身份证号相同的而用户,该接口只返回一个 + List userList = userBaseInfoService.getCommonIdNumUser(item.getCustomerId(), item.getIdCard()); + if (CollectionUtils.isNotEmpty(userList)) { + UserBaseInfoDTO userBaseInfoDTO = userList.get(NumConstant.ZERO); + UserMessageFormDTO messageFormDTO = new UserMessageFormDTO(); + messageFormDTO.setCustomerId(item.getCustomerId()); + messageFormDTO.setApp(AppClientConstant.APP_GOV); + messageFormDTO.setGridId(StrConstant.STAR); + messageFormDTO.setUserId(userBaseInfoDTO.getUserId()); + messageFormDTO.setTitle("您有一条通知消息!"); + messageFormDTO.setMessageContent(item.getContent()); + messageFormDTO.setReadFlag(Constant.UNREAD); + messageFormDTO.setMessageType(UserMessageTypeConstant.ANTIEPIDEMIC); + messageFormDTO.setTargetId(item.getId()); + msgList.add(messageFormDTO); + item.setUserId(userBaseInfoDTO.getUserId()); + } else { + // 没有找到居民端的用户id,发送失败 + item.setSendRes(NumConstant.ZERO_STR); + } + baseDao.updateById(item); + }); + // 发送小程序消息-站内信 + Result result = messageFeignClient.saveUserMessageList(msgList); + if (!result.success()) { + log.warn("发送小程序消息失败" + JSON.toJSONString(result)); + } + } else { + // 短信通知再说 todo + } + + + } + + + } + + + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiCollectServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiCollectServiceImpl.java index 599f9e81f8..c519210d7b 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiCollectServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiCollectServiceImpl.java @@ -224,6 +224,18 @@ public class IcResiCollectServiceImpl extends BaseServiceImpl orgInfoList = new ArrayList<>(); + for (String orgId : split) { + AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(orgId); + if (null == agencyInfo){ + throw new EpmetException("查询组织信息失败:"+orgId); + } + OrgInfoIdAndNameResultDTO orgInfoResultDTO = new OrgInfoIdAndNameResultDTO(orgId,agencyInfo.getOrganizationName()); + orgInfoList.add(orgInfoResultDTO); + } + result.setOrgIdPathList(orgInfoList); //查询成员信息 List memberList = icResiMemberDao.selectListByCollectId(dto.getId()); result.setMemberList(memberList); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserExportServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserExportServiceImpl.java index 8157ac1ccf..b0b9a12f77 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserExportServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserExportServiceImpl.java @@ -276,7 +276,7 @@ public class IcResiUserExportServiceImpl implements IcResiUserExportService { param.setExportConfig(exportConfig); Result exportConfigResult = operCustomizeOpenFeignClient.getExcelHeaderAndSqlColumnForExport(param); if (!exportConfigResult.success()) { - log.error("获取模板失败,internalMsg:{},msg:{}", exportConfigResult.getInternalMsg(), exportConfigResult.getMsg()); + log.error("/oper/customize/icExportTemplate/getExcelHeaderAndSqlColumnForExport获取模板失败,入参{},internalMsg:{},msg:{}", JSON.toJSONString(param), exportConfigResult.getInternalMsg(), exportConfigResult.getMsg()); throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), exportConfigResult.getInternalMsg(), exportConfigResult.getInternalMsg()); } IcCustomExportResultDTO data = exportConfigResult.getData(); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcTripReportRecordServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcTripReportRecordServiceImpl.java index 97f5ed43e0..a758fdba92 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcTripReportRecordServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcTripReportRecordServiceImpl.java @@ -221,6 +221,7 @@ public class IcTripReportRecordServiceImpl extends BaseServiceImpl implements OperUserService { @Autowired @@ -61,6 +69,8 @@ public class OperUserServiceImpl extends BaseServiceImpl page(Map params) { @@ -129,6 +139,13 @@ public class OperUserServiceImpl extends BaseServiceImpl lambdaQueryWrapper = new LambdaQueryWrapper<>(); lambdaQueryWrapper.eq(OperUserEntity::getUserId,userId); - baseDao.update(param, lambdaQueryWrapper); + + + baseDao.update(param, lambdaQueryWrapper); } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java index 56a5f56400..a328399810 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java @@ -18,6 +18,7 @@ package com.epmet.service.impl; import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; @@ -25,10 +26,15 @@ import com.epmet.commons.tools.constant.AppClientConstant; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.redis.common.CustomerOrgRedis; +import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import com.epmet.commons.tools.redis.common.bean.ResiUserInfoCache; import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.NameUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dao.*; import com.epmet.dto.RegisterRelationDTO; @@ -36,10 +42,13 @@ import com.epmet.dto.UserBaseInfoDTO; import com.epmet.dto.UserResiInfoDTO; import com.epmet.dto.UserWechatDTO; import com.epmet.dto.form.CommonUserIdFormDTO; +import com.epmet.dto.form.DingLoginResiFormDTO; import com.epmet.dto.form.UserRoleFormDTO; import com.epmet.dto.form.VolunteerRegResiFormDTO; import com.epmet.dto.result.*; +import com.epmet.entity.RegisterRelationEntity; import com.epmet.entity.UserBaseInfoEntity; +import com.epmet.entity.UserEntity; import com.epmet.entity.UserWechatEntity; import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.redis.UserBaseInfoRedis; @@ -57,6 +66,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +import javax.annotation.Resource; import java.util.*; /** @@ -90,6 +100,8 @@ public class UserBaseInfoServiceImpl extends BaseServiceImpl page(Map params) { @@ -212,7 +224,7 @@ public class UserBaseInfoServiceImpl extends BaseServiceImpl registerWrapper = new LambdaQueryWrapper<>(); + registerWrapper.eq(RegisterRelationEntity::getCustomerId, formDTO.getCustomerId()); + registerWrapper.eq(RegisterRelationEntity::getUserId, baseInfo.getUserId()); + registerWrapper.eq(RegisterRelationEntity::getFirstRegister, NumConstant.ONE_STR); + RegisterRelationEntity registerRelation = registerRelationDao.selectOne(registerWrapper); + if (null != registerRelation) { + result.setAgencyId(registerRelation.getAgencyId()); + result.setGridId(registerRelation.getGridId()); + GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(registerRelation.getGridId()); + if (null == gridInfo) { + logger.error(String.format("获取用户注册网格信息为空,userId:%s,gridId:%s", baseInfo.getUserId(), registerRelation.getGridId())); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取网格信息为空", "获取小程序注册网格信息失败"); + } + result.setGridName(gridInfo.getGridNamePath()); + result.setRegFlag(true); + } + } + return result; + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserResiInfoServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserResiInfoServiceImpl.java index 5e7d901f6c..3efd7e01fa 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserResiInfoServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserResiInfoServiceImpl.java @@ -18,6 +18,7 @@ package com.epmet.service.impl; import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.common.token.util.UserUtil; @@ -26,30 +27,28 @@ import com.epmet.commons.tools.constant.EpmetRoleKeyConstant; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; -import com.epmet.commons.tools.enums.IdCardTypeEnum; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.redis.common.CustomerOrgRedis; +import com.epmet.commons.tools.redis.common.bean.GridInfoCache; +import com.epmet.commons.tools.redis.common.bean.ResiUserInfoCache; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.IdCardRegexUtils; +import com.epmet.commons.tools.utils.NameUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.SmsTemplateConstant; import com.epmet.constant.UserConstant; import com.epmet.constant.UserResiRegisterConstant; import com.epmet.constant.UserRoleConstant; -import com.epmet.dao.UserCustomerDao; -import com.epmet.dao.UserResiInfoDao; -import com.epmet.dao.UserWechatDao; +import com.epmet.dao.*; import com.epmet.dto.UserResiInfoDTO; import com.epmet.dto.UserResiRegisterVisitDTO; import com.epmet.dto.UserRoleDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; -import com.epmet.entity.UserBaseInfoEntity; -import com.epmet.entity.UserResiInfoEntity; -import com.epmet.entity.UserResiRegisterVisitEntity; -import com.epmet.entity.UserWechatEntity; +import com.epmet.entity.*; import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.feign.GovIssueOpenFeignClient; import com.epmet.redis.UserBaseInfoRedis; @@ -67,6 +66,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; import java.util.*; /** @@ -103,9 +103,14 @@ public class UserResiInfoServiceImpl extends BaseServiceImpl page(Map params) { @@ -551,6 +556,116 @@ public class UserResiInfoServiceImpl extends BaseServiceImpl registerWrapper = new LambdaQueryWrapper<>(); + registerWrapper.eq(RegisterRelationEntity::getCustomerId, userResiInfoDTO.getCustomerId()); + registerWrapper.eq(RegisterRelationEntity::getUserId, userResiInfoDTO.getUserId()); + registerWrapper.eq(RegisterRelationEntity::getFirstRegister, NumConstant.ONE_STR); + RegisterRelationEntity registerRelation = registerRelationDao.selectOne(registerWrapper); + if (null != registerRelation) { + resDTO.setGridId(registerRelation.getGridId()); + GridInfoCache regGridInfo = CustomerOrgRedis.getGridInfo(registerRelation.getGridId()); + if (null == regGridInfo) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取注册网格信息失败", "获取注册网格信息失败"); + } + resDTO.setGridName(regGridInfo.getGridNamePath()); + resDTO.setAgencyId(regGridInfo.getPid()); + } + } + //6:记录用户访问的网格grid_latest + LambdaQueryWrapper latestWrapper = new LambdaQueryWrapper<>(); + latestWrapper.eq(GridLatestEntity::getCustomerId, userResiInfoDTO.getCustomerId()); + latestWrapper.eq(GridLatestEntity::getGridId, userResiInfoDTO.getGridId()); + latestWrapper.eq(GridLatestEntity::getCustomerUserId, userResiInfoDTO.getUserId()); + GridLatestEntity latest = gridLatestDao.selectOne(latestWrapper); + if (null == latest) { + latest = new GridLatestEntity(); + latest.setCustomerId(userResiInfoDTO.getCustomerId()); + latest.setGridId(userResiInfoDTO.getGridId()); + latest.setCustomerUserId(userResiInfoDTO.getUserId()); + latest.setAreaCode(gridInfo.getAreaCode()); + latest.setPid(gridInfo.getPid()); + latest.setLatestTime(new Date()); + gridLatestDao.insert(latest); + } else { + GridLatestEntity latestEntity = new GridLatestEntity(); + latestEntity.setId(latest.getId()); + latestEntity.setLatestTime(new Date()); + gridLatestDao.updateById(latestEntity); + } + return resDTO; + } /** * 自动认证居民:志愿者注册,自动认证居民 diff --git a/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml b/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml index a9ec2fcadb..11018f0592 100644 --- a/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml +++ b/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml @@ -185,3 +185,8 @@ thread: keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ threadNamePrefix: @thread.threadPool.thread-name-prefix@ rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ +epmet: + login: + publicKey: MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKjgDaHWqWgquoatbC4zzQCgqE8C425VIOyzJVVgH1HUYCHpuNUnGCv3HBAl2RsziWQqQgd1xxl0C3a5J4J69o8CAwEAAQ== + privateKey: MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEAqOANodapaCq6hq1sLjPNAKCoTwLjblUg7LMlVWAfUdRgIem41ScYK/ccECXZGzOJZCpCB3XHGXQLdrkngnr2jwIDAQABAkAyYaWvgrtHuHetdk+v+QRQC54q9FGluP/5nfilX+f4IUf8j92o/ZohTtmJn9qcDiAP4wxCLIsfy4IW3psST78BAiEA0A/E0WvtI7spWnjfw+wMDhdVMIbIJvDbj/cqMwRZInUCIQDPyO2sbXpwDjmAvyn0jpGJJxU5POWYdI37rTf9fScMcwIhAMkWNHbjBHKANVuHb10ACjakPmWEHnXkW5AspdBg53TxAiARPbzq99KXBbcjxbj3f/T3inSqYTEz60f0wDTLJd1dnQIhAIFe6Jd1TduIxGk1PDh/b/3q0jNGgVXkFnUBnKWDaL9N + diff --git a/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.62__alter_customer_staff.sql b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.62__alter_customer_staff.sql new file mode 100644 index 0000000000..c8a15854eb --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.62__alter_customer_staff.sql @@ -0,0 +1,2 @@ +ALTER TABLE epmet_user.customer_staff ADD USER_ACCOUNT varchar(32) NULL COMMENT '登录账户'; +ALTER TABLE epmet_user.customer_staff CHANGE USER_ACCOUNT USER_ACCOUNT varchar(32) NULL COMMENT '登录账户' AFTER USER_ID; diff --git a/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.69__alter_ic_epidemic_special_attention.sql b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.69__alter_ic_epidemic_special_attention.sql new file mode 100644 index 0000000000..24111f66ce --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.69__alter_ic_epidemic_special_attention.sql @@ -0,0 +1,3 @@ +ALTER TABLE ic_epidemic_special_attention ADD COLUMN IS_HISTORY tinyint not null DEFAULT '0' COMMENT '是否历史关注,1是0否' AFTER ATTENTION_TYPE; + +ALTER TABLE ic_epidemic_special_attention ADD COLUMN ISOLATED_STATE VARCHAR(20) COMMENT '隔离类型,来自字典表' AFTER IS_HISTORY; diff --git a/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.70__default_ic_epidemic_special_attention.sql b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.70__default_ic_epidemic_special_attention.sql new file mode 100644 index 0000000000..99e215885a --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.70__default_ic_epidemic_special_attention.sql @@ -0,0 +1,5 @@ +UPDATE ic_epidemic_special_attention +SET UPDATED_TIME = NOW(), + ISOLATED_STATE = '1' +WHERE ISOLATED_STATE IS NULL + AND ATTENTION_TYPE = 2; \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.71__icnotice_sendres.sql b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.71__icnotice_sendres.sql new file mode 100644 index 0000000000..d15af15aa1 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.71__icnotice_sendres.sql @@ -0,0 +1,10 @@ +ALTER TABLE ic_notice ADD COLUMN SEND_RES VARCHAR ( 1 ) NOT NULL DEFAULT '1' COMMENT '发送结果:1成功,0失败' after ORG_NAME; +update ic_notice n +set n.SEND_RES='1' +where n.USER_ID is not null + and n.USER_ID !=''; + +update ic_notice n +set n.SEND_RES='0' +where (n.USER_ID is null + or n.USER_ID =''); diff --git a/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.72__icepidemic_ISOLATED_STATE .sql b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.72__icepidemic_ISOLATED_STATE .sql new file mode 100644 index 0000000000..9fafca376f --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.72__icepidemic_ISOLATED_STATE .sql @@ -0,0 +1 @@ +ALTER TABLE ic_epidemic_special_attention MODIFY COLUMN ISOLATED_STATE VARCHAR(20) COMMENT '隔离类型,来自字典表;集中隔离:0;居家隔离1;居家健康监测2;已出隔离期3'; \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.73__datasync_config.sql b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.73__datasync_config.sql new file mode 100644 index 0000000000..751b7914d4 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.73__datasync_config.sql @@ -0,0 +1,36 @@ +CREATE TABLE `data_sync_config` ( + `ID` varchar(64) NOT NULL COMMENT 'ID主键', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户ID。如果该角色由客户定制,其下的机关和部门都不再各自定制自己的角色,这个字段会比较有用。包括通用角色以及客户定制角色。', + `DEPT_CODE` varchar(64) NOT NULL COMMENT '部门编码', + `DEPT_NAME` varchar(255) NOT NULL COMMENT '部门名称', + `DATA_NAME` varchar(255) NOT NULL COMMENT '数据名称', + `SWITCH_STATUS` varchar(10) NOT NULL COMMENT '开启:open;关闭:closed', + `SORT` int(11) NOT NULL COMMENT '排序', + `DEL_FLAG` int(11) NOT NULL COMMENT '删除标识:0.未删除 1.已删除', + `REVISION` int(11) NOT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='数据更新配置表'; + + +CREATE TABLE `data_sync_scope` ( + `ID` varchar(64) NOT NULL COMMENT '主键', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户ID。如果该角色由客户定制,其下的机关和部门都不再各自定制自己的角色,这个字段会比较有用。包括通用角色以及客户定制角色。', + `DATA_SYNC_CONFIG_ID` varchar(64) NOT NULL COMMENT '数据更新配置表主键', + `ORG_TYPE` varchar(10) NOT NULL COMMENT '网格:grid,组织:agency', + `ORG_ID` varchar(64) NOT NULL COMMENT '组织或者网格id', + `PID` varchar(64) NOT NULL COMMENT 'org_id的上级', + `ORG_ID_PATH` varchar(255) NOT NULL COMMENT 'org_id的全路径,包含自身', + `DEL_FLAG` int(11) NOT NULL COMMENT '删除标识:0.未删除 1.已删除', + `REVISION` int(11) NOT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='数据更新范围表'; + + diff --git a/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.74__natcompare.sql b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.74__natcompare.sql new file mode 100644 index 0000000000..f2d87662a2 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.74__natcompare.sql @@ -0,0 +1,43 @@ +CREATE TABLE `ic_nat_compare_record` ( + `ID` varchar(64) NOT NULL COMMENT '主键', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户Id', + `NAME` varchar(64) NOT NULL COMMENT '姓名', + `ID_CARD` varchar(64) NOT NULL COMMENT '身份证', + `MOBILE` varchar(32) DEFAULT NULL COMMENT '手机号', + `IS_RESI_USER` varchar(1) DEFAULT '0' COMMENT '是否客户下居民(0:否 1:是)', + `IC_RESI_USER_ID` varchar(64) DEFAULT NULL COMMENT '是否客户下居民,ic_resi_user.id', + `LATEST_NAT_TIME` datetime DEFAULT NULL COMMENT '最近一次核酸时间:接口填入', + `NAT_RESULT` varchar(1) DEFAULT NULL COMMENT '检测结果(0:阴性 1:阳性):接口填入', + `NAT_ADDRESS` varchar(255) DEFAULT NULL COMMENT '检测地点:接口填入', + `CONTACT_ADDRESS` varchar(255) DEFAULT NULL COMMENT '联系地址:接口填入', + `LATEST_IMPORT_TIME` datetime DEFAULT NULL COMMENT '最新一次导入时间,对应ic_nat_compare_rec_relation.IMPORT_TIME', + `DEL_FLAG` int(11) NOT NULL COMMENT '删除标识:0.未删除 1.已删除', + `REVISION` int(11) NOT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='核酸比对记录'; + +CREATE TABLE `ic_nat_compare_rec_relation` ( + `ID` varchar(64) NOT NULL COMMENT '主键(agency_id+compare_rec_id+import_date)唯一)', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户Id', + `COMPARE_REC_ID` varchar(64) NOT NULL COMMENT 'ic_nat_compare_record.id', + `IMPORT_DATE` varchar(32) NOT NULL COMMENT '导入日期:yyyyMMdd', + `IMPORT_TIME` datetime NOT NULL COMMENT '导入时间,同一天内导入多次需要更新此列值', + `AGENCY_ID` varchar(64) NOT NULL COMMENT '操作人员所属组织id', + `AGENCY_NAME` varchar(255) DEFAULT NULL COMMENT '组织名称', + `PID` varchar(64) DEFAULT NULL COMMENT 'agency_id的上级', + `PIDS` varchar(255) DEFAULT NULL COMMENT 'agency_id组织的所有上级', + `STAFF_ID` varchar(64) NOT NULL COMMENT '最近一次操作人', + `STAFF_NAME` varchar(64) NOT NULL COMMENT '最近一次操作人姓名', + `IS_AGENCY_USER` varchar(1) DEFAULT '0' COMMENT '是否本社区(agency_id)下居民(0:否 1:是)', + `DEL_FLAG` int(11) NOT NULL COMMENT '删除标识:0.未删除 1.已删除', + `REVISION` int(11) NOT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人,第一次导入到ic_nat_compare_record的人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='核酸比对组织关系表'; \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.75__datacode.sql b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.75__datacode.sql new file mode 100644 index 0000000000..74ed8d1a42 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.75__datacode.sql @@ -0,0 +1 @@ +alter table data_sync_config add COLUMN `DATA_CODE` varchar(32) NOT NULL COMMENT '数据key'after SORT; \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/excel/attention_nat_template.xlsx b/epmet-user/epmet-user-server/src/main/resources/excel/attention_nat_template.xlsx index e41ebaf0a7..de79811f24 100644 Binary files a/epmet-user/epmet-user-server/src/main/resources/excel/attention_nat_template.xlsx and b/epmet-user/epmet-user-server/src/main/resources/excel/attention_nat_template.xlsx differ diff --git a/epmet-user/epmet-user-server/src/main/resources/excel/ic_nat_compare_record_template.xlsx b/epmet-user/epmet-user-server/src/main/resources/excel/ic_nat_compare_record_template.xlsx new file mode 100644 index 0000000000..f2e5997d37 Binary files /dev/null and b/epmet-user/epmet-user-server/src/main/resources/excel/ic_nat_compare_record_template.xlsx differ diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml index 5250d48a0a..60b32c4d32 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml @@ -11,6 +11,14 @@ order by cs.ACTIVE_TIME desc,cs.CREATED_TIME asc + + + + + + + + + SELECT + ID AS id, + DEPT_CODE AS deptCode, + DEPT_NAME AS deptName, + DATA_NAME AS dataName, + switch_status AS switchStatus, + sort AS sort, + data_code AS dataCode, + customer_id as customerId + FROM data_sync_config + WHERE DEL_FLAG = 0 + + AND CUSTOMER_ID = #{customerId} + + order by sort + + + + + + + + + \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/DataSyncScopeDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/DataSyncScopeDao.xml new file mode 100644 index 0000000000..0fd7649a79 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/DataSyncScopeDao.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcEpidemicSpecialAttentionDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcEpidemicSpecialAttentionDao.xml index fe16fb2908..5db13945cb 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcEpidemicSpecialAttentionDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcEpidemicSpecialAttentionDao.xml @@ -8,7 +8,7 @@ UPDATE ic_epidemic_special_attention SET UPDATED_TIME = NOW(), IS_ATTENTION = 0, - del_flag = 1 + IS_HISTORY = '1' WHERE del_flag = 0 AND attention_type = #{attentionType} AND id IN ( @@ -18,12 +18,62 @@ ) + + UPDATE ic_epidemic_special_attention + SET UPDATED_TIME = NOW(), + IS_ATTENTION = 1 + WHERE del_flag = 0 + AND attention_type = #{attentionType} + AND id_card IN ( + + #{l} + + ) + + + + UPDATE ic_epidemic_special_attention + + + + when id_card = #{item.idCard} then 1 + + + + + when id_card = #{item.idCard} then #{item.reason} + + + + + when id_card = #{item.idCard} then #{item.remark} + + + + + when id_card = #{item.idCard} then #{item.isolatedState} + + + updated_time = now() + + WHERE del_flag = 0 + AND attention_type = #{attentionType} + AND is_history = 0 + AND id_card IN ( + + #{l.idCard} + + ) + + SELECT a.id, a.`NAME`, + a.customer_id as customerId, a.MOBILE, + a.MOBILE as realMobile, a.ID_CARD, + a.ID_CARD as realIdCard, a.REMARK, a.REASON, b.VILLAGE_ID, b.BUILD_ID, b.UNIT_ID, b.HOME_ID, - IFNULL((SELECT DATE_FORMAT(CREATED_TIME,'%Y-%m-%d %H:%i:%s') FROM ic_notice WHERE DEL_FLAG = '0' AND ORIGIN = #{attentionType} AND ID_CARD = a.ID_CARD ORDER BY CREATED_TIME DESC LIMIT 1),'') AS lastInformTime + b.id as userId, + b.grid_id as gridId, + a.ISOLATED_STATE, + IFNULL((SELECT DATE_FORMAT(NAT_TIME,'%Y-%m-%d %H:%i:%s') FROM ic_nat WHERE DEL_FLAG = '0' AND ID_CARD = a.ID_CARD ORDER BY CREATED_TIME DESC LIMIT 1),'') AS lastNatTime FROM ic_epidemic_special_attention a LEFT JOIN ic_resi_user b ON a.id_card = b.id_card AND b.del_flag = '0' and a.CUSTOMER_ID = b.CUSTOMER_ID WHERE a.DEL_FLAG = 0 AND concat(a.pids,':',ORG_ID) like concat('%',#{orgId},'%') AND a.ATTENTION_TYPE = #{attentionType} + + AND a.isolated_state = #{isolatedState} + + + AND a.isolated_state is not null + + + AND a.IS_ATTENTION = 1 + + + AND a.is_history = 1 + AND a.`NAME` LIKE CONCAT('%',#{name},'%') AND a.MOBILE LIKE CONCAT('%',#{mobile},'%') - + AND a.ID_CARD LIKE CONCAT('%',#{idCard},'%') @@ -125,6 +194,7 @@ ID_CARD FROM ic_epidemic_special_attention WHERE DEL_FLAG = 0 + AND IS_HISTORY = 0 AND ATTENTION_TYPE = #{attentionType} AND ID_CARD IN ( @@ -158,8 +228,30 @@ a.MOBILE, a.ID_CARD, a.REMARK, - a.REASON + a.REASON, + a.ISOLATED_STATE FROM ic_epidemic_special_attention a WHERE a.ID = #{id} + + diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcNatCompareRecRelationDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcNatCompareRecRelationDao.xml new file mode 100644 index 0000000000..e3f58f05b1 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcNatCompareRecRelationDao.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcNatCompareRecordDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcNatCompareRecordDao.xml new file mode 100644 index 0000000000..2a33a5680b --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcNatCompareRecordDao.xml @@ -0,0 +1,71 @@ + + + + + + + + + + \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcNatDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcNatDao.xml index 4459802f6d..e6dd5b0417 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcNatDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcNatDao.xml @@ -135,6 +135,19 @@ LIMIT 1 + + DELETE FROM ic_nat WHERE id = #{icNatId} diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml index caba921430..e8b69faefa 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml @@ -945,6 +945,33 @@ AND GRID_ID = #{gridId} + + AND a.VILLAGE_ID = #{neighborId} + + + AND a.BUILD_ID = #{buildingId} + + + AND a.UNIT_ID = #{unitId} + + + AND a.HOME_ID = #{houseId} + + + AND a.`NAME` LIKE concat( '%', #{name}, '%' ) + + + AND a.MOBILE LIKE concat( '%', #{mobile}, '%' ) + + + AND a.ID_CARD LIKE concat( '%', #{idCard}, '%' ) + + + AND a.BIRTHDAY = ]]> #{startBirthDay} + + + AND a.BIRTHDAY #{endBirthDay} + ) t WHERE 1=1 diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcTripReportRecordDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcTripReportRecordDao.xml index 15a413748b..b3e00357ac 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcTripReportRecordDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcTripReportRecordDao.xml @@ -26,35 +26,38 @@ + + + diff --git a/pom.xml b/pom.xml index 95a3495790..0eb19cb77e 100644 --- a/pom.xml +++ b/pom.xml @@ -81,7 +81,7 @@ com.aliyun alibaba-dingtalk-service-sdk - 1.0.1 + 2.0.0