bobol
12 months ago
8 changed files with 354 additions and 2 deletions
@ -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); |
|||
} |
|||
} |
@ -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; |
|||
} |
@ -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; |
|||
} |
@ -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; |
|||
} |
@ -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; |
|||
} |
|||
} |
Loading…
Reference in new issue