diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/EditCommunitySelfOrganizationFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/EditCommunitySelfOrganizationFormDTO.java new file mode 100644 index 0000000000..588843ba92 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/EditCommunitySelfOrganizationFormDTO.java @@ -0,0 +1,83 @@ +package com.epmet.dto.form; + +import com.epmet.dto.IcCommunitySelfOrganizationPersonnelDTO; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * @Author zxc + * @DateTime 2021/11/18 5:32 下午 + * @DESC + */ +@Data +public class EditCommunitySelfOrganizationFormDTO implements Serializable { + + private static final long serialVersionUID = -4990925380900678065L; + + public interface EditCommunitySelfOrganizationForm{} + + /** + * 组织名称 + */ + @NotBlank(message = "organizationName不能为空",groups = EditCommunitySelfOrganizationForm.class) + private String organizationName; + + /** + * 组织人数 + */ + @NotNull(message = "organizationPersonCount不能为空",groups = EditCommunitySelfOrganizationForm.class) + private Integer organizationPersonCount; + + /** + * 负责人姓名 + */ + @NotBlank(message = "principalName不能为空",groups = EditCommunitySelfOrganizationForm.class) + private String principalName; + + /** + * 负责人电话 + */ + @NotBlank(message = "principalPhone不能为空",groups = EditCommunitySelfOrganizationForm.class) + private String principalPhone; + + /** + * 服务事项 + */ + @NotBlank(message = "serviceItem不能为空",groups = EditCommunitySelfOrganizationForm.class) + private String serviceItem; + + /** + * 社区自组织创建时间 + */ + @NotNull(message = "organizationCreatedTime不能为空",groups = EditCommunitySelfOrganizationForm.class) + private String organizationCreatedTime; + + /** + * 经度 + */ + @NotBlank(message = "longitude不能为空",groups = EditCommunitySelfOrganizationForm.class) + private String longitude; + + /** + * 纬度 + */ + @NotBlank(message = "latitude不能为空",groups = EditCommunitySelfOrganizationForm.class) + private String latitude; + + /** + * 社区自组织ID + */ + @NotBlank(message = "orgId不能为空",groups = EditCommunitySelfOrganizationForm.class) + private String orgId; + + /** + * 社区自组织人员 + */ + private List organizationPersonnel; +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcCommunitySelfOrganizationController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcCommunitySelfOrganizationController.java index 3093b70b91..c80950e2e0 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcCommunitySelfOrganizationController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcCommunitySelfOrganizationController.java @@ -30,6 +30,7 @@ import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.dto.IcCommunitySelfOrganizationDTO; import com.epmet.dto.form.AddCommunitySelfOrganizationFormDTO; +import com.epmet.dto.form.EditCommunitySelfOrganizationFormDTO; import com.epmet.excel.IcCommunitySelfOrganizationExcel; import com.epmet.service.IcCommunitySelfOrganizationService; import org.springframework.beans.factory.annotation.Autowired; @@ -109,4 +110,18 @@ public class IcCommunitySelfOrganizationController { return new Result(); } + /** + * @Description 修改社区自组织 + * @param tokenDto + * @param formDTO + * @author zxc + * @date 2021/11/19 10:12 上午 + */ + @PostMapping("editcommunityselforganization") + public Result editCommunitySelfOrganization(@LoginUser TokenDto tokenDto, @RequestBody EditCommunitySelfOrganizationFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO, EditCommunitySelfOrganizationFormDTO.EditCommunitySelfOrganizationForm.class); + icCommunitySelfOrganizationService.editCommunitySelfOrganization(tokenDto, formDTO); + return new Result(); + } + } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcCommunitySelfOrganizationDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcCommunitySelfOrganizationDao.java index c046cfe956..e1c0e16689 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcCommunitySelfOrganizationDao.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcCommunitySelfOrganizationDao.java @@ -18,6 +18,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.form.EditCommunitySelfOrganizationFormDTO; import com.epmet.entity.IcCommunitySelfOrganizationEntity; import org.apache.ibatis.annotations.Mapper; @@ -29,5 +30,7 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface IcCommunitySelfOrganizationDao extends BaseDao { - + + void updateCommunitySelfOrganization(IcCommunitySelfOrganizationEntity formDTO); + } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcCommunitySelfOrganizationPersonnelDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcCommunitySelfOrganizationPersonnelDao.java index 45a233840c..4bd2fde9f4 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcCommunitySelfOrganizationPersonnelDao.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcCommunitySelfOrganizationPersonnelDao.java @@ -20,6 +20,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.entity.IcCommunitySelfOrganizationPersonnelEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; /** * 社区自组织人员表 @@ -29,5 +30,13 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface IcCommunitySelfOrganizationPersonnelDao extends BaseDao { - + + /** + * @Description 根据社区自组织ID删除 + * @param orgId + * @author zxc + * @date 2021/11/19 11:19 上午 + */ + void deleteByOrgId(@Param("orgId")String orgId); + } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcCommunitySelfOrganizationPersonnelService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcCommunitySelfOrganizationPersonnelService.java index c8265ba859..32d04687af 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcCommunitySelfOrganizationPersonnelService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcCommunitySelfOrganizationPersonnelService.java @@ -92,4 +92,12 @@ public interface IcCommunitySelfOrganizationPersonnelService extends BaseService * @date 2021-11-18 */ void delete(String[] ids); + + /** + * @Description 根据社区自组织ID删除 + * @param orgId + * @author zxc + * @date 2021/11/19 11:18 上午 + */ + void deleteByOrgId(String orgId); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcCommunitySelfOrganizationService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcCommunitySelfOrganizationService.java index 4133c7c103..530dbe671a 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcCommunitySelfOrganizationService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcCommunitySelfOrganizationService.java @@ -22,6 +22,7 @@ import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.dto.IcCommunitySelfOrganizationDTO; import com.epmet.dto.form.AddCommunitySelfOrganizationFormDTO; +import com.epmet.dto.form.EditCommunitySelfOrganizationFormDTO; import com.epmet.entity.IcCommunitySelfOrganizationEntity; import java.util.List; @@ -103,4 +104,13 @@ public interface IcCommunitySelfOrganizationService extends BaseService l = new LambdaQueryWrapper<>(); + l.eq(IcCommunitySelfOrganizationEntity::getOrganizationName,formDTO.getOrganizationName()) + .eq(IcCommunitySelfOrganizationEntity::getCustomerId,customerId) + .eq(BaseEpmetEntity::getDelFlag, NumConstant.ZERO); + IcCommunitySelfOrganizationEntity record = baseDao.selectOne(l); + if (null != record){ + throw new RenException(EpmetErrorCode.COMMUNITY_SELF_ORGANIZATION_REPART_ERROR.getCode()); + } CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(customerId, tokenDto.getUserId()); if (null == staffInfo){ throw new RenException(String.format("查询人员{%s}信息失败",tokenDto.getUserId())); @@ -139,4 +155,37 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl l = new LambdaQueryWrapper<>(); + l.eq(IcCommunitySelfOrganizationEntity::getOrganizationName,formDTO.getOrganizationName()) + .eq(IcCommunitySelfOrganizationEntity::getCustomerId,tokenDto.getCustomerId()) + .eq(BaseEpmetEntity::getDelFlag, NumConstant.ZERO) + .ne(BaseEpmetEntity::getId,formDTO.getOrgId()); + IcCommunitySelfOrganizationEntity record = baseDao.selectOne(l); + if (null != record){ + throw new RenException(EpmetErrorCode.COMMUNITY_SELF_ORGANIZATION_REPART_ERROR.getCode()); + } + IcCommunitySelfOrganizationEntity e = ConvertUtils.sourceToTarget(formDTO, IcCommunitySelfOrganizationEntity.class); + e.setOrganizationCreatedTime(DateUtils.stringToDate(formDTO.getOrganizationCreatedTime(),DATE_PATTERN)); + e.setUpdatedBy(tokenDto.getUserId()); + baseDao.updateCommunitySelfOrganization(e); + personnelService.deleteByOrgId(formDTO.getOrgId()); + if (CollectionUtils.isNotEmpty(formDTO.getOrganizationPersonnel())){ + List persons = ConvertUtils.sourceToTarget(formDTO.getOrganizationPersonnel(), IcCommunitySelfOrganizationPersonnelEntity.class); + persons.forEach(p -> { + p.setOrgId(formDTO.getOrgId()); + p.setCustomerId(tokenDto.getCustomerId()); + }); + personnelService.insertBatch(persons); + } + } + } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcCommunitySelfOrganizationDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcCommunitySelfOrganizationDao.xml index 12c22d2fa6..b7176f6859 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcCommunitySelfOrganizationDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcCommunitySelfOrganizationDao.xml @@ -3,4 +3,19 @@ + + UPDATE ic_community_self_organization + SET ORGANIZATION_NAME = #{organizationName}, + ORGANIZATION_PERSON_COUNT = #{organizationPersonCount}, + PRINCIPAL_NAME = #{principalName}, + PRINCIPAL_PHONE = #{principalPhone}, + SERVICE_ITEM = #{serviceItem}, + LONGITUDE = #{longitude}, + LATITUDE = #{latitude}, + ORGANIZATION_CREATED_TIME = #{organizationCreatedTime}, + UPDATED_TIME = NOW(), + UPDATED_BY = #{updatedBy} + WHERE DEL_FLAG = 0 + AND ID = #{orgId} + \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcCommunitySelfOrganizationPersonnelDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcCommunitySelfOrganizationPersonnelDao.xml index 91cf453a04..40758ceeda 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcCommunitySelfOrganizationPersonnelDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcCommunitySelfOrganizationPersonnelDao.xml @@ -3,4 +3,8 @@ + + + DELETE FROM ic_community_self_organization_personnel WHERE ORG_ID = #{orgId} + \ No newline at end of file