Browse Source

修改bug

ZeroLiYi 1 year ago
parent
commit
1f26286887

+ 23 - 14
unis-plugin/unis-plugin-biz/src/main/java/com/unis/emergencySupport/modular/es/controller/EsProcessEnterpriseController.java

@@ -168,24 +168,33 @@ public class EsProcessEnterpriseController {
168 168
     })
169 169
     @PostMapping(value= "/emergencySupport/esProcessEnterprise/importByEntity", headers= "content-type= multipart/form-data", consumes= "multipart/*")
170 170
     public Map<String,Object> importByEntity(@RequestParam(value= "file", required = true) MultipartFile file) throws IOException {
171
-
172
-        Map<String,Object> map = new HashMap<String,Object>();
173
-        if(file== null){
174
-            map.put("massage","无文件数据");
175
-            map.put("status","500");
171
+        Map<String, Object> map = new HashMap<>();
172
+        try {
173
+            if (file == null || file.isEmpty()) {
174
+                map.put("message", "无文件数据");
175
+                map.put("status", "500");
176
+                return map;
177
+            }
178
+            // 获得文件名
179
+            String fileName = file.getOriginalFilename();
180
+            // 判断文件是否是excel文件
181
+            if (!fileName.endsWith("xls") && !fileName.endsWith("xlsx")) {
182
+                map.put("message", "请使用正确的导入模板");
183
+                map.put("status", "500");
184
+                return map;
185
+            }
186
+
187
+            return esProcessEnterpriseService.importByEntityResult(file, map);
188
+        } catch (IOException e) {
189
+            map.put("message", "文件处理异常: " + e.getMessage());
190
+            map.put("status", "500");
176 191
             return map;
177
-        }
178
-        //获得文件名
179
-        String fileName = file.getOriginalFilename();
180
-        //判断文件是否是excel文件
181
-        if (!fileName.endsWith("xls") && !fileName.endsWith("xlsx")) {
182
-            map.put("massage","请使用正确的导入模板");
183
-            map.put("status","500");
192
+        } catch (Exception e) {
193
+            map.put("message", "发生异常: " + e.getMessage());
194
+            map.put("status", "500");
184 195
             return map;
185 196
         }
186 197
 
187
-        return esProcessEnterpriseService.importByEntityResult(file,map);
188
-
189 198
     }
190 199
 
191 200
 

+ 38 - 3
unis-plugin/unis-plugin-biz/src/main/java/com/unis/emergencySupport/modular/es/service/impl/EsProcessEnterpriseServiceImpl.java

@@ -14,6 +14,7 @@ package com.unis.emergencySupport.modular.es.service.impl;
14 14
 
15 15
 import cn.hutool.core.bean.BeanUtil;
16 16
 import cn.hutool.core.collection.CollStreamUtil;
17
+import cn.hutool.core.util.NumberUtil;
17 18
 import cn.hutool.core.util.ObjectUtil;
18 19
 import cn.hutool.core.util.StrUtil;
19 20
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -293,7 +294,11 @@ public class EsProcessEnterpriseServiceImpl extends ServiceImpl<EsProcessEnterpr
293 294
 
294 295
                         EsProcessEnterprise.setHeadquarterCreditCode(strings[11]);//所属总公司企业信用代码
295 296
                         EsProcessEnterprise.setEnterpriseName(strings[12]);//企业名称
296
-                        EsProcessEnterprise.setCreditCode(strings[13]);//统一社会信用代码
297
+                        if (strings[13] != null && strings[13].length() > 18) {
298
+                            throw new IllegalArgumentException(strings[13]+"统一社会信用代码长度不能超过18位");
299
+                        } else {
300
+                            EsProcessEnterprise.setCreditCode(strings[13]);//统一社会信用代码
301
+                        }
297 302
                         EsProcessEnterprise.setActualBusinessAddress(strings[14]);//实际经营地址(省、市、县、乡镇街道门牌号)
298 303
 
299 304
                         QueryWrapper<BizDict> queryWrapper7 = new QueryWrapper<>();
@@ -305,10 +310,40 @@ public class EsProcessEnterpriseServiceImpl extends ServiceImpl<EsProcessEnterpr
305 310
                         List<BizDict> list8 = BizDictServiceImpl.list(queryWrapper8);
306 311
                         EsProcessEnterprise.setEnterpriseType(strings[16]);//企业类型
307 312
 
308
-                        EsProcessEnterprise.setLongitude(new BigDecimal(strings[17]));//经度
313
+//                        EsProcessEnterprise.setLongitude(new BigDecimal(strings[17]));//经度
314
+//
315
+//                        EsProcessEnterprise.setLatitude(new BigDecimal(strings[18]));//纬度
316
+
317
+                        // 假设 strings 是字符串数组,其中包含经度和纬度的数据
318
+                        if (strings[17] != null) {
319
+                            try {
320
+                                if(NumberUtil.isNumber(strings[17])){
321
+                                    BigDecimal longitude = new BigDecimal(strings[17]);
322
+                                    // 进行后续的处理
323
+                                    EsProcessEnterprise.setLongitude(longitude);
324
+                                }else{
325
+                                    throw new NumberFormatException(strings[17] + " 经度格式不正确");
326
+                                }
327
+
328
+                            } catch (NumberFormatException e) {
329
+                                throw new NumberFormatException(strings[17] + " 经度格式不正确");
330
+                            }
331
+                        }
309 332
 
310
-                        EsProcessEnterprise.setLatitude(new BigDecimal(strings[18]));//纬度
333
+                        if (strings[18] != null) {
334
+                            try {
335
+                                if(NumberUtil.isNumber(strings[17])){
336
+                                    BigDecimal longitude = new BigDecimal(strings[18]);
337
+                                    // 进行后续的处理
338
+                                    EsProcessEnterprise.setLongitude(longitude);
339
+                                }{
340
+                                    throw new NumberFormatException(strings[18] + " 经度格式不正确");
341
+                                }
311 342
 
343
+                            } catch (NumberFormatException e) {
344
+                                throw new NumberFormatException(strings[18] + " 纬度格式不正确");
345
+                            }
346
+                        }
312 347
 
313 348
                         EsProcessEnterprise.setLegalRepresentative(strings[19]);//法人姓名
314 349
                         EsProcessEnterprise.setLegalContact(strings[20]);//法人联系方式

+ 4 - 0
unis-plugin/unis-plugin-biz/src/main/java/com/unis/purchaseAndSalesSupervision/modular/yjbj/entity/StorageRotationWarning.java

@@ -77,4 +77,8 @@ public class StorageRotationWarning {
77 77
     @ApiModelProperty(value = "最后修改时间", position = 18)
78 78
     private Date updatetime;
79 79
 
80
+
81
+    private String storehouseName;
82
+
83
+
80 84
 }

+ 11 - 10
unis-plugin/unis-plugin-biz/src/main/java/com/unis/purchaseAndSalesSupervision/modular/yjbj/mapper/mapping/YjbjMapper.xml

@@ -52,29 +52,30 @@
52 52
 
53 53
     <select id="selectLhList" resultType="com.unis.purchaseAndSalesSupervision.modular.yjbj.entity.StorageRotationWarning" parameterType="map">
54 54
         select
55
-            id, ch, hwh, lspz, lsxz, kcsl, scnf, zhycrq, cbnx, cccxrq, bjrq, bjlx, clzt, clr,
56
-            clsj, org_id, scsj, updatetime, remark, clyj
57
-        from storage_rotation_warning
55
+        srw.id, srw.ch, srw.hwh, srw.lspz, srw.lsxz,srw.kcsl, srw.scnf, srw.zhycrq, srw.cbnx, srw.cccxrq, srw.bjrq, srw.bjlx, srw.clzt, srw.clr,
56
+        srw.clsj, srw.org_id, srw.scsj, srw.updatetime, srw.remark, srw.clyj,bs.storehouse_name storehouseName
57
+        from depot_qh.storage_rotation_warning srw
58
+        left join depot_qh.basic_storehouse bs on bs.storehouse_id=srw.ch
58 59
         where 1=1
59 60
         <if test="record.bjlx != null">
60
-            and bjlx = #{record.bjlx, jdbcType=VARCHAR}
61
+            and srw.bjlx = #{record.bjlx, jdbcType=VARCHAR}
61 62
         </if>
62 63
         <if test="record.orgId != null">
63
-            and org_id = #{record.orgId, jdbcType=INTEGER}
64
+            and srw.org_id = #{record.orgId, jdbcType=INTEGER}
64 65
         </if>
65 66
         <if test="record.lspz != null">
66
-            and lspz = #{record.lspz, jdbcType=INTEGER}
67
+            and srw.lspz = #{record.lspz, jdbcType=INTEGER}
67 68
         </if>
68 69
         <if test="record.ch != null">
69
-            and ch = #{record.ch, jdbcType=INTEGER}
70
+            and srw.ch = #{record.ch, jdbcType=INTEGER}
70 71
         </if>
71 72
         <if test="record.startTime != null">
72
-            and STR_TO_DATE(zhycrq, '%Y-%m-%d %H:%i:%s') >= #{record.startTime, jdbcType=VARCHAR}
73
+            and srw.STR_TO_DATE(zhycrq, '%Y-%m-%d %H:%i:%s') >= #{record.startTime, jdbcType=VARCHAR}
73 74
         </if>
74 75
         <if test="record.endTime != null">
75
-            and STR_TO_DATE(zhycrq, '%Y-%m-%d %H:%i:%s') &lt;= #{record.endTime, jdbcType=VARCHAR}
76
+            and srw.STR_TO_DATE(zhycrq, '%Y-%m-%d %H:%i:%s') &lt;= #{record.endTime, jdbcType=VARCHAR}
76 77
         </if>
77
-        order by scsj desc
78
+        order by srw.scsj desc
78 79
     </select>
79 80
 
80 81
     <select id="queryLhById" parameterType="java.lang.String" resultType="com.unis.purchaseAndSalesSupervision.modular.yjbj.entity.StorageRotationWarning">