diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcCommunitySelfOrganizationDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcCommunitySelfOrganizationDTO.java index 6364dc08e2..a8cad6d0f6 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcCommunitySelfOrganizationDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcCommunitySelfOrganizationDTO.java @@ -104,6 +104,21 @@ public class IcCommunitySelfOrganizationDTO implements Serializable { */ private String latitude; + /** + * 同步状态【已同步:sync 未同步:not_sync】 + */ + private String syncType; + + /** + * 部门ID customer_department.id + */ + private String deptId; + + /** + * 部门下工作人员Id + */ + private String deptStaffId; + /** * */ diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcPartyUnitDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcPartyUnitDTO.java index 2258b94762..5935d564de 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcPartyUnitDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcPartyUnitDTO.java @@ -134,6 +134,21 @@ public class IcPartyUnitDTO implements Serializable { */ private String remark; + /** + * 同步状态【已同步:sync 未同步:not_sync】 + */ + private String syncType; + + /** + * 部门ID customer_department.id + */ + private String deptId; + + /** + * 部门下工作人员Id + */ + private String deptStaffId; + /** * 删除标识 0未删除、1已删除 */ diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java index 9939b88455..e3b04df7bb 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java @@ -16,6 +16,7 @@ import com.epmet.dto.form.demand.UserDemandNameQueryFormDTO; import com.epmet.dto.form.resi.ResiVolunteerAuthenticateFormDTO; import com.epmet.dto.form.resi.ResisByPolicyRulesFormDTO; import com.epmet.dto.form.resi.VolunteerCommonFormDTO; +import com.epmet.dto.result.CheckStaffInfoResultDTO; import com.epmet.dto.result.PartyUnitListResultDTO; import com.epmet.dto.result.demand.IcResiDemandDictDTO; import com.epmet.dto.result.resi.PageVolunteerInfoResultDTO; @@ -166,4 +167,8 @@ public interface EpmetHeartOpenFeignClient { */ @PostMapping("/heart/policy/rules4ResiListAndExport/{ruleId}") Result listPolicyRules4QueryAndExport(@PathVariable("ruleId") String ruleId); + + @PostMapping("/heart/icpartyunit/editpartyorcommunity") + Result editPartyOrCommunity(@RequestBody CheckStaffInfoResultDTO formDTO); + } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java index 815bfab92c..558cd43f2b 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java @@ -18,6 +18,7 @@ import com.epmet.dto.form.demand.UserDemandNameQueryFormDTO; import com.epmet.dto.form.resi.ResiVolunteerAuthenticateFormDTO; import com.epmet.dto.form.resi.ResisByPolicyRulesFormDTO; import com.epmet.dto.form.resi.VolunteerCommonFormDTO; +import com.epmet.dto.result.CheckStaffInfoResultDTO; import com.epmet.dto.result.PartyUnitListResultDTO; import com.epmet.dto.result.demand.IcResiDemandDictDTO; import com.epmet.dto.result.demand.OptionDTO; @@ -166,4 +167,9 @@ public class EpmetHeartOpenFeignClientFallback implements EpmetHeartOpenFeignCli public Result listPolicyRules4QueryAndExport(String ruleId) { return ModuleUtils.feignConError(ServiceConstant.EPMET_HEART_SERVER, "listPolicyRules4QueryAndExport", ruleId); } + + @Override + public Result editPartyOrCommunity(CheckStaffInfoResultDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_HEART_SERVER, "editPartyOrCommunity", formDTO); + } } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcPartyUnitController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcPartyUnitController.java index 236e0d3b99..95093177cb 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcPartyUnitController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcPartyUnitController.java @@ -22,11 +22,7 @@ import com.epmet.dto.form.PartyUnitFormDTO; import com.epmet.dto.form.PartyUnitListFormDTO; import com.epmet.dto.form.*; import com.epmet.dto.form.demand.ServiceQueryFormDTO; -import com.epmet.dto.result.ImportTaskCommonResultDTO; -import com.epmet.dto.result.PartyTypepercentResultDTO; -import com.epmet.dto.result.PartyUnitDistributionResultDTO; -import com.epmet.dto.result.PartyUnitListResultDTO; -import com.epmet.dto.result.PartyUnitListbrieResultDTO; +import com.epmet.dto.result.*; import com.epmet.dto.result.demand.OptionDTO; import com.epmet.excel.IcPartyUnitExcel; import com.epmet.feign.EpmetCommonServiceOpenFeignClient; @@ -312,4 +308,14 @@ public class IcPartyUnitController { return new Result>().ok(icPartyUnitService.getAssistanceUnitList(tokenDto)); } + /** + * Desc: 联建单位、社会自组织同步/取消同步到通讯录部门后相应的修改业务数据 + * @author sun + */ + @PostMapping("editpartyorcommunity") + public Result editPartyOrCommunity(@RequestBody CheckStaffInfoResultDTO formDTO){ + icPartyUnitService.editPartyOrCommunity(formDTO); + return new Result(); + } + } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcCommunitySelfOrganizationEntity.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcCommunitySelfOrganizationEntity.java index 7098ce83e9..3f35e32184 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcCommunitySelfOrganizationEntity.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcCommunitySelfOrganizationEntity.java @@ -117,4 +117,19 @@ public class IcCommunitySelfOrganizationEntity extends BaseEpmetEntity { */ private String remark; + /** + * 同步状态【已同步:sync 未同步:not_sync】 + */ + private String syncType; + + /** + * 部门ID customer_department.id + */ + private String deptId; + + /** + * 部门下工作人员Id + */ + private String deptStaffId; + } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcPartyUnitEntity.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcPartyUnitEntity.java index 65c11a447f..47210a837a 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcPartyUnitEntity.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcPartyUnitEntity.java @@ -105,4 +105,19 @@ public class IcPartyUnitEntity extends BaseEpmetEntity { */ private String remark; + /** + * 同步状态【已同步:sync 未同步:not_sync】 + */ + private String syncType; + + /** + * 部门ID customer_department.id + */ + private String deptId; + + /** + * 部门下工作人员Id + */ + private String deptStaffId; + } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcPartyUnitService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcPartyUnitService.java index 53ddf81e19..8cc2d342a7 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcPartyUnitService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcPartyUnitService.java @@ -12,10 +12,7 @@ import com.epmet.dto.form.PartyUnitFormDTO; import com.epmet.dto.form.PartyUnitListFormDTO; import com.epmet.dto.form.PartyUnitListbriefFormDTO; import com.epmet.dto.form.demand.ServiceQueryFormDTO; -import com.epmet.dto.result.PartyTypepercentResultDTO; -import com.epmet.dto.result.PartyUnitDistributionResultDTO; -import com.epmet.dto.result.PartyUnitListResultDTO; -import com.epmet.dto.result.PartyUnitListbrieResultDTO; +import com.epmet.dto.result.*; import com.epmet.dto.result.demand.OptionDTO; import com.epmet.entity.IcPartyUnitEntity; import org.springframework.web.multipart.MultipartFile; @@ -182,4 +179,6 @@ public interface IcPartyUnitService extends BaseService { * @param form */ List getTypepercent(PartyTypepercentFormDTO form); + + void editPartyOrCommunity(CheckStaffInfoResultDTO formDTO); } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyUnitServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyUnitServiceImpl.java index 91dc0baa57..7b8df1b923 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyUnitServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyUnitServiceImpl.java @@ -55,6 +55,7 @@ import com.epmet.dto.form.demand.ServiceQueryFormDTO; import com.epmet.dto.result.*; import com.epmet.dto.result.demand.OptionDTO; import com.epmet.dto.result.demand.ServiceStatDTO; +import com.epmet.entity.IcCommunitySelfOrganizationEntity; import com.epmet.entity.IcPartyUnitEntity; import com.epmet.excel.IcPartyUnitImportExcel; import com.epmet.excel.IcPartyUnitImportFailedExcel; @@ -62,6 +63,7 @@ import com.epmet.feign.EpmetAdminOpenFeignClient; import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.feign.EpmetHeartOpenFeignClient; import com.epmet.feign.OssFeignClient; +import com.epmet.service.IcCommunitySelfOrganizationService; import com.epmet.service.IcPartyUnitService; import com.epmet.service.IcServiceItemDictService; import com.epmet.service.IcUserDemandRecService; @@ -111,6 +113,8 @@ public class IcPartyUnitServiceImpl extends BaseServiceImpl search(PartyUnitFormDTO formDTO) { @@ -711,4 +715,30 @@ public class IcPartyUnitServiceImpl extends BaseServiceImpl newRoles; + /** + * 部门类型 + * 联建单位: party_unit + * 社会自组织: community_org + */ + private String deptType; } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/CheckStaffInfoResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/CheckStaffInfoResultDTO.java index 0f500a0cab..01619b955a 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/CheckStaffInfoResultDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/CheckStaffInfoResultDTO.java @@ -17,8 +17,10 @@ package com.epmet.dto.result; +import com.epmet.dto.form.CheckStaffInfoFormDTO; import lombok.Data; +import javax.validation.constraints.NotBlank; import java.io.Serializable; @@ -41,10 +43,41 @@ public class CheckStaffInfoResultDTO implements Serializable { * 数据库中工作人员姓名【返参姓名有值的则需要更新工作人员信息】 */ private String personName; + /** + * 联建单位、社会自组织Id + */ + private String id; + /** + * 部门Id + */ + private String deptId; + /** + * 联建单位: party_unit + * 社会自组织: community_org + */ + private String deptType; + /** + * 部门下工作人员Id + */ + private String deptStaffId; + /** + * 已同步:sync 未同步:not_sync + */ + private String syncType; + + + //token中信息 + private String customerId; + private String userId; /** - * 类型,后端使用 + * 后端使用 */ - private Boolean key = true; + //工作人员添加入口Id(agencyId;deptId;gridId) + private String orgId = ""; + //工作人员添加入口类型(组织:agency;部门:dept;网格:gridId) + private String orgType = ""; + //工作人员Id,后端使用 + private String staffId = ""; } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java index fac881ed3e..448181bf74 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java @@ -162,16 +162,27 @@ public class DepartmentController { return new Result>().ok(deptList); } - /** * @Author sun * @Description 根据手机号姓名查询人员信息,联建单位、社会自组织新增使用 */ @PostMapping("checkstaffinfo") public Result checkStaffInfo(@LoginUser TokenDto tokenDTO, @RequestBody CheckStaffInfoFormDTO formDTO) { - ValidatorUtils.validateEntity(formDTO, CheckStaffInfoFormDTO.Check.class); + ValidatorUtils.validateEntity(formDTO, CheckStaffInfoFormDTO.CheckAdd.class); formDTO.setCustomerId(tokenDTO.getCustomerId()); - formDTO.setStaffId(tokenDTO.getUserId()); + formDTO.setUserId(tokenDTO.getUserId()); return new Result().ok(departmentService.checkStaffInfo(formDTO)); } + + /** + * @Author sun + * @Description 联建单位、社会自组织同步到通讯录操作 + */ + @PostMapping("addoreditdeptorstaff") + public Result addOrEditDeptOrStaff(@RequestBody CheckStaffInfoFormDTO formDTO) { + return new Result().ok(departmentService.addOrEditDeptOrStaff(formDTO)); + } + + + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/DepartmentService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/DepartmentService.java index d1f589b26e..020ef3551e 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/DepartmentService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/DepartmentService.java @@ -103,4 +103,6 @@ public interface DepartmentService { List listDepartmentListByStaffId(String staffId); CheckStaffInfoResultDTO checkStaffInfo(CheckStaffInfoFormDTO formDTO); + + CheckStaffInfoResultDTO addOrEditDeptOrStaff(CheckStaffInfoFormDTO formDTO); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java index aa8d6c1db8..69f3ab9ae2 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java @@ -17,6 +17,7 @@ package com.epmet.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; @@ -39,14 +40,11 @@ import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.CustomerStaffDepartmentDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; -import com.epmet.entity.CustomerAgencyEntity; -import com.epmet.entity.CustomerDepartmentEntity; -import com.epmet.entity.CustomerStaffDepartmentEntity; +import com.epmet.entity.*; +import com.epmet.feign.EpmetHeartOpenFeignClient; import com.epmet.feign.EpmetUserFeignClient; import com.epmet.feign.EpmetUserOpenFeignClient; -import com.epmet.service.CustomerDepartmentService; -import com.epmet.service.CustomerStaffDepartmentService; -import com.epmet.service.DepartmentService; +import com.epmet.service.*; import com.epmet.util.ModuleConstant; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; @@ -55,6 +53,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +import org.springframework.web.bind.annotation.RequestBody; import java.util.ArrayList; import java.util.List; @@ -86,6 +85,15 @@ public class DepartmentServiceImpl implements DepartmentService { private EpmetUserOpenFeignClient epmetUserOpenFeignClient; @Autowired private StaffOrgRelationDao staffOrgRelationDao; + @Autowired + private CustomerStaffAgencyService customerStaffAgencyService; + @Autowired + private CustomerAgencyService customerAgencyService; + @Autowired + private StaffOrgRelationService staffOrgRelationService; + @Autowired + private EpmetHeartOpenFeignClient epmetHeartOpenFeignClient; + /** * @param formDTO * @return @@ -294,6 +302,13 @@ public class DepartmentServiceImpl implements DepartmentService { @Override public CheckStaffInfoResultDTO checkStaffInfo(CheckStaffInfoFormDTO formDTO) { CheckStaffInfoResultDTO resultDTO = new CheckStaffInfoResultDTO(); + resultDTO.setCustomerId(formDTO.getCustomerId()); + resultDTO.setUserId(formDTO.getUserId()); + //座机号的直接返回 + if(formDTO.getMobile().startsWith("0")){ + resultDTO.setMsg("座机账号无法创建账号,建议使用填写手机号,否则将无法获取通知信息"); + return resultDTO; + } //1.根据手机号查询客户下工作人员信息 CustomerStaffFormDTO user = new CustomerStaffFormDTO(); user.setCustomerId(formDTO.getCustomerId()); @@ -314,29 +329,29 @@ public class DepartmentServiceImpl implements DepartmentService { if (CollectionUtils.isEmpty(list)) { return resultDTO; } + resultDTO.setOrgId(list.get(0).getOrgId()); + resultDTO.setOrgType(list.get(0).getOrgType()); + resultDTO.setStaffId(list.get(0).getStaffId()); //3.校验工作人员的注册关系【从哪里新增进来的工作人员】 //获取当前操作人员缓存信息 - CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId()); + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getUserId()); if (null == staffInfo) { - throw new EpmetException(String.format("查询工作人员%s缓存信息失败...", formDTO.getStaffId())); + throw new EpmetException(String.format("查询工作人员%s缓存信息失败...", formDTO.getUserId())); } //所属组织信息不同的给提示【所属组织不同时则不新增部门、不新增工作人员】 if (!list.get(0).getAgencyId().equals(staffInfo.getAgencyId())) { resultDTO.setMsg("联系电话已存在其他组织工作账号中,请使用其他手机号,否则将无法获取通知信息"); - resultDTO.setKey(false); return resultDTO; } //从网格下添加的人给提示【网格下加的人时则不新增部门、不新增工作人员】 - if ("gridId".equals(list.get(0).getOrgType())) { + if (!"agency".equals(list.get(0).getOrgType())) { resultDTO.setMsg("联系电话已存在其他部门工作账号中,请先将该工作人员调动至本组织下,再次添加"); - resultDTO.setKey(false); return resultDTO; } //账号被禁用的给提示【人员被禁用的则不新增部门、不新增工作人员】 if ("disabled".equals(userResult.getData().getEnableFlag())) { resultDTO.setMsg("该工作人员账号已被禁用,请使用其他联系电话,否则将无法获取通知信息"); - resultDTO.setKey(false); return resultDTO; } //姓名不一样的给反馈 @@ -348,5 +363,116 @@ public class DepartmentServiceImpl implements DepartmentService { return resultDTO; } + @Override + public CheckStaffInfoResultDTO addOrEditDeptOrStaff(CheckStaffInfoFormDTO formDTO) { + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getUserId()); + if (null == staffInfo) { + throw new EpmetException(String.format("查询工作人员%s缓存信息失败...", formDTO.getUserId())); + } + //1.校验当前数据是否允许操作 + CheckStaffInfoResultDTO resultDTO = checkStaffInfo(formDTO); + if(!resultDTO.getType()){ + return resultDTO; + } + //2.根据校验结果操作数据 + //2-1.没查到人的直接新增部门、人员 + if(StringUtils.isBlank(resultDTO.getOrgType())){ + //一、新增工作人员 + StaffSubmitFromDTO submitDTO = ConvertUtils.sourceToTarget(formDTO, StaffSubmitFromDTO.class); + submitDTO.setName(formDTO.getPersonName()); + submitDTO.setAgencyId(staffInfo.getAgencyId()); + submitDTO.setGender(0); + submitDTO.setWorkType("fulltime"); + Result staffResult = epmetUserOpenFeignClient.deptToAddStaff(submitDTO); + if (!staffResult.success()) { + throw new RenException("人员添加失败" + staffResult.getMsg()); + } + //二、新增部门 + AddDepartmentFormDTO deptDTO = new AddDepartmentFormDTO(); + deptDTO.setAgencyId(staffInfo.getAgencyId()); + deptDTO.setDepartmentDuty(""); + deptDTO.setDepartmentName(formDTO.getDeptName()); + deptDTO.setTotalUser(1); + Result deptResult = addDepartment(deptDTO); + //三、新增组织人员关系数据 + //人员机关关系表 + CustomerStaffAgencyEntity customerStaffAgencyEntity = new CustomerStaffAgencyEntity(); + customerStaffAgencyEntity.setCustomerId(formDTO.getCustomerId()); + customerStaffAgencyEntity.setUserId(staffResult.getData().getUserId()); + customerStaffAgencyEntity.setAgencyId(staffInfo.getAgencyId()); + customerStaffAgencyService.insert(customerStaffAgencyEntity); + //机关总人数加一 + OrgResultDTO orgDTO = customerAgencyDao.selectAgencyDetail(staffInfo.getAgencyId(), "agency"); + CustomerAgencyEntity agencyEntity = new CustomerAgencyEntity(); + agencyEntity.setId(staffInfo.getAgencyId()); + agencyEntity.setTotalUser(orgDTO.getTotalUser() + 1); + customerAgencyService.updateById(agencyEntity); + //工作人员注册组织关系表新增数据 + StaffOrgRelationEntity staffOrgRelationEntity = new StaffOrgRelationEntity(); + staffOrgRelationEntity.setCustomerId(formDTO.getCustomerId()); + staffOrgRelationEntity.setPids(("".equals(orgDTO.getPids()) ? "" : orgDTO.getPids())); + staffOrgRelationEntity.setStaffId(staffResult.getData().getUserId()); + staffOrgRelationEntity.setOrgId(staffInfo.getAgencyId()); + staffOrgRelationEntity.setOrgType("agency"); + staffOrgRelationService.insert(staffOrgRelationEntity); + + //四、部门下新增人员关系数据 + CustomerStaffDepartmentEntity dept = new CustomerStaffDepartmentEntity(); + dept.setCustomerId(formDTO.getCustomerId()); + dept.setUserId(staffResult.getData().getUserId()); + dept.setDepartmentId(deptResult.getData().getDepartmentId()); + customerStaffDepartmentService.insert(dept); + //修改联建单位/社会自组织业务数据 + resultDTO.setId(formDTO.getId()); + resultDTO.setDeptId(deptResult.getData().getDepartmentId()); + resultDTO.setDeptType(formDTO.getDeptType()); + resultDTO.setDeptStaffId(staffResult.getData().getUserId()); + resultDTO.setSyncType("sync"); + Result heartResult = epmetHeartOpenFeignClient.editPartyOrCommunity(resultDTO); + if (!heartResult.success()) { + throw new RenException("修改联建单位/社会自组织业务数据失败" + heartResult.getMsg()); + } + + } + //2-2.查到是组织下的人,新增部门,绑定部门人员关系 + if(("agency".equals(resultDTO.getOrgType()))){ + //一、更新人员基础数据[姓名 手机号信息] + CustomerStaffDTO staffDTO = new CustomerStaffDTO(); + staffDTO.setUserId(resultDTO.getStaffId()); + staffDTO.setRealName(formDTO.getPersonName()); + staffDTO.setMobile(formDTO.getMobile()); + staffDTO.setUpdatedBy(resultDTO.getUserId()); + Result result = epmetUserOpenFeignClient.editToStaff(staffDTO); + if (!result.success()) { + throw new RenException("更新工作人员基础信息失败" + result.getMsg()); + } + //二、新增部门数据 + AddDepartmentFormDTO deptDTO = new AddDepartmentFormDTO(); + deptDTO.setAgencyId(staffInfo.getAgencyId()); + deptDTO.setDepartmentDuty(""); + deptDTO.setDepartmentName(formDTO.getDeptName()); + deptDTO.setTotalUser(1); + Result deptResult = addDepartment(deptDTO); + //三、部门下新增人员关系数据 + CustomerStaffDepartmentEntity dept = new CustomerStaffDepartmentEntity(); + dept.setCustomerId(formDTO.getCustomerId()); + dept.setUserId(resultDTO.getStaffId()); + dept.setDepartmentId(deptResult.getData().getDepartmentId()); + customerStaffDepartmentService.insert(dept); + //修改联建单位/社会自组织业务数据 + resultDTO.setId(formDTO.getId()); + resultDTO.setDeptId(deptResult.getData().getDepartmentId()); + resultDTO.setDeptType(formDTO.getDeptType()); + resultDTO.setDeptStaffId(resultDTO.getStaffId()); + resultDTO.setSyncType("sync"); + Result heartResult = epmetHeartOpenFeignClient.editPartyOrCommunity(resultDTO); + if (!heartResult.success()) { + throw new RenException("修改联建单位/社会自组织业务数据失败" + heartResult.getMsg()); + } + } + + return resultDTO; + } + } \ No newline at end of file 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 5cd018c37c..d6f6215b11 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 @@ -859,4 +859,10 @@ public interface EpmetUserOpenFeignClient { @PostMapping("/epmetuser/customerstaff/staffdetailinfo") Result staffDetailInfo(@RequestBody CustomerStaffFormDTO formDTO); + @PostMapping("/epmetuser/customerstaff/depttoaddstaff") + Result deptToAddStaff(@RequestBody StaffSubmitFromDTO fromDTO); + + @PostMapping("/epmetuser/customerstaff/edittostaff") + Result editToStaff(@RequestBody CustomerStaffDTO 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 6491dc477d..b6133865ad 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 @@ -651,4 +651,14 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "staffDetailInfo", formDTO); } + @Override + public Result deptToAddStaff(StaffSubmitFromDTO fromDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "deptToAddStaff", fromDTO); + } + + @Override + public Result editToStaff(CustomerStaffDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "editToStaff", formDTO); + } + } 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 f3a5d6bd99..cebe012041 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 @@ -498,5 +498,17 @@ public class CustomerStaffController { return new Result().ok(customerStaffService.staffDetailInfo(formDTO)); } + @PostMapping("depttoaddstaff") + public Result dedittostaffeptToAddStaff(@RequestBody StaffSubmitFromDTO fromDTO){ + Result result = customerStaffService.deptToAddStaff(fromDTO); + return result; + } + + @PostMapping(value = "edittostaff") + public Result editToStaff(@RequestBody CustomerStaffDTO formDTO) { + customerStaffService.editToStaff(formDTO); + return new Result(); + } + } 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 725a456b46..3cce3ff4b6 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 @@ -229,4 +229,6 @@ public interface CustomerStaffDao extends BaseDao { * @Description 工作人员基本信息 **/ List gridStaffMobileList(List staffIdList); + + void edit(CustomerStaffDTO formDTO); } 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 16d6e83189..6e6000b6db 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 @@ -349,4 +349,8 @@ public interface CustomerStaffService extends BaseService { List gridMobileList(String gridId, String userId); CustomerStaffDTO staffDetailInfo(CustomerStaffFormDTO formDTO); + + Result deptToAddStaff(StaffSubmitFromDTO fromDTO); + + void editToStaff(CustomerStaffDTO formDTO); } 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 1caf9abf5a..b25d014fc5 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 @@ -60,12 +60,14 @@ import com.epmet.service.UserService; import com.epmet.util.ModuleConstant; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.apache.ibatis.annotations.Param; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +import org.springframework.web.bind.annotation.RequestBody; import java.util.*; import java.util.stream.Collectors; @@ -874,4 +876,32 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl deptToAddStaff(StaffSubmitFromDTO fromDTO) { + //1.查询客户小程序端'工作人员'角色 + GovStaffRoleDTO govRole = govStaffRoleDao.getRoleByCustomerIdAndRoleKey(fromDTO.getCustomerId(), "staff"); + List roles = new ArrayList<>(); + roles.add(govRole.getId()); + fromDTO.setRoles(roles); + + //2.查询客户管理平台对应角色【联建单位负责人、社区自组织负责人】 + GovRoleListDTO roleDTO = new GovRoleListDTO(); + roleDTO.setName("party_unit".equals(fromDTO.getDeptType())?"联建单位负责人":"社区自组织负责人"); + Result resultRole = govAccessFeignClient.getGovRole(roleDTO); + if (!resultRole.success()) { + throw new RenException("人员添加失败" + resultRole.getMsg()); + } + List newRoles = new ArrayList<>(); + newRoles.add(resultRole.getData().getId()); + + //3.新增工作人员 + Result result = addStaff(fromDTO); + return result; + } + + @Override + public void editToStaff(CustomerStaffDTO formDTO) { + baseDao.edit(formDTO); + } + } 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 10965b93ce..919b69fe0b 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 @@ -456,4 +456,15 @@ + + UPDATE customer_staff + SET real_name = #{realName}, + mobile = #{mobile}, + updated_time = NOW(), + updated_by = #{updatedBy} + WHERE + del_flag = '0' + AND user_id = #{userId} + +