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/ThirdLoginController.java b/epmet-auth/src/main/java/com/epmet/controller/ThirdLoginController.java index 144e18d024..e8977cd508 100644 --- a/epmet-auth/src/main/java/com/epmet/controller/ThirdLoginController.java +++ b/epmet-auth/src/main/java/com/epmet/controller/ThirdLoginController.java @@ -63,6 +63,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 +102,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 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/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/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/ThirdLoginService.java b/epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java index c79a67d41c..69d13bf926 100644 --- a/epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java +++ b/epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java @@ -36,6 +36,15 @@ public interface ThirdLoginService { **/ UserTokenResultDTO enterOrg(ThirdWxmpEnteOrgFormDTO formDTO); + + /** + * @param formDTO + * @return + * @Author zhy + * @Description 单客户-选择组织,进入首页 + **/ + UserTokenResultDTO enterOrgByAccount(ThirdWxmpEnteOrgByAccountFormDTO formDTO); + /** * @param formDTO * @return @@ -52,6 +61,15 @@ public interface ThirdLoginService { **/ List getMyOrgByPassword(ThirdStaffOrgsFormDTO formDTO); + /** + * @param formDTO + * @return + * @author zhy + * @description 单客户-手机号密码获取组织 + **/ + List getMyOrgByAccount(ThirdStaffOrgByAccountFormDTO formDTO); + + /** * @param formDTO * @return 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/ThirdLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java index dd48a5577f..cd1495ddb2 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 @@ -425,6 +425,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 +600,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 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-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/resources/mapper/IcEventDao.xml b/epmet-module/gov-project/gov-project-server/src/main/resources/mapper/IcEventDao.xml index 578e1073c0..dd94828eb2 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/resources/mapper/IcEventDao.xml +++ b/epmet-module/gov-project/gov-project-server/src/main/resources/mapper/IcEventDao.xml @@ -72,7 +72,7 @@ and c.CATEGORY_CODE like CONCAT(#{categoryCode},'%') - order by e.CREATED_TIME desc + order by e.happen_time desc + + + + + + + +