Commit 49fa80760fab64de71871dca938bd4ad53ebbd8e

Authored by 王富生
1 parent a7160ef9

频次值增加公司

urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/planrate/PlanRateController.java
@@ -119,8 +119,7 @@ public class PlanRateController { @@ -119,8 +119,7 @@ public class PlanRateController {
119 @Operation(summary = "获得计划频次分页") 119 @Operation(summary = "获得计划频次分页")
120 @PreAuthorize("@ss.hasPermission('garden:plan-rate:query')") 120 @PreAuthorize("@ss.hasPermission('garden:plan-rate:query')")
121 public CommonResult<PageResult<PlanRateRespVO>> getPlanRatePage(@Valid PlanRatePageReqVO pageReqVO) { 121 public CommonResult<PageResult<PlanRateRespVO>> getPlanRatePage(@Valid PlanRatePageReqVO pageReqVO) {
122 - PageResult<PlanRateDO> pageResult = planRateService.getPlanRatePage(pageReqVO);  
123 - return success(BeanUtils.toBean(pageResult, PlanRateRespVO.class)); 122 + return success(planRateService.getPlanRatePage(pageReqVO));
124 } 123 }
125 124
126 @GetMapping("/export-excel") 125 @GetMapping("/export-excel")
@@ -130,7 +129,7 @@ public class PlanRateController { @@ -130,7 +129,7 @@ public class PlanRateController {
130 public void exportPlanRateExcel(@Valid PlanRatePageReqVO pageReqVO, 129 public void exportPlanRateExcel(@Valid PlanRatePageReqVO pageReqVO,
131 HttpServletResponse response) throws IOException { 130 HttpServletResponse response) throws IOException {
132 pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); 131 pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
133 - List<PlanRateDO> list = planRateService.getPlanRatePage(pageReqVO).getList(); 132 + List<PlanRateRespVO> list = planRateService.getPlanRatePage(pageReqVO).getList();
134 // 导出 Excel 133 // 导出 Excel
135 ExcelUtils.write(response, "计划频次.xls", "数据", PlanRateRespVO.class, 134 ExcelUtils.write(response, "计划频次.xls", "数据", PlanRateRespVO.class,
136 BeanUtils.toBean(list, PlanRateRespVO.class)); 135 BeanUtils.toBean(list, PlanRateRespVO.class));
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/planrate/PlanRateDetailController.java
@@ -82,8 +82,9 @@ public class PlanRateDetailController { @@ -82,8 +82,9 @@ public class PlanRateDetailController {
82 @PreAuthorize("@ss.hasPermission('garden:plan-rate-detail:query')") 82 @PreAuthorize("@ss.hasPermission('garden:plan-rate-detail:query')")
83 public CommonResult<PlanRateDetailRespVO> getPlanRateValue(@RequestParam("busi_Line") @NotBlank String busiLine, 83 public CommonResult<PlanRateDetailRespVO> getPlanRateValue(@RequestParam("busi_Line") @NotBlank String busiLine,
84 @RequestParam("plan_type_id") @NotNull Integer planTypeId, 84 @RequestParam("plan_type_id") @NotNull Integer planTypeId,
85 - @RequestParam("level_id") @NotNull Integer levelId) {  
86 - return success(planRateDetailService.getPlanRateValue(busiLine, planTypeId, levelId)); 85 + @RequestParam("level_id") @NotNull Integer levelId,
  86 + @RequestParam("company_id") Long companyId) {
  87 + return success(planRateDetailService.getPlanRateValue(busiLine, planTypeId, levelId, companyId));
87 } 88 }
88 89
89 @GetMapping("/page") 90 @GetMapping("/page")
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/planrate/vo/PlanRatePageReqVO.java
1 package com.zteits.urbanops.module.garden.controller.admin.planrate.vo; 1 package com.zteits.urbanops.module.garden.controller.admin.planrate.vo;
2 2
  3 +import io.swagger.v3.oas.annotations.Hidden;
3 import jakarta.validation.constraints.NotNull; 4 import jakarta.validation.constraints.NotNull;
4 import lombok.*; 5 import lombok.*;
5 import java.util.*; 6 import java.util.*;
@@ -30,4 +31,8 @@ public class PlanRatePageReqVO extends PageParam { @@ -30,4 +31,8 @@ public class PlanRatePageReqVO extends PageParam {
30 @NotNull(message = "类型:1:养护;2:巡查不能为空") 31 @NotNull(message = "类型:1:养护;2:巡查不能为空")
31 private Integer type; 32 private Integer type;
32 33
  34 + @Schema(description = "公司ID", requiredMode = Schema.RequiredMode.REQUIRED)
  35 + @Hidden
  36 + private Long companyId;
  37 +
33 } 38 }
34 \ No newline at end of file 39 \ No newline at end of file
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/planrate/vo/PlanRateRespVO.java
@@ -36,4 +36,10 @@ public class PlanRateRespVO { @@ -36,4 +36,10 @@ public class PlanRateRespVO {
36 @ExcelProperty("创建时间") 36 @ExcelProperty("创建时间")
37 private LocalDateTime createTime; 37 private LocalDateTime createTime;
38 38
  39 + @Schema(description = "公司ID", requiredMode = Schema.RequiredMode.REQUIRED)
  40 + private Long companyId;
  41 +
  42 + @Schema(description = "公司", requiredMode = Schema.RequiredMode.REQUIRED)
  43 + private String companyName;
  44 +
39 } 45 }
40 \ No newline at end of file 46 \ No newline at end of file
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/dataobject/planrate/PlanRateDO.java
@@ -47,6 +47,10 @@ public class PlanRateDO extends BaseDO { @@ -47,6 +47,10 @@ public class PlanRateDO extends BaseDO {
47 * 类型:1:养护;2:巡查 47 * 类型:1:养护;2:巡查
48 */ 48 */
49 private Integer type; 49 private Integer type;
  50 + /**
  51 + * 公司ID
  52 + */
  53 + private Long companyId;
50 54
51 55
52 } 56 }
53 \ No newline at end of file 57 \ No newline at end of file
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/mysql/planrate/PlanRateDetailMapper.java
@@ -31,4 +31,6 @@ public interface PlanRateDetailMapper extends BaseMapperX&lt;PlanRateDetailDO&gt; { @@ -31,4 +31,6 @@ public interface PlanRateDetailMapper extends BaseMapperX&lt;PlanRateDetailDO&gt; {
31 31
32 int deleteByRateNo(@Param("rateNo") String rateNo); 32 int deleteByRateNo(@Param("rateNo") String rateNo);
33 33
  34 + PlanRateDetailDO getPlanRateDetail(@Param("busiLine") String busiLine, @Param("planTypeId") Integer planTypeId, @Param("levelId") Integer levelId, @Param("companyId") Long companyId);
  35 +
34 } 36 }
35 \ No newline at end of file 37 \ No newline at end of file
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/mysql/planrate/PlanRateInterceptMapper.java
@@ -24,6 +24,7 @@ public interface PlanRateInterceptMapper extends BaseMapperX&lt;PlanRateDO&gt; { @@ -24,6 +24,7 @@ public interface PlanRateInterceptMapper extends BaseMapperX&lt;PlanRateDO&gt; {
24 .eqIfPresent(PlanRateDO::getPlanTypeId, reqVO.getPlanTypeId()) 24 .eqIfPresent(PlanRateDO::getPlanTypeId, reqVO.getPlanTypeId())
25 .eqIfPresent(PlanRateDO::getStdPlan, reqVO.getStdPlan()) 25 .eqIfPresent(PlanRateDO::getStdPlan, reqVO.getStdPlan())
26 .eq(PlanRateDO::getType, reqVO.getType()) 26 .eq(PlanRateDO::getType, reqVO.getType())
  27 + .eqIfPresent(PlanRateDO::getCompanyId, reqVO.getCompanyId())
27 .orderByDesc(PlanRateDO::getId)); 28 .orderByDesc(PlanRateDO::getId));
28 } 29 }
29 } 30 }
30 \ No newline at end of file 31 \ No newline at end of file
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/planrate/PlanRateDetailService.java
@@ -65,6 +65,6 @@ public interface PlanRateDetailService { @@ -65,6 +65,6 @@ public interface PlanRateDetailService {
65 * @param levelId 道路等级 65 * @param levelId 道路等级
66 * @return 对象 66 * @return 对象
67 */ 67 */
68 - PlanRateDetailRespVO getPlanRateValue(String busiLine,Integer planTypeId,Integer levelId); 68 + PlanRateDetailRespVO getPlanRateValue(String busiLine,Integer planTypeId,Integer levelId, Long companyId);
69 69
70 } 70 }
71 \ No newline at end of file 71 \ No newline at end of file
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/planrate/PlanRateDetailServiceImpl.java
@@ -5,6 +5,7 @@ import com.zteits.urbanops.framework.common.biz.system.dict.dto.DictDataRespDTO; @@ -5,6 +5,7 @@ import com.zteits.urbanops.framework.common.biz.system.dict.dto.DictDataRespDTO;
5 import com.zteits.urbanops.module.garden.dal.dataobject.planrate.PlanRateDO; 5 import com.zteits.urbanops.module.garden.dal.dataobject.planrate.PlanRateDO;
6 import com.zteits.urbanops.module.garden.dal.mysql.planrate.PlanRateMapper; 6 import com.zteits.urbanops.module.garden.dal.mysql.planrate.PlanRateMapper;
7 import com.zteits.urbanops.module.system.api.dict.DictDataApi; 7 import com.zteits.urbanops.module.system.api.dict.DictDataApi;
  8 +import org.apache.ibatis.annotations.Param;
8 import org.springframework.stereotype.Service; 9 import org.springframework.stereotype.Service;
9 import jakarta.annotation.Resource; 10 import jakarta.annotation.Resource;
10 import org.springframework.validation.annotation.Validated; 11 import org.springframework.validation.annotation.Validated;
@@ -92,12 +93,8 @@ public class PlanRateDetailServiceImpl implements PlanRateDetailService { @@ -92,12 +93,8 @@ public class PlanRateDetailServiceImpl implements PlanRateDetailService {
92 93
93 94
94 @Override 95 @Override
95 - public PlanRateDetailRespVO getPlanRateValue(String busiLine, Integer planTypeId, Integer levelId) {  
96 - QueryWrapper<PlanRateDetailDO> sql = new QueryWrapper<>();  
97 - sql.lambda().eq(PlanRateDetailDO::getBusiLine, busiLine)  
98 - .eq(PlanRateDetailDO::getPlanTypeId, planTypeId)  
99 - .eq(PlanRateDetailDO::getLevelId, levelId);  
100 - PlanRateDetailDO planRateDetailDO = planRateDetailMapper.selectOne(sql); 96 + public PlanRateDetailRespVO getPlanRateValue(String busiLine, Integer planTypeId, Integer levelId, Long companyId) {
  97 + PlanRateDetailDO planRateDetailDO = planRateDetailMapper.getPlanRateDetail(busiLine, planTypeId, levelId, companyId);
101 if (planRateDetailDO == null) { 98 if (planRateDetailDO == null) {
102 throw exception(PLAN_RATE_NOT_EXISTS); 99 throw exception(PLAN_RATE_NOT_EXISTS);
103 } 100 }
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/planrate/PlanRateService.java
@@ -64,7 +64,7 @@ public interface PlanRateService { @@ -64,7 +64,7 @@ public interface PlanRateService {
64 * @param pageReqVO 分页查询 64 * @param pageReqVO 分页查询
65 * @return 计划频次分页 65 * @return 计划频次分页
66 */ 66 */
67 - PageResult<PlanRateDO> getPlanRatePage(PlanRatePageReqVO pageReqVO); 67 + PageResult<PlanRateRespVO> getPlanRatePage(PlanRatePageReqVO pageReqVO);
68 68
69 /** 69 /**
70 * 获得计划频次明细 70 * 获得计划频次明细
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/planrate/PlanRateServiceImpl.java
@@ -12,13 +12,17 @@ import com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils; @@ -12,13 +12,17 @@ import com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils;
12 import com.zteits.urbanops.module.garden.dal.dataobject.planrate.PlanRateDetailDO; 12 import com.zteits.urbanops.module.garden.dal.dataobject.planrate.PlanRateDetailDO;
13 import com.zteits.urbanops.module.garden.dal.mysql.planrate.PlanRateDetailMapper; 13 import com.zteits.urbanops.module.garden.dal.mysql.planrate.PlanRateDetailMapper;
14 import com.zteits.urbanops.module.garden.dal.mysql.planrate.PlanRateInterceptMapper; 14 import com.zteits.urbanops.module.garden.dal.mysql.planrate.PlanRateInterceptMapper;
  15 +import com.zteits.urbanops.module.system.api.dept.DeptApi;
  16 +import com.zteits.urbanops.module.system.api.dept.dto.DeptRespDTO;
15 import org.springframework.stereotype.Service; 17 import org.springframework.stereotype.Service;
16 import jakarta.annotation.Resource; 18 import jakarta.annotation.Resource;
  19 +import org.springframework.util.CollectionUtils;
17 import org.springframework.validation.annotation.Validated; 20 import org.springframework.validation.annotation.Validated;
18 import org.springframework.transaction.annotation.Transactional; 21 import org.springframework.transaction.annotation.Transactional;
19 22
20 import java.time.LocalDateTime; 23 import java.time.LocalDateTime;
21 import java.util.*; 24 import java.util.*;
  25 +import java.util.stream.Collectors;
22 26
23 import com.zteits.urbanops.module.garden.controller.admin.planrate.vo.*; 27 import com.zteits.urbanops.module.garden.controller.admin.planrate.vo.*;
24 import com.zteits.urbanops.module.garden.dal.dataobject.planrate.PlanRateDO; 28 import com.zteits.urbanops.module.garden.dal.dataobject.planrate.PlanRateDO;
@@ -51,12 +55,16 @@ public class PlanRateServiceImpl implements PlanRateService { @@ -51,12 +55,16 @@ public class PlanRateServiceImpl implements PlanRateService {
51 @Resource 55 @Resource
52 private DictDataCommonApi dictDataCommonApi; 56 private DictDataCommonApi dictDataCommonApi;
53 57
  58 + @Resource
  59 + private DeptApi deptApi;
  60 +
54 @Transactional(rollbackFor = Exception.class) 61 @Transactional(rollbackFor = Exception.class)
55 @Override 62 @Override
56 public Long createPlanRate(PlanRateSaveReqVO createReqVO) { 63 public Long createPlanRate(PlanRateSaveReqVO createReqVO) {
57 // 校验存在 64 // 校验存在
58 validatePlanRateExists(createReqVO.getPlanTypeId(), createReqVO.getBusiLine()); 65 validatePlanRateExists(createReqVO.getPlanTypeId(), createReqVO.getBusiLine());
59 LocalDateTime now = LocalDateTime.now(); 66 LocalDateTime now = LocalDateTime.now();
  67 + Long companyId = SecurityFrameworkUtils.getCompanyId();
60 String userName = SecurityFrameworkUtils.getLoginUserId() + ""; 68 String userName = SecurityFrameworkUtils.getLoginUserId() + "";
61 String rateNo = DateUtil.format(new Date(), "yyyyMMddHHmmssSSS") + RandomUtil.randomInt(1000); 69 String rateNo = DateUtil.format(new Date(), "yyyyMMddHHmmssSSS") + RandomUtil.randomInt(1000);
62 PlanRateDO planRate = new PlanRateDO(); 70 PlanRateDO planRate = new PlanRateDO();
@@ -65,6 +73,7 @@ public class PlanRateServiceImpl implements PlanRateService { @@ -65,6 +73,7 @@ public class PlanRateServiceImpl implements PlanRateService {
65 planRate.setBusiLine(createReqVO.getBusiLine()); 73 planRate.setBusiLine(createReqVO.getBusiLine());
66 planRate.setPlanTypeId(createReqVO.getPlanTypeId()); 74 planRate.setPlanTypeId(createReqVO.getPlanTypeId());
67 planRate.setType(createReqVO.getType()); 75 planRate.setType(createReqVO.getType());
  76 + planRate.setCompanyId(companyId);
68 planRate.setCreator(userName); 77 planRate.setCreator(userName);
69 planRate.setCreateTime(now); 78 planRate.setCreateTime(now);
70 planRate.setUpdater(userName); 79 planRate.setUpdater(userName);
@@ -181,8 +190,28 @@ public class PlanRateServiceImpl implements PlanRateService { @@ -181,8 +190,28 @@ public class PlanRateServiceImpl implements PlanRateService {
181 } 190 }
182 191
183 @Override 192 @Override
184 - public PageResult<PlanRateDO> getPlanRatePage(PlanRatePageReqVO pageReqVO) {  
185 - return planRateInterceptMapper.selectForPage(pageReqVO); 193 + public PageResult<PlanRateRespVO> getPlanRatePage(PlanRatePageReqVO pageReqVO) {
  194 + Long companyId = SecurityFrameworkUtils.getCompanyId();
  195 + if(companyId == 100L){
  196 + companyId = null;
  197 + }
  198 + pageReqVO.setCompanyId(companyId);
  199 + PageResult<PlanRateDO> pageResult = planRateInterceptMapper.selectForPage(pageReqVO);
  200 + if(CollectionUtils.isEmpty(pageResult.getList())){
  201 + return PageResult.empty();
  202 + }
  203 + PageResult<PlanRateRespVO> result = BeanUtils.toBean(pageResult, PlanRateRespVO.class);
  204 + List<Long> companyIds = result.getList().stream().map(PlanRateRespVO::getCompanyId).collect(Collectors.toList());
  205 + Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(companyIds);
  206 + result.getList().forEach(planRate -> {
  207 + DeptRespDTO deptRespDTO = deptMap.get(planRate.getCompanyId());
  208 + if(deptRespDTO !=null){
  209 + planRate.setCompanyName(deptRespDTO.getName());
  210 + }
  211 +
  212 + });
  213 +
  214 + return result;
186 } 215 }
187 216
188 @Override 217 @Override
urbanops-module-garden/src/main/resources/mapper/planrate/PlanRateDetailMapper.xml
@@ -12,4 +12,19 @@ @@ -12,4 +12,19 @@
12 <delete id="deleteByRateNo"> 12 <delete id="deleteByRateNo">
13 delete from garden_plan_rate_detail where rate_no=#{rateNo} 13 delete from garden_plan_rate_detail where rate_no=#{rateNo}
14 </delete> 14 </delete>
  15 +
  16 + <select id="getPlanRateDetail" resultType="com.zteits.urbanops.module.garden.dal.dataobject.planrate.PlanRateDetailDO">
  17 + SELECT
  18 + b.*
  19 + FROM
  20 + garden_plan_rate a,
  21 + garden_plan_rate_detail b
  22 + WHERE
  23 + a.rate_no=b.rate
  24 + and b.busi_line=#{busiLine}
  25 + and b.level_id=#{levelId}
  26 + and b.plan_type_id=#{planTypeId}
  27 + and a.company_id= #{companyId}
  28 + limit 1
  29 + </select>
15 </mapper> 30 </mapper>
16 \ No newline at end of file 31 \ No newline at end of file