Commit ad78b27a authored by litengwei's avatar litengwei

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

parents c84fc8cd 3d17621a
...@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.rule.action.MessageAction; import com.yeejoin.amos.boot.biz.common.rule.action.MessageAction;
import com.yeejoin.equipmanage.common.dto.AnalysisReportLogDto; import com.yeejoin.equipmanage.common.dto.AnalysisReportLogDto;
import com.yeejoin.equipmanage.common.enums.AnalysisReportEnum;
import com.yeejoin.equipmanage.common.utils.*; import com.yeejoin.equipmanage.common.utils.*;
import com.yeejoin.equipmanage.config.PersonIdentify; import com.yeejoin.equipmanage.config.PersonIdentify;
import com.yeejoin.equipmanage.fegin.IotFeign; import com.yeejoin.equipmanage.fegin.IotFeign;
...@@ -845,6 +846,19 @@ public class ConfigureController extends AbstractBaseController { ...@@ -845,6 +846,19 @@ public class ConfigureController extends AbstractBaseController {
return CommonResponseUtil.success(); return CommonResponseUtil.success();
} }
@ApiOperation(httpMethod = "GET", value = "定时生成 MonthReport表", notes = "MonthReport表")
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping("/testMonthReport")
public void monthReport(String date,int num) throws ParseException {
Date time = DateUtils.longStr2Date(date);
Date yestDay = DateUtils.dateAdd(time,-num,false);
Date beginDate = DateUtils.getFirstDayOfMonth(yestDay);
Date endDate = DateUtils.getLastDayOfMonth(yestDay);
log.warn("monthReport报表开始生成");
iAnalysisReportLogService.generateMonthReportTest(AnalysisReportEnum.MONTH_REPORT,beginDate,endDate,time,num);
}
@PersonIdentify @PersonIdentify
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/iotWeekReport") @GetMapping(value = "/iotWeekReport")
......
...@@ -438,7 +438,7 @@ public class EquipmentSpecificController extends AbstractBaseController { ...@@ -438,7 +438,7 @@ public class EquipmentSpecificController extends AbstractBaseController {
List<String> split= Arrays.asList(equipSpeId.split(",")); List<String> split= Arrays.asList(equipSpeId.split(","));
for (String s : split) { for (String s : split) {
// 1.根据 equipSpeId 查询装备iotCode // 1.根据 equipSpeId 查询装备iotCode
EquipmentSpecific equipmentSpecific = equipmentSpecificMapper.selectById(equipSpeId); EquipmentSpecific equipmentSpecific = equipmentSpecificMapper.selectById(s);
if (ObjectUtils.isEmpty(equipmentSpecific)) { if (ObjectUtils.isEmpty(equipmentSpecific)) {
return CommonResponseUtil.failure("未查询到装备信息!"); return CommonResponseUtil.failure("未查询到装备信息!");
} }
......
...@@ -38,6 +38,7 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation; ...@@ -38,6 +38,7 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.math.BigDecimal;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
...@@ -846,18 +847,18 @@ public class TopographyController extends AbstractBaseController { ...@@ -846,18 +847,18 @@ public class TopographyController extends AbstractBaseController {
@RequestParam(required = false) String endDate) throws ParseException { @RequestParam(required = false) String endDate) throws ParseException {
Map<String, List<IotIndexResVo>> resultMap = new HashMap<>(); Map<String, List<IotIndexResVo>> resultMap = new HashMap<>();
List<String> split= Arrays.asList(equipSpeId.split(",")); List<String> split = Arrays.asList(equipSpeId.split(","));
List<IotIndexResVo> finalRes = new ArrayList<>(); List<IotIndexResVo> finalRes = new ArrayList<>();
List<IotIndexResVo> finalResContainsWaterLevel = new ArrayList<>(); List<IotIndexResVo> finalResContainsWaterLevel = new ArrayList<>();
List<IotIndexResVo> resultResContainsWater = new ArrayList<>(); List<IotIndexResVo> resultResContainsWater = new ArrayList<>();
Map<String, String> iotCodeMap = new HashMap<>();
for (String specId : split) { for (String specId : split) {
String eqpId; String eqpId;
String iotCode = null; String iotCode = null;
if(null != fieldKey || null != isTrend) { if (null != fieldKey || null != isTrend) {
EquipmentSpecific equipmentSpecific = equipmentSpecificService.getById(specId); EquipmentSpecific equipmentSpecific = equipmentSpecificService.getById(specId);
iotCode = equipmentSpecific.getIotCode(); iotCode = equipmentSpecific.getIotCode();
iotCodeMap.put(specId, iotCode);
List<EquipmentIndex> equipmentSpecifics = equipmentIndexService.getPerfQutoaIotList(Long.valueOf(specId)); List<EquipmentIndex> equipmentSpecifics = equipmentIndexService.getPerfQutoaIotList(Long.valueOf(specId));
...@@ -867,7 +868,6 @@ public class TopographyController extends AbstractBaseController { ...@@ -867,7 +868,6 @@ public class TopographyController extends AbstractBaseController {
if ("true".equals(isTrend)) { if ("true".equals(isTrend)) {
fieldKey = equipmentSpecifics.stream().filter(equipmentIndex -> equipmentIndex.getIsTrend()).map(EquipmentIndex::getPerfQuotaDefinitionId).collect(Collectors.joining(",")); fieldKey = equipmentSpecifics.stream().filter(equipmentIndex -> equipmentIndex.getIsTrend()).map(EquipmentIndex::getPerfQuotaDefinitionId).collect(Collectors.joining(","));
} }
} else { } else {
if (StringUtil.isNotEmpty(specId)) { if (StringUtil.isNotEmpty(specId)) {
eqpId = specId; eqpId = specId;
...@@ -882,7 +882,6 @@ public class TopographyController extends AbstractBaseController { ...@@ -882,7 +882,6 @@ public class TopographyController extends AbstractBaseController {
EquipmentSpecific equipmentSpecific = equipmentSpecificService.getById(eqpId); EquipmentSpecific equipmentSpecific = equipmentSpecificService.getById(eqpId);
iotCode = equipmentSpecific.getIotCode(); iotCode = equipmentSpecific.getIotCode();
} }
String prefix = null; String prefix = null;
String suffix = null; String suffix = null;
if (StringUtil.isNotEmpty(iotCode) && iotCode.length() > 8) { if (StringUtil.isNotEmpty(iotCode) && iotCode.length() > 8) {
...@@ -911,14 +910,7 @@ public class TopographyController extends AbstractBaseController { ...@@ -911,14 +910,7 @@ public class TopographyController extends AbstractBaseController {
} }
} }
} }
// List<IotDataVO> timeList = vos.stream().filter(x -> x.getKey().equals("time")).collect(Collectors.toList());
// List<Date> dates = new ArrayList<>();
Map<String, List<Date>> dateMap = new HashMap<>(); Map<String, List<Date>> dateMap = new HashMap<>();
// String indexKey = null;
// String useDate = null;
for (int i = 0; i < vos.size(); i = i + 2) { for (int i = 0; i < vos.size(); i = i + 2) {
Date useDate = null; Date useDate = null;
String indexKey = null; String indexKey = null;
...@@ -941,44 +933,7 @@ public class TopographyController extends AbstractBaseController { ...@@ -941,44 +933,7 @@ public class TopographyController extends AbstractBaseController {
dateMap.get(indexKey).add(useDate); dateMap.get(indexKey).add(useDate);
} }
} }
// for (IotDataVO vo : vos) {
// if (!vo.getKey().equals("time")) {
// indexKey = vo.getKey();
// if (useDate != null) {
// SimpleDateFormat sdf1 = new SimpleDateFormat(DateUtils.DATE_TIME_PATTERN);
// if (!dateMap.containsKey(indexKey)) {
// ArrayList<Date> dates1 = new ArrayList<>();
// dates1.add(sdf1.parse(useDate));
// dateMap.put(indexKey, dates1);
// } else {
// dateMap.get(indexKey).add(sdf1.parse(useDate));
// }
// indexKey = null;
// }
// } else {
// String value = String.valueOf(vo.getValue());
// String strDate = value.substring(0, 19);
// SimpleDateFormat sdf = new SimpleDateFormat(ISO8601_DATE_HOUR_MIN_SEC);
// SimpleDateFormat sdf1 = new SimpleDateFormat(DateUtils.DATE_TIME_PATTERN);
// logger.info("返回时间===================================(" + vo.getValue() + ") =======================================");
// sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
// Date date = sdf.parse(strDate);
// String time = DateTimeUtil.format(date, DateTimeUtil.ISO_DATE_HOUR24_MIN_SEC);
// if (indexKey == null) {
// useDate = time;
// }
//// dates.add(sdf1.parse(time));
// logger.info("返回时间===================================(" + sdf1.parse(time) + ") =======================================");
// }
// }
List<EquipmentSpecificIndex> indexes = equipmentSpecificIndexMapper.getEquipmentSpeIndexByIotCodeAndTrend(iotCode); List<EquipmentSpecificIndex> indexes = equipmentSpecificIndexMapper.getEquipmentSpeIndexByIotCodeAndTrend(iotCode);
if (0 < indexes.size()) { if (0 < indexes.size()) {
List<TopographyIotIndexTrendVo> list = new ArrayList<>(); List<TopographyIotIndexTrendVo> list = new ArrayList<>();
vos.forEach(iotDataVO -> { vos.forEach(iotDataVO -> {
...@@ -1006,7 +961,6 @@ public class TopographyController extends AbstractBaseController { ...@@ -1006,7 +961,6 @@ public class TopographyController extends AbstractBaseController {
for (String str : maps.keySet()) { for (String str : maps.keySet()) {
mapIndex.put(str, maps.get(str).get(0).getId()); mapIndex.put(str, maps.get(str).get(0).getId());
} }
List<IotIndexResVo> res = new ArrayList<>(); List<IotIndexResVo> res = new ArrayList<>();
List<IotIndexResVo> resContainsWaterLevelList = new ArrayList<>(); List<IotIndexResVo> resContainsWaterLevelList = new ArrayList<>();
for (String s : mapIndex.keySet()) { for (String s : mapIndex.keySet()) {
...@@ -1027,7 +981,6 @@ public class TopographyController extends AbstractBaseController { ...@@ -1027,7 +981,6 @@ public class TopographyController extends AbstractBaseController {
res.add(vo); res.add(vo);
} }
} }
for (IotIndexResVo s : res) { for (IotIndexResVo s : res) {
s.setIotData(map.get(s.getNameKey())); s.setIotData(map.get(s.getNameKey()));
s.setTimes(dateMap.get(s.getNameKey())); s.setTimes(dateMap.get(s.getNameKey()));
...@@ -1037,9 +990,9 @@ public class TopographyController extends AbstractBaseController { ...@@ -1037,9 +990,9 @@ public class TopographyController extends AbstractBaseController {
} }
} }
} }
List<Date> containsWaterDates = new ArrayList<>();
Map<String, Map<Date, IotDataVO>> iotDataAndDateMap= new HashMap<>(); List<Date> containsWaterDates = new ArrayList<>();
Map<String, Map<Date, IotDataVO>> iotDataAndDateMap = new HashMap<>();
finalResContainsWaterLevel.stream().forEach(item -> { finalResContainsWaterLevel.stream().forEach(item -> {
if (!CollectionUtils.isEmpty(item.getTimes())) { if (!CollectionUtils.isEmpty(item.getTimes())) {
containsWaterDates.addAll(item.getTimes()); containsWaterDates.addAll(item.getTimes());
...@@ -1051,9 +1004,10 @@ public class TopographyController extends AbstractBaseController { ...@@ -1051,9 +1004,10 @@ public class TopographyController extends AbstractBaseController {
} }
}); });
List<Date> collect = containsWaterDates.stream().distinct().sorted(Comparator.comparing(t -> t)).collect(Collectors.toList()); List<Date> collect = containsWaterDates.stream().distinct().sorted(Comparator.comparing(t -> t)).collect(Collectors.toList());
IotIndexResVo iotIndexRes = null;
Map<String, List<IotDataVO>> map = new HashMap<>();
for (IotIndexResVo indexResVo : finalResContainsWaterLevel) { for (IotIndexResVo indexResVo : finalResContainsWaterLevel) {
IotIndexResVo iotIndexRes = new IotIndexResVo(); iotIndexRes = new IotIndexResVo();
iotIndexRes.setName(indexResVo.getName()); iotIndexRes.setName(indexResVo.getName());
iotIndexRes.setTimes(collect); iotIndexRes.setTimes(collect);
iotIndexRes.setId(indexResVo.getId()); iotIndexRes.setId(indexResVo.getId());
...@@ -1063,14 +1017,67 @@ public class TopographyController extends AbstractBaseController { ...@@ -1063,14 +1017,67 @@ public class TopographyController extends AbstractBaseController {
List<IotDataVO> list = new ArrayList<>(); List<IotDataVO> list = new ArrayList<>();
collect.forEach(item -> { collect.forEach(item -> {
IotDataVO iotDataVO = new IotDataVO(); IotDataVO iotDataVO = new IotDataVO();
iotDataVO.setValue(0);
iotDataVO.setKey(indexResVo.getIotData().get(0).getKey()); iotDataVO.setKey(indexResVo.getIotData().get(0).getKey());
iotDataVO.setValue(0);
if (dateIotDataVOMap.containsKey(item)) { if (dateIotDataVOMap.containsKey(item)) {
iotDataVO.setValue(dateIotDataVOMap.get(item).getValue()); iotDataVO.setValue(dateIotDataVOMap.get(item).getValue());
} else {
String currentIotCode = iotCodeMap.get(indexResVo.getEquipId());
String currentPrefix = currentIotCode.substring(0, 8);
String currentSuffix = currentIotCode.substring(8);
ResponseModel entity = null;
try {
entity = iotFeign.selectPage(getAppKey(), getProduct(), getToken(), "2000-01-01 00:00:00", endDate, currentPrefix, currentSuffix, indexResVo.getIotData().get(0).getKey(), 0, 1);
} catch (Exception e) {
throw new RuntimeException("调用AMOS-API-IOT服务失败,请检查服务是否正常!");
}
if (200 == entity.getStatus() && !ObjectUtils.isEmpty(entity.getResult())) {
String json = JSON.toJSONString(entity.getResult());
Map<String, Object> listObject = (Map<String, Object>) JSONArray.parse(json);
List<Map<String, String>> listData = (List<Map<String, String>>) listObject.get("records");
if (!CollectionUtils.isEmpty(listData)) {
for (Map.Entry<String, String> stringStringEntry : listData.get(0).entrySet()) {
if (indexResVo.getIotData().get(0).getKey().equals(stringStringEntry.getKey())) {
iotDataVO.setValue(String.valueOf(stringStringEntry.getValue()));
}
}
} else {
iotDataVO.setValue(0);
}
} else {
iotDataVO.setValue(0);
}
} }
list.add(iotDataVO); list.add(iotDataVO);
}); });
map.put(indexResVo.getEquipId(), list);
}
List<IotDataVO> list = new ArrayList<>();
int j = 0;
for (Map.Entry<String, List<IotDataVO>> stringListEntry : map.entrySet()) {
if (j == 0) {
list = stringListEntry.getValue();
} else {
for (int i = 0; i < stringListEntry.getValue().size(); i++) {
Object last = list.get(i).getValue();
Object current = stringListEntry.getValue().get(i).getValue();
BigDecimal value1 = new BigDecimal(String.valueOf(last));
BigDecimal value2 = new BigDecimal(String.valueOf(current));
BigDecimal add = value1.add(value2);
BigDecimal divide = add.divide(new BigDecimal(2), 2, BigDecimal.ROUND_DOWN);
list.get(i).setValue(divide);
}
}
j++;
}
if (!CollectionUtils.isEmpty(list)) {
iotIndexRes.setIotData(list); iotIndexRes.setIotData(list);
}
if (!ObjectUtils.isEmpty(iotIndexRes)) {
resultResContainsWater.add(iotIndexRes); resultResContainsWater.add(iotIndexRes);
} }
resultMap.put("noMergeList", finalRes); resultMap.put("noMergeList", finalRes);
......
...@@ -25,4 +25,17 @@ public interface IotFeign { ...@@ -25,4 +25,17 @@ public interface IotFeign {
@RequestParam(value = "deviceName") String deviceName, @RequestParam(value = "deviceName") String deviceName,
@RequestParam(required = false, value = "fieldKey") String fieldKey); @RequestParam(required = false, value = "fieldKey") String fieldKey);
@RequestMapping(value = "/v1/livedata/page", method = RequestMethod.GET, consumes = "application/json")
ResponseModel selectPage(
@RequestHeader("appKey") String appKey,
@RequestHeader("product") String product,
@RequestHeader("token") String token,
@RequestParam(value = "timeStart") String beginDate,
@RequestParam(value = "timeEnd") String endDate,
@RequestParam(value = "productKey") String productKey,
@RequestParam(value = "deviceName") String deviceName,
@RequestParam(required = false, value = "fieldKey") String fieldKey,
@RequestParam(value = "current") Integer current,
@RequestParam(value = "size") Integer size);
} }
...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.equipmanage.common.entity.AnalysisReportMonth; import com.yeejoin.equipmanage.common.entity.AnalysisReportMonth;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -22,4 +23,6 @@ public interface AnalysisReportMonthMapper extends BaseMapper<AnalysisReportMont ...@@ -22,4 +23,6 @@ public interface AnalysisReportMonthMapper extends BaseMapper<AnalysisReportMont
* @param systemId 系统id * @param systemId 系统id
*/ */
void insertSystemMonthData(@Param("indexKeySuffix") List<String> suffix, @Param("beginDate") String beginDate, @Param("endDate") String endDate, @Param("systemId") Long systemId); void insertSystemMonthData(@Param("indexKeySuffix") List<String> suffix, @Param("beginDate") String beginDate, @Param("endDate") String endDate, @Param("systemId") Long systemId);
void insertSystemMonthDataTest(@Param("indexKeySuffix") List<String> suffix, @Param("beginDate") String beginDate, @Param("endDate") String endDate, @Param("systemId") Long systemId, @Param("date") Date date, @Param("num") int num);
} }
...@@ -4,6 +4,7 @@ import com.yeejoin.equipmanage.common.entity.AnalysisReportSummary; ...@@ -4,6 +4,7 @@ import com.yeejoin.equipmanage.common.entity.AnalysisReportSummary;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -22,4 +23,5 @@ public interface AnalysisReportSummaryMapper extends BaseMapper<AnalysisReportSu ...@@ -22,4 +23,5 @@ public interface AnalysisReportSummaryMapper extends BaseMapper<AnalysisReportSu
* @param systemId 系统id * @param systemId 系统id
*/ */
void insertSystemMonthSummaryData(@Param("indexKeySuffix") List<String> suffix, @Param("beginDate") String beginDate, @Param("endDate") String endDate, @Param("systemId") Long systemId); void insertSystemMonthSummaryData(@Param("indexKeySuffix") List<String> suffix, @Param("beginDate") String beginDate, @Param("endDate") String endDate, @Param("systemId") Long systemId);
void insertSystemMonthSummaryDataTest(@Param("indexKeySuffix") List<String> suffix, @Param("beginDate") String beginDate, @Param("endDate") String endDate, @Param("systemId") Long systemId, @Param("date") Date date, @Param("num") int num);
} }
...@@ -3,6 +3,8 @@ package com.yeejoin.equipmanage.quartz; ...@@ -3,6 +3,8 @@ package com.yeejoin.equipmanage.quartz;
import com.yeejoin.equipmanage.common.enums.AnalysisReportEnum; import com.yeejoin.equipmanage.common.enums.AnalysisReportEnum;
import com.yeejoin.equipmanage.common.utils.DateUtils; import com.yeejoin.equipmanage.common.utils.DateUtils;
import com.yeejoin.equipmanage.service.IAnalysisReportLogService; import com.yeejoin.equipmanage.service.IAnalysisReportLogService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
...@@ -20,7 +22,7 @@ public class AnalysisReportSchedulerJob { ...@@ -20,7 +22,7 @@ public class AnalysisReportSchedulerJob {
@Autowired @Autowired
private IAnalysisReportLogService iAnalysisReportLogService; private IAnalysisReportLogService iAnalysisReportLogService;
private final Logger log = LoggerFactory.getLogger(AnalysisReportSchedulerJob.class);
/** /**
* 每天凌晨0点-日报生成 * 每天凌晨0点-日报生成
*/ */
...@@ -45,11 +47,12 @@ public class AnalysisReportSchedulerJob { ...@@ -45,11 +47,12 @@ public class AnalysisReportSchedulerJob {
/** /**
* 每月第1天凌晨0-月报生成 * 每月第1天凌晨0-月报生成
*/ */
@Scheduled(cron="${jobs.month.cron}") @Scheduled(cron="0 0 0 1 * ?")
public void monthReport() throws ParseException { public void monthReport() throws ParseException {
Date yestDay = DateUtils.dateAdd(new Date(),-1,false); Date yestDay = DateUtils.dateAdd(new Date(),-1,false);
Date beginDate = DateUtils.getFirstDayOfMonth(yestDay); Date beginDate = DateUtils.getFirstDayOfMonth(yestDay);
Date endDate = DateUtils.getLastDayOfMonth(yestDay); Date endDate = DateUtils.getLastDayOfMonth(yestDay);
log.warn("monthReport报表开始生成");
iAnalysisReportLogService.generateMonthReport(AnalysisReportEnum.MONTH_REPORT,beginDate,endDate); iAnalysisReportLogService.generateMonthReport(AnalysisReportEnum.MONTH_REPORT,beginDate,endDate);
} }
} }
...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService; ...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.yeejoin.equipmanage.common.dto.AnalysisReportLogDto; import com.yeejoin.equipmanage.common.dto.AnalysisReportLogDto;
import com.yeejoin.equipmanage.common.entity.AnalysisReportLog; import com.yeejoin.equipmanage.common.entity.AnalysisReportLog;
import com.yeejoin.equipmanage.common.enums.AnalysisReportEnum; import com.yeejoin.equipmanage.common.enums.AnalysisReportEnum;
import org.springframework.transaction.annotation.Transactional;
import java.text.ParseException; import java.text.ParseException;
import java.util.Date; import java.util.Date;
...@@ -37,6 +38,9 @@ public interface IAnalysisReportLogService extends IService<AnalysisReportLog> { ...@@ -37,6 +38,9 @@ public interface IAnalysisReportLogService extends IService<AnalysisReportLog> {
*/ */
void generateMonthReport(AnalysisReportEnum monthReport, Date beginDate, Date endDate) throws ParseException; void generateMonthReport(AnalysisReportEnum monthReport, Date beginDate, Date endDate) throws ParseException;
void generateMonthReportTest(AnalysisReportEnum reportEnum, Date beginDate, Date endDate, Date now, int num) throws ParseException;
/** /**
* 消防物联报表列表分页查询 * 消防物联报表列表分页查询
* @param page * @param page
......
...@@ -86,6 +86,25 @@ public class AnalysisReportLogServiceImpl extends ServiceImpl<AnalysisReportLogM ...@@ -86,6 +86,25 @@ public class AnalysisReportLogServiceImpl extends ServiceImpl<AnalysisReportLogM
}); });
} }
@Override
@Transactional(rollbackFor = Exception.class)
public void generateMonthReportTest(AnalysisReportEnum reportEnum, Date beginDate, Date endDate,Date now,int num) throws ParseException {
// 0.保存日志
this.saveAnalysisReportLog(reportEnum, beginDate, endDate);
// 创建月分析统计报告数据
// 1、 查询消防系统表,捞出所有系统,新增字段,存放自定义用的告警指标模糊查询指标key,逗号分隔
List<FireFightingSystemEntity> fightingSystemEntityList = fireFightingSystemService.getBaseMapper().selectList(
new LambdaQueryWrapper<FireFightingSystemEntity>()
.isNotNull(FireFightingSystemEntity::getAnalysisIndexKey));
// 2、循环插入 wl_analysis_report_month、wl_analysis_report_summary
String beginDateStr = DateUtils.dateFormat(beginDate,DateUtils.DATE_PATTERN);
String endDateStr = DateUtils.dateFormat(endDate,DateUtils.DATE_PATTERN);
fightingSystemEntityList.forEach(f -> {
analysisReportMonthMapper.insertSystemMonthDataTest(new ArrayList<>(Arrays.asList(f.getAnalysisIndexKey().split(","))), beginDateStr, endDateStr, f.getId(),now,num);
analysisReportSummaryMapper.insertSystemMonthSummaryDataTest(new ArrayList<>(Arrays.asList(f.getAnalysisIndexKey().split(","))), beginDateStr, endDateStr, f.getId(),now,num);
});
}
private void saveAnalysisReportLog(AnalysisReportEnum reportEnum, Date beginDate, Date endDate) { private void saveAnalysisReportLog(AnalysisReportEnum reportEnum, Date beginDate, Date endDate) {
AnalysisReportLog reportLog = new AnalysisReportLog(); AnalysisReportLog reportLog = new AnalysisReportLog();
reportLog.setName(reportEnum.getName()); reportLog.setName(reportEnum.getName());
......
...@@ -168,7 +168,8 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste ...@@ -168,7 +168,8 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
} }
@Override @Override
public List<EquiplistSpecificBySystemVO> getEquiplistBySystemId(Long systemId) { public List<EquiplistSpecificBySystemVO>
getEquiplistBySystemId(Long systemId) {
return this.baseMapper.getEquiplistBySystemId(systemId); return this.baseMapper.getEquiplistBySystemId(systemId);
} }
...@@ -186,14 +187,14 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste ...@@ -186,14 +187,14 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
stb.append(y.getChargePerson()); stb.append(y.getChargePerson());
} }
}); });
Map<String, String> userMap = new HashMap<>(); //此userMap已被注掉 无用代码
/* Map<String, String> userMap = new HashMap<>();
if (StringUtil.isNotEmpty(stb)) { if (StringUtil.isNotEmpty(stb)) {
List<AgencyUserModel> agencyUserModels = remoteSecurityService.listUserByUserIds(stb.toString()); List<AgencyUserModel> agencyUserModels = remoteSecurityService.listUserByUserIds(stb.toString());
agencyUserModels.forEach(z -> { agencyUserModels.forEach(z -> {
userMap.put(z.getUserId(), z.getRealName()); userMap.put(z.getUserId(), z.getRealName());
}); });
} }*/
dataList.forEach(x -> { dataList.forEach(x -> {
// x.setChargePerson(userMap.get(x.getChargePerson())); // x.setChargePerson(userMap.get(x.getChargePerson()));
x.setSystemimg(equipmentManageMapper.getFiles(valueOf(x.getId()), "face")); x.setSystemimg(equipmentManageMapper.getFiles(valueOf(x.getId()), "face"));
......
...@@ -4,7 +4,6 @@ import java.io.InputStream; ...@@ -4,7 +4,6 @@ import java.io.InputStream;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -13,14 +12,11 @@ import javax.servlet.http.HttpServletResponse; ...@@ -13,14 +12,11 @@ import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.spire.ms.System.Collections.Specialized.CollectionsUtil;
import com.yeejoin.amos.boot.module.common.api.dto.*; import com.yeejoin.amos.boot.module.common.api.dto.*;
import com.yeejoin.amos.boot.module.common.api.excel.ExplicitConstraint; import com.yeejoin.amos.boot.module.common.api.excel.ExplicitConstraint;
import com.yeejoin.amos.boot.module.common.api.mapper.OrgUsrMapper; import com.yeejoin.amos.boot.module.common.api.mapper.OrgUsrMapper;
import com.yeejoin.amos.boot.module.common.api.service.*;
import com.yeejoin.amos.boot.module.jcs.api.dto.SignDto; import com.yeejoin.amos.boot.module.jcs.api.dto.SignDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.SinStaticDto;
import io.github.classgraph.json.JSONUtils;
import io.micrometer.core.instrument.util.JsonUtils;
import org.apache.commons.beanutils.ConvertUtils; import org.apache.commons.beanutils.ConvertUtils;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Row;
...@@ -34,6 +30,8 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -34,6 +30,8 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
...@@ -73,12 +71,6 @@ import com.yeejoin.amos.boot.module.common.api.entity.OrgUsr; ...@@ -73,12 +71,6 @@ import com.yeejoin.amos.boot.module.common.api.entity.OrgUsr;
import com.yeejoin.amos.boot.module.common.api.entity.RescueEquipment; import com.yeejoin.amos.boot.module.common.api.entity.RescueEquipment;
import com.yeejoin.amos.boot.module.common.api.entity.SpecialPositionStaff; import com.yeejoin.amos.boot.module.common.api.entity.SpecialPositionStaff;
import com.yeejoin.amos.boot.module.common.api.excel.ExcelUtil; import com.yeejoin.amos.boot.module.common.api.excel.ExcelUtil;
import com.yeejoin.amos.boot.module.common.api.service.IDutyFireFightingService;
import com.yeejoin.amos.boot.module.common.api.service.IDutyFirstAidService;
import com.yeejoin.amos.boot.module.common.api.service.IDutyPersonService;
import com.yeejoin.amos.boot.module.common.api.service.IKeySiteService;
import com.yeejoin.amos.boot.module.common.api.service.IMaintenanceCompanyService;
import com.yeejoin.amos.boot.module.common.api.service.IOrgUsrService;
import com.yeejoin.amos.boot.module.common.biz.service.impl.DutyCarServiceImpl; import com.yeejoin.amos.boot.module.common.biz.service.impl.DutyCarServiceImpl;
import com.yeejoin.amos.boot.module.common.biz.service.impl.DutyPersonServiceImpl; import com.yeejoin.amos.boot.module.common.biz.service.impl.DutyPersonServiceImpl;
import com.yeejoin.amos.boot.module.common.biz.service.impl.DutyPersonShiftServiceImpl; import com.yeejoin.amos.boot.module.common.biz.service.impl.DutyPersonShiftServiceImpl;
...@@ -193,12 +185,15 @@ public class ExcelServiceImpl { ...@@ -193,12 +185,15 @@ public class ExcelServiceImpl {
@Autowired @Autowired
private OrgUsrMapper orgUsrMapper; private OrgUsrMapper orgUsrMapper;
@Autowired
private IDataSyncService dataSyncService;
@Value("${logic}") @Value("${logic}")
Boolean logic; Boolean logic;
@Autowired @Autowired
SignServiceImpl signServiceImpl; SignServiceImpl signServiceImpl;
public void templateExport(HttpServletResponse response, ExcelDto excelDto) throws ClassNotFoundException { public void templateExport(HttpServletResponse response, ExcelDto excelDto) throws ClassNotFoundException {
String url = excelDto.getClassUrl(); String url = excelDto.getClassUrl();
Class<?> clz = Class.forName(url); Class<?> clz = Class.forName(url);
...@@ -207,7 +202,7 @@ public class ExcelServiceImpl { ...@@ -207,7 +202,7 @@ public class ExcelServiceImpl {
} }
public void commonExport(HttpServletResponse response, ExcelDto excelDto, Map par) { public void commonExport(HttpServletResponse response, ExcelDto excelDto, Map par) {
// ReginParams reginParams= getCurrentAllInfo(); // ReginParams reginParams= getCurrentAllInfo();
// boolean authFalg= false; // boolean authFalg= false;
// if(reginParams ==null) { // if(reginParams ==null) {
...@@ -304,7 +299,7 @@ public class ExcelServiceImpl { ...@@ -304,7 +299,7 @@ public class ExcelServiceImpl {
break; break;
} }
String nameString =null; String nameString =null;
Long bizCompanyId =null; Long bizCompanyId =null;
if(par!=null && par.size()>0) { if(par!=null && par.size()>0) {
nameString =par.containsKey("name")?par.get("name").toString():null; nameString =par.containsKey("name")?par.get("name").toString():null;
bizCompanyId =par.containsKey("bizCompanyId")?Long.parseLong(par.get("bizCompanyId").toString()):null; bizCompanyId =par.containsKey("bizCompanyId")?Long.parseLong(par.get("bizCompanyId").toString()):null;
...@@ -940,6 +935,14 @@ public class ExcelServiceImpl { ...@@ -940,6 +935,14 @@ public class ExcelServiceImpl {
// 保存其余项 // 保存其余项
orgUsrExcelDto.setOrgUsrId(orgUsrDto.getSequenceNbr().toString()); orgUsrExcelDto.setOrgUsrId(orgUsrDto.getSequenceNbr().toString());
savePeopleItem(orgUsrExcelDto); savePeopleItem(orgUsrExcelDto);
// 巡检站端与中心级数据同步
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
// 事物提交后业务逻辑
dataSyncService.OrgUsrSyncDtoDataSync(orgUsrDto.getSequenceNbr());
}
});
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -1237,7 +1240,7 @@ public class ExcelServiceImpl { ...@@ -1237,7 +1240,7 @@ public class ExcelServiceImpl {
} }
private void excelImportFireStation(MultipartFile multipartFile) throws Exception { private void excelImportFireStation(MultipartFile multipartFile) throws Exception {
List<FireStationDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, FireStationDto.class, 1); List<FireStationDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, FireStationDto.class, 1);
Map<String, String> maps = getAllBuildingIdForParentBuilingIds(excelDtoList); Map<String, String> maps = getAllBuildingIdForParentBuilingIds(excelDtoList);
List<FireStation> excelEntityList = new ArrayList<>(); List<FireStation> excelEntityList = new ArrayList<>();
...@@ -1570,7 +1573,7 @@ public class ExcelServiceImpl { ...@@ -1570,7 +1573,7 @@ public class ExcelServiceImpl {
redisUtils.set(uuidString, 2); redisUtils.set(uuidString, 2);
} }
} }
} }
private void ImportDutyPerson(MultipartFile multipartFile, String dutyType) throws Exception { private void ImportDutyPerson(MultipartFile multipartFile, String dutyType) throws Exception {
String fileName = multipartFile.getOriginalFilename(); String fileName = multipartFile.getOriginalFilename();
...@@ -1607,7 +1610,7 @@ public class ExcelServiceImpl { ...@@ -1607,7 +1610,7 @@ public class ExcelServiceImpl {
dutyFirstAidService.saveImportData(dataList); dutyFirstAidService.saveImportData(dataList);
} }
} }
} }
private void initDutyFirstAidData(XSSFSheet sheet, List<Map<String, Object>> dataList, List<Date> dayByMonth) { private void initDutyFirstAidData(XSSFSheet sheet, List<Map<String, Object>> dataList, List<Date> dayByMonth) {
for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) { for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
...@@ -1660,7 +1663,7 @@ public class ExcelServiceImpl { ...@@ -1660,7 +1663,7 @@ public class ExcelServiceImpl {
Map<String, Object> dutyPersonDtoMap = Bean.BeantoMap(dutyFirstAidDto); Map<String, Object> dutyPersonDtoMap = Bean.BeantoMap(dutyFirstAidDto);
dataList.add(dutyPersonDtoMap); dataList.add(dutyPersonDtoMap);
} }
} }
private void excelImportSafeReport(MultipartFile multipartFile) throws Exception { private void excelImportSafeReport(MultipartFile multipartFile) throws Exception {
......
...@@ -555,9 +555,6 @@ public class InputItemController extends AbstractBaseController { ...@@ -555,9 +555,6 @@ public class InputItemController extends AbstractBaseController {
if(param.getId()>0){ if(param.getId()>0){
if (param.getEquipmentType()==null && param.getCustomType()==null &&param.getFacilitiesType() == null&&param.getKeyPartsType() == null){
throw new BadRequest("适用类型至少需选择一项");
}
}else{ }else{
if ("1".equals(param.getEquipmentType()) && "1".equals(param.getCustomType()) &&param.getFacilitiesType() == null&&param.getKeyPartsType() == null){ if ("1".equals(param.getEquipmentType()) && "1".equals(param.getCustomType()) &&param.getFacilitiesType() == null&&param.getKeyPartsType() == null){
throw new BadRequest("适用类型至少需选择一项"); throw new BadRequest("适用类型至少需选择一项");
......
...@@ -87,4 +87,90 @@ ...@@ -87,4 +87,90 @@
GROUP BY equipment.code,s.id, equipment.name ORDER BY system_id, code GROUP BY equipment.code,s.id, equipment.name ORDER BY system_id, code
) a) as a1 ) a) as a1
</insert> </insert>
<insert id="insertSystemMonthDataTest">
insert into wl_analysis_report_month
(
system_id,
num,
equipment_name,
equipment_code,
fault_equip_num,
fault_info_num,
alarm_equip_num,
alarm_info_num,
total_info_num,
report_month
)
select
a1.*,
DATE_FORMAT(DATE_SUB(#{date},INTERVAL #{num} day),'%Y-%m')
from
(SELECT
system_id,
num,
name,
code,
(SELECT
count(distinct equipment_specific_id)
FROM wl_equipment_alarm_report_day report
where report.equipment_code = a.code and FIND_IN_SET(a.system_id,report.system_ids)
and report.index_true_num >0
and report.index_type LIKE CONCAT('%','Fault')
and report.report_date >= #{beginDate}
and report.report_date <![CDATA[<=]]> #{endDate}
) as faultEquipNum,
(SELECT IFNULL(sum(report.index_true_num),0)
FROM wl_equipment_alarm_report_day report
where report.equipment_code = a.code and FIND_IN_SET(a.system_id,report.system_ids)
and report.index_type LIKE CONCAT('%','Fault')
and report.report_date >= #{beginDate}
and report.report_date <![CDATA[<=]]> #{endDate}
) as faultInfoNum,
(SELECT count(distinct equipment_specific_id)
FROM wl_equipment_alarm_report_day report
where report.equipment_code = a.code and FIND_IN_SET(a.system_id,report.system_ids)
and report.index_true_num >0
<if test="indexKeySuffix.size() > 0">
and
<foreach collection="indexKeySuffix" item="keySuffix" open="(" close=")" separator="or">
report.index_type LIKE CONCAT('%',#{keySuffix})
</foreach>
</if>
and report.report_date >= #{beginDate}
and report.report_date <![CDATA[<=]]> #{endDate}
) as alarmEquipNum,
(SELECT IFNULL(sum(report.index_true_num),0)
FROM wl_equipment_alarm_report_day report
where report.equipment_code = a.code and FIND_IN_SET(a.system_id,report.system_ids)
<if test="indexKeySuffix.size() > 0">
and
<foreach collection="indexKeySuffix" item="keySuffix" open="(" close=")" separator="or">
report.index_type LIKE CONCAT('%',#{keySuffix})
</foreach>
</if>
and report.report_date >= #{beginDate}
and report.report_date <![CDATA[<=]]> #{endDate}
) as alarmInfoNum,
(SELECT IFNULL(sum(report.index_true_num),0)
FROM wl_equipment_alarm_report_day report
where report.equipment_code = a.code and FIND_IN_SET(a.system_id,report.system_ids)
and report.report_date >= #{beginDate}
and report.report_date <![CDATA[<=]]> #{endDate}
) as totalInfoNum
FROM(
SELECT
s.id as system_id,
equipment.code,
equipment.name,
count(1) AS num
FROM
wl_equipment_specific spec
LEFT JOIN wl_equipment_detail detail ON spec.equipment_detail_id = detail.id
LEFT JOIN wl_equipment equipment ON equipment.id =detail.equipment_id
left join f_fire_fighting_system s on FIND_IN_SET(s.id,spec.system_id)
where spec.system_id <![CDATA[<>]]> '' and s.id = #{systemId}
GROUP BY equipment.code,s.id, equipment.name ORDER BY system_id, code
) a) as a1
</insert>
</mapper> </mapper>
...@@ -180,4 +180,182 @@ ...@@ -180,4 +180,182 @@
) f1 on s.id = f1.system_id ) f1 on s.id = f1.system_id
where s.id = #{systemId} where s.id = #{systemId}
</insert> </insert>
<insert id="insertSystemMonthSummaryDataTest">
insert into
wl_analysis_report_summary (
system_id,
summary_info,
system_name,
report_type,
report_date
)
select
s.id,
CONCAT(s.name,',',#{beginDate},' - ',#{endDate} ,':',CHAR(10),
CONCAT('正常设备',IFNULL(f1.totalNormalEquipNum,0),'台,','正常率:',concat(TRUNCATE(ABS(IFNULL(f1.normalEquipNumPercent,0)*100), 2),'%'),',',
'同比上月',IF(IFNULL(f1.totalNormalEquipNum,0)- IFNULL(f1.lastMonthTotalNormalEquipNum,0) >0 ,'增加','减少'),
if(IFNULL(f1.lastMonthTotalNormalEquipNum,0) = 0 ,'---',CONCAT(TRUNCATE(ABS(IFNULL(f1.totalNormalEquipNum,0)/f1.lastMonthTotalNormalEquipNum -1),2)* 100,'%')),',',CHAR(10)),
CONCAT('故障设备',IFNULL(f1.totalFaultEquipNum,0),'台,','故障率:',concat(TRUNCATE(ABS(IFNULL(f1.faultEquipPercent,0)),2)*100,'%'),',',
'同比上月',IF(IFNULL(f1.totalFaultEquipNum,0)- IFNULL(f1.lastMonthTotalFaultEquipNum,0) >0 ,'增加','减少'),
if(IFNULL(f1.lastMonthTotalFaultEquipNum,0) = 0 ,'---',CONCAT(TRUNCATE(ABS(IFNULL(f1.totalFaultEquipNum,0)/f1.lastMonthTotalFaultEquipNum -1),2)* 100,'%')),',',CHAR(10)),
CONCAT('告警设备',IFNULL(f1.totalAlarmEquipNum,0),'台,',
'同比上月',IF(IFNULL(f1.totalAlarmEquipNum,0)- IFNULL(f1.lastMonthTotalAlarmEquipNum,0) >0 ,'增加','减少'),
if(IFNULL(f1.lastMonthTotalAlarmEquipNum,0) = 0 ,'---',CONCAT(TRUNCATE(ABS(IFNULL(f1.totalAlarmEquipNum,0)/f1.lastMonthTotalAlarmEquipNum -1),2)* 100,'%')),',',CHAR(10)),
CONCAT('告警总数',IFNULL(f1.totalAlarmInfoNum,0),'条,',
'同比上月',IF(IFNULL(f1.totalAlarmInfoNum,0)- IFNULL(f1.lastMonthTotalAlarmInfoNum,0) >0 ,'增加','减少'),
if(IFNULL(f1.lastMonthTotalAlarmInfoNum,0) = 0 ,'---', CONCAT(TRUNCATE(ABS(IFNULL(f1.totalAlarmInfoNum,0)/f1.lastMonthTotalAlarmInfoNum -1),2)* 100,'%'))
,'。')) as content,
s.`name`,
3 as report_type,
#{endDate} as report_date
from
f_fire_fighting_system s
LEFT JOIN
(select
s1.*,
IFNULL(s2.totalAlarmEquipNum,0) as lastMonthTotalAlarmEquipNum,
IFNULL(s2.totalAlarmInfoNum,0) as lastMonthTotalAlarmInfoNum,
IFNULL(s2.totalNormalEquipNum,0) as lastMonthTotalNormalEquipNum,
IFNULL(s2.totalEquipNum,0) as lastMonthTotalEquipNum,
IFNULL(s2.totalFaultEquipNum,0) as lastMonthTotalFaultEquipNum
from
(SELECT
u1.system_id,
IFNULL(sum(num),0) as totalEquipNum,
IFNULL(sum(normalEquipNum),0) as totalNormalEquipNum,
IFNULL(sum(faultEquipNum),0) as totalFaultEquipNum,
IFNULL(sum(alarmEquipNum),0) as totalAlarmEquipNum,
IFNULL(sum(alarmInfoNum),0) as totalAlarmInfoNum,
if(sum(num) > 0,ROUND(sum(normalEquipNum)/sum(num),2), '-') as normalEquipNumPercent,
if(sum(num) > 0,ROUND(sum(faultEquipNum)/sum(num),2), '-') as faultEquipPercent
from
(select
a1.*,
(a1.num - a1.alarmEquipNum) as normalEquipNum
from
(SELECT
system_id,
num,
name,
code,
(SELECT count(distinct equipment_specific_id)
FROM wl_equipment_alarm_report_day report
where report.equipment_code = a.code and FIND_IN_SET(a.system_id,report.system_ids)
and report.index_true_num >0
and report.index_type LIKE CONCAT('%','Fault')
and report.report_date >= #{beginDate}
and report.report_date <![CDATA[<=]]> #{endDate}
) as faultEquipNum,
(SELECT count(distinct equipment_specific_id)
FROM wl_equipment_alarm_report_day report
where report.equipment_code = a.code and FIND_IN_SET(a.system_id,report.system_ids)
<if test="indexKeySuffix.size() > 0">
and
<foreach collection="indexKeySuffix" item="keySuffix" open="(" close=")" separator="or">
report.index_type LIKE CONCAT('%',#{keySuffix})
</foreach>
</if>
and report.index_true_num >0
and report.report_date >= #{beginDate}
and report.report_date <![CDATA[<=]]> #{endDate}
) as alarmEquipNum,
(SELECT IFNULL(sum(report.index_true_num),0)
FROM wl_equipment_alarm_report_day report
where report.equipment_code = a.code and FIND_IN_SET(a.system_id,report.system_ids)
<if test="indexKeySuffix.size() > 0">
and
<foreach collection="indexKeySuffix" item="keySuffix" open="(" close=")" separator="or">
report.index_type LIKE CONCAT('%',#{keySuffix})
</foreach>
</if>
and report.report_date >= #{beginDate}
and report.report_date <![CDATA[<=]]> #{endDate}
) as alarmInfoNum
FROM
(
SELECT
s.id as system_id,
equipment.code,
equipment.name,
count(1) AS num
FROM
wl_equipment_specific spec
LEFT JOIN wl_equipment_detail detail ON spec.equipment_detail_id = detail.id
LEFT JOIN wl_equipment equipment ON equipment.id =detail.equipment_id
left join f_fire_fighting_system s on FIND_IN_SET(s.id,spec.system_id)
where spec.system_id <![CDATA[<>]]> ''
GROUP BY equipment.code,s.id, equipment.name ORDER BY system_id, code
) a) as a1) u1
GROUP BY u1.system_id) s1
LEFT JOIN
(SELECT
u1.system_id,
sum(num) as totalEquipNum,
sum(normalEquipNum) as totalNormalEquipNum,
sum(faultEquipNum) as totalFaultEquipNum,
sum(alarmEquipNum) as totalAlarmEquipNum,
sum(alarmInfoNum) as totalAlarmInfoNum
from
(select
a1.*,
(a1.num - a1.alarmEquipNum) as normalEquipNum
from
(SELECT
system_id,
num,
name,
code,
(SELECT count(distinct equipment_specific_id)
FROM wl_equipment_alarm_report_day report
where report.equipment_code = a.code and FIND_IN_SET(a.system_id,report.system_ids)
and report.index_type LIKE CONCAT('%','Fault')
and report.index_true_num >0
and report.report_date >= DATE_SUB(#{beginDate},INTERVAL 1 MONTH)
and report.report_date <![CDATA[<=]]> DATE_SUB(#{endDate},INTERVAL 1 MONTH)
) as faultEquipNum,
(SELECT count(distinct equipment_specific_id)
FROM wl_equipment_alarm_report_day report
where report.equipment_code = a.code and FIND_IN_SET(a.system_id,report.system_ids)
<if test="indexKeySuffix.size() > 0">
and
<foreach collection="indexKeySuffix" item="keySuffix" open="(" close=")" separator="or">
report.index_type LIKE CONCAT('%',#{keySuffix})
</foreach>
</if>
and report.index_true_num >0
and report.report_date >= DATE_SUB(#{beginDate},INTERVAL 1 MONTH)
and report.report_date <![CDATA[<=]]> DATE_SUB(#{endDate},INTERVAL 1 MONTH)
) as alarmEquipNum,
(SELECT IFNULL(sum(report.index_true_num),0)
FROM wl_equipment_alarm_report_day report
where report.equipment_code = a.code and FIND_IN_SET(a.system_id,report.system_ids)
<if test="indexKeySuffix.size() > 0">
and
<foreach collection="indexKeySuffix" item="keySuffix" open="(" close=")" separator="or">
report.index_type LIKE CONCAT('%',#{keySuffix})
</foreach>
</if>
and report.report_date >= DATE_SUB(#{beginDate},INTERVAL 1 MONTH)
and report.report_date<![CDATA[<=]]> DATE_SUB(#{endDate},INTERVAL 1 MONTH)
) as alarmInfoNum
FROM
(
SELECT
s.id as system_id,
equipment.code,
equipment.name,
count(1) AS num
FROM
wl_equipment_specific spec
LEFT JOIN wl_equipment_detail detail ON spec.equipment_detail_id = detail.id
LEFT JOIN wl_equipment equipment ON equipment.id =detail.equipment_id
left join f_fire_fighting_system s on FIND_IN_SET(s.id,spec.system_id)
where
spec.system_id <![CDATA[<>]]> ''
GROUP BY equipment.code,s.id, equipment.name ORDER BY system_id, code
) a) as a1) u1
GROUP BY u1.system_id) s2 ON s1.system_id = s2.system_id
) f1 on s.id = f1.system_id
where s.id = #{systemId}
</insert>
</mapper> </mapper>
...@@ -4228,7 +4228,7 @@ ...@@ -4228,7 +4228,7 @@
LEFT JOIN wl_equipment_detail detail ON spec.equipment_detail_id = detail.id LEFT JOIN wl_equipment_detail detail ON spec.equipment_detail_id = detail.id
LEFT JOIN wl_equipment equipment ON equipment.id =detail.equipment_id LEFT JOIN wl_equipment equipment ON equipment.id =detail.equipment_id
left join f_fire_fighting_system s on FIND_IN_SET(s.id,spec.system_id) left join f_fire_fighting_system s on FIND_IN_SET(s.id,spec.system_id)
where spec.system_id = #{systemId} and spec.create_date &lt; #{endDate} where FIND_IN_SET(#{systemId} , spec.system_id) and spec.create_date &lt; #{endDate}
GROUP BY code,s.id, name ORDER BY system_id, code ) a) as a1 GROUP BY code,s.id, name ORDER BY system_id, code ) a) as a1
GROUP BY a1.system_id GROUP BY a1.system_id
) as b ) as b
...@@ -4921,7 +4921,7 @@ ...@@ -4921,7 +4921,7 @@
WHEN nowPressure IS NOT NULL WHEN nowPressure IS NOT NULL
AND minLevel IS NOT NULL AND minLevel IS NOT NULL
AND nowPressure - minLevel > 0 THEN AND nowPressure - minLevel >= 0 THEN
'正常' '正常'
WHEN nowPressure IS NOT NULL WHEN nowPressure IS NOT NULL
AND minLevel IS NOT NULL AND minLevel IS NOT NULL
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment