Browse Source

ly 导入

ly 2 years ago
parent
commit
8f3326830b

+ 9 - 7
master/src/main/java/com/ruoyi/project/base/controller/TBasePointController.java

@@ -153,6 +153,8 @@ public class TBasePointController extends BaseController {
     public AjaxResult importData(@RequestParam("file") MultipartFile file) throws IOException {
         //获取操作人员ID
         Long userId = getUserId();
+
+        List<SysDictData> mediumTypeDict = isysDictTypeService.selectDictDataByType("medium_type");
         //报错行数统计
         CopyOnWriteArrayList<Integer> failRow = new CopyOnWriteArrayList<>();
         Workbook workbook = ExcelUtils.getWorkBook(file);
@@ -201,7 +203,7 @@ public class TBasePointController extends BaseController {
                             entity.setDevName(cellValue);
                         } else if (j == 8) {
                             // 设备编号
-                            entity.setDevCode(cellValue);// 设备id
+                            entity.setDevCode(cellValue);
                         } else if (j == 9) {
                             // 群组位置
                             entity.setGroupPosition(cellValue);
@@ -236,7 +238,7 @@ public class TBasePointController extends BaseController {
                             // 介质
                             entity.setMedium(cellValue);
                         } else if (j == 20) {
-                            for (SysDictData dictData : isysDictTypeService.selectDictDataByType("medium_type")) {
+                            for (SysDictData dictData : mediumTypeDict) {
                                 if (dictData.getDictLabel().equals(cellValue)) {
                                     // 介质状态
                                     entity.setMediumType(dictData.getDictValue());
@@ -263,7 +265,9 @@ public class TBasePointController extends BaseController {
                             entity.setPicNo(cellValue);
                         } else if (j == 27) {
                             // 运行时间
-                            entity.setRunTime(sdf.parse(cellValue));
+                            if (cellValue.length() > 3) {//下次年度检验日期
+                                entity.setRunTime(new SimpleDateFormat("yyyy-MM-dd").parse(cellValue));
+                            }
                         } else if (j == 28) {
                             // 备注
                             entity.setRemarks(cellValue);
@@ -285,12 +289,11 @@ public class TBasePointController extends BaseController {
                         TBasePoint tBasePoint = tBasePointService.selectTBasePointByGroupCodeAndExtendCode(entity);
                         if (tBasePoint == null) {
                             entity.setUpdatedate(new Date());
-                            entity.setUpdaterCode(getUserId());
+                            entity.setUpdaterCode(userId);
                             tBasePointService.insertTBasePoint(entity);
                             successNumber.getAndIncrement();
                         }else {
                             logger.info("重复数据");
-                            failNumber.getAndIncrement();
                             failRow.add(finalI + 1);
                             throw new InterruptedException();//中止线程
                         }
@@ -298,7 +301,6 @@ public class TBasePointController extends BaseController {
                 }catch (InterruptedException e) {
                     logger.info("中止线程"+ Thread.currentThread().getName());
                 }catch (Exception e) {
-                    failNumber.getAndIncrement();
                     failRow.add(finalI + 1);
                     e.printStackTrace();
                 } finally {
@@ -315,7 +317,7 @@ public class TBasePointController extends BaseController {
 
         logger.info("list:" + JSON.toJSONString(list));
         logger.info("successNumber:" + successNumber);
-        logger.info("failNumber:" + failNumber);
+        logger.info("failNumber:" + failRow.size());
         logger.info("failRow:" + failRow);
         return AjaxResult.success(String.valueOf(successNumber.get()), failRow);
     }

+ 1 - 1
master/src/main/resources/mybatis/base/TBaseDeviceMapper.xml

@@ -5,7 +5,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 <mapper namespace="com.ruoyi.project.base.mapper.TBaseDeviceMapper">
 
     <resultMap type="TBaseDevice" id="TBaseDeviceResult">
-        <result property="devId"    column="dev_id"    />
+        <id property="devId"    column="dev_id"    />
         <result property="plantId"    column="plant_id"    />
         <result property="plantName"    column="plant_name"    />
         <result property="plantCode"    column="plant_code"    />

+ 1 - 1
master/src/main/resources/mybatis/base/TBasePlantMapper.xml

@@ -5,7 +5,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 <mapper namespace="com.ruoyi.project.base.mapper.TBasePlantMapper">
 
     <resultMap type="TBasePlant" id="TBasePlantResult">
-        <result property="plantId"    column="plant_id"    />
+        <id property="plantId"    column="plant_id"    />
         <result property="plantCode"    column="plant_code"    />
         <result property="plantName"    column="plant_name"    />
         <result property="proAbility"    column="pro_ability"    />

+ 2 - 2
master/src/main/resources/mybatis/base/TBasePointMapper.xml

@@ -5,7 +5,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 <mapper namespace="com.ruoyi.project.base.mapper.TBasePointMapper">
 
     <resultMap type="TBasePoint" id="TBasePointResult">
-        <result property="pointId"    column="point_id"    />
+        <id property="pointId"    column="point_id"    />
         <result property="netTestValue"    column="net_test_value"    />
         <result property="leakageDegree"    column="leakage_degree"    />
         <result property="plantId"    column="plant_id"    />
@@ -122,7 +122,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </where>
     </select>
 
-    <insert id="insertTBasePoint" parameterType="TBasePoint" useGeneratedKeys="true" keyProperty="id">
+    <insert id="insertTBasePoint" parameterType="TBasePoint" useGeneratedKeys="true" keyProperty="pointId">
         insert into t_base_point
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="netTestValue != null">net_test_value,</if>

+ 1 - 1
master/src/main/resources/mybatis/base/TBaseRegionMapper.xml

@@ -5,7 +5,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 <mapper namespace="com.ruoyi.project.base.mapper.TBaseRegionMapper">
 
     <resultMap type="TBaseRegion" id="TBaseRegionResult">
-        <result property="regionId"    column="region_id"    />
+        <id property="regionId"    column="region_id"    />
         <result property="plantId"    column="plant_id"    />
         <result property="plantType"    column="plant_type"    />
         <result property="plantName"    column="plant_name"    />