Browse Source

提交代码

JX.Li 1 year ago
parent
commit
0d35e6298b

+ 10 - 4
ruoyi-gas/src/main/java/com/ruoyi/gas/domain/vo/GPressureRegulatingBoxExcelVo.java

@@ -2,6 +2,8 @@ package com.ruoyi.gas.domain.vo;
 
 import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
 import com.alibaba.excel.annotation.ExcelProperty;
+import com.ruoyi.common.annotation.ExcelDictFormat;
+import com.ruoyi.common.convert.ExcelDictConvert;
 import lombok.Data;
 
 import java.io.Serializable;
@@ -15,25 +17,29 @@ public class GPressureRegulatingBoxExcelVo implements Serializable {
     /**
      * 性质
      */
-    @ExcelProperty(value = "性质")
+    @ExcelProperty(value = "性质", converter = ExcelDictConvert.class)
+    @ExcelDictFormat(dictType = "tyx_nature")
     private String nature;
 
     /**
      * 类型
      */
-    @ExcelProperty(value = "类型")
+    @ExcelProperty(value = "类型", converter = ExcelDictConvert.class)
+    @ExcelDictFormat(dictType = "tyx_type")
     private String type;
 
     /**
      * 路数
      */
-    @ExcelProperty(value = "路数")
+    @ExcelProperty(value = "路数", converter = ExcelDictConvert.class)
+    @ExcelDictFormat(dictType = "tyx_numberOfRoutes")
     private String numberOfRoutes;
 
     /**
      * 管理所
      */
-    @ExcelProperty(value = "管理所")
+    @ExcelProperty(value = "管理所", converter = ExcelDictConvert.class)
+    @ExcelDictFormat(dictType = "administrative_office")
     private String managementOffice;
 
     /**

+ 2 - 1
ruoyi-gas/src/main/java/com/ruoyi/gas/mapper/GPressureRegulatingBoxMapper.java

@@ -3,6 +3,7 @@ package com.ruoyi.gas.mapper;
 import com.ruoyi.gas.domain.GPressureRegulatingBox;
 import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
 import com.ruoyi.gas.domain.vo.GPressureRegulatingBoxExcelVo;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -13,7 +14,7 @@ import java.util.List;
  * @date 2024-03-25
  */
 public interface GPressureRegulatingBoxMapper extends BaseMapperPlus<GPressureRegulatingBox> {
-    GPressureRegulatingBox getByNumber(String number);
+    GPressureRegulatingBox getByNumber(@Param("number") String number, @Param("name") String name, @Param("managementOffice") String managementOffice);
     List<GPressureRegulatingBoxExcelVo> getExcelList();
 
 }

+ 34 - 3
ruoyi-gas/src/main/java/com/ruoyi/gas/service/impl/GPressureRegulatingBoxServiceImpl.java

@@ -18,11 +18,13 @@ import com.ruoyi.gas.domain.vo.GPressureRegulatingBoxVo;
 import com.ruoyi.gas.mapper.GPressureRegulatingBoxMapper;
 import com.ruoyi.gas.service.IGPressureRegulatingBoxDetailsService;
 import com.ruoyi.gas.service.IGPressureRegulatingBoxService;
+import com.ruoyi.system.mapper.SysDictDataMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.ObjectUtils;
 
+import javax.annotation.Resource;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
@@ -39,6 +41,8 @@ public class GPressureRegulatingBoxServiceImpl extends ServicePlusImpl<GPressure
     @Autowired
     private IGPressureRegulatingBoxDetailsService igPressureRegulatingBoxDetailsService;
 
+    @Resource
+    private SysDictDataMapper sysDictDataMapper;
     @Override
     public Map<String, Object> importVo(List<GPressureRegulatingBoxExcelVo> list, Boolean isUpdateSupport, String operName, int n, int successNum) {
         if (ObjectUtils.isEmpty(list) || list.size() == 0) {
@@ -51,7 +55,28 @@ public class GPressureRegulatingBoxServiceImpl extends ServicePlusImpl<GPressure
             try {
                 n++;
                 if (StringUtils.isNotEmpty(vo.getNumber())) {
-                    GPressureRegulatingBox gPressureRegulatingBox = baseMapper.getByNumber(vo.getNumber());
+                    successNum++;
+                    GPressureRegulatingBox gPressureRegulatingBox = baseMapper.getByNumber(vo.getNumber(),vo.getName(),vo.getManagementOffice());
+                    String type = sysDictDataMapper.queryValueTextByKey("tyx_type", vo.getType());
+                    if (StringUtils.isBlank(type)) {
+                        throw new ServiceException( "第" + (n + 1) + "行类型填写错误,导入失败!");
+                    }
+                    String getNature = sysDictDataMapper.queryValueTextByKey("tyx_nature", vo.getNature());
+                    if (StringUtils.isBlank(getNature)) {
+                        throw new ServiceException("第" + (n + 1) + "行性质填写错误,导入失败!");
+                    }
+                    String getNumberOfRoutes = sysDictDataMapper.queryValueTextByKey("tyx_numberOfRoutes", vo.getNumberOfRoutes());
+                    if (StringUtils.isBlank(getNumberOfRoutes)) {
+                        throw new ServiceException( "第" + (n + 1) + "行路数填写错误,导入失败!");
+                    }
+                    String getManagementOffice = sysDictDataMapper.queryValueTextByKey("administrative_office", vo.getManagementOffice());
+                    if (StringUtils.isBlank(getManagementOffice)) {
+                        throw new ServiceException( "第" + (n + 1) + "行管理所填写错误,导入失败!");
+                    }
+                    vo.setNature(getNature);
+                    vo.setType(type);
+                    vo.setNumberOfRoutes(getNumberOfRoutes);
+                    vo.setManagementOffice(getManagementOffice);
                     if (ObjectUtils.isEmpty(gPressureRegulatingBox)) {
                         GPressureRegulatingBox bean = BeanUtil.toBean(vo, GPressureRegulatingBox.class);
                         bean.setId(null);
@@ -59,8 +84,12 @@ public class GPressureRegulatingBoxServiceImpl extends ServicePlusImpl<GPressure
                         Long id = bean.getId();
                         GPressureRegulatingBoxDetailsBo bean1 = BeanUtil.toBean(vo, GPressureRegulatingBoxDetailsBo.class);
                         bean1.setRegulatingBoxId(id.toString());
+                        bean1.setId(null);
                         igPressureRegulatingBoxDetailsService.insertByBo(bean1);
                     } else {
+                        GPressureRegulatingBox bean = BeanUtil.toBean(vo, GPressureRegulatingBox.class);
+                        bean.setId(gPressureRegulatingBox.getId());
+                        baseMapper.updateById(bean);
                         Long id = gPressureRegulatingBox.getId();
                         GPressureRegulatingBoxDetailsBo bean1 = BeanUtil.toBean(vo, GPressureRegulatingBoxDetailsBo.class);
                         bean1.setRegulatingBoxId(id.toString());
@@ -68,9 +97,10 @@ public class GPressureRegulatingBoxServiceImpl extends ServicePlusImpl<GPressure
                         igPressureRegulatingBoxDetailsService.insertByBo(bean1);
                     }
                 }else {
-                    throw new ServiceException("第" + (n + 1) + "行格式错误,导入失败!");
+                    throw new ServiceException("第" + (n + 1) + "行编号错误,导入失败!");
                 }
             } catch (Exception e) {
+                e.printStackTrace();
                 throw new ServiceException("第" + (n + 1) + "行格式错误,导入失败!");
             }
             ret.put("bfb", String.format("%.2f", (Double.valueOf((n + 1)) / Double.valueOf(list.size())) * 100));
@@ -80,7 +110,7 @@ public class GPressureRegulatingBoxServiceImpl extends ServicePlusImpl<GPressure
             ret.put("successNum", successNum);
             return ret;
         }
-        successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + list.size() + " 条");
+        successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条");
         ret.put("bfb", String.format("%.2f", (Double.valueOf((n + 1)) / Double.valueOf(list.size())) * 100));
         ret.put("n", n);
         ret.put("is_success", false);
@@ -138,6 +168,7 @@ public class GPressureRegulatingBoxServiceImpl extends ServicePlusImpl<GPressure
         lqw.like(StringUtils.isNotBlank(bo.getName()), GPressureRegulatingBox::getName, bo.getName());
         lqw.eq(StringUtils.isNotBlank(bo.getLongitude()), GPressureRegulatingBox::getLongitude, bo.getLongitude());
         lqw.eq(StringUtils.isNotBlank(bo.getLatitude()), GPressureRegulatingBox::getLatitude, bo.getLatitude());
+        lqw.like(StringUtils.isNotBlank(bo.getInspector()), GPressureRegulatingBox::getInspector, bo.getInspector());
         return lqw;
     }
 

+ 2 - 1
ruoyi-gas/src/main/resources/mapper/GPressureRegulatingBoxMapper.xml

@@ -23,7 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
 	<select id="getByNumber" resultType="com.ruoyi.gas.domain.GPressureRegulatingBox">
-		SELECT * FROM `g_pressure_regulating_box` WHERE number = #{number}
+		SELECT * FROM `g_pressure_regulating_box` WHERE number = #{number} and del_flag = 0 and name = #{name} and management_office = #{managementOffice}
 	</select>
 
     <select id="getExcelList" resultType="com.ruoyi.gas.domain.vo.GPressureRegulatingBoxExcelVo">
@@ -35,6 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 			b.name,
 			b.inspection_frequency,
 			b.inspector,
+			b.number,
 			bd.total_number_of_households,
 			bd.position_of_pressure_regulating_box,
 			bd.control_range,