Browse Source

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

develop
eric777 10 months ago
parent
commit
a4b98d2f2f
  1. 25
      lzbi-admin/src/main/resources/application-test.yml
  2. 38
      lzbi-common/src/main/java/com/lzbi/common/constant/TargetModelCodeConstants.java
  3. 67
      lzbi-module/src/main/java/com/lzbi/bill/service/DcBusiTargetInputMasterService.java
  4. 7
      lzbi-module/src/main/resources/mapper/asset/DcBusiTargetDraftDaynewMapper.xml

25
lzbi-admin/src/main/resources/application-test.yml

@ -129,3 +129,28 @@ target-model:
outputOfPlant: TM000FDL # 发电量
provideWaterAverageTemperature: TM000GSJW # 供水均温
answerWaterAverageTemperature: TM000HSJW # 回水均温
# 微信相关配置
wechat:
# 小程序ID
appId: wx4c96b81e6331fefa
# 小程序密钥
appSecret: b7258ba1e7db304d086cb83f034b3b60
# 小程序登录接口
code2Session: https://api.weixin.qq.com/sns/jscode2session?appid={appid}&secret={secret}&js_code={js_code}&grant_type={grant_type}
# 获取接口调用凭据
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

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

@ -86,41 +86,5 @@ public class TargetModelCodeConstants {
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";
}

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

@ -21,10 +21,15 @@ 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.*;
import org.apache.poi.xssf.usermodel.*;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
@ -35,10 +40,7 @@ import javax.annotation.Resource;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.regex.Pattern;
@ -180,7 +182,8 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
// 获取单元格内容的类型
CellType cellType = cell.getCellType();
if (null != cellType && cellType.equals(CellType.FORMULA)) {
// throw new RuntimeException("excel中不能存在公式!");
cellList.add("");
// throw new RuntimeException("excel中不能存在公式!");
} else {
cellList.add(formatter.formatCellValue(cell, formulaEvaluator));
}
@ -218,6 +221,7 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
Map<String, Map<String, DcBaseAssetTarget>> targetMap = new HashMap<>();
for (ProductionDailySheetReq productionDailySheetReq : list) {
String name = productionDailySheetReq.getName();
name = name.trim();
DcBaseAssetInfo dcBaseAssetInfo = dcBaseAssetInfoMapper.selectDcBaseAssetInfoByAliasName(name);
if (ObjectUtils.isEmpty(dcBaseAssetInfo)) {
return AjaxResult.error(name + "sheet页没有对应的统计单元");
@ -235,6 +239,7 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
}
for (ProductionDailySheetReq productionDailySheetReq : list) {
String name = productionDailySheetReq.getName();
name = name.trim();
DcBaseAssetInfo dcBaseAssetInfo = assetMap.get(name);
Map<String, DcBaseAssetTarget> dcBaseAssetTargetMap = targetMap.get(name);
List<List<String>> data = productionDailySheetReq.getData();
@ -259,6 +264,15 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
break;
}
dayMap.put(day, j);
} else if (Pattern.matches("\\d+[日小计]+", column)) {
String day = column.substring(0, column.length() - 3);
if (Integer.parseInt(day) > confirmReq.getDays()) {
continue;
}
if (dayMap.containsKey(day)) {
break;
}
dayMap.put(day, j);
}
}
sign = true;
@ -273,7 +287,13 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
if (!ObjectUtils.isEmpty(dcBaseAssetTarget)) {
dayMap.forEach((day, index) -> {
String v = row.get(index);
if (StringUtils.isNotBlank(v) && !v.contains("-")) {
if (Pattern.matches(".*[-!@#$%^&*()_+={}\\[\\]\"<>/;':\\\\|`~].*", v)) {
return;
}
if (v.contains(",")) {
v = v.replaceAll(",", "");
}
if (StringUtils.isNotBlank(v)) {
DcBusiTargetInputSub dcBusiTargetInputSub = new DcBusiTargetInputSub();
dcBusiTargetInputSub.setTargetCode(dcBaseAssetTarget.getTargetCode());
dcBusiTargetInputSub.setTargetName(dcBaseAssetTarget.getTargetName());
@ -290,14 +310,13 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
dcBusiTargetInputSub.setTagetUnit(dcBaseAssetTarget.getFieldUnit());
dcBusiTargetInputSub.setDay(String.valueOf(day));
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;
String format = "数值转换错误,sheet页:%s,指标:%s,日:%s,索引:%s,数据:%s";
String msg = String.format(format, dcBaseAssetInfo.getAssetNameAlias(), dcBaseAssetTarget.getTargetName(), day, index, v);
log.error(msg, e);
throw new RuntimeException(msg);
}
dcBusiTargetInputSub.setBillNoMaster(confirmReq.getBillNo());
result.add(dcBusiTargetInputSub);
@ -346,8 +365,10 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
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()));
String format = "%s(sheet页)中,%s(指标)%s年%s月%s日,已存在";
String msg = String.format(format, dcBusiTargetDraftDaynew.getAssetNameAlias(), dcBusiTargetDraftDaynew.getTagetName(), dcBusiTargetDraftDaynew.getDateYear(), dcBusiTargetDraftDaynew.getDateMonth(), dcBusiTargetDraftDaynew.getDateDay());
log.error(msg);
throw new RuntimeException(msg);
}
DcBusiTargetInputSub subParams = new DcBusiTargetInputSub();
@ -461,7 +482,19 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu
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);
int len = ids.length;
int range = 1000;
int remainder = len % range;
int count = len / range;
String[] idsNew;
for (int i = 0; i < count; i++) {
idsNew = Arrays.copyOfRange(ids, i * range, (i + 1) * range);
dcBusiTargetDraftDaynewMapper.deleteDcBusiTargetDraftDaynewByIds(idsNew);
}
if (remainder > 0) {
idsNew = Arrays.copyOfRange(ids, count * range, len);
dcBusiTargetDraftDaynewMapper.deleteDcBusiTargetDraftDaynewByIds(idsNew);
}
}
DcBusiTargetInputSub subParams = new DcBusiTargetInputSub();
subParams.setBillNoMaster(billNo);

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

@ -76,11 +76,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
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' )
INNER JOIN dc_busi_target_input_sub t2
ON 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}

Loading…
Cancel
Save