Commit bdb57240 authored by KeYong's avatar KeYong

优化联调应急报告

parent 417ccdbc
......@@ -2,7 +2,9 @@ package com.yeejoin.amos.fas.dao.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
......@@ -10,7 +12,6 @@ import java.util.Date;
@Data
@TableName("c_plan_report")
public class PlanReport extends BaseEntity {
private static final long serialVersionUID = 1L;
@TableField("batch_no")
private String batchNo;
......@@ -22,6 +23,8 @@ public class PlanReport extends BaseEntity {
private String title;
@TableField(value = "drill_date")
@JsonFormat(pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date drillDate;
@TableField("address")
......
......@@ -716,6 +716,7 @@ public class ContingencyAction implements CustomerAction {
// 结束预案,更新预案信息表结束时间
contingencyInstanceInfoService.updateEndTimeById(batchNo);
// 生成演练报告
planReportService.createReport(batchNo);
......
......@@ -81,13 +81,13 @@ public class PlanReportController extends BaseController {
@Permission
@ApiOperation(value = "更新", notes = "更新")
@PutMapping(value = "/update")
@PutMapping(value = "/update", produces = "application/json;charset=UTF-8")
public CommonResponse updateReport(@RequestBody PlanReport planReport) {
PlanReport report = iPlanReportService.updateReport(planReport);
return CommonResponseUtil.success(report);
}
@Permission
@ApiOperation(value = "下载报告", notes = "下载报告")
@GetMapping(value = "/download")
public void download(HttpServletRequest request, HttpServletResponse response,
......@@ -95,7 +95,7 @@ public class PlanReportController extends BaseController {
iPlanReportService.download(request, response, id);
}
@Permission
@ApiOperation(value = "预览报告", notes = "预览报告")
@GetMapping(value = "/preview")
public CommonResponse preview(
......
......@@ -21,4 +21,6 @@ public interface PlanReportMapper extends BaseMapper<PlanReport> {
PlanReport getById(@Param("id") Long id);
PlanReport getByBatchNo(@Param("batchNo") String batchNo);
void updateReportById(PlanReport report);
}
......@@ -85,5 +85,14 @@ public interface IContingencyPlanInstanceRepository extends BaseDao<ContingencyP
@Query(value = "SELECT * FROM `contingency_plan_instance` WHERE batch_no = ?1", nativeQuery = true)
List<ContingencyPlanInstance> findByBatchNo(String batchNo);
@Query(value = "SELECT " +
" *" +
" FROM " +
" contingency_plan_instance t" +
" WHERE" +
" t.batch_no = ?" +
" AND (t.record_type = 'MESSAGE' OR ( t.record_type = 'TASKOPERATE' AND t.runstate = true)) " +
" ORDER BY" +
" t.create_date ASC", nativeQuery = true)
List<ContingencyPlanInstance> queryForExecuteInfo(String batch_no);
}
......@@ -196,6 +196,11 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
return categorys;
}
public List<ContingencyPlanInstance> queryForExecuteInfo(String batchNo) {
List<ContingencyPlanInstance> instances = repository.queryForExecuteInfo(batchNo);
return instances;
}
@Transactional
public Optional<Equipment> fire(String batchNo, String stepCode, String contingencyPlanId, String buttonCode, String buttonState, String stepStateOnbutton) throws Exception {
//火灾误报
......
......@@ -117,6 +117,8 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
@Autowired
private IEmergencyTaskService emergencyTaskService;
@Autowired
IPlanReportService planReportService;
@Autowired
public ContingencyPlanServiceImpl(IPlanDetailDao planDetailDao, IPlanDocDao planDocDao, IPlanEquipmentDao planEquipmentDao,
......@@ -825,6 +827,8 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
logger.info("预案重置失败batchNo:{}", batchNo, e);
e.printStackTrace();
}
// 生成演练报告
planReportService.createReport(batchNo);
});
}
......@@ -846,6 +850,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
logger.info("数据同步之消息发送. [method='{}']", "activatePlan==>syncCreatedPlanDetailSyncBo==>syncCreatedPlanOperationRecordSyncBo", e);
}
}
planStepService.initPlanStep();
planStepService.initPlanTask();
} catch (Exception e) {
......
......@@ -6,15 +6,16 @@ import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.component.robot.BadRequest;
import com.yeejoin.amos.fas.business.dao.mapper.PlanReportMapper;
import com.yeejoin.amos.fas.business.dao.repository.IPlanOperationRecordDao;
import com.yeejoin.amos.fas.business.service.intfc.IContingencyInstance;
import com.yeejoin.amos.fas.business.service.intfc.IPlanReportService;
import com.yeejoin.amos.fas.business.util.MyByteArrayMultipartFile;
import com.yeejoin.amos.fas.business.util.StringUtil;
import com.yeejoin.amos.fas.business.util.WordTemplateUtils;
import com.yeejoin.amos.fas.common.enums.WordTemplateTypeEum;
import com.yeejoin.amos.fas.core.util.DateUtil;
import com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance;
import com.yeejoin.amos.fas.dao.entity.PlanOperationRecord;
import com.yeejoin.amos.fas.dao.entity.PlanReport;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import org.apache.http.client.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
......@@ -27,20 +28,22 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.*;
@Service
public class PlanReportServiceImpl extends ServiceImpl<PlanReportMapper, PlanReport> implements IPlanReportService {
private static String firstContent = "";
@Autowired
PlanReportMapper planReportMapper;
@Autowired
private IPlanOperationRecordDao planOperationRecordDao;
@Autowired
private IContingencyInstance iContingencyInstance;
@Override
public void download(HttpServletRequest request, HttpServletResponse response, String id) {
PlanReport report = planReportMapper.getById(Long.valueOf(id));
......@@ -87,16 +90,40 @@ public class PlanReportServiceImpl extends ServiceImpl<PlanReportMapper, PlanRep
public void createReport(String batchNo) {
Assert.notNull(batchNo, "batchNo 不能为空!");
PlanReport report = planReportMapper.getByBatchNo(batchNo);
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
List<ContingencyPlanInstance> list = null;
try {
list = iContingencyInstance.queryForExecuteInfo(batchNo);
firstContent = list.get(0).getContent();
list.remove(0);
} catch (Exception e) {
e.printStackTrace();
}
if (!ObjectUtils.isEmpty(list)) {
StringBuilder builder = new StringBuilder();
list.forEach(instance -> {
if ("MESSAGE".equalsIgnoreCase(instance.getRecordType())){
builder.append(sdf.format(instance.getCreateDate())).append(" ").append(instance.getStartUserName())
.append(":").append(instance.getContent()).append("\n");
} else {
builder.append(sdf.format(instance.getUpdateDate())).append(" ").append(instance.getStartUserName())
.append(":").append(instance.getCategory()).append("\n");
}
});
String str = builder.toString();
str = str.substring(0, str.length() - 1);
report.setHandleProcess(str);
}
String url = preview(report);
report.setReportUrl(url);
planReportMapper.updateById(report);
planReportMapper.updateReportById(report);
}
@Override
public PlanReport updateReport(PlanReport report) {
String url = preview(report);
report.setReportUrl(url);
planReportMapper.updateById(report);
planReportMapper.updateReportById(report);
return report;
}
......@@ -116,7 +143,7 @@ public class PlanReportServiceImpl extends ServiceImpl<PlanReportMapper, PlanRep
Map<String, Object> map = new HashMap<String, Object>();
PlanOperationRecord operationRecord = planOperationRecordDao.findByBatchNo(report.getBatchNo());
SimpleDateFormat dateStat = new SimpleDateFormat("HH:mm");
SimpleDateFormat drillDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat drillDateFormat = new SimpleDateFormat("yyyy-MM-dd");
// 活动主题
map.put("drill_title", report.getTitle());
// 演练时间
......@@ -130,9 +157,10 @@ public class PlanReportServiceImpl extends ServiceImpl<PlanReportMapper, PlanRep
// 演习题目
map.put("drill_topic", report.getDrillTopic());
// 处理过程
map.put("handle_process", report.getHandleProcess());
map.put("handle_process", StringUtil.isNotEmpty(report.getHandleProcess()) ? report.getHandleProcess().replaceAll("\n", "&#10;") : "");
// 预案开始时间
map.put("start_time", dateStat.format(operationRecord.getStartTime()));
map.put("first_content", firstContent);
// 预案结束时间
map.put("end_time", dateStat.format(operationRecord.getEndTime()));
// 演习总结
......
......@@ -14,6 +14,8 @@ public interface IContingencyInstance {
List<ContingencyPlanInstance> queryForTimeLine(String instanceNo,String recordType) throws Exception;
List<ContingencyPlanInstance> queryForExecuteInfo(String batchNo);
void setButtonExecuted(String batchNo,String contingencyPlanId,String code,String buttonState, String user) throws Exception;
void setButtonWait(String batchNo,String contingencyPlanId,String buttonState) throws Exception;
......
......@@ -90,4 +90,27 @@
<select id="getByBatchNo" resultType="com.yeejoin.amos.fas.dao.entity.PlanReport">
select * from c_plan_report where batch_no = #{batchNo}
</select>
<update id="updateReportById">
UPDATE
`c_plan_report`
SET `batch_no` = #{batchNo},
`report_url` = #{reportUrl},
`title` = #{title},
`create_date` = #{createDate},
`drill_date` = #{drillDate},
`address` = #{address},
`compere` = #{compere},
`attend_person` = #{attendPerson},
`drill_topic` = #{drillTopic},
`handle_process` = #{handleProcess},
`drill_summary` = #{drillSummary},
`examine_result` = #{examineResult},
`biz_org_name` = #{bizOrgName},
`biz_org_code` = #{bizOrgCode},
`drill_type` = #{drillType},
`drill_equip` = #{drillEquip},
`drill_equip_id` = #{drillEquipId}
WHERE `id` = #{id};
</update>
</mapper>
\ No newline at end of file
......@@ -1093,7 +1093,7 @@
<w:sz w:val="28"/>
<w:lang w:val="EN-US" w:fareast="ZH-CN"/>
</w:rPr>
<w:t>通过数字站观看起火换流变情况</w:t>
<w:t>${(first_content)!''}</w:t>
</w:r>
</w:p>
<w:p>
......@@ -1114,7 +1114,7 @@
<w:sz w:val="28"/>
<w:lang w:val="EN-US" w:fareast="ZH-CN"/>
</w:rPr>
<w:t>19:06 政府消防官兵到达火灾现场,运行人员和驻站消防队向政府消防队交待着火设备和现场运行设备状况后,现场指挥权移交给政府消防队。</w:t>
<w:t>${(handle_process)!''}</w:t>
</w:r>
</w:p>
<w:p>
......
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