Browse Source

定时任务生成每月的工伤月度报表
查询工伤率报表

sucheng 1 year ago
parent
commit
fc6cf6f44f

+ 83 - 11
cx-safe-check/cx-save-check-common/src/main/java/com/rongwei/sfcommon/sys/dao/AccidentDao.java

@@ -1,6 +1,7 @@
 package com.rongwei.sfcommon.sys.dao;
 
 import com.rongwe.scentity.domian.AccidentDo;
+import com.rongwe.scentity.domian.AspAccidentReport;
 import com.rongwe.scentity.domian.CheckTemplateDo;
 import com.rongwe.scentity.vo.AccidentVo;
 import com.rongwei.rwcommon.base.BaseDao;
@@ -23,29 +24,30 @@ import java.util.Map;
 public interface AccidentDao extends BaseDao<AccidentDo> {
     @Select("SELECT MAX(aa.ACCIDENTCODE) FROM asp_accident aa")
     String getCodeMAx();
+
     @Select("select sfi.FULLPATH from sys_file_item sfi WHERE  sfi.DELETED='0' AND sfi.ID=#{id}")
     AccidentVo getFilePathById(String id);
 
     @Select("   select\n" +
-        "        sfi.FULLPATH\n" +
-        "    from\n" +
-        "        sys_file_item sfi LEFT JOIN\n" +
-        "\t\t\t\tsys_file_folder sff ON sff.ID=sfi.FILEFOLDERID\n" +
-        "\t\t\t\tWHERE sfi.DELETED='0'  AND  sff.FOLDERCODE='accident_word' ORDER BY sfi.MODIFYDATE DESC")
+            "        sfi.FULLPATH\n" +
+            "    from\n" +
+            "        sys_file_item sfi LEFT JOIN\n" +
+            "\t\t\t\tsys_file_folder sff ON sff.ID=sfi.FILEFOLDERID\n" +
+            "\t\t\t\tWHERE sfi.DELETED='0'  AND  sff.FOLDERCODE='accident_word' ORDER BY sfi.MODIFYDATE DESC")
     List<AccidentVo> getFileList();
 
     @Select("select \n" +
-           "(select COUNT(1) from asp_hidden_danger_track where DELETED='0' and YEAR(CREATEDATE)=YEAR(NOW()) and (WARNSTATUS != '过期' or WARNSTATUS is NULL))/(select COUNT(1) from asp_hidden_danger_track where DELETED='0' and YEAR(CREATEDATE)=YEAR(NOW())) AS 'RERATE',\n" +
-           "(select COUNT(1) from asp_hidden_danger_track where DELETED='0' and YEAR(CREATEDATE)=YEAR(NOW()) AND HIDDENDANGERTYPE='20') AS 'ZDCOUNT'")
-    Map<String,Object> getDataXTaskQuato();
+            "(select COUNT(1) from asp_hidden_danger_track where DELETED='0' and YEAR(CREATEDATE)=YEAR(NOW()) and (WARNSTATUS != '过期' or WARNSTATUS is NULL))/(select COUNT(1) from asp_hidden_danger_track where DELETED='0' and YEAR(CREATEDATE)=YEAR(NOW())) AS 'RERATE',\n" +
+            "(select COUNT(1) from asp_hidden_danger_track where DELETED='0' and YEAR(CREATEDATE)=YEAR(NOW()) AND HIDDENDANGERTYPE='20') AS 'ZDCOUNT'")
+    Map<String, Object> getDataXTaskQuato();
 
     @Select("select (select COUNT(DISTINCT EMPID) from training_emp_exam a left join training_plan b on a.PLANID=b.ID " +
             "where a.EXAMSTATUS = '考试通过' and a.DELETED='0' and b.DELETED='0'  and YEAR(b.TRAININGSTARTTIME)=YEAR(NOW()))/(select COUNT(DISTINCT EMPID) " +
             "from training_emp_exam a left join training_plan b on a.PLANID=b.ID where a.DELETED='0' and b.DELETED='0' and YEAR(b.TRAININGSTARTTIME)=YEAR(NOW())) AS 'TRAINRATE'")
-    Map<String,BigDecimal> getDataXtrainRate();
+    Map<String, BigDecimal> getDataXtrainRate();
 
     @Select("select PLANNEDENDTIME from asp_contingency where STATE='1' and DELETED='0' and PARTICULARYEAR = YEAR(NOW())")
-    List<Map<String,Object>> getDataXEmergency();
+    List<Map<String, Object>> getDataXEmergency();
 
     @Select("<script>select COUNT(1) AS 'ACCIDENTCOUNT' from asp_accident " +
             "where DELETED='0' AND DATE_FORMAT(CREATEDATE,'%Y-%m') = DATE_FORMAT(NOW(),'%Y-%m') " +
@@ -53,9 +55,79 @@ public interface AccidentDao extends BaseDao<AccidentDo> {
             "and ACCIDENTTYPE in (${accidenttype})" +
             "</if>" +
             "</script>")
-    Map<String,Long> getDataXKjlAccident(@Param("accidenttype") String accidenttype);
+    Map<String, Long> getDataXKjlAccident(@Param("accidenttype") String accidenttype);
 
     @Select("select (select COUNT(*) AS HASCHECKNUM from asp_point_check where DELETED='0' and CHECKUSERID is not null and YEAR(CREATEDATE) = YEAR(NOW())) / (select COUNT(*) AS TOTALCHECKNUM from asp_point_check where DELETED='0' and YEAR(CREATEDATE) = YEAR(NOW())) AS 'pointCheckRate'")
     Map<String, Double> getDataXPointCheck();
 
+    @Select("SELECT * FROM sys_organization where DELETED = 0 AND PID = '-1'")
+    List<Map<String, String>> selectFactory();
+
+    @Select({"<script>" +
+            "SELECT\n" +
+            "\tso.ID AS 'departid',\n" +
+            "\tso.FULLNAME AS 'departname',\n" +
+            "\tsum(IFNULL( suo.totalPeople, 0 )) AS 'departpeople',\n" +
+            "\tsum(IFNULL( b.count, 0 )) AS 'count',\n" +
+            "\tIFNULL(round( sum( IFNULL( b.count, 0 ))/ sum( IFNULL( suo.totalPeople, 0 ))* 100, 2 ),0.00) AS 'value'\n" +
+            "FROM\n" +
+            "\tsys_organization so\n" +
+            "\tLEFT JOIN sys_organization so2 ON ( ( so2.FULLPID LIKE CONCAT( '%', so.ID, '%' )) OR so2.ID = so.ID ) \n" +
+            "\tAND so2.DELETED = 0\n" +
+            "\tLEFT JOIN (\n" +
+            "\tSELECT\n" +
+            "\t\taa.ACCIDENTDEPT,\n" +
+            "\t\taa.ACCIDENTDEPTNAME,\n" +
+            "\t\tcount( 1 ) AS 'count' \n" +
+            "\tFROM\n" +
+            "\t\tasp_accident aa \n" +
+            "\tWHERE\n" +
+            "\t\taa.DELETED = 0 \n" +
+            "\t\tAND aa.DECLAREJOBINJURED = '1' \n" +
+            "\t\t<if test = 'month != -1'>AND MONTH ( aa.HAPPENDATE ) = #{month}</if> \n" +
+            "\t\tAND YEAR ( aa.HAPPENDATE ) = #{year} \n" +
+            "\t\t<if test = 'tenantId != null and tenantId != \"\"'>AND aa.TENANTID = #{tenantId}</if>\n" +
+            "\tGROUP BY\n" +
+            "\t\taa.ACCIDENTDEPT \n" +
+            "\t) b ON b.ACCIDENTDEPT = so2.ID \n" +
+            "\tAND so.DELETED = 0\n" +
+            "\tLEFT JOIN ( SELECT ORGID, count( 1 ) AS totalPeople FROM sys_user_org WHERE DELETED = 0 GROUP BY ORGID ) suo ON so2.ID = suo.ORGID \n" +
+            "WHERE\n" +
+            "\tso.ORGTYPE = 'chejian' \n" +
+            "\t<if test = 'tenantId != null and tenantId != \"\"'>AND so.FULLPID like CONCAT('%',#{tenantId},'%')</if>\n" +
+            "GROUP BY\n" +
+            "\tso.ID"+
+            "</script>"})
+    List<AspAccidentReport> selectReport(int year, int month, String tenantId);
+
+    @Select({"<script>" +
+            "SELECT\n" +
+            "\t* \n" +
+            "FROM\n" +
+            "\tasp_accident_report \n" +
+            "WHERE\n" +
+            "\tDELETED = 0 \n" +
+            "\tAND `YEAR` = #{year}" +
+            "\t<if test = 'tenantId != null and tenantId != \"\"'>and TENANTID = #{tenantId}</if>" +
+            "</script>"})
+    List<AspAccidentReport> selectReportByYear(Integer year, String tenantId);
+
+    @Select({"<script>" +
+            "SELECT\n" +
+            "\tso.ID AS 'departId',\n" +
+            "\tso.FULLNAME AS 'departName',\n" +
+            "\tCAST(ifnull(sum(suo.totalPeople),0) AS UNSIGNED) AS 'totalPeople'\n" +
+            "FROM\n" +
+            "\tsys_organization so\n" +
+            "\tLEFT JOIN sys_organization so2 ON ( ( so2.FULLPID LIKE CONCAT( '%', so.ID, '%' )) OR so2.ID = so.ID ) \n" +
+            "\tAND so2.DELETED = 0\n" +
+            "\tLEFT JOIN ( SELECT ORGID, count( 1 ) AS totalPeople FROM sys_user_org WHERE DELETED = 0 GROUP BY ORGID ) suo ON so2.ID = suo.ORGID \n" +
+            "WHERE\n" +
+            "\tso.ORGTYPE = 'chejian' \n" +
+            "\t<if test = 'tenantId != null and tenantId != \"\"'>AND so.FULLPID like CONCAT('%',#{tenantId},'%')</if>\n" +
+            "GROUP BY\n" +
+            "\tso.ID" +
+            "</script>"})
+    List<Map<String, Object>> getOrgMap(@Param("tenantId") String tenantId);
+
 }

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

@@ -0,0 +1,8 @@
+package com.rongwei.sfcommon.sys.dao;
+
+import com.rongwe.scentity.domian.AspAccidentReport;
+import com.rongwei.rwcommon.base.BaseDao;
+
+public interface AspAccidentReportDao extends BaseDao<AspAccidentReport> {
+
+}

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

@@ -3,6 +3,7 @@ package com.rongwei.sfcommon.sys.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.rongwe.scentity.domian.AccidentDo;
 import com.rongwe.scentity.vo.AccidentVo;
+import com.rongwe.scentity.vo.AspAccidentReportVo;
 import com.rongwei.rwcommon.base.R;
 
 import java.util.List;
@@ -31,5 +32,8 @@ public interface AccidentService extends IService<AccidentDo> {
 
     List<AccidentVo> getFileList();
 
+    R report();
+
+    List<AspAccidentReportVo> selectReport(Integer year, String tenantId);
 }
 

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

@@ -0,0 +1,16 @@
+package com.rongwei.sfcommon.sys.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.rongwe.scentity.domian.AccidentDo;
+import com.rongwe.scentity.domian.AspAccidentReport;
+import com.rongwe.scentity.vo.AccidentVo;
+import com.rongwei.rwcommon.base.R;
+
+import java.util.List;
+import java.util.Map;
+
+
+public interface AspAccidentReportService extends IService<AspAccidentReport> {
+
+}
+

+ 409 - 72
cx-safe-check/cx-save-check-common/src/main/java/com/rongwei/sfcommon/sys/service/impl/AccidentServiceImpl.java

@@ -1,11 +1,14 @@
 package com.rongwei.sfcommon.sys.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.date.DateUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.rongwe.scentity.domian.*;
 import com.rongwe.scentity.vo.AccidentTrackPlanVo;
 import com.rongwe.scentity.vo.AccidentUserVo;
 import com.rongwe.scentity.vo.AccidentVo;
+import com.rongwe.scentity.vo.AspAccidentReportVo;
 import com.rongwei.commonservice.serial.service.CommonDictService;
 import com.rongwei.commonservice.serial.service.SysSerialNumberService;
 import com.rongwei.rwcommon.base.R;
@@ -18,15 +21,17 @@ import com.rongwei.sfcommon.sys.service.*;
 import com.rongwei.sfcommon.utils.MlConstants;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
-import java.io.File;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.text.DateFormat;
-import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
 import java.util.*;
 
 @Service("accidentService")
-public  class AccidentServiceImpl extends ServiceImpl<AccidentDao, AccidentDo> implements AccidentService {
+public class AccidentServiceImpl extends ServiceImpl<AccidentDao, AccidentDo> implements AccidentService {
 
     @Autowired
     private AccidentService accidentService;
@@ -50,28 +55,30 @@ public  class AccidentServiceImpl extends ServiceImpl<AccidentDao, AccidentDo> i
 
     @Autowired
     private AccidentObjectService accidentObjectService;
+    @Autowired
+    private AspAccidentReportService aspAccidentReportService;
 
 
     @Override
     public R getCode(Map<String, Object> map) {
-        try{
+        try {
             //数据结构适配
-            GeneralApiParameter generalApiParameter = BeanUtil.mapToBeanIgnoreCase(map, GeneralApiParameter.class,true);
+            GeneralApiParameter generalApiParameter = BeanUtil.mapToBeanIgnoreCase(map, GeneralApiParameter.class, true);
             AccidentDo accidentDo = BeanUtil.mapToBeanIgnoreCase(generalApiParameter.getMasterPar(), AccidentDo.class, true);
             //如果是新增,则在订单评价中间表中新增评价项
-            if(accidentDo.getAccidentcode()==null){
+            if (accidentDo.getAccidentcode() == null) {
                 //设置订单流水
                 SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
                 String date = formatter.format(new Date());
                 String code = accidentService.getCodeMAx();
                 AccidentDo accidentDo1 = new AccidentDo();
                 accidentDo1.setId(accidentDo.getId());
-                if(StringUtils.isBlank(code)){
-                    accidentDo1.setAccidentcode(date+"-0001");
-                }else {
+                if (StringUtils.isBlank(code)) {
+                    accidentDo1.setAccidentcode(date + "-0001");
+                } else {
                     String[] split = code.split("-");
-                    int i = Integer.parseInt(split[split.length - 1])+1;
-                    accidentDo1.setAccidentcode(date+"-"+String.format("%04d", i));
+                    int i = Integer.parseInt(split[split.length - 1]) + 1;
+                    accidentDo1.setAccidentcode(date + "-" + String.format("%04d", i));
                 }
                 accidentService.updateById(accidentDo1);
             }
@@ -85,24 +92,25 @@ public  class AccidentServiceImpl extends ServiceImpl<AccidentDao, AccidentDo> i
 
     @Override
     public String getCodeMAx() {
-        return  accidentDao.getCodeMAx();
+        return accidentDao.getCodeMAx();
     }
 
     /**
      * 事故保存后生成隐患跟踪任务
+     *
      * @param map
      */
-    public void createHiddenTask(Map<String,Object> map){
-        if(map.get("ID") != null && !"".equals(map.get("ID"))){
+    public void createHiddenTask(Map<String, Object> map) {
+        if (map.get("ID") != null && !"".equals(map.get("ID"))) {
             String accidenId = map.get("ID").toString();
             AccidentDo accidentDo = this.getById(accidenId);
             // 跟踪计划获取
-            Map<String,Object> parMap = new HashMap<>();
-            parMap.put("ACCIDENTID",accidenId);
-            List<AccidentTrackPlanDo> accidentTrackPlans = (List<AccidentTrackPlanDo>)accidentTrackPlanService.listByMap(parMap);
-            if(accidentTrackPlans != null && accidentTrackPlans.size()>0){
+            Map<String, Object> parMap = new HashMap<>();
+            parMap.put("ACCIDENTID", accidenId);
+            List<AccidentTrackPlanDo> accidentTrackPlans = (List<AccidentTrackPlanDo>) accidentTrackPlanService.listByMap(parMap);
+            if (accidentTrackPlans != null && accidentTrackPlans.size() > 0) {
                 List<HiddenDangerTrackDo> hiddenDangerTracks = new ArrayList<>();
-                accidentTrackPlans.forEach(v->{
+                accidentTrackPlans.forEach(v -> {
                     HiddenDangerTrackDo hiddenDangerTrack = new HiddenDangerTrackDo();
                     hiddenDangerTrack.setId(SecurityUtil.getUUID());
                     hiddenDangerTrack.setFindtime(accidentDo.getHappendate());
@@ -141,7 +149,7 @@ public  class AccidentServiceImpl extends ServiceImpl<AccidentDao, AccidentDo> i
 
     @Override
     public R word(Map<String, Object> map) {
-        String fileName ="";
+        String fileName = "";
         DateFormat format1 = new SimpleDateFormat("yyyy-MM-dd");
         String accidentname = (String) map.get("ACCIDENTNAME");
         //主键
@@ -149,82 +157,82 @@ public  class AccidentServiceImpl extends ServiceImpl<AccidentDao, AccidentDo> i
 
         //发生日期
         String happendate = (String) map.get("HAPPENDATE");
-        if (StringUtils.isNotEmpty(happendate)){
-            map.put("HAPPENDATE",happendate);
+        if (StringUtils.isNotEmpty(happendate)) {
+            map.put("HAPPENDATE", happendate);
             happendate = happendate.substring(0, 10);
         }
 
-        fileName=accidentname+happendate;
+        fileName = accidentname + happendate;
         //报告日期
         String reportdate = (String) map.get("REPORTDATE");
-        if (StringUtils.isNotEmpty(reportdate)){
+        if (StringUtils.isNotEmpty(reportdate)) {
             String format = reportdate.substring(0, 10);
-            map.put("REPORTDATE",format);
+            map.put("REPORTDATE", format);
         }
         //是否受伤人员
-        String  haspeopleinjured = (String) map.get("HASPEOPLEINJURED");
-        if (StringUtils.isNotBlank(haspeopleinjured)){
+        String haspeopleinjured = (String) map.get("HASPEOPLEINJURED");
+        if (StringUtils.isNotBlank(haspeopleinjured)) {
             haspeopleinjured = dictService.getDictNameByValue("YN", haspeopleinjured);
-            map.put("HASPEOPLEINJURED",haspeopleinjured);
+            map.put("HASPEOPLEINJURED", haspeopleinjured);
         }
         //申报工伤
         String declarejobinjured = (String) map.get("DECLAREJOBINJURED");
-        if (StringUtils.isNotBlank(declarejobinjured)){
-           declarejobinjured = dictService.getDictNameByValue("declaration-industrial-injury", declarejobinjured);
-            map.put("DECLAREJOBINJURED",declarejobinjured);
+        if (StringUtils.isNotBlank(declarejobinjured)) {
+            declarejobinjured = dictService.getDictNameByValue("declaration-industrial-injury", declarejobinjured);
+            map.put("DECLAREJOBINJURED", declarejobinjured);
         }
         //财务受损
         String hasfinanceloss = (String) map.get("HASFINANCELOSS");
-        if (StringUtils.isNotBlank(hasfinanceloss)){
+        if (StringUtils.isNotBlank(hasfinanceloss)) {
             hasfinanceloss = dictService.getDictNameByValue("YN", hasfinanceloss);
-            map.put("HASFINANCELOSS",hasfinanceloss);
+            map.put("HASFINANCELOSS", hasfinanceloss);
         }
         //是否厂内
         String isinfactory = (String) map.get("ISINFACTORY");
-        if (StringUtils.isNotBlank(isinfactory)){
+        if (StringUtils.isNotBlank(isinfactory)) {
             isinfactory = dictService.getDictNameByValue("YN", isinfactory);
-            map.put("ISINFACTORY",isinfactory);
+            map.put("ISINFACTORY", isinfactory);
         }
         //事故类型
         String accidenttype = (String) map.get("ACCIDENTTYPE");
-        if (StringUtils.isNotBlank(accidenttype)){
+        if (StringUtils.isNotBlank(accidenttype)) {
             accidenttype = dictService.getDictNameByValue("accident-type", accidenttype);
-            map.put("ACCIDENTTYPE",accidenttype);
+            map.put("ACCIDENTTYPE", accidenttype);
         }
 
 
         //事故受伤员工表
         List<AccidentUserVo> UserList = accidentUserService.getByAccidentId(id);
-        if (UserList.size()>0){
-            for (int i=0;i<UserList.size();i++){
+        if (UserList.size() > 0) {
+            for (int i = 0; i < UserList.size(); i++) {
                 //出生日期
                 Date birthdate = UserList.get(i).getBirthdate();
-                if (birthdate!=null){
+                if (birthdate != null) {
                     String format = format1.format(birthdate);
                     UserList.get(i).setBirthdatestring(format);
                 }
                 //	入职日期
                 Date entrydate = UserList.get(i).getEntrydate();
-                if (entrydate!=null){
+                if (entrydate != null) {
                     String format = format1.format(entrydate);
                     UserList.get(i).setEntrydatestring(format);
                 }
                 //是否加班
                 String hasworkovertime = UserList.get(i).getHasworkovertime();
-                if (StringUtils.isNotBlank(hasworkovertime)){
+                if (StringUtils.isNotBlank(hasworkovertime)) {
                     hasworkovertime = dictService.getDictNameByValue("YN", hasworkovertime);
                     UserList.get(i).setHasworkovertime(hasworkovertime);
                 }
 
                 //受伤部位 injuredsite
                 String injuredsite = UserList.get(i).getInjuredsite();
-                if (StringUtils.isNotBlank(injuredsite)){
+                if (StringUtils.isNotBlank(injuredsite)) {
                     injuredsite = dictService.getDictNameByValue("Injured-site", injuredsite);
                     UserList.get(i).setInjuredsite(injuredsite);
                 }
                 //受伤程度 DEGREEOFINJURY
                 String degreeofinjury = UserList.get(i).getDegreeofinjury();
-                if (StringUtils.isNotBlank(degreeofinjury)){
+                if (StringUtils.isNotBlank(degreeofinjury)) {
                     degreeofinjury = dictService.getDictNameByValue("injury-degree", degreeofinjury);
                     UserList.get(i).setDegreeofinjury(degreeofinjury);
                 }
@@ -235,63 +243,63 @@ public  class AccidentServiceImpl extends ServiceImpl<AccidentDao, AccidentDo> i
         List<AccidentObjectDo> accidentObjectDoList = accidentObjectService.getByAccidentId(id);
 
         //事故跟踪计划表
-        List<AccidentTrackPlanVo> accidentTrackPlanVoList =  accidentTrackPlanService.getByAccidentId(id);
-        if (accidentTrackPlanVoList.size()>0){
-            for (int i=0;i<accidentTrackPlanVoList.size();i++){
+        List<AccidentTrackPlanVo> accidentTrackPlanVoList = accidentTrackPlanService.getByAccidentId(id);
+        if (accidentTrackPlanVoList.size() > 0) {
+            for (int i = 0; i < accidentTrackPlanVoList.size(); i++) {
                 //开始日期
                 Date startdate = accidentTrackPlanVoList.get(i).getStartdate();
-                if (startdate!=null){
+                if (startdate != null) {
                     String format = format1.format(startdate);
                     accidentTrackPlanVoList.get(i).setStartdatestring(format);
                 }
                 //预计完成日期 expectedfinishdate
                 Date expectedfinishdate = accidentTrackPlanVoList.get(i).getExpectedfinishdate();
-                if (expectedfinishdate!=null){
+                if (expectedfinishdate != null) {
                     String format = format1.format(expectedfinishdate);
                     accidentTrackPlanVoList.get(i).setExpectedfinishdatestring(format);
                 }
                 //实际完成日期
                 Date finishdate = accidentTrackPlanVoList.get(i).getFinishdate();
-                if (finishdate!=null){
+                if (finishdate != null) {
                     String format = format1.format(finishdate);
                     accidentTrackPlanVoList.get(i).setFinishdatestring(format);
                 }
 
             }
         }
-        map.put("UserList",UserList);
-        map.put("accidentObjectDoList",accidentObjectDoList);
-        map.put("accidentTrackPlanVoList",accidentTrackPlanVoList);
+        map.put("UserList", UserList);
+        map.put("accidentObjectDoList", accidentObjectDoList);
+        map.put("accidentTrackPlanVoList", accidentTrackPlanVoList);
 
         //图片处理
         List<AccidentVo> imageList = new ArrayList();
         String accidentphoto = (String) map.get("ACCIDENTPHOTO");
-        if (StringUtils.isNotEmpty(accidentphoto)){
+        if (StringUtils.isNotEmpty(accidentphoto)) {
             String[] split = accidentphoto.split("\\^_\\^");  //多个图片切割
-            for (int i=0;i<split.length;i++){
+            for (int i = 0; i < split.length; i++) {
                 String[] split1 = split[i].split("-;-");  //单图片切割
                 String fileId = split1[1];
-               AccidentVo Path = accidentService.getFilePathById(fileId);
+                AccidentVo Path = accidentService.getFilePathById(fileId);
                 String data = Path.getFullpath();
-                if (StringUtils.isNotEmpty(data)){
-             try {
-                 String imageBase = wordExportUtil.getImageBase(data);
-                 AccidentVo accidentVo = new AccidentVo();
-                 accidentVo.setReplace(data);
-                 accidentVo.setImageBase(imageBase);
-                 imageList.add(i,accidentVo);
-             } catch (Exception e) {
-                 e.printStackTrace();
-             }
-         }
-         }
+                if (StringUtils.isNotEmpty(data)) {
+                    try {
+                        String imageBase = wordExportUtil.getImageBase(data);
+                        AccidentVo accidentVo = new AccidentVo();
+                        accidentVo.setReplace(data);
+                        accidentVo.setImageBase(imageBase);
+                        imageList.add(i, accidentVo);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                }
+            }
         }
-        map.put("imageList",imageList);
+        map.put("imageList", imageList);
         List<AccidentVo> fileList = accidentService.getFileList();
-        if (fileList.size()>0){
+        if (fileList.size() > 0) {
             String fullpath = fileList.get(0).getFullpath();
-            if (StringUtils.isNotEmpty(fullpath)){
-                wordExportUtil.createDoc(map, fullpath, fileName+".doc");
+            if (StringUtils.isNotEmpty(fullpath)) {
+                wordExportUtil.createDoc(map, fullpath, fileName + ".doc");
             }
         }
         return R.ok(fileName);
@@ -307,5 +315,334 @@ public  class AccidentServiceImpl extends ServiceImpl<AccidentDao, AccidentDo> i
         return accidentDao.getFileList();
     }
 
+    @Override
+    @Transactional
+    public R report() {
+        //============查询工厂,按照工厂进行分类查询=================
+        //获取上一个月的年份和月份
+        LocalDateTime lastMonth = DateUtil.toLocalDateTime(DateUtil.offsetMonth(DateUtil.date(), -1));
+        int year = lastMonth.getYear();
+        int month = lastMonth.getMonthValue();
+        //防止重复执行,生成报表前,删除原数据
+        aspAccidentReportService.remove(new QueryWrapper<AspAccidentReport>().lambda().eq(AspAccidentReport::getYear, year).eq(AspAccidentReport::getMonth, month));
+
+        //从组织机构中获取最上级的工厂,即pid=-1的
+        List<Map<String, String>> factoryList = this.baseMapper.selectFactory();
+        factoryList.forEach(item -> {
+            //============根据工厂查询前一个月的事故数据,按部门/车间统计===================
+            //获取工厂的ID
+            String tenantId = item.get("ID");
+            List<AspAccidentReport> list = handleData(year, month, tenantId);
+
+            //============数据保存==============
+            aspAccidentReportService.saveBatch(list);
+        });
+
+        return R.ok();
+    }
+
+    private List<AspAccidentReport> handleData(int year, int month, String tenantId) {
+        //统计数据
+        List<AspAccidentReport> list = this.baseMapper.selectReport(year, month, tenantId);
+        //计算月合计
+        Integer valueTotal = 0;
+        Integer peopleTotal = 0;
+        for (AspAccidentReport aspAccidentReport : list) {
+            //设值基础数据
+            aspAccidentReport.setDeleted("0");
+            aspAccidentReport.setCreatedate(new Date());
+            aspAccidentReport.setModifydate(new Date());
+            aspAccidentReport.setId(SecurityUtil.getUUID());
+
+            //设值年
+            aspAccidentReport.setYear(year);
+            //设值月
+            aspAccidentReport.setMonth(month);
+            //设值工厂ID
+            aspAccidentReport.setTenantid(tenantId);
+            //设值加上百分号
+            aspAccidentReport.setValue(aspAccidentReport.getValue() + "%");
+            //计算总工伤数
+            valueTotal += aspAccidentReport.getCount();
+            //计算总人数
+            peopleTotal += aspAccidentReport.getDepartpeople();
+        }
+        //计算月合计
+        double v = 0.00;
+        if(peopleTotal != 0){
+            v = (valueTotal * 1.0000 / peopleTotal * 1.0000) * 100.0000;
+        }
+        String monthTotal;
+        if(v == 0.00){
+            monthTotal = "0.00%";
+        }else {
+            monthTotal = BigDecimal.valueOf(v).setScale(2, RoundingMode.HALF_UP).toString() + "%";
+        }
+        for (AspAccidentReport aspAccidentReport : list) {
+            //设值月合计
+            aspAccidentReport.setMonthtotal(monthTotal);
+        }
+        return list;
+    }
+
+    @Override
+    public List<AspAccidentReportVo> selectReport(Integer year, String tenantId) {
+        List<AspAccidentReportVo> res = new LinkedList<>();
+        //=============查询已生成报表的部分=============
+        List<AspAccidentReport> list = this.baseMapper.selectReportByYear(year, tenantId);
+
+        //=============查询未生成报表的部分=============
+        //获取当前的年月
+        LocalDateTime lastMonth = DateUtil.toLocalDateTime(DateUtil.date());
+        int nowYear = lastMonth.getYear();
+        int nowMonth = lastMonth.getMonthValue();
+        //判断查询的是否是当前年,如果不是当前年,跳过此处数据处理
+        if(year.equals(nowYear)){
+            //===========判断当前月份,需要重新处理当前月份的统计数据
+            //查询当前月份的报表数据(实时)
+            //统计数据
+            List<AspAccidentReport> aspAccidentReportList = handleData(nowYear, nowMonth, tenantId);
+            //=================合并报表===========
+            list.addAll(aspAccidentReportList);
+        }
+
+        //先初始化map
+        //查询所有车间和车间的员工人数
+        List<Map<String, Object>> orgMap = this.baseMapper.getOrgMap(tenantId);
+        //组装map《部门ID,报表数据》
+        Map<String, AspAccidentReportVo> map = new HashMap<>();
+        for (Map<String, Object> stringStringMap : orgMap) {
+            AspAccidentReportVo aspAccidentReportVo = new AspAccidentReportVo();
+            aspAccidentReportVo.setDepartId(stringStringMap.get("departId").toString());
+            aspAccidentReportVo.setDepartName(stringStringMap.get("departName").toString());
+            aspAccidentReportVo.setDepartPeople(Integer.parseInt(stringStringMap.get("totalPeople").toString()));
+            map.put(stringStringMap.get("departId").toString(), aspAccidentReportVo);
+        }
+
+        for (AspAccidentReport item : list) {
+            Integer month = item.getMonth();
+            if(month == 1){
+                if(!map.containsKey(item.getDepartid())){
+                    AspAccidentReportVo aspAccidentReportVo = new AspAccidentReportVo();
+                    aspAccidentReportVo.setDepartId(item.getDepartid());
+                    aspAccidentReportVo.setDepartName(item.getDepartname());
+                    aspAccidentReportVo.setCount1(item.getValue());
+                    map.put(item.getDepartid(), aspAccidentReportVo);
+                }else {
+                    AspAccidentReportVo aspAccidentReportVo = map.get(item.getDepartid());
+                    aspAccidentReportVo.setCount1(item.getValue());
+                    map.put(item.getDepartid(), aspAccidentReportVo);
+                }
+            }
+            if(month == 2){
+                if(!map.containsKey(item.getDepartid())){
+                    AspAccidentReportVo aspAccidentReportVo = new AspAccidentReportVo();
+                    aspAccidentReportVo.setDepartId(item.getDepartid());
+                    aspAccidentReportVo.setDepartName(item.getDepartname());
+                    aspAccidentReportVo.setCount2(item.getValue());
+                    map.put(item.getDepartid(), aspAccidentReportVo);
+                }else {
+                    AspAccidentReportVo aspAccidentReportVo = map.get(item.getDepartid());
+                    aspAccidentReportVo.setCount2(item.getValue());
+                    map.put(item.getDepartid(), aspAccidentReportVo);
+                }
+            }
+            if(month == 3){
+                if(!map.containsKey(item.getDepartid())){
+                    AspAccidentReportVo aspAccidentReportVo = new AspAccidentReportVo();
+                    aspAccidentReportVo.setDepartId(item.getDepartid());
+                    aspAccidentReportVo.setDepartName(item.getDepartname());
+                    aspAccidentReportVo.setCount3(item.getValue());
+                    map.put(item.getDepartid(), aspAccidentReportVo);
+                }else {
+                    AspAccidentReportVo aspAccidentReportVo = map.get(item.getDepartid());
+                    aspAccidentReportVo.setCount3(item.getValue());
+                    map.put(item.getDepartid(), aspAccidentReportVo);
+                }
+            }
+            if(month == 4){
+                if(!map.containsKey(item.getDepartid())){
+                    AspAccidentReportVo aspAccidentReportVo = new AspAccidentReportVo();
+                    aspAccidentReportVo.setDepartId(item.getDepartid());
+                    aspAccidentReportVo.setDepartName(item.getDepartname());
+                    aspAccidentReportVo.setCount4(item.getValue());
+                    map.put(item.getDepartid(), aspAccidentReportVo);
+                }else {
+                    AspAccidentReportVo aspAccidentReportVo = map.get(item.getDepartid());
+                    aspAccidentReportVo.setCount4(item.getValue());
+                    map.put(item.getDepartid(), aspAccidentReportVo);
+                }
+            }
+            if(month == 5){
+                if(!map.containsKey(item.getDepartid())){
+                    AspAccidentReportVo aspAccidentReportVo = new AspAccidentReportVo();
+                    aspAccidentReportVo.setDepartId(item.getDepartid());
+                    aspAccidentReportVo.setDepartName(item.getDepartname());
+                    aspAccidentReportVo.setCount5(item.getValue());
+                    map.put(item.getDepartid(), aspAccidentReportVo);
+                }else {
+                    AspAccidentReportVo aspAccidentReportVo = map.get(item.getDepartid());
+                    aspAccidentReportVo.setCount5(item.getValue());
+                    map.put(item.getDepartid(), aspAccidentReportVo);
+                }
+            }
+            if(month == 6){
+                if(!map.containsKey(item.getDepartid())){
+                    AspAccidentReportVo aspAccidentReportVo = new AspAccidentReportVo();
+                    aspAccidentReportVo.setDepartId(item.getDepartid());
+                    aspAccidentReportVo.setDepartName(item.getDepartname());
+                    aspAccidentReportVo.setCount6(item.getValue());
+                    map.put(item.getDepartid(), aspAccidentReportVo);
+                }else {
+                    AspAccidentReportVo aspAccidentReportVo = map.get(item.getDepartid());
+                    aspAccidentReportVo.setCount6(item.getValue());
+                    map.put(item.getDepartid(), aspAccidentReportVo);
+                }
+            }
+            if(month == 7){
+                if(!map.containsKey(item.getDepartid())){
+                    AspAccidentReportVo aspAccidentReportVo = new AspAccidentReportVo();
+                    aspAccidentReportVo.setDepartId(item.getDepartid());
+                    aspAccidentReportVo.setDepartName(item.getDepartname());
+                    aspAccidentReportVo.setCount7(item.getValue());
+                    map.put(item.getDepartid(), aspAccidentReportVo);
+                }else {
+                    AspAccidentReportVo aspAccidentReportVo = map.get(item.getDepartid());
+                    aspAccidentReportVo.setCount7(item.getValue());
+                    map.put(item.getDepartid(), aspAccidentReportVo);
+                }
+            }
+            if(month == 8){
+                if(!map.containsKey(item.getDepartid())){
+                    AspAccidentReportVo aspAccidentReportVo = new AspAccidentReportVo();
+                    aspAccidentReportVo.setDepartId(item.getDepartid());
+                    aspAccidentReportVo.setDepartName(item.getDepartname());
+                    aspAccidentReportVo.setCount8(item.getValue());
+                    map.put(item.getDepartid(), aspAccidentReportVo);
+                }else {
+                    AspAccidentReportVo aspAccidentReportVo = map.get(item.getDepartid());
+                    aspAccidentReportVo.setCount8(item.getValue());
+                    map.put(item.getDepartid(), aspAccidentReportVo);
+                }
+            }
+            if(month == 9){
+                if(!map.containsKey(item.getDepartid())){
+                    AspAccidentReportVo aspAccidentReportVo = new AspAccidentReportVo();
+                    aspAccidentReportVo.setDepartId(item.getDepartid());
+                    aspAccidentReportVo.setDepartName(item.getDepartname());
+                    aspAccidentReportVo.setCount9(item.getValue());
+                    map.put(item.getDepartid(), aspAccidentReportVo);
+                }else {
+                    AspAccidentReportVo aspAccidentReportVo = map.get(item.getDepartid());
+                    aspAccidentReportVo.setCount9(item.getValue());
+                    map.put(item.getDepartid(), aspAccidentReportVo);
+                }
+            }
+            if(month == 10){
+                if(!map.containsKey(item.getDepartid())){
+                    AspAccidentReportVo aspAccidentReportVo = new AspAccidentReportVo();
+                    aspAccidentReportVo.setDepartId(item.getDepartid());
+                    aspAccidentReportVo.setDepartName(item.getDepartname());
+                    aspAccidentReportVo.setCount10(item.getValue());
+                    map.put(item.getDepartid(), aspAccidentReportVo);
+                }else {
+                    AspAccidentReportVo aspAccidentReportVo = map.get(item.getDepartid());
+                    aspAccidentReportVo.setCount10(item.getValue());
+                    map.put(item.getDepartid(), aspAccidentReportVo);
+                }
+            }
+            if(month == 11){
+                if(!map.containsKey(item.getDepartid())){
+                    AspAccidentReportVo aspAccidentReportVo = new AspAccidentReportVo();
+                    aspAccidentReportVo.setDepartId(item.getDepartid());
+                    aspAccidentReportVo.setDepartName(item.getDepartname());
+                    aspAccidentReportVo.setCount11(item.getValue());
+                    map.put(item.getDepartid(), aspAccidentReportVo);
+                }else {
+                    AspAccidentReportVo aspAccidentReportVo = map.get(item.getDepartid());
+                    aspAccidentReportVo.setCount11(item.getValue());
+                    map.put(item.getDepartid(), aspAccidentReportVo);
+                }
+            }
+            if(month == 12){
+                if(!map.containsKey(item.getDepartid())){
+                    AspAccidentReportVo aspAccidentReportVo = new AspAccidentReportVo();
+                    aspAccidentReportVo.setDepartId(item.getDepartid());
+                    aspAccidentReportVo.setDepartName(item.getDepartname());
+                    aspAccidentReportVo.setCount12(item.getValue());
+                    map.put(item.getDepartid(), aspAccidentReportVo);
+                }else {
+                    AspAccidentReportVo aspAccidentReportVo = map.get(item.getDepartid());
+                    aspAccidentReportVo.setCount12(item.getValue());
+                    map.put(item.getDepartid(), aspAccidentReportVo);
+                }
+            }
+        }
+
+        //=============根据最终结果的部门和计算合计====================
+        //合计的合计
+        String totalOfTotal = "";
+
+        //传入月为-1表示查询整年的数据
+        List<AspAccidentReport> aspAccidentReportAll = handleData(year, -1, tenantId);
+        for (AspAccidentReport item : aspAccidentReportAll) {
+            String departId = item.getDepartid();
+            AspAccidentReportVo aspAccidentReportVo = map.get(departId);
+            aspAccidentReportVo.setCountAll(item.getValue());
+            totalOfTotal = item.getMonthtotal();
+        }
+
+        //=============结果赋值===============
+        List<AspAccidentReportVo> resList = new LinkedList<>();
+        for (Map.Entry<String, AspAccidentReportVo> entry : map.entrySet()) {
+            resList.add(entry.getValue());
+        }
+        //下方的合计
+        AspAccidentReportVo downTotal = new AspAccidentReportVo();
+        downTotal.setDepartName("合计");
+        downTotal.setCountAll(totalOfTotal);
+        for (AspAccidentReport item : list) {
+            Integer month = item.getMonth();
+            String monthTotal = item.getMonthtotal();
+            if(month == 1){
+                downTotal.setCount1(monthTotal);
+            }
+            if(month == 2){
+                downTotal.setCount2(monthTotal);
+            }
+            if(month ==3){
+                downTotal.setCount3(monthTotal);
+            }
+            if(month == 4){
+                downTotal.setCount4(monthTotal);
+            }
+            if(month == 5){
+                downTotal.setCount5(monthTotal);
+            }
+            if(month == 6){
+                downTotal.setCount6(monthTotal);
+            }
+            if(month == 7){
+                downTotal.setCount7(monthTotal);
+            }
+            if(month == 8){
+                downTotal.setCount8(monthTotal);
+            }
+            if(month == 9){
+                downTotal.setCount9(monthTotal);
+            }
+            if(month == 10){
+                downTotal.setCount10(monthTotal);
+            }
+            if(month == 11){
+                downTotal.setCount11(monthTotal);
+            }
+            if(month == 12){
+                downTotal.setCount12(monthTotal);
+            }
+        }
+        resList.add(downTotal);
+        return resList;
+    }
 
 }

+ 13 - 0
cx-safe-check/cx-save-check-common/src/main/java/com/rongwei/sfcommon/sys/service/impl/AspAccidentReportServiceImpl.java

@@ -0,0 +1,13 @@
+package com.rongwei.sfcommon.sys.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.rongwe.scentity.domian.AspAccidentReport;
+import com.rongwei.sfcommon.sys.dao.AspAccidentReportDao;
+import com.rongwei.sfcommon.sys.service.AspAccidentReportService;
+import org.springframework.stereotype.Service;
+
+@Service
+public  class AspAccidentReportServiceImpl extends ServiceImpl<AspAccidentReportDao, AspAccidentReport> implements AspAccidentReportService {
+
+
+}

+ 125 - 3
cx-safe-check/cx-save-check-entity/src/main/java/com/rongwe/scentity/domian/AccidentDo.java

@@ -25,104 +25,226 @@ public class AccidentDo extends BaseDo implements Serializable {
 	/**
 	 * 主键
 	 */
-	@TableId
 	private String id;
+
 	/**
 	 * 编号
 	 */
 	private String accidentcode;
+
 	/**
 	 * 名称
 	 */
 	private String accidentname;
+
 	/**
 	 * 事故部门
 	 */
 	private String accidentdept;
+
 	/**
 	 * 事故部门名称
 	 */
 	private String accidentdeptname;
+
 	/**
 	 * 事故地点
 	 */
 	private String accidentplace;
+
 	/**
 	 * 是否在厂内
 	 */
 	private String isinfactory;
+
 	/**
 	 * 发生日期
 	 */
 	private Date happendate;
+
 	/**
 	 * 报告日期
 	 */
 	private Date reportdate;
+
 	/**
 	 * 是否人员受伤
 	 */
 	private String haspeopleinjured;
+
 	/**
 	 * 申报工伤
 	 */
 	private String declarejobinjured;
+
 	/**
 	 * 是否财务受损
 	 */
 	private String hasfinanceloss;
+
 	/**
 	 * 导致事故发生的物体
 	 */
 	private String accidentsource;
+
 	/**
 	 * 事故发生物体负责人ID
 	 */
 	private String accidentsourcechargerid;
+
 	/**
 	 * 事故发生物体负责人名称
 	 */
 	private String accidentsourcechargername;
+
 	/**
 	 * 目击者ID
 	 */
 	private String witnessid;
+
 	/**
 	 * 目击者名称
 	 */
 	private String witnessname;
+
 	/**
 	 * 事故类型
 	 */
 	private String accidenttype;
+
 	/**
 	 * 问题经过
 	 */
 	private String problemcourse;
+
 	/**
-	 * 原因分析
+	 * 直接原因分析
 	 */
 	private String causeanalysis;
+
+	/**
+	 * 间接原因分析
+	 */
+	private String indirectcauseanalysis;
+
+	/**
+	 * 根本原因分析
+	 */
+	private String basiccauseanalysis;
+
 	/**
 	 * 照片
 	 */
 	private String accidentphoto;
+
 	/**
 	 * 租户ID
 	 */
-	@TableField(value = "TENANTID", fill = FieldFill.INSERT)
 	private String tenantid;
+
 	/**
 	 * 扩展json格式配置
 	 */
 	private String roption;
+
+	/**
+	 * 是否删除Y/N
+	 */
+	private String deleted;
+
+	/**
+	 * 备注
+	 */
+	private String remark;
+
+	/**
+	 * 创建时间
+	 */
+	private Date createdate;
+
+	/**
+	 * 创建用户ID
+	 */
+	private String createuserid;
+
+	/**
+	 * 修改日期
+	 */
+	private Date modifydate;
+
+	/**
+	 * 修改用户ID
+	 */
+	private String modifyuserid;
+
 	/**
 	 * 创建人名称
 	 */
 	private String createusername;
+
 	/**
 	 * 修改人名称
 	 */
 	private String modifyusername;
 
+	/**
+	 * 岗位
+	 */
+	private String post;
+
+	/**
+	 * 违章人员姓名
+	 */
+	private String nameofviolator;
+
+	/**
+	 * 所在班组
+	 */
+	private String workteam;
+
+	/**
+	 * 班组长
+	 */
+	private String teamleader;
+
+	/**
+	 * 违章人员入职时间
+	 */
+	private Date entrydateofviolator;
+
+	/**
+	 * 违章人员调动情况
+	 */
+	private String moveofviolator;
+
+	/**
+	 * 班组长询问情况
+	 */
+	private String askteamleader;
+
+	/**
+	 * 安全员询问情况
+	 */
+	private String asksafetyofficer;
+
+	/**
+	 * 工序负责人询问情况
+	 */
+	private String askprocessleader;
+
+	/**
+	 * 其他人员询问情况
+	 */
+	private String askothers;
+
+	/**
+	 * 是否涉险
+	 */
+	private String isdanger;
+
+	/**
+	 * 所在班组ID
+	 */
+	private String workitemid;
+
 }

+ 109 - 0
cx-safe-check/cx-save-check-entity/src/main/java/com/rongwe/scentity/domian/AspAccidentReport.java

@@ -0,0 +1,109 @@
+package com.rongwe.scentity.domian;
+
+import java.io.Serializable;
+import java.util.Date;
+import lombok.Data;
+
+/**
+ * asp_accident_report
+ * @author 
+ */
+@Data
+public class AspAccidentReport implements Serializable {
+    /**
+     * 主键ID
+     */
+    private String id;
+
+    /**
+     * 租户ID
+     */
+    private String tenantid;
+
+    /**
+     * 扩展json格式配置
+     */
+    private String roption;
+
+    /**
+     * 是否删除Y/N
+     */
+    private String deleted;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 创建时间
+     */
+    private Date createdate;
+
+    /**
+     * 创建用户ID
+     */
+    private String createuserid;
+
+    /**
+     * 修改日期
+     */
+    private Date modifydate;
+
+    /**
+     * 修改用户ID
+     */
+    private String modifyuserid;
+
+    /**
+     * 创建人
+     */
+    private String createusername;
+
+    /**
+     * 修改人
+     */
+    private String modifyusername;
+
+    /**
+     * 部门名称
+     */
+    private String departname;
+
+    /**
+     * 部门ID
+     */
+    private String departid;
+
+    /**
+     * 年份
+     */
+    private Integer year;
+
+    /**
+     * 月份
+     */
+    private Integer month;
+
+    /**
+     * 值
+     */
+    private String value;
+
+    /**
+     * 月合计
+     */
+    private String monthtotal;
+
+    /**
+     * 车间人数
+     */
+    private Integer departpeople = 0;
+
+    /**
+     * 工伤数量
+     */
+    private Integer count = 0;
+
+    private static final long serialVersionUID = 1L;
+}

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

@@ -0,0 +1,88 @@
+package com.rongwe.scentity.vo;
+
+import lombok.Data;
+
+@Data
+public class AspAccidentReportVo{
+    /**
+     * 部门名称
+     */
+    private String departName;
+
+    /**
+     * 部门ID
+     */
+    private String departId;
+
+    /**
+     * 1月
+     */
+    private String count1 = "0.00%";
+
+    /**
+     * 2月
+     */
+    private String count2 = "0.00%";
+
+    /**
+     * 3月
+     */
+    private String count3 = "0.00%";
+
+    /**
+     * 4月
+     */
+    private String count4 = "0.00%";
+
+    /**
+     * 5月
+     */
+    private String count5 = "0.00%";
+
+    /**
+     * 6月
+     */
+    private String count6 = "0.00%";
+
+    /**
+     * 7月
+     */
+    private String count7 = "0.00%";
+
+    /**
+     * 8月
+     */
+    private String count8 = "0.00%";
+
+    /**
+     * 9月
+     */
+    private String count9 = "0.00%";
+
+    /**
+     * 10月
+     */
+    private String count10 = "0.00%";
+
+    /**
+     * 11月
+     */
+    private String count11 = "0.00%";
+
+    /**
+     * 12月
+     */
+    private String count12 = "0.00%";
+
+    /**
+     * 合计
+     */
+    private String countAll = "0.00%";
+
+    /**
+     * 部门人数
+     */
+    private Integer departPeople = 0;
+
+
+}

+ 48 - 8
cx-safe-check/cx-save-check-server/src/main/java/com/rongwei/savecheck/controller/AccidentController.java

@@ -1,12 +1,17 @@
 package com.rongwei.savecheck.controller;
 
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.rongwe.scentity.vo.AspAccidentReportVo;
 import com.rongwei.rwcommon.base.R;
 import com.rongwei.rwcommon.utils.StringUtils;
 import com.rongwei.sfcommon.sys.service.AccidentService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -25,15 +30,16 @@ public class AccidentController {
 
     /**
      * 生成事故表编号
+     *
      * @param map
      * @return
      */
     @PostMapping("/code")
-    public R code (@RequestBody Map<String,Object> map){
-        try{
+    public R code(@RequestBody Map<String, Object> map) {
+        try {
             accidentService.getCode(map);
             return R.ok();
-        }catch (Exception e){
+        } catch (Exception e) {
             e.printStackTrace();
             log.error(StringUtils.spliceErrorMsg(e), e.fillInStackTrace());
             return R.error();
@@ -42,12 +48,13 @@ public class AccidentController {
 
     /**
      * 点检保存生成隐患跟踪任务
+     *
      * @param map
      * @return
      */
     @PostMapping("/createHiddenDangerTask")
-    public R createHiddenDangerTask(@RequestBody Map<String,Object> map){
-        try{
+    public R createHiddenDangerTask(@RequestBody Map<String, Object> map) {
+        try {
             accidentService.createHiddenTask(map);
             return R.ok();
         } catch (Exception e) {
@@ -58,15 +65,48 @@ public class AccidentController {
 
     /**
      * 事故表word导出
+     *
      * @param map
      * @return
      */
     @PostMapping("/word")
-    public R word (@RequestBody Map<String,Object> map){
-        try{
+    public R word(@RequestBody Map<String, Object> map) {
+        try {
             R r = accidentService.word(map);
             return R.ok(r);
-        }catch (Exception e){
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error(StringUtils.spliceErrorMsg(e), e.fillInStackTrace());
+            return R.error();
+        }
+    }
+
+    /**
+     * 定时任务生成每月的工伤月度报表
+     */
+    @PostMapping("/report")
+    public R report() {
+        try {
+            return accidentService.report();
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error(StringUtils.spliceErrorMsg(e), e.fillInStackTrace());
+            return R.error();
+        }
+    }
+
+    /**
+     * 查询工伤率报表
+     */
+    @PostMapping("/selectReport")
+    public R selectReport(@RequestParam(required = true) Integer year,
+                          @RequestParam(required = false) String tenantId) {
+        try {
+            List<AspAccidentReportVo> r = accidentService.selectReport(year, tenantId);
+            IPage<AspAccidentReportVo> res = new Page<>();
+            res.setRecords(r);
+            return R.ok(res);
+        } catch (Exception e) {
             e.printStackTrace();
             log.error(StringUtils.spliceErrorMsg(e), e.fillInStackTrace());
             return R.error();