diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/AddSocietyOrgFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/AddSocietyOrgFormDTO.java index bc0555f95b..5d80ef5c18 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/AddSocietyOrgFormDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/AddSocietyOrgFormDTO.java @@ -18,6 +18,7 @@ package com.epmet.dto.form; import lombok.Data; +import org.hibernate.validator.constraints.Length; import javax.validation.constraints.NotBlank; import java.io.Serializable; @@ -25,11 +26,9 @@ import java.util.Date; /** - * 社会组织管理 - * - * @author generator generator@elink-cn.com - * @since v1.0.0 2021-11-18 - */ + * @Author sun + * @Description 新增社会组织 + **/ @Data public class AddSocietyOrgFormDTO implements Serializable { @@ -50,21 +49,25 @@ public class AddSocietyOrgFormDTO implements Serializable { * 社会组织名称 */ @NotBlank(message = "社会组织名称不能为空", groups = { AddSocietyOrgFormDTO.Add.class }) + @Length(max = 50, message = "社会组织名称不能超过50个字符",groups = {Add.class}) private String societyName; /** * 服务事项 */ @NotBlank(message = "服务事项不能为空", groups = { AddSocietyOrgFormDTO.Add.class }) + @Length(max = 1000, message = "服务事项不能超过1000个字符",groups = {Add.class}) private String serviceMatters; /** * 负责人 */ @NotBlank(message = "负责人名称不能为空", groups = { AddSocietyOrgFormDTO.Add.class }) + @Length(max = 20, message = "负责人名称不能超过20个字符",groups = {Add.class}) private String personInCharge; /** * 负责人电话 */ @NotBlank(message = "负责人电话不能为空", groups = { AddSocietyOrgFormDTO.Add.class }) + @Length(max = 11, message = "负责人电话不能超过11个字符",groups = {Add.class}) private String mobile; /** * 起始服务时间 diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/EditSocietyOrgFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/EditSocietyOrgFormDTO.java new file mode 100644 index 0000000000..e28bba50b5 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/EditSocietyOrgFormDTO.java @@ -0,0 +1,92 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.form; + +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.Date; + + +/** + * @Author sun + * @Description 修改、删除社会组织 + **/ +@Data +public class EditSocietyOrgFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 社会组织Id + */ + @NotBlank(message = "社会组织Id不能为空", groups = { Edit.class, Del.class }) + private String societyId; + /** + * 社会组织名称 + */ + @Length(max = 50, message = "社会组织名称不能超过50个字符",groups = {Edit.class}) + private String societyName; + /** + * 服务事项 + */ + @Length(max = 1000, message = "服务事项不能超过1000个字符",groups = {Edit.class}) + private String serviceMatters; + /** + * 负责人 + */ + @Length(max = 20, message = "负责人名称不能超过20个字符",groups = {Edit.class}) + private String personInCharge; + /** + * 负责人电话 + */ + @Length(max = 11, message = "负责人电话不能超过11个字符",groups = {Edit.class}) + private String mobile; + /** + * 起始服务时间 + */ + private Date serviceStartTime; + /** + * 终止服务时间 + */ + private Date serviceEndTime; + /** + * 绑定管理员[组织下录入的工作人员] + */ + private String adminStaffId; + /** + * 地址 + */ + private String address; + /** + * 经度 + */ + private String longitude; + /** + * 维度 + */ + private String dimension; + //token中userId + private String staffId; + + public interface Edit {} + public interface Del {} + +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/GetListSocietyOrgFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/GetListSocietyOrgFormDTO.java new file mode 100644 index 0000000000..d28f93fe7e --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/GetListSocietyOrgFormDTO.java @@ -0,0 +1,51 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.Min; +import java.io.Serializable; +import java.util.Date; + + +/** + * @Author sun + * @Description 社会组织列表查询 + **/ +@Data +public class GetListSocietyOrgFormDTO implements Serializable { + private static final long serialVersionUID = 1L; + + //社会组织名称 + private String societyName; + //负责人 + private String personInCharge; + //负责人电话 + private String mobile; + //起始服务时间 + private Date serviceStartTime; + //终止服务时间 + private Date serviceEndTime; + //页码 + @Min(1) + private Integer pageNo; + //每页多少条 + private Integer pageSize = 20; + +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/GetListSocietyOrgResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/GetListSocietyOrgResultDTO.java new file mode 100644 index 0000000000..1765350a6d --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/GetListSocietyOrgResultDTO.java @@ -0,0 +1,69 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @Author sun + * @Description 社会组织列表查询 + **/ +@Data +public class GetListSocietyOrgResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + //集合总条数 + private Integer total; + //社会组织信息 + private List list; + + @Data + public class SocietyOrgList{ + //所属组织Id + private String agencyId; + //社会组织Id + private String societyId; + //社会组织名称 + private String societyName; + //服务事项 + private String serviceMatters; + //负责人姓名 + private String personInCharge; + //负责人电话 + private String mobile; + //起始服务时间 + private String serviceStartTime; + //终止服务时间 + private String serviceEndTime; + //绑定管理员[组织下Id录入的工作人员] + private String adminStaffId; + //绑定管理员[组织下录入的工作人员]姓名 + private String adminStaffName; + //地址 + private String address; + //经度 + private String longitude; + //维度 + private String dimension; + } + +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/SocietyOrgController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/SocietyOrgController.java index 0eb23cde7d..7443423ece 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/SocietyOrgController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/SocietyOrgController.java @@ -22,6 +22,9 @@ import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.form.AddSocietyOrgFormDTO; +import com.epmet.dto.form.EditSocietyOrgFormDTO; +import com.epmet.dto.form.GetListSocietyOrgFormDTO; +import com.epmet.dto.result.GetListSocietyOrgResultDTO; import com.epmet.service.SocietyOrgService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; @@ -39,7 +42,7 @@ import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("societyorg") public class SocietyOrgController { - + @Autowired private SocietyOrgService societyOrgService; @@ -56,4 +59,35 @@ public class SocietyOrgController { return new Result(); } + /** + * @Author sun + * @Description 修改社会组织 + **/ + @PostMapping("edit") + public Result edit(@LoginUser TokenDto tokenDto, @RequestBody EditSocietyOrgFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, EditSocietyOrgFormDTO.Edit.class); + societyOrgService.edit(formDTO); + return new Result(); + } + + /** + * @Author sun + * @Description 删除社会组织 + **/ + @PostMapping("del") + public Result del(@LoginUser TokenDto tokenDto, @RequestBody EditSocietyOrgFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, EditSocietyOrgFormDTO.Del.class); + societyOrgService.del(formDTO.getSocietyId()); + return new Result(); + } + + /** + * @Author sun + * @Description 社会组织列表查询 + **/ + @PostMapping("getlist") + public Result getList(@LoginUser TokenDto tokenDto, @RequestBody GetListSocietyOrgFormDTO formDTO) { + return new Result().ok(societyOrgService.getList(formDTO)); + } + } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/SocietyOrgDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/SocietyOrgDao.java index b46d6035d2..0c3f5cc4af 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/SocietyOrgDao.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/SocietyOrgDao.java @@ -18,9 +18,13 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.form.GetListSocietyOrgFormDTO; +import com.epmet.dto.result.GetListSocietyOrgResultDTO; import com.epmet.entity.SocietyOrgEntity; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 社会组织管理 * @@ -29,5 +33,11 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface SocietyOrgDao extends BaseDao { - + + /** + * @Author sun + * @Description 社会组织列表查询 + **/ + List getList(GetListSocietyOrgFormDTO formDTO); + } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/SocietyOrgService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/SocietyOrgService.java index 846e07777f..2acaa20c05 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/SocietyOrgService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/SocietyOrgService.java @@ -19,6 +19,9 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.dto.form.AddSocietyOrgFormDTO; +import com.epmet.dto.form.EditSocietyOrgFormDTO; +import com.epmet.dto.form.GetListSocietyOrgFormDTO; +import com.epmet.dto.result.GetListSocietyOrgResultDTO; import com.epmet.entity.SocietyOrgEntity; /** @@ -34,4 +37,22 @@ public interface SocietyOrgService extends BaseService { * @Description 新增社会组织 **/ void add(AddSocietyOrgFormDTO dto); + + /** + * @Author sun + * @Description 修改社会组织 + **/ + void edit(EditSocietyOrgFormDTO formDTO); + + /** + * @Author sun + * @Description 删除社会组织 + **/ + void del(String societyId); + + /** + * @Author sun + * @Description 社会组织列表查询 + **/ + GetListSocietyOrgResultDTO getList(GetListSocietyOrgFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/SocietyOrgServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/SocietyOrgServiceImpl.java index 5f2c284be2..b2cb48717c 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/SocietyOrgServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/SocietyOrgServiceImpl.java @@ -18,17 +18,36 @@ package com.epmet.service.impl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; +import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.Result; import com.epmet.dao.SocietyOrgDao; +import com.epmet.dto.ProjectStaffDTO; import com.epmet.dto.form.AddSocietyOrgFormDTO; +import com.epmet.dto.form.EditSocietyOrgFormDTO; +import com.epmet.dto.form.GetListSocietyOrgFormDTO; +import com.epmet.dto.form.UserIdsFormDTO; +import com.epmet.dto.result.GetListSocietyOrgResultDTO; +import com.epmet.dto.result.StaffSinGridResultDTO; +import com.epmet.entity.ActInfoEntity; import com.epmet.entity.SocietyOrgEntity; +import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.service.SocietyOrgService; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; /** * 社会组织管理 @@ -39,6 +58,9 @@ import org.springframework.transaction.annotation.Transactional; @Service public class SocietyOrgServiceImpl extends BaseServiceImpl implements SocietyOrgService { private static final Logger log = LoggerFactory.getLogger(SocietyOrgServiceImpl.class); + @Autowired + private EpmetUserOpenFeignClient epmetUserOpenFeignClient; + /** * @Author sun @@ -53,4 +75,58 @@ public class SocietyOrgServiceImpl extends BaseServiceImpl%s", formDTO.getSocietyId())); + } + entity = ConvertUtils.sourceToTarget(formDTO, SocietyOrgEntity.class); + baseDao.updateById(entity); + } + + /** + * @Author sun + * @Description 删除社会组织 + **/ + @Override + public void del(String societyId) { + if (baseDao.deleteById(societyId) < NumConstant.ONE) { + throw new RenException(String.format("修改社会组织信息删除失败,社会组织Id->%s", societyId)); + } + } + + /** + * @Author sun + * @Description 社会组织列表查询 + **/ + @Override + public GetListSocietyOrgResultDTO getList(GetListSocietyOrgFormDTO formDTO) { + GetListSocietyOrgResultDTO resultDTO = new GetListSocietyOrgResultDTO(); + //1.根据查询条件分页查询社会组织数据 + PageInfo result = + PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.getList(formDTO)); + if (CollectionUtils.isEmpty(result.getList())) { + return resultDTO; + } + resultDTO.setTotal((int) result.getTotal()); + //2.查询被绑定管理员信息 + UserIdsFormDTO dto = new UserIdsFormDTO(); + List staffIdList = result.getList().stream().map(GetListSocietyOrgResultDTO.SocietyOrgList::getAdminStaffId).collect(Collectors.toList()); + staffIdList = staffIdList.stream().distinct().collect(Collectors.toList()); + dto.setUserIds(staffIdList); + Result> listResult = epmetUserOpenFeignClient.getStaffInfoList(dto); + if (!listResult.success()) { + throw new RenException("获取工作人员基本信息失败......"); + } + result.getList().forEach(r -> listResult.getData().stream().filter(u -> r.getAdminStaffId().equals(u.getStaffId())).forEach(u -> r.setAdminStaffName(u.getStaffName()))); + resultDTO.setList(result.getList()); + + return resultDTO; + } + } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/SocietyOrgDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/SocietyOrgDao.xml index 6583d6afc2..e2bac86f4b 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/SocietyOrgDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/SocietyOrgDao.xml @@ -3,6 +3,39 @@ - + \ No newline at end of file