Browse Source

Merge remote-tracking branch 'origin/develop' into develop

develop
zhousq 8 months ago
parent
commit
53a4245886
  1. 5
      lzbi-module/pom.xml
  2. 3
      lzbi-module/src/main/java/com/lzbi/asset/mapper/DcBusiWorkReadConfigMapper.java
  3. 6
      lzbi-module/src/main/java/com/lzbi/bill/controller/DcBusiTargetInputMasterController.java
  4. 18
      lzbi-module/src/main/java/com/lzbi/bill/domain/CellDataReadFormulaData.java
  5. 113
      lzbi-module/src/main/java/com/lzbi/bill/listener/CellDataReadFormulaListener.java
  6. 224
      lzbi-module/src/main/java/com/lzbi/bill/service/DcBusiTargetInputMasterService.java
  7. 3
      lzbi-module/src/main/java/com/lzbi/draft/domain/vo/ProductionDailySheetVO.java
  8. 16
      lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiTargetDraftDaynewMapper.java
  9. 17
      lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiTargetDraftMonthMapper.java
  10. 97
      lzbi-module/src/main/java/com/lzbi/wechat/controller/BizController.java
  11. 33
      lzbi-module/src/main/java/com/lzbi/wechat/controller/LoginController.java
  12. 54
      lzbi-module/src/main/java/com/lzbi/wechat/controller/WechatController.java
  13. 30
      lzbi-module/src/main/java/com/lzbi/wechat/domain/SysWechat.java
  14. 31
      lzbi-module/src/main/java/com/lzbi/wechat/domain/dto/ParamsContrastDTO.java
  15. 37
      lzbi-module/src/main/java/com/lzbi/wechat/domain/dto/TargetModelValueDTO.java
  16. 18
      lzbi-module/src/main/java/com/lzbi/wechat/domain/req/CodeLoginReq.java
  17. 19
      lzbi-module/src/main/java/com/lzbi/wechat/domain/req/PhoneNumberLoginReq.java
  18. 18
      lzbi-module/src/main/java/com/lzbi/wechat/domain/req/PhoneNumberReq.java
  19. 14
      lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatAccessTokenResp.java
  20. 19
      lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatBaseResp.java
  21. 23
      lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatCodeLoginResp.java
  22. 28
      lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatPhoneNumberResp.java
  23. 28
      lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/ChildDeptVO.java
  24. 14
      lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/CodeLoginVO.java
  25. 19
      lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/DeptVO.java
  26. 22
      lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/FinishingRateVO.java
  27. 25
      lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/TargetPlanVO.java
  28. 36
      lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/TargetResultVO.java
  29. 16
      lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/TargetVO.java
  30. 45
      lzbi-module/src/main/java/com/lzbi/wechat/mapper/SysWechatMapper.java
  31. 139
      lzbi-module/src/main/java/com/lzbi/wechat/service/DeptService.java
  32. 181
      lzbi-module/src/main/java/com/lzbi/wechat/service/LoginService.java
  33. 62
      lzbi-module/src/main/java/com/lzbi/wechat/service/SysWechatService.java
  34. 245
      lzbi-module/src/main/java/com/lzbi/wechat/service/TargetService.java
  35. 161
      lzbi-module/src/main/java/com/lzbi/wechat/service/WechatService.java
  36. 149
      lzbi-module/src/main/java/com/lzbi/wechat/webSocket/HeatSourceServer.java
  37. 26
      lzbi-module/src/main/resources/mapper/SysWechatMapper.xml
  38. 49
      lzbi-module/src/main/resources/mapper/asset/DcBusiTargetDraftDaynewMapper.xml
  39. 47
      lzbi-module/src/main/resources/mapper/asset/DcBusiTargetDraftMonthMapper.xml
  40. 25
      lzbi-module/src/main/resources/mapper/asset/DcBusiWorkReadConfigMapper.xml

5
lzbi-module/pom.xml

@ -55,6 +55,11 @@
<artifactId>easyexcel-core</artifactId>
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.54</version>
</dependency>
<!-- Mysql驱动包 -->
<!-- <dependency>-->

3
lzbi-module/src/main/java/com/lzbi/asset/mapper/DcBusiWorkReadConfigMapper.java

@ -6,7 +6,6 @@ import com.lzbi.asset.domain.DcBaseAssetInfo;
import com.lzbi.asset.domain.DcBusiWorkReadConfig;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lzbi.common.AssetQueryParams;
import com.lzbi.wechat.domain.dto.ParamsContrastDTO;
import org.apache.ibatis.annotations.Param;
/**
@ -35,8 +34,6 @@ public interface DcBusiWorkReadConfigMapper extends BaseMapper<DcBusiWorkReadCon
public List<DcBusiWorkReadConfig> selectDcBusiWorkReadConfigList(DcBusiWorkReadConfig dcBusiWorkReadConfig);
public List<DcBusiWorkReadConfig> selectDcBusiWorkReadConfigMainList(AssetQueryParams assetQueryParams);
List<ParamsContrastDTO> selectDcBusiWorkReadConfigByAssetTarget(@Param("targetModelCodeList") List<String> targetModelCodeList, @Param("dcBaseAssetInfo") DcBaseAssetInfo dcBaseAssetInfo);
/**
* 新增互联参数读取数据对照
*

6
lzbi-module/src/main/java/com/lzbi/bill/controller/DcBusiTargetInputMasterController.java

@ -33,7 +33,7 @@ import org.springframework.web.multipart.MultipartFile;
* @date 2024-01-19
*/
@RestController
@RequestMapping("/bill/DcBusiTargetInputMaster")
@RequestMapping("/bill/dcBusiTargetInputMaster")
public class DcBusiTargetInputMasterController extends BaseController
{
@Autowired
@ -151,7 +151,7 @@ public class DcBusiTargetInputMasterController extends BaseController
/**
* 确认日报数据
* @param list
* @param confirmReq
* @return
*/
@PostMapping("/confirm")
@ -175,7 +175,7 @@ public class DcBusiTargetInputMasterController extends BaseController
@ApiImplicitParam(name = "billNo", value = "", dataType = "String", dataTypeClass = String.class),
})
@PostMapping("/checkPass/{billNo}")
public AjaxResult checkPass(@PathVariable String billNo){
public AjaxResult checkPass(@PathVariable String billNo) throws InterruptedException {
return AjaxResult.success(dcBusiTargetInputMasterService.checkPass(billNo));
}

18
lzbi-module/src/main/java/com/lzbi/bill/domain/CellDataReadFormulaData.java

@ -0,0 +1,18 @@
package com.lzbi.bill.domain;
import com.alibaba.excel.metadata.data.CellData;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import java.util.Date;
/**
* 读取公式数据
*/
@Getter
@Setter
@EqualsAndHashCode
public class CellDataReadFormulaData {
private CellData<String> string;
}

113
lzbi-module/src/main/java/com/lzbi/bill/listener/CellDataReadFormulaListener.java

@ -0,0 +1,113 @@
package com.lzbi.bill.listener;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONConfig;
import cn.hutool.json.JSONUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.metadata.CellExtra;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.read.listener.ReadListener;
import com.lzbi.draft.domain.vo.ProductionDailySheetVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @author LWB
* @Description excel读取的监听器
* 有个很重要的点 ExcelReadListener监听器 不能被spring管理要每次读取excel都要new,然后里面用到spring可以构造方法传进去
* 所以,如果需要传入spring管理的对象,要么按照文档中的说明,直接使用构造器传参进来,要么使用ThreadLocal线程级别的变量工具传参
* 实际应用中,可能会需要传入很多的spring管理的对象,或者其他上下文参数,遇到这种情况,建议使用ThreadLocal来传递参数,简单,便捷,无需重复修改构造器
* 如果是简单的传递个别上下文参数,也可以选用构造器传参的方式
*/
@Slf4j
public class CellDataReadFormulaListener implements ReadListener<Map<Integer, String>> {
/**
* excel所有的sheet-row-cell数据
*/
private List<ProductionDailySheetVO> list;
/**
* 每个sheet页的所有行
*/
private List<List<String>> rows;
/**
* sheet页的号
*/
private Integer sheetNo;
/**
* 行的长度
*/
private Integer rowLength;
public CellDataReadFormulaListener () {
this.list = new ArrayList<>();
}
public List<ProductionDailySheetVO> getList() {
return list;
}
@Override
public void onException(Exception exception, AnalysisContext context) throws Exception {
ReadListener.super.onException(exception, context);
}
@Override
public void invokeHead(Map<Integer, ReadCellData<?>> headMap, AnalysisContext context) {
ReadListener.super.invokeHead(headMap, context);
}
@Override
public void invoke(Map<Integer, String> data, AnalysisContext context) {
if (null != data) {
List<String> cells = new ArrayList<>();
data.forEach((k, v) -> {
if ("系统指标名称".equals(v)) {
rowLength = data.size();
}
});
if (null != rowLength) {
for (int i = 0; i < rowLength; i++) {
if (StringUtils.isNotBlank(data.get(i))) {
cells.add(data.get(i));
} else {
cells.add("");
}
}
this.rows.add(cells);
}
}
}
@Override
public void extra(CellExtra extra, AnalysisContext context) {
ReadListener.super.extra(extra, context);
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
if (CollectionUtil.isNotEmpty(this.rows)) {
JSONArray data = JSONUtil.parseArray(JSONUtil.toJsonStr(this.rows));
list.add(new ProductionDailySheetVO(context.readSheetHolder().getSheetNo(), context.readSheetHolder().getSheetName(), data));
}
this.rows = null;
this.rowLength = null;
}
@Override
public boolean hasNext(AnalysisContext context) {
if (!context.readSheetHolder().getSheetNo().equals(this.sheetNo)) {
this.sheetNo = context.readSheetHolder().getSheetNo();
this.rows = new ArrayList<>();
}
return ReadListener.super.hasNext(context);
}
}

224
lzbi-module/src/main/java/com/lzbi/bill/service/DcBusiTargetInputMasterService.java

@ -1,11 +1,15 @@
package com.lzbi.bill.service;
import cn.hutool.json.JSONUtil;
import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lzbi.asset.domain.DcBaseAssetInfo;
import com.lzbi.asset.mapper.DcBaseAssetInfoMapper;
import com.lzbi.bill.domain.CellDataReadFormulaData;
import com.lzbi.bill.domain.DcBusiTargetInputMaster;
import com.lzbi.bill.domain.DcBusiTargetInputSub;
import com.lzbi.bill.listener.CellDataReadFormulaListener;
import com.lzbi.bill.mapper.DcBusiTargetInputMasterMapper;
import com.lzbi.bill.mapper.DcBusiTargetInputSubMapper;
import com.lzbi.common.core.domain.AjaxResult;
@ -41,6 +45,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.regex.Pattern;
@ -153,7 +158,7 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
return baseMapper.deleteDcBusiTargetInputMasterById(id);
}
public AjaxResult uploadProductionDaily(MultipartFile file) {
public AjaxResult uploadProductionDaily2(MultipartFile file) {
List<ProductionDailySheetVO> list = new ArrayList<>();
InputStream inputStream = null;
try {
@ -194,7 +199,7 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
data.add(cellList);
}
}
list.add(new ProductionDailySheetVO(j, sheetName, data));
// list.add(new ProductionDailySheetVO(j, sheetName, data));
}
return AjaxResult.success(list);
} catch (Exception e) {
@ -211,6 +216,29 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
}
}
public AjaxResult uploadProductionDaily(MultipartFile file) {
List<ProductionDailySheetVO> list;
InputStream inputStream = null;
try {
inputStream = file.getInputStream();
CellDataReadFormulaListener cellDataReadFormulaListener = new CellDataReadFormulaListener();
EasyExcel.read(inputStream, cellDataReadFormulaListener).doReadAll();
list = cellDataReadFormulaListener.getList();
} catch (Exception e) {
log.error("文件解析异常", e);
return AjaxResult.error();
} finally {
try {
if (null != inputStream) {
inputStream.close();
}
} catch (IOException e) {
log.error("文件解析异常", e);
}
}
return AjaxResult.success(list);
}
public AjaxResult confirm(ConfirmReq confirmReq) {
List<DcBusiTargetInputSub> result = new ArrayList<>();
List<ProductionDailySheetReq> list = confirmReq.getList();
@ -246,11 +274,19 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
if (!CollectionUtils.isEmpty(data)) {
Map<String, Integer> dayMap = new HashMap<>();
boolean sign = false;
int marking = -1;
for (int i = 0, leni = data.size(); i < leni; i++) {
List<String> row = data.get(i);
if ("日期".equals(row.get(0))) {
int lenj = row.size();
for (int j = 1; j < lenj; j++) {
boolean flag = false;
for (int j = 0; j < lenj; j++) {
if ("系统指标名称".equals(row.get(j))) {
flag = true;
marking = j;
}
}
if (flag) {
for (int j = 0; j < lenj; j++) {
String column = row.get(j);
if ("合计".equals(column)) {
break;
@ -279,15 +315,30 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
continue;
}
if (sign) {
String column = row.get(0);
String column = "";
try {
column = row.get(marking);
} catch (IndexOutOfBoundsException e) {
log.error("数组越界,row:{},index:{}", JSONUtil.toJsonStr(row), marking);
}
if (StringUtils.isBlank(column)) {
continue;
}
DcBaseAssetTarget dcBaseAssetTarget = dcBaseAssetTargetMap.get(column);
if (!ObjectUtils.isEmpty(dcBaseAssetTarget)) {
if (ObjectUtils.isEmpty(dcBaseAssetTarget)) {
log.warn("统计单元:【{}】,指标:【{}】未配置", dcBaseAssetInfo.getAssetName(), column);
} else {
dayMap.forEach((day, index) -> {
String v = row.get(index);
if (Pattern.matches(".*[-!@#$%^&*()_+={}\\[\\]\"<>/;':\\\\|`~].*", v)) {
String v = "";
try {
v = row.get(index);
} catch (IndexOutOfBoundsException e) {
log.error("数组越界,row:{},day:{},index:{}", JSONUtil.toJsonStr(row), day, index);
}
if (Pattern.matches(".*[- !@#$%^&*()_+={}\\[\\]\"<>/;':\\\\|`~].*", v)) {
return;
}
if ("-".equals(v)) {
return;
}
if (v.contains(",")) {
@ -351,8 +402,9 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
}
@Transactional(rollbackFor = Exception.class)
public int checkPass(String billNo) {
lock.lock();
public int checkPass(String billNo) throws InterruptedException {
int r = 0;
if (lock.tryLock()) {
try {
DcBusiTargetInputMaster master = baseMapper.selectDcBusiTargetInputMasterByBillSerial(billNo);
if (ObjectUtils.isEmpty(master)) {
@ -374,13 +426,14 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
DcBusiTargetInputSub subParams = new DcBusiTargetInputSub();
subParams.setBillNoMaster(billNo);
List<DcBusiTargetInputSub> dcBusiTargetInputSubList = dcBusiTargetInputSubMapper.selectDcBusiTargetInputSubList(subParams);
List<DcBusiTargetDraftDaynew> newList = new ArrayList<>();
List<DcBusiTargetDraftDaynew> draftDayList = new ArrayList<>();
if (!CollectionUtils.isEmpty(dcBusiTargetInputSubList)) {
String year = master.getYear();
String month = master.getMonth();
List<String> targetCodeList = dcBusiTargetInputSubList.stream().map(DcBusiTargetInputSub::getTargetCode).collect(Collectors.toList());
List<DcBaseAssetTarget> dcBaseAssetTargets = dcBaseAssetTargetMapper.selectDcBaseAssetTargetByTargetCodeList(targetCodeList);
Map<String, List<DcBaseAssetTarget>> targetModelMap = dcBaseAssetTargets.stream().collect(Collectors.groupingBy(DcBaseAssetTarget::getTargetCode));
Map<String, DcBaseAssetTarget> targetModelMap = dcBaseAssetTargets.stream().collect(Collectors.toMap(DcBaseAssetTarget::getTargetCode, e -> e));
Map<String, String> targetModelCodeMap = dcBaseAssetTargets.stream().collect(Collectors.toMap(DcBaseAssetTarget::getTargetCode, DcBaseAssetTarget::getTargetModelCode));
for (DcBusiTargetInputSub dcBusiTargetInputSub : dcBusiTargetInputSubList) {
String day = dcBusiTargetInputSub.getDay();
@ -400,44 +453,77 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
dcBusiTargetDraftDaynew.setTagetName(dcBusiTargetInputSub.getTargetName());
dcBusiTargetDraftDaynew.setValueResult(dcBusiTargetInputSub.getValResult());
dcBusiTargetDraftDaynew.setTargetModelCode(targetModelCodeMap.get(dcBusiTargetInputSub.getTargetCode()));
newList.add(dcBusiTargetDraftDaynew);
draftDayList.add(dcBusiTargetDraftDaynew);
}
dcBusiTargetDraftDaynewMapper.batchInsertDcBusiTargetDraftDaynew(newList);
Map<String, List<DcBusiTargetInputSub>> targetMap = dcBusiTargetInputSubList.stream().collect(Collectors.groupingBy(DcBusiTargetInputSub::getTargetCode));
targetMap.forEach((targetCode, subList) -> {
dcBusiTargetDraftDaynewMapper.batchInsertDcBusiTargetDraftDaynew(draftDayList);
List<DcBusiTargetDraftMonth> draftMonthList = new ArrayList<>();
Map<String, List<DcBusiTargetInputSub>> billTargetMap = dcBusiTargetInputSubList.stream().collect(Collectors.groupingBy(DcBusiTargetInputSub::getTargetCode));
List<DcBusiTargetDraftMonth> dcBusiTargetDraftMonthList = dcBusiTargetDraftMonthMapper.selectDcBusiTargetDraftMonthListByInputBill(master);
if (CollectionUtils.isEmpty(dcBusiTargetDraftMonthList)) {
billTargetMap.forEach((targetCode, subList) -> {
DcBusiTargetInputSub subObj = subList.get(0);
DcBusiTargetDraftMonth dcBusiTargetDraftMonth = new DcBusiTargetDraftMonth();
DcBusiTargetInputSub dcBusiTargetInputSub = subList.get(0);
dcBusiTargetDraftMonth.setCompanyId(dcBusiTargetInputSub.getCompanyId());
dcBusiTargetDraftMonth.setOrgId(dcBusiTargetInputSub.getOragnizeId());
dcBusiTargetDraftMonth.setFieldCode(dcBusiTargetInputSub.getFieldCode());
dcBusiTargetDraftMonth.setAssetCode(dcBusiTargetInputSub.getAssetCode());
dcBusiTargetDraftMonth.setTargetCode(dcBusiTargetInputSub.getTargetCode());
dcBusiTargetDraftMonth.setCompanyId(subObj.getCompanyId());
dcBusiTargetDraftMonth.setOrgId(subObj.getOragnizeId());
dcBusiTargetDraftMonth.setFieldCode(subObj.getFieldCode());
dcBusiTargetDraftMonth.setAssetCode(subObj.getAssetCode());
dcBusiTargetDraftMonth.setTargetCode(subObj.getTargetCode());
dcBusiTargetDraftMonth.setCountYear(year);
dcBusiTargetDraftMonth.setCountMonth(month);
List<DcBusiTargetDraftMonth> dcBusiTargetDraftMonthList = dcBusiTargetDraftMonthMapper.selectDcBusiTargetDraftMonthList(dcBusiTargetDraftMonth);
if (CollectionUtils.isEmpty(dcBusiTargetDraftMonthList)) {
dcBusiTargetDraftMonth.setCompanyName(dcBusiTargetInputSub.getCompanyName());
dcBusiTargetDraftMonth.setOrgName(dcBusiTargetInputSub.getOrganizeName());
dcBusiTargetDraftMonth.setFieldName(dcBusiTargetInputSub.getFieldName());
dcBusiTargetDraftMonth.setAssetName(dcBusiTargetInputSub.getAssetName());
dcBusiTargetDraftMonth.setTargetName(dcBusiTargetInputSub.getTargetName());
List<DcBaseAssetTarget> dcBaseAssetTargets1 = targetModelMap.get(dcBusiTargetInputSub.getTargetCode());
DcBaseAssetTarget dcBaseAssetTarget = dcBaseAssetTargets1.get(0);
dcBusiTargetDraftMonth.setCountDate(year + "-" + month);
dcBusiTargetDraftMonth.setCompanyName(subObj.getCompanyName());
dcBusiTargetDraftMonth.setOrgName(subObj.getOrganizeName());
dcBusiTargetDraftMonth.setFieldName(subObj.getFieldName());
dcBusiTargetDraftMonth.setAssetName(subObj.getAssetName());
dcBusiTargetDraftMonth.setTargetName(subObj.getTargetName());
DcBaseAssetTarget dcBaseAssetTarget = targetModelMap.get(targetCode);
if (org.apache.commons.lang3.ObjectUtils.isNotEmpty(dcBaseAssetTarget)) {
dcBusiTargetDraftMonth.setTargetModelCode(dcBaseAssetTarget.getTargetModelCode());
dcBusiTargetDraftMonth.setTargetUint(dcBaseAssetTarget.getFieldUnit());
dcBusiTargetDraftMonth.setTargetNameAlias(dcBaseAssetTarget.getTargetNameAlias());
}
List<BigDecimal> resultList = subList.stream().map(DcBusiTargetInputSub::getValResult).collect(Collectors.toList());
BigDecimal result = new BigDecimal(0);
for (BigDecimal v : resultList) {
result = result.add(v);
}
dcBusiTargetDraftMonth.setValResult(result);
draftMonthList.add(dcBusiTargetDraftMonth);
});
} else {
Map<String, DcBusiTargetDraftMonth> draftMontTargetMap = dcBusiTargetDraftMonthList.stream().collect(Collectors.toMap(DcBusiTargetDraftMonth::getTargetCode, e -> e));
billTargetMap.forEach((targetCode, subList) -> {
DcBusiTargetDraftMonth dcBusiTargetDraftMonth = draftMontTargetMap.get(targetCode);
if (ObjectUtils.isEmpty(dcBusiTargetDraftMonth)) {
DcBusiTargetInputSub subObj = subList.get(0);
dcBusiTargetDraftMonth = new DcBusiTargetDraftMonth();
dcBusiTargetDraftMonth.setCompanyId(subObj.getCompanyId());
dcBusiTargetDraftMonth.setOrgId(subObj.getOragnizeId());
dcBusiTargetDraftMonth.setFieldCode(subObj.getFieldCode());
dcBusiTargetDraftMonth.setAssetCode(subObj.getAssetCode());
dcBusiTargetDraftMonth.setTargetCode(subObj.getTargetCode());
dcBusiTargetDraftMonth.setCountYear(year);
dcBusiTargetDraftMonth.setCountMonth(month);
dcBusiTargetDraftMonth.setCountDate(year + "-" + month);
dcBusiTargetDraftMonth.setCompanyName(subObj.getCompanyName());
dcBusiTargetDraftMonth.setOrgName(subObj.getOrganizeName());
dcBusiTargetDraftMonth.setFieldName(subObj.getFieldName());
dcBusiTargetDraftMonth.setAssetName(subObj.getAssetName());
dcBusiTargetDraftMonth.setTargetName(subObj.getTargetName());
DcBaseAssetTarget dcBaseAssetTarget = targetModelMap.get(targetCode);
if (org.apache.commons.lang3.ObjectUtils.isNotEmpty(dcBaseAssetTarget)) {
dcBusiTargetDraftMonth.setTargetModelCode(dcBaseAssetTarget.getTargetModelCode());
dcBusiTargetDraftMonth.setTargetUint(dcBaseAssetTarget.getFieldUnit());
dcBusiTargetDraftMonth.setTargetNameAlias(dcBaseAssetTarget.getTargetNameAlias());
}
List<BigDecimal> resultList = subList.stream().map(DcBusiTargetInputSub::getValResult).collect(Collectors.toList());
BigDecimal result = new BigDecimal(0);
for (BigDecimal v : resultList) {
result = result.add(v);
}
dcBusiTargetDraftMonth.setValResult(result);
dcBusiTargetDraftMonthMapper.insertDcBusiTargetDraftMonth(dcBusiTargetDraftMonth);
} else {
dcBusiTargetDraftMonth = dcBusiTargetDraftMonthList.get(0);
List<BigDecimal> resultList = subList.stream().map(DcBusiTargetInputSub::getValResult).collect(Collectors.toList());
BigDecimal result = new BigDecimal(0);
for (BigDecimal v : resultList) {
@ -450,15 +536,18 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
valResult = valResult.add(result);
}
dcBusiTargetDraftMonth.setValResult(valResult);
dcBusiTargetDraftMonthMapper.updateDcBusiTargetDraftMonth(dcBusiTargetDraftMonth);
}
draftMonthList.add(dcBusiTargetDraftMonth);
});
this.deleteDcBusiTargetDraftMonth(dcBusiTargetDraftMonthList);
}
dcBusiTargetDraftMonthMapper.batchInsertDcBusiTargetDraftMonth(draftMonthList);
}
// 修改审核状态为已处理
master.setCheckStatus("2");
master.setUpdatedBy(SecurityUtils.getUsername());
master.setCreatedTime(DateUtils.getNowDate());
return baseMapper.updateDcBusiTargetInputMaster(master);
r = baseMapper.updateDcBusiTargetInputMaster(master);
} catch (RuntimeException e) {
log.error("处理异常", e);
throw e;
@ -466,10 +555,13 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
lock.unlock();
}
}
return r;
}
@Transactional(rollbackFor = Exception.class)
public int checkRevert(String billNo) {
lock.lock();
int r = 0;
if (lock.tryLock()) {
try {
DcBusiTargetInputMaster master = baseMapper.selectDcBusiTargetInputMasterByBillSerial(billNo);
if ("0".equals(master.getCheckStatus())) {
@ -500,43 +592,32 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
subParams.setBillNoMaster(billNo);
List<DcBusiTargetInputSub> dcBusiTargetInputSubList = dcBusiTargetInputSubMapper.selectDcBusiTargetInputSubList(subParams);
if (!CollectionUtils.isEmpty(dcBusiTargetInputSubList)) {
String year = master.getYear();
String month = master.getMonth();
Map<String, List<DcBusiTargetInputSub>> targetMap = dcBusiTargetInputSubList.stream().collect(Collectors.groupingBy(DcBusiTargetInputSub::getTargetCode));
targetMap.forEach((targetCode, subList) -> {
DcBusiTargetDraftMonth dcBusiTargetDraftMonth = new DcBusiTargetDraftMonth();
DcBusiTargetInputSub dcBusiTargetInputSub = subList.get(0);
dcBusiTargetDraftMonth.setCompanyId(dcBusiTargetInputSub.getCompanyId());
dcBusiTargetDraftMonth.setOrgId(dcBusiTargetInputSub.getOragnizeId());
dcBusiTargetDraftMonth.setFieldCode(dcBusiTargetInputSub.getFieldCode());
dcBusiTargetDraftMonth.setAssetCode(dcBusiTargetInputSub.getAssetCode());
dcBusiTargetDraftMonth.setTargetCode(dcBusiTargetInputSub.getTargetCode());
dcBusiTargetDraftMonth.setCountYear(year);
dcBusiTargetDraftMonth.setCountMonth(month);
List<DcBusiTargetDraftMonth> dcBusiTargetDraftMonthList = dcBusiTargetDraftMonthMapper.selectDcBusiTargetDraftMonthList(dcBusiTargetDraftMonth);
List<DcBusiTargetDraftMonth> dcBusiTargetDraftMonthList = dcBusiTargetDraftMonthMapper.selectDcBusiTargetDraftMonthListByInputBill(master);
if (!CollectionUtils.isEmpty(dcBusiTargetDraftMonthList)) {
dcBusiTargetDraftMonth = dcBusiTargetDraftMonthList.get(0);
List<DcBusiTargetDraftMonth> draftMonthList = new ArrayList<>();
Map<String, List<DcBusiTargetInputSub>> billTargetMap = dcBusiTargetInputSubList.stream().collect(Collectors.groupingBy(DcBusiTargetInputSub::getTargetCode));
Map<String, DcBusiTargetDraftMonth> draftMonthMap = dcBusiTargetDraftMonthList.stream().collect(Collectors.toMap(DcBusiTargetDraftMonth::getTargetCode, e -> e));
draftMonthMap.forEach((targetCode, dcBusiTargetDraftMonth) -> {
if (billTargetMap.containsKey(targetCode)) {
List<DcBusiTargetInputSub> subList = billTargetMap.get(targetCode);
List<BigDecimal> resultList = subList.stream().map(DcBusiTargetInputSub::getValResult).collect(Collectors.toList());
BigDecimal valResult = dcBusiTargetDraftMonth.getValResult();
BigDecimal result = new BigDecimal(0);
BigDecimal result = dcBusiTargetDraftMonth.getValResult();
for (BigDecimal v : resultList) {
result = result.add(v);
result = result.subtract(v);
}
if (null == valResult) {
valResult = new BigDecimal(0);
} else {
valResult = valResult.subtract(result);
}
dcBusiTargetDraftMonth.setValResult(valResult);
dcBusiTargetDraftMonthMapper.updateDcBusiTargetDraftMonth(dcBusiTargetDraftMonth);
dcBusiTargetDraftMonth.setValResult(result);
draftMonthList.add(dcBusiTargetDraftMonth);
}
});
this.deleteDcBusiTargetDraftMonth(draftMonthList);
dcBusiTargetDraftMonthMapper.batchInsertDcBusiTargetDraftMonth(draftMonthList);
}
}
// 修改审核状态为已处理
master.setCheckStatus("1");
master.setUpdatedBy(SecurityUtils.getUsername());
master.setCreatedTime(DateUtils.getNowDate());
return baseMapper.updateDcBusiTargetInputMaster(master);
r = baseMapper.updateDcBusiTargetInputMaster(master);
} catch (RuntimeException e) {
log.error("处理异常", e);
throw e;
@ -544,5 +625,24 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
lock.unlock();
}
}
return r;
}
private void deleteDcBusiTargetDraftMonth (List<DcBusiTargetDraftMonth> dcBusiTargetDraftMonthList) {
Set<Long> draftMonthIdSet = dcBusiTargetDraftMonthList.stream().map(DcBusiTargetDraftMonth::getId).collect(Collectors.toSet());
Long[] ids = draftMonthIdSet.toArray(new Long[]{});
int len = ids.length;
int range = 1000;
int remainder = len % range;
int count = len / range;
Long[] idsNew;
for (int i = 0; i < count; i++) {
idsNew = Arrays.copyOfRange(ids, i * range, (i + 1) * range);
dcBusiTargetDraftMonthMapper.deleteDcBusiTargetDraftMonthByIds(idsNew);
}
if (remainder > 0) {
idsNew = Arrays.copyOfRange(ids, count * range, len);
dcBusiTargetDraftMonthMapper.deleteDcBusiTargetDraftMonthByIds(idsNew);
}
}
}

3
lzbi-module/src/main/java/com/lzbi/draft/domain/vo/ProductionDailySheetVO.java

@ -1,5 +1,6 @@
package com.lzbi.draft.domain.vo;
import cn.hutool.json.JSONArray;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@ -22,6 +23,6 @@ public class ProductionDailySheetVO {
/**
* 数据
*/
private List<List<Object>> data;
private JSONArray data;
}

16
lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiTargetDraftDaynewMapper.java

@ -7,8 +7,6 @@ import com.lzbi.draft.domain.vo.TargetDraftDayRangeResVo;
import com.lzbi.draft.domain.vo.TargetDraftDaynewAggregateResVo;
import com.lzbi.draft.domain.vo.TargetDraftDaynewReqVo;
import com.lzbi.draft.domain.vo.TargetDraftDaynewResVo;
import com.lzbi.wechat.domain.dto.TargetModelValueDTO;
import com.lzbi.wechat.domain.vo.TargetResultVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -43,20 +41,6 @@ public interface DcBusiTargetDraftDaynewMapper extends BaseMapper<DcBusiTargetDr
*/
public List<DcBusiTargetDraftDaynew> selectDcBusiTargetDraftDaynewList(DcBusiTargetDraftDaynew dcBusiTargetDraftDaynew);
/**
* 查询日指标数据
* @param targetModelValueDTO
* @return
*/
List<TargetResultVO> selectDayTargetModelValue(TargetModelValueDTO targetModelValueDTO);
/**
* 查询累计指标数据
* @param targetModelValueDTO
* @return
*/
List<TargetResultVO> selectTotalTargetModelValue(TargetModelValueDTO targetModelValueDTO);
/**
* 新增指标数据底稿日-新结构
*

17
lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiTargetDraftMonthMapper.java

@ -2,12 +2,11 @@ package com.lzbi.draft.mapper;
import java.util.List;
import com.lzbi.bill.domain.DcBusiTargetInputMaster;
import com.lzbi.draft.domain.DcBusiTargetDraftMonth;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lzbi.draft.domain.vo.TargetDraftDaynewReqVo;
import com.lzbi.draft.domain.vo.TargetDraftMonthAggregateResVo;
import com.lzbi.wechat.domain.dto.TargetModelValueDTO;
import com.lzbi.wechat.domain.vo.TargetPlanVO;
import org.apache.ibatis.annotations.Param;
/**
@ -36,18 +35,18 @@ public interface DcBusiTargetDraftMonthMapper extends BaseMapper<DcBusiTargetDra
public List<DcBusiTargetDraftMonth> selectDcBusiTargetDraftMonthList(DcBusiTargetDraftMonth dcBusiTargetDraftMonth);
/**
* 查询月指标总计划
* @param targetModelValueDTO
* 查询月指标累计
* @param targetDraftDaynewReqVo
* @return
*/
List<TargetPlanVO> selectTotalTargetModelPlanValue(TargetModelValueDTO targetModelValueDTO);
List<TargetDraftMonthAggregateResVo> selectDcBusiTargetDraftMontAggregateList(TargetDraftDaynewReqVo targetDraftDaynewReqVo);
/**
* 查询月指标累计值
* @param targetDraftDaynewReqVo
* 根据录入单查询
* @param dcBusiTargetInputMaster
* @return
*/
List<TargetDraftMonthAggregateResVo> selectDcBusiTargetDraftMontAggregateList(TargetDraftDaynewReqVo targetDraftDaynewReqVo);
List<DcBusiTargetDraftMonth> selectDcBusiTargetDraftMonthListByInputBill(DcBusiTargetInputMaster dcBusiTargetInputMaster);
/**
* 新增指标数据底稿()
@ -62,7 +61,7 @@ public interface DcBusiTargetDraftMonthMapper extends BaseMapper<DcBusiTargetDra
* @param dcBusiTargetDraftMonths
* @return
*/
int batchInsertDcBusiTargetDraftMonth(List<DcBusiTargetDraftMonth> dcBusiTargetDraftMonths);
int batchInsertDcBusiTargetDraftMonth(@Param("dcBusiTargetDraftMonths") List<DcBusiTargetDraftMonth> dcBusiTargetDraftMonths);
/**
* 修改指标数据底稿()

97
lzbi-module/src/main/java/com/lzbi/wechat/controller/BizController.java

@ -1,97 +0,0 @@
package com.lzbi.wechat.controller;
import com.lzbi.common.core.domain.AjaxResult;
import com.lzbi.wechat.service.DeptService;
import com.lzbi.wechat.service.TargetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/wechat/biz")
public class BizController {
@Autowired
@Qualifier("wechatDeptService")
private DeptService deptService;
@Autowired
private TargetService targetService;
/**
* 获取自己所在部门
* @return
*/
@GetMapping("/dept/self/list")
public AjaxResult getSelfDeptList() {
return AjaxResult.success(deptService.getSelfDeptList());
}
/**
* 获取下属部门列表
* @return
*/
@GetMapping("/dept/children")
public AjaxResult getDeptChildren(@RequestParam("deptId") Long deptId) {
return AjaxResult.success(deptService.getDeptChildren(deptId));
}
/**
* 获取供热面积
* @return
*/
@GetMapping("/heatRadiatingArea")
public AjaxResult getHeatRadiatingArea(@RequestParam("deptId") Long deptId, @RequestParam("date") String date) {
return AjaxResult.success(targetService.getHeatRadiatingArea(deptId, date));
}
/**
* 获取公司指标值
* @return
*/
@GetMapping("/comany/target")
public AjaxResult getComanyTarget(@RequestParam("deptId") Long deptId, @RequestParam("date") String date) {
return AjaxResult.success(targetService.getComanyTarget(deptId, date));
}
/**
* 获取热源指标值
* @param type 1单日指标2累计指标
* @return
*/
@GetMapping("/heatSource/target")
public AjaxResult getHeatSourceTarget(@RequestParam("deptId") Long deptId, @RequestParam("date") String date, @RequestParam("type") String type) {
return AjaxResult.success(targetService.getHeatSourceTarget(deptId, date, type));
}
/**
* 获取换热站参数
* @return
*/
@GetMapping("/heatExchangeStation/params")
public AjaxResult getHeatExchangeStationParams(@RequestParam("deptId") Long deptId, @RequestParam("date") String date) {
return AjaxResult.success(targetService.getHeatExchangeStationParams(deptId));
}
/**
* 获取完成率
* @return
*/
@GetMapping("/finishingRate")
public AjaxResult getFinishingRate(@RequestParam("deptId") Long deptId) {
return AjaxResult.success(targetService.getFinishingRate(deptId));
}
/**
* 获取完成率
* @return
*/
@GetMapping("/finishingRateLine")
public AjaxResult getFinishingRateLine(@RequestParam("deptId") Long deptId, @RequestParam("date") String date) {
return AjaxResult.success(targetService.finishingRateLine(deptId));
}
}

33
lzbi-module/src/main/java/com/lzbi/wechat/controller/LoginController.java

@ -1,33 +0,0 @@
package com.lzbi.wechat.controller;
import com.lzbi.common.constant.Constants;
import com.lzbi.common.core.domain.AjaxResult;
import com.lzbi.common.core.domain.model.LoginBody;
import com.lzbi.wechat.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/wechat/biz/login")
public class LoginController {
@Autowired
private LoginService loginService;
/**
* 登录方法
*
* @param loginBody 登录信息
* @return 结果
*/
@PostMapping("/username")
public AjaxResult login(@RequestBody LoginBody loginBody)
{
// 生成令牌
return loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
loginBody.getUuid());
}
}

54
lzbi-module/src/main/java/com/lzbi/wechat/controller/WechatController.java

@ -1,54 +0,0 @@
package com.lzbi.wechat.controller;
import com.lzbi.common.core.domain.AjaxResult;
import com.lzbi.wechat.domain.req.CodeLoginReq;
import com.lzbi.wechat.domain.req.PhoneNumberLoginReq;
import com.lzbi.wechat.domain.req.PhoneNumberReq;
import com.lzbi.wechat.service.WechatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 微信服务相关接口控制器
*/
@RestController
@RequestMapping("/wechat/server")
public class WechatController {
@Autowired
private WechatService wechatService;
/**
* 登录凭证登录
* @param codeLoginReq
* @return
*/
@PostMapping("/codeLogin")
public AjaxResult codeLogin(@Validated @RequestBody CodeLoginReq codeLoginReq) {
return AjaxResult.success("操作成功", wechatService.codeLogin(codeLoginReq));
}
/**
* 获取手机号
* @param phoneNumberReq
* @return
*/
@PostMapping("/phoneNumber")
public AjaxResult getPhoneNumber(@Validated @RequestBody PhoneNumberReq phoneNumberReq) {
return AjaxResult.success("操作成功", wechatService.getPhoneNumber(phoneNumberReq));
}
/**
* 手机号登录
* @param phoneNumberLoginReq
* @return
*/
@PostMapping("/phoneNumberLogin")
public AjaxResult phoneNumberLogin(@Validated @RequestBody PhoneNumberLoginReq phoneNumberLoginReq) {
return AjaxResult.success("操作成功", wechatService.phoneNumberLogin(phoneNumberLoginReq));
}
}

30
lzbi-module/src/main/java/com/lzbi/wechat/domain/SysWechat.java

@ -1,30 +0,0 @@
package com.lzbi.wechat.domain;
import lombok.Data;
/**
* 微信用户关系实体类
*/
@Data
public class SysWechat {
/**
* id
*/
private Long id;
/**
* 微信用户唯一标识
*/
private String openId;
/**
* 手机号
*/
private String phone;
public SysWechat() {}
public SysWechat(String openId, String phone) {
this.openId = openId;
this.phone = phone;
}
}

31
lzbi-module/src/main/java/com/lzbi/wechat/domain/dto/ParamsContrastDTO.java

@ -1,31 +0,0 @@
package com.lzbi.wechat.domain.dto;
import com.lzbi.wechat.domain.vo.TargetVO;
import lombok.Data;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Data
public class ParamsContrastDTO {
/**
* 内部参数模板编码
*/
private String paramsModelCode;
/**
* 外部参数编码
*/
private String paramsCode;
/**
*
*/
private Double value;
public static Map<String, ParamsContrastDTO> listTransitionMap(List<ParamsContrastDTO> list) {
Map<String, ParamsContrastDTO> map = new HashMap<>();
list.forEach(obj -> map.put(obj.getParamsModelCode(), obj));
return map;
}
}

37
lzbi-module/src/main/java/com/lzbi/wechat/domain/dto/TargetModelValueDTO.java

@ -1,37 +0,0 @@
package com.lzbi.wechat.domain.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* 查询指标值
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TargetModelValueDTO {
/**
* 指标模板编码列表
*/
private List<String> targetModelCodeList;
/**
* 部门id
*/
private Long deptId;
/**
*
*/
private String year;
/**
*
*/
private String month;
/**
*
*/
private String day;
}

18
lzbi-module/src/main/java/com/lzbi/wechat/domain/req/CodeLoginReq.java

@ -1,18 +0,0 @@
package com.lzbi.wechat.domain.req;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* 微信授权登录请求参数
*/
@Data
public class CodeLoginReq {
/**
* 登录时获取的 code可通过wx.login获取
*/
@NotBlank(message = "登录凭证不能为空")
private String code;
}

19
lzbi-module/src/main/java/com/lzbi/wechat/domain/req/PhoneNumberLoginReq.java

@ -1,19 +0,0 @@
package com.lzbi.wechat.domain.req;
import lombok.Data;
/**
* 手机号登录请求参数
*/
@Data
public class PhoneNumberLoginReq {
/**
* 手机号
*/
private String phone;
/**
* 微信用户唯一标识
*/
private String openId;
}

18
lzbi-module/src/main/java/com/lzbi/wechat/domain/req/PhoneNumberReq.java

@ -1,18 +0,0 @@
package com.lzbi.wechat.domain.req;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* 获取手机号请求参数
*/
@Data
public class PhoneNumberReq {
/**
* 手机号获取凭证
*/
@NotBlank(message = "手机号获取凭证不能为空")
private String code;
}

14
lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatAccessTokenResp.java

@ -1,14 +0,0 @@
package com.lzbi.wechat.domain.resp;
import lombok.Data;
/**
* 获取接口调用凭据
*/
@Data
public class WechatAccessTokenResp extends WechatBaseResp {
private String access_token;
private Long expires_in;
}

19
lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatBaseResp.java

@ -1,19 +0,0 @@
package com.lzbi.wechat.domain.resp;
import lombok.Data;
/**
* 微信接口返回值
*/
@Data
public class WechatBaseResp {
/**
* 错误码
*/
private Integer errcode;
/**
* 错误信息
*/
private String errmsg;
}

23
lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatCodeLoginResp.java

@ -1,23 +0,0 @@
package com.lzbi.wechat.domain.resp;
import lombok.Data;
/**
* 微信登录凭证登录返回值
*/
@Data
public class WechatCodeLoginResp extends WechatBaseResp {
/**
* 会话密钥
*/
private String session_key;
/**
* 用户在开放平台的唯一标识符若当前小程序已绑定到微信开放平台账号下会返回
*/
private String unionid;
/**
* 用户唯一标识
*/
private String openid;
}

28
lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatPhoneNumberResp.java

@ -1,28 +0,0 @@
package com.lzbi.wechat.domain.resp;
import lombok.Data;
/**
* 获取手机号返回值
*/
@Data
public class WechatPhoneNumberResp extends WechatBaseResp {
/**
* 手机号信息
*/
private PhoneInfo phone_info;
/**
* 手机号信息
*/
@Data
public static class PhoneInfo {
private String phoneNumber;
private String purePhoneNumber;
private String countryCode;
}
}

28
lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/ChildDeptVO.java

@ -1,28 +0,0 @@
package com.lzbi.wechat.domain.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ChildDeptVO {
/**
* 部门id
*/
private Object deptId;
/**
* 部门名称
*/
private String deptName;
/**
* 一次网供温
*/
private Double temperatureSupply;
/**
* 一次网回温
*/
private Double temperatureComeBack;
}

14
lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/CodeLoginVO.java

@ -1,14 +0,0 @@
package com.lzbi.wechat.domain.vo;
import lombok.Data;
/**
* 登录凭证登录返回值
*/
@Data
public class CodeLoginVO {
private String token;
private String openId;
}

19
lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/DeptVO.java

@ -1,19 +0,0 @@
package com.lzbi.wechat.domain.vo;
import lombok.Data;
/**
* 部门返回值
*/
@Data
public class DeptVO {
/**
* 部门id
*/
private Long value;
/**
* 部门名称
*/
private String label;
}

22
lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/FinishingRateVO.java

@ -1,22 +0,0 @@
package com.lzbi.wechat.domain.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class FinishingRateVO {
/**
* 指标怕名称列表
*/
private List<String> names;
/**
* 指标值列表
*/
private List<Double> values;
}

25
lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/TargetPlanVO.java

@ -1,25 +0,0 @@
package com.lzbi.wechat.domain.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* 指标返回值
*/
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TargetPlanVO extends TargetVO {
/**
* 指标模板编码
*/
private String targetCode;
/**
*
*/
Double value;
}

36
lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/TargetResultVO.java

@ -1,36 +0,0 @@
package com.lzbi.wechat.domain.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* 指标返回值
*/
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TargetResultVO extends TargetVO {
/**
* 指标名称
*/
private String targetName;
/**
* 指标单位
*/
private String targetUnit;
/**
*
*/
private Double value;
public TargetResultVO (String targetCode, String targetName, String targetUnit, Double value) {
super(targetCode);
this.targetName = targetName;
this.targetUnit = targetUnit;
this.value = value;
}
}

16
lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/TargetVO.java

@ -1,16 +0,0 @@
package com.lzbi.wechat.domain.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TargetVO {
/**
* 指标模板编码
*/
private String targetCode;
}

45
lzbi-module/src/main/java/com/lzbi/wechat/mapper/SysWechatMapper.java

@ -1,45 +0,0 @@
package com.lzbi.wechat.mapper;
import com.lzbi.wechat.domain.SysWechat;
import org.apache.ibatis.annotations.Param;
/**
* 微信用户关系数据访问层
*/
public interface SysWechatMapper {
/**
* 查询微信用户关系
* @param id
* @return
*/
SysWechat selectSysWechatById(@Param("id") Long id);
/**
* 查询微信用户关系
* @param openId
* @return
*/
SysWechat selectWechatByOpenId(@Param("openId") String openId);
/**
* 增加微信用户关系
* @param sysWechat
* @return
*/
int insertSysWechat(SysWechat sysWechat);
/**
* 修改微信用户关系
* @param sysWechat
* @return
*/
int updateSysWechat(SysWechat sysWechat);
/**
* 删除微信用户关系
* @param id
* @return
*/
int deleteSysWechat(@Param("id") Long id);
}

139
lzbi-module/src/main/java/com/lzbi/wechat/service/DeptService.java

@ -1,139 +0,0 @@
package com.lzbi.wechat.service;
import com.lzbi.asset.domain.DcBaseAssetInfo;
import com.lzbi.asset.mapper.DcBaseAssetInfoMapper;
import com.lzbi.asset.mapper.DcBusiWorkReadConfigMapper;
import com.lzbi.common.config.IotServerApiConfig;
import com.lzbi.common.constant.BizConstants;
import com.lzbi.common.core.domain.entity.SysDept;
import com.lzbi.common.core.domain.entity.SysRole;
import com.lzbi.common.core.domain.entity.SysUser;
import com.lzbi.common.core.domain.model.LoginUser;
import com.lzbi.common.utils.SecurityUtils;
import com.lzbi.system.service.ISysDeptService;
import com.lzbi.wechat.domain.dto.ParamsContrastDTO;
import com.lzbi.wechat.domain.vo.ChildDeptVO;
import com.lzbi.wechat.domain.vo.DeptVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j
@Service("wechatDeptService")
public class DeptService {
@Autowired
private ISysDeptService sysDeptService;
@Resource
private DcBaseAssetInfoMapper dcBaseAssetInfoMapper;
@Resource
private DcBusiWorkReadConfigMapper dcBusiWorkReadConfigMapper;
@Autowired
private RestTemplate restTemplate;
@Autowired
private IotServerApiConfig iotServerApiConfig;
public List<DeptVO> getSelfDeptList() {
List<DeptVO> list = new ArrayList<>();
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser sysUser = loginUser.getUser();
List<SysRole> roles = sysUser.getRoles();
List<Long> roleIds = roles.stream().map(SysRole::getRoleId).collect(Collectors.toList());
List<SysDept> sysDepts = sysDeptService.selectDeptListByRoleIds(roleIds);
if (!CollectionUtils.isEmpty(sysDepts)) {
list = sysDepts.stream().filter(sysDept -> {
if (BizConstants.DcDeptAttr.COMANY.equals(sysDept.getOrgType())) {
return true;
} else {
return false;
}
}).map(sysDept -> {
DeptVO deptVO = new DeptVO();
deptVO.setValue(sysDept.getDeptId());
deptVO.setLabel(sysDept.getDeptName());
return deptVO;
}).collect(Collectors.toList());
}
return list;
}
public List<ChildDeptVO> getDeptChildren(Long deptId) {
List<ChildDeptVO> list = new ArrayList<>();
SysDept selfDept = sysDeptService.selectDeptById(deptId);
String orgType = selfDept.getOrgType();
if (BizConstants.DcDeptAttr.COMANY.equals(orgType)) {
SysDept params = new SysDept();
params.setParentId(deptId);
params.setOrgType(BizConstants.DcDeptAttr.HEAT_SOURCE);
List<SysDept> sysDeptList = sysDeptService.selectDeptList(params);
if (!CollectionUtils.isEmpty(sysDeptList)) {
list = sysDeptList.stream().map(item -> {
ChildDeptVO childDeptVO = new ChildDeptVO();
childDeptVO.setDeptId(item.getDeptId());
childDeptVO.setDeptName(item.getDeptName());
childDeptVO.setTemperatureSupply(80D);
childDeptVO.setTemperatureComeBack(53D);
return childDeptVO;
}).collect(Collectors.toList());
}
getHeatSourceParamsValue(deptId);
} else {
DcBaseAssetInfo params = new DcBaseAssetInfo();
params.setOrgId(deptId);
params.setAssetLevel(BizConstants.DcAssetLevel.HEAT_EXCHANGE_STATION);
List<DcBaseAssetInfo> assetInfoList = dcBaseAssetInfoMapper.selectDcBaseAssetInfoList(params);
if (!CollectionUtils.isEmpty(assetInfoList)) {
list = assetInfoList.stream().map(item -> {
ChildDeptVO childDeptVO = new ChildDeptVO();
childDeptVO.setDeptId(item.getAssetCode());
childDeptVO.setDeptName(item.getAssetName());
childDeptVO.setTemperatureSupply(80D);
childDeptVO.setTemperatureComeBack(53D);
return childDeptVO;
}).collect(Collectors.toList());
}
}
return list;
}
/**
* 查询热源参数值
* @param deptId
* @return
*/
public Map<Long, Map<String, Double>> getHeatSourceParamsValue (Long deptId) {
Long userId = SecurityUtils.getUserId();
List<String> targetModelCodeList = new ArrayList<>();
targetModelCodeList.add("101");
targetModelCodeList.add("102");
DcBaseAssetInfo assetParams = new DcBaseAssetInfo();
assetParams.setOrgId(deptId);
assetParams.setAssetLevel(BizConstants.DcAssetLevel.HEAT_EXCHANGE_STATION);
assetParams.setAssetType(BizConstants.DcAssetType.REPORT);
List<ParamsContrastDTO> paramsContrastDTOList = dcBusiWorkReadConfigMapper.selectDcBusiWorkReadConfigByAssetTarget(targetModelCodeList, assetParams);
if (!CollectionUtils.isEmpty(paramsContrastDTOList)) {
List<String> paramsCodeList = paramsContrastDTOList.stream().map(ParamsContrastDTO::getParamsCode).collect(Collectors.toList());
Map<Long, Map<Object, List<String>>> req = new HashMap<>();
Map<Object, List<String>> deptMap = new HashMap<>();
deptMap.put(deptId, paramsCodeList);
req.put(userId, deptMap);
String resp = restTemplate.postForObject(iotServerApiConfig.getParamsValue(), req, String.class);
log.info("参数值:{}", resp);
}
return null;
}
}

181
lzbi-module/src/main/java/com/lzbi/wechat/service/LoginService.java

@ -1,181 +0,0 @@
package com.lzbi.wechat.service;
import com.lzbi.common.constant.CacheConstants;
import com.lzbi.common.constant.Constants;
import com.lzbi.common.constant.UserConstants;
import com.lzbi.common.core.domain.AjaxResult;
import com.lzbi.common.core.domain.entity.SysUser;
import com.lzbi.common.core.domain.model.LoginUser;
import com.lzbi.common.core.redis.RedisCache;
import com.lzbi.common.exception.ServiceException;
import com.lzbi.common.exception.user.*;
import com.lzbi.common.utils.DateUtils;
import com.lzbi.common.utils.MessageUtils;
import com.lzbi.common.utils.StringUtils;
import com.lzbi.common.utils.ip.IpUtils;
import com.lzbi.framework.manager.AsyncManager;
import com.lzbi.framework.manager.factory.AsyncFactory;
import com.lzbi.framework.security.context.AuthenticationContextHolder;
import com.lzbi.framework.web.service.TokenService;
import com.lzbi.system.service.ISysConfigService;
import com.lzbi.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service
public class LoginService {
@Autowired
private TokenService tokenService;
@Resource
private AuthenticationManager authenticationManager;
@Autowired
private RedisCache redisCache;
@Autowired
private ISysUserService userService;
@Autowired
private ISysConfigService configService;
/**
* 登录验证
*
* @param username 用户名
* @param password 密码
* @param code 验证码
* @param uuid 唯一标识
* @return 结果
*/
public AjaxResult login(String username, String password, String code, String uuid)
{
AjaxResult ajax = AjaxResult.success();
// 验证码校验
validateCaptcha(username, code, uuid);
// 登录前置校验
loginPreCheck(username, password);
// 用户验证
Authentication authentication = null;
try
{
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password);
AuthenticationContextHolder.setContext(authenticationToken);
// 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
authentication = authenticationManager.authenticate(authenticationToken);
}
catch (Exception e)
{
if (e instanceof BadCredentialsException)
{
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
throw new UserPasswordNotMatchException();
}
else
{
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage()));
throw new ServiceException(e.getMessage());
}
}
finally
{
AuthenticationContextHolder.clearContext();
}
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
SysUser user = loginUser.getUser();
recordLoginInfo(loginUser.getUserId());
// 生成token
String token = tokenService.createToken(loginUser);
ajax.put(Constants.TOKEN, token);
ajax.put("nickName", user.getNickName());
ajax.put("phone", user.getPhonenumber());
return ajax;
}
/**
* 校验验证码
*
* @param username 用户名
* @param code 验证码
* @param uuid 唯一标识
* @return 结果
*/
public void validateCaptcha(String username, String code, String uuid)
{
boolean captchaEnabled = configService.selectCaptchaEnabled();
if (captchaEnabled)
{
String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, "");
String captcha = redisCache.getCacheObject(verifyKey);
redisCache.deleteObject(verifyKey);
if (captcha == null)
{
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire")));
throw new CaptchaExpireException();
}
if (!code.equalsIgnoreCase(captcha))
{
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error")));
throw new CaptchaException();
}
}
}
/**
* 登录前置校验
* @param username 用户名
* @param password 用户密码
*/
public void loginPreCheck(String username, String password)
{
// 用户名或密码为空 错误
if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password))
{
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("not.null")));
throw new UserNotExistsException();
}
// 密码如果不在指定范围内 错误
if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
|| password.length() > UserConstants.PASSWORD_MAX_LENGTH)
{
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
throw new UserPasswordNotMatchException();
}
// 用户名不在指定范围内 错误
if (username.length() < UserConstants.USERNAME_MIN_LENGTH
|| username.length() > UserConstants.USERNAME_MAX_LENGTH)
{
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
throw new UserPasswordNotMatchException();
}
// IP黑名单校验
String blackStr = configService.selectConfigByKey("sys.login.blackIPList");
if (IpUtils.isMatchedIp(blackStr, IpUtils.getIpAddr()))
{
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("login.blocked")));
throw new BlackListException();
}
}
/**
* 记录登录信息
*
* @param userId 用户ID
*/
public void recordLoginInfo(Long userId)
{
SysUser sysUser = new SysUser();
sysUser.setUserId(userId);
sysUser.setLoginIp(IpUtils.getIpAddr());
sysUser.setLoginDate(DateUtils.getNowDate());
userService.updateUserProfile(sysUser);
}
}

62
lzbi-module/src/main/java/com/lzbi/wechat/service/SysWechatService.java

@ -1,62 +0,0 @@
package com.lzbi.wechat.service;
import com.lzbi.wechat.domain.SysWechat;
import com.lzbi.wechat.mapper.SysWechatMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* 微信用户关系业务访问层
*/
@Service
public class SysWechatService {
@Resource
private SysWechatMapper sysWechatMapper;
/**
* 查询微信用户关系
* @param id
* @return
*/
public SysWechat selectWechatById(Long id) {
return sysWechatMapper.selectSysWechatById(id);
}
/**
* 查询微信用户关系
* @param openId
* @return
*/
public SysWechat selectWechatByOpenId(String openId) {
return sysWechatMapper.selectWechatByOpenId(openId);
}
/**
* 增加微信用户关系
* @param sysWechat
* @return
*/
public int insertWechat(SysWechat sysWechat) {
return sysWechatMapper.insertSysWechat(sysWechat);
}
/**
* 修改微信用户关系
* @param sysWechat
* @return
*/
public int updateWechat(SysWechat sysWechat) {
return sysWechatMapper.updateSysWechat(sysWechat);
}
/**
* 删除微信用户关系
* @param id
* @return
*/
public int deleteWechat(Long id) {
return sysWechatMapper.deleteSysWechat(id);
}
}

245
lzbi-module/src/main/java/com/lzbi/wechat/service/TargetService.java

@ -1,245 +0,0 @@
package com.lzbi.wechat.service;
import com.lzbi.asset.mapper.DcBaseAssetInfoMapper;
import com.lzbi.common.constant.BizConstants;
import com.lzbi.common.constant.TargetModelCodeConstants;
import com.lzbi.draft.mapper.DcBusiTargetDraftDaynewMapper;
import com.lzbi.draft.mapper.DcBusiTargetDraftMonthMapper;
import com.lzbi.system.service.ISysDeptService;
import com.lzbi.targetFolder.mapper.DcBaseAssetTargetMapper;
import com.lzbi.wechat.domain.dto.TargetModelValueDTO;
import com.lzbi.wechat.domain.vo.TargetPlanVO;
import com.lzbi.wechat.domain.vo.TargetResultVO;
import com.lzbi.wechat.domain.vo.TargetVO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.text.DecimalFormat;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class TargetService {
@Autowired
private ISysDeptService sysDeptService;
@Resource
private DcBaseAssetInfoMapper dcBaseAssetInfoMapper;
@Resource
private DcBaseAssetTargetMapper dcBaseAssetTargetMapper;
@Resource
private DcBusiTargetDraftDaynewMapper dcBusiTargetDraftDaynewMapper;
@Resource
private DcBusiTargetDraftMonthMapper dcBusiTargetDraftMonthMapper;
private TargetModelValueDTO buildeTargetModelValueDTO(List<String> targetModelCodeList, Long deptId, String date) {
String year = null;
String month = null;
String day = null;
if (StringUtils.isNotBlank(date)) {
String[] arr = date.split("-");
if (arr.length == 3) {
year = arr[0];
month = arr[1];
day = arr[2];
} else {
throw new RuntimeException("日期格式不正确");
}
}
return new TargetModelValueDTO(targetModelCodeList, deptId, year, month, day);
}
public Double getHeatRadiatingArea(Long deptId, String date) {
List<String> targetModelCodeList = new ArrayList<>();
targetModelCodeList.add(TargetModelCodeConstants.总开栓面积);
TargetModelValueDTO targetModelValueDTO = buildeTargetModelValueDTO(targetModelCodeList, deptId, date);
List<TargetResultVO> targetResultVOList = dcBusiTargetDraftDaynewMapper.selectDayTargetModelValue(targetModelValueDTO);
Double result = null;
if (!CollectionUtils.isEmpty(targetResultVOList)) {
result = targetResultVOList.get(0).getValue();
}
return result;
}
public Map<String, TargetResultVO> getComanyTarget(Long deptId, String date) {
List<String> targetModelCodeList = new ArrayList<>();
targetModelCodeList.add(TargetModelCodeConstants.总产热量);
targetModelCodeList.add(TargetModelCodeConstants.一次网补水量);
targetModelCodeList.add(TargetModelCodeConstants.从大唐补一次网水量);
targetModelCodeList.add(TargetModelCodeConstants.总厂用电量);
targetModelCodeList.add(TargetModelCodeConstants.生产用标煤总量);
targetModelCodeList.add(TargetModelCodeConstants.热耗率);
TargetModelValueDTO targetModelValueDTO = buildeTargetModelValueDTO(targetModelCodeList, deptId, date);
List<TargetResultVO> targetResultVOList = dcBusiTargetDraftDaynewMapper.selectDayTargetModelValue(targetModelValueDTO);
Map<String, TargetResultVO> map = listTransitionMap(targetResultVOList);
TargetResultVO onceWater = map.get(TargetModelCodeConstants.一次网补水量);
TargetResultVO onceWater2 = map.get(TargetModelCodeConstants.从大唐补一次网水量);
if (null != onceWater.getValue() && null != onceWater2.getValue()) {
onceWater.setValue(onceWater.getValue() + onceWater2.getValue());
}
map.remove(TargetModelCodeConstants.从大唐补一次网水量);
map.put(TargetModelCodeConstants.一次网补水量, onceWater);
return map;
}
public Map<String, TargetResultVO> getHeatSourceTarget(Long deptId, String date, String type) {
List<String> targetModelCodeList = new ArrayList<>();
targetModelCodeList.add(TargetModelCodeConstants.一次网补水量); // 一次网水耗
targetModelCodeList.add(TargetModelCodeConstants.从大唐补一次网水量); // 一次网水耗
targetModelCodeList.add(TargetModelCodeConstants.总厂用电量); // 一次网电耗
targetModelCodeList.add(TargetModelCodeConstants.生产用标煤总量); // 一次网煤耗
targetModelCodeList.add(TargetModelCodeConstants.总产热量); // 总产热量
targetModelCodeList.add(TargetModelCodeConstants.汽炉产汽量); // 总产气量
targetModelCodeList.add(TargetModelCodeConstants.发电量); // 总发电量
targetModelCodeList.add(TargetModelCodeConstants.二次网耗水量); // 二次网总水耗
targetModelCodeList.add(TargetModelCodeConstants.二次网耗电量); // 二次网总电耗
targetModelCodeList.add(TargetModelCodeConstants.一次网供水温度); // 一次网供温
targetModelCodeList.add(TargetModelCodeConstants.一次网回水温度); // 一次网回温
targetModelCodeList.add(TargetModelCodeConstants.一次网耗水率); // 一次网水单耗
targetModelCodeList.add(TargetModelCodeConstants.热源厂电耗率); // 一次网电单耗
targetModelCodeList.add(TargetModelCodeConstants.单位面积耗标煤); // 一次网煤单耗
targetModelCodeList.add(TargetModelCodeConstants.二次网耗水率); // 二次网水单耗
targetModelCodeList.add(TargetModelCodeConstants.二次网耗电率); // 二次网电单耗
TargetModelValueDTO targetModelValueDTO = buildeTargetModelValueDTO(targetModelCodeList, deptId, date);
Map<String, TargetResultVO> map;
if (BizConstants.TargetType.DAY.equals(type)) {
List<TargetResultVO> targetResultVOList = dcBusiTargetDraftDaynewMapper.selectDayTargetModelValue(targetModelValueDTO);
map = listTransitionMap(targetResultVOList);
} else {
List<TargetResultVO> targetResultVOList = dcBusiTargetDraftDaynewMapper.selectTotalTargetModelValue(targetModelValueDTO);
map = listTransitionMap(targetResultVOList);
}
TargetResultVO targetResultVO1 = map.get(TargetModelCodeConstants.一次网补水量);
TargetResultVO targetResultVO2 = map.get(TargetModelCodeConstants.从大唐补一次网水量);
if (null != targetResultVO1.getValue() && null != targetResultVO2.getValue()) {
targetResultVO1.setValue(targetResultVO1.getValue() + targetResultVO2.getValue());
} else if (null == targetResultVO1.getValue() && null != targetResultVO2.getValue()) {
targetResultVO1.setValue(targetResultVO2.getValue());
}
map.remove(TargetModelCodeConstants.从大唐补一次网水量);
return map;
}
public Map<String, TargetResultVO> getHeatExchangeStationParams(Long deptId) {
Map<String, TargetResultVO> map = new HashMap<>();
map.put("014", new TargetResultVO("014", "一次网回压", "Mpa", 14123123D));
map.put("013", new TargetResultVO("013", "一次网供压", "Mpa", 2697D));
map.put("011", new TargetResultVO("011", "一次网供温", "°C", 16791D));
map.put("012", new TargetResultVO("012", "一次网回温", "°C", 11679D));
map.put("007", new TargetResultVO("007", "瞬时流量", "m³/h", 8971D));
map.put("008", new TargetResultVO("008", "瞬时热量", "kcal", 14123123D));
map.put("009", new TargetResultVO("009", "累计热量", "kcal", 2697D));
map.put("047", new TargetResultVO("047", "二次网供水压力", "Mpa", 16791D));
map.put("048", new TargetResultVO("048", "二次网回水压力", "Mpa", 11679D));
map.put("045", new TargetResultVO("045", "二次网供水温", "°C", 8971D));
map.put("046", new TargetResultVO("046", "二次网回水温", "°C", 8971D));
map.put("001", new TargetResultVO("001", "电调阀开度给定", "%", 14123123D));
map.put("002", new TargetResultVO("002", "电调阀开度反馈", "%", 2697D));
map.put("015", new TargetResultVO("015", "水箱水位计", "GJ", 16791D));
map.put("004", new TargetResultVO("004", "电调阀控制模式选择", "GJ", 11679D));
map.put("003", new TargetResultVO("003", "电调阀远控/就地", "°C", 8971D));
map.put("044", new TargetResultVO("044", "二次网压差设定", "%", 14123123D));
map.put("019", new TargetResultVO("019", "一次网管道泵上电", "", 2697D));
map.put("020", new TargetResultVO("020", "一次网管道泵下电", "", 16791D));
map.put("005", new TargetResultVO("005", "二次网供温设定", "", 16791D));
map.put("018", new TargetResultVO("018", "一次网管道泵远控/就地", "", 16791D));
map.put("021", new TargetResultVO("021", "一次网管道泵启动", "", 16791D));
map.put("010", new TargetResultVO("010", "热量累计清零", "kwh", 16791D));
map.put("017", new TargetResultVO("017", "总电表", "°C", 16791D));
map.put("006", new TargetResultVO("006", "二次网供回水平均温设定", "m³", 16791D));
map.put("031", new TargetResultVO("031", "水表(累计补水量)", "%", 16791D));
map.put("023", new TargetResultVO("023", "一次网管道泵频率给定", "%", 16791D));
map.put("028", new TargetResultVO("028", "一次网混水电调阀开度给定", "%", 16791D));
map.put("029", new TargetResultVO("029", "一次网混水电调阀开度反馈", "", 16791D));
map.put("035", new TargetResultVO("035", "补水泵1#故障状态", "m³", 16791D));
map.put("032", new TargetResultVO("032", "水表(累计补水量清零)", "", 16791D));
map.put("036", new TargetResultVO("036", "补水泵2#故障状态", "", 16791D));
map.put("037", new TargetResultVO("037", "循环泵远控/就地选择", "", 16791D));
map.put("038", new TargetResultVO("038", "循环泵1#/2#泵选择", "", 16791D));
map.put("039", new TargetResultVO("039", "循环泵控制模式选择", "", 16791D));
map.put("025", new TargetResultVO("025", "一次网管道泵运行/停止状态", "", 16791D));
map.put("026", new TargetResultVO("026", "一次网管道泵故障状态", "", 16791D));
map.put("027", new TargetResultVO("027", "一次网混水电调阀远控/就地", "", 16791D));
map.put("033", new TargetResultVO("033", "补水泵1#运行/停止状态", "", 16791D));
map.put("034", new TargetResultVO("034", "补水泵2#运行/停止状态", "", 16791D));
map.put("040", new TargetResultVO("040", "循环泵变频上电", "", 16791D));
map.put("041", new TargetResultVO("041", "循环泵变频下电", "", 16791D));
map.put("042", new TargetResultVO("042", "循环泵变频启动", "", 16791D));
map.put("043", new TargetResultVO("043", "循环泵变频停止", "", 16791D));
map.put("022", new TargetResultVO("022", "一次网管道泵停止", "", 16791D));
map.put("030", new TargetResultVO("030", "水表(瞬时补水量)", "m³", 16791D));
map.put("066", new TargetResultVO("066", "一次网管道泵启/停", "", 16791D));
map.put("024", new TargetResultVO("024", "一次网管道泵频率反馈", "", 16791D));
return map;
}
public List<List<Object>> getFinishingRate(Long deptId) {
List<List<Object>> list = new ArrayList<>();
List<String> targetModelCodeList = new ArrayList<>();
targetModelCodeList.add(TargetModelCodeConstants.一次网耗水率);
targetModelCodeList.add(TargetModelCodeConstants.二次网耗水率);
targetModelCodeList.add(TargetModelCodeConstants.热源厂电耗率);
targetModelCodeList.add(TargetModelCodeConstants.二次网耗电率);
targetModelCodeList.add(TargetModelCodeConstants.单位面积耗标煤);
TargetModelValueDTO targetModelValueDTO = buildeTargetModelValueDTO(targetModelCodeList, deptId, null);
List<TargetResultVO> targetResultVOList = dcBusiTargetDraftDaynewMapper.selectTotalTargetModelValue(targetModelValueDTO);
List<TargetPlanVO> targetPlanVOList = dcBusiTargetDraftMonthMapper.selectTotalTargetModelPlanValue(targetModelValueDTO);
Map<String, TargetResultVO> targetValueMap = null;
Map<String, Double> targetPlanValueMap = null;
if (!CollectionUtils.isEmpty(targetResultVOList)) {
targetValueMap = listTransitionMap(targetResultVOList);
}
if (!CollectionUtils.isEmpty(targetPlanVOList)) {
targetPlanValueMap = targetPlanVOList.stream().collect(Collectors.toMap(TargetPlanVO::getTargetCode, TargetPlanVO::getValue));
}
if (null == targetValueMap || null == targetPlanValueMap) {
throw new RuntimeException("无数据");
}
List<Object> names = new ArrayList<>();
names.add("name");
List<Object> values = new ArrayList<>();
values.add("总完成率");
DecimalFormat decimalFormat = new DecimalFormat("#0.00");
for (String targetModelCode : targetModelCodeList) {
TargetResultVO targetResultVO = targetValueMap.get(targetModelCode);
Double value = targetResultVO.getValue();
Double planValue = targetPlanValueMap.get(targetModelCode);
if (null == planValue) {
continue;
}
names.add(targetResultVO.getTargetName());
values.add(decimalFormat.format((value / planValue) * 100));
}
list.add(names);
list.add(values);
return list;
}
public List<List<Object>> finishingRateLine(Long deptId) {
List<List<Object>> list = new ArrayList<>();
List<Object> list1 = Arrays.asList("product", "2012", "2013", "2014", "2015", "2016", "2017");
List<Object> list2 = Arrays.asList("Milk Tea", 56.5, 82.1, 88.7, 70.1, 53.4, 85.1);
List<Object> list3 = Arrays.asList("Matcha Latte", 51.1, 51.4, 55.1, 53.3, 73.8, 68.7);
List<Object> list4 = Arrays.asList("Cheese Cocoa", 40.1, 62.2, 69.5, 36.4, 45.2, 32.5);
List<Object> list5 = Arrays.asList("Walnut Brownie", 25.2, 37.1, 41.2, 18, 33.9, 49.1);
list.add(list1);
list.add(list2);
list.add(list3);
list.add(list4);
list.add(list5);
return list;
}
private <T extends TargetVO> Map<String, T> listTransitionMap(List<T> list) {
Map<String, T> map = new HashMap<>();
list.forEach(obj -> map.put(obj.getTargetCode(), obj));
return map;
}
}

161
lzbi-module/src/main/java/com/lzbi/wechat/service/WechatService.java

@ -1,161 +0,0 @@
package com.lzbi.wechat.service;
import com.alibaba.fastjson2.JSONObject;
import com.lzbi.common.config.WechatConfig;
import com.lzbi.common.core.domain.entity.SysUser;
import com.lzbi.common.core.domain.model.LoginUser;
import com.lzbi.common.exception.ServiceException;
import com.lzbi.framework.web.service.SysLoginService;
import com.lzbi.framework.web.service.SysPermissionService;
import com.lzbi.framework.web.service.TokenService;
import com.lzbi.system.service.ISysUserService;
import com.lzbi.wechat.domain.SysWechat;
import com.lzbi.wechat.domain.resp.WechatAccessTokenResp;
import com.lzbi.wechat.domain.resp.WechatCodeLoginResp;
import com.lzbi.wechat.domain.resp.WechatPhoneNumberResp;
import com.lzbi.wechat.domain.req.CodeLoginReq;
import com.lzbi.wechat.domain.req.PhoneNumberLoginReq;
import com.lzbi.wechat.domain.req.PhoneNumberReq;
import com.lzbi.wechat.domain.vo.CodeLoginVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
import java.util.HashMap;
import java.util.Map;
/**
* 微信服务业务逻辑层
*/
@Slf4j
@Service
public class WechatService {
@Autowired
private WechatConfig wechatConfig;
@Autowired
private RestTemplate restTemplate;
@Autowired
private SysWechatService sysWechatService;
@Autowired
private ISysUserService sysUserService;
@Autowired
private SysLoginService sysLoginService;
@Autowired
private TokenService tokenService;
@Autowired
private SysPermissionService permissionService;
/**
* 登录凭证登录
*
* @param codeLoginReq
* @return
*/
public CodeLoginVO codeLogin(CodeLoginReq codeLoginReq) {
CodeLoginVO codeLoginVO = new CodeLoginVO();
// 微信登录凭证登录请求,获取到open_id
Map<String, Object> params = new HashMap<>();
params.put("appid", wechatConfig.getAppId());
params.put("secret", wechatConfig.getAppSecret());
params.put("js_code", codeLoginReq.getCode());
params.put("grant_type", "authorization_code");
WechatCodeLoginResp resp = restTemplate.getForObject(wechatConfig.getCode2Session(), WechatCodeLoginResp.class, params);
if (ObjectUtils.isNotEmpty(resp) && 0L == resp.getErrcode()) {
String openid = resp.getOpenid();
codeLoginVO.setOpenId(openid);
// 根据open_id到数据库中查询sysWechat信息
SysWechat sysWechat = sysWechatService.selectWechatByOpenId(openid);
// 查询到了的话,执行登录操作,返回token
if (ObjectUtils.isNotEmpty(sysWechat)) {
SysUser sysUser = sysUserService.selectUserByPhonenumber(sysWechat.getPhone());
if (ObjectUtils.isNotEmpty(sysUser)) {
String token = this.getToken(sysUser);
codeLoginVO.setToken(token);
}
}
} else {
log.error("调用微信服务小程序登录接口时失败,{}, {}", resp.getErrcode(), resp.getErrmsg());
throw new ServiceException(resp.getErrmsg(), resp.getErrcode());
}
return codeLoginVO;
}
@Transactional(rollbackFor = Exception.class)
public String phoneNumberLogin(PhoneNumberLoginReq phoneNumberLoginReq) {
// 微信和用户信息绑定
SysWechat sysWechat = new SysWechat(phoneNumberLoginReq.getOpenId(), phoneNumberLoginReq.getPhone());
int i = sysWechatService.insertWechat(sysWechat);
if (i > 0) {
// 获取token
SysUser sysUser = sysUserService.selectUserByPhonenumber(sysWechat.getPhone());
if (ObjectUtils.isNotEmpty(sysUser)) {
return this.getToken(sysUser);
}
}
return null;
}
/**
* 获取手机号
* @param phoneNumberReq
* @return
*/
public String getPhoneNumber(PhoneNumberReq phoneNumberReq) {
// 获取接口调用凭据
Map<String, Object> getAccessTokenParams = new HashMap<>();
getAccessTokenParams.put("appid", wechatConfig.getAppId());
getAccessTokenParams.put("secret", wechatConfig.getAppSecret());
getAccessTokenParams.put("grant_type", "client_credential");
WechatAccessTokenResp wechatAccessTokenResp = restTemplate.getForObject(wechatConfig.getAccessToken(), WechatAccessTokenResp.class, getAccessTokenParams);
if (ObjectUtils.isNotEmpty(wechatAccessTokenResp) && null == wechatAccessTokenResp.getErrcode()) {
// 获取手机号
String accessToken = wechatAccessTokenResp.getAccess_token();
Map<String, Object> getPhoneNumberParams = new HashMap<>();
getPhoneNumberParams.put("access_token", accessToken);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
Map<String, Object> getPhoneNumberBody = new HashMap<>();
getPhoneNumberBody.put("code", phoneNumberReq.getCode());
HttpEntity<String> entity = new HttpEntity<>(JSONObject.toJSONString(getPhoneNumberBody), headers);
WechatPhoneNumberResp resp = restTemplate.postForObject(wechatConfig.getPhoneNumber(), entity, WechatPhoneNumberResp.class, getPhoneNumberParams);
if (ObjectUtils.isNotEmpty(resp) && 0L == resp.getErrcode()) {
if (null != resp.getPhone_info()) {
return resp.getPhone_info().getPurePhoneNumber();
}
} else {
log.error("调用微信服务获取手机号接口时失败,{}, {}", resp.getErrcode(), resp.getErrmsg());
throw new ServiceException(resp.getErrmsg(), resp.getErrcode());
}
} else {
log.error("调用微信服务获取access_token接口时失败,{}, {}", wechatAccessTokenResp.getErrcode(), wechatAccessTokenResp.getErrmsg());
throw new ServiceException(wechatAccessTokenResp.getErrmsg(), wechatAccessTokenResp.getErrcode());
}
return null;
}
/**
* 获取token
* @param sysUser
* @return
*/
private String getToken(SysUser sysUser) {
LoginUser loginUser = new LoginUser(sysUser.getUserId(), sysUser.getDeptId(), sysUser, permissionService.getMenuPermission(sysUser));
sysLoginService.recordLoginInfo(loginUser.getUserId());
// 生成token
return tokenService.createToken(loginUser);
}
}

149
lzbi-module/src/main/java/com/lzbi/wechat/webSocket/HeatSourceServer.java

@ -1,149 +0,0 @@
package com.lzbi.wechat.webSocket;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.websocket.*;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
/**
* @ClassName HeatSourceServer
* @Description 热源列表服务
* @Author lienbo
* @Date 2024/01/25 16:06
* @Version V1.0
*/
@Component
@Slf4j
@ServerEndpoint("/ws/heatSourceList/{userId}/{deptId}")
public class HeatSourceServer {
/**
* 静态变量用来记录当前在线连接数线程安全的类
*/
private static AtomicInteger onlineSessionClientCount = new AtomicInteger(0);
/**
* 存放所有在线的客户端
*/
private static Map<Long, Session> onlineSessionClientMap = new ConcurrentHashMap<>();
/**
* 存放所有在线的用户和要查询的组织id
*/
private static Map<Long, Long> onlineUserDeptMap = new ConcurrentHashMap<>();
/**
* 连接建立成功调用的方法由前端<code>new WebSocket</code>触发
*
* @param userId 每次页面建立连接时传入到服务端的id比如用户id等可以自定义
* @param deptId 公司ID
* @param session 与某个客户端的连接会话需要通过它来给客户端发送消息
*/
@OnOpen
public void onOpen(@PathParam("userId") Long userId, @PathParam("deptId") Long deptId, Session session) {
log.info("连接建立中 ==> session_id = {},userId = {},deptId = {}", session.getId(), userId, deptId);
onlineUserDeptMap.put(userId, deptId);
onlineSessionClientMap.put(userId, session);
//在线数加1
onlineSessionClientCount.incrementAndGet();
sendToOne(userId, "hello " + userId + " 您已连接成功");
log.info("连接建立成功,当前在线数为:{} ==> 开始监听新连接:session_id = {}, sid = {},。", onlineSessionClientCount, session.getId(), userId);
}
/**
* 连接关闭调用的方法由前端<code>socket.close()</code>触发
*
* @param userId
* @param session
*/
@OnClose
public void onClose(@PathParam("userId") Long userId, Session session) {
// 从 Map中移除
onlineSessionClientMap.remove(userId);
//在线数减1
onlineSessionClientCount.decrementAndGet();
log.info("连接关闭成功,当前在线数为:{} ==> 关闭该连接信息:session_id = {}, userId = {},。", onlineSessionClientCount, session.getId(), userId);
}
/**
* 收到客户端消息后调用的方法由前端<code>socket.send</code>触发
* * 当服务端执行toSession.getAsyncRemote().sendText(xxx)前端的socket.onmessage得到监听
*
* @param message
* @param session
*/
@OnMessage
public void onMessage(String message, Session session) throws IOException {
log.info("服务端收到客户端消息 ==>, message = {}", message);
session.getBasicRemote().sendText(message);
}
/**
* 发生错误调用的方法
*
* @param session
* @param error
*/
@OnError
public void onError(Session session, Throwable error) {
log.error("WebSocket发生错误,错误信息为:" + error.getMessage());
error.printStackTrace();
}
/**
* 功能描述: 发送移除黑名单消息
* @param userId
* @Author: lienbo
* @Date: 2023/8/27 23:19
* @return: void
*/
public void sendRemoveBlackList(Long userId) {
log.info("发送移除黑名单消息 ==>, userId = {}", userId);
this.sendToOne(userId, "remove");
}
/**
* 群发消息
*
* @param message 消息
*/
private void sendToAll(String message) {
// 遍历在线map集合
onlineSessionClientMap.forEach((userId, toSession) -> {
log.info("服务端给客户端群发消息 ==> userId = {}, message = {}", userId, message);
toSession.getAsyncRemote().sendText(message);
});
}
/**
* 指定发送消息
*
* @param userId
* @param message
*/
private void sendToOne(Long userId, String message) {
// 通过sid查询map中是否存在
Session toSession = onlineSessionClientMap.get(userId);
if (toSession == null) {
log.error("服务端给客户端发送消息 ==> userId = {} 不存在, message = {}", userId, message);
return;
}
// 异步发送
log.info("服务端给客户端发送消息 ==> userId = {}, message = {}", userId, message);
toSession.getAsyncRemote().sendText(message);
/*
// 同步发送
try {
toSession.getBasicRemote().sendText(message);
} catch (IOException e) {
log.error("发送消息失败,WebSocket IO异常");
e.printStackTrace();
}*/
}
}

26
lzbi-module/src/main/resources/mapper/SysWechatMapper.xml

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.lzbi.wechat.mapper.SysWechatMapper">
<select id="selectSysWechatById" resultType="com.lzbi.wechat.domain.SysWechat">
select id, phone, app_id from sys_wechat where id = #{id}
</select>
<select id="selectWechatByOpenId" resultType="com.lzbi.wechat.domain.SysWechat">
select id, phone, app_id from sys_wechat where open_id = #{openId}
</select>
<insert id="insertSysWechat" parameterType="com.lzbi.wechat.domain.SysWechat">
insert into sys_wechat (open_id, phone) values (#{openId}, #{phone})
</insert>
<update id="updateSysWechat">
update sys_wechat set open_id = #{openId}, phone = #{phone} where id = #{id}
</update>
<delete id="deleteSysWechat">
delete from sys_wechat where id = #{id}
</delete>
</mapper>

49
lzbi-module/src/main/resources/mapper/asset/DcBusiTargetDraftDaynewMapper.xml

@ -102,55 +102,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND t1.date_month = #{month}
</select>
<select id="selectDayTargetModelValue" parameterType="com.lzbi.wechat.domain.dto.TargetModelValueDTO" resultType="com.lzbi.wechat.domain.vo.TargetResultVO">
SELECT
t1.target_model_code AS "targetCode",
MIN( t1.target_name_alias ) AS "targetName",
MIN( t1.field_unit ) AS "targetUnit",
SUM( t4.value_result ) AS "value"
FROM
dc_base_asset_target t1
INNER JOIN dc_base_asset_info t3
ON t1.asset_code = t3.asset_code
AND t3.org_id = #{deptId}
AND t3.asset_type = "0"
LEFT JOIN dc_busi_target_draft_daynew t4
ON t1.target_code = t4.target_code
AND t4.date_year = #{year}
AND t4.date_month = #{month}
AND t4.date_day = #{day}
WHERE
t1.target_model_code IN
<foreach item="targetModelCode" collection="targetModelCodeList" open="(" separator="," close=")">
#{targetModelCode}
</foreach>
GROUP BY
t1.target_model_code
</select>
<select id="selectTotalTargetModelValue" parameterType="com.lzbi.wechat.domain.dto.TargetModelValueDTO" resultType="com.lzbi.wechat.domain.vo.TargetResultVO">
SELECT
t1.target_model_code AS "targetCode",
MIN( t1.target_name_alias ) AS "targetName",
MIN( t1.field_unit ) AS "targetUnit",
SUM( t4.value_result ) AS "value"
FROM
dc_base_asset_target t1
INNER JOIN dc_base_asset_info t3
ON t1.asset_code = t3.asset_code
AND t3.org_id = #{deptId}
AND t3.asset_type = "0"
LEFT JOIN dc_busi_target_draft_daynew t4
ON t1.target_code = t4.target_code
WHERE
t1.target_model_code IN
<foreach item="targetModelCode" collection="targetModelCodeList" open="(" separator="," close=")">
#{targetModelCode}
</foreach>
GROUP BY
t1.target_model_code
</select>
<insert id="insertDcBusiTargetDraftDaynew" parameterType="DcBusiTargetDraftDaynew" useGeneratedKeys="true" keyProperty="id">
insert into dc_busi_target_draft_daynew
<trim prefix="(" suffix=")" suffixOverrides=",">

47
lzbi-module/src/main/resources/mapper/asset/DcBusiTargetDraftMonthMapper.xml

@ -62,27 +62,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
</select>
<select id="selectTotalTargetModelPlanValue" parameterType="com.lzbi.wechat.domain.dto.TargetModelValueDTO" resultType="com.lzbi.wechat.domain.vo.TargetPlanVO">
SELECT
t1.target_model_code AS "targetCode",
SUM( t4.val_plan ) AS "value"
FROM
dc_base_asset_target t1
INNER JOIN
dc_base_asset_info t3 ON t1.asset_code = t3.asset_code
AND t3.org_id = #{deptId}
AND t3.asset_type = "0"
LEFT JOIN
dc_busi_target_draft_month t4 ON t1.target_code = t4.target_code
WHERE
t1.target_model_code IN
<foreach item="targetModelCode" collection="targetModelCodeList" open="(" separator="," close=")">
#{targetModelCode}
</foreach>
GROUP BY
t1.target_model_code
</select>
<select id="selectDcBusiTargetDraftMontAggregateList" parameterType="com.lzbi.draft.domain.vo.TargetDraftDaynewReqVo" resultType="com.lzbi.draft.domain.vo.TargetDraftMonthAggregateResVo">
select
d.org_name,
@ -125,6 +104,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
m.target_unit
</select>
<select id="selectDcBusiTargetDraftMonthListByInputBill" parameterType="com.lzbi.bill.domain.DcBusiTargetInputMaster" resultMap="DcBusiTargetDraftMonthResult">
SELECT
t1.*
FROM
dc_busi_target_draft_month t1
WHERE
t1.count_year = #{year}
AND t1.count_month = #{month}
AND t1.target_code IN (
SELECT
t2.target_code
FROM
dc_busi_target_input_sub t2
WHERE
t2.bill_no_master = #{billSerial})
</select>
<insert id="insertDcBusiTargetDraftMonth" parameterType="DcBusiTargetDraftMonth" useGeneratedKeys="true" keyProperty="id">
insert into dc_busi_target_draft_month
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -139,6 +135,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="targetNameAlias != null">target_name_alias,</if>
<if test="targetName != null">target_name,</if>
<if test="targetCode != null">target_code,</if>
<if test="targetModelCode != null">target_model_code,</if>
<if test="targetUint != null">target_uint,</if>
<if test="countDate != null">count_date,</if>
<if test="countYear != null">count_year,</if>
@ -168,6 +165,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="targetNameAlias != null">#{targetNameAlias},</if>
<if test="targetName != null">#{targetName},</if>
<if test="targetCode != null">#{targetCode},</if>
<if test="targetModelCode != null">#{targetModelCode},</if>
<if test="targetUint != null">#{targetUint},</if>
<if test="countDate != null">#{countDate},</if>
<if test="countYear != null">#{countYear},</if>
@ -190,12 +188,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="batchInsertDcBusiTargetDraftMonth">
insert into dc_busi_target_draft_month
(company_id, company_name, org_id, org_name, asset_code, asset_name,
target_code, taget_name, target_name_alias, target_uint, count_year,
target_model_code, target_code, target_name, target_name_alias, target_uint, count_year,
count_month, count_date, val_result, field_code, field_name)
values
<foreach collection="list" item="item" separator=",">
<foreach collection="dcBusiTargetDraftMonths" item="item" separator=",">
(#{item.companyId}, #{item.companyName}, #{item.orgId}, #{item.orgName}, #{item.assetCode}, #{item.assetName},
#{item.targetCode}, #{item.tagetName}, #{item.targetNameAlias}, #{iteam.targetUint}, #{item.countYear},
#{item.targetModelCode}, #{item.targetCode}, #{item.targetName}, #{item.targetNameAlias}, #{item.targetUint}, #{item.countYear},
#{item.countMonth}, #{item.countDate}, #{item.valResult}, #{item.fieldCode}, #{item.fieldName})
</foreach>
</insert>
@ -213,6 +211,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="fieldName != null">field_name = #{fieldName},</if>
<if test="targetNameAlias != null">target_name_alias = #{targetNameAlias},</if>
<if test="targetName != null">target_name = #{targetName},</if>
<if test="targetModelCode != null">target_model_code = #{targetModelCode},</if>
<if test="targetCode != null">target_code = #{targetCode},</if>
<if test="targetUint != null">target_uint = #{targetUint},</if>
<if test="countDate != null">count_date = #{countDate},</if>

25
lzbi-module/src/main/resources/mapper/asset/DcBusiWorkReadConfigMapper.xml

@ -66,31 +66,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by company_name,organize_name,asset_field_name,asset_field_name
</select>
<select id="selectDcBusiWorkReadConfigByAssetTarget" resultType="com.lzbi.wechat.domain.dto.ParamsContrastDTO">
select
t2.target_model_code,
t1.goal_param_code
from
dc_busi_work_read_config t1
INNER JOIN
dc_base_asset_target t2
ON
t1.asset_param_code = t2.target_code
INNER JOIN
dc_base_asset_info t3
ON
t2.asset_code = t3.asset_code
where
t2.target_model_code in
<foreach item="targetModelCode" collection="targetModelCodeList" open="(" separator="," close=")">
#{targetModelCode}
</foreach>
and t2.column_type = "P"
and t3.org_id = #{dcBaseAssetInfo.orgId}
and t3.asset_level = #{dcBaseAssetInfo.assetLevel}
and t3.asset_type = #{dcBaseAssetInfo.assetType}
</select>
<select id="selectDcBusiWorkReadConfigById" parameterType="Long" resultMap="DcBusiWorkReadConfigResult">
<include refid="selectDcBusiWorkReadConfigVo"/>
where id = #{id}

Loading…
Cancel
Save