Parcourir la source

Merge branch 'master' of huangrui/CostAccount into dev

lijiaxi il y a 4 ans
Parent
commit
bed45932c6

+ 21 - 0
src/main/java/com/imed/costaccount/model/dto/CostOtherPaymentsDataEditDto.java

@@ -0,0 +1,21 @@
+package com.imed.costaccount.model.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author 李加喜
+ * @Package com.imed.costaccount.model.dto
+ * @date 2021-08-17 10:25
+ */
+@Data
+@ApiModel("全院其他收支数据修改")
+public class CostOtherPaymentsDataEditDto extends CostOtherPaymentsDataSaveDto {
+    private static final long serialVersionUID = 1L;
+    @ApiModelProperty(name = "id",value = "原始Id不能为空")
+    @NotNull(message = "原始Id不能为空")
+    private Long id;
+}

+ 34 - 0
src/main/java/com/imed/costaccount/model/dto/CostOtherPaymentsDataSaveDto.java

@@ -0,0 +1,34 @@
+package com.imed.costaccount.model.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.math.BigDecimal;
+
+/**
+ * @author 李加喜
+ * @Package com.imed.costaccount.model.dto
+ * @date 2021-08-17 9:47
+ */
+@Data
+@ApiModel("全院收支数据")
+public class CostOtherPaymentsDataSaveDto {
+
+    @ApiModelProperty(name = "dateTime",value = "年月")
+    @NotNull(message = "时间不能为空")
+    private String dateTime;
+
+    @ApiModelProperty(name = "paymentsType",value = "收支类型")
+    @NotNull(message = "收支类型不能为空")
+    private Integer paymentsType;
+
+    @ApiModelProperty(name = "paymentsName",value = "收支名称")
+    @NotNull(message = "收支名称不能为空")
+    private String paymentsName;
+
+    @ApiModelProperty(name = "totalAmount",value = "金额")
+    @NotNull(message = "金额")
+    private BigDecimal totalAmount;
+}

+ 35 - 0
src/main/java/com/imed/costaccount/model/vo/CostOtherPaymentsDataVO.java

@@ -0,0 +1,35 @@
+package com.imed.costaccount.model.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @author 李加喜
+ * @Package com.imed.costaccount.model.vo
+ * @date 2021-08-17 9:24
+ */
+@Data
+@ApiModel("全院其他数据")
+public class CostOtherPaymentsDataVO {
+
+    @ApiModelProperty(name = "id",value = "全院其他收支数据Id")
+    private Long id;
+
+    @ApiModelProperty(name = "dateYear",value = "年份")
+    private Integer dateYear;
+
+    @ApiModelProperty(name = "dateMonth",value = "月份")
+    private Integer dateMonth;
+
+    @ApiModelProperty(name = "paymentsType",value = "收支类型")
+    private Integer paymentsType;
+
+    @ApiModelProperty(name = "paymentsName",value = "收支名称")
+    private String paymentsName;
+
+    @ApiModelProperty(name = "totalAmount",value = "金额")
+    private BigDecimal totalAmount;
+}

+ 18 - 2
src/main/java/com/imed/costaccount/service/CostOtherPaymentsDataService.java

@@ -3,6 +3,8 @@ package com.imed.costaccount.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.imed.costaccount.common.util.PageUtils;
 import com.imed.costaccount.model.CostOtherPaymentsData;
+import com.imed.costaccount.model.dto.CostOtherPaymentsDataEditDto;
+import com.imed.costaccount.model.dto.CostOtherPaymentsDataSaveDto;
 
 /**
  * 全院其他收支数据
@@ -16,10 +18,24 @@ public interface CostOtherPaymentsDataService extends IService<CostOtherPayments
      * 分页查询
      * @param current
      * @param pageSize
-     * @param datetime
+     * @param dateTime
      * @param hospId
      * @return
      */
-    PageUtils queryList(Integer current, Integer pageSize, String datetime, Long hospId);
+    PageUtils queryList(Integer current, Integer pageSize, String dateTime, Long hospId);
+
+    /**
+     *  保存全院其他收支数据
+     * @param costOtherPaymentsDataSaveDto  全院其他收支
+     * @param hospId 医院的Id
+     */
+    void addOtherPaymentData(CostOtherPaymentsDataSaveDto costOtherPaymentsDataSaveDto, Long hospId);
+
+    /**
+     * 修改全院其他收支数据
+     * @param costOtherPaymentsDataEditDto
+     * @param hospId
+     */
+    void updateOtherPaymentData(CostOtherPaymentsDataEditDto costOtherPaymentsDataEditDto, Long hospId);
 }
 

+ 9 - 0
src/main/java/com/imed/costaccount/service/CostOtherPaymentsService.java

@@ -7,6 +7,8 @@ import com.imed.costaccount.model.dto.CostOtherPaymentsEditDto;
 import com.imed.costaccount.model.vo.CostOtherPaymentsSaveDto;
 import com.imed.costaccount.model.vo.CostOtherPaymentsVO;
 
+import java.util.List;
+
 /**
  * 全院其他收支设置
  *
@@ -43,5 +45,12 @@ public interface CostOtherPaymentsService extends IService<CostOtherPayments> {
      * @param costOtherPaymentsEditDto
      */
     void updateOtherPaymentById(CostOtherPaymentsEditDto costOtherPaymentsEditDto);
+
+    /**
+     * 查询全院收支设置数据
+     * @param hospId
+     * @return
+     */
+    List<CostOtherPaymentsVO> getAll(Long hospId);
 }
 

+ 4 - 17
src/main/java/com/imed/costaccount/service/impl/CostCostingGroupServiceImpl.java

@@ -27,8 +27,6 @@ import org.springframework.web.multipart.MultipartFile;
 
 import java.math.BigDecimal;
 import java.util.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 
 @Service("costCostingGroupService")
@@ -118,9 +116,6 @@ public class CostCostingGroupServiceImpl extends ServiceImpl<CostCostingGroupMap
             return Result.build(500, "数据未成功导入", null);
         }
         // 检验数据的合理性
-
-        Pattern pattern = Pattern.compile("[0-9]+(.[0-9]+)?");
-        Matcher isNum = pattern.matcher("str");
         // 检验成本数据
         checkCostData(list, incomeErrorMessageList, departmentMap, productMap, responsibilityMap, accountingMap, responsibilityDepMap, accountProMap, costCostingGroupArrayList, year, month);
         // 文件上传
@@ -144,14 +139,6 @@ public class CostCostingGroupServiceImpl extends ServiceImpl<CostCostingGroupMap
             return Result.build(200, "数据未成功导入", null);
         }
     }
-    public static boolean isNumeric(String str){
-        Pattern pattern = Pattern.compile("[0-9]+(.[0-9]+)?");
-        Matcher isNum = pattern.matcher(str);
-        if( !isNum.matches() ){
-            return false;
-        }
-        return true;
-    }
     /**
      * 检验成本数据
      *
@@ -193,7 +180,7 @@ public class CostCostingGroupServiceImpl extends ServiceImpl<CostCostingGroupMap
                 Integer emptyStatus = 0;
                 for (int j = 2; j < data.size()-1 ; j++) {
                     BigDecimal parseInt = new BigDecimal (data.get(j).toString());
-                    if (!NumberConstant.ZERO.equals(parseInt)) {
+                    if (!BigDecimal.ZERO.equals(parseInt)) {
                         emptyStatus = 1;
                         break;
                     }
@@ -234,9 +221,9 @@ public class CostCostingGroupServiceImpl extends ServiceImpl<CostCostingGroupMap
                 // 0表示全为0 1表示不全为0
 
                 BigDecimal combined = new BigDecimal (data.get(data.size() - 1).toString());
-                if (NumberConstant.ZERO.equals(emptyStatus) && NumberConstant.ZERO.equals(combined)) {
+                if (NumberConstant.ZERO.equals(emptyStatus) &&BigDecimal.ZERO.equals(combined)) {
                     // 全为0
-                } else if (!NumberConstant.ZERO.equals(combined) && NumberConstant.ZERO.equals(emptyStatus)) {
+                } else if (!BigDecimal.ZERO.equals(combined) && NumberConstant.ZERO.equals(emptyStatus)) {
                     // 这条数据是保存到其他责任中心的
                     CostCostingGroup costCostingGroup = costCostingGroupRequest;
                     // TODO 设置其他责任中心
@@ -285,7 +272,7 @@ public class CostCostingGroupServiceImpl extends ServiceImpl<CostCostingGroupMap
                             incomeErrorMessage.setErrMessage("第" + j + "列科室信息不存在");
                             incomeErrorMessageList.add(incomeErrorMessage);
                         }
-                        costCostingGroup.setAmount(BigDecimal.valueOf(Double.parseDouble((Objects.isNull(data.get(j)) || "0".equals(data.get(j).toString())) ? "0.00" : data.get(j).toString())));
+                        costCostingGroup.setAmount(new BigDecimal((Objects.isNull(data.get(j)) || "0".equals(data.get(j).toString())) ? "0.00" : data.get(j).toString()));
                         costCostingGroup.setHospId(UserContext.getHospId());
                         costCostingGroup.setCreateTime(System.currentTimeMillis());
                         costCostingGroup.setDateYear(year);

+ 3 - 4
src/main/java/com/imed/costaccount/service/impl/CostIncomeFileServiceImpl.java

@@ -20,7 +20,6 @@ import com.imed.costaccount.model.*;
 import com.imed.costaccount.model.vo.CostIncomeFileVO;
 import com.imed.costaccount.model.vo.IncomeErrorMessage;
 import com.imed.costaccount.service.CostIncomeFileService;
-import com.imed.costaccount.service.ShareParamValueService;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
@@ -75,11 +74,11 @@ public class CostIncomeFileServiceImpl extends ServiceImpl<CostIncomeFileMapper,
             costIncomeFile.setSuccessAmount(list.size());
         }
         if (NumberConstant.ONE.equals(fileType)) {
-            costIncomeFile.setFileType(INCOME_FILETYPE);
+            costIncomeFile.setFileType(SHAREPARAM_FILETYPE);
         } else if (NumberConstant.TWO.equals(fileType)) {
-            costIncomeFile.setFileType(COST_FILETYPE);
+            costIncomeFile.setFileType(INCOME_FILETYPE);
         } else if (NumberConstant.THREE.equals(fileType)) {
-            costIncomeFile.setFileType(SHAREPARAM_FILETYPE);
+            costIncomeFile.setFileType(COST_FILETYPE);
         } else {
             costIncomeFile.setFileType(file.getContentType());
         }

+ 114 - 6
src/main/java/com/imed/costaccount/service/impl/CostOtherPaymentsDataServiceImpl.java

@@ -1,11 +1,28 @@
 package com.imed.costaccount.service.impl;
 
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 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;
 import com.imed.costaccount.common.util.PageUtils;
+import com.imed.costaccount.enums.DateStyleEnum;
 import com.imed.costaccount.mapper.CostOtherPaymentsDataMapper;
 import com.imed.costaccount.model.CostOtherPaymentsData;
+import com.imed.costaccount.model.dto.CostOtherPaymentsDataEditDto;
+import com.imed.costaccount.model.dto.CostOtherPaymentsDataSaveDto;
+import com.imed.costaccount.model.vo.CostOtherPaymentsDataVO;
 import com.imed.costaccount.service.CostOtherPaymentsDataService;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;
 
 
 @Service("costOtherPaymentsDataService")
@@ -15,14 +32,105 @@ public class CostOtherPaymentsDataServiceImpl extends ServiceImpl<CostOtherPayme
     /**
      * 分页查询
      *
-     * @param current
-     * @param pageSize
-     * @param datetime
-     * @param hospId
+     * @param current 第几页
+     * @param pageSize 每页大小
+     * @param dateTime 时间
+     * @param hospId 医院Id
      * @return
      */
     @Override
-    public PageUtils queryList(Integer current, Integer pageSize, String datetime, Long hospId) {
-        return null;
+    public PageUtils queryList(Integer current, Integer pageSize, String dateTime, Long hospId) {
+        // 先检验当前年月是否存在数据
+        int year = 0;
+        int month = 0;
+        Date date = DateUtils.StringToDate(dateTime, DateStyleEnum.YYYY_MM);
+        if (StrUtil.isNotBlank(dateTime)) {
+            year = DateUtil.year(date);
+            month = DateUtil.month(date) + 1;
+        }
+        Page<CostOtherPaymentsData> paymentsDataPage = new Page<>(current, pageSize);
+        Page<CostOtherPaymentsData> pages = this.page(paymentsDataPage, new QueryWrapper<CostOtherPaymentsData>().lambda()
+                .eq(CostOtherPaymentsData::getHospId, hospId)
+                .eq(StrUtil.isNotBlank(dateTime),CostOtherPaymentsData::getDateYear,year)
+                .eq(StrUtil.isNotBlank(dateTime),CostOtherPaymentsData::getDateMonth,month)
+                .orderByDesc(CostOtherPaymentsData::getCreateTime));
+        List<CostOtherPaymentsData> records = pages.getRecords();
+        List<CostOtherPaymentsDataVO> costOtherPaymentsDataVOList = BeanUtil.convertList(records, CostOtherPaymentsDataVO.class);
+        PageUtils pageUtils = new PageUtils(pages);
+        pageUtils.setList(costOtherPaymentsDataVOList);
+        return pageUtils;
+    }
+
+    /**
+     * 保存全院其他收支数据
+     *
+     * @param costOtherPaymentsDataSaveDto 全院其他收支
+     * @param hospId 医院的Id
+     */
+    @Override
+    @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
+    public void addOtherPaymentData(CostOtherPaymentsDataSaveDto costOtherPaymentsDataSaveDto, Long hospId) {
+        String dateTime = costOtherPaymentsDataSaveDto.getDateTime();
+        // 先检验当前年月是否存在数据
+        checkOtherPaymentData(costOtherPaymentsDataSaveDto, hospId, dateTime);
+        CostOtherPaymentsData costOtherPaymentsData = BeanUtil.convertObj(costOtherPaymentsDataSaveDto, CostOtherPaymentsData.class);
+        int year = 0;
+        int month = 0;
+        Date date = DateUtils.StringToDate(dateTime, DateStyleEnum.YYYY_MM);
+        if (StrUtil.isNotBlank(dateTime)) {
+            year = DateUtil.year(date);
+            month = DateUtil.month(date) + 1;
+        }
+        costOtherPaymentsData.setHospId(hospId);
+        costOtherPaymentsData.setCreateTime(System.currentTimeMillis());
+        costOtherPaymentsData.setDateYear(year);
+        costOtherPaymentsData.setDateMonth(month);
+        this.save(costOtherPaymentsData);
+    }
+    // 先检验当前年月是否存在数据
+    private void checkOtherPaymentData(CostOtherPaymentsDataSaveDto costOtherPaymentsDataSaveDto, Long hospId, String dateTime) {
+        int year = 0;
+        int month = 0;
+        Date date = DateUtils.StringToDate(dateTime, DateStyleEnum.YYYY_MM);
+        if (StrUtil.isNotBlank(dateTime)) {
+            year = DateUtil.year(date);
+            month = DateUtil.month(date) + 1;
+        }
+        Integer paymentsType = costOtherPaymentsDataSaveDto.getPaymentsType();
+        String paymentsName = costOtherPaymentsDataSaveDto.getPaymentsName();
+        CostOtherPaymentsData paymentsData = this.getOne(new QueryWrapper<CostOtherPaymentsData>().lambda()
+                .eq(CostOtherPaymentsData::getHospId, hospId)
+                .eq(CostOtherPaymentsData::getDateYear, year).eq(CostOtherPaymentsData::getDateMonth, month)
+                .eq(CostOtherPaymentsData::getPaymentsType, paymentsType).eq(CostOtherPaymentsData::getPaymentsName, paymentsName));
+        if (Objects.nonNull(paymentsData)){
+            throw new CostException(500,"当前年月添加的数据已存在");
+        }
     }
+
+    /**
+     * 修改全院其他收支数据
+     *
+     * @param costOtherPaymentsDataEditDto
+     * @param hospId
+     */
+    @Override
+    @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
+    public void updateOtherPaymentData(CostOtherPaymentsDataEditDto costOtherPaymentsDataEditDto, Long hospId) {
+        String dateTime = costOtherPaymentsDataEditDto.getDateTime();
+        Long id = costOtherPaymentsDataEditDto.getId();
+        CostOtherPaymentsData otherPaymentsData = this.getById(id);
+        if (Objects.isNull(otherPaymentsData)){
+            throw new CostException(500,"全院其他收支数据不存在");
+        }
+        this.removeById(id);
+        CostOtherPaymentsDataSaveDto costOtherPaymentsDataSaveDto = BeanUtil.convertObj(costOtherPaymentsDataEditDto, CostOtherPaymentsDataSaveDto.class);
+        // 检验数据
+        checkOtherPaymentData(costOtherPaymentsDataSaveDto,hospId,dateTime);
+        // 实现数据添加
+        CostOtherPaymentsData costOtherPaymentsData = BeanUtil.convertObj(costOtherPaymentsDataSaveDto, CostOtherPaymentsData.class);
+        costOtherPaymentsData.setCreateTime(System.currentTimeMillis());
+        costOtherPaymentsData.setHospId(hospId);
+        this.save(costOtherPaymentsData);
+    }
+
 }

+ 12 - 0
src/main/java/com/imed/costaccount/service/impl/CostOtherPaymentsServiceImpl.java

@@ -109,4 +109,16 @@ public class CostOtherPaymentsServiceImpl extends ServiceImpl<CostOtherPaymentsM
         costOtherPayments.setHospId(hospId);
         this.save(costOtherPayments);
     }
+
+    /**
+     * 查询全院收支设置数据
+     *
+     * @param hospId
+     * @return
+     */
+    @Override
+    public List<CostOtherPaymentsVO> getAll(Long hospId) {
+        List<CostOtherPayments> costOtherPaymentsList = this.list(new QueryWrapper<CostOtherPayments>().lambda().eq(CostOtherPayments::getHospId, hospId));
+        return BeanUtil.convertList(costOtherPaymentsList, CostOtherPaymentsVO.class);
+    }
 }

+ 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();