ljx 4 年之前
父節點
當前提交
4020235d52

+ 21 - 7
src/main/java/com/imed/costaccount/service/impl/ShareParamValueServiceImpl.java

@@ -1,8 +1,11 @@
 package com.imed.costaccount.service.impl;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.druid.util.StringUtils;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.imed.costaccount.common.exception.CostException;
 import com.imed.costaccount.common.util.BeanUtil;
 import com.imed.costaccount.common.util.DateUtils;
@@ -10,16 +13,13 @@ import com.imed.costaccount.common.util.Result;
 import com.imed.costaccount.common.util.UserContext;
 import com.imed.costaccount.constants.NumberConstant;
 import com.imed.costaccount.enums.DateStyleEnum;
+import com.imed.costaccount.mapper.ShareParamValueMapper;
 import com.imed.costaccount.model.*;
 import com.imed.costaccount.model.vo.IncomeErrorMessage;
 import com.imed.costaccount.service.CostIncomeFileService;
 import com.imed.costaccount.service.CostShareParamService;
-import org.springframework.stereotype.Service;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-
-import com.imed.costaccount.mapper.ShareParamValueMapper;
 import com.imed.costaccount.service.ShareParamValueService;
+import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
@@ -112,8 +112,22 @@ public class ShareParamValueServiceImpl extends ServiceImpl<ShareParamValueMappe
             i.setFileId(id);
             i.setDataSourceType(1);
         });
+        // 保存数据的唯一性
+        Map<String, List<ShareParamValue>> map = shareParamValues.stream().collect(Collectors.groupingBy(k -> k.getShareParamCode().trim() + "code" + k.getResponsibilityCode().trim()+k.getDateYear().toString().trim()+"code"+k.getDateMonth().toString().trim()
+        ));
+        LinkedList<ShareParamValue> realList = new LinkedList<>();
+        Set<String> strings = map.keySet();
+        for (String str : strings) {
+            List<ShareParamValue> shareParamValuesList = map.get(str);
+            if (CollUtil.isNotEmpty(shareParamValuesList)) {
+                BigDecimal reduce = shareParamValuesList.stream().map(ShareParamValue::getValueNum).reduce(BigDecimal.ZERO, BigDecimal::add);
+                ShareParamValue shareParamValue = shareParamValuesList.get(0);
+                shareParamValue.setValueNum(reduce);
+                realList.add(shareParamValue);
+            }
+        }
         if (CollectionUtils.isEmpty(incomeErrorMessageList)) {
-            this.saveBatch(shareParamValues);
+            this.saveBatch(realList);
             return Result.build(200, "数据导入成功", null);
         } else {
             return Result.build(200, "数据未成功导入", null);
@@ -201,7 +215,7 @@ public class ShareParamValueServiceImpl extends ServiceImpl<ShareParamValueMappe
                             incomeErrorMessage.setErrMessage("第" + j + "列科室信息不存在");
                             incomeErrorMessageList.add(incomeErrorMessage);
                         }
-                        shareParamValue.setValueNum(BigDecimal.valueOf(Double.parseDouble(("0".equals(data.get(j).toString()) || StrUtil.isBlank(data.get(j).toString())) ? "0.00" : data.get(j).toString())));
+                        shareParamValue.setValueNum(new BigDecimal(("0".equals(data.get(j).toString()) || StrUtil.isBlank(data.get(j).toString())) ? "0.00" : data.get(j).toString()));
                         shareParamValue.setHospId(UserContext.getHospId());
                         shareParamValue.setCreateTime(System.currentTimeMillis());
                         shareParamValue.setDateYear(year);

+ 11 - 1
src/main/java/com/imed/costaccount/web/CostOtherPaymentsController.java

@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
 import java.util.Arrays;
+import java.util.List;
 
 
 /**
@@ -53,7 +54,16 @@ public class CostOtherPaymentsController {
 		CostOtherPaymentsVO costOtherPaymentsVO = costOtherPaymentsService.getByParamsId(id);
         return Result.ok(costOtherPaymentsVO);
     }
-
+    /**
+     * 查询全院其他收支设置数据列表
+     */
+    @GetMapping("/getAll")
+    @ApiOperation("查询全院其他收支设置列表")
+    public Result getAll(){
+        Long hospId = UserContext.getHospId();
+        List<CostOtherPaymentsVO> costOtherPaymentsVOList = costOtherPaymentsService.getAll(hospId);
+        return Result.ok(costOtherPaymentsVOList);
+    }
     /**
      * 保存
      */

+ 25 - 13
src/main/java/com/imed/costaccount/web/CostOtherPaymentsDataController.java

@@ -4,10 +4,15 @@ import com.imed.costaccount.common.util.PageUtils;
 import com.imed.costaccount.common.util.Result;
 import com.imed.costaccount.common.util.UserContext;
 import com.imed.costaccount.model.CostOtherPaymentsData;
+import com.imed.costaccount.model.dto.CostOtherPaymentsDataEditDto;
+import com.imed.costaccount.model.dto.CostOtherPaymentsDataSaveDto;
 import com.imed.costaccount.service.CostOtherPaymentsDataService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import javax.validation.Valid;
 import java.util.Arrays;
 
 
@@ -19,6 +24,7 @@ import java.util.Arrays;
  */
 @RestController
 @RequestMapping("/costAccount/costotherpaymentsdata")
+@Api(tags = "全院其他收支数据操作")
 public class CostOtherPaymentsDataController {
     @Autowired
     private CostOtherPaymentsDataService costOtherPaymentsDataService;
@@ -27,21 +33,22 @@ public class CostOtherPaymentsDataController {
      * 分页查询列表
      * 查询的是
      */
-    @RequestMapping("/list")
+    @GetMapping("/list")
+    @ApiOperation("分页查询全院其他收支数据")
     public Result list(@RequestParam(value = "current", defaultValue = "1") Integer current,
                        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
-                        @RequestParam(value = "dateTime",required = false) String datetime){
+                        @RequestParam(value = "dateTime",required = false) String dateTime){
         Long hospId = UserContext.getHospId();
-        PageUtils pageUtils = costOtherPaymentsDataService.queryList(current,pageSize,datetime,hospId);
-        return Result.ok(pageSize);
+        PageUtils pageUtils = costOtherPaymentsDataService.queryList(current,pageSize,dateTime,hospId);
+        return Result.ok(pageUtils);
     }
 
 
     /**
      * 信息
      */
-    @RequestMapping("/info/{id}")
-    public Result info(@PathVariable("id") Long id){
+    @GetMapping("/info")
+    public Result info( Long id){
 		CostOtherPaymentsData costOtherPaymentsData = costOtherPaymentsDataService.getById(id);
         return Result.ok(costOtherPaymentsData);
     }
@@ -49,25 +56,30 @@ public class CostOtherPaymentsDataController {
     /**
      * 保存
      */
-    @RequestMapping("/save")
-    public Result save(@RequestBody CostOtherPaymentsData costOtherPaymentsData){
-		costOtherPaymentsDataService.save(costOtherPaymentsData);
+    @PostMapping("/save")
+    @ApiOperation("保存全院其他收支数据")
+    public Result save(@RequestBody @Valid CostOtherPaymentsDataSaveDto costOtherPaymentsDataSaveDto){
+        Long hospId = UserContext.getHospId();
+        costOtherPaymentsDataService.addOtherPaymentData(costOtherPaymentsDataSaveDto,hospId);
         return Result.ok();
     }
 
     /**
      * 修改
      */
-    @RequestMapping("/update")
-    public Result update(@RequestBody CostOtherPaymentsData costOtherPaymentsData){
-		costOtherPaymentsDataService.updateById(costOtherPaymentsData);
+    @PostMapping("/update")
+    @ApiOperation("修改全院其他收支数据")
+    public Result update(@RequestBody @Valid CostOtherPaymentsDataEditDto costOtherPaymentsDataEditDto){
+        Long hospId = UserContext.getHospId();
+        costOtherPaymentsDataService.updateOtherPaymentData(costOtherPaymentsDataEditDto,hospId);
         return Result.ok();
     }
 
     /**
      * 删除
      */
-    @RequestMapping("/delete")
+    @PostMapping("/delete")
+    @ApiOperation("批量删除全院其他收支数据")
     public Result delete(@RequestBody Long[] ids){
 		costOtherPaymentsDataService.removeByIds(Arrays.asList(ids));
         return Result.ok();