From 4763b042a041249370c8ae7d73539d8dccd20235 Mon Sep 17 00:00:00 2001 From: WenShiJun Date: Thu, 28 Mar 2024 18:32:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=A4=E9=80=9A=E4=B8=80=E4=BD=93=E5=8C=96bu?= =?UTF-8?q?g=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TrafficDrivingCommitmentController.java | 7 +- .../TrafficDrivingTypeController.java | 5 +- ...refightingEquipmentFacilityController.java | 3 - .../FreighttTrailerController.java | 165 ++++++++++++++++++ .../LabourEntrenchThingController.java | 6 - .../freighttrailer/FreightTrailerMapper.java | 2 + .../freighttrailer/FreightTrailerService.java | 2 + .../impl/FreightTrailerServiceImpl.java | 5 + src/main/java/com/zcloud/util/DateUtil.java | 1 + .../TrafficDrivingCommitmentMapper.xml | 2 +- .../TrafficDrivingTypeMapper.xml | 2 +- .../TrafficSafetyActivitiesMapper.xml | 1 + .../TrafficSafetyManualMapper.xml | 1 + .../TrafficSafetyMeetingRecipientMapper.xml | 11 +- .../TrafficSecurityNoticeMapper.xml | 1 + .../FirefightingEquipmentFacilityMapper.xml | 1 + .../freighttrailer/FreightTrailerMapper.xml | 7 + .../LabourEntrenchThingMapper.xml | 1 + .../operations/OperationsMapper.xml | 2 +- .../ReportedIncidentMapper.xml | 7 +- .../mybatis/datasource/system/UsersMapper.xml | 66 +++---- .../taxationManage/TaxationManageMapper.xml | 3 +- 22 files changed, 238 insertions(+), 63 deletions(-) diff --git a/src/main/java/com/zcloud/controller/comprehensive/TrafficDrivingCommitmentController.java b/src/main/java/com/zcloud/controller/comprehensive/TrafficDrivingCommitmentController.java index 7d466a2..f42eb73 100644 --- a/src/main/java/com/zcloud/controller/comprehensive/TrafficDrivingCommitmentController.java +++ b/src/main/java/com/zcloud/controller/comprehensive/TrafficDrivingCommitmentController.java @@ -46,12 +46,9 @@ public class TrafficDrivingCommitmentController extends BaseController { pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //主键 pd.put("ISDELETE", "0"); //是否删除 pd.put("INQUIRYCONCLUSION","正常"); - pd.put("CREATORNAME", Jurisdiction.getUsername()); //是否发送短信0不发1发 + pd.put("CREATORNAME", Jurisdiction.getUsername()); pd.put("CREATOR", Jurisdiction.getUSER_ID()); //创建人 pd.put("CREATTIME", DateUtil.date2Str(new Date())); //创建时间 - pd.put("OPERATOR", Jurisdiction.getUSER_ID()); //操作人 - pd.put("OPERATORNAME", Jurisdiction.getUsername()); //操作人 - pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //操作时间 trafficDrivingCommitmentService.save(pd); map.put("pd",pd); @@ -80,8 +77,6 @@ public class TrafficDrivingCommitmentController extends BaseController { return map; } - - //列表 @RequestMapping(value = "/listForSafetyDrivingCommitment") @ResponseBody diff --git a/src/main/java/com/zcloud/controller/comprehensive/TrafficDrivingTypeController.java b/src/main/java/com/zcloud/controller/comprehensive/TrafficDrivingTypeController.java index 8b892bc..1b20d37 100644 --- a/src/main/java/com/zcloud/controller/comprehensive/TrafficDrivingTypeController.java +++ b/src/main/java/com/zcloud/controller/comprehensive/TrafficDrivingTypeController.java @@ -40,12 +40,9 @@ public class TrafficDrivingTypeController extends BaseController { pd.put("DRIVINGTYPE_ID", this.get32UUID()); pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //主键 pd.put("ISDELETE", "0"); //是否删除 - pd.put("CREATORNAME", Jurisdiction.getUsername()); //是否发送短信0不发1发 + pd.put("CREATORNAME", Jurisdiction.getUsername()); pd.put("CREATOR", Jurisdiction.getUSER_ID()); //创建人 pd.put("CREATTIME", DateUtil.date2Str(new Date())); //创建时间 - pd.put("OPERATOR", Jurisdiction.getUSER_ID()); //操作人 - pd.put("OPERATORNAME", Jurisdiction.getUsername()); //操作人 - pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //操作时间 trafficDrivingTypeService.save(pd); map.put("pd",pd); diff --git a/src/main/java/com/zcloud/controller/firefightingEquipmentFacility/FirefightingEquipmentFacilityController.java b/src/main/java/com/zcloud/controller/firefightingEquipmentFacility/FirefightingEquipmentFacilityController.java index 5eab23c..2bb032b 100644 --- a/src/main/java/com/zcloud/controller/firefightingEquipmentFacility/FirefightingEquipmentFacilityController.java +++ b/src/main/java/com/zcloud/controller/firefightingEquipmentFacility/FirefightingEquipmentFacilityController.java @@ -50,9 +50,6 @@ public class FirefightingEquipmentFacilityController extends BaseController { pd.put("CREATOR", Jurisdiction.getUSER_ID()); //添加人id pd.put("CREATORNAME", Jurisdiction.getUsername()); //添加人名字 pd.put("CREATTIME", DateUtil.date2Str(new Date())); //添加时间 - pd.put("OPERATOR", Jurisdiction.getUSER_ID()); //修改人id - pd.put("OPERATORNAME", Jurisdiction.getUsername()); // 修改人名字 - pd.put("OPERATTIME", DateUtil.date2Str(new Date())); // 修改时间 firefightingEquipmentFacilityService.save(pd); map.put("pd", pd); map.put("result", errInfo); diff --git a/src/main/java/com/zcloud/controller/freighttrailer/FreighttTrailerController.java b/src/main/java/com/zcloud/controller/freighttrailer/FreighttTrailerController.java index 02fb7b3..ea28f9f 100644 --- a/src/main/java/com/zcloud/controller/freighttrailer/FreighttTrailerController.java +++ b/src/main/java/com/zcloud/controller/freighttrailer/FreighttTrailerController.java @@ -10,13 +10,18 @@ import com.zcloud.service.scrapManage.ScrapManageService; import com.zcloud.service.system.ImgFilesService; import com.zcloud.service.taxationManage.TaxationManageService; import com.zcloud.util.*; +import org.apache.commons.io.FileUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletResponse; +import java.io.File; import java.util.*; /** @@ -192,6 +197,166 @@ public class FreighttTrailerController extends BaseController { return map; } + /**从EXCEL导入到数据库 + * @param file + * @return + * @throws Exception + */ + @RequestMapping(value = "/readExcel") + @SuppressWarnings("unchecked") + @ResponseBody + @Transactional + @LogAnno(menuType= "双重预防",menuServer= "风险管控",instructionsOperate = "风险点(单元)",instructionsType = "上传附件") + public Object readExcel(@RequestParam(value = "FFILE", required = false) MultipartFile file) throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + StringBuffer errorStr = new StringBuffer(); + if (null != file && !file.isEmpty()) { + File tempFile = new File(file.getOriginalFilename()); //新建file + FileUtils.copyInputStreamToFile(file.getInputStream(), tempFile); //将MultipartFile复制到File + List listPd = (List) ObjectExcelRead.readExcel(tempFile, 1, 0, 0); // 执行读EXCEL操作,读出的数据导入List + // 2:从第3行开始;0:从第A列开始;0:第0个sheet + /** + * var0 :风险点(单元) var1 :所属部门 + */ + + try { + if (listPd.size() < 1) { + map.put("result", "error"); // 返回结果 + map.put("resultStr", "Excel数据为空,请检查数据后,重新上传!"); + FileUtils.deleteQuietly(tempFile);//删除临时文件 + return map; + } + List riskunitList = new ArrayList<>(); + PageData pd = new PageData(); + pd.put("ISDELETE", "0"); + pd.put("BELONGING_DEPT", Jurisdiction.getCORPINFO_ID()); + List riskunitListAll = freightTrailerService.listAll(pd); + Map riskunitMapAll = new HashMap<>(); + for (PageData pageData : riskunitListAll) { + // 使用车牌号作为键 + String plateNumberKey = Tools.excelHandle(pageData.getString("PLATE_NUMBER")); + riskunitMapAll.put(plateNumberKey, pageData); + } + List header = new ArrayList<>(); + header.add("自编号"); + header.add("车牌号"); + header.add("车架号"); + header.add("车身编号"); + header.add("挂车类型"); + header.add("运营证号"); + header.add("归属部门"); + header.add("车主"); + header.add("车主电话"); + header.add("联系人"); + header.add("联系电话"); + header.add("初登日期"); + header.add("发证日期"); + header.add("到期日期"); + header.add("挂车品牌"); + header.add("挂车型号"); + header.add("核定总质量"); + header.add("核定载质量"); + header.add("容积"); + header.add("备注"); + Map hasRiskUnit = new HashMap<>(); + int succeeNum = 1; + for (PageData lpd : listPd) { + succeeNum++; + convertExcelDate(lpd, "var11"); // 初登日期 INITIAL_REGISTRATION_DATE + convertExcelDate(lpd, "var12"); // 发证日期 CERTIFICATE_DATE + convertExcelDate(lpd, "var13"); // 到期日期 DUE_DATE + System.out.println(lpd.get("var11")+"--"+lpd.get("var12")+"--"+lpd.get("var13")); + for (int i = 0; i < header.size(); i++) { + if (!lpd.containsKey("var" + i)) { + errorStr.append("

第" + succeeNum + "行的\"" + header.get(i) + "\"无数据

"); + continue; + } + if (Tools.isEmpty(lpd.get("var" + i))) { + errorStr.append("

第" + succeeNum + "行的\"" + header.get(i) + "\"无数据

"); + continue; + } + } + + String plateNumberVar = Tools.isEmpty(lpd.get("var1")) ? "" : Tools.excelHandle(lpd.get("var1")); + + if (riskunitMapAll.containsKey(plateNumberVar)) { + errorStr.append("

第" + succeeNum + "行:" + "车牌号为\"" + plateNumberVar + "\"的记录已存在,请检查!" + "

"); + continue; + } + if (hasRiskUnit.containsKey(plateNumberVar)) { + errorStr.append("

第" + succeeNum + "行:" + "车牌号重复,请重新检查内容!" + "

"); + continue; + } + hasRiskUnit.put(plateNumberVar, "1"); + PageData riskunit = new PageData(); + riskunit.put("NUM", lpd.get("var0")); + riskunit.put("PLATE_NUMBER", lpd.get("var1")); + riskunit.put("VIN", lpd.get("var2")); + riskunit.put("VEHICLE_BODY_NUMBER", lpd.get("var3")); + riskunit.put("TRAILER_TYPE", lpd.get("var4")); + riskunit.put("OPER_CERTIFICATE_NUM", lpd.get("var5")); + riskunit.put("BELONGING_DEPT", lpd.get("var6")); + riskunit.put("CAR_OWNERS", lpd.get("var7")); + riskunit.put("CAR_OWNERS_TEL", lpd.get("var8")); + riskunit.put("CONTACTS", lpd.get("var9")); + riskunit.put("CONTACT_PHONE", lpd.get("var10")); + riskunit.put("INITIAL_REGISTRATION_DATE", lpd.get("var11")); + riskunit.put("CERTIFICATE_DATE", lpd.get("var12")); + riskunit.put("DUE_DATE", lpd.get("var13")); + riskunit.put("TRAILER_BRAND", lpd.get("var14")); + riskunit.put("TRAILER_MODEL", lpd.get("var15")); + riskunit.put("APPROVED_TOTAL_MASS", lpd.get("var16")); + riskunit.put("APPROVED_LOAD_CAPACITY", lpd.get("var17")); + riskunit.put("VOLUME", lpd.get("var18")); + riskunit.put("NOTES", lpd.get("var19")); + riskunit.put("FREIGHTTRAILER_ID", this.get32UUID()); + riskunit.put("ISDELETE", "0"); + riskunit.put("CREATOR", Jurisdiction.getUsername()); + riskunit.put("CREATTIME", DateUtil.date2Str(new Date())); + riskunit.put("OPERATOR", Jurisdiction.getUsername()); + riskunit.put("OPERATTIME", DateUtil.date2Str(new Date())); + riskunit.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); + riskunitList.add(riskunit); + } + if (Tools.isEmpty(errorStr.toString())) { + for (PageData riskunit : riskunitList) { + freightTrailerService.save(riskunit); + } + errorStr.append("成功导入" + riskunitList.size() + "条数据!"); + } else { + errInfo = "error"; + } + + FileUtils.deleteQuietly(tempFile);//删除临时文件 + } catch (Exception e) { + map.put("result", "fail"); // 返回结果 + map.put("resultStr", errorStr.toString()); + FileUtils.deleteQuietly(tempFile);//删除临时文件 + return map; + } + } + map.put("result", "success");//返回结果 + map.put("resultType", errInfo);//返回message类型 + map.put("isExcel","1");//返回类型 + map.put("resultStr", errorStr.toString()); + return map; + } + + private void convertExcelDate(PageData lpd, String field) { + Object excelDateObj = lpd.get(field); + if (excelDateObj != null) { + // 尝试将对象转换为Double,因为Excel中的日期是以Double类型的数字存储的 + double excelDate = Double.parseDouble(excelDateObj.toString()); + // 使用Apache POI的DateUtil获取Java日期对象 + Date javaDate = org.apache.poi.ss.usermodel.DateUtil.getJavaDate(excelDate); + // 使用您的DateUtil工具类进行日期格式化 + String formattedDate = DateUtil.date2Str(javaDate, "yyyy-MM-dd"); + // 更新lpd对象中的日期字段 + lpd.put(field, formattedDate); + } + } + /** * 去修改页面获取数据 * diff --git a/src/main/java/com/zcloud/controller/labourEntrenchThing/LabourEntrenchThingController.java b/src/main/java/com/zcloud/controller/labourEntrenchThing/LabourEntrenchThingController.java index a35fe94..a803d36 100644 --- a/src/main/java/com/zcloud/controller/labourEntrenchThing/LabourEntrenchThingController.java +++ b/src/main/java/com/zcloud/controller/labourEntrenchThing/LabourEntrenchThingController.java @@ -46,9 +46,6 @@ public class LabourEntrenchThingController extends BaseController { pd.put("CREATOR", Jurisdiction.getUSER_ID()); //添加人id pd.put("CREATORNAME", Jurisdiction.getUsername()); //添加人名字 pd.put("CREATTIME", DateUtil.date2Str(new Date())); //添加时间 - pd.put("OPERATOR", Jurisdiction.getUSER_ID()); //修改人id - pd.put("OPERATORNAME", Jurisdiction.getUsername()); // 修改人名字 - pd.put("OPERATTIME", DateUtil.date2Str(new Date())); // 修改时间 labourEntrenchThingService.save(pd); map.put("pd", pd); map.put("result", errInfo); @@ -87,9 +84,6 @@ public class LabourEntrenchThingController extends BaseController { PageData pd = new PageData(); pd = this.getPageData(); pd.put("ISDELETE", "0"); //是否删除(0:有效 1:删除) - pd.put("CREATOR", Jurisdiction.getUSER_ID()); //添加人id - pd.put("CREATORNAME", Jurisdiction.getUsername()); //添加人名字 - pd.put("CREATTIME", DateUtil.date2Str(new Date())); //添加时间 pd.put("OPERATOR", Jurisdiction.getUSER_ID()); //修改人id pd.put("OPERATORNAME", Jurisdiction.getUsername()); // 修改人名字 pd.put("OPERATTIME", DateUtil.date2Str(new Date())); // 修改时间 diff --git a/src/main/java/com/zcloud/mapper/datasource/freighttrailer/FreightTrailerMapper.java b/src/main/java/com/zcloud/mapper/datasource/freighttrailer/FreightTrailerMapper.java index de48558..924bc7f 100644 --- a/src/main/java/com/zcloud/mapper/datasource/freighttrailer/FreightTrailerMapper.java +++ b/src/main/java/com/zcloud/mapper/datasource/freighttrailer/FreightTrailerMapper.java @@ -76,5 +76,7 @@ public interface FreightTrailerMapper { List vehicleList(PageData pd); List listOut(PageData pd); + + List listAll(PageData pd); } diff --git a/src/main/java/com/zcloud/service/freighttrailer/FreightTrailerService.java b/src/main/java/com/zcloud/service/freighttrailer/FreightTrailerService.java index 5be0879..0728ce9 100644 --- a/src/main/java/com/zcloud/service/freighttrailer/FreightTrailerService.java +++ b/src/main/java/com/zcloud/service/freighttrailer/FreightTrailerService.java @@ -76,5 +76,7 @@ public interface FreightTrailerService { public List vehicleList(PageData pd) throws Exception; List listOut(PageData pd); + + List listAll(PageData pd); } diff --git a/src/main/java/com/zcloud/service/freighttrailer/impl/FreightTrailerServiceImpl.java b/src/main/java/com/zcloud/service/freighttrailer/impl/FreightTrailerServiceImpl.java index 60bca84..74d5c2a 100644 --- a/src/main/java/com/zcloud/service/freighttrailer/impl/FreightTrailerServiceImpl.java +++ b/src/main/java/com/zcloud/service/freighttrailer/impl/FreightTrailerServiceImpl.java @@ -108,5 +108,10 @@ public class FreightTrailerServiceImpl implements FreightTrailerService { return freightTrailerMapper.listOut(pd); } + @Override + public List listAll(PageData pd) { + return freightTrailerMapper.listAll(pd); + } + } diff --git a/src/main/java/com/zcloud/util/DateUtil.java b/src/main/java/com/zcloud/util/DateUtil.java index 644a58d..037e5f2 100644 --- a/src/main/java/com/zcloud/util/DateUtil.java +++ b/src/main/java/com/zcloud/util/DateUtil.java @@ -891,4 +891,5 @@ public class DateUtil { } return new Date(); } + } diff --git a/src/main/resources/mybatis/datasource/comprehensive/TrafficDrivingCommitmentMapper.xml b/src/main/resources/mybatis/datasource/comprehensive/TrafficDrivingCommitmentMapper.xml index c462ffd..03bd6d6 100644 --- a/src/main/resources/mybatis/datasource/comprehensive/TrafficDrivingCommitmentMapper.xml +++ b/src/main/resources/mybatis/datasource/comprehensive/TrafficDrivingCommitmentMapper.xml @@ -101,7 +101,7 @@ and f.INQUIRYCONTENT LIKE CONCAT(CONCAT('%', #{pd.INQUIRYCONTENT}),'%') - order by f.OPERATTIME DESC + order by f.CREATTIME DESC + diff --git a/src/main/resources/mybatis/datasource/labourEntrenchThing/LabourEntrenchThingMapper.xml b/src/main/resources/mybatis/datasource/labourEntrenchThing/LabourEntrenchThingMapper.xml index 083313d..6a0217d 100644 --- a/src/main/resources/mybatis/datasource/labourEntrenchThing/LabourEntrenchThingMapper.xml +++ b/src/main/resources/mybatis/datasource/labourEntrenchThing/LabourEntrenchThingMapper.xml @@ -350,6 +350,7 @@ and f.PERSON_NAME LIKE CONCAT(CONCAT('%', #{pd.PERSON_NAME}),'%') + ORDER BY f.CREATTIME desc - diff --git a/src/main/resources/mybatis/datasource/system/UsersMapper.xml b/src/main/resources/mybatis/datasource/system/UsersMapper.xml index 98f525f..dff67a3 100644 --- a/src/main/resources/mybatis/datasource/system/UsersMapper.xml +++ b/src/main/resources/mybatis/datasource/system/UsersMapper.xml @@ -464,59 +464,63 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" diff --git a/src/main/resources/mybatis/datasource/taxationManage/TaxationManageMapper.xml b/src/main/resources/mybatis/datasource/taxationManage/TaxationManageMapper.xml index 352e95d..e72a45b 100644 --- a/src/main/resources/mybatis/datasource/taxationManage/TaxationManageMapper.xml +++ b/src/main/resources/mybatis/datasource/taxationManage/TaxationManageMapper.xml @@ -445,8 +445,7 @@ AND f.TRANSPORT_ENTERPRISES = #{pd.TRANSPORT_ENTERPRISES} - ORDER BY f.OPERATTIME DESC - ORDER BY OPERATTIME DESC + ORDER BY f.CREATTIME DESC