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 index d28f93fe7e..48272aa6a6 100644 --- 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 @@ -47,5 +47,7 @@ public class GetListSocietyOrgFormDTO implements Serializable { private Integer pageNo; //每页多少条 private Integer pageSize = 20; + //token中客户Id + private String customerId; } \ No newline at end of file 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 7443423ece..560e0bd76f 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 @@ -87,6 +87,7 @@ public class SocietyOrgController { **/ @PostMapping("getlist") public Result getList(@LoginUser TokenDto tokenDto, @RequestBody GetListSocietyOrgFormDTO formDTO) { + formDTO.setCustomerId(tokenDto.getCustomerId()); return new Result().ok(societyOrgService.getList(formDTO)); } 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 b2cb48717c..3b91521309 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 @@ -25,14 +25,12 @@ 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; @@ -45,7 +43,6 @@ 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; @@ -71,6 +68,7 @@ public class SocietyOrgServiceImpl extends BaseServiceImpl + AND a.customer_id = #{customerId} + - AND society_name LIKE #{societyName} + AND society_name LIKE CONCAT('%', #{societyName}, '%') - AND person_in_charge LIKE #{personInCharge} + AND person_in_charge LIKE CONCAT('%', #{personInCharge}, '%') AND mobile = #{mobile} @@ -36,6 +39,7 @@ AND date_id #{serviceEndTime} + ORDER BY created_time DESC \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddPlaceOrgFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddPlaceOrgFormDTO.java new file mode 100644 index 0000000000..a3d56416c0 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddPlaceOrgFormDTO.java @@ -0,0 +1,95 @@ +/** + * 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; + + +/** + * @Author sun + * @Description 新增九小场所下组织 + **/ +@Data +public class AddPlaceOrgFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + /** + * 客户Id + */ + private String customerId; + /** + * 组织Id + */ + private String agencyId; + /** + * agency_id的所有上级 + */ + private String pids; + /** + * 网格Id【场所区域】 + */ + @NotBlank(message = "场所区域不能为空", groups = {Add.class}) + private String gridId; + /** + * 场所类型【admin库sys_dict_data表九小场所value值】 + */ + @NotBlank(message = "场所类型不能为空", groups = {Add.class}) + private String ninePlaceVal; + /** + * 场所名称 + */ + @NotBlank(message = "场所名称不能为空", groups = {Add.class}) + @Length(max = 20, message = "场所名称不能超过20个字符", groups = {Add.class}) + private String placeOrgName; + /** + * 场所地址 + */ + @NotBlank(message = "场所地址不能为空", groups = {Add.class}) + @Length(max = 100, message = "场所地址不能超过100个字符", groups = {Add.class}) + private String address; + /** + * 字典value,场所规模【0:10人以下 1:10-20人 2:21-40人 3:41-100人 4:100人以上】 + */ + @NotBlank(message = "场所规模不能为空", groups = {Add.class}) + private String scale; + /** + * 场所负责人 + */ + @NotBlank(message = "负责人名称不能为空", groups = {Add.class}) + @Length(max = 20, message = "负责人名称不能超过20个字符", groups = {Add.class}) + private String personInCharge; + /** + * 负责人电话 + */ + @NotBlank(message = "负责人电话不能为空", groups = {Add.class}) + @Length(max = 11, message = "负责人电话不能超过11个字符", groups = {Add.class}) + private String mobile; + /** + * 备注 + */ + private String remarks; + //token中userId + private String staffId; + + public interface Add { } + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditPlaceOrgFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditPlaceOrgFormDTO.java new file mode 100644 index 0000000000..d4863f9cb9 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditPlaceOrgFormDTO.java @@ -0,0 +1,84 @@ +/** + * 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; + + +/** + * @Author sun + * @Description 修改、删除九小场所下组织 + **/ +@Data +public class EditPlaceOrgFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + /** + * 场所Id + */ + @NotBlank(message = "场所Id不能为空", groups = {Edit.class, Del.class, Detail.class}) + private String placeOrgId; + /** + * 网格Id【场所区域】 + */ + private String gridId; + /** + * 场所类型【admin库sys_dict_data表九小场所value值】 + */ + private String ninePlaceVal; + /** + * 场所名称 + */ + @Length(max = 20, message = "场所名称不能超过20个字符", groups = {Edit.class}) + private String placeOrgName; + /** + * 场所地址 + */ + @Length(max = 100, message = "场所地址不能超过100个字符", groups = {Edit.class}) + private String address; + /** + * 字典value,场所规模【0:10人以下 1:10-20人 2:21-40人 3:41-100人 4:100人以上】 + */ + private String scale; + /** + * 场所负责人 + */ + @Length(max = 20, message = "负责人名称不能超过20个字符", groups = {Edit.class}) + private String personInCharge; + /** + * 负责人电话 + */ + @Length(max = 11, message = "负责人电话不能超过11个字符", groups = {Edit.class}) + private String mobile; + /** + * 备注 + */ + private String remarks; + + public interface Edit { } + + public interface Del { } + + public interface Detail { } + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/GetListPlaceOrgFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/GetListPlaceOrgFormDTO.java new file mode 100644 index 0000000000..b9db9d065e --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/GetListPlaceOrgFormDTO.java @@ -0,0 +1,56 @@ +/** + * 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; + + +/** + * @Author sun + * @Description 九小场所下组织列表查询 + **/ +@Data +public class GetListPlaceOrgFormDTO implements Serializable { + private static final long serialVersionUID = 1L; + + //场所名称 + private String placeOrgName; + //联系电话 + private String mobile; + //场所规模【 0:10人以下 1:10-20人 2:21-40人 3:41-100人 4:100人以上】 + private String scale; + //场所区域【网格Id】 + private String gridId; + //场所类型【九小场所Value值】 + private String ninePlacsVal; + //是否分页(是:true 否:false) 有这个参数是给新增巡查记录时用的,默认是 + private Boolean isPage = true; + //页码 + @Min(1) + private Integer pageNo; + //每页多少条 + private Integer pageSize = 20; + //token中客户Id + private String customerId; + //场所Id + private String placeOrgId; + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/GetListPlaceOrgResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/GetListPlaceOrgResultDTO.java new file mode 100644 index 0000000000..963a972543 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/GetListPlaceOrgResultDTO.java @@ -0,0 +1,43 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @Author sun + * @Description 九小场所下组织列表查询 + **/ +@Data +public class GetListPlaceOrgResultDTO implements Serializable { + //集合总条数 + private Integer total; + //社会组织信息 + private List list; + + @Data + public class PlaceOrgList { + //场所Id + private String placeOrgId; + //场所名称 + private String placeOrgName; + //场所区域Id + private String gridId; + //场所区域名称 + private String gridName; + //场所地址 + private String address; + //场所类型名称[九小场所Value值] + private String ninePlaceVal; + //场所类型名称[九小场所名称] + private String ninePlaceName; + //场所规模【 0:10人以下 1:10-20人 2:21-40人 3:41-100人 4:100人以上】 + private String scale; + //负责人 + private String personInCharge; + //联系电话 + private String mobile; + } + +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/PlaceOrgDetailResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/PlaceOrgDetailResultDTO.java new file mode 100644 index 0000000000..211c74097f --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/PlaceOrgDetailResultDTO.java @@ -0,0 +1,35 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @Author sun + * @Description 九小场所下组织列表查询 + **/ +@Data +public class PlaceOrgDetailResultDTO implements Serializable { + //场所Id + private String placeOrgId; + //场所名称 + private String placeOrgName; + //场所区域Id + private String gridId; + //场所区域名称 + private String gridName; + //场所地址 + private String address; + //场所类型名称[九小场所Value值] + private String ninePlaceVal; + //场所类型名称[九小场所名称] + private String ninePlaceName; + //场所规模【 0:10人以下 1:10-20人 2:21-40人 3:41-100人 4:100人以上】 + private String scale; + //负责人 + private String personInCharge; + //联系电话 + private String mobile; + +} diff --git a/epmet-module/gov-org/gov-org-server/pom.xml b/epmet-module/gov-org/gov-org-server/pom.xml index 5b9c7fbf37..7b2a84d8dd 100644 --- a/epmet-module/gov-org/gov-org-server/pom.xml +++ b/epmet-module/gov-org/gov-org-server/pom.xml @@ -119,6 +119,12 @@ 2.0.0 compile + + com.epmet + epmet-admin-client + 2.0.0 + compile + diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/PlaceOrgController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/PlaceOrgController.java index 77fc0c7fc9..dce1acdc07 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/PlaceOrgController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/PlaceOrgController.java @@ -17,23 +17,21 @@ package com.epmet.controller; -import com.epmet.commons.tools.page.PageData; -import com.epmet.commons.tools.utils.ExcelUtils; +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; -import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; -import com.epmet.commons.tools.validator.group.AddGroup; -import com.epmet.commons.tools.validator.group.UpdateGroup; -import com.epmet.commons.tools.validator.group.DefaultGroup; -import com.epmet.dto.PlaceOrgDTO; -import com.epmet.excel.PlaceOrgExcel; +import com.epmet.dto.form.AddPlaceOrgFormDTO; +import com.epmet.dto.form.EditPlaceOrgFormDTO; +import com.epmet.dto.form.GetListPlaceOrgFormDTO; +import com.epmet.dto.result.GetListPlaceOrgResultDTO; +import com.epmet.dto.result.PlaceOrgDetailResultDTO; import com.epmet.service.PlaceOrgService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import javax.servlet.http.HttpServletResponse; -import java.util.List; -import java.util.Map; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; /** @@ -49,46 +47,60 @@ public class PlaceOrgController { @Autowired private PlaceOrgService placeOrgService; - @GetMapping("page") - public Result> page(@RequestParam Map params){ - PageData page = placeOrgService.page(params); - return new Result>().ok(page); - } - - @GetMapping("{id}") - public Result get(@PathVariable("id") String id){ - PlaceOrgDTO data = placeOrgService.get(id); - return new Result().ok(data); + /** + * @Author sun + * @Description 新增九小场所下组织 + **/ + @PostMapping("add") + public Result add(@LoginUser TokenDto tokenDto, @RequestBody AddPlaceOrgFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, AddPlaceOrgFormDTO.Add.class); + formDTO.setCustomerId(tokenDto.getToken()); + formDTO.setStaffId(tokenDto.getUserId()); + placeOrgService.add(formDTO); + return new Result(); } - @PostMapping - public Result save(@RequestBody PlaceOrgDTO dto){ - //效验数据 - ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); - placeOrgService.save(dto); + /** + * @Author sun + * @Description 修改九小场所下组织 + **/ + @PostMapping("edit") + public Result edit(@LoginUser TokenDto tokenDto, @RequestBody EditPlaceOrgFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, EditPlaceOrgFormDTO.Edit.class); + placeOrgService.edit(formDTO); return new Result(); } - @PutMapping - public Result update(@RequestBody PlaceOrgDTO dto){ - //效验数据 - ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); - placeOrgService.update(dto); + /** + * @Author sun + * @Description 删除九小场所下组织 + **/ + @PostMapping("del") + public Result del(@LoginUser TokenDto tokenDto, @RequestBody EditPlaceOrgFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, EditPlaceOrgFormDTO.Del.class); + placeOrgService.del(formDTO.getPlaceOrgId()); return new Result(); } - @DeleteMapping - public Result delete(@RequestBody String[] ids){ - //效验数据 - AssertUtils.isArrayEmpty(ids, "id"); - placeOrgService.delete(ids); - return new Result(); + /** + * @Author sun + * @Description 九小场所下组织详情 + **/ + @PostMapping("detail") + public Result detail(@LoginUser TokenDto tokenDto, @RequestBody EditPlaceOrgFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, EditPlaceOrgFormDTO.Detail.class); + return new Result().ok(placeOrgService.detail(formDTO.getPlaceOrgId())); } - @GetMapping("export") - public void export(@RequestParam Map params, HttpServletResponse response) throws Exception { - List list = placeOrgService.list(params); - ExcelUtils.exportExcelToTarget(response, null, list, PlaceOrgExcel.class); + /** + * @Author sun + * @Description 九小场所下组织列表查询 + **/ + @PostMapping("getlist") + public Result getList(@LoginUser TokenDto tokenDto, @RequestBody GetListPlaceOrgFormDTO formDTO) { + formDTO.setCustomerId(tokenDto.getCustomerId()); + return new Result().ok(placeOrgService.getList(formDTO)); } + } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/PlaceOrgDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/PlaceOrgDao.java index d25d485262..c379dde695 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/PlaceOrgDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/PlaceOrgDao.java @@ -18,9 +18,13 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.form.GetListPlaceOrgFormDTO; +import com.epmet.dto.result.GetListPlaceOrgResultDTO; import com.epmet.entity.PlaceOrgEntity; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 九小场所下组织管理 * @@ -29,5 +33,11 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface PlaceOrgDao extends BaseDao { - + + /** + * @Author sun + * @Description 九小场所下组织列表查询 + **/ + List getList(GetListPlaceOrgFormDTO formDTO); + } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/PlaceOrgService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/PlaceOrgService.java index ba728dcca2..733ef7db48 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/PlaceOrgService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/PlaceOrgService.java @@ -18,13 +18,13 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; -import com.epmet.commons.tools.page.PageData; -import com.epmet.dto.PlaceOrgDTO; +import com.epmet.dto.form.AddPlaceOrgFormDTO; +import com.epmet.dto.form.EditPlaceOrgFormDTO; +import com.epmet.dto.form.GetListPlaceOrgFormDTO; +import com.epmet.dto.result.GetListPlaceOrgResultDTO; +import com.epmet.dto.result.PlaceOrgDetailResultDTO; import com.epmet.entity.PlaceOrgEntity; -import java.util.List; -import java.util.Map; - /** * 九小场所下组织管理 * @@ -34,62 +34,32 @@ import java.util.Map; public interface PlaceOrgService extends BaseService { /** - * 默认分页 - * - * @param params - * @return PageData - * @author generator - * @date 2021-11-18 - */ - PageData page(Map params); - - /** - * 默认查询 - * - * @param params - * @return java.util.List - * @author generator - * @date 2021-11-18 - */ - List list(Map params); + * @Author sun + * @Description 新增九小场所下组织 + **/ + void add(AddPlaceOrgFormDTO formDTO); /** - * 单条查询 - * - * @param id - * @return PlaceOrgDTO - * @author generator - * @date 2021-11-18 - */ - PlaceOrgDTO get(String id); + * @Author sun + * @Description 修改九小场所下组织 + **/ + void edit(EditPlaceOrgFormDTO formDTO); /** - * 默认保存 - * - * @param dto - * @return void - * @author generator - * @date 2021-11-18 - */ - void save(PlaceOrgDTO dto); + * @Author sun + * @Description 删除九小场所下组织 + **/ + void del(String placeOrgId); /** - * 默认更新 - * - * @param dto - * @return void - * @author generator - * @date 2021-11-18 - */ - void update(PlaceOrgDTO dto); + * @Author sun + * @Description 九小场所下组织详情 + **/ + PlaceOrgDetailResultDTO detail(String placeOrgId); /** - * 批量删除 - * - * @param ids - * @return void - * @author generator - * @date 2021-11-18 - */ - void delete(String[] ids); + * @Author sun + * @Description 九小场所下组织列表查询 + **/ + GetListPlaceOrgResultDTO getList(GetListPlaceOrgFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/PlaceOrgServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/PlaceOrgServiceImpl.java index a6be788df8..927e5845f1 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/PlaceOrgServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/PlaceOrgServiceImpl.java @@ -17,23 +17,36 @@ package com.epmet.service.impl; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; -import com.epmet.commons.tools.constant.FieldConstant; -import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; +import com.epmet.commons.tools.dto.result.OptionResultDTO; +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.PlaceOrgDao; -import com.epmet.dto.PlaceOrgDTO; +import com.epmet.dto.form.AddPlaceOrgFormDTO; +import com.epmet.dto.form.EditPlaceOrgFormDTO; +import com.epmet.dto.form.GetListPlaceOrgFormDTO; +import com.epmet.dto.form.UserIdsFormDTO; +import com.epmet.dto.result.GetListPlaceOrgResultDTO; +import com.epmet.dto.result.GetListSocietyOrgResultDTO; +import com.epmet.dto.result.PlaceOrgDetailResultDTO; +import com.epmet.dto.result.StaffSinGridResultDTO; import com.epmet.entity.PlaceOrgEntity; +import com.epmet.feign.EpmetAdminOpenFeignClient; import com.epmet.service.PlaceOrgService; -import org.apache.commons.lang3.StringUtils; +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.Arrays; import java.util.List; -import java.util.Map; +import java.util.stream.Collectors; /** * 九小场所下组织管理 @@ -43,58 +56,98 @@ import java.util.Map; */ @Service public class PlaceOrgServiceImpl extends BaseServiceImpl implements PlaceOrgService { - - + private static final Logger log = LoggerFactory.getLogger(PlaceOrgServiceImpl.class); + @Autowired + private EpmetAdminOpenFeignClient epmetAdminOpenFeignClient; + + /** + * @Author sun + * @Description 新增九小场所下组织 + **/ @Override - public PageData page(Map params) { - IPage page = baseDao.selectPage( - getPage(params, FieldConstant.CREATED_TIME, false), - getWrapper(params) - ); - return getPageData(page, PlaceOrgDTO.class); - } - - @Override - public List list(Map params) { - List entityList = baseDao.selectList(getWrapper(params)); - - return ConvertUtils.sourceToTarget(entityList, PlaceOrgDTO.class); - } - - private QueryWrapper getWrapper(Map params){ - String id = (String)params.get(FieldConstant.ID_HUMP); - - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); - - return wrapper; + public void add(AddPlaceOrgFormDTO formDTO) { + PlaceOrgEntity entity = ConvertUtils.sourceToTarget(formDTO, PlaceOrgEntity.class); + CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId()); + entity.setAgencyId(staffInfoCache.getAgencyId()); + entity.setPids(staffInfoCache.getAgencyPIds()); + insert(entity); } + /** + * @Author sun + * @Description 修改九小场所下组织 + **/ @Override - public PlaceOrgDTO get(String id) { - PlaceOrgEntity entity = baseDao.selectById(id); - return ConvertUtils.sourceToTarget(entity, PlaceOrgDTO.class); + public void edit(EditPlaceOrgFormDTO formDTO) { + PlaceOrgEntity entity = baseDao.selectById(formDTO.getPlaceOrgId()); + if (null == entity) { + throw new RenException(String.format("修改九小场所下组织信息失败,场所信息不存在,场所Id->%s", formDTO.getPlaceOrgId())); + } + entity = ConvertUtils.sourceToTarget(formDTO, PlaceOrgEntity.class); + baseDao.updateById(entity); } + /** + * @Author sun + * @Description 删除九小场所下组织 + **/ @Override - @Transactional(rollbackFor = Exception.class) - public void save(PlaceOrgDTO dto) { - PlaceOrgEntity entity = ConvertUtils.sourceToTarget(dto, PlaceOrgEntity.class); - insert(entity); + public void del(String placeOrgId) { + if (baseDao.deleteById(placeOrgId) < NumConstant.ONE) { + throw new RenException(String.format("修改九小场所下组织信息删除失败,场所Id->%s", placeOrgId)); + } } + /** + * @Author sun + * @Description 九小场所下组织详情 + **/ @Override - @Transactional(rollbackFor = Exception.class) - public void update(PlaceOrgDTO dto) { - PlaceOrgEntity entity = ConvertUtils.sourceToTarget(dto, PlaceOrgEntity.class); - updateById(entity); + public PlaceOrgDetailResultDTO detail(String placeOrgId) { + PlaceOrgDetailResultDTO resultDTO = new PlaceOrgDetailResultDTO(); + //1.查询场所基础信息 + GetListPlaceOrgFormDTO dto = new GetListPlaceOrgFormDTO(); + dto.setPlaceOrgId(placeOrgId); + List result = baseDao.getList(dto); + if (CollectionUtils.isEmpty(result)) { + return resultDTO; + } + resultDTO = ConvertUtils.sourceToTarget(result.get(0), PlaceOrgDetailResultDTO.class); + //2.查询九小场所信息 + Result> result1 = epmetAdminOpenFeignClient.getNineSmallPlacesOption(); + if (!result1.success()) { + throw new RenException("获取九小场所基本信息失败......"); + } + for (OptionResultDTO d : result1.getData()) { + if (d.getValue().equals(resultDTO.getNinePlaceVal())) { + resultDTO.setNinePlaceName(d.getLabel()); + } + } + return resultDTO; } + /** + * @Author sun + * @Description 九小场所下组织列表查询 + **/ @Override - @Transactional(rollbackFor = Exception.class) - public void delete(String[] ids) { - // 逻辑删除(@TableLogic 注解) - baseDao.deleteBatchIds(Arrays.asList(ids)); + public GetListPlaceOrgResultDTO getList(GetListPlaceOrgFormDTO formDTO) { + GetListPlaceOrgResultDTO resultDTO = new GetListPlaceOrgResultDTO(); + //1.根据查询条件分页查询场所数据 + PageInfo result = + PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage()).doSelectPageInfo(() -> baseDao.getList(formDTO)); + if (CollectionUtils.isEmpty(result.getList())) { + return resultDTO; + } + resultDTO.setTotal((int) result.getTotal()); + //2.查询九小场所信息 + Result> result1 = epmetAdminOpenFeignClient.getNineSmallPlacesOption(); + if (!result1.success()) { + throw new RenException("获取九小场所基本信息失败......"); + } + result.getList().forEach(r -> result1.getData().stream().filter(u -> r.getNinePlaceVal().equals(u.getValue())).forEach(u -> r.setNinePlaceName(u.getLabel()))); + resultDTO.setList(result.getList()); + + return resultDTO; } - } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/PlaceOrgDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/PlaceOrgDao.xml index 3fb8247c8b..596106bf0c 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/PlaceOrgDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/PlaceOrgDao.xml @@ -3,6 +3,44 @@ - + \ No newline at end of file