diff --git a/lzbi-framework/src/main/java/com/lzbi/framework/config/SecurityConfig.java b/lzbi-framework/src/main/java/com/lzbi/framework/config/SecurityConfig.java index 5aafb00..24b46b8 100644 --- a/lzbi-framework/src/main/java/com/lzbi/framework/config/SecurityConfig.java +++ b/lzbi-framework/src/main/java/com/lzbi/framework/config/SecurityConfig.java @@ -111,7 +111,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter // 过滤请求 .authorizeRequests() // 对于登录login 注册register 验证码captchaImage 允许匿名访问 - .antMatchers("/login", "/register", "/captchaImage","/assetData/**","/magic/api/**").permitAll() + .antMatchers("/login", "/register", "/captchaImage","/assetData/**","/magic/api/**", "/report/**").permitAll() // 静态资源,可匿名访问 .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() .antMatchers( "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll() diff --git a/lzbi-module/src/main/java/com/lzbi/draft/controller/ReportController.java b/lzbi-module/src/main/java/com/lzbi/draft/controller/ReportController.java new file mode 100644 index 0000000..a663cec --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/draft/controller/ReportController.java @@ -0,0 +1,31 @@ +package com.lzbi.draft.controller; + +import com.lzbi.common.core.domain.AjaxResult; +import com.lzbi.draft.entity.req.TargetDraftMonthReportReq; +import com.lzbi.draft.entity.vo.TargetDraftMonthReportVO; +import com.lzbi.draft.service.ReportService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * 报表Controller + * + * @author lienbo + * @date 2023-12-12 + */ +@RestController +@RequestMapping("/report") +public class ReportController { + + @Autowired + private ReportService reportService; + + @GetMapping("/targetDraftMonthReport") + public List targetDraftMonthReport(TargetDraftMonthReportReq targetDraftMonthReportReq) { + return reportService.getTargetDraftMonthReport(targetDraftMonthReportReq); + } +} diff --git a/lzbi-module/src/main/java/com/lzbi/draft/entity/dto/TargetDraftMonthReportValueDTO.java b/lzbi-module/src/main/java/com/lzbi/draft/entity/dto/TargetDraftMonthReportValueDTO.java new file mode 100644 index 0000000..e9e5ecc --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/draft/entity/dto/TargetDraftMonthReportValueDTO.java @@ -0,0 +1,22 @@ +package com.lzbi.draft.entity.dto; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 月指标报表查询dto + */ +@Data +public class TargetDraftMonthReportValueDTO { + + /** + * 统计单元编码 + */ + private String assetCode; + + /** + * 值 + */ + private BigDecimal value; +} diff --git a/lzbi-module/src/main/java/com/lzbi/draft/entity/req/TargetDraftMonthReportReq.java b/lzbi-module/src/main/java/com/lzbi/draft/entity/req/TargetDraftMonthReportReq.java new file mode 100644 index 0000000..520958c --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/draft/entity/req/TargetDraftMonthReportReq.java @@ -0,0 +1,42 @@ +package com.lzbi.draft.entity.req; + +import lombok.Data; + +@Data +public class TargetDraftMonthReportReq { + + /** + * 指标模型编码数组 + */ + public static final String[] TARGET_MODEL_CODE_ARR = new String[]{"MJ01","SSLL01","SSRL01","LJRL01","GW01","HW01","GY01","HY01","GW02","HW02","GY02","HY02","FMGD01","FMFK01","SXSW01","YCGJ01","CNFS01","KGM201","JGM201","YC01","WC01","JW01","WC02","EJW01","YC02"}; + + /** + * 公司id + */ + private Long companyId; + + /** + * 组织id + */ + private Long orgId; + + /** + * 专业编码 + */ + private String fieldCode; + + /** + * 年 + */ + private String year; + + /** + * 月 + */ + private String month; + + /** + * 指标模型编码 + */ + private String targetModelCode; +} diff --git a/lzbi-module/src/main/java/com/lzbi/draft/entity/vo/TargetDraftMonthReportVO.java b/lzbi-module/src/main/java/com/lzbi/draft/entity/vo/TargetDraftMonthReportVO.java new file mode 100644 index 0000000..04a4a88 --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/draft/entity/vo/TargetDraftMonthReportVO.java @@ -0,0 +1,144 @@ +package com.lzbi.draft.entity.vo; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class TargetDraftMonthReportVO { + + /** + * 统计单元编码 + */ + private String assetCode; + + /** + * 统计单元名称 + */ + private String assetName; + + /** + * 面积 + */ + private BigDecimal MJ01; + + /** + * 瞬时流量 + */ + private BigDecimal SSLL01; + + /** + * 瞬时热量 + */ + private BigDecimal SSRL01; + + /** + * 累计热量 + */ + private BigDecimal LJRL01; + + /** + * 供温 + */ + private BigDecimal GW01; + + /** + * 回温 + */ + private BigDecimal HW01; + + /** + * 供压 + */ + private BigDecimal GY01; + + /** + * 回压 + */ + private BigDecimal HY01; + + /** + * 供温 + */ + private BigDecimal GW02; + + /** + * 回温 + */ + private BigDecimal HW02; + + /** + * 供压 + */ + private BigDecimal GY02; + + /** + * 回压 + */ + private BigDecimal HY02; + + /** + * 阀门给定 + */ + private BigDecimal FMGD01; + + /** + * 阀门反馈 + */ + private BigDecimal FMFK01; + + /** + * 水箱水位 + */ + private BigDecimal SXSW01; + + /** + * 一次管径 + */ + private BigDecimal YCGJ01; + + /** + * 采暖方式 + */ + private BigDecimal CNFS01; + + /** + * KG/㎡ + */ + private BigDecimal KGM201; + + /** + * JG/㎡ + */ + private BigDecimal JGM201; + + /** + * 压差 + */ + private BigDecimal YC01; + + /** + * 温差 + */ + private BigDecimal WC01; + + /** + * 均温 + */ + private BigDecimal JW01; + + /** + * 温差 + */ + private BigDecimal WC02; + + /** + * 二均温 + */ + private BigDecimal EJW01; + + /** + * 压差 + */ + private BigDecimal YC02; +} diff --git a/lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiTargetDraftMonthMapper.java b/lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiTargetDraftMonthMapper.java index 4fe52a9..6badb8c 100644 --- a/lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiTargetDraftMonthMapper.java +++ b/lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiTargetDraftMonthMapper.java @@ -3,6 +3,9 @@ package com.lzbi.draft.mapper; import java.util.List; import com.lzbi.draft.domain.DcBusiTargetDraftMonth; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.lzbi.draft.entity.dto.TargetDraftMonthReportValueDTO; +import com.lzbi.draft.entity.req.TargetDraftMonthReportReq; +import com.lzbi.draft.entity.vo.TargetDraftMonthReportVO; /** * 指标数据底稿(月)Mapper接口 @@ -60,4 +63,8 @@ public interface DcBusiTargetDraftMonthMapper extends BaseMapper selectTargetDraftMonthReportValue(TargetDraftMonthReportReq targetDraftMonthReportReq); + + List selectTargetDraftMonthReportVO(TargetDraftMonthReportReq targetDraftMonthReportReq); } diff --git a/lzbi-module/src/main/java/com/lzbi/draft/service/ReportService.java b/lzbi-module/src/main/java/com/lzbi/draft/service/ReportService.java new file mode 100644 index 0000000..b067adb --- /dev/null +++ b/lzbi-module/src/main/java/com/lzbi/draft/service/ReportService.java @@ -0,0 +1,71 @@ +package com.lzbi.draft.service; + +import com.alibaba.fastjson2.JSONArray; +import com.alibaba.fastjson2.JSONObject; +import com.lzbi.draft.entity.dto.TargetDraftMonthReportValueDTO; +import com.lzbi.draft.entity.req.TargetDraftMonthReportReq; +import com.lzbi.draft.entity.vo.TargetDraftMonthReportVO; +import com.lzbi.draft.mapper.DcBusiTargetDraftMonthMapper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.lang.reflect.Field; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CountDownLatch; + +@Slf4j +@Service +public class ReportService { + + @Resource + private DcBusiTargetDraftMonthMapper dcBusiTargetDraftMonthMapper; + + @Autowired + private ThreadPoolTaskExecutor threadPoolTaskExecutor; + + public List getTargetDraftMonthReport(TargetDraftMonthReportReq targetDraftMonthReportReq) { + Class targetDraftMonthReportVOClass = TargetDraftMonthReportVO.class; + List list = dcBusiTargetDraftMonthMapper.selectTargetDraftMonthReportVO(targetDraftMonthReportReq); + CountDownLatch countDownLatch = new CountDownLatch(TargetDraftMonthReportReq.TARGET_MODEL_CODE_ARR.length); + for (String targetModelCode : TargetDraftMonthReportReq.TARGET_MODEL_CODE_ARR) { + threadPoolTaskExecutor.execute(() -> { + TargetDraftMonthReportReq req = JSONObject.parseObject(JSONObject.toJSONString(targetDraftMonthReportReq), TargetDraftMonthReportReq.class); + req.setTargetModelCode(targetModelCode); + List targetDraftMonthReportValueDTOS = dcBusiTargetDraftMonthMapper.selectTargetDraftMonthReportValue(req); + log.info("{} 执行完成,结果是 {}", targetModelCode, JSONArray.toJSONString(targetDraftMonthReportValueDTOS)); + for (int i = 0, len = list.size(); i < len; i++) { + TargetDraftMonthReportVO targetDraftMonthReportVO = list.get(i); + for (int j = targetDraftMonthReportValueDTOS.size() - 1; j >= 0; j--) { + TargetDraftMonthReportValueDTO targetDraftMonthReportValueDTO = targetDraftMonthReportValueDTOS.get(j); + if (targetDraftMonthReportVO.getAssetCode().equals(targetDraftMonthReportValueDTO.getAssetCode())) { + try { + Field declaredField = targetDraftMonthReportVOClass.getDeclaredField(targetModelCode); + if (!declaredField.isAccessible()) { + declaredField.setAccessible(true); + } + declaredField.set(targetDraftMonthReportVO, targetDraftMonthReportValueDTO.getValue()); + } catch (NoSuchFieldException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + targetDraftMonthReportValueDTOS.remove(j); + break; + } + } + } + countDownLatch.countDown(); + }); + } + try { + countDownLatch.await(); + } catch (InterruptedException e) { + log.error("门闩异常", e); + } + return list; + } +} diff --git a/lzbi-module/src/main/resources/mapper/draft/DcBusiTargetDraftMonthMapper.xml b/lzbi-module/src/main/resources/mapper/draft/DcBusiTargetDraftMonthMapper.xml index 763400c..f96d6ae 100644 --- a/lzbi-module/src/main/resources/mapper/draft/DcBusiTargetDraftMonthMapper.xml +++ b/lzbi-module/src/main/resources/mapper/draft/DcBusiTargetDraftMonthMapper.xml @@ -88,7 +88,42 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} - + + + + insert into dc_busi_target_draft_month