Browse Source

1、指标录入单

2、微信小程序接口
develop
bobol 10 months ago
parent
commit
d55a33338a
  1. 13
      lzbi-admin/src/main/resources/application-dev.yml
  2. 20
      lzbi-common/src/main/java/com/lzbi/common/config/GoalServerApiConfig.java
  3. 16
      lzbi-common/src/main/java/com/lzbi/common/config/GoalServerConfig.java
  4. 31
      lzbi-common/src/main/java/com/lzbi/common/constant/BizConstants.java
  5. 126
      lzbi-common/src/main/java/com/lzbi/common/constant/TargetModelCodeConstants.java
  6. 10
      lzbi-module/src/main/java/com/lzbi/asset/domain/DcBaseAssetInfo.java
  7. 6
      lzbi-module/src/main/java/com/lzbi/asset/mapper/DcBusiWorkReadConfigMapper.java
  8. 13
      lzbi-module/src/main/java/com/lzbi/asset/service/DcBusiParamSourceService.java
  9. 6
      lzbi-module/src/main/java/com/lzbi/bill/service/DcBusiMonthPlanBillMasterService.java
  10. 216
      lzbi-module/src/main/java/com/lzbi/bill/service/DcBusiTargetInputMasterService.java
  11. 2
      lzbi-module/src/main/java/com/lzbi/draft/controller/DcBusiTargetDraftDaynewController.java
  12. 4
      lzbi-module/src/main/java/com/lzbi/draft/domain/DcBusiTargetDraftDaynew.java
  13. 2
      lzbi-module/src/main/java/com/lzbi/draft/domain/vo/ProductionDailySheetVO.java
  14. 23
      lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiTargetDraftDaynewMapper.java
  15. 16
      lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiTargetDraftMonthMapper.java
  16. 2
      lzbi-module/src/main/java/com/lzbi/draft/service/DcBusiTargetDraftDaynewService.java
  17. 2
      lzbi-module/src/main/java/com/lzbi/targetFolder/mapper/DcBaseAssetTargetMapper.java
  18. 34
      lzbi-module/src/main/java/com/lzbi/wechat/controller/BizController.java
  19. 9
      lzbi-module/src/main/java/com/lzbi/wechat/controller/LoginController.java
  20. 31
      lzbi-module/src/main/java/com/lzbi/wechat/domain/dto/ParamsContrastDTO.java
  21. 37
      lzbi-module/src/main/java/com/lzbi/wechat/domain/dto/TargetModelValueDTO.java
  22. 4
      lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatAccessTokenResp.java
  23. 4
      lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatBaseResp.java
  24. 4
      lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatCodeLoginResp.java
  25. 4
      lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatPhoneNumberResp.java
  26. 25
      lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/TargetPlanVO.java
  27. 36
      lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/TargetResultVO.java
  28. 17
      lzbi-module/src/main/java/com/lzbi/wechat/domain/vo/TargetVO.java
  29. 117
      lzbi-module/src/main/java/com/lzbi/wechat/service/DeptService.java
  30. 181
      lzbi-module/src/main/java/com/lzbi/wechat/service/LoginService.java
  31. 296
      lzbi-module/src/main/java/com/lzbi/wechat/service/TargetService.java
  32. 22
      lzbi-module/src/main/java/com/lzbi/wechat/service/WechatService.java
  33. 149
      lzbi-module/src/main/java/com/lzbi/wechat/webSocket/HeatSourceServer.java
  34. 74
      lzbi-module/src/main/resources/mapper/asset/DcBaseAssetInfoMapper.xml
  35. 89
      lzbi-module/src/main/resources/mapper/asset/DcBusiTargetDraftDaynewMapper.xml
  36. 34
      lzbi-module/src/main/resources/mapper/asset/DcBusiTargetDraftMonthMapper.xml
  37. 25
      lzbi-module/src/main/resources/mapper/asset/DcBusiWorkReadConfigMapper.xml
  38. 29
      lzbi-module/src/main/resources/mapper/targetFolder/DcBaseAssetTargetMapper.xml
  39. 3
      lzbi-system/src/main/resources/mapper/system/SysDeptMapper.xml

13
lzbi-admin/src/main/resources/application-dev.yml

@ -142,3 +142,16 @@ wechat:
accessToken: https://api.weixin.qq.com/cgi-bin/token?appid={appid}&secret={secret}&grant_type={grant_type}
# 获取手机号
phoneNumber: https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token={access_token}
# 外部服务
goal-server:
# iot平台服务地址
iot: http://127.0.0.1:9010
# 外部服务接口
goal-server-api:
# 获取组织资产参数树形结构
getOrgAssetParamsTree: ${goal-server.iot}/biz/common/orgAssetParamsTree
# 获取组织资产参数树形结构
getParamsValue: ${goal-server.iot}/biz/common/paramsValue

20
lzbi-common/src/main/java/com/lzbi/common/config/GoalServerApiConfig.java

@ -0,0 +1,20 @@
package com.lzbi.common.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Data
@Component
@ConfigurationProperties(prefix = "goal-server-api")
public class GoalServerApiConfig {
/**
* 获取组织资产参数树形结构
*/
private String getOrgAssetParamsTree;
/**
* 获取参数值
*/
private String getParamsValue;
}

16
lzbi-common/src/main/java/com/lzbi/common/config/GoalServerConfig.java

@ -0,0 +1,16 @@
package com.lzbi.common.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Data
@Component
@ConfigurationProperties(prefix = "goal-server")
public class GoalServerConfig {
/**
* iot平台服务地址
*/
private String iot;
}

31
lzbi-common/src/main/java/com/lzbi/common/constant/BizConstants.java

@ -36,18 +36,39 @@ public interface BizConstants {
}
/**
* 资产类
* 统计单元级
*/
interface DcAssetAttr {
interface DcAssetLevel {
/**
* 集团
*/
String BLOC = "0";
/**
* 公司
*/
String COMPANY = "10";
/**
* 热源
*/
String HEAT_SOURCE = "20";
/**
* 换热站
*/
String HEAT_EXCHANGE_STATION = "1001";
String HEAT_EXCHANGE_STATION = "30";
}
/**
* 统计单元类型
*/
interface DcAssetType {
/**
* 热源
* 报表
*/
String REPORT = "0";
/**
* 计算
*/
String HEAT_SOURCE = "1002";
String COMPUTE = "1";
}
}

126
lzbi-common/src/main/java/com/lzbi/common/constant/TargetModelCodeConstants.java

@ -0,0 +1,126 @@
package com.lzbi.common.constant;
public class TargetModelCodeConstants {
public static final String 热源厂电耗率 = "00001";
public static final String 热耗率 = "00002";
public static final String 单位面积耗原煤 = "00003";
public static final String 单位面积耗标煤 = "00004";
public static final String 一次网耗水率 = "00005";
public static final String 二次网耗电率 = "00006";
public static final String 二次网耗水率 = "00007";
public static final String 总锅炉效率 = "00008";
public static final String 产热标准煤耗率 = "00009";
public static final String 发电标准煤耗率 = "00010";
public static final String 供汽损耗率 = "00011";
public static final String 单耗消石灰 = "00012";
public static final String 单耗氨水 = "00013";
public static final String 单耗氧化镁 = "00014";
public static final String 单耗石灰石粉 = "00015";
public static final String 单耗纯碱 = "00016";
public static final String 单耗液氧 = "00017";
public static final String 单耗电石渣 = "00018";
public static final String 单耗氧化钙 = "00019";
public static final String 室外平均气温 = "00020";
public static final String 总开栓面积 = "00021";
public static final String 自管开栓面积 = "00022";
public static final String 总产热量 = "00023";
public static final String 供暖供热量 = "00024";
public static final String 从大唐购热量 = "00025";
public static final String 供汽量 = "00026";
public static final String 售汽量 = "00027";
public static final String 生产用原煤总量 = "00028";
public static final String 生产用标煤总量 = "00029";
public static final String 进煤量 = "00030";
public static final String 煤库存 = "00031";
public static final String 发电量 = "00032";
public static final String 上网电量 = "00033";
public static final String 总厂用电量 = "00034";
public static final String 耗自发电量 = "00035";
public static final String 购市政电量 = "00036";
public static final String 二次网耗电量 = "00037";
public static final String 热源耗水量 = "00038";
public static final String 一次网补水量 = "00039";
public static final String 从大唐补一次网水量 = "00040";
public static final String 二次网耗水量 = "00041";
public static final String 汽炉运行台数 = "00042";
public static final String 汽炉运行出力 = "00043";
public static final String 汽炉产汽量 = "00044";
public static final String 汽炉产热量 = "00045";
public static final String 汽炉供热量 = "00046";
public static final String 汽炉热效率 = "00047";
public static final String 水炉运行台数 = "00048";
public static final String 水炉运行容量 = "00049";
public static final String 水炉产热量 = "00050";
public static final String 水炉热效率 = "00051";
public static final String 供汽供热量 = "00052";
public static final String 总供热量 = "00053";
public static final String 一次网供水温度 = "00054";
public static final String 一次网回水温度 = "00055";
public static final String 汽炉耗原煤量 = "00056";
public static final String 水炉耗原煤量 = "00057";
public static final String 入炉煤热值 = "00058";
public static final String 锅炉点火耗燃料油 = "00059";
public static final String 消石灰 = "00060";
public static final String 氨水 = "00061";
public static final String 氧化镁 = "00062";
public static final String 石灰石粉 = "00063";
public static final String 纯碱 = "00064";
public static final String 电石渣 = "00065";
public static final String 氧化钙 = "00066";
public static final String 液体氢氧化钠 = "00067";
public static final String 盐酸 = "00068";
public static final String 生物质进量 = "00069";
public static final String 生物质耗用 = "00070";
public static final String 生物质库存 = "00071";
public static final String 生物质热值 = "00072";
public static final String 液氧 = "00073";
public static final String 汽炉颗粒物折算排放浓度 = "00074";
public static final String 汽炉二氧化硫折算排放浓度 = "00075";
public static final String 汽炉氮氧化物折算排放浓度 = "00076";
public static final String 水炉颗粒物折算排放浓度 = "00077";
public static final String 水炉二氧化硫折算排放浓度 = "00078";
public static final String 水炉氮氧化物折算排放浓度 = "00079";
public static final String 烟气余热回收耗电量 = "00080";
public static final String 烟气余热回收热量 = "00081";
public static final String 中水汽动热泵提取热量 = "00082";
public static final String 中水电动热泵耗电量 = "00083";
public static final String 中水电动热泵产热量 = "00084";
public static final String 燃气锅炉产热量 = "00085";
public static final String 一次网水耗 = "ycwsh";
public static final String 一次网电耗 = "ycwdh";
public static final String 一次网煤耗 = "ycwmh";
public static final String 总产汽量 = "zcql";
public static final String 总发电量 = "zfdl";
public static final String 二次网水耗 = "ecwsh";
public static final String 二次网电耗 = "ecwdh";
public static final String 循环流量 = "xhll";
public static final String 一次网供温 = "ycwgw";
public static final String 一次网回温 = "ycwhw";
public static final String 一次网水单耗 = "ycwsdh";
public static final String 一次网电单耗 = "ycwddh";
public static final String 一次网煤单耗 = "ycwmdh";
public static final String 单产热量 = "dcrl";
public static final String 单产汽量 = "dcql";
public static final String 单发电量 = "dfdl";
public static final String 二次网水单耗 = "ecwsdh";
public static final String 二次网电单耗 = "ecwddh";
public static final String 一次网水耗累计 = "ycwshlj";
public static final String 一次网电耗累计 = "ycwdhlj";
public static final String 一次网煤耗累计 = "ycwmhlj";
public static final String 总产热量累计 = "zcrllj";
public static final String 总产汽量累计 = "zcqllj";
public static final String 总发电量累计 = "zfdllj";
public static final String 二次网水耗累计 = "ecwshlj";
public static final String 二次网电耗累计 = "ecwdhlj";
public static final String 循环流量累计 = "xhlllj";
public static final String 一次网供温累计 = "ycwgwlj";
public static final String 一次网回温累计 = "ycwhwlj";
public static final String 一次网水单耗累计 = "ycwsdhlj";
public static final String 一次网电单耗累计 = "ycwddhlj";
public static final String 一次网煤单耗累计 = "ycwmdhlj";
public static final String 单产热量累计 = "dcrllj";
public static final String 单产汽量累计 = "dcqllj";
public static final String 单发电量累计 = "dfdllj";
public static final String 二次网水单耗累计 = "ecwsdhlj";
public static final String 二次网电单耗累计 = "ecwddhlj";
}

10
lzbi-module/src/main/java/com/lzbi/asset/domain/DcBaseAssetInfo.java

@ -58,6 +58,16 @@ public class DcBaseAssetInfo extends BaseModuleEntity {
@ApiModelProperty(name = "统计单元状态",notes = "statusAsset")
private String statusAsset;
/** 统计单元级别(0集团 10公司 20热源 30换热站) */
@Excel(name = "统计单元级别", readConverterExp = "0=集团,1=0公司,2=0热源,3=0换热站")
@ApiModelProperty(name = "统计单元级别",notes = "")
private String assetLevel;
/** 统计单元类型(0日报 1统计) */
@Excel(name = "统计单元类型", readConverterExp = "0=日报,1=统计")
@ApiModelProperty(name = "统计单元类型",notes = "")
private String assetType;
/** 所属公司 */
@Excel(name = "所属公司")
@ApiModelProperty(name = "所属公司",notes = "comanyId")

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

@ -1,9 +1,13 @@
package com.lzbi.asset.mapper;
import java.util.List;
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;
/**
* 互联参数读取数据对照Mapper接口
@ -31,6 +35,8 @@ public interface DcBusiWorkReadConfigMapper extends BaseMapper<DcBusiWorkReadCon
public List<DcBusiWorkReadConfig> selectDcBusiWorkReadConfigList(DcBusiWorkReadConfig dcBusiWorkReadConfig);
public List<DcBusiWorkReadConfig> selectDcBusiWorkReadConfigMainList(AssetQueryParams assetQueryParams);
List<ParamsContrastDTO> selectDcBusiWorkReadConfigByAssetTarget(@Param("targetModelCodeList") List<String> targetModelCodeList, @Param("dcBaseAssetInfo") DcBaseAssetInfo dcBaseAssetInfo);
/**
* 新增互联参数读取数据对照
*

13
lzbi-module/src/main/java/com/lzbi/asset/service/DcBusiParamSourceService.java

@ -3,20 +3,16 @@ package com.lzbi.asset.service;
import com.alibaba.fastjson2.JSONArray;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lzbi.asset.domain.DcBusiParamSource;
import com.lzbi.asset.domain.ElementTreeVO;
import com.lzbi.asset.domain.TreeVO;
import com.lzbi.asset.mapper.DcBusiParamSourceMapper;
import com.lzbi.common.config.GoalServerApiConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.lzbi.asset.domain.DcBusiParamSource;
import org.springframework.util.CollectionUtils;
import org.springframework.web.client.RestTemplate;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 采集参数来源信息表;(dc_busi_param_source)表服务接口
@ -29,6 +25,9 @@ public class DcBusiParamSourceService extends ServiceImpl<DcBusiParamSourceMapp
@Autowired
private RestTemplate restTemplate;
@Autowired
private GoalServerApiConfig goalServerApiConfig;
public List<DcBusiParamSource> selectByVo( DcBusiParamSource dcBusiParamSource){
return baseMapper.selectByVo(dcBusiParamSource);
}
@ -41,7 +40,7 @@ public class DcBusiParamSourceService extends ServiceImpl<DcBusiParamSourceMapp
ElementTreeVO elementTreeVO = new ElementTreeVO();
elementTreeVO.setValue("IOT");
elementTreeVO.setLabel("IOT平台");
String result = restTemplate.getForObject("http://127.0.0.1:9010/biz/common/orgAssetParamsTree", String.class);
String result = restTemplate.getForObject(goalServerApiConfig.getGetOrgAssetParamsTree(), String.class);
if (null != result) {
List<ElementTreeVO> elementTreeVOS = JSONArray.parseArray(result, ElementTreeVO.class);
elementTreeVO.setIsLeaf(Boolean.TRUE);

6
lzbi-module/src/main/java/com/lzbi/bill/service/DcBusiMonthPlanBillMasterService.java

@ -203,9 +203,9 @@ public class DcBusiMonthPlanBillMasterService extends ServiceImpl<DcBusiMonthPla
dcBusiTargetDraftMonth.setTargetCode(subList.get(i).getTargetCode());
dcBusiTargetDraftMonth.setCountYear(subList.get(i).getDateYear());
dcBusiTargetDraftMonth.setCountMonth(subList.get(i).getDateMonth());
List<DcBusiTargetDraftMonth> dcBusiTargetDraftDaynews = dcBusiTargetDraftMonthMapper.selectDcBusiTargetDraftMonthList(dcBusiTargetDraftMonth);
List<DcBusiTargetDraftMonth> dcBusiTargetDraftMonthList = dcBusiTargetDraftMonthMapper.selectDcBusiTargetDraftMonthList(dcBusiTargetDraftMonth);
// 如果底稿表数据为空,则新增底稿数据,否则,加上计划值修改
if (CollectionUtils.isEmpty(dcBusiTargetDraftDaynews)) {
if (CollectionUtils.isEmpty(dcBusiTargetDraftMonthList)) {
dcBusiTargetDraftMonth.setCompanyName(master.getCompanyName());
dcBusiTargetDraftMonth.setOrgName(master.getOrganizeName());
dcBusiTargetDraftMonth.setFieldName(subList.get(i).getFieldName());
@ -221,7 +221,7 @@ public class DcBusiMonthPlanBillMasterService extends ServiceImpl<DcBusiMonthPla
dcBusiTargetDraftMonth.setValPlan(subList.get(i).getPlanValue());
dcBusiTargetDraftMonthMapper.insertDcBusiTargetDraftMonth(dcBusiTargetDraftMonth);
} else {
dcBusiTargetDraftMonth = dcBusiTargetDraftDaynews.get(0);
dcBusiTargetDraftMonth = dcBusiTargetDraftMonthList.get(0);
dcBusiTargetDraftMonth.setValPlan(dcBusiTargetDraftMonth.getValPlan().add(subList.get(i).getPlanValue()));
dcBusiTargetDraftMonthMapper.updateDcBusiTargetDraftMonth(dcBusiTargetDraftMonth);
}

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

@ -11,22 +11,20 @@ import com.lzbi.bill.mapper.DcBusiTargetInputSubMapper;
import com.lzbi.common.core.domain.AjaxResult;
import com.lzbi.common.utils.DateUtils;
import com.lzbi.common.utils.SecurityUtils;
import com.lzbi.draft.domain.DcBusiTargetAdjustDayMasterDao;
import com.lzbi.draft.domain.DcBusiTargetDraftDaynew;
import com.lzbi.draft.domain.DcBusiTargetDraftMonth;
import com.lzbi.draft.domain.req.ConfirmReq;
import com.lzbi.draft.domain.req.ProductionDailySheetReq;
import com.lzbi.draft.domain.vo.ProductionDailySheetVO;
import com.lzbi.draft.mapper.DcBusiTargetDraftDaynewMapper;
import com.lzbi.draft.mapper.DcBusiTargetDraftMonthMapper;
import com.lzbi.targetFolder.domain.DcBaseAssetTarget;
import com.lzbi.targetFolder.mapper.DcBaseAssetTargetMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.IteratorUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.BeanUtils;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.*;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
@ -52,9 +50,9 @@ import java.util.stream.Collectors;
* @author lienbo
* @date 2024-01-19
*/
@Slf4j
@Service
public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInputMasterMapper, DcBusiTargetInputMaster> implements IService<DcBusiTargetInputMaster>
{
public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInputMasterMapper, DcBusiTargetInputMaster> implements IService<DcBusiTargetInputMaster> {
@Resource
private DcBaseAssetInfoMapper dcBaseAssetInfoMapper;
@ -68,6 +66,9 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
@Resource
private DcBusiTargetDraftDaynewMapper dcBusiTargetDraftDaynewMapper;
@Resource
private DcBusiTargetDraftMonthMapper dcBusiTargetDraftMonthMapper;
private static final Lock lock = new ReentrantLock();
/**
@ -76,8 +77,7 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
* @param id 指标录入单主键
* @return 指标录入单
*/
public DcBusiTargetInputMaster selectDcBusiTargetInputMasterById(Long id)
{
public DcBusiTargetInputMaster selectDcBusiTargetInputMasterById(Long id) {
return baseMapper.selectDcBusiTargetInputMasterById(id);
}
@ -97,8 +97,7 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
* @param dcBusiTargetInputMaster 指标录入单
* @return 指标录入单
*/
public List<DcBusiTargetInputMaster> selectDcBusiTargetInputMasterList(DcBusiTargetInputMaster dcBusiTargetInputMaster)
{
public List<DcBusiTargetInputMaster> selectDcBusiTargetInputMasterList(DcBusiTargetInputMaster dcBusiTargetInputMaster) {
return baseMapper.selectDcBusiTargetInputMasterList(dcBusiTargetInputMaster);
}
@ -109,8 +108,7 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
* @return 结果
*/
@Transactional(rollbackFor = Exception.class)
public int insertDcBusiTargetInputMaster(DcBusiTargetInputMaster dcBusiTargetInputMaster)
{
public int insertDcBusiTargetInputMaster(DcBusiTargetInputMaster dcBusiTargetInputMaster) {
dcBusiTargetInputSubMapper.batchInsertDcBusiTargetInputSub(dcBusiTargetInputMaster.getSubList());
dcBusiTargetInputMaster.setCreatedTime(DateUtils.getNowDate());
dcBusiTargetInputMaster.setDeptId(SecurityUtils.getDeptId());
@ -126,8 +124,7 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
* @return 结果
*/
public int updateDcBusiTargetInputMaster(DcBusiTargetInputMaster dcBusiTargetInputMaster)
{
public int updateDcBusiTargetInputMaster(DcBusiTargetInputMaster dcBusiTargetInputMaster) {
dcBusiTargetInputMaster.setUpdatedTime(DateUtils.getNowDate());
return baseMapper.updateDcBusiTargetInputMaster(dcBusiTargetInputMaster);
}
@ -139,8 +136,7 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
* @return 结果
*/
public int deleteDcBusiTargetInputMasterByIds(Long[] ids)
{
public int deleteDcBusiTargetInputMasterByIds(Long[] ids) {
return baseMapper.deleteDcBusiTargetInputMasterByIds(ids);
}
@ -151,8 +147,7 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
* @return 结果
*/
public int deleteDcBusiTargetInputMasterById(Long id)
{
public int deleteDcBusiTargetInputMasterById(Long id) {
return baseMapper.deleteDcBusiTargetInputMasterById(id);
}
@ -162,6 +157,8 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
try {
inputStream = file.getInputStream();
XSSFWorkbook hssfWorkbook = new XSSFWorkbook(inputStream);
//后面使用它来执行计算公式
FormulaEvaluator formulaEvaluator = new XSSFFormulaEvaluator(hssfWorkbook);
int numberOfSheets = hssfWorkbook.getNumberOfSheets();
DataFormatter formatter = new DataFormatter();
for (int j = 0; j < numberOfSheets; j++) {
@ -169,16 +166,27 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
String sheetName = sheetAt.getSheetName();
//获取数据总行数
int rows = sheetAt.getPhysicalNumberOfRows();
List<List<String>> data = new ArrayList<>();
List<List<Object>> data = new ArrayList<>();
//每行数据处理
for (int i = 0; i < rows; i++) {
//获取一行数据
XSSFRow row = sheetAt.getRow(i);
if (null != row) {
List<Cell> cells = IteratorUtils.toList(row.cellIterator());
List<String> cellList = new ArrayList<>();
for (int i1 = 0, len1 = cells.size(); i1 < len1; i1++) {
cellList.add(formatter.formatCellValue(cells.get(i1)));
int cellLength = row.getPhysicalNumberOfCells();
List<Object> cellList = new ArrayList<>();
for (int i1 = 0; i1 < cellLength; i1++) {
Cell cell = row.getCell(i1);
if (null != cell) {
// 获取单元格内容的类型
CellType cellType = cell.getCellType();
if (null != cellType && cellType.equals(CellType.FORMULA)) {
// throw new RuntimeException("excel中不能存在公式!");
} else {
cellList.add(formatter.formatCellValue(cell, formulaEvaluator));
}
} else {
cellList.add("");
}
}
data.add(cellList);
}
@ -194,7 +202,7 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
if (null != inputStream) {
inputStream.close();
}
} catch (IOException e) {
} catch (IOException e) {
log.error("文件解析异常", e);
}
}
@ -259,13 +267,13 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
if (sign) {
String column = row.get(0);
if (StringUtils.isBlank(column)) {
break;
continue;
}
DcBaseAssetTarget dcBaseAssetTarget = dcBaseAssetTargetMap.get(column);
if (!ObjectUtils.isEmpty(dcBaseAssetTarget)) {
dayMap.forEach((day, index) -> {
String v = row.get(index);
if (StringUtils.isNotBlank(v)) {
if (StringUtils.isNotBlank(v) && !v.contains("-")) {
DcBusiTargetInputSub dcBusiTargetInputSub = new DcBusiTargetInputSub();
dcBusiTargetInputSub.setTargetCode(dcBaseAssetTarget.getTargetCode());
dcBusiTargetInputSub.setTargetName(dcBaseAssetTarget.getTargetName());
@ -281,7 +289,16 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
dcBusiTargetInputSub.setOrganizeName(dcBaseAssetInfo.getOrgName());
dcBusiTargetInputSub.setTagetUnit(dcBaseAssetTarget.getFieldUnit());
dcBusiTargetInputSub.setDay(String.valueOf(day));
dcBusiTargetInputSub.setValResult(new BigDecimal(v));
try {
if (v.contains(",")) {
v = v.replaceAll(",", "");
}
BigDecimal bigDecimal = new BigDecimal(v);
dcBusiTargetInputSub.setValResult(bigDecimal.setScale(4, BigDecimal.ROUND_HALF_EVEN));
} catch (RuntimeException e) {
log.error("值转换错误,v:{}, AssetName:{},TargetName:{},day:{},index:{}", v, dcBaseAssetInfo.getAssetName(), dcBaseAssetTarget.getTargetName(), day, index);
throw e;
}
dcBusiTargetInputSub.setBillNoMaster(confirmReq.getBillNo());
result.add(dcBusiTargetInputSub);
}
@ -325,6 +342,14 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
if ("2".equals(master.getCheckStatus())) {
throw new RuntimeException("审核失败,单据已审核");
}
List<DcBusiTargetDraftDaynew> dcBusiTargetDraftDaynews = dcBusiTargetDraftDaynewMapper.selectDcBusiTargetDraftDaynewByTargetInput(master);
if (!CollectionUtils.isEmpty(dcBusiTargetDraftDaynews)) {
DcBusiTargetDraftDaynew dcBusiTargetDraftDaynew = dcBusiTargetDraftDaynews.get(0);
String msg = "%s中,%s(指标)%s年%s月%s日,已存在";
throw new RuntimeException(String.format(msg, dcBusiTargetDraftDaynew.getAssetNameAlias(), dcBusiTargetDraftDaynew.getTagetName(), dcBusiTargetDraftDaynew.getDateYear(), dcBusiTargetDraftDaynew.getDateMonth(), dcBusiTargetDraftDaynew.getDateDay()));
}
DcBusiTargetInputSub subParams = new DcBusiTargetInputSub();
subParams.setBillNoMaster(billNo);
List<DcBusiTargetInputSub> dcBusiTargetInputSubList = dcBusiTargetInputSubMapper.selectDcBusiTargetInputSubList(subParams);
@ -334,6 +359,7 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
String month = master.getMonth();
List<String> targetCodeList = dcBusiTargetInputSubList.stream().map(DcBusiTargetInputSub::getTargetCode).collect(Collectors.toList());
List<DcBaseAssetTarget> dcBaseAssetTargets = dcBaseAssetTargetMapper.selectDcBaseAssetTargetByTargetCodeList(targetCodeList);
Map<String, List<DcBaseAssetTarget>> targetModelMap = dcBaseAssetTargets.stream().collect(Collectors.groupingBy(DcBaseAssetTarget::getTargetCode));
Map<String, String> targetModelCodeMap = dcBaseAssetTargets.stream().collect(Collectors.toMap(DcBaseAssetTarget::getTargetCode, DcBaseAssetTarget::getTargetModelCode));
for (DcBusiTargetInputSub dcBusiTargetInputSub : dcBusiTargetInputSubList) {
String day = dcBusiTargetInputSub.getDay();
@ -345,23 +371,67 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
dcBusiTargetDraftDaynew.setTargetCode(dcBusiTargetInputSub.getTargetCode());
dcBusiTargetDraftDaynew.setDateYear(year);
dcBusiTargetDraftDaynew.setDateMonth(month);
dcBusiTargetDraftDaynew.setDateDay(day);
List<DcBusiTargetDraftDaynew> dcBusiTargetDraftDaynewList = dcBusiTargetDraftDaynewMapper.selectDcBusiTargetDraftDaynewList(dcBusiTargetDraftDaynew);
if (CollectionUtils.isEmpty(dcBusiTargetDraftDaynewList)) {
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);
} else {
String msg = "{} 中 {} {}-{}-{},已存在";
throw new RuntimeException(String.format(msg, dcBusiTargetInputSub.getAssetNameAlias(), dcBusiTargetInputSub.getTargetName(), year, month, StringUtils.leftPad(day, 2, "0")));
}
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);
}
dcBusiTargetDraftDaynewMapper.batchInsertDcBusiTargetDraftDaynew(newList);
Map<String, List<DcBusiTargetInputSub>> targetMap = dcBusiTargetInputSubList.stream().collect(Collectors.groupingBy(DcBusiTargetInputSub::getTargetCode));
targetMap.forEach((targetCode, subList) -> {
DcBusiTargetDraftMonth dcBusiTargetDraftMonth = new DcBusiTargetDraftMonth();
DcBusiTargetInputSub dcBusiTargetInputSub = subList.get(0);
dcBusiTargetDraftMonth.setCompanyId(dcBusiTargetInputSub.getCompanyId());
dcBusiTargetDraftMonth.setOrgId(dcBusiTargetInputSub.getOragnizeId());
dcBusiTargetDraftMonth.setFieldCode(dcBusiTargetInputSub.getFieldCode());
dcBusiTargetDraftMonth.setAssetCode(dcBusiTargetInputSub.getAssetCode());
dcBusiTargetDraftMonth.setTargetCode(dcBusiTargetInputSub.getTargetCode());
dcBusiTargetDraftMonth.setCountYear(year);
dcBusiTargetDraftMonth.setCountMonth(month);
List<DcBusiTargetDraftMonth> dcBusiTargetDraftMonthList = dcBusiTargetDraftMonthMapper.selectDcBusiTargetDraftMonthList(dcBusiTargetDraftMonth);
if (CollectionUtils.isEmpty(dcBusiTargetDraftMonthList)) {
dcBusiTargetDraftMonth.setCompanyName(dcBusiTargetInputSub.getCompanyName());
dcBusiTargetDraftMonth.setOrgName(dcBusiTargetInputSub.getOrganizeName());
dcBusiTargetDraftMonth.setFieldName(dcBusiTargetInputSub.getFieldName());
dcBusiTargetDraftMonth.setAssetName(dcBusiTargetInputSub.getAssetName());
dcBusiTargetDraftMonth.setTargetName(dcBusiTargetInputSub.getTargetName());
List<DcBaseAssetTarget> dcBaseAssetTargets1 = targetModelMap.get(dcBusiTargetInputSub.getTargetCode());
DcBaseAssetTarget dcBaseAssetTarget = dcBaseAssetTargets1.get(0);
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<BigDecimal> resultList = subList.stream().map(DcBusiTargetInputSub::getValResult).collect(Collectors.toList());
BigDecimal result = new BigDecimal(0);
for (BigDecimal v : resultList) {
result = result.add(v);
}
dcBusiTargetDraftMonth.setValResult(result);
dcBusiTargetDraftMonthMapper.insertDcBusiTargetDraftMonth(dcBusiTargetDraftMonth);
} else {
dcBusiTargetDraftMonth = dcBusiTargetDraftMonthList.get(0);
List<BigDecimal> resultList = subList.stream().map(DcBusiTargetInputSub::getValResult).collect(Collectors.toList());
BigDecimal result = new BigDecimal(0);
for (BigDecimal v : resultList) {
result = result.add(v);
}
BigDecimal valResult = dcBusiTargetDraftMonth.getValResult();
if (null == valResult) {
valResult = result;
} else {
valResult = valResult.add(result);
}
dcBusiTargetDraftMonth.setValResult(valResult);
dcBusiTargetDraftMonthMapper.updateDcBusiTargetDraftMonth(dcBusiTargetDraftMonth);
}
});
}
// 修改审核状态为已处理
master.setCheckStatus("2");
@ -376,6 +446,7 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
}
}
@Transactional(rollbackFor = Exception.class)
public int checkRevert(String billNo) {
lock.lock();
try {
@ -386,34 +457,47 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
if ("1".equals(master.getCheckStatus())) {
throw new RuntimeException("反审核失败,单据未审核通过");
}
List<DcBusiTargetDraftDaynew> dateNewList = dcBusiTargetDraftDaynewMapper.selectDcBusiTargetDraftDaynewByTargetInput(master);
if (!CollectionUtils.isEmpty(dateNewList)) {
List<String> idList = dateNewList.stream().map(dcBusiTargetDraftDaynew -> String.valueOf(dcBusiTargetDraftDaynew.getId())).collect(Collectors.toList());
String[] ids = idList.toArray(new String[]{});
dcBusiTargetDraftDaynewMapper.deleteDcBusiTargetDraftDaynewByIds(ids);
}
DcBusiTargetInputSub subParams = new DcBusiTargetInputSub();
subParams.setBillNoMaster(billNo);
List<DcBusiTargetInputSub> dcBusiTargetInputSubList = dcBusiTargetInputSubMapper.selectDcBusiTargetInputSubList(subParams);
List<DcBusiTargetDraftDaynew> newList = new ArrayList<>();
if (!CollectionUtils.isEmpty(dcBusiTargetInputSubList)) {
String year = master.getYear();
String month = master.getMonth();
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(day);
List<DcBusiTargetDraftDaynew> dcBusiTargetDraftDaynewList = dcBusiTargetDraftDaynewMapper.selectDcBusiTargetDraftDaynewList(dcBusiTargetDraftDaynew);
if (!CollectionUtils.isEmpty(dcBusiTargetDraftDaynewList)) {
newList.addAll(dcBusiTargetDraftDaynewList);
Map<String, List<DcBusiTargetInputSub>> targetMap = dcBusiTargetInputSubList.stream().collect(Collectors.groupingBy(DcBusiTargetInputSub::getTargetCode));
targetMap.forEach((targetCode, subList) -> {
DcBusiTargetDraftMonth dcBusiTargetDraftMonth = new DcBusiTargetDraftMonth();
DcBusiTargetInputSub dcBusiTargetInputSub = subList.get(0);
dcBusiTargetDraftMonth.setCompanyId(dcBusiTargetInputSub.getCompanyId());
dcBusiTargetDraftMonth.setOrgId(dcBusiTargetInputSub.getOragnizeId());
dcBusiTargetDraftMonth.setFieldCode(dcBusiTargetInputSub.getFieldCode());
dcBusiTargetDraftMonth.setAssetCode(dcBusiTargetInputSub.getAssetCode());
dcBusiTargetDraftMonth.setTargetCode(dcBusiTargetInputSub.getTargetCode());
dcBusiTargetDraftMonth.setCountYear(year);
dcBusiTargetDraftMonth.setCountMonth(month);
List<DcBusiTargetDraftMonth> dcBusiTargetDraftMonthList = dcBusiTargetDraftMonthMapper.selectDcBusiTargetDraftMonthList(dcBusiTargetDraftMonth);
if (!CollectionUtils.isEmpty(dcBusiTargetDraftMonthList)) {
dcBusiTargetDraftMonth = dcBusiTargetDraftMonthList.get(0);
List<BigDecimal> 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);
}
}
if (!CollectionUtils.isEmpty(newList)) {
List<Long> idList = newList.stream().map(DcBusiTargetDraftDaynew::getId).collect(Collectors.toList());
Long[] ids = idList.toArray(new Long[]{});
dcBusiTargetDraftDaynewMapper.deleteDcBusiTargetDraftDaynewByIds(ids);
}
});
}
// 修改审核状态为已处理
master.setCheckStatus("1");

2
lzbi-module/src/main/java/com/lzbi/draft/controller/DcBusiTargetDraftDaynewController.java

@ -124,7 +124,7 @@ public class DcBusiTargetDraftDaynewController extends BaseController
@PreAuthorize("@ss.hasPermi('bi:dcBusiTargetDraftDaynew:remove')")
@Log(title = "指标数据底稿日-新结构", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
public AjaxResult remove(@PathVariable String[] ids)
{
return toAjax(dcBusiTargetDraftDaynewService.deleteDcBusiTargetDraftDaynewByIds(ids));
}

4
lzbi-module/src/main/java/com/lzbi/draft/domain/DcBusiTargetDraftDaynew.java

@ -62,6 +62,10 @@ public class DcBusiTargetDraftDaynew extends BaseModuleEntity
@ApiModelProperty(name = "统计单元名称",notes = "assetName")
private String assetName;
/** 统计单元名称 */
@ApiModelProperty(name = "统计单元别名",notes = "assetNameAlias", hidden = true)
private String assetNameAlias;
/** 指标编码 */
@Excel(name = "指标编码")
@ApiModelProperty(name = "指标编码",notes = "targetCode")

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

@ -22,6 +22,6 @@ public class ProductionDailySheetVO {
/**
* 数据
*/
private List<List<String>> data;
private List<List<Object>> data;
}

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

@ -2,7 +2,10 @@ package com.lzbi.draft.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lzbi.bill.domain.DcBusiTargetInputMaster;
import com.lzbi.draft.domain.DcBusiTargetDraftDaynew;
import com.lzbi.wechat.domain.dto.TargetModelValueDTO;
import com.lzbi.wechat.domain.vo.TargetResultVO;
import org.apache.ibatis.annotations.Param;
/**
@ -22,6 +25,10 @@ public interface DcBusiTargetDraftDaynewMapper extends BaseMapper<DcBusiTargetDr
*/
public DcBusiTargetDraftDaynew selectDcBusiTargetDraftDaynewById(String id);
List<DcBusiTargetDraftDaynew> selectDcBusiTargetDraftDaynewByTargetInput(DcBusiTargetInputMaster dcBusiTargetInputMaster);
int selectDcBusiTargetDraftDaynewCountByTargetInput(DcBusiTargetInputMaster dcBusiTargetInputMaster);
/**
* 查询指标数据底稿日-新结构列表
*
@ -30,6 +37,20 @@ public interface DcBusiTargetDraftDaynewMapper extends BaseMapper<DcBusiTargetDr
*/
public List<DcBusiTargetDraftDaynew> selectDcBusiTargetDraftDaynewList(DcBusiTargetDraftDaynew dcBusiTargetDraftDaynew);
/**
* 查询日指标数据
* @param targetModelValueDTO
* @return
*/
List<TargetResultVO> selectDayTargetModelValue(TargetModelValueDTO targetModelValueDTO);
/**
* 查询累计指标数据
* @param targetModelValueDTO
* @return
*/
List<TargetResultVO> selectTotalTargetModelValue(TargetModelValueDTO targetModelValueDTO);
/**
* 新增指标数据底稿日-新结构
*
@ -62,5 +83,5 @@ public interface DcBusiTargetDraftDaynewMapper extends BaseMapper<DcBusiTargetDr
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteDcBusiTargetDraftDaynewByIds(Long[] ids);
public int deleteDcBusiTargetDraftDaynewByIds(String[] ids);
}

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

@ -4,6 +4,8 @@ import java.util.List;
import com.lzbi.draft.domain.DcBusiTargetDraftMonth;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lzbi.wechat.domain.dto.TargetModelValueDTO;
import com.lzbi.wechat.domain.vo.TargetPlanVO;
import org.apache.ibatis.annotations.Param;
/**
@ -31,6 +33,13 @@ public interface DcBusiTargetDraftMonthMapper extends BaseMapper<DcBusiTargetDra
*/
public List<DcBusiTargetDraftMonth> selectDcBusiTargetDraftMonthList(DcBusiTargetDraftMonth dcBusiTargetDraftMonth);
/**
* 查询月指标总计划值
* @param targetModelValueDTO
* @return
*/
List<TargetPlanVO> selectTotalTargetModelPlanValue(TargetModelValueDTO targetModelValueDTO);
/**
* 新增指标数据底稿()
*
@ -39,6 +48,13 @@ public interface DcBusiTargetDraftMonthMapper extends BaseMapper<DcBusiTargetDra
*/
public int insertDcBusiTargetDraftMonth(DcBusiTargetDraftMonth dcBusiTargetDraftMonth);
/**
* 批量新增
* @param dcBusiTargetDraftMonths
* @return
*/
int batchInsertDcBusiTargetDraftMonth(List<DcBusiTargetDraftMonth> dcBusiTargetDraftMonths);
/**
* 修改指标数据底稿()
*

2
lzbi-module/src/main/java/com/lzbi/draft/service/DcBusiTargetDraftDaynewService.java

@ -72,7 +72,7 @@ public class DcBusiTargetDraftDaynewService extends ServiceImpl<DcBusiTargetDraf
* @return 结果
*/
public int deleteDcBusiTargetDraftDaynewByIds(Long[] ids)
public int deleteDcBusiTargetDraftDaynewByIds(String[] ids)
{
return baseMapper.deleteDcBusiTargetDraftDaynewByIds(ids);
}

2
lzbi-module/src/main/java/com/lzbi/targetFolder/mapper/DcBaseAssetTargetMapper.java

@ -2,6 +2,7 @@ package com.lzbi.targetFolder.mapper;
import java.util.List;
import com.lzbi.asset.domain.DcBaseAssetInfo;
import com.lzbi.targetFolder.domain.DcBaseAssetTarget;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lzbi.targetFolder.domain.DcBaseAssetTargetExpand;
@ -44,6 +45,7 @@ public interface DcBaseAssetTargetMapper extends BaseMapper<DcBaseAssetTarget>
List<DcBaseAssetTarget> selectDcBaseAssetTargetByTargetCodeList(@Param("targetCodeList") List<String> targetCodeList);
List<DcBaseAssetTarget> selectDcBaseAssetTargetByTargetModelCodeListAndAsset(@Param("targetModelCodeList") List<String> targetModelCodeList, @Param("dcBaseAssetInfo") DcBaseAssetInfo dcBaseAssetInfo);
/**
* 新增资产指标配置

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

@ -30,13 +30,22 @@ public class BizController {
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) {
return AjaxResult.success(targetService.getHeatRadiatingArea(deptId));
public AjaxResult getHeatRadiatingArea(@RequestParam("deptId") Long deptId, @RequestParam("date") String date) {
return AjaxResult.success(targetService.getHeatRadiatingArea(deptId, date));
}
/**
@ -44,8 +53,8 @@ public class BizController {
* @return
*/
@GetMapping("/comany/target")
public AjaxResult getComanyTarget(@RequestParam("deptId") Long deptId) {
return AjaxResult.success(targetService.getComanyTarget(deptId));
public AjaxResult getComanyTarget(@RequestParam("deptId") Long deptId, @RequestParam("date") String date) {
return AjaxResult.success(targetService.getComanyTarget(deptId, date));
}
/**
@ -54,8 +63,8 @@ public class BizController {
* @return
*/
@GetMapping("/heatSource/target")
public AjaxResult getHeatSourceTarget(@RequestParam("deptId") Long deptId, @RequestParam("type") String type) {
return AjaxResult.success(targetService.getHeatSourceTarget(deptId, type));
public AjaxResult getHeatSourceTarget(@RequestParam("deptId") Long deptId, @RequestParam("date") String date, @RequestParam("type") String type) {
return AjaxResult.success(targetService.getHeatSourceTarget(deptId, date, type));
}
/**
@ -63,7 +72,7 @@ public class BizController {
* @return
*/
@GetMapping("/heatExchangeStation/params")
public AjaxResult getHeatExchangeStationParams(@RequestParam("deptId") Long deptId) {
public AjaxResult getHeatExchangeStationParams(@RequestParam("deptId") Long deptId, @RequestParam("date") String date) {
return AjaxResult.success(targetService.getHeatExchangeStationParams(deptId));
}
@ -81,17 +90,8 @@ public class BizController {
* @return
*/
@GetMapping("/finishingRateLine")
public AjaxResult getFinishingRateLine(@RequestParam("deptId") Long deptId) {
public AjaxResult getFinishingRateLine(@RequestParam("deptId") Long deptId, @RequestParam("date") String date) {
return AjaxResult.success(targetService.finishingRateLine(deptId));
}
/**
* 获取下属部门列表
* @return
*/
@GetMapping("/dept/children")
public AjaxResult getDeptChildren(@RequestParam("deptId") Long deptId) {
return AjaxResult.success(deptService.getDeptChildren(deptId));
}
}

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

@ -3,7 +3,7 @@ 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.framework.web.service.SysLoginService;
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;
@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
public class LoginController {
@Autowired
private SysLoginService loginService;
private LoginService loginService;
/**
* 登录方法
@ -26,11 +26,8 @@ public class LoginController {
@PostMapping("/username")
public AjaxResult login(@RequestBody LoginBody loginBody)
{
AjaxResult ajax = AjaxResult.success();
// 生成令牌
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
return loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
loginBody.getUuid());
ajax.put(Constants.TOKEN, token);
return ajax;
}
}

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

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

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

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

4
lzbi-module/src/main/java/com/lzbi/wechat/domain/rep/WechatAccessTokenRep.java → lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatAccessTokenResp.java

@ -1,4 +1,4 @@
package com.lzbi.wechat.domain.rep;
package com.lzbi.wechat.domain.resp;
import lombok.Data;
@ -6,7 +6,7 @@ import lombok.Data;
* 获取接口调用凭据
*/
@Data
public class WechatAccessTokenRep extends WechatBaseRep{
public class WechatAccessTokenResp extends WechatBaseResp {
private String access_token;

4
lzbi-module/src/main/java/com/lzbi/wechat/domain/rep/WechatBaseRep.java → lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatBaseResp.java

@ -1,4 +1,4 @@
package com.lzbi.wechat.domain.rep;
package com.lzbi.wechat.domain.resp;
import lombok.Data;
@ -6,7 +6,7 @@ import lombok.Data;
* 微信接口返回值
*/
@Data
public class WechatBaseRep {
public class WechatBaseResp {
/**
* 错误码

4
lzbi-module/src/main/java/com/lzbi/wechat/domain/rep/WechatCodeLoginRep.java → lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatCodeLoginResp.java

@ -1,4 +1,4 @@
package com.lzbi.wechat.domain.rep;
package com.lzbi.wechat.domain.resp;
import lombok.Data;
@ -6,7 +6,7 @@ import lombok.Data;
* 微信登录凭证登录返回值
*/
@Data
public class WechatCodeLoginRep extends WechatBaseRep {
public class WechatCodeLoginResp extends WechatBaseResp {
/**
* 会话密钥

4
lzbi-module/src/main/java/com/lzbi/wechat/domain/rep/WechatPhoneNumberRep.java → lzbi-module/src/main/java/com/lzbi/wechat/domain/resp/WechatPhoneNumberResp.java

@ -1,4 +1,4 @@
package com.lzbi.wechat.domain.rep;
package com.lzbi.wechat.domain.resp;
import lombok.Data;
@ -6,7 +6,7 @@ import lombok.Data;
* 获取手机号返回值
*/
@Data
public class WechatPhoneNumberRep extends WechatBaseRep {
public class WechatPhoneNumberResp extends WechatBaseResp {
/**
* 手机号信息

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

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

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

@ -0,0 +1,36 @@
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;
}
}

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

@ -4,28 +4,13 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 指标返回值
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TargetVO {
/**
* 指标编码
* 指标模板编码
*/
private String targetCode;
/**
* 指标名称
*/
private String targetName;
/**
* 指标单位
*/
private String targetUnit;
/**
*
*/
private Double value;
}

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

@ -1,5 +1,11 @@
package com.lzbi.wechat.service;
import com.lzbi.asset.domain.DcBaseAssetInfo;
import com.lzbi.asset.domain.DcBusiWorkReadConfig;
import com.lzbi.asset.mapper.DcBaseAssetInfoMapper;
import com.lzbi.asset.mapper.DcBusiWorkReadConfigMapper;
import com.lzbi.common.config.GoalServerApiConfig;
import com.lzbi.common.config.GoalServerConfig;
import com.lzbi.common.constant.BizConstants;
import com.lzbi.common.core.domain.entity.SysDept;
import com.lzbi.common.core.domain.entity.SysRole;
@ -7,22 +13,43 @@ 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.targetFolder.domain.DcBaseAssetTarget;
import com.lzbi.targetFolder.mapper.DcBaseAssetTargetMapper;
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 GoalServerApiConfig goalServerApiConfig;
public List<DeptVO> getSelfDeptList() {
List<DeptVO> list = new ArrayList<>();
LoginUser loginUser = SecurityUtils.getLoginUser();
@ -52,41 +79,65 @@ public class DeptService {
SysDept selfDept = sysDeptService.selectDeptById(deptId);
String orgType = selfDept.getOrgType();
if (BizConstants.DcDeptAttr.COMANY.equals(orgType)) {
// SysDept query = new SysDept();
// query.setParentId(deptId);
// query.setOrgType(BizConstants.DcDeptAttr.HEAT_SOURCE);
// List<SysDept> sysDeptList = sysDeptService.selectDeptList(query);
// 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());
// }
list.add(new ChildDeptVO(103L, "1#热源", 80D, 53D));
list.add(new ChildDeptVO(104L, "2#热源", 76D, 42D));
SysDept params = new SysDept();
params.setParentId(deptId);
params.setOrgType(BizConstants.DcDeptAttr.HEAT_SOURCE);
List<SysDept> sysDeptList = sysDeptService.selectDeptList(params);
if (!CollectionUtils.isEmpty(sysDeptList)) {
list = sysDeptList.stream().map(item -> {
ChildDeptVO childDeptVO = new ChildDeptVO();
childDeptVO.setDeptId(item.getDeptId());
childDeptVO.setDeptName(item.getDeptName());
childDeptVO.setTemperatureSupply(80D);
childDeptVO.setTemperatureComeBack(53D);
return childDeptVO;
}).collect(Collectors.toList());
}
getHeatSourceParamsValue(deptId);
} else {
// QueryWrapper<DcBaseAssetInfo> queryWrapper = new QueryWrapper<>();
// queryWrapper.eq("orgCode", deptId);
// queryWrapper.eq("assetType", BizConstants.DcAssetAttr.HEAT_EXCHANGE_STATION);
// List<DcBaseAssetInfo> assetInfoList = dcBaseAssetInfoService.list(queryWrapper);
// 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());
// }
list.add(new ChildDeptVO(1L, "大唐管井", 90D, 105D));
list.add(new ChildDeptVO(2L, "汪家分局", 80D, 105D));
list.add(new ChildDeptVO(3L, "万盈大厦", 90D, 89D));
DcBaseAssetInfo params = new DcBaseAssetInfo();
params.setOrgId(deptId);
params.setAssetLevel(BizConstants.DcAssetLevel.HEAT_EXCHANGE_STATION);
List<DcBaseAssetInfo> assetInfoList = dcBaseAssetInfoMapper.selectDcBaseAssetInfoList(params);
if (!CollectionUtils.isEmpty(assetInfoList)) {
list = assetInfoList.stream().map(item -> {
ChildDeptVO childDeptVO = new ChildDeptVO();
childDeptVO.setDeptId(item.getAssetCode());
childDeptVO.setDeptName(item.getAssetName());
childDeptVO.setTemperatureSupply(80D);
childDeptVO.setTemperatureComeBack(53D);
return childDeptVO;
}).collect(Collectors.toList());
}
}
return list;
}
/**
* 查询热源参数值
* @param deptId
* @return
*/
public Map<Long, Map<String, Double>> getHeatSourceParamsValue (Long deptId) {
Long userId = SecurityUtils.getUserId();
List<String> targetModelCodeList = new ArrayList<>();
targetModelCodeList.add("101");
targetModelCodeList.add("102");
DcBaseAssetInfo assetParams = new DcBaseAssetInfo();
assetParams.setOrgId(deptId);
assetParams.setAssetLevel(BizConstants.DcAssetLevel.HEAT_EXCHANGE_STATION);
assetParams.setAssetType(BizConstants.DcAssetType.REPORT);
List<ParamsContrastDTO> paramsContrastDTOList = dcBusiWorkReadConfigMapper.selectDcBusiWorkReadConfigByAssetTarget(targetModelCodeList, assetParams);
if (!CollectionUtils.isEmpty(paramsContrastDTOList)) {
List<String> paramsCodeList = paramsContrastDTOList.stream().map(ParamsContrastDTO::getParamsCode).collect(Collectors.toList());
Map<Long, Map<Object, List<String>>> req = new HashMap<>();
Map<Object, List<String>> deptMap = new HashMap<>();
deptMap.put(deptId, paramsCodeList);
req.put(userId, deptMap);
String resp = restTemplate.postForObject(goalServerApiConfig.getGetParamsValue(), req, String.class);
log.info("参数值:{}", resp);
}
return null;
}
}

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

@ -0,0 +1,181 @@
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);
}
}

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

@ -1,13 +1,25 @@
package com.lzbi.wechat.service;
import com.lzbi.asset.mapper.DcBaseAssetInfoMapper;
import com.lzbi.common.constant.BizConstants;
import com.lzbi.common.core.domain.entity.SysDept;
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 {
@ -15,126 +27,196 @@ public class TargetService {
@Autowired
private ISysDeptService sysDeptService;
public Double getHeatRadiatingArea(Long deptId) {
Double result = 314251101D;
@Resource
private DcBaseAssetInfoMapper dcBaseAssetInfoMapper;
@Resource
private DcBaseAssetTargetMapper dcBaseAssetTargetMapper;
@Resource
private DcBusiTargetDraftDaynewMapper dcBusiTargetDraftDaynewMapper;
@Resource
private DcBusiTargetDraftMonthMapper dcBusiTargetDraftMonthMapper;
private TargetModelValueDTO buildeTargetModelValueDTO(List<String> targetModelCodeList, Long deptId, String date) {
String year = null;
String month = null;
String day = null;
if (StringUtils.isNotBlank(date)) {
String[] arr = date.split("-");
if (arr.length == 3) {
year = arr[0];
month = arr[1];
day = arr[2];
} else {
throw new RuntimeException("日期格式不正确");
}
}
return new TargetModelValueDTO(targetModelCodeList, deptId, year, month, day);
}
public Double getHeatRadiatingArea(Long deptId, String date) {
List<String> targetModelCodeList = new ArrayList<>();
targetModelCodeList.add(TargetModelCodeConstants.总开栓面积);
TargetModelValueDTO targetModelValueDTO = buildeTargetModelValueDTO(targetModelCodeList, deptId, date);
List<TargetResultVO> targetResultVOList = dcBusiTargetDraftDaynewMapper.selectDayTargetModelValue(targetModelValueDTO);
Double result = null;
if (!CollectionUtils.isEmpty(targetResultVOList)) {
result = targetResultVOList.get(0).getValue();
}
return result;
}
public Map<String, TargetVO> getComanyTarget(Long deptId) {
Map<String, TargetVO> map = new HashMap<>();
SysDept selfDept = sysDeptService.selectDeptById(deptId);
map.put("00023210", new TargetVO("00023210", "总产热量", "GJ", 14123123D));
map.put("00023211", new TargetVO("00023211", "水总耗", "GJ", 2697D));
map.put("00023212", new TargetVO("00023212", "电总耗", "GJ", 16791D));
map.put("00023213", new TargetVO("00023213", "煤总耗", "GJ", 11679D));
map.put("00023214", new TargetVO("00023214", "平均单耗", "GJ", 8971D));
public Map<String, TargetResultVO> getComanyTarget(Long deptId, String date) {
List<String> targetModelCodeList = new ArrayList<>();
targetModelCodeList.add(TargetModelCodeConstants.总产热量);
targetModelCodeList.add(TargetModelCodeConstants.一次网补水量);
targetModelCodeList.add(TargetModelCodeConstants.从大唐补一次网水量);
targetModelCodeList.add(TargetModelCodeConstants.总厂用电量);
targetModelCodeList.add(TargetModelCodeConstants.生产用标煤总量);
targetModelCodeList.add(TargetModelCodeConstants.热耗率);
TargetModelValueDTO targetModelValueDTO = buildeTargetModelValueDTO(targetModelCodeList, deptId, date);
List<TargetResultVO> targetResultVOList = dcBusiTargetDraftDaynewMapper.selectDayTargetModelValue(targetModelValueDTO);
Map<String, TargetResultVO> map = listTransitionMap(targetResultVOList);
TargetResultVO onceWater = map.get(TargetModelCodeConstants.一次网补水量);
TargetResultVO onceWater2 = map.get(TargetModelCodeConstants.从大唐补一次网水量);
if (null != onceWater.getValue() && null != onceWater2.getValue()) {
onceWater.setValue(onceWater.getValue() + onceWater2.getValue());
}
map.remove(TargetModelCodeConstants.从大唐补一次网水量);
map.put(TargetModelCodeConstants.一次网补水量, onceWater);
return map;
}
public Map<String, TargetVO> getHeatSourceTarget(Long deptId, String type) {
Map<String, TargetVO> map = new HashMap<>();
SysDept selfDept = sysDeptService.selectDeptById(deptId);
public Map<String, TargetResultVO> getHeatSourceTarget(Long deptId, String date, String type) {
List<String> targetModelCodeList = new ArrayList<>();
targetModelCodeList.add(TargetModelCodeConstants.一次网补水量); // 一次网水耗
targetModelCodeList.add(TargetModelCodeConstants.从大唐补一次网水量); // 一次网水耗
targetModelCodeList.add(TargetModelCodeConstants.总厂用电量); // 一次网电耗
targetModelCodeList.add(TargetModelCodeConstants.生产用标煤总量); // 一次网煤耗
targetModelCodeList.add(TargetModelCodeConstants.总产热量); // 总产热量
targetModelCodeList.add(TargetModelCodeConstants.汽炉产汽量); // 总产气量
targetModelCodeList.add(TargetModelCodeConstants.发电量); // 总发电量
targetModelCodeList.add(TargetModelCodeConstants.二次网耗水量); // 二次网总水耗
targetModelCodeList.add(TargetModelCodeConstants.二次网耗电量); // 二次网总电耗
targetModelCodeList.add(TargetModelCodeConstants.一次网供水温度); // 一次网供温
targetModelCodeList.add(TargetModelCodeConstants.一次网回水温度); // 一次网回温
targetModelCodeList.add(TargetModelCodeConstants.一次网耗水率); // 一次网水单耗
targetModelCodeList.add(TargetModelCodeConstants.热源厂电耗率); // 一次网电单耗
targetModelCodeList.add(TargetModelCodeConstants.单位面积耗标煤); // 一次网煤单耗
targetModelCodeList.add(TargetModelCodeConstants.二次网耗水率); // 二次网水单耗
targetModelCodeList.add(TargetModelCodeConstants.二次网耗电率); // 二次网电单耗
TargetModelValueDTO targetModelValueDTO = buildeTargetModelValueDTO(targetModelCodeList, deptId, date);
Map<String, TargetResultVO> map;
if (BizConstants.TargetType.DAY.equals(type)) {
map.put("ycwsh", new TargetVO("ycwsh", "一次网水耗", "GJ", 14123123D));
map.put("ycwdh", new TargetVO("ycwdh", "一次网电耗", "GJ", 2697D));
map.put("ycwmh", new TargetVO("ycwmh", "一次网煤耗", "GJ", 16791D));
map.put("zcrl", new TargetVO("zcrl", "总产热量", "GJ", 11679D));
map.put("zcql", new TargetVO("zcql", "总产汽量", "GJ", 8971D));
map.put("zfdl", new TargetVO("zfdl", "总发电量", "GJ", 14123123D));
map.put("ecwsh", new TargetVO("ecwsh", "二次网水耗", "GJ", 2697D));
map.put("ecwdh", new TargetVO("ecwdh", "二次网电耗", "GJ", 16791D));
map.put("xhll", new TargetVO("xhll", "循环流量", "GJ", 11679D));
map.put("ycwgw", new TargetVO("ycwgw", "一次网供温", "GJ", 8971D));
map.put("ycwhw", new TargetVO("ycwhw", "一次网回温", "GJ", 8971D));
map.put("ycwsdh", new TargetVO("ycwsdh", "一次网水单耗", "GJ", 14123123D));
map.put("ycwddh", new TargetVO("ycwddh", "一次网电单耗", "GJ", 2697D));
map.put("ycwmdh", new TargetVO("ycwmdh", "一次网煤单耗", "GJ", 16791D));
map.put("dcrl", new TargetVO("dcrl", "单产热量", "GJ", 11679D));
map.put("dcql", new TargetVO("dcql", "单产汽量", "GJ", 8971D));
map.put("dfdl", new TargetVO("dfdl", "单发电量", "GJ", 14123123D));
map.put("ecwsdh", new TargetVO("ecwsdh", "二次网水单耗", "GJ", 2697D));
map.put("ecwddh", new TargetVO("ecwddh", "二次网电单耗", "GJ", 16791D));
List<TargetResultVO> targetResultVOList = dcBusiTargetDraftDaynewMapper.selectDayTargetModelValue(targetModelValueDTO);
map = listTransitionMap(targetResultVOList);
} else {
map.put("ycwshlj", new TargetVO("ycwshlj", "一次网水耗", "GJ", 14123123D));
map.put("ycwdhlj", new TargetVO("ycwdhlj", "一次网电耗", "GJ", 2697D));
map.put("ycwmhlj", new TargetVO("ycwmhlj", "一次网煤耗", "GJ", 16791D));
map.put("zcrllj", new TargetVO("zcrllj", "总产热量", "GJ", 11679D));
map.put("zcqllj", new TargetVO("zcqllj", "总产汽量", "GJ", 8971D));
map.put("zfdllj", new TargetVO("zfdllj", "总发电量", "GJ", 14123123D));
map.put("ecwshlj", new TargetVO("ecwshlj", "二次网水耗", "GJ", 2697D));
map.put("ecwdhlj", new TargetVO("ecwdhlj", "二次网电耗", "GJ", 16791D));
map.put("xhlllj", new TargetVO("xhllj", "循环流量", "GJ", 11679D));
map.put("ycwgwlj", new TargetVO("ycwgwlj", "一次网供温", "GJ", 8971D));
map.put("ycwhwlj", new TargetVO("ycwhwlj", "一次网回温", "GJ", 8971D));
map.put("ycwsdhlj", new TargetVO("ycwsdhlj", "一次网水单耗", "GJ", 14123123D));
map.put("ycwddhlj", new TargetVO("ycwddhlj", "一次网电单耗", "GJ", 2697D));
map.put("ycwmdhlj", new TargetVO("ycwmdhlj", "一次网煤单耗", "GJ", 16791D));
map.put("dcrllj", new TargetVO("dcrllj", "单产热量", "GJ", 11679D));
map.put("dcqllj", new TargetVO("dcqllj", "单产汽量", "GJ", 8971D));
map.put("dfdllj", new TargetVO("dfdllj", "单发电量", "GJ", 14123123D));
map.put("ecwsdhlj", new TargetVO("ecwsdhlj", "二次网水单耗", "GJ", 2697D));
map.put("ecwddhlj", new TargetVO("ecwddhlj", "二次网电单耗", "GJ", 16791D));
List<TargetResultVO> targetResultVOList = dcBusiTargetDraftDaynewMapper.selectTotalTargetModelValue(targetModelValueDTO);
map = listTransitionMap(targetResultVOList);
}
TargetResultVO targetResultVO1 = map.get(TargetModelCodeConstants.一次网补水量);
TargetResultVO targetResultVO2 = map.get(TargetModelCodeConstants.从大唐补一次网水量);
if (null != targetResultVO1.getValue() && null != targetResultVO2.getValue()) {
targetResultVO1.setValue(targetResultVO1.getValue() + targetResultVO2.getValue());
} else if (null == targetResultVO1.getValue() && null != targetResultVO2.getValue()) {
targetResultVO1.setValue(targetResultVO2.getValue());
}
map.remove(TargetModelCodeConstants.从大唐补一次网水量);
return map;
}
public Map<String, TargetVO> getHeatExchangeStationParams(Long deptId) {
Map<String, TargetVO> map = new HashMap<>();
map.put("014", new TargetVO("014", "一次网回压", "Mpa", 14123123D));
map.put("013", new TargetVO("013", "一次网供压", "Mpa", 2697D));
map.put("011", new TargetVO("011", "一次网供温", "°C", 16791D));
map.put("012", new TargetVO("012", "一次网回温", "°C", 11679D));
map.put("007", new TargetVO("007", "瞬时流量", "m³/h", 8971D));
map.put("008", new TargetVO("008", "瞬时热量", "kcal", 14123123D));
map.put("009", new TargetVO("009", "累计热量", "kcal", 2697D));
map.put("047", new TargetVO("047", "二次网供水压力", "Mpa", 16791D));
map.put("048", new TargetVO("048", "二次网回水压力", "Mpa", 11679D));
map.put("045", new TargetVO("045", "二次网供水温", "°C", 8971D));
map.put("046", new TargetVO("046", "二次网回水温", "°C", 8971D));
map.put("001", new TargetVO("001", "电调阀开度给定", "%", 14123123D));
map.put("002", new TargetVO("002", "电调阀开度反馈", "%", 2697D));
map.put("015", new TargetVO("015", "水箱水位计", "GJ", 16791D));
map.put("004", new TargetVO("004", "电调阀控制模式选择", "GJ", 11679D));
map.put("003", new TargetVO("003", "电调阀远控/就地", "°C", 8971D));
map.put("044", new TargetVO("044", "二次网压差设定", "%", 14123123D));
map.put("019", new TargetVO("019", "一次网管道泵上电", "", 2697D));
map.put("020", new TargetVO("020", "一次网管道泵下电", "", 16791D));
map.put("005", new TargetVO("005", "二次网供温设定", "", 16791D));
map.put("018", new TargetVO("018", "一次网管道泵远控/就地", "", 16791D));
map.put("021", new TargetVO("021", "一次网管道泵启动", "", 16791D));
map.put("010", new TargetVO("010", "热量累计清零", "kwh", 16791D));
map.put("017", new TargetVO("017", "总电表", "°C", 16791D));
map.put("006", new TargetVO("006", "二次网供回水平均温设定", "m³", 16791D));
map.put("031", new TargetVO("031", "水表(累计补水量)", "%", 16791D));
map.put("023", new TargetVO("023", "一次网管道泵频率给定", "%", 16791D));
map.put("028", new TargetVO("028", "一次网混水电调阀开度给定", "%", 16791D));
map.put("029", new TargetVO("029", "一次网混水电调阀开度反馈", "", 16791D));
map.put("035", new TargetVO("035", "补水泵1#故障状态", "m³", 16791D));
map.put("032", new TargetVO("032", "水表(累计补水量清零)", "", 16791D));
map.put("036", new TargetVO("036", "补水泵2#故障状态", "", 16791D));
map.put("037", new TargetVO("037", "循环泵远控/就地选择", "", 16791D));
map.put("038", new TargetVO("038", "循环泵1#/2#泵选择", "", 16791D));
map.put("039", new TargetVO("039", "循环泵控制模式选择", "", 16791D));
map.put("025", new TargetVO("025", "一次网管道泵运行/停止状态", "", 16791D));
map.put("026", new TargetVO("026", "一次网管道泵故障状态", "", 16791D));
map.put("027", new TargetVO("027", "一次网混水电调阀远控/就地", "", 16791D));
map.put("033", new TargetVO("033", "补水泵1#运行/停止状态", "", 16791D));
map.put("034", new TargetVO("034", "补水泵2#运行/停止状态", "", 16791D));
map.put("040", new TargetVO("040", "循环泵变频上电", "", 16791D));
map.put("041", new TargetVO("041", "循环泵变频下电", "", 16791D));
map.put("042", new TargetVO("042", "循环泵变频启动", "", 16791D));
map.put("043", new TargetVO("043", "循环泵变频停止", "", 16791D));
map.put("022", new TargetVO("022", "一次网管道泵停止", "", 16791D));
map.put("030", new TargetVO("030", "水表(瞬时补水量)", "m³", 16791D));
map.put("066", new TargetVO("066", "一次网管道泵启/停", "", 16791D));
map.put("024", new TargetVO("024", "一次网管道泵频率反馈", "", 16791D));
public Map<String, TargetResultVO> getHeatExchangeStationParams(Long deptId) {
Map<String, TargetResultVO> map = new HashMap<>();
map.put("014", new TargetResultVO("014", "一次网回压", "Mpa", 14123123D));
map.put("013", new TargetResultVO("013", "一次网供压", "Mpa", 2697D));
map.put("011", new TargetResultVO("011", "一次网供温", "°C", 16791D));
map.put("012", new TargetResultVO("012", "一次网回温", "°C", 11679D));
map.put("007", new TargetResultVO("007", "瞬时流量", "m³/h", 8971D));
map.put("008", new TargetResultVO("008", "瞬时热量", "kcal", 14123123D));
map.put("009", new TargetResultVO("009", "累计热量", "kcal", 2697D));
map.put("047", new TargetResultVO("047", "二次网供水压力", "Mpa", 16791D));
map.put("048", new TargetResultVO("048", "二次网回水压力", "Mpa", 11679D));
map.put("045", new TargetResultVO("045", "二次网供水温", "°C", 8971D));
map.put("046", new TargetResultVO("046", "二次网回水温", "°C", 8971D));
map.put("001", new TargetResultVO("001", "电调阀开度给定", "%", 14123123D));
map.put("002", new TargetResultVO("002", "电调阀开度反馈", "%", 2697D));
map.put("015", new TargetResultVO("015", "水箱水位计", "GJ", 16791D));
map.put("004", new TargetResultVO("004", "电调阀控制模式选择", "GJ", 11679D));
map.put("003", new TargetResultVO("003", "电调阀远控/就地", "°C", 8971D));
map.put("044", new TargetResultVO("044", "二次网压差设定", "%", 14123123D));
map.put("019", new TargetResultVO("019", "一次网管道泵上电", "", 2697D));
map.put("020", new TargetResultVO("020", "一次网管道泵下电", "", 16791D));
map.put("005", new TargetResultVO("005", "二次网供温设定", "", 16791D));
map.put("018", new TargetResultVO("018", "一次网管道泵远控/就地", "", 16791D));
map.put("021", new TargetResultVO("021", "一次网管道泵启动", "", 16791D));
map.put("010", new TargetResultVO("010", "热量累计清零", "kwh", 16791D));
map.put("017", new TargetResultVO("017", "总电表", "°C", 16791D));
map.put("006", new TargetResultVO("006", "二次网供回水平均温设定", "m³", 16791D));
map.put("031", new TargetResultVO("031", "水表(累计补水量)", "%", 16791D));
map.put("023", new TargetResultVO("023", "一次网管道泵频率给定", "%", 16791D));
map.put("028", new TargetResultVO("028", "一次网混水电调阀开度给定", "%", 16791D));
map.put("029", new TargetResultVO("029", "一次网混水电调阀开度反馈", "", 16791D));
map.put("035", new TargetResultVO("035", "补水泵1#故障状态", "m³", 16791D));
map.put("032", new TargetResultVO("032", "水表(累计补水量清零)", "", 16791D));
map.put("036", new TargetResultVO("036", "补水泵2#故障状态", "", 16791D));
map.put("037", new TargetResultVO("037", "循环泵远控/就地选择", "", 16791D));
map.put("038", new TargetResultVO("038", "循环泵1#/2#泵选择", "", 16791D));
map.put("039", new TargetResultVO("039", "循环泵控制模式选择", "", 16791D));
map.put("025", new TargetResultVO("025", "一次网管道泵运行/停止状态", "", 16791D));
map.put("026", new TargetResultVO("026", "一次网管道泵故障状态", "", 16791D));
map.put("027", new TargetResultVO("027", "一次网混水电调阀远控/就地", "", 16791D));
map.put("033", new TargetResultVO("033", "补水泵1#运行/停止状态", "", 16791D));
map.put("034", new TargetResultVO("034", "补水泵2#运行/停止状态", "", 16791D));
map.put("040", new TargetResultVO("040", "循环泵变频上电", "", 16791D));
map.put("041", new TargetResultVO("041", "循环泵变频下电", "", 16791D));
map.put("042", new TargetResultVO("042", "循环泵变频启动", "", 16791D));
map.put("043", new TargetResultVO("043", "循环泵变频停止", "", 16791D));
map.put("022", new TargetResultVO("022", "一次网管道泵停止", "", 16791D));
map.put("030", new TargetResultVO("030", "水表(瞬时补水量)", "m³", 16791D));
map.put("066", new TargetResultVO("066", "一次网管道泵启/停", "", 16791D));
map.put("024", new TargetResultVO("024", "一次网管道泵频率反馈", "", 16791D));
return map;
}
public List<List<Object>> getFinishingRate(Long deptId) {
List<List<Object>> list = new ArrayList<>();
List<Object> names = Arrays.asList("name", "水耗", "电耗", "煤耗");
List<Object> values = Arrays.asList("总完成率", 90D, 80D, 95D);
List<String> targetModelCodeList = new ArrayList<>();
targetModelCodeList.add(TargetModelCodeConstants.一次网耗水率);
targetModelCodeList.add(TargetModelCodeConstants.二次网耗水率);
targetModelCodeList.add(TargetModelCodeConstants.热源厂电耗率);
targetModelCodeList.add(TargetModelCodeConstants.二次网耗电率);
targetModelCodeList.add(TargetModelCodeConstants.单位面积耗标煤);
TargetModelValueDTO targetModelValueDTO = buildeTargetModelValueDTO(targetModelCodeList, deptId, null);
List<TargetResultVO> targetResultVOList = dcBusiTargetDraftDaynewMapper.selectTotalTargetModelValue(targetModelValueDTO);
List<TargetPlanVO> targetPlanVOList = dcBusiTargetDraftMonthMapper.selectTotalTargetModelPlanValue(targetModelValueDTO);
Map<String, TargetResultVO> targetValueMap = null;
Map<String, Double> targetPlanValueMap = null;
if (!CollectionUtils.isEmpty(targetResultVOList)) {
targetValueMap = listTransitionMap(targetResultVOList);
}
if (!CollectionUtils.isEmpty(targetPlanVOList)) {
targetPlanValueMap = targetPlanVOList.stream().collect(Collectors.toMap(TargetPlanVO::getTargetCode, TargetPlanVO::getValue));
}
if (null == targetValueMap || null == targetPlanValueMap) {
throw new RuntimeException("无数据");
}
List<Object> names = new ArrayList<>();
names.add("name");
List<Object> values = new ArrayList<>();
values.add("总完成率");
DecimalFormat decimalFormat = new DecimalFormat("#0.00");
for (String targetModelCode : targetModelCodeList) {
TargetResultVO targetResultVO = targetValueMap.get(targetModelCode);
Double value = targetResultVO.getValue();
Double planValue = targetPlanValueMap.get(targetModelCode);
if (null == planValue) {
continue;
}
names.add(targetResultVO.getTargetName());
values.add(decimalFormat.format((value / planValue) * 100));
}
list.add(names);
list.add(values);
return list;
@ -154,4 +236,10 @@ public class TargetService {
list.add(list5);
return list;
}
private <T extends TargetVO> Map<String, T> listTransitionMap(List<T> list) {
Map<String, T> map = new HashMap<>();
list.forEach(obj -> map.put(obj.getTargetCode(), obj));
return map;
}
}

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

@ -4,16 +4,15 @@ 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.core.redis.RedisCache;
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.rep.WechatAccessTokenRep;
import com.lzbi.wechat.domain.rep.WechatCodeLoginRep;
import com.lzbi.wechat.domain.rep.WechatPhoneNumberRep;
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;
@ -21,7 +20,6 @@ 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.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
@ -74,7 +72,7 @@ public class WechatService {
params.put("secret", wechatConfig.getAppSecret());
params.put("js_code", codeLoginReq.getCode());
params.put("grant_type", "authorization_code");
WechatCodeLoginRep resp = restTemplate.getForObject(wechatConfig.getCode2Session(), WechatCodeLoginRep.class, params);
WechatCodeLoginResp resp = restTemplate.getForObject(wechatConfig.getCode2Session(), WechatCodeLoginResp.class, params);
if (ObjectUtils.isNotEmpty(resp) && 0L == resp.getErrcode()) {
String openid = resp.getOpenid();
codeLoginVO.setOpenId(openid);
@ -121,10 +119,10 @@ public class WechatService {
getAccessTokenParams.put("appid", wechatConfig.getAppId());
getAccessTokenParams.put("secret", wechatConfig.getAppSecret());
getAccessTokenParams.put("grant_type", "client_credential");
WechatAccessTokenRep wechatAccessTokenRep = restTemplate.getForObject(wechatConfig.getAccessToken(), WechatAccessTokenRep.class, getAccessTokenParams);
if (ObjectUtils.isNotEmpty(wechatAccessTokenRep) && null == wechatAccessTokenRep.getErrcode()) {
WechatAccessTokenResp wechatAccessTokenResp = restTemplate.getForObject(wechatConfig.getAccessToken(), WechatAccessTokenResp.class, getAccessTokenParams);
if (ObjectUtils.isNotEmpty(wechatAccessTokenResp) && null == wechatAccessTokenResp.getErrcode()) {
// 获取手机号
String accessToken = wechatAccessTokenRep.getAccess_token();
String accessToken = wechatAccessTokenResp.getAccess_token();
Map<String, Object> getPhoneNumberParams = new HashMap<>();
getPhoneNumberParams.put("access_token", accessToken);
HttpHeaders headers = new HttpHeaders();
@ -132,7 +130,7 @@ public class WechatService {
Map<String, Object> getPhoneNumberBody = new HashMap<>();
getPhoneNumberBody.put("code", phoneNumberReq.getCode());
HttpEntity<String> entity = new HttpEntity<>(JSONObject.toJSONString(getPhoneNumberBody), headers);
WechatPhoneNumberRep resp = restTemplate.postForObject(wechatConfig.getPhoneNumber(), entity, WechatPhoneNumberRep.class, getPhoneNumberParams);
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();
@ -142,8 +140,8 @@ public class WechatService {
throw new ServiceException(resp.getErrmsg(), resp.getErrcode());
}
} else {
log.error("调用微信服务获取access_token接口时失败,{}, {}", wechatAccessTokenRep.getErrcode(), wechatAccessTokenRep.getErrmsg());
throw new ServiceException(wechatAccessTokenRep.getErrmsg(), wechatAccessTokenRep.getErrcode());
log.error("调用微信服务获取access_token接口时失败,{}, {}", wechatAccessTokenResp.getErrcode(), wechatAccessTokenResp.getErrmsg());
throw new ServiceException(wechatAccessTokenResp.getErrmsg(), wechatAccessTokenResp.getErrcode());
}
return null;
}

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

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

74
lzbi-module/src/main/resources/mapper/asset/DcBaseAssetInfoMapper.xml

@ -22,33 +22,15 @@
<result property="flagValidateRole" column="flag_validate_role"/>
<result property="flagValidateUser" column="flag_validate_user"/>
<result property="statusAsset" column="status_asset"/>
<result property="assetLevel" column="asset_level" />
<result property="assetType" column="asset_type" />
<result property="comanyId" column="comany_id"/>
<result property="orgId" column="org_id"/>
<result property="deptId" column="dept_id"/>
</resultMap>
<sql id="selectDcBaseAssetInfoVo">
select TENANT_ID,
REVISION,
CREATED_BY,
CREATED_TIME,
UPDATED_BY,
UPDATED_TIME,
DELETE_BY,
DELETE_TIME,
id,
asset_name,
asset_name_alias,
asset_code,
asset_class,
flag_validate_dept,
flag_validate_role,
flag_validate_user,
status_asset,
comany_id,
org_id,
dept_id
from dc_base_asset_info
select tenant_id, revision, created_by, created_time, updated_by, updated_time, delete_by, delete_time, id, asset_name, asset_code, asset_name_alias, asset_class, flag_validate_dept, flag_validate_role, flag_validate_user, status_asset, asset_level, asset_type, comany_id, org_id, dept_id, user_id from dc_base_asset_info
</sql>
<select id="selectDcBaseAssetInfoList" parameterType="DcBaseAssetInfo" resultMap="DcBaseAssetInfoResult">
<include refid="selectDcBaseAssetInfoVo"/>
@ -66,6 +48,8 @@
#{flagValidateUser}
</if>
<if test="statusAsset != null and statusAsset != ''">and status_asset = #{statusAsset}</if>
<if test="assetLevel != null and assetLevel != ''"> and asset_level = #{assetLevel}</if>
<if test="assetType != null and assetType != ''"> and asset_type = #{assetType}</if>
<if test="comanyId != null ">and comany_id = #{comanyId}</if>
<if test="deptId != null ">and dept_id = #{deptId}</if>
</where>
@ -103,26 +87,32 @@
asset_name
from dc_base_asset_info
</select>
<insert id="insertDcBaseAssetInfo" parameterType="DcBaseAssetInfo" useGeneratedKeys="true" keyProperty="id">
insert into dc_base_asset_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="tenantId != null">TENANT_ID,</if>
<if test="revision != null">REVISION,</if>
<if test="createdBy != null">CREATED_BY,</if>
<if test="createdTime != null">CREATED_TIME,</if>
<if test="updatedBy != null">UPDATED_BY,</if>
<if test="updatedTime != null">UPDATED_TIME,</if>
<if test="deleteBy != null">DELETE_BY,</if>
<if test="deleteTime != null">DELETE_TIME,</if>
<if test="tenantId != null">tenant_id,</if>
<if test="revision != null">revision,</if>
<if test="createdBy != null">created_by,</if>
<if test="createdTime != null">created_time,</if>
<if test="updatedBy != null">updated_by,</if>
<if test="updatedTime != null">updated_time,</if>
<if test="deleteBy != null">delete_by,</if>
<if test="deleteTime != null">delete_time,</if>
<if test="assetName != null and assetName != ''">asset_name,</if>
<if test="assetCode != null and assetCode != ''">asset_code,</if>
<if test="assetNameAlias != null">asset_name_alias,</if>
<if test="assetClass != null and assetClass != ''">asset_class,</if>
<if test="flagValidateDept != null">flag_validate_dept,</if>
<if test="flagValidateRole != null">flag_validate_role,</if>
<if test="flagValidateUser != null">flag_validate_user,</if>
<if test="statusAsset != null">status_asset,</if>
<if test="assetLevel != null">asset_level,</if>
<if test="assetType != null">asset_type,</if>
<if test="comanyId != null">comany_id,</if>
<if test="orgId != null">org_id,</if>
<if test="deptId != null">dept_id,</if>
<if test="userId != null">user_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="tenantId != null">#{tenantId},</if>
@ -135,36 +125,46 @@
<if test="deleteTime != null">#{deleteTime},</if>
<if test="assetName != null and assetName != ''">#{assetName},</if>
<if test="assetCode != null and assetCode != ''">#{assetCode},</if>
<if test="assetNameAlias != null">#{assetNameAlias},</if>
<if test="assetClass != null and assetClass != ''">#{assetClass},</if>
<if test="flagValidateDept != null">#{flagValidateDept},</if>
<if test="flagValidateRole != null">#{flagValidateRole},</if>
<if test="flagValidateUser != null">#{flagValidateUser},</if>
<if test="statusAsset != null">#{statusAsset},</if>
<if test="assetLevel != null">#{assetLevel},</if>
<if test="assetType != null">#{assetType},</if>
<if test="comanyId != null">#{comanyId},</if>
<if test="orgId != null">#{orgId},</if>
<if test="deptId != null">#{deptId},</if>
<if test="userId != null">#{userId},</if>
</trim>
</insert>
<update id="updateDcBaseAssetInfo" parameterType="DcBaseAssetInfo">
update dc_base_asset_info
<trim prefix="SET" suffixOverrides=",">
<if test="tenantId != null">TENANT_ID = #{tenantId},</if>
<if test="revision != null">REVISION = #{revision},</if>
<if test="createdBy != null">CREATED_BY = #{createdBy},</if>
<if test="createdTime != null">CREATED_TIME = #{createdTime},</if>
<if test="updatedBy != null">UPDATED_BY = #{updatedBy},</if>
<if test="updatedTime != null">UPDATED_TIME = #{updatedTime},</if>
<if test="deleteBy != null">DELETE_BY = #{deleteBy},</if>
<if test="deleteTime != null">DELETE_TIME = #{deleteTime},</if>
<if test="tenantId != null">tenant_id = #{tenantId},</if>
<if test="revision != null">revision = #{revision},</if>
<if test="createdBy != null">created_by = #{createdBy},</if>
<if test="createdTime != null">created_time = #{createdTime},</if>
<if test="updatedBy != null">updated_by = #{updatedBy},</if>
<if test="updatedTime != null">updated_time = #{updatedTime},</if>
<if test="deleteBy != null">delete_by = #{deleteBy},</if>
<if test="deleteTime != null">delete_time = #{deleteTime},</if>
<if test="assetName != null and assetName != ''">asset_name = #{assetName},</if>
<if test="assetCode != null and assetCode != ''">asset_code = #{assetCode},</if>
<if test="assetNameAlias != null">asset_name_alias = #{assetNameAlias},</if>
<if test="assetClass != null and assetClass != ''">asset_class = #{assetClass},</if>
<if test="flagValidateDept != null">flag_validate_dept = #{flagValidateDept},</if>
<if test="flagValidateRole != null">flag_validate_role = #{flagValidateRole},</if>
<if test="flagValidateUser != null">flag_validate_user = #{flagValidateUser},</if>
<if test="statusAsset != null">status_asset = #{statusAsset},</if>
<if test="assetLevel != null">asset_level = #{assetLevel},</if>
<if test="assetType != null">asset_type = #{assetType},</if>
<if test="comanyId != null">comany_id = #{comanyId},</if>
<if test="orgId != null">org_id = #{orgId},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="userId != null">user_id = #{userId},</if>
</trim>
where id = #{id}
</update>

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

@ -20,6 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="organizeName" column="organize_name" />
<result property="assetCode" column="asset_code" />
<result property="assetName" column="asset_name" />
<result property="assetNameAlias" column="asset_name_alias" />
<result property="targetCode" column="target_code" />
<result property="tagetName" column="taget_name" />
<result property="targetModelCode" column="target_model_code" />
@ -69,6 +70,90 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
</select>
<select id="selectDcBusiTargetDraftDaynewByTargetInput" parameterType="com.lzbi.bill.domain.DcBusiTargetInputMaster" resultMap="DcBusiTargetDraftDaynewResult">
SELECT
t2.asset_name_alias,
t1.*
FROM
dc_busi_target_draft_daynew t1
INNER JOIN dc_busi_target_input_sub t2 ON t1.company_id = t2.company_id
AND t1.organize_id = t2.oragnize_id
AND t1.asset_code = t2.asset_code
AND t1.target_code = t2.target_code
AND t1.date_day = LPAD( t2.`day`, 2, '0' )
WHERE
t2.bill_no_master = #{billSerial}
AND t1.date_year = #{year}
AND t1.date_month = #{month}
ORDER BY
t1.id
</select>
<select id="selectDcBusiTargetDraftDaynewCountByTargetInput" parameterType="com.lzbi.bill.domain.DcBusiTargetInputMaster" resultType="java.lang.Integer">
SELECT
count(*)
FROM
dc_busi_target_draft_daynew t1
INNER JOIN dc_busi_target_input_sub t2 ON t1.company_id = t2.company_id
AND t1.organize_id = t2.oragnize_id
AND t1.asset_code = t2.asset_code
AND t1.target_code = t2.target_code
AND t1.date_day = LPAD( t2.`day`, 2, '0' )
WHERE
t2.bill_no_master = #{billSerial}
AND t1.date_year = #{year}
AND t1.date_month = #{month}
</select>
<select id="selectDayTargetModelValue" parameterType="com.lzbi.wechat.domain.dto.TargetModelValueDTO" resultType="com.lzbi.wechat.domain.vo.TargetResultVO">
SELECT
t1.target_model_code AS "targetCode",
MIN( t1.target_name_alias ) AS "targetName",
MIN( t1.field_unit ) AS "targetUnit",
SUM( t4.value_result ) AS "value"
FROM
dc_base_asset_target t1
INNER JOIN dc_base_asset_info t3
ON t1.asset_code = t3.asset_code
AND t3.org_id = #{deptId}
AND t3.asset_type = "0"
LEFT JOIN dc_busi_target_draft_daynew t4
ON t1.target_code = t4.target_code
AND t4.date_year = #{year}
AND t4.date_month = #{month}
AND t4.date_day = #{day}
WHERE
t1.target_model_code IN
<foreach item="targetModelCode" collection="targetModelCodeList" open="(" separator="," close=")">
#{targetModelCode}
</foreach>
GROUP BY
t1.target_model_code
</select>
<select id="selectTotalTargetModelValue" parameterType="com.lzbi.wechat.domain.dto.TargetModelValueDTO" resultType="com.lzbi.wechat.domain.vo.TargetResultVO">
SELECT
t1.target_model_code AS "targetCode",
MIN( t1.target_name_alias ) AS "targetName",
MIN( t1.field_unit ) AS "targetUnit",
SUM( t4.value_result ) AS "value"
FROM
dc_base_asset_target t1
INNER JOIN dc_base_asset_info t3
ON t1.asset_code = t3.asset_code
AND t3.org_id = #{deptId}
AND t3.asset_type = "0"
LEFT JOIN dc_busi_target_draft_daynew t4
ON t1.target_code = t4.target_code
WHERE
t1.target_model_code IN
<foreach item="targetModelCode" collection="targetModelCodeList" open="(" separator="," close=")">
#{targetModelCode}
</foreach>
GROUP BY
t1.target_model_code
</select>
<insert id="insertDcBusiTargetDraftDaynew" parameterType="DcBusiTargetDraftDaynew" useGeneratedKeys="true" keyProperty="id">
insert into dc_busi_target_draft_daynew
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -181,10 +266,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
delete from dc_busi_target_draft_daynew where id = #{id}
</delete>
<delete id="deleteDcBusiTargetDraftDaynewByIds" parameterType="Long">
<delete id="deleteDcBusiTargetDraftDaynewByIds" parameterType="String">
delete from dc_busi_target_draft_daynew where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

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

@ -62,6 +62,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
</select>
<select id="selectTotalTargetModelPlanValue" parameterType="com.lzbi.wechat.domain.dto.TargetModelValueDTO" resultType="com.lzbi.wechat.domain.vo.TargetPlanVO">
SELECT
t1.target_model_code AS "targetCode",
SUM( t4.val_plan ) AS "value"
FROM
dc_base_asset_target t1
INNER JOIN
dc_base_asset_info t3 ON t1.asset_code = t3.asset_code
AND t3.org_id = #{deptId}
AND t3.asset_type = "0"
LEFT JOIN
dc_busi_target_draft_month t4 ON t1.target_code = t4.target_code
WHERE
t1.target_model_code IN
<foreach item="targetModelCode" collection="targetModelCodeList" open="(" separator="," close=")">
#{targetModelCode}
</foreach>
GROUP BY
t1.target_model_code
</select>
<insert id="insertDcBusiTargetDraftMonth" parameterType="DcBusiTargetDraftMonth" useGeneratedKeys="true" keyProperty="id">
insert into dc_busi_target_draft_month
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -124,6 +145,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
</insert>
<insert id="batchInsertDcBusiTargetDraftMonth">
insert into dc_busi_target_draft_month
(company_id, company_name, org_id, org_name, asset_code, asset_name,
target_code, taget_name, target_name_alias, target_uint, count_year,
count_month, count_date, val_result, field_code, field_name)
values
<foreach collection="list" item="item" separator=",">
(#{item.companyId}, #{item.companyName}, #{item.orgId}, #{item.orgName}, #{item.assetCode}, #{item.assetName},
#{item.targetCode}, #{item.tagetName}, #{item.targetNameAlias}, #{iteam.targetUint}, #{item.countYear},
#{item.countMonth}, #{item.countDate}, #{item.valResult}, #{item.fieldCode}, #{item.fieldName})
</foreach>
</insert>
<update id="updateDcBusiTargetDraftMonth" parameterType="DcBusiTargetDraftMonth">
update dc_busi_target_draft_month
<trim prefix="SET" suffixOverrides=",">

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

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

29
lzbi-module/src/main/resources/mapper/targetFolder/DcBaseAssetTargetMapper.xml

@ -112,6 +112,35 @@
where id = #{id}
</select>
<select id="selectDcBaseAssetTargetByTargetModelCodeListAndAsset" resultMap="DcBaseAssetTargetResult">
select
t1.id,
t1.asset_code,
t1.asset_id,
t1.target_model_code,
t1.target_name,
t1.target_name_alias,
t1.target_code,
t1.field_code,
t1.field_name,
t1.column_type,
t1.field_unit
from
dc_base_asset_target t1
INNER JOIN
dc_base_asset_info t2
ON
t1.asset_code = t2.asset_code
where
t1.target_model_code in
<foreach item="targetModelCode" collection="targetModelCodeList" open="(" separator="," close=")">
#{targetModelCode}
</foreach>
and t2.org_id = #{dcBaseAssetInfo.orgId}
and t2.asset_level = #{dcBaseAssetInfo.assetLevel}
and t2.asset_type = #{dcBaseAssetInfo.assetType}
</select>
<select id="selectDcBaseAssetTargetByTargetCodeAndAssetCode" resultMap="DcBaseAssetTargetResult">
<include refid="selectDcBaseAssetTargetVo"/>
where target_code = #{targetCode}

3
lzbi-system/src/main/resources/mapper/system/SysDeptMapper.xml

@ -46,6 +46,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null and status != ''">
AND status = #{status}
</if>
<if test="orgType != null and orgType != ''">
AND org_type = #{orgType}
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
order by d.parent_id, d.order_num

Loading…
Cancel
Save