Browse Source

财务结算-上传账户截图

yangzian 3 năm trước cách đây
mục cha
commit
f413bc9919

+ 17 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/SettlementFileController.java

@@ -4,6 +4,7 @@ import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.ctop.finance.policy.utils.Check;
 import org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementFileInfo;
 import org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementInfo;
 import org.jeecg.ctop.finance.settlement.entity.vo.SettlementFileParamsVo;
@@ -13,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.util.List;
 import java.util.Map;
 
 
@@ -48,5 +50,20 @@ public class SettlementFileController {
 
 
 
+    @ApiOperation(value="结算单-账户截图上传", notes="结算单-账户截图上传")
+    @PostMapping(value = "/insertAccountImages")
+    public Result insertAccountImages(@RequestBody ctopCwjsSettlementFileInfo settlementFileInfo) {
+        if (Check.isNull(settlementFileInfo.getSettlementList())){
+            return Result.errorMsg("账户截图不能为空!");
+        }
+        return settlementFileInfoService.insertAccountImages(settlementFileInfo,settlementFileInfo.getSettlementList());
+    }
+
+
+
+
+
+
+
 
 }

+ 4 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/entity/pojo/ctopCwjsSettlementFileInfo.java

@@ -7,6 +7,7 @@ import lombok.Data;
 
 import java.io.Serializable;
 import java.util.Date;
+import java.util.List;
 
 /**
  * 财务结算 结算单信息
@@ -105,4 +106,7 @@ public class ctopCwjsSettlementFileInfo implements Serializable {
      */
     private Date updateTime;
 
+    @TableField(exist = false)
+    private List<ctopCwjsSettlementFileInfo> settlementList;
+
 }

+ 3 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/ISettlementFileInfoService.java

@@ -7,6 +7,7 @@ import org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementFileInfo;
 import org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementInfo;
 import org.jeecg.ctop.finance.settlement.entity.vo.SettlementFileParamsVo;
 
+import java.util.List;
 import java.util.Map;
 
 public interface ISettlementFileInfoService extends IService<ctopCwjsSettlementFileInfo> {
@@ -16,6 +17,8 @@ public interface ISettlementFileInfoService extends IService<ctopCwjsSettlementF
 
     Result deleteSettlementFile(SettlementFileParamsVo paramsVo);
 
+    Result insertAccountImages(ctopCwjsSettlementFileInfo settlementFileInfo, List<ctopCwjsSettlementFileInfo> settlementList);
+
 
 
 }

+ 25 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/SettlementFileInfoServiceImpl.java

@@ -3,6 +3,7 @@ package org.jeecg.ctop.finance.settlement.service.serviceImpl;
 import cn.afterturn.easypoi.excel.ExcelImportUtil;
 import cn.afterturn.easypoi.excel.entity.ImportParams;
 import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
+import cn.hutool.core.bean.copier.CopyOptions;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.PageHelper;
@@ -22,8 +23,10 @@ import org.jeecg.ctop.finance.settlement.mapper.SettlementFileInfoMapper;
 import org.jeecg.ctop.finance.settlement.mapper.SettlementInfoMapper;
 import org.jeecg.ctop.finance.settlement.service.ISettlementFileInfoService;
 import org.jeecg.ctop.finance.settlement.service.ISettlementInfoService;
+import org.jeecg.ctop.finance.utils.SettlementUtil;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.mapping.AccessOptions;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -123,4 +126,26 @@ public class SettlementFileInfoServiceImpl extends ServiceImpl<SettlementFileInf
         return Result.successMsg("删除成功。",null);
     }
 
+
+    /**
+     *
+     * @description: 上传账户截图
+     *
+     * @param settlementFileInfo
+     * @param settlementList
+     * @return: org.jeecg.common.api.vo.Result
+     * @author: zianY
+     */
+    @Override
+    public Result insertAccountImages(ctopCwjsSettlementFileInfo settlementFileInfo, List<ctopCwjsSettlementFileInfo> settlementList) {
+        settlementList.forEach(settlement -> {
+            settlement.setAccountId(SettlementUtil.subAccountName(settlement.getFileName()));
+            //BeanUtils.copyProperties(settlementFileInfo,settlement,true,CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
+            BeanUtils.copyProperties(settlementFileInfo,settlement,SettlementUtil.getNullPropertyNames(settlementFileInfo));
+            settlementFileInfoMapper.insert(settlement);
+        });
+        return Result.successMsg("账户截图上传成功。",null);
+    }
+
+
 }

+ 1 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/SettlementInfoServiceImpl.java

@@ -15,6 +15,7 @@ import org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementInfo;
 import org.jeecg.ctop.finance.settlement.entity.vo.AccountImportVo;
 import org.jeecg.ctop.finance.settlement.mapper.SettlementInfoMapper;
 import org.jeecg.ctop.finance.settlement.service.ISettlementInfoService;
+import org.jeecg.ctop.finance.utils.SettlementUtil;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;

+ 41 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/utils/SettlementUtil.java

@@ -0,0 +1,41 @@
+package org.jeecg.ctop.finance.utils;
+
+import org.springframework.beans.BeanWrapper;
+import org.springframework.beans.BeanWrapperImpl;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * zian Y
+ * 2021/8/3
+ **/
+public class SettlementUtil {
+
+
+    /**
+     * 格式:123456-1
+     * 截取 账户 id
+     * @param str
+     * @return
+     */
+    public static String subAccountName(String str){
+        return str.substring(0, str.indexOf("-"));
+    }
+
+    /**
+     * @Description: 忽略null值/只拷贝非null属性
+     */
+    public static String[] getNullPropertyNames (Object source) {
+        final BeanWrapper src = new BeanWrapperImpl(source);
+        java.beans.PropertyDescriptor[] pds = src.getPropertyDescriptors();
+        Set<String> emptyNames = new HashSet<String>();
+        for(java.beans.PropertyDescriptor pd : pds) {
+            Object srcValue = src.getPropertyValue(pd.getName());
+            if (srcValue == null) emptyNames.add(pd.getName());
+        }
+        String[] result = new String[emptyNames.size()];
+        return emptyNames.toArray(result);
+    }
+
+}

+ 42 - 0
jeecg-boot-finance/src/test/java/org/jeecg/modules/finance/FinanceTest.java

@@ -0,0 +1,42 @@
+package org.jeecg.modules.finance;
+
+import org.jeecg.JeecgSystemApplication;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+/**
+ * zian Y
+ * 2021/8/3
+ **/
+
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,classes = JeecgSystemApplication.class)
+public class FinanceTest {
+
+    @Test
+    public void getAccountId(){
+        String str1 = "123123123-1";
+        String str2 = "123123123-1";
+        String str = str1.substring(0, str1.indexOf("-"));
+        String str3 = str2.substring(0, str2.indexOf("-"));
+
+        System.out.println(str);
+        System.out.println(str3);
+
+    }
+
+
+    public static void main(String[] args) {
+        String str1 = "123123123-1";
+        String str2 = "123123123-1";
+        String str = str1.substring(0, str1.indexOf("-"));
+        String str3 = str2.substring(0, str2.indexOf("-"));
+
+        System.out.println(str);
+        System.out.println(str3);
+    }
+
+}