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 119 @Operation(summary = "获得计划频次分页")
120 120 @PreAuthorize("@ss.hasPermission('garden:plan-rate:query')")
121 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 125 @GetMapping("/export-excel")
... ... @@ -130,7 +129,7 @@ public class PlanRateController {
130 129 public void exportPlanRateExcel(@Valid PlanRatePageReqVO pageReqVO,
131 130 HttpServletResponse response) throws IOException {
132 131 pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
133   - List<PlanRateDO> list = planRateService.getPlanRatePage(pageReqVO).getList();
  132 + List<PlanRateRespVO> list = planRateService.getPlanRatePage(pageReqVO).getList();
134 133 // 导出 Excel
135 134 ExcelUtils.write(response, "计划频次.xls", "数据", PlanRateRespVO.class,
136 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 82 @PreAuthorize("@ss.hasPermission('garden:plan-rate-detail:query')")
83 83 public CommonResult<PlanRateDetailRespVO> getPlanRateValue(@RequestParam("busi_Line") @NotBlank String busiLine,
84 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 90 @GetMapping("/page")
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/planrate/vo/PlanRatePageReqVO.java
1 1 package com.zteits.urbanops.module.garden.controller.admin.planrate.vo;
2 2  
  3 +import io.swagger.v3.oas.annotations.Hidden;
3 4 import jakarta.validation.constraints.NotNull;
4 5 import lombok.*;
5 6 import java.util.*;
... ... @@ -30,4 +31,8 @@ public class PlanRatePageReqVO extends PageParam {
30 31 @NotNull(message = "类型:1:养护;2:巡查不能为空")
31 32 private Integer type;
32 33  
  34 + @Schema(description = "公司ID", requiredMode = Schema.RequiredMode.REQUIRED)
  35 + @Hidden
  36 + private Long companyId;
  37 +
33 38 }
34 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 36 @ExcelProperty("创建时间")
37 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 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 47 * 类型:1:养护;2:巡查
48 48 */
49 49 private Integer type;
  50 + /**
  51 + * 公司ID
  52 + */
  53 + private Long companyId;
50 54  
51 55  
52 56 }
53 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 31  
32 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 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 24 .eqIfPresent(PlanRateDO::getPlanTypeId, reqVO.getPlanTypeId())
25 25 .eqIfPresent(PlanRateDO::getStdPlan, reqVO.getStdPlan())
26 26 .eq(PlanRateDO::getType, reqVO.getType())
  27 + .eqIfPresent(PlanRateDO::getCompanyId, reqVO.getCompanyId())
27 28 .orderByDesc(PlanRateDO::getId));
28 29 }
29 30 }
30 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 65 * @param levelId 道路等级
66 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 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 5 import com.zteits.urbanops.module.garden.dal.dataobject.planrate.PlanRateDO;
6 6 import com.zteits.urbanops.module.garden.dal.mysql.planrate.PlanRateMapper;
7 7 import com.zteits.urbanops.module.system.api.dict.DictDataApi;
  8 +import org.apache.ibatis.annotations.Param;
8 9 import org.springframework.stereotype.Service;
9 10 import jakarta.annotation.Resource;
10 11 import org.springframework.validation.annotation.Validated;
... ... @@ -92,12 +93,8 @@ public class PlanRateDetailServiceImpl implements PlanRateDetailService {
92 93  
93 94  
94 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 98 if (planRateDetailDO == null) {
102 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 64 * @param pageReqVO 分页查询
65 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 12 import com.zteits.urbanops.module.garden.dal.dataobject.planrate.PlanRateDetailDO;
13 13 import com.zteits.urbanops.module.garden.dal.mysql.planrate.PlanRateDetailMapper;
14 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 17 import org.springframework.stereotype.Service;
16 18 import jakarta.annotation.Resource;
  19 +import org.springframework.util.CollectionUtils;
17 20 import org.springframework.validation.annotation.Validated;
18 21 import org.springframework.transaction.annotation.Transactional;
19 22  
20 23 import java.time.LocalDateTime;
21 24 import java.util.*;
  25 +import java.util.stream.Collectors;
22 26  
23 27 import com.zteits.urbanops.module.garden.controller.admin.planrate.vo.*;
24 28 import com.zteits.urbanops.module.garden.dal.dataobject.planrate.PlanRateDO;
... ... @@ -51,12 +55,16 @@ public class PlanRateServiceImpl implements PlanRateService {
51 55 @Resource
52 56 private DictDataCommonApi dictDataCommonApi;
53 57  
  58 + @Resource
  59 + private DeptApi deptApi;
  60 +
54 61 @Transactional(rollbackFor = Exception.class)
55 62 @Override
56 63 public Long createPlanRate(PlanRateSaveReqVO createReqVO) {
57 64 // 校验存在
58 65 validatePlanRateExists(createReqVO.getPlanTypeId(), createReqVO.getBusiLine());
59 66 LocalDateTime now = LocalDateTime.now();
  67 + Long companyId = SecurityFrameworkUtils.getCompanyId();
60 68 String userName = SecurityFrameworkUtils.getLoginUserId() + "";
61 69 String rateNo = DateUtil.format(new Date(), "yyyyMMddHHmmssSSS") + RandomUtil.randomInt(1000);
62 70 PlanRateDO planRate = new PlanRateDO();
... ... @@ -65,6 +73,7 @@ public class PlanRateServiceImpl implements PlanRateService {
65 73 planRate.setBusiLine(createReqVO.getBusiLine());
66 74 planRate.setPlanTypeId(createReqVO.getPlanTypeId());
67 75 planRate.setType(createReqVO.getType());
  76 + planRate.setCompanyId(companyId);
68 77 planRate.setCreator(userName);
69 78 planRate.setCreateTime(now);
70 79 planRate.setUpdater(userName);
... ... @@ -181,8 +190,28 @@ public class PlanRateServiceImpl implements PlanRateService {
181 190 }
182 191  
183 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 217 @Override
... ...
urbanops-module-garden/src/main/resources/mapper/planrate/PlanRateDetailMapper.xml
... ... @@ -12,4 +12,19 @@
12 12 <delete id="deleteByRateNo">
13 13 delete from garden_plan_rate_detail where rate_no=#{rateNo}
14 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 30 </mapper>
16 31 \ No newline at end of file
... ...