Jelajahi Sumber

全院其他收支数据

ljx 4 tahun lalu
induk
melakukan
9e97bc57e4

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

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

@@ -285,7 +285,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);

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