From 83487f40288fecfe2bd6fb0f75600440a7fd913c Mon Sep 17 00:00:00 2001 From: WenShiJun Date: Tue, 3 Sep 2024 18:08:40 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E6=B6=88=E9=98=B2=E5=AE=89=E5=85=A8?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E6=B7=BB=E5=8A=A0=E6=89=AB=E7=A0=81=E6=9F=A5?= =?UTF-8?q?=E7=9C=8B=E6=A3=80=E6=9F=A5=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/mybatis/datasource/corpsystem/CorpMenuMapper.xml | 2 +- .../mybatis/datasource/firemanager/FirePonitMapper.xml | 1 + src/main/resources/mybatis/datasource/system/MenuMapper.xml | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/resources/mybatis/datasource/corpsystem/CorpMenuMapper.xml b/src/main/resources/mybatis/datasource/corpsystem/CorpMenuMapper.xml index 24f3cd6b..c21d8390 100644 --- a/src/main/resources/mybatis/datasource/corpsystem/CorpMenuMapper.xml +++ b/src/main/resources/mybatis/datasource/corpsystem/CorpMenuMapper.xml @@ -34,7 +34,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - SYS_MENU + SYS_MENU2 diff --git a/src/main/resources/mybatis/datasource/firemanager/FirePonitMapper.xml b/src/main/resources/mybatis/datasource/firemanager/FirePonitMapper.xml index 7ec95e23..d8731441 100644 --- a/src/main/resources/mybatis/datasource/firemanager/FirePonitMapper.xml +++ b/src/main/resources/mybatis/datasource/firemanager/FirePonitMapper.xml @@ -143,6 +143,7 @@ fqp.QUALIFIED_TYPE_NAME, IFNULL( t.DEVICE_COUNT, 0 ) DEVICE_COUNT, d.`NAME` AS DEPARTMENT_NAME, + p.USER_ID, u.`NAME` AS USERNAME, r.FIRE_REGION_NAME, if(p.LATITUDE is null or p.LONGITUDE is null or p.LATITUDE = '' or p.LONGITUDE = '', '1', '0') AS ISPUNCTUATION diff --git a/src/main/resources/mybatis/datasource/system/MenuMapper.xml b/src/main/resources/mybatis/datasource/system/MenuMapper.xml index b8ffb1ba..55caf1f8 100644 --- a/src/main/resources/mybatis/datasource/system/MenuMapper.xml +++ b/src/main/resources/mybatis/datasource/system/MenuMapper.xml @@ -34,7 +34,7 @@ - SYS_MENU + SYS_MENU2 From db8a7b76be690bfde68c03ca1c74559e2f9e386d Mon Sep 17 00:00:00 2001 From: guoyuepeng <770272267@qq.com> Date: Wed, 4 Sep 2024 11:24:37 +0800 Subject: [PATCH 02/10] =?UTF-8?q?1.=E5=85=AB=E9=A1=B9=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E5=BC=BA=E5=88=B6=E5=9B=9E=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/zcloud/config/CORSFilter.java | 34 ++++--- .../bus/HotWorkApplicationController.java | 28 +++++- .../HotWorkApplicationMapper.java | 6 +- .../HotWorkApplicationService.java | 2 + .../impl/HotWorkApplicationServiceImpl.java | 18 ++++ .../HotWorkApplicationUserServiceImpl.java | 3 + src/main/java/com/zcloud/util/Const.java | 6 +- .../highriskwork/HotWorkApplicationMapper.xml | 95 +++++++++++-------- 8 files changed, 131 insertions(+), 61 deletions(-) diff --git a/src/main/java/com/zcloud/config/CORSFilter.java b/src/main/java/com/zcloud/config/CORSFilter.java index 62fc6011..43978ee5 100644 --- a/src/main/java/com/zcloud/config/CORSFilter.java +++ b/src/main/java/com/zcloud/config/CORSFilter.java @@ -38,21 +38,25 @@ public class CORSFilter implements Filter { // (referer.trim().startsWith("http://192.168.192.201:8992/"))|| // (referer.trim().startsWith("http://192.168.192.201:8993/"))|| // (referer.trim().startsWith("https://skqhdg.porthebei.com:9005/"))){ - response.setContentType("textml;charset=UTF-8"); - response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin")); - response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); - response.setHeader("Access-Control-Max-Age", "0"); - response.setHeader("Access-Control-Allow-Headers","Origin, No-Cache, X-Requested-With, If-Modified-Since, Pragma, Last-Modified, Cache-Control, Expires, Content-Type, X-E4M-With,userId,token"); - response.setHeader("Access-Control-Allow-Credentials", "true"); // 是否支持cookie跨域         - response.setHeader("XDomainRequestAllowed", "1"); - response.setHeader("x-frame-options","SAMEORIGIN"); // **** - response.setHeader("X-Content-Type-Options","nosniff"); - response.setHeader("Content-Security-Policy","default-src 'none'; script-src 'self'; connect-src 'self'; img-src 'self'; style-src 'self';"); - // 一公司烯体哦那个系统漏洞修复 - response.setHeader("X-XSS-Protection", "1; mode=block"); - response.setHeader("X-Permitted-Cross-Domain-Policies", "none"); - response.setHeader("Strict-Transport-Security", "max-age=31536000; includeSubDomains; preload"); - response.setHeader("Referrer-Policy", "strict-origin-when-cross-origin"); + response.setContentType("textml;charset=UTF-8"); + response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin")); + response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); + response.setHeader("Access-Control-Max-Age", "0"); + response.setHeader("Access-Control-Allow-Headers","Origin, No-Cache, X-Requested-With, If-Modified-Since, Pragma, Last-Modified, Cache-Control, Expires, Content-Type, X-E4M-With,userId,token"); + response.setHeader("Access-Control-Allow-Credentials", "true"); // 是否支持cookie跨域         + response.setHeader("XDomainRequestAllowed", "1"); + response.setHeader("x-frame-options","SAMEORIGIN"); // **** + response.setHeader("X-Content-Type-Options","nosniff"); + response.setHeader("Content-Security-Policy","default-src 'none'; script-src 'self'; connect-src 'self'; img-src 'self'; style-src 'self';"); + // 系统漏洞修复 + response.setHeader("X-XSS-Protection", "1; mode=block"); + response.setHeader("X-Permitted-Cross-Domain-Policies", "none"); + response.setHeader("Strict-Transport-Security", "max-age=31536000; includeSubDomains; preload"); + response.setHeader("Referrer-Policy", "strict-origin-when-cross-origin"); + response.setHeader("X-Download-Options", "noopen"); + response.setHeader("X-Content-TYpe-OPtions", "nosniff"); + response.setHeader("Content-Security-Policy", "default-src 'self'"); + filterChain.doFilter(servletRequest, servletResponse); // } } diff --git a/src/main/java/com/zcloud/controller/bus/HotWorkApplicationController.java b/src/main/java/com/zcloud/controller/bus/HotWorkApplicationController.java index 5eeda735..1a663510 100644 --- a/src/main/java/com/zcloud/controller/bus/HotWorkApplicationController.java +++ b/src/main/java/com/zcloud/controller/bus/HotWorkApplicationController.java @@ -153,7 +153,7 @@ public class HotWorkApplicationController extends BaseController { return map; } - /**去修改页面获取数据 + /**去修改页面获取数据 * @param * @throws Exception */ @@ -573,7 +573,7 @@ public class HotWorkApplicationController extends BaseController { return map; } - /**批量删除 + /**批量删除 * @param * @throws Exception */ @@ -597,7 +597,7 @@ public class HotWorkApplicationController extends BaseController { return map; } - /**导出到excel + /**导出到excel * @param * @throws Exception */ @@ -1344,4 +1344,26 @@ public class HotWorkApplicationController extends BaseController { map.put("result", errInfo); return map; } + + /**强制结束动火 + * @param + * @throws Exception + */ + @RequestMapping(value="/forcedEnd") +// @RequiresPermissions("hotwork:del") + @ResponseBody + public Object forcedEnd() throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + String userid = Jurisdiction.getUSER_ID(); + if(!Tools.isEmpty(pd.getString("HOTWORKAPPLICATION_ID"))){ + hotworkapplicationService.forcedEndHotwork(pd.getString("HOTWORKAPPLICATION_ID"), + userid, pd.getString("STATE")); + } + + map.put("result", errInfo); //返回结果 + return map; + } } diff --git a/src/main/java/com/zcloud/mapper/datasource/highriskwork/HotWorkApplicationMapper.java b/src/main/java/com/zcloud/mapper/datasource/highriskwork/HotWorkApplicationMapper.java index eaa1c75b..f8cafbd7 100644 --- a/src/main/java/com/zcloud/mapper/datasource/highriskwork/HotWorkApplicationMapper.java +++ b/src/main/java/com/zcloud/mapper/datasource/highriskwork/HotWorkApplicationMapper.java @@ -79,7 +79,7 @@ public interface HotWorkApplicationMapper{ Integer getJobNumber(PageData pd); - List hotworkdatalistPage(Page page); + List hotworkdatalistPage(Page page); void cleanUpJobNumber(PageData pd); @@ -90,8 +90,10 @@ public interface HotWorkApplicationMapper{ * @return * @throws Exception */ - void updateState4ids(PageData pageData); + void updateState4ids(PageData pageData); PageData getCountByMyApprovalForDelayedHotWork(PageData pageData); + + void forcedEndHotwork (PageData pageData); } diff --git a/src/main/java/com/zcloud/service/highriskwork/HotWorkApplicationService.java b/src/main/java/com/zcloud/service/highriskwork/HotWorkApplicationService.java index 872f7d61..7d70dcd9 100644 --- a/src/main/java/com/zcloud/service/highriskwork/HotWorkApplicationService.java +++ b/src/main/java/com/zcloud/service/highriskwork/HotWorkApplicationService.java @@ -112,6 +112,8 @@ public interface HotWorkApplicationService{ public void updateState4ids(PageData pageData); PageData getCountByMyApprovalForDelayedHotWork(String user_id) throws Exception; + + void forcedEndHotwork (String HOTWORKAPPLICATION_ID,String user_id ,String state) throws Exception; } diff --git a/src/main/java/com/zcloud/service/highriskwork/impl/HotWorkApplicationServiceImpl.java b/src/main/java/com/zcloud/service/highriskwork/impl/HotWorkApplicationServiceImpl.java index 439a4590..2b3d00b8 100644 --- a/src/main/java/com/zcloud/service/highriskwork/impl/HotWorkApplicationServiceImpl.java +++ b/src/main/java/com/zcloud/service/highriskwork/impl/HotWorkApplicationServiceImpl.java @@ -259,5 +259,23 @@ public class HotWorkApplicationServiceImpl implements HotWorkApplicationService{ public List archivelist(Page page)throws Exception{ return hotworkapplicationMapper.filedatalistPage(page); } + + /** + * 方法名称:强制结束动火 + * 方法描述:轻质结束正在进行中的动火或者已经过去的动火信息 + * 创建人:guoyuepeng + * 时间:2024/9/3 14:48 + * @param HOTWORKAPPLICATION_ID 动火ID + * @return void + */ + public void forcedEndHotwork(String HOTWORKAPPLICATION_ID ,String userid,String state) throws Exception{ + PageData pd = new PageData(); + pd.put("OPERATOR", userid); + pd.put("OPERATTIME", DateUtil.date2Str(new Date())); + pd.put("HOTWORKAPPLICATION_ID", HOTWORKAPPLICATION_ID); + pd.put("STATE", "11"); + pd.put("FORCED_END_STATE", state); + hotworkapplicationMapper.forcedEndHotwork(pd); + } } diff --git a/src/main/java/com/zcloud/service/highriskwork/impl/HotWorkApplicationUserServiceImpl.java b/src/main/java/com/zcloud/service/highriskwork/impl/HotWorkApplicationUserServiceImpl.java index 0a931c53..00f0ecad 100644 --- a/src/main/java/com/zcloud/service/highriskwork/impl/HotWorkApplicationUserServiceImpl.java +++ b/src/main/java/com/zcloud/service/highriskwork/impl/HotWorkApplicationUserServiceImpl.java @@ -277,6 +277,9 @@ public class HotWorkApplicationUserServiceImpl implements HotWorkApplicationUser && 0 > Integer.parseInt(hotVal.get("STATE").toString())){ hotVal.put("examineUserName", hotVal.get("OPERATORNAME")); } + if("1".equals(hotVal.getString("IS_FORCED_END"))){ //如果是强制回档 + hotVal.put("examineUserName", hotVal.get("OPERATORNAME")); + } } PageData pd = new PageData(); pd.put("hotIds",hotIds); diff --git a/src/main/java/com/zcloud/util/Const.java b/src/main/java/com/zcloud/util/Const.java index b7f82567..145ae510 100644 --- a/src/main/java/com/zcloud/util/Const.java +++ b/src/main/java/com/zcloud/util/Const.java @@ -24,7 +24,7 @@ public class Const { public static final String SYSNAME = "sysName"; //系统名称 public static final String SHOWCOUNT = "showCount"; //每页条数 - public static final String basePath = "/mnt/qask/file/"; + public static final String basePath = "/mnt/vdc1/qask/file/"; public static final String FILEPATHFILE = "/uploadFiles/file/"; //文件上传路径 public static final String FILEPATHHEADPHONE = "/uploadFiles/headPhone/"; //用户头像 public static final String BIFILEPATHFILE = "/uploadFiles/Bfile/"; //文件上传路径 @@ -46,9 +46,9 @@ public class Const { public static final String IS_MAIN = "IS_MAIN"; //是否主账号 public static final String ISSUPERVISE = "ISSUPERVISE"; //是否监管部门 public static final String DEFAULT_PASSWORD = "Aa@123456789"; //系统默认密码 - public static final String FILEURL = "/mnt/qask/file/"; //文件服务器地址 + public static final String FILEURL = "/mnt/vdc1/qask/file/"; //文件服务器地址 public static final String HTTPFILEURL = "https://skqhdg.porthebei.com:9004/file/"; //文件服务器地址 -// public static final String HTTPFILEURL = "https://qgqy.qhdsafety.com/file/"; + // public static final String HTTPFILEURL = "https://qgqy.qhdsafety.com/file/"; public final static String APPID = "wx9199de454d31b016"; public final static String SECRET = "183cdcac380e1f98f00c793491e27d88"; public static final String XCX_MCH_ID = "1607757714"; diff --git a/src/main/resources/mybatis/datasource/highriskwork/HotWorkApplicationMapper.xml b/src/main/resources/mybatis/datasource/highriskwork/HotWorkApplicationMapper.xml index 7758c8da..537e8d7e 100644 --- a/src/main/resources/mybatis/datasource/highriskwork/HotWorkApplicationMapper.xml +++ b/src/main/resources/mybatis/datasource/highriskwork/HotWorkApplicationMapper.xml @@ -36,6 +36,7 @@ f.IS_SAFETY_DIRECTOR, f.IS_GAS_TESTING, f.SPARE, + f.IS_FORCED_END, f.HOTWORKAPPLICATION_ID @@ -63,6 +64,7 @@ IS_SAFETY_DIRECTOR, IS_GAS_TESTING, SPARE, + IS_FORCED_END, HOTWORKAPPLICATION_ID @@ -90,6 +92,7 @@ #{IS_SAFETY_DIRECTOR}, #{IS_GAS_TESTING}, #{SPARE}, + #{IS_FORCED_END}, #{HOTWORKAPPLICATION_ID} @@ -143,10 +146,10 @@ - update - - set - STATE = #{STATE} + update + + set + STATE = #{STATE} where HOTWORKAPPLICATION_ID = #{HOTWORKAPPLICATION_ID} @@ -191,6 +194,7 @@ f.IS_SAFETY_DIRECTOR, f.IS_GAS_TESTING, f.SPARE, + f.IS_FORCED_END, f.HOTWORKAPPLICATION_ID, u.NAME CREATORNAME, d.NAME DEPARTMENTNAME, @@ -215,15 +219,15 @@ ) - and f.CORPINFO_ID = #{pd.CORPINFO_ID} - - - and (f.CREATOR = #{pd.CREATOR}) - - + and f.CORPINFO_ID = #{pd.CORPINFO_ID} + + + and (f.CREATOR = #{pd.CREATOR}) + + and (HOT_WORK_LEVEL_INDEX = #{pd.HOT_WORK_LEVEL_INDEX}) - - + + @@ -409,9 +413,9 @@ from f - where 1=1 + where 1=1 - and STATE in + and STATE in #{item} @@ -430,7 +434,7 @@ #{item} - + @@ -485,8 +489,8 @@ @@ -500,20 +504,20 @@ LEFT JOIN bus_hotworkapplicationuser fu ON fu.FOREIGN_KEY = f.HOTWORKAPPLICATION_ID WHERE fu.user_id = #{USER_ID} - AND fu.STATE = '24' - and f.STATE in ('1','2','3','4','5','6' + AND fu.STATE = '24' + and f.STATE in ('1','2','3','4','5','6' ,'7','8','9') @@ -530,20 +534,20 @@ insert into - bus_hotworkapplicationnumber + bus_hotworkapplicationnumber ( - JOB_NUMBER + JOB_NUMBER ) values ( - #{JOB_NUMBER} - ) + #{JOB_NUMBER} + ) @@ -598,8 +602,23 @@ + + + + + update + + set + STATE = #{STATE}, + OPERATOR = #{OPERATOR}, + OPERATTIME = #{OPERATTIME}, + FORCED_END_STATE = #{state}, + IS_FORCED_END ='1' + where + HOTWORKAPPLICATION_ID = #{HOTWORKAPPLICATION_ID} + From 26f7bce7a86b3e240cfc4954ac96301a22657140 Mon Sep 17 00:00:00 2001 From: water_xu Date: Wed, 4 Sep 2024 20:23:29 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E9=99=84=E4=BB=B6=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=99=A8=E9=85=8D=E7=BD=AE=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-master.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/resources/application-master.properties b/src/main/resources/application-master.properties index 892f00b8..a493b235 100644 --- a/src/main/resources/application-master.properties +++ b/src/main/resources/application-master.properties @@ -64,7 +64,7 @@ smb.host=192.168.192.201 smb.port=22 smb.user=root smb.password=SJSKaqhb@20240131 -smb.basePath=/mnt/qask/file/ +smb.basePath=/mnt/vdc1/qask/file/ #Mq\u914D\u7F6E rocketmq.consumer.group2=edu-admin-edit rocketmq.consumer.group1=edu-admin-add @@ -131,6 +131,7 @@ gongJiangXueYuanGetImgUrl=https://skqhdg.porthebei.com:9004/file/ # \u4E2D\u53F0 # \u6D88\u8D39\u4E2D\u53F0\u901A\u77E5 +tongbu.url=http://127.0.0.1:8094 mq.consumer.dataChange.tongbu-data-change.topic=tongbu_dataChange_docking mq.consumer.dataChange.tongbu-data-change.group=tongbu_dataChange_group From 370adafd23b190c9a97dc2e499805193f2b6fe09 Mon Sep 17 00:00:00 2001 From: water_xu Date: Wed, 4 Sep 2024 20:30:21 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E4=BA=BA=E5=91=98=E4=B8=AD=E5=8F=B0=20-?= =?UTF-8?q?=20=E9=85=8D=E7=BD=AE=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-master.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application-master.properties b/src/main/resources/application-master.properties index a493b235..0254d295 100644 --- a/src/main/resources/application-master.properties +++ b/src/main/resources/application-master.properties @@ -131,7 +131,7 @@ gongJiangXueYuanGetImgUrl=https://skqhdg.porthebei.com:9004/file/ # \u4E2D\u53F0 # \u6D88\u8D39\u4E2D\u53F0\u901A\u77E5 -tongbu.url=http://127.0.0.1:8094 +tongbu.url=http://192.168.192.201:8971/qa-prevention-gwj-tongbu/ mq.consumer.dataChange.tongbu-data-change.topic=tongbu_dataChange_docking mq.consumer.dataChange.tongbu-data-change.group=tongbu_dataChange_group From 439eb4fdb0d5ac6c65124d4213e4c738a0c4b8c8 Mon Sep 17 00:00:00 2001 From: water_xu Date: Wed, 4 Sep 2024 20:42:01 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E6=81=A2=E5=A4=8D=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/mybatis/datasource/corpsystem/CorpMenuMapper.xml | 2 +- src/main/resources/mybatis/datasource/system/MenuMapper.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/mybatis/datasource/corpsystem/CorpMenuMapper.xml b/src/main/resources/mybatis/datasource/corpsystem/CorpMenuMapper.xml index c21d8390..24f3cd6b 100644 --- a/src/main/resources/mybatis/datasource/corpsystem/CorpMenuMapper.xml +++ b/src/main/resources/mybatis/datasource/corpsystem/CorpMenuMapper.xml @@ -34,7 +34,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - SYS_MENU2 + SYS_MENU diff --git a/src/main/resources/mybatis/datasource/system/MenuMapper.xml b/src/main/resources/mybatis/datasource/system/MenuMapper.xml index 55caf1f8..b8ffb1ba 100644 --- a/src/main/resources/mybatis/datasource/system/MenuMapper.xml +++ b/src/main/resources/mybatis/datasource/system/MenuMapper.xml @@ -34,7 +34,7 @@ - SYS_MENU2 + SYS_MENU From f629b3535135815245293ad0b2adbf337c04aed3 Mon Sep 17 00:00:00 2001 From: WenShiJun Date: Thu, 5 Sep 2024 09:25:02 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E6=B6=88=E9=98=B2=E7=82=B9=E4=BD=8D?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E6=A8=A1=E5=9D=97=E6=A3=80=E6=9F=A5=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E4=BA=8C=E7=BB=B4=E7=A0=81=E5=8A=9F=E8=83=BD=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/AppFireRecordController.java | 16 ++++++ .../firemanager/FireRecordMapper.java | 1 + .../firemanager/FireRecordService.java | 1 + .../impl/FireRecordServiceImpl.java | 5 ++ .../firemanager/FireRecordMapper.xml | 53 +++++++++++++++++++ 5 files changed, 76 insertions(+) diff --git a/src/main/java/com/zcloud/controller/firemanager/app/AppFireRecordController.java b/src/main/java/com/zcloud/controller/firemanager/app/AppFireRecordController.java index 69587a87..4b99ab52 100644 --- a/src/main/java/com/zcloud/controller/firemanager/app/AppFireRecordController.java +++ b/src/main/java/com/zcloud/controller/firemanager/app/AppFireRecordController.java @@ -194,6 +194,22 @@ public class AppFireRecordController extends BaseController { map.put("varList", res); return map; } + + @RequestMapping("getCheckRecordListV3") + @ResponseBody + public Object getCheckRecordListV3(Page page) { + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = getPageData(); + page.setPd(pd); + List res = fireRecordService.getCheckListByAppV3(page); +// List res = fireRecordService.getCheckRecordList(pd); + map.put("result", errInfo); + map.put("page", page); + map.put("varList", res); + return map; + } + /** * @Description: 清单下的检查记录 * @Author: dearLin diff --git a/src/main/java/com/zcloud/mapper/datasource/firemanager/FireRecordMapper.java b/src/main/java/com/zcloud/mapper/datasource/firemanager/FireRecordMapper.java index cfe481a5..835d5d51 100644 --- a/src/main/java/com/zcloud/mapper/datasource/firemanager/FireRecordMapper.java +++ b/src/main/java/com/zcloud/mapper/datasource/firemanager/FireRecordMapper.java @@ -89,6 +89,7 @@ public interface FireRecordMapper { List datalistPageV2(Page page); + List datalistPageV3(Page page); List datalistPage(Page page); List getCheckingByCid(String fireCheckId); diff --git a/src/main/java/com/zcloud/service/firemanager/FireRecordService.java b/src/main/java/com/zcloud/service/firemanager/FireRecordService.java index 982a1b70..799c900b 100644 --- a/src/main/java/com/zcloud/service/firemanager/FireRecordService.java +++ b/src/main/java/com/zcloud/service/firemanager/FireRecordService.java @@ -80,6 +80,7 @@ public interface FireRecordService { List getCheckListByApp(Page page); List getCheckListByAppV2(Page page); + List getCheckListByAppV3(Page page); List getCheckRecordByPid(PageData pd); /** diff --git a/src/main/java/com/zcloud/service/firemanager/impl/FireRecordServiceImpl.java b/src/main/java/com/zcloud/service/firemanager/impl/FireRecordServiceImpl.java index 771b1771..45aecea5 100644 --- a/src/main/java/com/zcloud/service/firemanager/impl/FireRecordServiceImpl.java +++ b/src/main/java/com/zcloud/service/firemanager/impl/FireRecordServiceImpl.java @@ -723,6 +723,11 @@ public class FireRecordServiceImpl implements FireRecordService { return data; } + @Override + public List getCheckListByAppV3(Page page) { + List data = fireRecordMapper.datalistPageV3(page); + return data; + } @Override public List getCheckRecordByPid(PageData pd) { return fireRecordMapper.getCheckRecordByPid(pd); diff --git a/src/main/resources/mybatis/datasource/firemanager/FireRecordMapper.xml b/src/main/resources/mybatis/datasource/firemanager/FireRecordMapper.xml index 29996134..bd0a81ec 100644 --- a/src/main/resources/mybatis/datasource/firemanager/FireRecordMapper.xml +++ b/src/main/resources/mybatis/datasource/firemanager/FireRecordMapper.xml @@ -1031,5 +1031,58 @@ frp.EQUIPMENT_POINT_ID = #{EQUIPMENT_POINT_ID} AND frp.ISDELETE = '0' + From 1d66e96757d21ccc87bd4024adf547ed4b07c0bf Mon Sep 17 00:00:00 2001 From: huangyuxuan Date: Thu, 5 Sep 2024 13:51:14 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8D=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E9=98=BF=E9=87=8CJSONUtil?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/zcloud/controller/system/UsersController.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/main/java/com/zcloud/controller/system/UsersController.java b/src/main/java/com/zcloud/controller/system/UsersController.java index ee503d61..6dce241c 100644 --- a/src/main/java/com/zcloud/controller/system/UsersController.java +++ b/src/main/java/com/zcloud/controller/system/UsersController.java @@ -11,7 +11,6 @@ import com.alibaba.druid.support.json.JSONUtils; import com.alibaba.fastjson.JSON; import com.zcloud.dto.UpdateEnum; import com.zcloud.entity.system.Dictionaries; -import com.zcloud.entity.system.User; import com.zcloud.service.bus.*; import com.zcloud.service.system.*; import com.zcloud.syncData.SyncPlatformAdvice; @@ -20,10 +19,8 @@ import com.zcloud.util.*; import org.apache.commons.collections.map.ListOrderedMap; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.time.DateUtils; -import org.apache.fop.layoutmgr.PaddingElement; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.crypto.hash.SimpleHash; -import org.hyperic.sigar.pager.PageList; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; @@ -40,8 +37,6 @@ import com.zcloud.entity.PageData; import com.zcloud.entity.system.Role; import net.sf.json.JSONArray; -import sun.security.krb5.internal.PAData; -import sun.util.logging.resources.logging; /** * 说明:系统用户处理类 @@ -1034,7 +1029,7 @@ public class UsersController extends BaseController { map.put("USER_ID",ID); map.put("result", errInfo); //返回结果 map.put("code", "0"); - map.put("syncInfo", JSONUtils.toJSONString(userinfo)); + map.put("syncInfo", JSONUtil.toJsonStr(userinfo)); } else { map.put("result", "您输入的身份证号和用户名二次校验失败,请确认后重新申请"); //返回结果 } From a24771a505c69a0be039407fa0ae5a8ba89fbb74 Mon Sep 17 00:00:00 2001 From: huangyuxuan Date: Tue, 10 Sep 2024 17:52:05 +0800 Subject: [PATCH 08/10] =?UTF-8?q?[=E6=96=B0=E5=A2=9E=E5=8A=9F=E8=83=BD](hy?= =?UTF-8?q?x=5FchangeFileUpload=5F2024-9-10)=20ClearFilesJob.java=20=20-?= =?UTF-8?q?=20=E5=AE=9A=E6=97=B6=E6=B8=85=E9=99=A4=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=BB=BB=E5=8A=A1=20FileUploadUtil.java=20?= =?UTF-8?q?=20-=20=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E5=88=B0=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=99=A8=E4=B8=B4=E6=97=B6=E5=9C=B0=E5=9D=80=20=20-?= =?UTF-8?q?=20=E4=B8=B4=E6=97=B6=E6=96=87=E4=BB=B6=E6=8B=B7=E8=B4=9D?= =?UTF-8?q?=E5=88=B0=E6=AD=A3=E5=BC=8F=20MfolderController.java=20=20-=20?= =?UTF-8?q?=E6=9C=AA=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../filemanager/MfolderController.java | 58 +++++++++++++--- .../java/com/zcloud/util/ClearFilesJob.java | 64 +++++++++++++++++ src/main/java/com/zcloud/util/Const.java | 4 ++ .../java/com/zcloud/util/FileUploadUtil.java | 68 +++++++++++++++++++ 4 files changed, 184 insertions(+), 10 deletions(-) create mode 100644 src/main/java/com/zcloud/util/ClearFilesJob.java create mode 100644 src/main/java/com/zcloud/util/FileUploadUtil.java diff --git a/src/main/java/com/zcloud/controller/filemanager/MfolderController.java b/src/main/java/com/zcloud/controller/filemanager/MfolderController.java index 0d7c1be6..12d25ec0 100644 --- a/src/main/java/com/zcloud/controller/filemanager/MfolderController.java +++ b/src/main/java/com/zcloud/controller/filemanager/MfolderController.java @@ -1,5 +1,6 @@ package com.zcloud.controller.filemanager; +import com.zcloud.util.*; import net.sf.json.JSONArray; import java.io.Console; @@ -22,16 +23,6 @@ import com.zcloud.controller.base.BaseController; import com.zcloud.entity.Page; import com.zcloud.entity.PageData; import com.zcloud.service.filemanager.MfolderService; -import com.zcloud.util.Const; -import com.zcloud.util.DateUtil; -import com.zcloud.util.DelFileUtil; -import com.zcloud.util.FileDownload; -import com.zcloud.util.FileUpload; -import com.zcloud.util.FileUtil; -import com.zcloud.util.Jurisdiction; -import com.zcloud.util.PathUtil; -import com.zcloud.util.Smb; -import com.zcloud.util.Tools; import org.apache.shiro.authz.annotation.RequiresPermissions; @@ -75,6 +66,53 @@ public class MfolderController extends BaseController { return map; } + /** + * 上传临时文件 + * @return 不含前缀的临时文件路径 + * @throws Exception + * @date 2024-9-10 + * @author hyx + */ + @RequestMapping("upLoadTemporary") + @ResponseBody + public Object upLoadTemporary(@RequestParam(value="FFILE",required=false) MultipartFile file) throws Exception{ + Map map = new HashMap(); + if (null != file && !file.isEmpty()) { + + } + + String CORPINFO_ID = Jurisdiction.getCORPINFO_ID(); + String temporaryFilePath = FileUploadUtil.uploadTemporaryFile(file, CORPINFO_ID); + + map.put("temporaryFilePath", temporaryFilePath); + return map; + } + + /** + * 保存文件到正式地址 + * @param temporaryFilePath 不含前缀的临时文件路径 + * @param PARENT_ID 文件父级id + * @param REMARKS 备注 + * @param SHARE 是否共享 + * @return + * @throws Exception + * @date 2024-9-10 + * @author hyx + */ + public Object saveFile(@RequestParam(value="temporaryFilePath",required=false) String temporaryFilePath, + @RequestParam(value="NAME",required=false) String NAME, + @RequestParam(value="PARENT_ID",required=false) String PARENT_ID, + @RequestParam(value="REMARKS",required=false) String REMARKS, + @RequestParam(value="SHARE",required=false) String SHARE + ) throws Exception { + Map map = new HashMap(); + PageData pd = new PageData(); + String productFilePath = FileUploadUtil.copyTemporaryFileToProduct(temporaryFilePath, Jurisdiction.getCORPINFO_ID()); + + return null; + } + + /**上传文件 * @param * @throws Exception diff --git a/src/main/java/com/zcloud/util/ClearFilesJob.java b/src/main/java/com/zcloud/util/ClearFilesJob.java new file mode 100644 index 00000000..bfa677bb --- /dev/null +++ b/src/main/java/com/zcloud/util/ClearFilesJob.java @@ -0,0 +1,64 @@ +package com.zcloud.util; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.Scheduled; + +import java.io.File; + +/** + * 定时清除临时文件任务 + * 每月30日定时清除 /uploadFiles/linshi/ 路径下所有文件 + * @date 2024-9-10 + * @author hyx + */ +@Configuration +public class ClearFilesJob { + + private final static Logger log = LoggerFactory.getLogger(ClearFilesJob.class); + + @Scheduled(cron ="0 0 0 30 * ?") + public void scheduled(){ + log.info("==========清除临时文件定时任务开启=========="); + String filePath = Const.PATH_PREFIX + Const.TEMPORARY_FILE_PATH; + log.info(delAllFile(filePath) ? "临时文件清除成功!" : "临时文件清除失败!"); + } + + /** + * 删除文件夹下所有文件 + * @param path 目标路径 + * @return + */ + public static boolean delAllFile(String path) { + boolean flag = false; + File file = new File(path); + if (!file.exists()) { + return flag; + } + if (!file.isDirectory()) { + return flag; + } + String[] tempList = file.list(); + File temp = null; + for (int i = 0; i < tempList.length; i++) { + if (path.endsWith(File.separator)) { + temp = new File(path + tempList[i]); + } else { + temp = new File(path + File.separator + tempList[i]); + } + if (temp.isFile()) { + temp.delete(); + } + if (temp.isDirectory()) { + //删除文件夹下文件 + delAllFile(path + "/" + tempList[i]); + flag = true; + } + } + return flag; + } + + +} + diff --git a/src/main/java/com/zcloud/util/Const.java b/src/main/java/com/zcloud/util/Const.java index 145ae510..deaccee4 100644 --- a/src/main/java/com/zcloud/util/Const.java +++ b/src/main/java/com/zcloud/util/Const.java @@ -63,4 +63,8 @@ public class Const { public static final String USER_CITY_CODE = "SESSION_USER_CITY_CODE"; public static final String USER_CITY_NAME = "SESSION_USER_CITY_NAME"; + + public final static String TEMPORARY_FILE_PATH = "/uploadFiles/linshi/"; // 临时文件路径 + public final static String PRODUCT_FILE_PATH = "/uploadFiles/yhtp/"; //正式文件路径 + public final static String PATH_PREFIX = "/mnt/vdc1/qask/file"; //服务器路径前缀 } diff --git a/src/main/java/com/zcloud/util/FileUploadUtil.java b/src/main/java/com/zcloud/util/FileUploadUtil.java new file mode 100644 index 00000000..5764fa73 --- /dev/null +++ b/src/main/java/com/zcloud/util/FileUploadUtil.java @@ -0,0 +1,68 @@ +package com.zcloud.util; + +import cn.hutool.core.io.FileUtil; +import cn.hutool.core.io.IORuntimeException; +import org.springframework.web.multipart.MultipartFile; + +/** + * 文件上传工具类 + * 变更文件上传方式,原上传方式可能会导致附件丢失 + * 修改后逻辑:点击上传 -> 调后端接口返回临时文件路径 -> 提交-> 临时文件拷贝到正式,保存正式文件地址 -> 定期清空临时文件 + * @date 2024-9-10 + * @author hyx + * @version V1.0 + */ +public class FileUploadUtil { + + private final static String PATH_PREFIX = "/mnt/vdc1/qask/file"; //服务器路径前缀 + private final static String TEMPORARY_FILE_PATH = "/uploadFiles/linshi/"; //临时文件储存路径 + private final static String PRODUCT_FILE_PATH = "/uploadFiles/yhtp/"; //正式文件储存路径 + /** + * 上传文件到服务器临时地址 + * + * @param file 文件 + * @param CORPINFO_ID 企业id + * @return 文件临时路径 + * @throws Exception + * @date 2024-9-10 + * @author hyx + */ + public static String uploadTemporaryFile(MultipartFile file,String CORPINFO_ID) throws Exception { + String ffile = DateUtil.getDays(); + String fileName = UuidUtil.get32UUID()+file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); + try { + Smb.sshSftp(file,fileName,TEMPORARY_FILE_PATH + CORPINFO_ID + "/" + ffile); + } catch (Exception e) { + throw new RuntimeException(e); + } + return TEMPORARY_FILE_PATH + CORPINFO_ID+ "/" + ffile + "/" + fileName; + } + + /** + * 临时文件拷贝到正式 + * + * @param temporaryFilePath 临时文件路径 + * @param CORPINFO_ID 企业id + * @return 不含路径前缀的正式文件路径 + * @throws Exception + * @date 2024-9-10 + * @author hyx + */ + public static String copyTemporaryFileToProduct(String temporaryFilePath,String CORPINFO_ID) throws Exception { + //临时文件在服务器的完整路径 + String completeTemporaryPath = PATH_PREFIX + temporaryFilePath; + //截取文件名 + String fileName = completeTemporaryPath.substring(completeTemporaryPath.lastIndexOf("")).replace("/",""); + //正式文件完整路径 + String completeProductPath = PATH_PREFIX + PRODUCT_FILE_PATH + CORPINFO_ID + "/" + DateUtil.getDays() + "/"; + //临时文件拷贝到正式路径 + try { + FileUtil.copy(completeTemporaryPath,completeProductPath,true); + } catch (IORuntimeException e) { + throw new RuntimeException(e); + } + return PRODUCT_FILE_PATH + fileName; + } + + +} From 785cb0b4e9f4af55c04172761e1af7e378d3d55f Mon Sep 17 00:00:00 2001 From: huangyuxuan Date: Thu, 19 Sep 2024 10:02:54 +0800 Subject: [PATCH 09/10] =?UTF-8?q?[=E6=96=B0=E5=A2=9E=E5=8A=9F=E8=83=BD](hy?= =?UTF-8?q?x=5FchangeFileUpload=5F2024-9-10)=20=20-=20AppSystemController.?= =?UTF-8?q?java=20=20=20=20-=20=E5=BB=B6=E6=97=B6=E7=9B=91=E7=81=AB?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E8=BD=AC=E5=8F=91=E4=B8=8B=E6=8B=89=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E9=83=A8=E9=97=A8=E6=97=B6=E4=B8=8D=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E4=B8=BB=E4=BC=81=E4=B8=9A=20=20-=20CheckRecordMapper.xml=20?= =?UTF-8?q?=20-=20ListManagerMapper.xml=20=20=20=20-=20=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=20USER=5FNAME=20=E6=97=B6=20=E8=B0=83=E7=94=A8=20=20getUnameBy?= =?UTF-8?q?Uid=E5=87=BD=E6=95=B0=20=20-=20StatisticsDataController.java=20?= =?UTF-8?q?=20=20=20-=20=E6=95=B0=E6=8D=AE=E5=A4=A7=E5=B1=8F=EF=BC=8C?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=8E=A5=E5=8F=A3=E4=B8=8D=E7=99=BB=E9=99=86?= =?UTF-8?q?=E8=AE=BF=E9=97=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/zcloud/config/ShiroConfiguration.java | 1 + .../controller/app/AppSystemController.java | 2 +- .../StatisticsDataController.java | 955 ++++++++++++++++++ .../datasource/bus/CheckRecordMapper.xml | 2 +- .../datasource/bus/ListManagerMapper.xml | 12 +- 5 files changed, 964 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/zcloud/controller/statisticsdata/StatisticsDataController.java diff --git a/src/main/java/com/zcloud/config/ShiroConfiguration.java b/src/main/java/com/zcloud/config/ShiroConfiguration.java index 629d6292..3adc0306 100644 --- a/src/main/java/com/zcloud/config/ShiroConfiguration.java +++ b/src/main/java/com/zcloud/config/ShiroConfiguration.java @@ -81,6 +81,7 @@ public class ShiroConfiguration { filterChainMap.put("/openApi/**/**", "anon"); filterChainMap.put("/Api**/**", "anon"); filterChainMap.put("/api/**/**", "anon"); + filterChainMap.put("/getStatisticsData/**","anon"); filterChainMap.put("/**", "authc"); factoryBean.setFilterChainDefinitionMap(filterChainMap); } diff --git a/src/main/java/com/zcloud/controller/app/AppSystemController.java b/src/main/java/com/zcloud/controller/app/AppSystemController.java index 08e26ec9..3e0cdfb9 100644 --- a/src/main/java/com/zcloud/controller/app/AppSystemController.java +++ b/src/main/java/com/zcloud/controller/app/AppSystemController.java @@ -65,7 +65,7 @@ public class AppSystemController extends BaseController { depar.setSubDepartment(this.departmentService.listAllDepartment(depar.getDEPARTMENT_ID(),url)); depar.setTarget("treeFrame"); depar.setIcon("../../../assets/images/user.gif"); - zdepartmentPdList.add(depar); + zdepartmentPdList.addAll(depar.getSubDepartment()); // zdepartmentPdList.addAll(departmentService.listAllDepartment(ZDEPARTMENT_ID)); JSONArray arr = JSONArray.fromObject(zdepartmentPdList); String json = arr.toString(); diff --git a/src/main/java/com/zcloud/controller/statisticsdata/StatisticsDataController.java b/src/main/java/com/zcloud/controller/statisticsdata/StatisticsDataController.java new file mode 100644 index 00000000..5d046d49 --- /dev/null +++ b/src/main/java/com/zcloud/controller/statisticsdata/StatisticsDataController.java @@ -0,0 +1,955 @@ +package com.zcloud.controller.statisticsdata; + +import com.zcloud.controller.base.BaseController; +import com.zcloud.entity.Page; +import com.zcloud.entity.PageData; +import com.zcloud.entity.system.Dictionaries; +import com.zcloud.service.bus.*; +import com.zcloud.service.highriskwork.HighWorkService; +import com.zcloud.service.majordangersource.MajordangersourceDisposalService; +import com.zcloud.service.system.*; +import com.zcloud.util.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.*; + +@Controller +@RequestMapping("/getStatisticsData") +public class StatisticsDataController extends BaseController { + + private final static String CORPINFO_ID = "21590a00ea5e462e9ee44dd332dddc26"; + private final static String USER_ID = "48a8ca9815814c979814ddcf041c5cd5"; + private final static String USER_NAME = "秦港股份九公司"; + private final static String DEPT_ID = "21590a00ea5e462e9ee44dd332dddc26"; + + @Autowired + private RiskPointService riskpointService; + @Autowired + private UsersService usersService; + @Autowired + private DepartmentService departmentService; + @Autowired + private ListManagerService listmanagerService; + @Autowired + private HiddenService hiddenService; + @Autowired + private CardUserService cardUserService; + @Autowired + private MajordangersourceDisposalService majordangersourceDisposalService; + @Autowired + private HighWorkService highworkService; + @Autowired + private DictionariesService dictionariesService; + @Autowired + private VideoService videoService; + @Autowired + private MajordangersourceDisposalService majordangersourcedisposalService; + @Autowired + private PhotoService photoService; + @Autowired + private FhsmsService fhsmsService; + @Autowired + private RoleService roleService; + @Autowired + private PostService postService; + @Autowired + private CheckRecordService checkrecordService; + @Autowired + private ListStatisticsService listStatisticsService; + @Autowired + private IdentificationPartsService identificationPartsService; + @Autowired + private RiskUnitService riskUnitService; + @Autowired + private NoticeCorpService noticecorpService; + @Autowired + private ServiceNoticeService noticeService; + + /** + * 可视化首页统计数据 + * + * @param + * @throws Exception + */ + @RequestMapping(value = "/findFormCount") + @ResponseBody + public Object findFormCount() throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = this.getPageData(); + pd.put("CORPINFO_ID", CORPINFO_ID); + + /*风险管控 数据统计*/ + PageData risk = riskpointService.statisticsRiskCount(pd); + map.put("risk", risk); + + /* 隐患排查数据统计 */ + Map corp = new HashMap<>(); + //部门 + List userCount = usersService.statisticsByCorp(pd); + corp.put("USERCOUNT", userCount.get(0).get("COUNT")); //人员总数 + corp.put("USERCHECKCOUNT", userCount.get(1).get("COUNT")); //人员总数 + //部门 + List deptCount = departmentService.statisticsByCorp(pd); + corp.put("DEPTCOUNT", deptCount.get(0).get("COUNT")); //人员总数 + corp.put("DEPTCHECKCOUNT", deptCount.get(1).get("COUNT")); //人员总数 + //清单 + List listCount = listmanagerService.statisticsByCorp(pd); //列出ListManager列表 + corp.put("LISTCOUNT", listCount.get(0).get("COUNT")); //人员总数 + corp.put("LISTCHECKCOUNT", listCount.get(1).get("COUNT")); //人员总数 + map.put("corp", corp); + + map.put("result", errInfo); + return map; + } + + /** + * 可视化首页 清单类型占比统计 + * + * @param + * @throws Exception + */ + @RequestMapping(value = "/findListTypeChartData") + @ResponseBody + public Object findListTypeChartData() throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = this.getPageData(); + pd.put("CORPINFO_ID",CORPINFO_ID); + + //清单类型占比统计 + List chartData = listmanagerService.statisticsGroupType(pd); + map.put("chartData", chartData); + map.put("result", errInfo); + return map; + } + + /** + * 可视化首页 隐患整改趋势 + * + * @param + * @throws Exception + */ + @RequestMapping(value = "/findHdRecTrendChartData") + @ResponseBody + public Object findHdRecTrendChartData() throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + //隐患整改趋势(近半年) + Map chartData = new HashMap(); + List legendData = Arrays.asList(new String[]{"已发现", "待确认", "已确认", "待验收", "已验收", "延期处置"}); + chartData.put("legendData", legendData); + List halfYearMonth = DateUtil.getHalfYearMonth(true); + chartData.put("xAxisData", halfYearMonth); + + List seriesData = new ArrayList(); + for (int i = 0; i < legendData.size(); i++) { + PageData pd = new PageData(); + pd.put("CORPINFO_ID", CORPINFO_ID); + pd.put("STATENAME",legendData.get(i)); + List data = new ArrayList(); + List hdRecChart = hiddenService.statisticsGroupMonthByState(pd); //根据状态按时间分组统计隐患数据 + for (int j = 0; j < halfYearMonth.size(); j++) { + boolean flag = true; + for (int k = 0; k < hdRecChart.size(); k++) { + if (halfYearMonth.get(j).equals(hdRecChart.get(k).getString("CREATMONTH"))) { + flag = false; + data.add(hdRecChart.get(k).get("COUNT")); + break; + } + } + if (flag) { + data.add(0); + } + } + seriesData.add(data); + } + chartData.put("seriesData", seriesData); + map.put("chartData", chartData); + + map.put("result", errInfo); + return map; + } + + + /** + * 可视化首页 风险程度统计 + * + * @param + * @throws Exception + */ + @RequestMapping(value = "/findRiskPointChartData") + @ResponseBody + public Object findRiskPointChartData() throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = this.getPageData(); + pd.put("CORPINFO_ID", CORPINFO_ID); + Map chartData = new HashMap(); + List deptList = riskpointService.listDeptByPoint(pd); + List yAxisData = new ArrayList(); + for(PageData d :deptList){ + PageData pdf = new PageData(); + yAxisData.add(d.getString("DEPT_NAME")); + } + chartData.put("yAxisData", yAxisData); + + List varList = dictionariesService.listSubDictByParentId("5a81e63ec0e94d919b3138bc01dbef6b"); + List legendData = new ArrayList(); + List seriesData = new ArrayList(); + for(Dictionaries d :varList){ + PageData pdf = new PageData(); + legendData.add(d.getNAME()); + seriesData.add(new ArrayList()); + } + chartData.put("legendData", legendData); + //隐患整改趋势(近半年) + for (int i = 0; i < deptList.size(); i++) { + PageData dept = new PageData(); + dept.put("DEPARTMENT_ID",deptList.get(i).getString("DEPARTMENT_ID")); + List dataChart = riskpointService.statisticsGroupLevelByDept(dept); //按照级别分类统计各部门风险管控数据 + for (int j = 0; j < varList.size(); j++) { + List secondList = (List) seriesData.get(j); + secondList.add(i, dataChart.get(j).getString("COUNT")); + } + } + chartData.put("seriesData", seriesData); + map.put("chartData", chartData); + map.put("result", errInfo); + return map; + } + + /** + * 可视化首页 本月人员进出 + * + * @param + * @throws Exception + */ + @RequestMapping(value = "/findCarUserChartData") + @ResponseBody + public Object findCarUserChartData() throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + //隐患整改趋势(近半年) + Map chartData = new HashMap(); +// List legendData = Arrays.asList(new String[]{"进入人员", "外出人员", "刷卡率"}); + List legendData = Arrays.asList(new String[]{"进入人员", "外出人员"}); + chartData.put("legendData", legendData); + List thisMonth = DateUtil.getThisMonth(false); // 本月日期 + chartData.put("xAxisData", thisMonth); + + List seriesData = new ArrayList(); + for (int i = 0; i < legendData.size(); i++) { + PageData pd = new PageData(); + pd.put("CORPINFO_ID", CORPINFO_ID); + pd.put("STATENAME", legendData.get(i)); + List data = new ArrayList(); + List hdRecChart = cardUserService.statisticsGroupDay(pd); //根据状态按时间分组统计人员进出刷卡 + for (int j = 0; j < thisMonth.size(); j++) { + boolean flag = true; + for (int k = 0; k < hdRecChart.size(); k++) { + if (thisMonth.get(j).equals(hdRecChart.get(k).getString("CREATDAY"))) { + flag = false; + data.add(hdRecChart.get(k).get("COUNT")); + break; + } + } + if (flag) { + data.add(0); + } + } + seriesData.add(data); + } + chartData.put("seriesData", seriesData); + map.put("chartData", chartData); + + map.put("result", errInfo); + return map; + } + + /** + * 可视化首页 报警处置情况 + * + * @param + * @throws Exception + */ + @RequestMapping(value = "/findAlarmDisposalChartData") + @ResponseBody + public Object findAlarmDisposalChartData() throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = this.getPageData(); + pd.put("CORPINFO_ID", CORPINFO_ID); + //隐患整改趋势(近半年) + Map chartData = new HashMap(); + List legendData = Arrays.asList(new String[]{"报警数", "已处置", "处置中"}); + chartData.put("legendData", legendData); + List xAxisData = new ArrayList(); + List seriesData1 = new ArrayList(); + List seriesData2 = new ArrayList(); + List seriesData3 = new ArrayList(); + + List disposalChart = majordangersourceDisposalService.statisticsGroupMajordangersource(pd); //根据重大危险源分组统计报警处置情况 + List seriesData = new ArrayList(); + for (PageData data : disposalChart) { + xAxisData.add(data.getString("MAJORDANGERSOURCE_NAME")); + seriesData1.add(data.get("COUNTALARM")); + seriesData2.add(data.get("COUNTDISPOSED")); + seriesData3.add(data.get("COUNTDISPOSAL")); + } + chartData.put("xAxisData", xAxisData); + seriesData.add(seriesData1); + seriesData.add(seriesData2); + seriesData.add(seriesData3); + chartData.put("seriesData", seriesData); + map.put("chartData", chartData); + + map.put("result", errInfo); + return map; + } + + /** + * 可视化首页 作业类型统计分析 + * + * @param + * @throws Exception + */ + @RequestMapping(value = "/findHighRiskWorkChartData") + @ResponseBody + public Object findHighRiskWorkChartData() throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = this.getPageData(); + pd.put("CORPINFO_ID", CORPINFO_ID); + //隐患整改趋势(近半年) + Map chartData = new HashMap(); + List legendData = Arrays.asList(new String[]{"动火作业", "临时用电作业", "盲板作业", "高处作业", "有限空间作业", "吊装作业"}); + + List workChart = highworkService.statisticsAllHighRiskWork(pd); //统计高危作业里各作业数 + List seriesData = new ArrayList(); + for (int i = 0; i < legendData.size(); i++) { + PageData pie = new PageData(); + pie.put("name", legendData.get(i)); + pie.put("value", workChart.get(i).get("COUNT")); + seriesData.add(pie); + } + chartData.put("seriesData", seriesData); + map.put("chartData", chartData); + + map.put("result", errInfo); + return map; + } + + /**数据可视化平台首页获取 + * 1.获取企业的置顶视频 + * 2.获取管理的置顶视频 + * 3.没有视频或者没有置顶视频 + * @param + * @throws Exception + */ + @RequestMapping(value="/getObjectForBiLogin") + @ResponseBody + public Object getObjectForBiLogin() throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd.put("TYPE", "1"); + pd.put("CORPINFO_TYPE", "1"); + pd.put("CORPINFO_ID", CORPINFO_ID); + List cpvarList = videoService.listAll(pd); //企业视频 + pd = new PageData(); + pd.put("CORPINFO_TYPE", "2"); + pd.put("TYPE", "1"); + List ptVarList = videoService.listAll(pd); //平台视频 + + map.put("ptVarList", ptVarList); + map.put("cpvarList", cpvarList); + map.put("result", errInfo); + return map; + } + + /**获取重大危险源数据 + * @param + * @throws Exception + */ + @RequestMapping(value="/findValidateData") + @ResponseBody + public Object findValidateData() throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = this.getPageData(); + List varList = majordangersourcedisposalService.listAll(pd); //根据ID读取 + map.put("varList", varList); + map.put("result", errInfo); + return map; + } + + + /** + * 清单检查完成率统计 + * + * @param + * @throws Exception + */ + @RequestMapping(value = "/goIndexCount") + @ResponseBody + public Object goIndexCount() throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = this.getPageData(); + pd.put("CORPINFO_ID", CORPINFO_ID); // 企业 + String STARTTIME = pd.getString("STARTTIME"); // 关键词检索条件 + if (Tools.notEmpty(STARTTIME)) + pd.put("STARTTIME", STARTTIME.trim() + " 00:00:00"); + String ENDTIME = pd.getString("ENDTIME"); // 关键词检索条件 + if (Tools.notEmpty(ENDTIME)) + pd.put("ENDTIME", ENDTIME.trim() + " 23:59:59"); + + List varList = new ArrayList(); + PageData listType0001 = new PageData(); + PageData listType0002 = new PageData(); + PageData listType0003 = new PageData(); + PageData listType0004 = new PageData(); + PageData listType0005 = new PageData(); + PageData all = new PageData(); + + Map varMap = new HashMap(); + + listType0001.put("type", "listType0001"); + listType0001.put("name", "日常"); + listType0001.put("molecule", 0); + listType0001.put("denominator", 0); + listType0001.put("percentage", 0d); + listType0002.put("type", "listType0002"); + listType0002.put("name", "综合"); + listType0002.put("molecule", 0); + listType0002.put("denominator", 0); + listType0002.put("percentage", 0d); + + listType0003.put("type", "listType0003"); + listType0003.put("name", "专业"); + listType0003.put("molecule", 0); + listType0003.put("denominator", 0); + listType0003.put("percentage", 0d); + + listType0004.put("type", "listType0004"); + listType0004.put("name", "季节性"); + listType0004.put("molecule", 0); + listType0004.put("denominator", 0); + listType0004.put("percentage", 0d); + + listType0005.put("type", "listType0005"); + listType0005.put("name", "节假日"); + listType0005.put("molecule", 0); + listType0005.put("denominator", 0); + listType0005.put("percentage", 0d); + + all.put("type", "all"); + all.put("name", "合计"); + all.put("molecule", 0); + all.put("denominator", 0); + all.put("percentage", 0d); + + varMap.put("listType0001", listType0001); + varMap.put("listType0002", listType0002); + varMap.put("listType0003", listType0003); + varMap.put("listType0004", listType0004); + varMap.put("listType0005", listType0005); + varMap.put("all", all); + + List countList = listStatisticsService.getCountList(pd);// 统计分母 + + if (countList != null && countList.size() > 0) { + List dayList = checkrecordService.listCountDay(pd); // 统计--日 + if (dayList != null && dayList.size() > 0) { + for (PageData count : dayList) { + Integer molecule = Integer.parseInt(count.get("NUM").toString()) + + Integer.parseInt(varMap.get(count.get("TYPE")).get("molecule").toString()); + varMap.get(count.get("TYPE")).put("molecule", molecule); + + Integer allMolecule = Integer.parseInt(count.get("NUM").toString()) + + Integer.parseInt(varMap.get("all").get("molecule").toString()); + varMap.get("all").put("molecule", allMolecule); + } + } + List weekList = checkrecordService.listCountWeek(pd); // 统计--周 + if (weekList != null && weekList.size() > 0) { + for (PageData count : weekList) { + Integer molecule = Integer.parseInt(count.get("NUM").toString()) + + Integer.parseInt(varMap.get(count.get("TYPE")).get("molecule").toString()); + varMap.get(count.get("TYPE")).put("molecule", molecule); + + Integer allMolecule = Integer.parseInt(count.get("NUM").toString()) + + Integer.parseInt(varMap.get("all").get("molecule").toString()); + varMap.get("all").put("molecule", allMolecule); + } + } + List monthList = checkrecordService.listCountMonth(pd); // 统计--月 + + if (monthList != null && monthList.size() > 0) { + for (PageData count : monthList) { + Integer molecule = Integer.parseInt(count.get("NUM").toString()) + + Integer.parseInt(varMap.get(count.get("TYPE")).get("molecule").toString()); + varMap.get(count.get("TYPE")).put("molecule", molecule); + + Integer allMolecule = Integer.parseInt(count.get("NUM").toString()) + + Integer.parseInt(varMap.get("all").get("molecule").toString()); + varMap.get("all").put("molecule", allMolecule); + } + } + List quarterList = checkrecordService.listCountQuarter(pd); // 统计--季 + + if (quarterList != null && quarterList.size() > 0) { + for (PageData count : quarterList) { + Integer molecule = Integer.parseInt(count.get("NUM").toString()) + + Integer.parseInt(varMap.get(count.get("TYPE")).get("molecule").toString()); + varMap.get(count.get("TYPE")).put("molecule", molecule); + + Integer allMolecule = Integer.parseInt(count.get("NUM").toString()) + + Integer.parseInt(varMap.get("all").get("molecule").toString()); + varMap.get("all").put("molecule", allMolecule); + } + } + List halfYearList = checkrecordService.listCountHalfYear(pd); // 统计--半年 + + if (halfYearList != null && halfYearList.size() > 0) { + for (PageData count : halfYearList) { + Integer molecule = Integer.parseInt(count.get("NUM").toString()) + + Integer.parseInt(varMap.get(count.get("TYPE")).get("molecule").toString()); + varMap.get(count.get("TYPE")).put("molecule", molecule); + + Integer allMolecule = Integer.parseInt(count.get("NUM").toString()) + + Integer.parseInt(varMap.get("all").get("molecule").toString()); + varMap.get("all").put("molecule", allMolecule); + } + } + List yearList = checkrecordService.listCountYear(pd); // 统计--年 + if (yearList != null && yearList.size() > 0) { + for (PageData count : yearList) { + Integer molecule = Integer.parseInt(count.get("NUM").toString()) + + Integer.parseInt(varMap.get(count.get("TYPE")).get("molecule").toString()); + varMap.get(count.get("TYPE")).put("molecule", molecule); + + Integer allMolecule = Integer.parseInt(count.get("NUM").toString()) + + Integer.parseInt(varMap.get("all").get("molecule").toString()); + varMap.get("all").put("molecule", allMolecule); + } + } + // 处理旬时间 + StringBuffer stt = new StringBuffer(); + stt.append(pd.getString("STARTTIME")); + stt.setCharAt(9, '1'); + pd.put("STARTTIME", stt.toString()); + + String endDay = ENDTIME.substring(8, 10); + Integer endTime = Integer.parseInt(endDay); + StringBuffer et = new StringBuffer(); + et.append(pd.getString("ENDTIME")); + + if (endTime <= 10) { + stt.setCharAt(8, '1'); + stt.setCharAt(9, '0'); + pd.put("ENDTIME", et.toString()); + } else if (endTime <= 20) { + stt.setCharAt(8, '2'); + stt.setCharAt(9, '0'); + pd.put("ENDTIME", et.toString()); + } else { + Integer endMonth = Integer.parseInt(ENDTIME.substring(5, 7)); + Integer endYear = Integer.parseInt(ENDTIME.substring(0, 4)); + pd.put("ENDTIME", getLastDayOfMonth(endYear, endMonth) + " 23:59:59"); + } + List tenDaysList = checkrecordService.listCountTenDays(pd); // 统计--旬 + if (tenDaysList != null && tenDaysList.size() > 0) { + for (PageData count : tenDaysList) { + Integer molecule = Integer.parseInt(count.get("NUM").toString()) + + Integer.parseInt(varMap.get(count.get("TYPE")).get("molecule").toString()); + varMap.get(count.get("TYPE")).put("molecule", molecule); + + Integer allMolecule = Integer.parseInt(count.get("NUM").toString()) + + Integer.parseInt(varMap.get("all").get("molecule").toString()); + varMap.get("all").put("molecule", allMolecule); + } + } + // 分母 + for (PageData count : countList) { + Integer denominator = Integer.parseInt(count.get("NOTEXAMINEDNUM").toString()) + + Integer.parseInt(varMap.get(count.get("TYPE")).get("denominator").toString()); + varMap.get(count.get("TYPE")).put("denominator", denominator); + + Integer allDenominator = Integer.parseInt(count.get("NOTEXAMINEDNUM").toString()) + + Integer.parseInt(varMap.get("all").get("denominator").toString()); + varMap.get("all").put("denominator", allDenominator); + } + } + for (int i = 1; i < 5; i++) { + String type = "listType000" + i; + if (!varMap.get(type).get("denominator").toString().equals("0")) { + if (varMap.get(type).get("molecule").toString().equals("0")) { + varMap.get(type).put("percentage", 0d); + } else { + Double denominator = Double.parseDouble(varMap.get(type).get("denominator").toString()); + Double molecule = Double.parseDouble(varMap.get(type).get("molecule").toString()); + Double percentage = molecule / denominator * 100; + DecimalFormat df = new DecimalFormat("#.00"); + varMap.get(type).put("percentage", df.format(percentage)); + } + + } + varList.add(varMap.get(type)); + } + if (!varMap.get("listType0005").get("denominator").toString().equals("0")) { + Integer jjr = checkrecordService.listCountJjr(pd) == null ? 0 : checkrecordService.listCountJjr(pd); + if (jjr == 0) { + varMap.get("listType0005").put("percentage", 0d); + } else { + Double denominator = Double.parseDouble(varMap.get("listType0005").get("denominator").toString()); + Double molecule = Double.valueOf(jjr); + Double percentage = molecule / denominator * 100; + DecimalFormat df = new DecimalFormat("#.00"); + varMap.get("listType0005").put("percentage", df.format(percentage)); + } + } + Integer allMolecule = Integer.parseInt(varMap.get("listType0005").get("molecule").toString()) + + Integer.parseInt(varMap.get("all").get("molecule").toString()); + varMap.get("all").put("molecule", allMolecule); + varList.add(varMap.get("listType0005")); + if (!varMap.get("all").get("denominator").toString().equals("0")) { + if (varMap.get("all").get("molecule").toString().equals("0")) { + varMap.get("all").put("percentage", 0d); + } else { + Double denominator = Double.parseDouble(varMap.get("all").get("denominator").toString()); + Double molecule = Double.parseDouble(varMap.get("all").get("molecule").toString()); + Double percentage = molecule / denominator * 100; + DecimalFormat df = new DecimalFormat("#.00"); + varMap.get("all").put("percentage", df.format(percentage)); + } + } + varList.add(varMap.get("all")); + map.put("varList", varList); + map.put("varMap", varMap); + map.put("result", errInfo); + return map; + } + + public static String getLastDayOfMonth(int year, int month) { + Calendar cal = Calendar.getInstance(); + // 设置年份 + cal.set(Calendar.YEAR, year); + // 设置月份 + cal.set(Calendar.MONTH, month - 1); + // 获取某月最大天数 + int lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH); + // 设置日历中月份的最大天数 + cal.set(Calendar.DAY_OF_MONTH, lastDay); + // 格式化日期 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String lastDayOfMonth = sdf.format(cal.getTime()); + + return lastDayOfMonth; + } + + /**首页 获取折线图 + * @param + * @throws Exception + */ + @RequestMapping(value="/listmanagerIndexCount") + @ResponseBody + public Object listmanagerIndexCount() throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = this.getPageData(); + pd.put("CORPINFO_ID", CORPINFO_ID); //企业 + List valList = listmanagerService.goIndexCount(pd); + List valList1 = new ArrayList(); + + //杨明图标数据 +// {months: "2022-06", count: 0, screenType: "riskChecklistType0001"} +// 6 * 3 近6個月 ,3 三种类型 + + Map monSCrMap = new HashMap<>(); + for (PageData pageData : valList){ + String key = pageData.getString("months")+"*"+pageData.getString("screenType"); + monSCrMap.put(key,pageData.getString("count")); + } + + + List halfYearMonth = DateUtil.getHalfYearMonth(true); + String [] typeAll = new String[]{"riskChecklistType0001","riskChecklistType0002","zhqd03"}; + + + List> list = new ArrayList<>(); // 整理完成的数据 size 6 * 3 + for(String month : halfYearMonth){ + for (String type : typeAll){ + String count = "0"; + + String key = month +"*" + type; + if (monSCrMap.containsKey(key)){ + count = monSCrMap.get(key); + } + Map monAndType = new HashMap<>(); + monAndType.put("months",month); + monAndType.put("screenType",type); + monAndType.put("count",count); + list.add(monAndType); + } + } + + System.out.println(list); + map.put("xAxisData", halfYearMonth); + map.put("valList", list); + map.put("result", errInfo); + return map; + } + + /** + * 隐患数量统计 + * + * @param page + * @throws Exception + */ + @RequestMapping(value = "/getCountByUserId") + @ResponseBody + public Object getCountByUserId(Page page) throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = this.getPageData(); + Map hidCount = new HashMap<>(); + + pd.put("userId", USER_ID); // 发现人 + Integer dzg = 0;// 待整改 1 + Integer ycq = 0;// 已超期 5 + Integer dfc = 0;// 待复查 2 + Integer yys = 0;// 已验收 4 + // STATE -- 隐患状态 0-未提交 1- 未整改 2-已整改 3-已复查 4-已验收 5-已过期 + if (Tools.notEmpty(pd.get("userId").toString())) { + pd.put("SELFUSERID", USER_ID); + pd.put("CORPINFO_ID", CORPINFO_ID); + + List rectifiHid = hiddenService.getCountByRectifiCationorId(pd); // 根据人员id获取整改隐患信息 state 1 5 + for (int i = 0; i < rectifiHid.size(); i++) { + PageData rec = rectifiHid.get(i); + if (null == rec.get("STATE")) { + continue; + } + if (rec.get("STATE").equals("1") || rec.get("STATE").equals("-1")) { + dzg++; + } + } + List creatorHid = hiddenService.getCountByCreatorId(pd); // 根据人员id获取发现隐患信息 + for (int i = 0; i < creatorHid.size(); i++) { + PageData cre = creatorHid.get(i); + if (null == cre.get("STATE")) { + continue; + } + if (cre.get("STATE").equals("2")) { + dfc++; + } + if (cre.get("STATE").equals("4")) { + yys++; + } + if (cre.get("STATE").equals("-1")) { + ycq++; + } + } + } + hidCount.put("dzg", dzg); + hidCount.put("ycq", ycq); + hidCount.put("dfc", dfc); + hidCount.put("yys", yys); + + map.put("hidCount", hidCount); + map.put("page", page); + map.put("result", errInfo); + return map; + } + + /** + * 风险点统计 + * + * @param + * @throws Exception + */ + @RequestMapping(value = "/statistic") + @ResponseBody + public Object statistic() throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = this.getPageData(); + pd.put("CORPINFO_ID", CORPINFO_ID); + + List riskAll = riskpointService.statisticsAll(pd); + List idAll = identificationPartsService.listIndexAll(pd); + List unitAll = riskUnitService.listIndexAll(pd); + Integer idcount = 0; + Integer unitcount = 0; + Integer cnzfx = 0; + if (idAll != null && idAll.size() > 0) { + idcount = idAll.size(); + } + if (unitAll != null && unitAll.size() > 0) { + unitcount = unitAll.size(); + } + for (int i = 0; riskAll.size() > i; i++) { + if (riskAll.get(i).get("LEVELID") != null && Tools.notEmpty(riskAll.get(i).get("LEVELID").toString())) { + if ("levelA".equals(riskAll.get(i).get("LEVELID").toString()) + || "levelB".equals(riskAll.get(i).get("LEVELID").toString()) + || "levelC".equals(riskAll.get(i).get("LEVELID").toString()) + || "levelD".equals(riskAll.get(i).get("LEVELID").toString())) { + cnzfx += Integer.valueOf(riskAll.get(i).get("COUNT").toString()); + } + } + } + + Map riskCount = new HashMap<>(); + + riskCount.put("idcount", idcount); + riskCount.put("unitcount", unitcount); + riskCount.put("cnzfx", cnzfx); + // 风险点-只按名称统计 辨识部位-统计不同单元内的辨识部位名称的总数 + + map.put("riskCount", riskCount); + map.put("riskAll", riskAll); + map.put("idAll", idAll); + map.put("unitAll", unitAll); + map.put("result", errInfo); + return map; + } + + + /** + * 隐患类型数量统计 + * + * @param page + * @throws Exception + */ + @RequestMapping(value = "/getCountByHiddenType") + @ResponseBody + public Object getCountByHiddenType(Page page) throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = this.getPageData(); + pd.put("CORPINFO_ID", CORPINFO_ID); + + List dicIdsList = dictionariesService.getIdsByRecuByParentId("3babc15144444bdc8d763d0af2bdfff6"); + int anl = 0; + int hbl = 0; + String anlIDs = dicIdsList.get(0).getString("ids"); + String hblIDs = dicIdsList.get(1).getString("ids"); + List hiddList = hiddenService.getCountByHiddenType(pd); + for (PageData pageData : hiddList) { + String hiddenType = pageData.getString("DICTIONARIES_ID"); + if (anlIDs.indexOf(hiddenType) != -1) { + anl += Integer.parseInt(pageData.getString("count")); + } + if (hblIDs.indexOf(hiddenType) != -1) { + hbl += Integer.parseInt(pageData.getString("count")); + } + } + + List valList = new ArrayList(); + Map valMap = new HashMap<>(); + valMap.put("name", "安全隐患"); + valMap.put("value", anl); + valList.add(valMap); + valMap = new HashMap<>(); + valMap.put("name", "卫生环保"); + valMap.put("value", hbl); + + valList.add(valMap); + map.put("hiddenTypeCount", valList); + map.put("result", errInfo); + return map; + } + + /**平台公告 + * @param page + * @throws Exception + */ + @RequestMapping(value="/listByIndex") + @ResponseBody + public Object listByIndex(Page page) throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = this.getPageData(); + //获取发布给这个企业的信息 + pd.put("CORP_INFO_ID", CORPINFO_ID); + page.setPd(pd); + List varList = noticeService.getNotAndCorpByCorpId(page); + + map.put("varList", varList); + map.put("page", page); + map.put("result", errInfo); + return map; + } + + /**企业公告 + * @param page + * @throws Exception + */ + @RequestMapping(value="/enterpriseListByIndex") + @ResponseBody + public Object enterpriseListByIndex(Page page) throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = this.getPageData(); + String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件 + if(Tools.notEmpty(KEYWORDS))pd.put("KEYWORDS", KEYWORDS.trim()); + pd.put("USER_ID", USER_ID); + page.setPd(pd); + List varList = noticecorpService.listByIndex(page); //列出NOTICECORP列表 + map.put("varList", varList); + map.put("page", page); + map.put("result", errInfo); + return map; + } + + + /**清單列表 + * @param + * @throws Exception + */ + @RequestMapping(value="/checkListIndex") + @ResponseBody + public Object checkListIndex() throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + pd.put("CORPINFO_ID", CORPINFO_ID); //企业 + pd.put("USER_ID",USER_ID); + pd.put("DEPARTMENT_ID", DEPT_ID); + + pd.put("USER_ID",""); + List varList = listmanagerService.listAll(pd); //列出ListManager列表 + int wjcNum = 0; + int yjcNum = 0; + for (PageData list : varList) { + if(list.getString("TYPE").equals("listType0005")) { + if(Integer.parseInt(list.get("checkCount").toString()) > 0) { + yjcNum++; + } else { + wjcNum++; + } + continue; + } + if(Integer.parseInt(list.get("checkCount").toString()) > 0) { + yjcNum++; + } else { + wjcNum++; + } + } + map.put("yjcNum", yjcNum); + map.put("wjcNum", wjcNum); + map.put("varList", varList); + map.put("result", errInfo); + return map; + } + + +} diff --git a/src/main/resources/mybatis/datasource/bus/CheckRecordMapper.xml b/src/main/resources/mybatis/datasource/bus/CheckRecordMapper.xml index 98b1f378..35b58d38 100644 --- a/src/main/resources/mybatis/datasource/bus/CheckRecordMapper.xml +++ b/src/main/resources/mybatis/datasource/bus/CheckRecordMapper.xml @@ -192,7 +192,7 @@ f.TYPE, f.PERIODSTART DATESTART, f.PERIODEND DATEEND, - u.NAME AS USER_NAME, + getUnameByUid(u.USER_ID) AS USER_NAME, su.NAME AS PRINCIPALNAME, (select group_concat(chr.NAME) from BUS_CHECKUSER bh left join sys_user chr on chr.USER_ID=bh.USER_ID where bh.CHECKRECORD_ID=f.CHECKRECORD_ID) CHECK_USERS from diff --git a/src/main/resources/mybatis/datasource/bus/ListManagerMapper.xml b/src/main/resources/mybatis/datasource/bus/ListManagerMapper.xml index ab860678..274a6ac4 100644 --- a/src/main/resources/mybatis/datasource/bus/ListManagerMapper.xml +++ b/src/main/resources/mybatis/datasource/bus/ListManagerMapper.xml @@ -192,7 +192,7 @@ sp.NAME AS POST_NAME, s.NAME AS SCREENTYPENAME, - u.NAME AS USER_NAME + getUnameByUid(f.USER_ID) AS USER_NAME from f @@ -220,7 +220,7 @@ d.NAME as DEPARTMENT_NAME, sp.NAME AS POST_NAME, - u.NAME USER_NAME, + getUnameByUid(f.USER_ID) USER_NAME, s.NAME AS SCREENTYPENAME, (select count(1) from BUS_LIST_CHECKITEM ch where ch.LISTMANAGER_ID=f.LISTMANAGER_ID and ch.ISDELETE = '0') as count , @@ -271,7 +271,7 @@ and f.DEPARTMENT_ID = #{pd.DEPARTMENT_ID} - and u.NAME LIKE CONCAT(CONCAT('%', #{pd.USERNAME}),'%') + and getUnameByUid(f.USER_ID) LIKE CONCAT(CONCAT('%', #{pd.USERNAME}),'%') and f.TYPE = #{pd.TYPE} @@ -500,7 +500,7 @@ d.NAME as DEPARTMENT_NAME, sp.NAME AS POST_NAME, - u.NAME USER_NAME, + getUnameByUid(f.USER_ID) USER_NAME, (select count(1) from BUS_LIST_CHECKITEM ch where ch.LISTMANAGER_ID=f.LISTMANAGER_ID and ch.ISDELETE =0) as count, @@ -593,7 +593,7 @@ d.NAME as DEPARTMENT_NAME, sp.NAME AS POST_NAME, - u.NAME USER_NAME, + getUnameByUid(f.USER_ID) USER_NAME, (select count(1) from BUS_LIST_CHECKITEM ch where ch.LISTMANAGER_ID=f.LISTMANAGER_ID and ch.ISDELETE =0) as count, ve.numCount checkCount from @@ -649,7 +649,7 @@ and f.DEPARTMENT_ID = #{pd.DTID} - and u.NAME LIKE CONCAT(CONCAT('%', #{pd.USERNAME}),'%') + and getUnameByUid(f.USER_ID) LIKE CONCAT(CONCAT('%', #{pd.USERNAME}),'%') and f.NAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%') From 876b63f0e6bfe5020dd604b8b65938b3c08f6a6d Mon Sep 17 00:00:00 2001 From: huangyuxuan Date: Thu, 19 Sep 2024 14:36:11 +0800 Subject: [PATCH 10/10] =?UTF-8?q?[=E6=96=B0=E5=A2=9E=E5=8A=9F=E8=83=BD](hy?= =?UTF-8?q?x=5FchangeFileUpload=5F2024-9-10)=20ClearFilesJob.java=20=20-?= =?UTF-8?q?=20=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E6=AF=8F=E6=97=A5=E6=B8=85=E7=90=8630=E5=A4=A9=E5=89=8D?= =?UTF-8?q?=E7=9A=84=E4=B8=B4=E6=97=B6=E6=96=87=E4=BB=B6=20DateUtil.java?= =?UTF-8?q?=20=20-=20=E6=96=B0=E5=A2=9E=20=E8=8E=B7=E5=8F=9630=E5=A4=A9?= =?UTF-8?q?=E4=B9=8B=E5=89=8D=E7=9A=84=E6=97=A5=E6=9C=9F=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E4=B8=B2=20=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/bus/ImgFilesController.java | 117 +++++++++++------- .../filemanager/MfolderController.java | 84 +++++++++++-- .../tzsb/SpecialEquipmentAqxjController.java | 4 +- .../java/com/zcloud/util/ClearFilesJob.java | 12 +- src/main/java/com/zcloud/util/DateUtil.java | 14 +++ .../java/com/zcloud/util/FileUploadUtil.java | 36 ++++-- 6 files changed, 200 insertions(+), 67 deletions(-) diff --git a/src/main/java/com/zcloud/controller/bus/ImgFilesController.java b/src/main/java/com/zcloud/controller/bus/ImgFilesController.java index 65dcb6b2..c2f07f61 100644 --- a/src/main/java/com/zcloud/controller/bus/ImgFilesController.java +++ b/src/main/java/com/zcloud/controller/bus/ImgFilesController.java @@ -81,61 +81,92 @@ public class ImgFilesController extends BaseController { public Object finish( @RequestParam(value="FFILE",required=false) MultipartFile[] files, @RequestParam(value="TYPE",required=false) String TYPE, - @RequestParam(value="FOREIGN_KEY",required=false) String FOREIGN_KEY + @RequestParam(value="FOREIGN_KEY",required=false) String FOREIGN_KEY, + @RequestParam(value="temporaryFilePath",required=false) String[] temporaryFilePath ) throws Exception{ Map map = new HashMap(); System.out.println("+++++++++++++++"+files); + System.out.println("==================="+temporaryFilePath); String errInfo = "success"; - if (files != null && files.length > 0) { - for (int i = 0; i < files.length; i++) { - String suffixName = files[i].getOriginalFilename().substring(files[i].getOriginalFilename().lastIndexOf(".")+1).toLowerCase(); + if (temporaryFilePath != null && temporaryFilePath.length > 0) { + for (int i = 0; i < temporaryFilePath.length; i++) { + String suffixName = temporaryFilePath[i].substring(temporaryFilePath[i].lastIndexOf(".")+1).toLowerCase(); if (!"json".equals(suffixName) && !"pdf".equals(suffixName) && !"jpg".equals(suffixName) && !"jpeg".equals(suffixName) && !"png".equals(suffixName) && !"mp4".equals(suffixName)) { errInfo = "fail"; map.put("result", errInfo); map.put("msg", "文件格式不正确!"); return map; } - } - for (int i = 0; i < files.length; i++) { - MultipartFile file = files[i]; -// 保存文件 - File tempFile = new File(file.getOriginalFilename()); - FileUtils.copyInputStreamToFile(file.getInputStream(), tempFile); - if(!FileUpload.isImage(tempFile) && !TYPE.equals("2")) {//四色图改为json文件,不用判断类型 - tempFile.delete(); - map.put("result", "failed"); - map.put("exception", "上传图片格式不正确,请重新上传"); - return map; - } - if (tempFile.exists()) { - tempFile.delete(); - } - - if(TYPE.equals("2")) {//先删除原四色图 - PageData pd2 = new PageData(); - pd2.put("FOREIGN_KEY",FOREIGN_KEY); - pd2.put("TYPE",TYPE); - List four = imgfilesService.listAll(pd2); - for (PageData pageData : four) { - File old = new File(PathUtil.getProjectpath()+pageData.getString("FILEPATH")); - old.delete(); - imgfilesService.delete(pageData); + if(TYPE.equals("2")) {//先删除原四色图 + PageData pd2 = new PageData(); + pd2.put("FOREIGN_KEY",FOREIGN_KEY); + pd2.put("TYPE",TYPE); + List four = imgfilesService.listAll(pd2); + for (PageData pageData : four) { + File old = new File(PathUtil.getProjectpath()+pageData.getString("FILEPATH")); + old.delete(); + imgfilesService.delete(pageData); } - } - String ffile = DateUtil.getDays(); -// String filePath = PathUtil.getProjectpath() + Const.FILEPATHFILE + ffile; //文件上传路径 -// String fileName = FileUpload.fileUp(file, filePath, this.get32UUID()); //执行上传 - String fileName = this.get32UUID()+file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); - Smb.sshSftp(file, fileName,Const.FILEPATHYHTP + Jurisdiction.getCORPINFO_ID() + "/" + ffile); - PageData pd = new PageData(); - pd.put("IMGFILES_ID", this.get32UUID()); - pd.put("FILEPATH", Const.FILEPATHYHTP + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName); - pd.put("TYPE", TYPE); - pd.put("FOREIGN_KEY", FOREIGN_KEY); - imgfilesService.save(pd); - } - } + } +// String productPath = FileUploadUtil.copyTemporaryFileToProduct(temporaryFilePath[i]); + PageData pd = new PageData(); + pd.put("IMGFILES_ID", this.get32UUID()); + pd.put("FILEPATH", temporaryFilePath[i]); + pd.put("TYPE", TYPE); + pd.put("FOREIGN_KEY", FOREIGN_KEY); + imgfilesService.save(pd); + } + } +// if (files != null && files.length > 0) { +// for (int i = 0; i < files.length; i++) { +// String suffixName = files[i].getOriginalFilename().substring(files[i].getOriginalFilename().lastIndexOf(".")+1).toLowerCase(); +// if (!"json".equals(suffixName) && !"pdf".equals(suffixName) && !"jpg".equals(suffixName) && !"jpeg".equals(suffixName) && !"png".equals(suffixName) && !"mp4".equals(suffixName)) { +// errInfo = "fail"; +// map.put("result", errInfo); +// map.put("msg", "文件格式不正确!"); +// return map; +// } +// } +// for (int i = 0; i < files.length; i++) { +// MultipartFile file = files[i]; +//// 保存文件 +// File tempFile = new File(file.getOriginalFilename()); +// FileUtils.copyInputStreamToFile(file.getInputStream(), tempFile); +// if(!FileUpload.isImage(tempFile) && !TYPE.equals("2")) {//四色图改为json文件,不用判断类型 +// tempFile.delete(); +// map.put("result", "failed"); +// map.put("exception", "上传图片格式不正确,请重新上传"); +// return map; +// } +// if (tempFile.exists()) { +// tempFile.delete(); +// } +// +// if(TYPE.equals("2")) {//先删除原四色图 +// PageData pd2 = new PageData(); +// pd2.put("FOREIGN_KEY",FOREIGN_KEY); +// pd2.put("TYPE",TYPE); +// List four = imgfilesService.listAll(pd2); +// for (PageData pageData : four) { +// File old = new File(PathUtil.getProjectpath()+pageData.getString("FILEPATH")); +// old.delete(); +// imgfilesService.delete(pageData); +// } +// } +// String ffile = DateUtil.getDays(); +//// String filePath = PathUtil.getProjectpath() + Const.FILEPATHFILE + ffile; //文件上传路径 +//// String fileName = FileUpload.fileUp(file, filePath, this.get32UUID()); //执行上传 +// String fileName = this.get32UUID()+file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); +// Smb.sshSftp(file, fileName,Const.FILEPATHYHTP + Jurisdiction.getCORPINFO_ID() + "/" + ffile); +// PageData pd = new PageData(); +// pd.put("IMGFILES_ID", this.get32UUID()); +// pd.put("FILEPATH", Const.FILEPATHYHTP + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName); +// pd.put("TYPE", TYPE); +// pd.put("FOREIGN_KEY", FOREIGN_KEY); +// imgfilesService.save(pd); +// } +// } map.put("result", errInfo); return map; } diff --git a/src/main/java/com/zcloud/controller/filemanager/MfolderController.java b/src/main/java/com/zcloud/controller/filemanager/MfolderController.java index 12d25ec0..3d3395cf 100644 --- a/src/main/java/com/zcloud/controller/filemanager/MfolderController.java +++ b/src/main/java/com/zcloud/controller/filemanager/MfolderController.java @@ -1,9 +1,12 @@ package com.zcloud.controller.filemanager; +import cn.hutool.core.util.ObjectUtil; +import com.zcloud.service.bus.ImgFilesService; import com.zcloud.util.*; import net.sf.json.JSONArray; import java.io.Console; +import java.io.File; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -11,6 +14,7 @@ import java.util.Map; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.io.FileUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; @@ -41,6 +45,9 @@ public class MfolderController extends BaseController { @Autowired private MfolderService mfolderService; + @Autowired + private ImgFilesService imgfilesService; + /**创建目录 * @param * @throws Exception @@ -73,20 +80,33 @@ public class MfolderController extends BaseController { * @date 2024-9-10 * @author hyx */ - @RequestMapping("upLoadTemporary") + @RequestMapping("/upLoadTemporary") @ResponseBody - public Object upLoadTemporary(@RequestParam(value="FFILE",required=false) MultipartFile file) throws Exception{ - Map map = new HashMap(); - if (null != file && !file.isEmpty()) { + public Object upLoadTemporary(@RequestParam(value="FFILE",required=false) MultipartFile file) throws Exception { + Map map = new HashMap(); + String temporaryFilePath = null; + if (null != file && !file.isEmpty()) { + String suffixName = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1).toLowerCase(); + if (!"pdf".equals(suffixName) && !"jpg".equals(suffixName) && !"jpeg".equals(suffixName) && !"png".equals(suffixName) && + !"mp4".equals(suffixName) && !"json".equals(suffixName) && !"pdf".equals(suffixName) && !"jpg".equals(suffixName) && + !"jpeg".equals(suffixName) && !"png".equals(suffixName) && !"mp4".equals(suffixName)) { + map.put("result", "fail"); + map.put("msg", "文件格式不正确!"); + return map; + } + String CORPINFO_ID = Jurisdiction.getCORPINFO_ID(); + temporaryFilePath = FileUploadUtil.uploadTemporaryFile(file, CORPINFO_ID); + map.put("result", "success"); + map.put("temporaryFilePath", temporaryFilePath); + return map; + }else { + map.put("result", "fail"); + map.put("msg","文件为空"); + return map; } - String CORPINFO_ID = Jurisdiction.getCORPINFO_ID(); - String temporaryFilePath = FileUploadUtil.uploadTemporaryFile(file, CORPINFO_ID); - - map.put("temporaryFilePath", temporaryFilePath); - return map; - } + } /** * 保存文件到正式地址 @@ -99,17 +119,57 @@ public class MfolderController extends BaseController { * @date 2024-9-10 * @author hyx */ + @RequestMapping("saveFile") + @ResponseBody public Object saveFile(@RequestParam(value="temporaryFilePath",required=false) String temporaryFilePath, @RequestParam(value="NAME",required=false) String NAME, @RequestParam(value="PARENT_ID",required=false) String PARENT_ID, @RequestParam(value="REMARKS",required=false) String REMARKS, - @RequestParam(value="SHARE",required=false) String SHARE + @RequestParam(value="SHARE",required=false) String SHARE, + @RequestParam(value="TYPE",required=false) String TYPE, + @RequestParam(value="FOREIGN_KEY",required=false) String FOREIGN_KEY ) throws Exception { Map map = new HashMap(); + if (ObjectUtil.hasEmpty(temporaryFilePath)){ + map.put("result", "fail"); + map.put("msg","缺少必要参数"); + return map; + } PageData pd = new PageData(); String productFilePath = FileUploadUtil.copyTemporaryFileToProduct(temporaryFilePath, Jurisdiction.getCORPINFO_ID()); - return null; + //如果上传文件为图片 -> 保存图片流程 + if (ObjectUtil.hasEmpty(TYPE,FOREIGN_KEY)){ + if ("2".equals(TYPE)) { + pd.put("FOREIGN_KEY",FOREIGN_KEY); + pd.put("TYPE",TYPE); + List four = imgfilesService.listAll(pd); + for (PageData pageData : four) { + File old = new File(PathUtil.getProjectpath()+pageData.getString("FILEPATH")); + old.delete(); + imgfilesService.delete(pageData); + } + } + pd.put("IMGFILES_ID", this.get32UUID()); + pd.put("FILEPATH", productFilePath); + pd.put("TYPE", TYPE); + pd.put("FOREIGN_KEY", FOREIGN_KEY); + imgfilesService.save(pd); + }else { //保存企业文件流程 + pd.put("FILEPATH", productFilePath); //文件路径 + pd.put("NAME", NAME); //文件名 + pd.put("PARENT_ID", PARENT_ID); //目录ID + pd.put("CTIME", DateUtil.date2Str(new Date())); //创建时间 + pd.put("UNAME", Jurisdiction.getName()); //上传者,当前用户的姓名 + pd.put("MASTER", Jurisdiction.getUsername()); //用户名 + pd.put("SHARE", SHARE); //是否共享 + pd.put("MFOLDER_ID", this.get32UUID()); //主键 + pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //企业 + mfolderService.save(pd); + } + + map.put("result", "success");//返回结果 + return map; } diff --git a/src/main/java/com/zcloud/controller/tzsb/SpecialEquipmentAqxjController.java b/src/main/java/com/zcloud/controller/tzsb/SpecialEquipmentAqxjController.java index bb80de39..de853eea 100644 --- a/src/main/java/com/zcloud/controller/tzsb/SpecialEquipmentAqxjController.java +++ b/src/main/java/com/zcloud/controller/tzsb/SpecialEquipmentAqxjController.java @@ -66,13 +66,13 @@ public class SpecialEquipmentAqxjController extends BaseController { fileList.add(FILES[i]); if (i!=TYPE.length-1 && !TYPE[i].equals(TYPE[i+1])) { MultipartFile[] fileArr = new MultipartFile[fileList.size()]; - imgFilesController.finish(fileList.toArray(fileArr),type,pd.getString("SPECIALEQUIPMENTAQXJ_ID")); + imgFilesController.finish(fileList.toArray(fileArr),type,pd.getString("SPECIALEQUIPMENTAQXJ_ID"),new String[]{}); fileList.clear(); } } if (fileList.size()>0) { MultipartFile[] fileArr = new MultipartFile[fileList.size()]; - imgFilesController.finish(fileList.toArray(fileArr),type,pd.getString("SPECIALEQUIPMENTAQXJ_ID")); + imgFilesController.finish(fileList.toArray(fileArr),type,pd.getString("SPECIALEQUIPMENTAQXJ_ID"),new String[]{}); } map.put("pd", pd); map.put("result", errInfo); diff --git a/src/main/java/com/zcloud/util/ClearFilesJob.java b/src/main/java/com/zcloud/util/ClearFilesJob.java index bfa677bb..7a7b0ef0 100644 --- a/src/main/java/com/zcloud/util/ClearFilesJob.java +++ b/src/main/java/com/zcloud/util/ClearFilesJob.java @@ -6,6 +6,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.Scheduled; import java.io.File; +import java.util.Date; /** * 定时清除临时文件任务 @@ -18,11 +19,16 @@ public class ClearFilesJob { private final static Logger log = LoggerFactory.getLogger(ClearFilesJob.class); - @Scheduled(cron ="0 0 0 30 * ?") +// @Scheduled(cron ="0 0 0 30 * ?") + @Scheduled(cron = "0 0 0 * * ?") public void scheduled(){ log.info("==========清除临时文件定时任务开启=========="); - String filePath = Const.PATH_PREFIX + Const.TEMPORARY_FILE_PATH; - log.info(delAllFile(filePath) ? "临时文件清除成功!" : "临时文件清除失败!"); + System.out.println("==========清除临时文件定时任务开启=========="); +// String filePath = Const.PATH_PREFIX + Const.TEMPORARY_FILE_PATH; + String filePath = "D:/file/test/linshi/"; + String beforeDayDate = DateUtil.getBeforeDayDate(); + System.out.println("要清除的文件夹:"+ filePath + beforeDayDate); + delAllFile(filePath + beforeDayDate); } /** diff --git a/src/main/java/com/zcloud/util/DateUtil.java b/src/main/java/com/zcloud/util/DateUtil.java index 6b2dcda6..69b0285e 100644 --- a/src/main/java/com/zcloud/util/DateUtil.java +++ b/src/main/java/com/zcloud/util/DateUtil.java @@ -195,6 +195,20 @@ public class DateUtil { return dateStr; } + /** + * 获取30天之前的日期字符串 + * @return yyyyMMdd格式时间字符串 + */ + public static String getBeforeDayDate() { + Calendar canlendar = Calendar.getInstance(); + canlendar.setTime(new Date()); + canlendar.add(Calendar.DATE, -30); + Date date = canlendar.getTime(); + SimpleDateFormat sdfd = new SimpleDateFormat("yyyyMMdd"); + String dateStr = sdfd.format(date); + return dateStr; + } + /** * 得到n天之后是周几 * @param days diff --git a/src/main/java/com/zcloud/util/FileUploadUtil.java b/src/main/java/com/zcloud/util/FileUploadUtil.java index 5764fa73..c96e4e65 100644 --- a/src/main/java/com/zcloud/util/FileUploadUtil.java +++ b/src/main/java/com/zcloud/util/FileUploadUtil.java @@ -4,6 +4,8 @@ import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.IORuntimeException; import org.springframework.web.multipart.MultipartFile; +import java.io.File; + /** * 文件上传工具类 * 变更文件上传方式,原上传方式可能会导致附件丢失 @@ -16,7 +18,11 @@ public class FileUploadUtil { private final static String PATH_PREFIX = "/mnt/vdc1/qask/file"; //服务器路径前缀 private final static String TEMPORARY_FILE_PATH = "/uploadFiles/linshi/"; //临时文件储存路径 - private final static String PRODUCT_FILE_PATH = "/uploadFiles/yhtp/"; //正式文件储存路径 + private final static String PRODUCT_FILE_PATH = "/uploadFiles/zhengshi/"; //正式文件储存路径 +// private final static String PATH_PREFIX = "D:/file"; //服务器路径前缀 +// private final static String TEMPORARY_FILE_PATH = "/test/linshi/"; //临时文件储存路径 +// private final static String PRODUCT_FILE_PATH = "/test/zhengshi/"; //正式文件储存路径 + /** * 上传文件到服务器临时地址 * @@ -31,11 +37,11 @@ public class FileUploadUtil { String ffile = DateUtil.getDays(); String fileName = UuidUtil.get32UUID()+file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); try { - Smb.sshSftp(file,fileName,TEMPORARY_FILE_PATH + CORPINFO_ID + "/" + ffile); + Smb.sshSftp(file,fileName,TEMPORARY_FILE_PATH + ffile + "/" + CORPINFO_ID); } catch (Exception e) { throw new RuntimeException(e); } - return TEMPORARY_FILE_PATH + CORPINFO_ID+ "/" + ffile + "/" + fileName; + return TEMPORARY_FILE_PATH + ffile + "/" + CORPINFO_ID + "/" + fileName; } /** @@ -52,16 +58,32 @@ public class FileUploadUtil { //临时文件在服务器的完整路径 String completeTemporaryPath = PATH_PREFIX + temporaryFilePath; //截取文件名 - String fileName = completeTemporaryPath.substring(completeTemporaryPath.lastIndexOf("")).replace("/",""); + String fileName = completeTemporaryPath.substring(completeTemporaryPath.lastIndexOf("/")).replace("/",""); //正式文件完整路径 - String completeProductPath = PATH_PREFIX + PRODUCT_FILE_PATH + CORPINFO_ID + "/" + DateUtil.getDays() + "/"; + String completeProductPath = PATH_PREFIX + PRODUCT_FILE_PATH + CORPINFO_ID + "/" ; //临时文件拷贝到正式路径 try { - FileUtil.copy(completeTemporaryPath,completeProductPath,true); + FileUtil.copy(completeTemporaryPath,completeProductPath,false); } catch (IORuntimeException e) { throw new RuntimeException(e); } - return PRODUCT_FILE_PATH + fileName; + return PRODUCT_FILE_PATH + CORPINFO_ID + "/" + fileName; + } + + public static String copyTemporaryFileToProduct(String temporaryFilePath) throws Exception { + //临时文件在服务器的完整路径 + String completeTemporaryPath = PATH_PREFIX + temporaryFilePath; + //截取文件名 + String fileName = completeTemporaryPath.substring(completeTemporaryPath.lastIndexOf("/")).replace("/",""); + //正式文件完整路径 + String completeProductPath = PATH_PREFIX + PRODUCT_FILE_PATH + "/" ; + //临时文件拷贝到正式路径 + try { + FileUtil.copy(completeTemporaryPath,completeProductPath,false); + } catch (IORuntimeException e) { + throw new RuntimeException(e); + } + return PRODUCT_FILE_PATH + "/" + fileName; }