Browse Source

巡检录入index越界

pra 3 years ago
parent
commit
560f3d0f41

+ 23 - 10
src/main/java/com/tofly/dyrq/custom/service/impl/CustomMaintenanceServiceImpl.java

@@ -353,17 +353,30 @@ public class CustomMaintenanceServiceImpl implements CustomMaintenanceService {
         excelParam.setOutfields("SID,OBJECTID,CODE,GASDATE,FINISHDATE,MATERIAL,SPEC,DIAMETER");
         JSONArray geo = gisAboutService.exceloutList(excelParam);
         //保存使用年限,设备参数,型号
-        String material = geo.getJSONObject(0).getJSONObject("attributes").getString("MATERIAL");
-        Integer dimameter = geo.getJSONObject(0).getJSONObject("attributes").getInteger("DIAMETER");
-        String type = geo.getJSONObject(0).getJSONObject("attributes").getString("SPEC");
-        addMaintenanceDevice.setType(type);
-        addMaintenanceDevice.setTechParam("材质:" + (material == null ? "无" : material) + " 管径:" + (dimameter == null ? "无" : dimameter.toString()));
-        Date gasDate = geo.getJSONObject(0).getJSONObject("attributes").getDate("GASDATE");
-        Integer differentYear = null;
-        if (gasDate != null) {
-            differentYear = getDifferentYear(gasDate);
+        if(geo.size() >0){
+            String material = geo.getJSONObject(0).getJSONObject("attributes").getString("MATERIAL");
+            Integer dimameter = geo.getJSONObject(0).getJSONObject("attributes").getInteger("DIAMETER");
+            String type = geo.getJSONObject(0).getJSONObject("attributes").getString("SPEC");
+            addMaintenanceDevice.setType(type);
+            addMaintenanceDevice.setTechParam("材质:" + (material == null ? "无" : material) + " 管径:" + (dimameter == null ? "无" : dimameter.toString()));
+            Date gasDate = geo.getJSONObject(0).getJSONObject("attributes").getDate("GASDATE");
+            Integer differentYear = null;
+            if (gasDate != null) {
+                differentYear = getDifferentYear(gasDate);
+            }
+            addMaintenanceDevice.setUsedYears(differentYear == null ? null : differentYear.shortValue());
         }
-        addMaintenanceDevice.setUsedYears(differentYear == null ? null : differentYear.shortValue());
+//        String material = geo.getJSONObject(0).getJSONObject("attributes").getString("MATERIAL");
+//        Integer dimameter = geo.getJSONObject(0).getJSONObject("attributes").getInteger("DIAMETER");
+//        String type = geo.getJSONObject(0).getJSONObject("attributes").getString("SPEC");
+//        addMaintenanceDevice.setType(type);
+//        addMaintenanceDevice.setTechParam("材质:" + (material == null ? "无" : material) + " 管径:" + (dimameter == null ? "无" : dimameter.toString()));
+//        Date gasDate = geo.getJSONObject(0).getJSONObject("attributes").getDate("GASDATE");
+//        Integer differentYear = null;
+//        if (gasDate != null) {
+//            differentYear = getDifferentYear(gasDate);
+//        }
+//        addMaintenanceDevice.setUsedYears(differentYear == null ? null : differentYear.shortValue());
         //保存登记表 保养人,保养时间
         addMaintenanceDevice.setMaintainUser(SecurityUtils.getUserId());
         addMaintenanceDevice.setMaintainDate(Date8Util.getCurrentDate());