From 7a1f5a4c36cf3cb28c2573ae57bea20f40228149 Mon Sep 17 00:00:00 2001 From: bobol Date: Wed, 7 Feb 2024 16:37:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E6=8A=A5=E5=AF=BC=E5=85=A5=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lzbi-module/pom.xml | 7 +- .../mapper/DcBusiWorkReadConfigMapper.java | 3 - .../DcBusiTargetInputMasterController.java | 6 +- .../bill/domain/CellDataReadFormulaData.java | 18 + .../listener/CellDataReadFormulaListener.java | 113 +++++ .../DcBusiTargetInputMasterService.java | 468 +++++++++++------- .../domain/vo/ProductionDailySheetVO.java | 3 +- .../mapper/DcBusiTargetDraftDaynewMapper.java | 16 - .../mapper/DcBusiTargetDraftMonthMapper.java | 17 +- .../lzbi/wechat/controller/BizController.java | 97 ---- .../wechat/controller/LoginController.java | 33 -- .../wechat/controller/WechatController.java | 54 -- .../com/lzbi/wechat/domain/SysWechat.java | 30 -- .../wechat/domain/dto/ParamsContrastDTO.java | 31 -- .../domain/dto/TargetModelValueDTO.java | 37 -- .../lzbi/wechat/domain/req/CodeLoginReq.java | 18 - .../domain/req/PhoneNumberLoginReq.java | 19 - .../wechat/domain/req/PhoneNumberReq.java | 18 - .../domain/resp/WechatAccessTokenResp.java | 14 - .../wechat/domain/resp/WechatBaseResp.java | 19 - .../domain/resp/WechatCodeLoginResp.java | 23 - .../domain/resp/WechatPhoneNumberResp.java | 28 -- .../lzbi/wechat/domain/vo/ChildDeptVO.java | 28 -- .../lzbi/wechat/domain/vo/CodeLoginVO.java | 14 - .../com/lzbi/wechat/domain/vo/DeptVO.java | 19 - .../wechat/domain/vo/FinishingRateVO.java | 22 - .../lzbi/wechat/domain/vo/TargetPlanVO.java | 25 - .../lzbi/wechat/domain/vo/TargetResultVO.java | 36 -- .../com/lzbi/wechat/domain/vo/TargetVO.java | 16 - .../lzbi/wechat/mapper/SysWechatMapper.java | 45 -- .../com/lzbi/wechat/service/DeptService.java | 139 ------ .../com/lzbi/wechat/service/LoginService.java | 181 ------- .../lzbi/wechat/service/SysWechatService.java | 62 --- .../lzbi/wechat/service/TargetService.java | 245 --------- .../lzbi/wechat/service/WechatService.java | 161 ------ .../wechat/webSocket/HeatSourceServer.java | 149 ------ .../main/resources/mapper/SysWechatMapper.xml | 26 - .../asset/DcBusiTargetDraftDaynewMapper.xml | 49 -- .../asset/DcBusiTargetDraftMonthMapper.xml | 47 +- .../asset/DcBusiWorkReadConfigMapper.xml | 25 - 40 files changed, 456 insertions(+), 1905 deletions(-) create mode 100644 lzbi-module/src/main/java/com/lzbi/bill/domain/CellDataReadFormulaData.java create mode 100644 lzbi-module/src/main/java/com/lzbi/bill/listener/CellDataReadFormulaListener.java delete mode 100644 lzbi-module/src/main/java/com/lzbi/wechat/controller/BizController.java delete mode 100644 lzbi-module/src/main/java/com/lzbi/wechat/controller/LoginController.java delete mode 100644 lzbi-module/src/main/java/com/lzbi/wechat/controller/WechatController.java delete mode 100644 lzbi-module/src/main/java/com/lzbi/wechat/domain/SysWechat.java delete mode 100644 lzbi-module/src/main/java/com/lzbi/wechat/domain/dto/ParamsContrastDTO.java delete mode 100644 lzbi-module/src/main/java/com/lzbi/wechat/domain/dto/TargetModelValueDTO.java delete mode 100644 lzbi-module/src/main/java/com/lzbi/wechat/domain/req/CodeLoginReq.java delete mode 100644 lzbi-module/src/main/java/com/lzbi/wechat/domain/req/PhoneNumberLoginReq.java delete mode 100644 lzbi-module/src/main/java/com/lzbi/wechat/domain/req/PhoneNumberReq.java delete mode 100644 lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatAccessTokenResp.java delete mode 100644 lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatBaseResp.java delete mode 100644 lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatCodeLoginResp.java delete mode 100644 lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatPhoneNumberResp.java delete mode 100644 lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/ChildDeptVO.java delete mode 100644 lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/CodeLoginVO.java delete mode 100644 lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/DeptVO.java delete mode 100644 lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/FinishingRateVO.java delete mode 100644 lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/TargetPlanVO.java delete mode 100644 lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/TargetResultVO.java delete mode 100644 lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/TargetVO.java delete mode 100644 lzbi-module/src/main/java/com/lzbi/wechat/mapper/SysWechatMapper.java delete mode 100644 lzbi-module/src/main/java/com/lzbi/wechat/service/DeptService.java delete mode 100644 lzbi-module/src/main/java/com/lzbi/wechat/service/LoginService.java delete mode 100644 lzbi-module/src/main/java/com/lzbi/wechat/service/SysWechatService.java delete mode 100644 lzbi-module/src/main/java/com/lzbi/wechat/service/TargetService.java delete mode 100644 lzbi-module/src/main/java/com/lzbi/wechat/service/WechatService.java delete mode 100644 lzbi-module/src/main/java/com/lzbi/wechat/webSocket/HeatSourceServer.java delete mode 100644 lzbi-module/src/main/resources/mapper/SysWechatMapper.xml diff --git a/lzbi-module/pom.xml b/lzbi-module/pom.xml index 07151be..38346d4 100644 --- a/lzbi-module/pom.xml +++ b/lzbi-module/pom.xml @@ -55,13 +55,16 @@ easyexcel-core 3.3.2 + + com.alibaba + fastjson + 1.2.54 + - - \ No newline at end of file diff --git a/lzbi-module/src/main/java/com/lzbi/asset/mapper/DcBusiWorkReadConfigMapper.java b/lzbi-module/src/main/java/com/lzbi/asset/mapper/DcBusiWorkReadConfigMapper.java index 013c127..8137458 100644 --- a/lzbi-module/src/main/java/com/lzbi/asset/mapper/DcBusiWorkReadConfigMapper.java +++ b/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 selectDcBusiWorkReadConfigList(DcBusiWorkReadConfig dcBusiWorkReadConfig); public List selectDcBusiWorkReadConfigMainList(AssetQueryParams assetQueryParams); - List selectDcBusiWorkReadConfigByAssetTarget(@Param("targetModelCodeList") List targetModelCodeList, @Param("dcBaseAssetInfo") DcBaseAssetInfo dcBaseAssetInfo); - /** * 新增互联参数读取数据对照 * diff --git a/lzbi-module/src/main/java/com/lzbi/bill/controller/DcBusiTargetInputMasterController.java b/lzbi-module/src/main/java/com/lzbi/bill/controller/DcBusiTargetInputMasterController.java index 933c43c..9f602d4 100644 --- a/lzbi-module/src/main/java/com/lzbi/bill/controller/DcBusiTargetInputMasterController.java +++ b/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)); } diff --git a/lzbi-module/src/main/java/com/lzbi/bill/domain/CellDataReadFormulaData.java b/lzbi-module/src/main/java/com/lzbi/bill/domain/CellDataReadFormulaData.java new file mode 100644 index 0000000..ef8f723 --- /dev/null +++ b/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; +} \ No newline at end of file diff --git a/lzbi-module/src/main/java/com/lzbi/bill/listener/CellDataReadFormulaListener.java b/lzbi-module/src/main/java/com/lzbi/bill/listener/CellDataReadFormulaListener.java new file mode 100644 index 0000000..313c348 --- /dev/null +++ b/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> { + + /** + * excel所有的sheet-row-cell数据 + */ + private List list; + + /** + * 每个sheet页的所有行 + */ + private List> rows; + + /** + * sheet页的号 + */ + private Integer sheetNo; + + /** + * 行的长度 + */ + private Integer rowLength; + + public CellDataReadFormulaListener () { + this.list = new ArrayList<>(); + } + + public List getList() { + return list; + } + + @Override + public void onException(Exception exception, AnalysisContext context) throws Exception { + ReadListener.super.onException(exception, context); + } + + @Override + public void invokeHead(Map> headMap, AnalysisContext context) { + ReadListener.super.invokeHead(headMap, context); + } + + @Override + public void invoke(Map data, AnalysisContext context) { + if (null != data) { + List 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); + } +} \ No newline at end of file diff --git a/lzbi-module/src/main/java/com/lzbi/bill/service/DcBusiTargetInputMasterService.java b/lzbi-module/src/main/java/com/lzbi/bill/service/DcBusiTargetInputMasterService.java index e57f88b..d24a110 100644 --- a/lzbi-module/src/main/java/com/lzbi/bill/service/DcBusiTargetInputMasterService.java +++ b/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 list = new ArrayList<>(); InputStream inputStream = null; try { @@ -194,7 +199,7 @@ public class DcBusiTargetInputMasterService extends ServiceImpl 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 result = new ArrayList<>(); List list = confirmReq.getList(); @@ -246,11 +274,19 @@ public class DcBusiTargetInputMasterService extends ServiceImpl dayMap = new HashMap<>(); boolean sign = false; + int marking = -1; for (int i = 0, leni = data.size(); i < leni; i++) { List row = data.get(i); - if ("日期".equals(row.get(0))) { - int lenj = row.size(); - for (int j = 1; j < lenj; j++) { + int lenj = row.size(); + 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 { - 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,198 +402,247 @@ public class DcBusiTargetInputMasterService extends ServiceImpl dcBusiTargetDraftDaynews = dcBusiTargetDraftDaynewMapper.selectDcBusiTargetDraftDaynewByTargetInput(master); - if (!CollectionUtils.isEmpty(dcBusiTargetDraftDaynews)) { - DcBusiTargetDraftDaynew dcBusiTargetDraftDaynew = dcBusiTargetDraftDaynews.get(0); - String format = "%s(sheet页)中,%s(指标)%s年%s月%s日,已存在"; - String msg = String.format(format, dcBusiTargetDraftDaynew.getAssetNameAlias(), dcBusiTargetDraftDaynew.getTagetName(), dcBusiTargetDraftDaynew.getDateYear(), dcBusiTargetDraftDaynew.getDateMonth(), dcBusiTargetDraftDaynew.getDateDay()); - log.error(msg); - throw new RuntimeException(msg); - } + public int checkPass(String billNo) throws InterruptedException { + int r = 0; + if (lock.tryLock()) { + try { + DcBusiTargetInputMaster master = baseMapper.selectDcBusiTargetInputMasterByBillSerial(billNo); + if (ObjectUtils.isEmpty(master)) { + throw new RuntimeException("单据不存在"); + } + if ("2".equals(master.getCheckStatus())) { + throw new RuntimeException("审核失败,单据已审核"); + } - DcBusiTargetInputSub subParams = new DcBusiTargetInputSub(); - subParams.setBillNoMaster(billNo); - List dcBusiTargetInputSubList = dcBusiTargetInputSubMapper.selectDcBusiTargetInputSubList(subParams); - List newList = new ArrayList<>(); - if (!CollectionUtils.isEmpty(dcBusiTargetInputSubList)) { - String year = master.getYear(); - String month = master.getMonth(); - List targetCodeList = dcBusiTargetInputSubList.stream().map(DcBusiTargetInputSub::getTargetCode).collect(Collectors.toList()); - List dcBaseAssetTargets = dcBaseAssetTargetMapper.selectDcBaseAssetTargetByTargetCodeList(targetCodeList); - Map> targetModelMap = dcBaseAssetTargets.stream().collect(Collectors.groupingBy(DcBaseAssetTarget::getTargetCode)); - Map targetModelCodeMap = dcBaseAssetTargets.stream().collect(Collectors.toMap(DcBaseAssetTarget::getTargetCode, DcBaseAssetTarget::getTargetModelCode)); - for (DcBusiTargetInputSub dcBusiTargetInputSub : dcBusiTargetInputSubList) { - String day = dcBusiTargetInputSub.getDay(); - DcBusiTargetDraftDaynew dcBusiTargetDraftDaynew = new DcBusiTargetDraftDaynew(); - dcBusiTargetDraftDaynew.setCompanyId(dcBusiTargetInputSub.getCompanyId()); - dcBusiTargetDraftDaynew.setOrganizeId(dcBusiTargetInputSub.getOragnizeId()); - dcBusiTargetDraftDaynew.setAssetCode(dcBusiTargetInputSub.getAssetCode()); - dcBusiTargetDraftDaynew.setFieldCode(dcBusiTargetInputSub.getFieldCode()); - dcBusiTargetDraftDaynew.setTargetCode(dcBusiTargetInputSub.getTargetCode()); - dcBusiTargetDraftDaynew.setDateYear(year); - dcBusiTargetDraftDaynew.setDateMonth(month); - dcBusiTargetDraftDaynew.setDateDay(StringUtils.leftPad(day, 2, "0")); - dcBusiTargetDraftDaynew.setCompanyName(dcBusiTargetInputSub.getCompanyName()); - dcBusiTargetDraftDaynew.setOrganizeName(dcBusiTargetInputSub.getOrganizeName()); - dcBusiTargetDraftDaynew.setAssetName(dcBusiTargetInputSub.getAssetName()); - dcBusiTargetDraftDaynew.setFieldName(dcBusiTargetInputSub.getFieldName()); - dcBusiTargetDraftDaynew.setTagetName(dcBusiTargetInputSub.getTargetName()); - dcBusiTargetDraftDaynew.setValueResult(dcBusiTargetInputSub.getValResult()); - dcBusiTargetDraftDaynew.setTargetModelCode(targetModelCodeMap.get(dcBusiTargetInputSub.getTargetCode())); - newList.add(dcBusiTargetDraftDaynew); + List dcBusiTargetDraftDaynews = dcBusiTargetDraftDaynewMapper.selectDcBusiTargetDraftDaynewByTargetInput(master); + if (!CollectionUtils.isEmpty(dcBusiTargetDraftDaynews)) { + DcBusiTargetDraftDaynew dcBusiTargetDraftDaynew = dcBusiTargetDraftDaynews.get(0); + String format = "%s(sheet页)中,%s(指标)%s年%s月%s日,已存在"; + String msg = String.format(format, dcBusiTargetDraftDaynew.getAssetNameAlias(), dcBusiTargetDraftDaynew.getTagetName(), dcBusiTargetDraftDaynew.getDateYear(), dcBusiTargetDraftDaynew.getDateMonth(), dcBusiTargetDraftDaynew.getDateDay()); + log.error(msg); + throw new RuntimeException(msg); } - dcBusiTargetDraftDaynewMapper.batchInsertDcBusiTargetDraftDaynew(newList); - Map> 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 dcBusiTargetDraftMonthList = dcBusiTargetDraftMonthMapper.selectDcBusiTargetDraftMonthList(dcBusiTargetDraftMonth); + + DcBusiTargetInputSub subParams = new DcBusiTargetInputSub(); + subParams.setBillNoMaster(billNo); + List dcBusiTargetInputSubList = dcBusiTargetInputSubMapper.selectDcBusiTargetInputSubList(subParams); + + List draftDayList = new ArrayList<>(); + if (!CollectionUtils.isEmpty(dcBusiTargetInputSubList)) { + String year = master.getYear(); + String month = master.getMonth(); + List targetCodeList = dcBusiTargetInputSubList.stream().map(DcBusiTargetInputSub::getTargetCode).collect(Collectors.toList()); + List dcBaseAssetTargets = dcBaseAssetTargetMapper.selectDcBaseAssetTargetByTargetCodeList(targetCodeList); + Map targetModelMap = dcBaseAssetTargets.stream().collect(Collectors.toMap(DcBaseAssetTarget::getTargetCode, e -> e)); + Map targetModelCodeMap = dcBaseAssetTargets.stream().collect(Collectors.toMap(DcBaseAssetTarget::getTargetCode, DcBaseAssetTarget::getTargetModelCode)); + for (DcBusiTargetInputSub dcBusiTargetInputSub : dcBusiTargetInputSubList) { + String day = dcBusiTargetInputSub.getDay(); + DcBusiTargetDraftDaynew dcBusiTargetDraftDaynew = new DcBusiTargetDraftDaynew(); + dcBusiTargetDraftDaynew.setCompanyId(dcBusiTargetInputSub.getCompanyId()); + dcBusiTargetDraftDaynew.setOrganizeId(dcBusiTargetInputSub.getOragnizeId()); + dcBusiTargetDraftDaynew.setAssetCode(dcBusiTargetInputSub.getAssetCode()); + dcBusiTargetDraftDaynew.setFieldCode(dcBusiTargetInputSub.getFieldCode()); + dcBusiTargetDraftDaynew.setTargetCode(dcBusiTargetInputSub.getTargetCode()); + dcBusiTargetDraftDaynew.setDateYear(year); + dcBusiTargetDraftDaynew.setDateMonth(month); + dcBusiTargetDraftDaynew.setDateDay(StringUtils.leftPad(day, 2, "0")); + dcBusiTargetDraftDaynew.setCompanyName(dcBusiTargetInputSub.getCompanyName()); + dcBusiTargetDraftDaynew.setOrganizeName(dcBusiTargetInputSub.getOrganizeName()); + dcBusiTargetDraftDaynew.setAssetName(dcBusiTargetInputSub.getAssetName()); + dcBusiTargetDraftDaynew.setFieldName(dcBusiTargetInputSub.getFieldName()); + dcBusiTargetDraftDaynew.setTagetName(dcBusiTargetInputSub.getTargetName()); + dcBusiTargetDraftDaynew.setValueResult(dcBusiTargetInputSub.getValResult()); + dcBusiTargetDraftDaynew.setTargetModelCode(targetModelCodeMap.get(dcBusiTargetInputSub.getTargetCode())); + draftDayList.add(dcBusiTargetDraftDaynew); + } + dcBusiTargetDraftDaynewMapper.batchInsertDcBusiTargetDraftDaynew(draftDayList); + + List draftMonthList = new ArrayList<>(); + Map> billTargetMap = dcBusiTargetInputSubList.stream().collect(Collectors.groupingBy(DcBusiTargetInputSub::getTargetCode)); + List dcBusiTargetDraftMonthList = dcBusiTargetDraftMonthMapper.selectDcBusiTargetDraftMonthListByInputBill(master); 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 dcBaseAssetTargets1 = targetModelMap.get(dcBusiTargetInputSub.getTargetCode()); - DcBaseAssetTarget dcBaseAssetTarget = dcBaseAssetTargets1.get(0); - if (org.apache.commons.lang3.ObjectUtils.isNotEmpty(dcBaseAssetTarget)) { - dcBusiTargetDraftMonth.setTargetModelCode(dcBaseAssetTarget.getTargetModelCode()); - dcBusiTargetDraftMonth.setTargetUint(dcBaseAssetTarget.getFieldUnit()); - dcBusiTargetDraftMonth.setTargetNameAlias(dcBaseAssetTarget.getTargetNameAlias()); - } - dcBusiTargetDraftMonth.setCountDate(year + "-" + month); - List 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); + billTargetMap.forEach((targetCode, subList) -> { + DcBusiTargetInputSub subObj = subList.get(0); + DcBusiTargetDraftMonth 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 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 { - dcBusiTargetDraftMonth = dcBusiTargetDraftMonthList.get(0); - List resultList = subList.stream().map(DcBusiTargetInputSub::getValResult).collect(Collectors.toList()); - BigDecimal result = new BigDecimal(0); - for (BigDecimal v : resultList) { - result = result.add(v); - } - BigDecimal valResult = dcBusiTargetDraftMonth.getValResult(); - if (null == valResult) { - valResult = result; - } else { - valResult = valResult.add(result); - } - dcBusiTargetDraftMonth.setValResult(valResult); - dcBusiTargetDraftMonthMapper.updateDcBusiTargetDraftMonth(dcBusiTargetDraftMonth); + Map 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 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); + } else { + List resultList = subList.stream().map(DcBusiTargetInputSub::getValResult).collect(Collectors.toList()); + BigDecimal result = new BigDecimal(0); + for (BigDecimal v : resultList) { + result = result.add(v); + } + BigDecimal valResult = dcBusiTargetDraftMonth.getValResult(); + if (null == valResult) { + valResult = result; + } else { + valResult = valResult.add(result); + } + dcBusiTargetDraftMonth.setValResult(valResult); + } + draftMonthList.add(dcBusiTargetDraftMonth); + }); + this.deleteDcBusiTargetDraftMonth(dcBusiTargetDraftMonthList); } - }); + dcBusiTargetDraftMonthMapper.batchInsertDcBusiTargetDraftMonth(draftMonthList); + } + // 修改审核状态为已处理 + master.setCheckStatus("2"); + master.setUpdatedBy(SecurityUtils.getUsername()); + master.setCreatedTime(DateUtils.getNowDate()); + r = baseMapper.updateDcBusiTargetInputMaster(master); + } catch (RuntimeException e) { + log.error("处理异常", e); + throw e; + } finally { + lock.unlock(); } - // 修改审核状态为已处理 - master.setCheckStatus("2"); - master.setUpdatedBy(SecurityUtils.getUsername()); - master.setCreatedTime(DateUtils.getNowDate()); - return baseMapper.updateDcBusiTargetInputMaster(master); - } catch (RuntimeException e) { - log.error("处理异常", e); - throw e; - } finally { - lock.unlock(); } + return r; } @Transactional(rollbackFor = Exception.class) public int checkRevert(String billNo) { - lock.lock(); - try { - DcBusiTargetInputMaster master = baseMapper.selectDcBusiTargetInputMasterByBillSerial(billNo); - if ("0".equals(master.getCheckStatus())) { - throw new RuntimeException("反审核失败,单据未提交"); - } - if ("1".equals(master.getCheckStatus())) { - throw new RuntimeException("反审核失败,单据未审核通过"); - } - List dateNewList = dcBusiTargetDraftDaynewMapper.selectDcBusiTargetDraftDaynewByTargetInput(master); - if (!CollectionUtils.isEmpty(dateNewList)) { - List idList = dateNewList.stream().map(dcBusiTargetDraftDaynew -> String.valueOf(dcBusiTargetDraftDaynew.getId())).collect(Collectors.toList()); - String[] ids = idList.toArray(new String[]{}); - int len = ids.length; - int range = 1000; - int remainder = len % range; - int count = len / range; - String[] idsNew; - for (int i = 0; i < count; i++) { - idsNew = Arrays.copyOfRange(ids, i * range, (i + 1) * range); - dcBusiTargetDraftDaynewMapper.deleteDcBusiTargetDraftDaynewByIds(idsNew); + int r = 0; + if (lock.tryLock()) { + try { + DcBusiTargetInputMaster master = baseMapper.selectDcBusiTargetInputMasterByBillSerial(billNo); + if ("0".equals(master.getCheckStatus())) { + throw new RuntimeException("反审核失败,单据未提交"); } - if (remainder > 0) { - idsNew = Arrays.copyOfRange(ids, count * range, len); - dcBusiTargetDraftDaynewMapper.deleteDcBusiTargetDraftDaynewByIds(idsNew); + if ("1".equals(master.getCheckStatus())) { + throw new RuntimeException("反审核失败,单据未审核通过"); } - } - DcBusiTargetInputSub subParams = new DcBusiTargetInputSub(); - subParams.setBillNoMaster(billNo); - List dcBusiTargetInputSubList = dcBusiTargetInputSubMapper.selectDcBusiTargetInputSubList(subParams); - if (!CollectionUtils.isEmpty(dcBusiTargetInputSubList)) { - String year = master.getYear(); - String month = master.getMonth(); - Map> 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 dcBusiTargetDraftMonthList = dcBusiTargetDraftMonthMapper.selectDcBusiTargetDraftMonthList(dcBusiTargetDraftMonth); + List dateNewList = dcBusiTargetDraftDaynewMapper.selectDcBusiTargetDraftDaynewByTargetInput(master); + if (!CollectionUtils.isEmpty(dateNewList)) { + List idList = dateNewList.stream().map(dcBusiTargetDraftDaynew -> String.valueOf(dcBusiTargetDraftDaynew.getId())).collect(Collectors.toList()); + String[] ids = idList.toArray(new String[]{}); + int len = ids.length; + int range = 1000; + int remainder = len % range; + int count = len / range; + String[] idsNew; + for (int i = 0; i < count; i++) { + idsNew = Arrays.copyOfRange(ids, i * range, (i + 1) * range); + dcBusiTargetDraftDaynewMapper.deleteDcBusiTargetDraftDaynewByIds(idsNew); + } + if (remainder > 0) { + idsNew = Arrays.copyOfRange(ids, count * range, len); + dcBusiTargetDraftDaynewMapper.deleteDcBusiTargetDraftDaynewByIds(idsNew); + } + } + DcBusiTargetInputSub subParams = new DcBusiTargetInputSub(); + subParams.setBillNoMaster(billNo); + List dcBusiTargetInputSubList = dcBusiTargetInputSubMapper.selectDcBusiTargetInputSubList(subParams); + if (!CollectionUtils.isEmpty(dcBusiTargetInputSubList)) { + List dcBusiTargetDraftMonthList = dcBusiTargetDraftMonthMapper.selectDcBusiTargetDraftMonthListByInputBill(master); if (!CollectionUtils.isEmpty(dcBusiTargetDraftMonthList)) { - dcBusiTargetDraftMonth = dcBusiTargetDraftMonthList.get(0); - List resultList = subList.stream().map(DcBusiTargetInputSub::getValResult).collect(Collectors.toList()); - BigDecimal valResult = dcBusiTargetDraftMonth.getValResult(); - BigDecimal result = new BigDecimal(0); - for (BigDecimal v : resultList) { - result = result.add(v); - } - if (null == valResult) { - valResult = new BigDecimal(0); - } else { - valResult = valResult.subtract(result); - } - dcBusiTargetDraftMonth.setValResult(valResult); - dcBusiTargetDraftMonthMapper.updateDcBusiTargetDraftMonth(dcBusiTargetDraftMonth); + List draftMonthList = new ArrayList<>(); + Map> billTargetMap = dcBusiTargetInputSubList.stream().collect(Collectors.groupingBy(DcBusiTargetInputSub::getTargetCode)); + Map draftMonthMap = dcBusiTargetDraftMonthList.stream().collect(Collectors.toMap(DcBusiTargetDraftMonth::getTargetCode, e -> e)); + draftMonthMap.forEach((targetCode, dcBusiTargetDraftMonth) -> { + if (billTargetMap.containsKey(targetCode)) { + List subList = billTargetMap.get(targetCode); + List resultList = subList.stream().map(DcBusiTargetInputSub::getValResult).collect(Collectors.toList()); + BigDecimal result = dcBusiTargetDraftMonth.getValResult(); + for (BigDecimal v : resultList) { + result = result.subtract(v); + } + dcBusiTargetDraftMonth.setValResult(result); + draftMonthList.add(dcBusiTargetDraftMonth); + } + }); + this.deleteDcBusiTargetDraftMonth(draftMonthList); + dcBusiTargetDraftMonthMapper.batchInsertDcBusiTargetDraftMonth(draftMonthList); } - }); + } + // 修改审核状态为已处理 + master.setCheckStatus("1"); + master.setUpdatedBy(SecurityUtils.getUsername()); + master.setCreatedTime(DateUtils.getNowDate()); + r = baseMapper.updateDcBusiTargetInputMaster(master); + } catch (RuntimeException e) { + log.error("处理异常", e); + throw e; + } finally { + lock.unlock(); } - // 修改审核状态为已处理 - master.setCheckStatus("1"); - master.setUpdatedBy(SecurityUtils.getUsername()); - master.setCreatedTime(DateUtils.getNowDate()); - return baseMapper.updateDcBusiTargetInputMaster(master); - } catch (RuntimeException e) { - log.error("处理异常", e); - throw e; - } finally { - lock.unlock(); } + return r; } + private void deleteDcBusiTargetDraftMonth (List dcBusiTargetDraftMonthList) { + Set 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); + } + } } diff --git a/lzbi-module/src/main/java/com/lzbi/draft/domain/vo/ProductionDailySheetVO.java b/lzbi-module/src/main/java/com/lzbi/draft/domain/vo/ProductionDailySheetVO.java index 1ca4780..3817c4d 100644 --- a/lzbi-module/src/main/java/com/lzbi/draft/domain/vo/ProductionDailySheetVO.java +++ b/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> data; + private JSONArray data; } diff --git a/lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiTargetDraftDaynewMapper.java b/lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiTargetDraftDaynewMapper.java index 595a27d..aaa9679 100644 --- a/lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiTargetDraftDaynewMapper.java +++ b/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 selectDcBusiTargetDraftDaynewList(DcBusiTargetDraftDaynew dcBusiTargetDraftDaynew); - /** - * 查询日指标数据 - * @param targetModelValueDTO - * @return - */ - List selectDayTargetModelValue(TargetModelValueDTO targetModelValueDTO); - - /** - * 查询累计指标数据 - * @param targetModelValueDTO - * @return - */ - List selectTotalTargetModelValue(TargetModelValueDTO targetModelValueDTO); - /** * 新增指标数据底稿日-新结构 * diff --git a/lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiTargetDraftMonthMapper.java b/lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiTargetDraftMonthMapper.java index 0d90929..4550c80 100644 --- a/lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiTargetDraftMonthMapper.java +++ b/lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiTargetDraftMonthMapper.java @@ -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 selectDcBusiTargetDraftMonthList(DcBusiTargetDraftMonth dcBusiTargetDraftMonth); /** - * 查询月指标总计划值 - * @param targetModelValueDTO + * 查询月指标累计值 + * @param targetDraftDaynewReqVo * @return */ - List selectTotalTargetModelPlanValue(TargetModelValueDTO targetModelValueDTO); + List selectDcBusiTargetDraftMontAggregateList(TargetDraftDaynewReqVo targetDraftDaynewReqVo); /** - * 查询月指标累计值 - * @param targetDraftDaynewReqVo + * 根据录入单查询 + * @param dcBusiTargetInputMaster * @return */ - List selectDcBusiTargetDraftMontAggregateList(TargetDraftDaynewReqVo targetDraftDaynewReqVo); + List selectDcBusiTargetDraftMonthListByInputBill(DcBusiTargetInputMaster dcBusiTargetInputMaster); /** * 新增指标数据底稿(日) @@ -62,7 +61,7 @@ public interface DcBusiTargetDraftMonthMapper extends BaseMapper dcBusiTargetDraftMonths); + int batchInsertDcBusiTargetDraftMonth(@Param("dcBusiTargetDraftMonths") List dcBusiTargetDraftMonths); /** * 修改指标数据底稿(日) diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/controller/BizController.java b/lzbi-module/src/main/java/com/lzbi/wechat/controller/BizController.java deleted file mode 100644 index 609c3b3..0000000 --- a/lzbi-module/src/main/java/com/lzbi/wechat/controller/BizController.java +++ /dev/null @@ -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)); - } - -} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/controller/LoginController.java b/lzbi-module/src/main/java/com/lzbi/wechat/controller/LoginController.java deleted file mode 100644 index 2656aed..0000000 --- a/lzbi-module/src/main/java/com/lzbi/wechat/controller/LoginController.java +++ /dev/null @@ -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()); - } -} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/controller/WechatController.java b/lzbi-module/src/main/java/com/lzbi/wechat/controller/WechatController.java deleted file mode 100644 index 1dba9d4..0000000 --- a/lzbi-module/src/main/java/com/lzbi/wechat/controller/WechatController.java +++ /dev/null @@ -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)); - } -} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/domain/SysWechat.java b/lzbi-module/src/main/java/com/lzbi/wechat/domain/SysWechat.java deleted file mode 100644 index fdaac4d..0000000 --- a/lzbi-module/src/main/java/com/lzbi/wechat/domain/SysWechat.java +++ /dev/null @@ -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; - } -} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/domain/dto/ParamsContrastDTO.java b/lzbi-module/src/main/java/com/lzbi/wechat/domain/dto/ParamsContrastDTO.java deleted file mode 100644 index ed9fa21..0000000 --- a/lzbi-module/src/main/java/com/lzbi/wechat/domain/dto/ParamsContrastDTO.java +++ /dev/null @@ -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 listTransitionMap(List list) { - Map map = new HashMap<>(); - list.forEach(obj -> map.put(obj.getParamsModelCode(), obj)); - return map; - } -} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/domain/dto/TargetModelValueDTO.java b/lzbi-module/src/main/java/com/lzbi/wechat/domain/dto/TargetModelValueDTO.java deleted file mode 100644 index 23c2f55..0000000 --- a/lzbi-module/src/main/java/com/lzbi/wechat/domain/dto/TargetModelValueDTO.java +++ /dev/null @@ -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 targetModelCodeList; - /** - * 部门id - */ - private Long deptId; - /** - * 年 - */ - private String year; - /** - * 月 - */ - private String month; - /** - * 日 - */ - private String day; -} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/domain/req/CodeLoginReq.java b/lzbi-module/src/main/java/com/lzbi/wechat/domain/req/CodeLoginReq.java deleted file mode 100644 index 04f1daf..0000000 --- a/lzbi-module/src/main/java/com/lzbi/wechat/domain/req/CodeLoginReq.java +++ /dev/null @@ -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; -} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/domain/req/PhoneNumberLoginReq.java b/lzbi-module/src/main/java/com/lzbi/wechat/domain/req/PhoneNumberLoginReq.java deleted file mode 100644 index 8178cf9..0000000 --- a/lzbi-module/src/main/java/com/lzbi/wechat/domain/req/PhoneNumberLoginReq.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.lzbi.wechat.domain.req; - -import lombok.Data; - -/** - * 手机号登录请求参数 - */ -@Data -public class PhoneNumberLoginReq { - - /** - * 手机号 - */ - private String phone; - /** - * 微信用户唯一标识 - */ - private String openId; -} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/domain/req/PhoneNumberReq.java b/lzbi-module/src/main/java/com/lzbi/wechat/domain/req/PhoneNumberReq.java deleted file mode 100644 index dd386b5..0000000 --- a/lzbi-module/src/main/java/com/lzbi/wechat/domain/req/PhoneNumberReq.java +++ /dev/null @@ -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; -} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatAccessTokenResp.java b/lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatAccessTokenResp.java deleted file mode 100644 index 4339f82..0000000 --- a/lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatAccessTokenResp.java +++ /dev/null @@ -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; -} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatBaseResp.java b/lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatBaseResp.java deleted file mode 100644 index ce6b1c6..0000000 --- a/lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatBaseResp.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.lzbi.wechat.domain.resp; - -import lombok.Data; - -/** - * 微信接口返回值 - */ -@Data -public class WechatBaseResp { - - /** - * 错误码 - */ - private Integer errcode; - /** - * 错误信息 - */ - private String errmsg; -} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatCodeLoginResp.java b/lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatCodeLoginResp.java deleted file mode 100644 index 6fb92cc..0000000 --- a/lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatCodeLoginResp.java +++ /dev/null @@ -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; -} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatPhoneNumberResp.java b/lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatPhoneNumberResp.java deleted file mode 100644 index 01520a3..0000000 --- a/lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatPhoneNumberResp.java +++ /dev/null @@ -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; - } -} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/ChildDeptVO.java b/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/ChildDeptVO.java deleted file mode 100644 index 3b77a87..0000000 --- a/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/ChildDeptVO.java +++ /dev/null @@ -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; -} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/CodeLoginVO.java b/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/CodeLoginVO.java deleted file mode 100644 index 60fd880..0000000 --- a/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/CodeLoginVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.lzbi.wechat.domain.vo; - -import lombok.Data; - -/** - * 登录凭证登录返回值 - */ -@Data -public class CodeLoginVO { - - private String token; - - private String openId; -} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/DeptVO.java b/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/DeptVO.java deleted file mode 100644 index 86857e4..0000000 --- a/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/DeptVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.lzbi.wechat.domain.vo; - -import lombok.Data; - -/** - * 部门返回值 - */ -@Data -public class DeptVO { - - /** - * 部门id - */ - private Long value; - /** - * 部门名称 - */ - private String label; -} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/FinishingRateVO.java b/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/FinishingRateVO.java deleted file mode 100644 index b75c149..0000000 --- a/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/FinishingRateVO.java +++ /dev/null @@ -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 names; - /** - * 指标值列表 - */ - private List values; -} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/TargetPlanVO.java b/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/TargetPlanVO.java deleted file mode 100644 index 56b2327..0000000 --- a/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/TargetPlanVO.java +++ /dev/null @@ -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; -} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/TargetResultVO.java b/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/TargetResultVO.java deleted file mode 100644 index 0553ec0..0000000 --- a/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/TargetResultVO.java +++ /dev/null @@ -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; - } -} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/TargetVO.java b/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/TargetVO.java deleted file mode 100644 index 7ef4515..0000000 --- a/lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/TargetVO.java +++ /dev/null @@ -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; -} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/mapper/SysWechatMapper.java b/lzbi-module/src/main/java/com/lzbi/wechat/mapper/SysWechatMapper.java deleted file mode 100644 index 5e33e1b..0000000 --- a/lzbi-module/src/main/java/com/lzbi/wechat/mapper/SysWechatMapper.java +++ /dev/null @@ -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); -} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/service/DeptService.java b/lzbi-module/src/main/java/com/lzbi/wechat/service/DeptService.java deleted file mode 100644 index cda3348..0000000 --- a/lzbi-module/src/main/java/com/lzbi/wechat/service/DeptService.java +++ /dev/null @@ -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 getSelfDeptList() { - List list = new ArrayList<>(); - LoginUser loginUser = SecurityUtils.getLoginUser(); - SysUser sysUser = loginUser.getUser(); - List roles = sysUser.getRoles(); - List roleIds = roles.stream().map(SysRole::getRoleId).collect(Collectors.toList()); - List 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 getDeptChildren(Long deptId) { - List 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 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 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> getHeatSourceParamsValue (Long deptId) { - Long userId = SecurityUtils.getUserId(); - List 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 paramsContrastDTOList = dcBusiWorkReadConfigMapper.selectDcBusiWorkReadConfigByAssetTarget(targetModelCodeList, assetParams); - if (!CollectionUtils.isEmpty(paramsContrastDTOList)) { - List paramsCodeList = paramsContrastDTOList.stream().map(ParamsContrastDTO::getParamsCode).collect(Collectors.toList()); - Map>> req = new HashMap<>(); - Map> 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; - } -} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/service/LoginService.java b/lzbi-module/src/main/java/com/lzbi/wechat/service/LoginService.java deleted file mode 100644 index 2bdb217..0000000 --- a/lzbi-module/src/main/java/com/lzbi/wechat/service/LoginService.java +++ /dev/null @@ -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); - } -} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/service/SysWechatService.java b/lzbi-module/src/main/java/com/lzbi/wechat/service/SysWechatService.java deleted file mode 100644 index dd9ff7b..0000000 --- a/lzbi-module/src/main/java/com/lzbi/wechat/service/SysWechatService.java +++ /dev/null @@ -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); - } -} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/service/TargetService.java b/lzbi-module/src/main/java/com/lzbi/wechat/service/TargetService.java deleted file mode 100644 index c73e003..0000000 --- a/lzbi-module/src/main/java/com/lzbi/wechat/service/TargetService.java +++ /dev/null @@ -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 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 targetModelCodeList = new ArrayList<>(); - targetModelCodeList.add(TargetModelCodeConstants.总开栓面积); - TargetModelValueDTO targetModelValueDTO = buildeTargetModelValueDTO(targetModelCodeList, deptId, date); - List targetResultVOList = dcBusiTargetDraftDaynewMapper.selectDayTargetModelValue(targetModelValueDTO); - Double result = null; - if (!CollectionUtils.isEmpty(targetResultVOList)) { - result = targetResultVOList.get(0).getValue(); - } - return result; - } - - public Map getComanyTarget(Long deptId, String date) { - List 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 targetResultVOList = dcBusiTargetDraftDaynewMapper.selectDayTargetModelValue(targetModelValueDTO); - Map 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 getHeatSourceTarget(Long deptId, String date, String type) { - List 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 map; - if (BizConstants.TargetType.DAY.equals(type)) { - List targetResultVOList = dcBusiTargetDraftDaynewMapper.selectDayTargetModelValue(targetModelValueDTO); - map = listTransitionMap(targetResultVOList); - } else { - List 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 getHeatExchangeStationParams(Long deptId) { - Map 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> getFinishingRate(Long deptId) { - List> list = new ArrayList<>(); - List 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 targetResultVOList = dcBusiTargetDraftDaynewMapper.selectTotalTargetModelValue(targetModelValueDTO); - List targetPlanVOList = dcBusiTargetDraftMonthMapper.selectTotalTargetModelPlanValue(targetModelValueDTO); - Map targetValueMap = null; - Map 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 names = new ArrayList<>(); - names.add("name"); - List 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> finishingRateLine(Long deptId) { - List> list = new ArrayList<>(); - List list1 = Arrays.asList("product", "2012", "2013", "2014", "2015", "2016", "2017"); - List list2 = Arrays.asList("Milk Tea", 56.5, 82.1, 88.7, 70.1, 53.4, 85.1); - List list3 = Arrays.asList("Matcha Latte", 51.1, 51.4, 55.1, 53.3, 73.8, 68.7); - List list4 = Arrays.asList("Cheese Cocoa", 40.1, 62.2, 69.5, 36.4, 45.2, 32.5); - List 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 Map listTransitionMap(List list) { - Map map = new HashMap<>(); - list.forEach(obj -> map.put(obj.getTargetCode(), obj)); - return map; - } -} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/service/WechatService.java b/lzbi-module/src/main/java/com/lzbi/wechat/service/WechatService.java deleted file mode 100644 index fe0d59d..0000000 --- a/lzbi-module/src/main/java/com/lzbi/wechat/service/WechatService.java +++ /dev/null @@ -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 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 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 getPhoneNumberParams = new HashMap<>(); - getPhoneNumberParams.put("access_token", accessToken); - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_JSON); - Map getPhoneNumberBody = new HashMap<>(); - getPhoneNumberBody.put("code", phoneNumberReq.getCode()); - HttpEntity 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); - } - -} diff --git a/lzbi-module/src/main/java/com/lzbi/wechat/webSocket/HeatSourceServer.java b/lzbi-module/src/main/java/com/lzbi/wechat/webSocket/HeatSourceServer.java deleted file mode 100644 index 15ddf24..0000000 --- a/lzbi-module/src/main/java/com/lzbi/wechat/webSocket/HeatSourceServer.java +++ /dev/null @@ -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 onlineSessionClientMap = new ConcurrentHashMap<>(); - - /** - * 存放所有在线的用户和要查询的组织id - */ - private static Map onlineUserDeptMap = new ConcurrentHashMap<>(); - - /** - * 连接建立成功调用的方法。由前端new WebSocket触发 - * - * @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); - } - - /** - * 连接关闭调用的方法。由前端socket.close()触发 - * - * @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); - } - - /** - * 收到客户端消息后调用的方法。由前端socket.send触发 - * * 当服务端执行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(); - }*/ - } -} diff --git a/lzbi-module/src/main/resources/mapper/SysWechatMapper.xml b/lzbi-module/src/main/resources/mapper/SysWechatMapper.xml deleted file mode 100644 index 7db2713..0000000 --- a/lzbi-module/src/main/resources/mapper/SysWechatMapper.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - insert into sys_wechat (open_id, phone) values (#{openId}, #{phone}) - - - - update sys_wechat set open_id = #{openId}, phone = #{phone} where id = #{id} - - - - delete from sys_wechat where id = #{id} - - \ No newline at end of file diff --git a/lzbi-module/src/main/resources/mapper/asset/DcBusiTargetDraftDaynewMapper.xml b/lzbi-module/src/main/resources/mapper/asset/DcBusiTargetDraftDaynewMapper.xml index f85cd60..2691e36 100644 --- a/lzbi-module/src/main/resources/mapper/asset/DcBusiTargetDraftDaynewMapper.xml +++ b/lzbi-module/src/main/resources/mapper/asset/DcBusiTargetDraftDaynewMapper.xml @@ -101,55 +101,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND t1.date_year = #{year} AND t1.date_month = #{month} - - - - insert into dc_busi_target_draft_daynew diff --git a/lzbi-module/src/main/resources/mapper/asset/DcBusiTargetDraftMonthMapper.xml b/lzbi-module/src/main/resources/mapper/asset/DcBusiTargetDraftMonthMapper.xml index 02a8380..90f91aa 100644 --- a/lzbi-module/src/main/resources/mapper/asset/DcBusiTargetDraftMonthMapper.xml +++ b/lzbi-module/src/main/resources/mapper/asset/DcBusiTargetDraftMonthMapper.xml @@ -62,27 +62,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} - - + + insert into dc_busi_target_draft_month @@ -139,6 +135,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" target_name_alias, target_name, target_code, + target_model_code, target_uint, count_date, count_year, @@ -168,6 +165,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{targetNameAlias}, #{targetName}, #{targetCode}, + #{targetModelCode}, #{targetUint}, #{countDate}, #{countYear}, @@ -190,12 +188,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 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 - + (#{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}) @@ -213,6 +211,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" field_name = #{fieldName}, target_name_alias = #{targetNameAlias}, target_name = #{targetName}, + target_model_code = #{targetModelCode}, target_code = #{targetCode}, target_uint = #{targetUint}, count_date = #{countDate}, diff --git a/lzbi-module/src/main/resources/mapper/asset/DcBusiWorkReadConfigMapper.xml b/lzbi-module/src/main/resources/mapper/asset/DcBusiWorkReadConfigMapper.xml index 00e92e4..76703fa 100644 --- a/lzbi-module/src/main/resources/mapper/asset/DcBusiWorkReadConfigMapper.xml +++ b/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 - -