浏览代码

预防、鉴定成本导入

DLC 1 月之前
父节点
当前提交
d472268443

+ 16 - 0
qcs-common/pom.xml

@@ -50,5 +50,21 @@
             <version>3.1.2</version>
         </dependency>
 
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi</artifactId>
+            <version>4.1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-ooxml</artifactId>
+            <version>4.1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-ooxml-schemas</artifactId>
+            <version>4.1.0</version>
+        </dependency>
+
     </dependencies>
 </project>

+ 2 - 2
qcs-common/src/main/java/com/rongwei/bscommon/sys/dao/QcsMainCostDao.java

@@ -28,8 +28,8 @@ public interface QcsMainCostDao extends BaseDao<QcsMainCostDo> {
     @Select("select * from qcs_main_cost where DELETED='0' and BASEID=#{baseId} and DATE_FORMAT(YEARMONTH, '%Y-%m')=#{yearmonth}")
     List<QcsMainCostDo> getMainCosts(@Param("baseId") String baseId, @Param("yearmonth") String yearmonth);
 
-    @Select("select * from qcs_subject_config where DELETED='0' order by SECSUBJECT,SORT")
-    List<QcsSubjectConfigDo> getSubjectConfig();
+    @Select("select * from qcs_subject_config where DELETED='0' ${typeWhr} order by SECSUBJECT,SORT")
+    List<QcsSubjectConfigDo> getSubjectConfig(@Param("typeWhr") String typeWhr);
 
     @Update("update qcs_recovery_amount set STATUS='已提交',SUBMITDATE=NOW() where ID=#{id}")
     void tjAmountData(@Param("id") String id);

+ 5 - 0
qcs-common/src/main/java/com/rongwei/bscommon/sys/service/QcsMainCostService.java

@@ -3,7 +3,10 @@ package com.rongwei.bscommon.sys.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.rongwei.bsentity.domain.QcsMainCostDo;
 import com.rongwei.rwcommon.base.R;
+import org.springframework.web.multipart.MultipartFile;
 
+import java.io.IOException;
+import java.text.ParseException;
 import java.util.Map;
 
 public interface QcsMainCostService extends IService<QcsMainCostDo> {
@@ -12,4 +15,6 @@ public interface QcsMainCostService extends IService<QcsMainCostDo> {
     R saveActAmount(Map<String, String> params);
 
     R tjAmount(Map<String, String> params);
+
+    R importMainCost(MultipartFile file, String costType, String unitId) throws IOException, ParseException;
 }

文件差异内容过多而无法显示
+ 151 - 1
qcs-common/src/main/java/com/rongwei/bscommon/sys/service/impl/QcsMainCostServiceImpl.java


+ 49 - 0
qcs-common/src/main/java/com/rongwei/bscommon/sys/utils/ExcelUtils.java

@@ -0,0 +1,49 @@
+package com.rongwei.bscommon.sys.utils;
+
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
+import org.apache.poi.ss.usermodel.Row;
+
+import java.io.InputStream;
+
+public class ExcelUtils {
+    /**
+     * license认证,保证license.xml放到resource根目录下
+     *
+     * @return
+     */
+    public static boolean GetWordLicense() {
+        boolean result = false;
+        try {
+            InputStream license = ExcelUtils.class.getClassLoader().getResourceAsStream(
+                    "license.xml"); // license路径
+            com.aspose.words.License aposeLic = new com.aspose.words.License();
+            aposeLic.setLicense(license);
+            result = true;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return result;
+    }
+
+    /**
+     * 校验excel行是否为空
+     *
+     * @param row
+     * @return
+     */
+    public static boolean isRowEmpty(Row row) {
+        if (row == null) {
+            return true;
+        } else {
+            for (int c = row.getFirstCellNum(); c < row.getLastCellNum(); c++) {
+                Cell cell = row.getCell(c);
+                if (cell != null && cell.getCellType() != CellType.BLANK) {
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+
+}

+ 6 - 0
qcs-entity/pom.xml

@@ -29,5 +29,11 @@
             <artifactId>rw-common-utils</artifactId>
             <version>1.1-SNAPSHOT</version>
         </dependency>
+        <dependency>
+            <groupId>com.rongwei</groupId>
+            <artifactId>rw-admin-common</artifactId>
+            <version>1.1-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 </project>

+ 4 - 0
qcs-entity/src/main/java/com/rongwei/bsentity/domain/QcsMainCostDo.java

@@ -20,6 +20,10 @@ public class QcsMainCostDo extends BaseDo implements Serializable {
      * ID
      */
     private String id;
+    /**
+     * ROPTION
+     */
+    private String roption;
 
     /**
      * 一级单位ID

+ 4 - 0
qcs-entity/src/main/java/com/rongwei/bsentity/domain/QcsMainDetailDo.java

@@ -19,6 +19,10 @@ public class QcsMainDetailDo extends BaseDo implements Serializable {
      * ID
      */
     private String id;
+    /**
+     * ROPTION
+     */
+    private String roption;
 
     /**
      * 主表ID

+ 5 - 0
qcs-entity/src/main/java/com/rongwei/bsentity/domain/QcsSubjectConfigDo.java

@@ -15,6 +15,11 @@ import java.io.Serializable;
 public class QcsSubjectConfigDo extends BaseDo implements Serializable {
     private static final long serialVersionUID = 1L;
 
+    /**
+     * 成本类型(预防成本1鉴定成本2内部损失3外部损失4)
+     */
+    private String costtype;
+
     /**
      * 二级科目
      */

+ 18 - 4
qcs-server/src/main/java/com/rongwei/controller/QcsMainCostController.java

@@ -4,10 +4,8 @@ import com.rongwei.bscommon.sys.service.QcsMainCostService;
 import com.rongwei.rwcommon.base.R;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import java.util.Map;
 
@@ -56,4 +54,20 @@ public class QcsMainCostController {
             return R.error();
         }
     }
+
+    //数据导入
+    @RequestMapping("/importMainCost")
+    @ResponseBody
+    public R importMainCost(@RequestParam MultipartFile file, String costType, String unitId) {
+        try {
+            if (file == null) {
+                return R.error("文件解析失败");
+            }
+            return qcsMainCostService.importMainCost(file, costType, unitId);
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.info("数据导入异常..." + e.getMessage());
+            return R.error();
+        }
+    }
 }