Browse Source

月指标报表

develop
bobol 12 months ago
parent
commit
9d3cb26ac4
  1. 2
      lzbi-framework/src/main/java/com/lzbi/framework/config/SecurityConfig.java
  2. 31
      lzbi-module/src/main/java/com/lzbi/draft/controller/ReportController.java
  3. 22
      lzbi-module/src/main/java/com/lzbi/draft/entity/dto/TargetDraftMonthReportValueDTO.java
  4. 42
      lzbi-module/src/main/java/com/lzbi/draft/entity/req/TargetDraftMonthReportReq.java
  5. 144
      lzbi-module/src/main/java/com/lzbi/draft/entity/vo/TargetDraftMonthReportVO.java
  6. 7
      lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiTargetDraftMonthMapper.java
  7. 71
      lzbi-module/src/main/java/com/lzbi/draft/service/ReportService.java
  8. 35
      lzbi-module/src/main/resources/mapper/draft/DcBusiTargetDraftMonthMapper.xml

2
lzbi-framework/src/main/java/com/lzbi/framework/config/SecurityConfig.java

@ -111,7 +111,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
// 过滤请求 // 过滤请求
.authorizeRequests() .authorizeRequests()
// 对于登录login 注册register 验证码captchaImage 允许匿名访问 // 对于登录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(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
.antMatchers( "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll() .antMatchers( "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()

31
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<TargetDraftMonthReportVO> targetDraftMonthReport(TargetDraftMonthReportReq targetDraftMonthReportReq) {
return reportService.getTargetDraftMonthReport(targetDraftMonthReportReq);
}
}

22
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;
}

42
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;
}

144
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;
}

7
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 java.util.List;
import com.lzbi.draft.domain.DcBusiTargetDraftMonth; import com.lzbi.draft.domain.DcBusiTargetDraftMonth;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; 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接口 * 指标数据底稿()Mapper接口
@ -60,4 +63,8 @@ public interface DcBusiTargetDraftMonthMapper extends BaseMapper<DcBusiTargetDra
* @return 结果 * @return 结果
*/ */
public int deleteDcBusiTargetDraftMonthByIds(Long[] ids); public int deleteDcBusiTargetDraftMonthByIds(Long[] ids);
List<TargetDraftMonthReportValueDTO> selectTargetDraftMonthReportValue(TargetDraftMonthReportReq targetDraftMonthReportReq);
List<TargetDraftMonthReportVO> selectTargetDraftMonthReportVO(TargetDraftMonthReportReq targetDraftMonthReportReq);
} }

71
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<TargetDraftMonthReportVO> getTargetDraftMonthReport(TargetDraftMonthReportReq targetDraftMonthReportReq) {
Class<TargetDraftMonthReportVO> targetDraftMonthReportVOClass = TargetDraftMonthReportVO.class;
List<TargetDraftMonthReportVO> 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<TargetDraftMonthReportValueDTO> 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;
}
}

35
lzbi-module/src/main/resources/mapper/draft/DcBusiTargetDraftMonthMapper.xml

@ -89,6 +89,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id} where id = #{id}
</select> </select>
<select id="selectTargetDraftMonthReportValue"
parameterType="com.lzbi.draft.entity.req.TargetDraftMonthReportReq"
resultType="com.lzbi.draft.entity.dto.TargetDraftMonthReportValueDTO">
SELECT
t1.asset_code AS "assetCode",
sum( t1.val_avg_all ) AS "value"
FROM
dc_busi_target_draft_month t1
INNER JOIN dc_base_asset_target t2 ON t1.target_code = t2.target_code
AND t1.asset_code = t2.asset_code
WHERE
t2.target_model_code = #{targetModelCode}
AND t1.company_id = #{companyId}
AND t1.org_id = #{orgId}
AND t1.field_code = #{fieldCode}
AND t1.count_year = #{year}
AND t1.count_month = #{month}
GROUP BY
t1.asset_code
</select>
<select id="selectTargetDraftMonthReportVO"
parameterType="com.lzbi.draft.entity.req.TargetDraftMonthReportReq"
resultType="com.lzbi.draft.entity.vo.TargetDraftMonthReportVO">
SELECT t1.asset_code AS "assetCode", max(t1.asset_name) AS "assetName"
FROM `dc_busi_target_draft_month` t1
WHERE
t1.company_id = #{companyId}
AND t1.org_id = #{orgId}
AND t1.field_code = #{fieldCode}
AND t1.count_year = #{year}
AND t1.count_month = #{month}
GROUP BY
t1.asset_code
</select>
<insert id="insertDcBusiTargetDraftMonth" parameterType="DcBusiTargetDraftMonth" useGeneratedKeys="true" keyProperty="id"> <insert id="insertDcBusiTargetDraftMonth" parameterType="DcBusiTargetDraftMonth" useGeneratedKeys="true" keyProperty="id">
insert into dc_busi_target_draft_month insert into dc_busi_target_draft_month
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">

Loading…
Cancel
Save