Commit 47c6956d authored by chenzhao's avatar chenzhao

修改bug 给测试提供月报表测试用生成接口

parent 53cd7228
...@@ -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,18 @@ public class ConfigureController extends AbstractBaseController { ...@@ -845,6 +846,18 @@ 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(Date date,int num) throws ParseException {
Date yestDay = DateUtils.dateAdd(date,-num,false);
Date beginDate = DateUtils.getFirstDayOfMonth(yestDay);
Date endDate = DateUtils.getLastDayOfMonth(yestDay);
log.warn("monthReport报表开始生成");
iAnalysisReportLogService.generateMonthReportTest(AnalysisReportEnum.MONTH_REPORT,beginDate,endDate,date,num);
}
@PersonIdentify @PersonIdentify
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/iotWeekReport") @GetMapping(value = "/iotWeekReport")
......
...@@ -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"));
......
...@@ -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>
...@@ -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