From 6892c31200a7ed1b0e60ee5aff794b1fcecc7ef6 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期三, 01 十一月 2023 16:28:06 +0800
Subject: [PATCH] 解决文件上传时,文件名重复问题

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceFundController.java |   84 ++++++++++++++++++++++++++++++++++++------
 1 files changed, 72 insertions(+), 12 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceFundController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceFundController.java
index 493efff..b14a7c4 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceFundController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceFundController.java
@@ -1,5 +1,7 @@
 package com.ruoyi.web.controller.project;
 
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.annotation.RepeatSubmit;
 import com.ruoyi.common.config.RuoYiConfig;
@@ -28,7 +30,12 @@
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.ibatis.annotations.Options;
+import org.apache.poi.ss.formula.functions.T;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.datasource.DataSourceTransactionManager;
+import org.springframework.transaction.TransactionDefinition;
+import org.springframework.transaction.TransactionStatus;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.*;
 
@@ -76,7 +83,7 @@
     private IServiceSystemmessageService ServiceSystemmessage;
 
     @Autowired
-    private IServiceFundSharedService fundServiceShare;
+    private IBaseOnlyvalueService baseOnlyvalueService;
 
     @Autowired
     private IServiceExternalpersonService externalpersonService;
@@ -84,6 +91,11 @@
     @Autowired
     private ISysPostService postService;
 
+    @Autowired
+    private DataSourceTransactionManager transactionManager;
+
+    @Autowired
+    private TransactionDefinition transactionDefinition;
 
     public ServiceFundController() {
         configuration = new Configuration();
@@ -128,7 +140,12 @@
         Integer APPLYTYPE = spFinancialExpensesIn.getAPPLYTYPE();
         Integer pageNum = spFinancialExpensesIn.getPageNum();
         Integer pageSize = spFinancialExpensesIn.getPageSize();
+        Integer checkstatus = spFinancialExpensesIn.getCheckstatus();
 
+        String donorname = spFinancialExpensesIn.getDonorname();
+        if (StringUtils.isEmpty(donorname)) {
+            donorname = null;
+        }
         if (pageNum == null) {
             pageNum = 1;
         }
@@ -150,7 +167,7 @@
         }
 
         //startPage();
-        List<SpFinancialExpensesFundOut> list = serviceFundService.getListBypower(loginUser.getUsername(), 2, APPLICANT, APPLICATIONBEGTIME, APPLICATIONENDTIME, loginUser.getDeptId().toString(), CHECKFLAG, APPLYTYPE);
+        List<SpFinancialExpensesFundOut> list = serviceFundService.getListBypower(loginUser.getUsername(), 2, APPLICANT, APPLICATIONBEGTIME, APPLICATIONENDTIME, loginUser.getDeptId().toString(), CHECKFLAG, APPLYTYPE, checkstatus, donorname);
         //閫氳繃鎹愮尞鑰呰繃婊�
         if (StringUtils.isNotEmpty(spFinancialExpensesIn.getDonorname())) {
             list = list.stream().filter(obj -> obj.getDonorname().contains(spFinancialExpensesIn.getDonorname())).collect(Collectors.toList());
@@ -461,10 +478,10 @@
      * 瀹℃牳璐圭敤
      */
     @ApiOperation("瀹℃牳璐圭敤")
-    @Log(title = "瀹℃牳璐圭敤", businessType = BusinessType.OTHER)
+//    @Log(title = "瀹℃牳璐圭敤", businessType = BusinessType.OTHER)
     @PostMapping("/checkfund")
     public AjaxResult checkFund(@RequestBody CheckFundVO checkFundVO) {
-        logger.info("serviceFundController---checkFund鐨勫叆鍙傚�糲heckFundVO :{}", checkFundVO);
+        log.info("serviceFundController---checkFund鐨勫叆鍙傚�糲heckFundVO :{}", checkFundVO);
         ServiceFund serviceFund = serviceFundService.getById(checkFundVO.getFundid());
         if (serviceFund != null) {
             Integer TotalLevel = 0;
@@ -473,7 +490,7 @@
             serviceFundflowrule.setFundtype(2);
             serviceFundflowrule.setApplytype(serviceFund.getApplytype());
             serviceFundflowrule.setCheckuserno(loginUser.getUsername());
-            logger.info("serviceFundController---checkFund---queryList鐨勫叆鍙傚�約erviceFundflowrule:{}", serviceFundflowrule);
+            log.info("serviceFundController---checkFund---queryList鐨勫叆鍙傚�約erviceFundflowrule:{}", serviceFundflowrule);
 
             List<ServiceFundflowrule> serviceFundflowrules = serviceFundflowruleService.queryList(serviceFundflowrule);
 
@@ -513,6 +530,8 @@
                     //搴斿尰闄㈣姹傚鏋滃嚭鐜伴��鍥烇紝鐩存帴閫�鍒板彂璧疯��
                     FlowLevel = 0;
                     RecordStatus = -1;
+                    logger.info("serviceFund杩涙潵浜嗗悧锛燂紵锛燂紵锛燂紵 :{},{}", RecordStatus, FlowLevel);
+                    System.out.println("serviceFund杩涙潵浜嗗悧锛燂紵锛燂紵锛燂紵");
                 } else {
                     RecordStatus = (FlowLevel + 1) * 2 - 1;
                     FlowLevel = (FlowLevel - 1);
@@ -540,14 +559,22 @@
                 serviceFundflow.setFlowcontent(checkFundVO.getFlowconclusion() == 1 ? "閫氳繃" : "涓嶉�氳繃");
             }
             serviceFundflow.setFlowlevel(OriginalFlowLevel + 1);
-            serviceFundflowService.save(serviceFundflow);
+
+            Boolean aBoolean = serviceFundflowService.saveData(serviceFundflow);
+            log.info("sserviceFund淇濆瓨鐨勭殑鍊兼槸-------- :{}", aBoolean);
 
             //001瀹℃壒閫氳繃涔嬪悗锛屽氨闇�瑕佹妸鈥滃姙鍏涓讳换鈥濈殑鍚嶅瓧濉笂
             if (checkFundVO.getFlowconclusion() == 1 && user.getUserName().equals("001")) {
                 serviceFund.setOfficedirector(user.getNickName());
             }
-            serviceFundService.updateById(serviceFund);
+            System.out.println("serviceFund鐨勫�兼槸--------:" + serviceFund);
+            log.info("寮�濮嬫洿鏂扮殑鐨勫�兼槸--------");
+            ServiceFund updateServiceFund = new ServiceFund();
+            updateServiceFund.setRecordstatus(serviceFund.getRecordstatus());
+            updateServiceFund.setFlowlevel(serviceFund.getFlowlevel());
 
+            Boolean aBoolean1 = serviceFundService.updateById(serviceFund);
+            log.info("integer鏇存柊鐨勭殑鍊兼槸-------- :{}", aBoolean1);
             ServiceSystemmessage serviceSystemmessage = new ServiceSystemmessage();
             serviceSystemmessage.setFundtype(2);
             serviceSystemmessage.setApplytype(serviceFund.getApplytype());
@@ -707,7 +734,7 @@
         dataMap.put("XZBH", serviceFund.getBh() == null ? "" : serviceFund.getBh());
         dataMap.put("ZB", serviceFund.getDeptmentname() == null ? "" : serviceFund.getDeptmentname());
         dataMap.put("TBYYMMDD", time);
-        dataMap.put("BXDFJ", serviceFund.getAttachcount() == 0 ? "   " : serviceFund.getAttachcount());
+        dataMap.put("BXDFJ", serviceFund.getAttachcount() == null ? "   " : serviceFund.getAttachcount());
         dataMap.put("JXZXM", serviceFund.getDonorname() == null ? "" : serviceFund.getDonorname());
         dataMap.put("JSR", serviceFund.getUsername() == null ? "" : serviceFund.getUsername());
 //        dataMap.put("FYXM1", "鏀粯涓撳璐圭敤锛屽叾涓◣鍓嶉噾棰�" + serviceFund.getPretaxcost() + "鍏冿紝绋庡悗閲戦" + serviceFund.getTaxedcost() + "鍏冦��");
@@ -1013,9 +1040,9 @@
     }
 
     /**
-     * 涓嬭浇鎹愮尞鑰呭尰瀛︽垚鏈粺璁¤〃
+     * 涓嬭浇鎹愮尞鑰呭尰瀛︺�佸姙鍏�佺哗鏁堟垚鏈粺璁¤〃
      */
-    @ApiOperation("鎹愮尞鑰呭尰瀛︽垚鏈粺璁¤〃")
+    @ApiOperation("鎹愮尞鑰呭尰瀛︺�佸姙鍏�佺哗鏁堟垚鏈粺璁¤〃")
     @GetMapping(value = "/downloadYX/{id}")
     public Map downloadInfoYX(@PathVariable("id") Long id) throws IOException {
         Map dataMap = new HashMap();
@@ -1028,11 +1055,13 @@
         Template t = null;
         try {
             //鎹愮尞琛�.ftl涓鸿瑁呰浇鐨勬ā鏉�
-            //涓撳鍔冲姟璐圭敵璇� 1    浼︾悊璇勪及鍔冲姟璐圭敵璇� 2    鍖诲鎴愭湰璐圭敤鐢宠 3     鍔炲叕璐圭敤鎶ラ攢鐢宠 4
+            //涓撳鍔冲姟璐圭敵璇� 1    浼︾悊璇勪及鍔冲姟璐圭敵璇� 2    鍖诲鎴愭湰璐圭敤鐢宠 3     鍔炲叕璐圭敤鎶ラ攢鐢宠 4   缁╂晥璐圭敤鎶ラ攢鐢宠 5
             if (dataYX.equals("3")) {
                 t = configuration.getTemplate("鍖诲鎴愭湰璐圭敤鐢宠鍗�.ftl");
             } else if (dataYX.equals("4")) {
                 t = configuration.getTemplate("鍔炲叕璐圭敤鐢宠鍗�.ftl");
+            } else if (dataYX.equals("5")) {
+                t = configuration.getTemplate("缁╂晥璐圭敤鐢宠鍗�.ftl");
             }
         } catch (IOException e) {
             e.printStackTrace();
@@ -1043,6 +1072,8 @@
             name = "鍖诲鎴愭湰璐圭敤鐢宠鍗昣" + dataMap.get("XM") + "_" + newTime;
         } else if (dataYX.equals("4")) {
             name = "鍔炲叕璐圭敤鐢宠鍗昣" + dataMap.get("XM") + "_" + newTime;
+        } else if (dataYX.equals("5")) {
+            name = "缁╂晥璐圭敤鐢宠鍗昣" + dataMap.get("XM") + "_" + newTime;
         }
         //杈撳嚭鏂囨。璺緞鍙婂悕绉�
         File outFile = new File(RuoYiConfig.getProfile() + "/download/wordtemplate/" + name + ".doc");
@@ -1055,6 +1086,7 @@
             e1.printStackTrace();
         }
         try {
+
             t.process(dataMap, out);
         } catch (TemplateException e) {
             e.printStackTrace();
@@ -1075,6 +1107,18 @@
         }
 
         List<ServiceFunddetail> fd = serviceFunddetailService.getAllDetailsByFDIDHZ(id);
+        if (serviceFund.getApplytype().equals("5")) {
+            //缁╂晥鐨勮鎯呭鏋滃皬浜�3琛岋紝榛樿瑕佺瓑浜�3琛�
+            if (fd.size() < 3) {
+                for (int i = 0; i <= 3 - fd.size(); i++) {
+                    ServiceFunddetail serviceFunddetail = new ServiceFunddetail();
+                    serviceFunddetail.setQuantity(0.00);
+                    serviceFunddetail.setPrice(0.00);
+                    serviceFunddetail.setAmount(0.00);
+                    fd.add(serviceFunddetail);
+                }
+            }
+        }
         if (fd == null) {
             throw new ServiceException("涓嬭浇澶辫触锛屾病鏈夊搴斾俊鎭�", HttpStatus.NO_CONTENT);
         }
@@ -1135,6 +1179,9 @@
             String fyxm = "";
             fyxm += f.getItemname() == null ? "" : f.getItemname();
             fyxm += f.getAmount() + "鍏�";
+            if (f.getItemname() == null && f.getAmount() == 0.0) {
+                fyxm = "";
+            }
             map.put("FYXM", fyxm);
             newList.add(map);
         }
@@ -1171,7 +1218,7 @@
             count++;
             map.put("XH", count);
             map.put("FWNR", f.getItemname() == null ? "" : f.getItemname());
-            map.put("DW", f.getUnitname() == null ? "" : f.getUnitname());
+            map.put("DW", f.getBeneficiaryname() == null ? "" : f.getBeneficiaryname());
             map.put("SL", f.getQuantity() == 0.00 ? "" : f.getQuantity());
             map.put("JG", f.getPrice() == 0.00 ? "" : f.getPrice());
 
@@ -2003,4 +2050,17 @@
 
     }
 
+
+    /**
+     * 缁╂晥璁$畻
+     */
+    @ApiOperation("缁╂晥璁$畻")
+    @Log(title = "缁╂晥璁$畻", businessType = BusinessType.INSERT)
+    @PostMapping("/performance")
+    @RepeatSubmit
+    public AjaxResult performance(@RequestBody ServiceFundVO serviceFundVO) {
+
+        return AjaxResult.success(serviceFundService.performance(serviceFundVO));
+    }
+
 }

--
Gitblit v1.9.3