zouxuan 3 年之前
父節點
當前提交
701d15c7bd

+ 7 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/FinancialExpenditureServiceImpl.java

@@ -31,6 +31,7 @@ import com.ym.mec.util.ini.IniFileUtil;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.record.WriteAccessRecord;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -491,7 +492,7 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
                 }
                 String submitForm = oaInputDto.getModel();
                 List<HashMap> hashMaps = JSONObject.parseArray(formData.get(submitForm).toString(), HashMap.class);
-                for (HashMap hashMap : hashMaps) {
+                nullUser: for (HashMap hashMap : hashMaps) {
                     FinancialExpenditure financialExpenditure = new FinancialExpenditure();
                     List<OaColumnDto> columns = oaInputDto.getColumns();
                     if(columns != null && columns.size() > 0){
@@ -523,6 +524,8 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
                                         if(o != null){
                                             financialExpenditure.setStudentId(Integer.parseInt(o.toString()));
                                             continue;
+                                        }else {
+                                            continue nullUser;
                                         }
                                     }else if(name.contains("金额")){
                                         Object o = hashMap.get(inputDto.getModel());
@@ -538,6 +541,9 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
                     financialExpenditureList.add(financialExpenditure);
                 }
             }
+            if(CollectionUtils.isEmpty(financialExpenditureList)){
+                return;
+            }
             //课程退费
             if(tplInfoId.equals("11")){
                 long count = financialExpenditureList.stream().filter(e -> StringUtils.isEmpty(e.getGroupType()) ||

+ 8 - 8
mec-biz/src/main/resources/config/mybatis/FinancialExpenditureMapper.xml

@@ -230,26 +230,26 @@
         <result property="deptId" column="dept_id"/>
     </resultMap>
     <select id="getWorkOrderInfo" resultMap="PWorkOrderInfo">
-        SELECT woi.*,su.mec_user_id FROM oa_pro.p_work_order_info woi
-        LEFT JOIN oa_pro.p_work_order_circulation_history woch ON woi.id = woch.work_order
-        LEFT JOIN oa_pro.p_process_info pi ON pi.id = woi.classify
-        LEFT JOIN oa_pro.sys_user su ON su.user_id = woi.creator
+        SELECT woi.*,su.mec_user_id FROM mec_dev_api.p_work_order_info woi
+        LEFT JOIN mec_dev_api.p_work_order_circulation_history woch ON woi.id = woch.work_order
+        LEFT JOIN mec_dev_api.p_process_info pi ON pi.id = woi.classify
+        LEFT JOIN mec_dev_api.sys_user su ON su.user_id = woi.creator
         WHERE woi.is_end = 1  AND woi.is_denied = 0  AND woi.is_cancel = 0
         AND woch.`status` != 0 AND woi.id = #{workOrderId} AND pi.fee_type = 1 LIMIT 1
     </select>
     <select id="getFormStructure" resultType="java.lang.String">
-        SELECT form_structure FROM oa_pro.p_work_order_tpl_data WHERE work_order = #{workOrderId}
+        SELECT form_structure FROM mec_dev_api.p_work_order_tpl_data WHERE work_order = #{workOrderId}
     </select>
     <select id="getFormData" resultType="java.lang.String">
-        SELECT form_data FROM oa_pro.p_work_order_tpl_data WHERE work_order = #{workOrderId}
+        SELECT form_data FROM mec_dev_api.p_work_order_tpl_data WHERE work_order = #{workOrderId}
     </select>
     <select id="getTplInfo" resultType="java.lang.String">
-        SELECT form_structure FROM oa_pro.p_tpl_info WHERE id = #{tplInfoId}
+        SELECT form_structure FROM mec_dev_api.p_tpl_info WHERE id = #{tplInfoId}
     </select>
     <select id="findByBatchNoAndProcessNo" resultType="integer">
         SELECT id_ FROM financial_expenditure WHERE batch_no_ = #{workOrderId} AND financial_process_no_ = #{workOrderId} LIMIT 1
     </select>
     <select id="getDeptId" resultType="java.lang.Integer">
-        SELECT organ_id FROM oa_pro.sys_dept WHERE dept_id = #{deptId}
+        SELECT organ_id FROM mec_dev_api.sys_dept WHERE dept_id = #{deptId}
     </select>
 </mapper>

+ 26 - 18
mec-web/src/main/java/com/ym/mec/web/controller/ImportController.java

@@ -29,6 +29,8 @@ import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.URL;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
@@ -95,27 +97,33 @@ public class ImportController extends BaseController {
     @PostMapping(value = "oaUploadFile")
     public Object uploadFile(@ApiParam(value = "上传的文件", required = true) @RequestParam("file") MultipartFile file,Integer processId) throws Exception {
         if (file != null && StringUtils.isNotBlank(file.getOriginalFilename())) {
-            String filename = file.getOriginalFilename();
-            String prefix = filename.substring(filename.lastIndexOf("."));
-            File excelFile = File.createTempFile(UUID.randomUUID().toString(), prefix);
-            file.transferTo(excelFile);
-            //如果是乐团退费,校验excel
-            if(processId != null && processId.equals(19)){
-                if(!"xls".equals(prefix.substring(1)) && !"xlsx".equals(prefix.substring(1))){
-                    throw new BizException("请上传Excel文件");
-                }
-                financialExpenditureService.checkOaQuitMusicGroupExcel(FileUtils.readFileToByteArray(excelFile),filename);
-            }
-            UploadReturnBean bean = uploadFileService.uploadFile(FileUtils.openInputStream(excelFile), UploadUtil.getExtension(filename));
+            String fileName = UploadUtil.getExtension(file.getOriginalFilename());
+            UploadReturnBean bean = uploadFileService.uploadFile(file.getInputStream(),fileName);
             bean.setName(file.getOriginalFilename());
-            if (bean.isStatus()) {
+            if(bean.isStatus()){
+                //如果是乐团退费,校验excel
+                if(processId != null && processId.equals(19)){
+                    if(!"xls".equals(fileName) && !"xlsx".equals(fileName)){
+                        throw new BizException("请上传Excel文件");
+                    }
+                    URL url = new URL(bean.getUrl());
+                    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+                    conn.setConnectTimeout(3*1000);
+                    File excelFile = File.createTempFile(UUID.randomUUID().toString(), ".xls");
+                    try {
+                        FileUtils.copyInputStreamToFile(conn.getInputStream(),excelFile);
+                        financialExpenditureService.checkOaQuitMusicGroupExcel(FileUtils.readFileToByteArray(excelFile),fileName);
+                    }finally {
+                        //删除临时文件
+                        if (excelFile.exists()) {
+                            excelFile.delete();
+                        }
+                    }
+                }
                 return succeed(bean);
+            }else {
+                return failed(bean.getMessage());
             }
-            //删除临时文件
-            if (excelFile.exists()) {
-                excelFile.delete();
-            }
-            return failed(bean.getMessage());
         }
         return failed("上传失败");
     }