sucheng пре 1 година
родитељ
комит
913b1d9e47

+ 12 - 0
cx-safe-check/cx-save-check-common/src/main/java/com/rongwei/sfcommon/sys/dao/AspSafetyDrillProgrammeDao.java

@@ -3,9 +3,12 @@ package com.rongwei.sfcommon.sys.dao;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.rongwe.scentity.domian.*;
 import com.rongwe.scentity.vo.AspSafetyEmergencyDrillPlanVo;
+import com.rongwe.scentity.vo.AspSafetyTeamMemberVo;
+import com.rongwe.scentity.vo.AspSafetyTeamVo;
 import org.apache.ibatis.annotations.Select;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -28,4 +31,13 @@ public interface AspSafetyDrillProgrammeDao extends BaseMapper<AspSafetyDrillPro
 
     @Select("select * from asp_safety_annual_drill_plan_month where DELETED = 0 AND ANNUALDRILLPLANID = #{id}")
     List<AspSafetyAnnualDrillPlanMonth> selectAnnualDrillPlanMonthById(String id);
+
+    @Select("select ID,TEAMNAME AS 'teamName',ORGPOSITION AS 'content' from asp_safety_team where DELETED = 0")
+    List<AspSafetyTeamVo> selectTeam();
+
+    @Select("select TEAMPOSITION AS 'roleName',GROUP_CONCAT(TEAMMEMBERNAME) AS 'name' from asp_safety_team_member where DELETED = 0 AND TEAMID=#{id} GROUP BY TEAMPOSITION")
+    List<AspSafetyTeamMemberVo> selectTeamMemberByTeamId(String id);
+
+    @Select("select GROUP_CONCAT(a.`name`) from (SELECT CONCAT(ITEMNAME,ITEMQTY) as 'name' FROM asp_safety_drill_programme_item where DELETED = 0 AND PROGRAMMEID = #{mainId}) a")
+    String selectEquimentByMainId(String mainId);
 }

+ 7 - 0
cx-safe-check/cx-save-check-common/src/main/java/com/rongwei/sfcommon/sys/service/AspSafetyDrillProgrammeService.java

@@ -5,6 +5,10 @@ import com.rongwe.scentity.domian.AspSafetyDrillProgrammeDo;
 import com.rongwei.rwcommon.base.R;
 
 import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -42,4 +46,7 @@ public interface AspSafetyDrillProgrammeService extends IService<AspSafetyDrillP
     void exportEmergencyDrillPlanWord(String startDate, String endDate, HttpServletResponse response) throws Exception;
 
     void exportAnnualDrillPlanWord(String id, HttpServletResponse response) throws Exception;
+
+    void exportDrillProgramme(String id, HttpServletResponse response) throws Exception;
+
 }

+ 110 - 3
cx-safe-check/cx-save-check-common/src/main/java/com/rongwei/sfcommon/sys/service/impl/AspSafetyDrillProgrammeServiceImpl.java

@@ -10,9 +10,12 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.rongwe.scentity.domian.*;
 import com.rongwe.scentity.vo.AspSafetyEmergencyDrillPlanVo;
+import com.rongwe.scentity.vo.AspSafetyTeamMemberVo;
+import com.rongwe.scentity.vo.AspSafetyTeamVo;
 import com.rongwei.rwadmincommon.system.domain.SysDictDo;
 import com.rongwei.rwadmincommon.system.service.SysDictService;
 import com.rongwei.rwcommon.base.R;
+import com.rongwei.rwcommon.base.exception.CustomException;
 import com.rongwei.rwcommon.utils.SecurityUtil;
 import com.rongwei.rwcommon.utils.StringUtils;
 import com.rongwei.safecommon.utils.CXCommonUtils;
@@ -21,15 +24,14 @@ import com.rongwei.sfcommon.sys.service.AspSafetyDrillProgrammeMsgNotifyRecordSe
 import com.rongwei.sfcommon.sys.service.AspSafetyDrillProgrammeService;
 import com.rongwei.sfcommon.sys.service.AspSafetyEmergencyPlanService;
 import com.rongwei.sfcommon.utils.AsposeWordsUtils;
-import com.rongwei.sfcommon.utils.CommonUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.ClassPathResource;
 import org.springframework.stereotype.Service;
 
 import javax.servlet.http.HttpServletResponse;
 import java.awt.*;
-import java.io.File;
-import java.io.FileOutputStream;
+import java.io.IOException;
 import java.net.URLEncoder;
 import java.util.*;
 import java.util.List;
@@ -529,6 +531,111 @@ public class AspSafetyDrillProgrammeServiceImpl extends ServiceImpl<AspSafetyDri
 
     }
 
+    @Override
+    public void exportDrillProgramme(String mainId, HttpServletResponse response) throws Exception {
+        boolean wordLicense = AsposeWordsUtils.getWordLicense();
+
+        Map<String,Object> map = new HashMap<>();
+        //查询小组表信息
+        List<AspSafetyTeamVo> list = this.baseMapper.selectTeam();
+        //查询小组对应成员信息
+        for (AspSafetyTeamVo item : list) {
+            String id = item.getID();
+            String teamName = item.getTeamName();
+            String content = item.getContent();
+            List<AspSafetyTeamMemberVo> memberList = this.baseMapper.selectTeamMemberByTeamId(id);
+            item.setMemberList(memberList);
+            if(teamName.equals("演练指挥小组")){
+                for (AspSafetyTeamMemberVo vo : memberList) {
+                    String roleName = vo.getRoleName();
+                    String name = vo.getName();
+                    if(roleName.equals("总指挥")){
+                        map.put("item1",name);
+                    }
+                    if(roleName.equals("副总指挥")){
+                        map.put("item2",name);
+                    }
+                    if(roleName.equals("成员")){
+                        map.put("item3",name);
+                    }
+                }
+            }
+            if(teamName.equals("指挥领导小组")){
+                map.put("item4",content);
+            }
+            if(teamName.equals("总指挥")){
+                map.put("item5",content);
+            }
+            if(teamName.equals("副总指挥")){
+                map.put("item6",content);
+            }
+            List<String> teamNameList = new LinkedList<>();
+            teamNameList.add("抢险技术组");
+            teamNameList.add("抢险抢修组");
+            teamNameList.add("医疗救护组");
+            teamNameList.add("监测洗消组");
+            teamNameList.add("消防救援组");
+            teamNameList.add("后勤物资保障组");
+            teamNameList.add("警戒疏散联络组");
+            teamNameList.add("财力保障组");
+            int index = 7;
+            if(teamNameList.contains(teamName)){
+                int i = teamNameList.indexOf(teamName);
+                int startIndex = index + i*4;
+                for (AspSafetyTeamMemberVo vo : memberList) {
+                    String roleName = vo.getRoleName();
+                    String name = vo.getName();
+                    if(roleName.equals("组长")){
+                        map.put("item"+startIndex,name);
+                    }
+                    if(roleName.equals("副组长")){
+                        map.put("item"+(startIndex+1),name);
+                    }
+                    if(roleName.equals("成员")){
+                        map.put("item"+(startIndex+2),name);
+                    }
+                }
+                map.put("item"+(startIndex+3),content);
+            }
+
+        }
+        //主表数据
+        AspSafetyDrillProgrammeDo aspSafetyDrillProgrammeDo = this.baseMapper.selectById(mainId);
+        map.put("PLANNAME",aspSafetyDrillProgrammeDo.getPlanname());
+        map.put("DRILLTIME",DateUtil.format(aspSafetyDrillProgrammeDo.getDrilltime(), "yyyy年MM月dd日 HH时mm分"));
+        map.put("DRILLLOCATION",aspSafetyDrillProgrammeDo.getDrilllocation());
+        map.put("PARTICIPANTNAME",aspSafetyDrillProgrammeDo.getParticipantname());
+        map.put("OBSERVERNAMES",aspSafetyDrillProgrammeDo.getObservernames());
+        map.put("CAMERACREWNAME",aspSafetyDrillProgrammeDo.getCameracrewname());
+
+        map.put("PREPARATION",aspSafetyDrillProgrammeDo.getPreparation());
+        map.put("MOBILIZATIONTRAINING",aspSafetyDrillProgrammeDo.getMobilizationtraining());
+        map.put("DRILLPROCESS",aspSafetyDrillProgrammeDo.getDrillprocess());
+        map.put("EVALUATIONSUMMARY",aspSafetyDrillProgrammeDo.getEvaluationsummary());
+
+        //增加所需器材组装字段(equipments)
+        String equipments = this.baseMapper.selectEquimentByMainId(mainId);
+        map.put("equipments", equipments);
+
+        ClassPathResource classPathResource = new ClassPathResource("template/ExercisePlan.docx");
+
+
+        Document doc = new Document(classPathResource.getInputStream());
+        doc.getMailMerge().setCleanupOptions(MailMergeCleanupOptions.REMOVE_UNUSED_FIELDS);
+        try {
+            doc.getMailMerge().execute(map.keySet().toArray(new String[0]),map.values().toArray());
+            doc.getMailMerge().setCleanupOptions(MailMergeCleanupOptions.REMOVE_EMPTY_TABLE_ROWS);
+            doc.getMailMerge().deleteFields();
+            response.setContentType("application/octet-stream;charset=ISO8859-1");
+            response.setHeader("Content-Disposition", "attachment;filename="+URLEncoder.encode(aspSafetyDrillProgrammeDo.getPlanname()+"演练方案.docx", "UTF-8"));
+            doc.save(response.getOutputStream(), com.aspose.words.SaveFormat.DOCX);
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new CustomException("演练方案导出异常");
+        }
+
+    }
+
     /**
      * 消息提醒
      *

+ 15 - 0
cx-safe-check/cx-save-check-entity/src/main/java/com/rongwe/scentity/vo/AspSafetyTeamMemberVo.java

@@ -0,0 +1,15 @@
+package com.rongwe.scentity.vo;
+
+import lombok.Data;
+
+/**
+ * @author :sc
+ * @since :2024/1/20
+ */
+@Data
+public class AspSafetyTeamMemberVo {
+    //小组职务
+    private String roleName;
+    //姓名
+    private String name;
+}

+ 22 - 0
cx-safe-check/cx-save-check-entity/src/main/java/com/rongwe/scentity/vo/AspSafetyTeamVo.java

@@ -0,0 +1,22 @@
+package com.rongwe.scentity.vo;
+
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author :sc
+ * @since :2024/1/20
+ */
+@Data
+public class AspSafetyTeamVo {
+    //小组主键
+    private String ID;
+    //小组名称
+    private String teamName;
+    //小组职责
+    private String content;
+    //小组成员
+    private List<AspSafetyTeamMemberVo> memberList;
+}

+ 11 - 0
cx-safe-check/cx-save-check-server/src/main/java/com/rongwei/savecheck/controller/AspSafetyDrillProgrammeController.java

@@ -1,11 +1,14 @@
 package com.rongwei.savecheck.controller;
 
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.rongwei.rwcommon.base.R;
 import com.rongwei.sfcommon.sys.service.AspSafetyDrillProgrammeService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -85,5 +88,13 @@ public class AspSafetyDrillProgrammeController {
                                           HttpServletResponse response) throws Exception {
         aspSafetyDrillProgrammeService.exportAnnualDrillPlanWord(id, response);
     }
+
+    /**
+     * 导出演练方案
+     */
+    @PostMapping("/exportDrillProgramme")
+    public void exportDrillProgramme(@RequestParam String id, HttpServletResponse response) throws Exception {
+        aspSafetyDrillProgrammeService.exportDrillProgramme(id, response);
+    }
 }
 

BIN
cx-safe-check/cx-save-check-server/src/main/resources/template/ExercisePlan.docx