3
0

2 Коммиты f7aa66980f ... dca321e69c

Автор SHA1 Сообщение Дата
  xiachangming dca321e69c Merge branch 'master' of http://s.dev01.dkiboss.com:9001/DK-SCU/dkscu-server-finance 10 месяцев назад
  xiachangming 46cd60cdbf 固定资产 10 месяцев назад

+ 68 - 0
src/main/java/com/dk/finance/controller/fia/AssetController.java

@@ -1,5 +1,10 @@
 package com.dk.finance.controller.fia;
 
+import com.dk.common.infrastructure.util.AuthUtils;
+import com.dk.common.model.vo.core.StaffEntity;
+import com.dk.common.response.ResponseCodeEnum;
+import com.dk.common.response.ResponseResultUtil;
+import com.dk.common.util.ExcelUtils;
 import com.dk.finance.model.pojo.fia.Asset;
 import com.dk.finance.model.query.fia.AssetQuery;
 import com.dk.finance.model.vo.fia.AssetVO;
@@ -7,12 +12,22 @@ import com.dk.finance.model.response.fia.AssetResponse;
 import com.dk.common.service.BaseService;
 import com.dk.common.response.ResponseResultVO;
 import com.dk.common.model.pojo.PageList;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.beans.factory.annotation.Autowired;
+
+import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import com.dk.finance.service.fia.AssetService;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
 
 /**
  * @desc   : 固定资产控制器
@@ -31,6 +46,59 @@ public class AssetController{
     @Autowired
     private AssetService assetService;
 
+    @Autowired
+    private AuthUtils authUtils;
+
+    /**
+     * @desc : 导入明细
+     * @author : 于继渤
+     * @date : 2024-12-24 09:07
+     */
+    @PostMapping({"import_item/{cpId}"})
+    public ResponseResultVO<?> importList(@PathVariable Long cpId, MultipartFile file, HttpServletResponse response) throws UnsupportedEncodingException {
+        List<AssetVO> importList = ExcelUtils.importExcel(file, 0, 1, AssetVO.class);
+        //最终有效的数据
+        List<AssetVO> otherIntoItemVOList = new ArrayList<>();
+        List<AssetVO> otherIntoItemErrorList = new ArrayList<>();
+        List<String> errMsg = new ArrayList<>();
+        String errMsgString = "";
+        Workbook workbook = null;
+        StaffEntity staff = authUtils.getStaff();
+        Integer ctrCpId = staff.getCtrCpId();
+        Integer ownCpId = staff.getOwnCpId();
+        try {
+            List<String> codeList = importList.stream().map(m -> ((m).getAssetName() != null ? (m).getAssetName() : "")).collect(Collectors.toList());
+            importList = (importList).stream().filter(f -> f.getAssetName() != null).collect(Collectors.toList());
+            if (importList.size() <= 0) {
+                return ResponseResultUtil.error(-1, "请至少选择一条有效数据");
+            }
+            //生成保存数据
+            List<AssetVO> assetVOList = new ArrayList<>();
+            //循环导入数据
+            int num = 1;
+            for (AssetVO item:importList
+                 ) {
+
+                num ++;
+            }
+            //调整行号顺序
+            errMsgString = errMsg.stream().sorted((o1, o2) -> {
+                int i1 = Integer.parseInt(o1.substring(o1.indexOf("-") + 1, o1.lastIndexOf("-")));
+                int i2 = Integer.parseInt(o2.substring(o1.indexOf("-") + 1, o2.lastIndexOf("-")));
+                return i1 - i2;
+            }).map(String::valueOf).collect(Collectors.joining("" + "|"));
+        } catch (Exception e) {
+            e.printStackTrace();
+            return ResponseResultUtil.error(-1, ResponseCodeEnum.EXCEL_UPLOAD_CONTENT_ERROR.getMessage(), e.toString());
+        }
+
+        if (errMsg.size() > 0) {
+            return ResponseResultUtil.error(-2, "部分失败,失败信息如下:|" + errMsgString, errMsgString);
+        } else {
+            return ResponseResultUtil.success();
+        }
+    }
+
     /**
      * @desc   : 分页、关联、条件查询固定资产
      * @author : 夏常明

+ 38 - 0
src/main/java/com/dk/finance/model/vo/fia/AssetVO.java

@@ -1,5 +1,6 @@
 package com.dk.finance.model.vo.fia;
 
+import cn.afterturn.easypoi.excel.annotation.Excel;
 import com.baomidou.mybatisplus.annotation.*;
 import java.io.Serializable;
 import com.dk.common.infrastructure.handler.*;
@@ -38,6 +39,7 @@ public class AssetVO implements Serializable {
     private String docId;
 
     @ApiModelProperty(value = "固定资产编码")
+    @Excel(name = "资产编码", orderNum = "1")
     private String docNo;
 
     @ApiModelProperty(value = "单据类型 (【系统单据dkscu_bs.t_doc】固定资产)")
@@ -53,35 +55,61 @@ public class AssetVO implements Serializable {
     @NotNull(message = "经手部门不能为空")
     private String orgId;
 
+    @ApiModelProperty(value = "经手部门名称")
+    @Excel(name = "经手部门", orderNum = "5")
+    private String orgName;
+
+    @ApiModelProperty(value = "使用部门")
+    @Excel(name = "使用部门", orderNum = "13")
+    private String useOrgName;
+
+    @ApiModelProperty(value = "分摊占比%")
+    @Excel(name = "分摊占比%", orderNum = "14")
+    private String feeCalcRate;
+
     @ApiModelProperty(value = "经手人")
     @NotNull(message = "经手人不能为空")
     private String staffId;
 
+    @ApiModelProperty(value = "经手人名称")
+    @Excel(name = "经手人", orderNum = "4")
+    private String staffName;
+
     @ApiModelProperty(value = "资产名称")
     @NotNull(message = "资产名称不能为空")
+    @Excel(name = "资产名称", orderNum = "2")
     private String assetName;
 
     @ApiModelProperty(value = "资产类别ID (t_fia_asset_type.type_id)")
     @NotNull(message = "资产类别ID (t_fia_asset_type.type_id)不能为空")
+    @Excel(name = "资产类别", orderNum = "3")
     private String assetTypeId;
 
     @ApiModelProperty(value = "折旧方法 (【系统数据dkscu_bs.t_data_kind】平均年限法、不折旧)")
     @NotNull(message = "折旧方法 (【系统数据dkscu_bs.t_data_kind】平均年限法、不折旧)不能为空")
     private String calcMethod;
 
+    @ApiModelProperty(value = "折旧方法名称")
+    @Excel(name = "折旧方法", orderNum = "6")
+    private String calcMethodName;
+
     @ApiModelProperty(value = "摘要")
+    @Excel(name = "摘要", orderNum = "15")
     private String summary;
 
     @ApiModelProperty(value = "资产原值 (不含税原值)")
+    @Excel(name = "资产原值", orderNum = "10")
     private BigDecimal sumAmtAsset;
 
     @ApiModelProperty(value = "资产净额 (资产净额=资产原值-累计折旧-减值准备)")
     private BigDecimal sumAmtNetWorth;
 
     @ApiModelProperty(value = "资产净残值 (资产净残值=资产原值*资产类别的税率)")
+    @Excel(name = "净残值", orderNum = "11")
     private BigDecimal sumAmtNetSalvage;
 
     @ApiModelProperty(value = "总折旧期数")
+    @Excel(name = "折旧期数(月)", orderNum = "8")
     private Integer totalCalcNo;
 
     @ApiModelProperty(value = "月折旧额")
@@ -89,6 +117,7 @@ public class AssetVO implements Serializable {
 
     @ApiModelProperty(value = "开始折旧月份 (日期取1号)")
     @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    @Excel(name = "开始折旧月", orderNum = "7")
     private LocalDate accCalcBegin;
 
     @ApiModelProperty(value = "结束折旧月份 (日期取1号)")
@@ -96,23 +125,32 @@ public class AssetVO implements Serializable {
     private LocalDate accCalcEnd;
 
     @ApiModelProperty(value = "已折旧期数")
+    @Excel(name = "已折旧期数(月)", orderNum = "9")
     private Integer happenCalcNo;
 
     @ApiModelProperty(value = "累计折旧")
+    @Excel(name = "累计折旧额", orderNum = "12")
     private BigDecimal sumAmtHappenCalc;
 
     @ApiModelProperty(value = "减值准备")
+    @Excel(name = "减值准备", orderNum = "19")
     private BigDecimal sumAmtLoss;
 
     @ApiModelProperty(value = "已清理金额")
     private BigDecimal sumAmtClear;
 
     @ApiModelProperty(value = "固定资产科目")
+    @Excel(name = "固定资产科目", orderNum = "16")
     private String assetSubjectId;
 
     @ApiModelProperty(value = "累计折旧科目")
+    @Excel(name = "累计折旧科目", orderNum = "17")
     private String calcSubjectId;
 
+    @ApiModelProperty(value = "资产减值科目")
+    @Excel(name = "资产减值科目", orderNum = "18")
+    private String lossSubjectId;
+
     @ApiModelProperty(value = "税率 (非专票固定资产取0)")
     private BigDecimal taxRate;
 

+ 12 - 1
src/main/java/com/dk/finance/service/fia/AssetService.java

@@ -71,7 +71,18 @@ public class AssetService extends BaseService<Asset> implements AccountFeeBusine
 	public ResponseResultVO<PageList<AssetResponse>> selectByCond(AssetQuery assetQuery) {
 		return super.mergeListWithCount(assetQuery, assetMapper.selectByCond(assetQuery), assetMapper.countByCond(assetQuery));
 	}
-	
+
+	/**
+	 * @desc   : 期初导入
+	 * @author : 夏常明
+	 * @date   : 2025/5/21 19:08
+	 */
+	@Transactional(rollbackFor = {Exception.class})
+	public ResponseResultVO<?> importAssetList(List<AssetVO> assetImport){
+
+		return ResponseResultUtil.success();
+	}
+
 	/**
 	 * @desc   : 新建固定资产
 	 * @author : 夏常明