Ver Fonte

Merge branch 'master' of huangrui/CostAccount into dev

lijiaxi há 4 anos atrás
pai
commit
fbbabe89e8

+ 16 - 0
src/main/java/com/imed/costaccount/mapper/FileRecordMapper.java

@@ -0,0 +1,16 @@
+package com.imed.costaccount.mapper;
+
+import com.imed.costaccount.model.FileRecord;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 文件记录
+ * 
+ * @author huangrui
+ * @date 2021-09-01 15:49:14
+ */
+@Mapper
+public interface FileRecordMapper extends BaseMapper<FileRecord> {
+	
+}

+ 9 - 1
src/main/java/com/imed/costaccount/mapper/HospProfitAndLossMapper.java

@@ -3,6 +3,9 @@ package com.imed.costaccount.mapper;
 import com.imed.costaccount.model.HospProfitAndLoss;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * 全院损益表
@@ -12,5 +15,10 @@ import org.apache.ibatis.annotations.Mapper;
  */
 @Mapper
 public interface HospProfitAndLossMapper extends BaseMapper<HospProfitAndLoss> {
-	
+
+    List<HospProfitAndLoss> getPageList(@Param("startIndex") int startIndex, @Param("pageSize") Integer pageSize, @Param("year") int year, @Param("month") int month, @Param("hospId") Long hospId);
+
+
+    int getPageCount(@Param("year") int year, @Param("month") int month, @Param("hospId") Long hospId);
+
 }

+ 71 - 0
src/main/java/com/imed/costaccount/model/FileRecord.java

@@ -0,0 +1,71 @@
+package com.imed.costaccount.model;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * 文件记录
+ * 
+ * @author huangrui
+ * @email 
+ * @date 2021-09-01 15:49:14
+ */
+@Data
+@Accessors(chain = true)
+@AllArgsConstructor
+@NoArgsConstructor
+@TableName("cost_file_record")
+public class FileRecord implements Serializable {
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 主键  文件编号
+	 */
+	@TableId
+	private Long id;
+	/**
+	 * 年
+	 */
+	private Integer dateYear;
+	/**
+	 * 月
+	 */
+	private Integer dateMonth;
+	/**
+	 * 文件来源
+	 */
+	private Integer fileSource;
+	/**
+	 * 文件类型
+	 */
+	private String fileType;
+	/**
+	 * 文件名称
+	 */
+	private String fileName;
+	/**
+	 * 文件上传路径
+	 */
+	private String fileUrl;
+	/**
+	 * 医院Id
+	 */
+	private Long hospId;
+	/**
+	 * 创建时间13位时间戳
+	 */
+	private Long createTime;
+	/**
+	 * 删除时间,如果存在表示已删除13位时间戳
+	 */
+	@TableLogic(value = "0",delval = "UNIX_TIMESTAMP(NOW()) * 1000")
+	private Long deleteTime;
+
+}

+ 16 - 0
src/main/java/com/imed/costaccount/service/FileRecordService.java

@@ -0,0 +1,16 @@
+package com.imed.costaccount.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.imed.costaccount.model.FileRecord;
+
+/**
+ * 文件记录
+ *
+ * @author huangrui
+ * @email 
+ * @date 2021-09-01 15:49:14
+ */
+public interface FileRecordService extends IService<FileRecord> {
+
+}
+

+ 3 - 0
src/main/java/com/imed/costaccount/service/HospProfitAndLossService.java

@@ -48,5 +48,8 @@ public interface HospProfitAndLossService extends IService<HospProfitAndLoss> {
      * @param hospId
      */
     void calcByResponsibility(String date, Long hospId);
+
+    PageUtils hospProfitReports(Integer current, Integer pageSize, Long hospId);
+
 }
 

+ 16 - 0
src/main/java/com/imed/costaccount/service/impl/FileRecordServiceImpl.java

@@ -0,0 +1,16 @@
+package com.imed.costaccount.service.impl;
+
+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.FileRecordMapper;
+import com.imed.costaccount.model.FileRecord;
+import com.imed.costaccount.service.FileRecordService;
+
+
+@Service("fileRecordService")
+public class FileRecordServiceImpl extends ServiceImpl<FileRecordMapper, FileRecord> implements FileRecordService {
+
+
+}

+ 33 - 47
src/main/java/com/imed/costaccount/service/impl/HospProfitAndLossServiceImpl.java

@@ -3,28 +3,22 @@ package com.imed.costaccount.service.impl;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
-import cn.hutool.core.io.IoUtil;
 import cn.hutool.core.util.ReUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.poi.excel.ExcelUtil;
 import cn.hutool.poi.excel.ExcelWriter;
-import cn.hutool.poi.excel.StyleSet;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.imed.costaccount.common.enums.CalcTypeEnum;
 import com.imed.costaccount.common.enums.ReportTypeEnum;
 import com.imed.costaccount.common.exception.CostException;
-import com.imed.costaccount.common.util.BeanUtil;
 import com.imed.costaccount.common.util.PageUtils;
 import com.imed.costaccount.model.*;
-import com.imed.costaccount.model.vo.HospProfitVO;
 import com.imed.costaccount.model.vo.RelationVO;
 import com.imed.costaccount.model.vo.ReportFormVO;
 import com.imed.costaccount.service.*;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.poi.hssf.usermodel.HSSFCellStyle;
-import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.xssf.usermodel.XSSFCellStyle;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
@@ -32,9 +26,7 @@ import com.imed.costaccount.mapper.HospProfitAndLossMapper;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
-import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
 import java.math.BigDecimal;
 import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
@@ -45,35 +37,40 @@ import java.util.stream.Collectors;
 @Service("hospProfitAndLossService")
 public class HospProfitAndLossServiceImpl extends ServiceImpl<HospProfitAndLossMapper, HospProfitAndLoss> implements HospProfitAndLossService {
 
+    @Value("${file.filelocal}")
+    private String hospProfitReportUrl;
+
+    @Value("${file.serverUrl}")
+    private String serverUrl;
+
     private final ReportFormService reportFormService;
     private final IncomeCollectionService collectionService;
     private final AllocationQueryService allocationQueryService;
-    private final AllocationService allocationService;
 
     private final ReportRelationService reportRelationService;
     private final CostShareLevelService shareLevelService;
     private final CostOtherPaymentsDataService otherPaymentsDataService;
     private final ResponsibilityService responsibilityService;
     private final CostAccountShareService accountShareService;
+    private final FileRecordService fileRecordService;
 
     public HospProfitAndLossServiceImpl(ReportFormService reportFormService,
                                         IncomeCollectionService collectionService,
                                         AllocationQueryService allocationQueryService,
-                                        AllocationService allocationService,
                                         ReportRelationService reportRelationService,
                                         CostShareLevelService shareLevelService,
                                         CostOtherPaymentsDataService otherPaymentsDataService,
                                         ResponsibilityService responsibilityService,
-                                        CostAccountShareService accountShareService) {
+                                        CostAccountShareService accountShareService, FileRecordService fileRecordService) {
         this.reportFormService = reportFormService;
         this.collectionService = collectionService;
         this.allocationQueryService = allocationQueryService;
-        this.allocationService = allocationService;
         this.reportRelationService = reportRelationService;
         this.shareLevelService = shareLevelService;
         this.otherPaymentsDataService = otherPaymentsDataService;
         this.responsibilityService = responsibilityService;
         this.accountShareService = accountShareService;
+        this.fileRecordService = fileRecordService;
     }
 
 
@@ -363,19 +360,10 @@ public class HospProfitAndLossServiceImpl extends ServiceImpl<HospProfitAndLossM
         DateTime parse = DateUtil.parse(date);
         int year = DateUtil.year(parse);
         int month = DateUtil.month(parse) + 1;
-        Page<HospProfitAndLoss> page = new Page<>(current, pageSize);
-        Page<HospProfitAndLoss> pages = this.page(
-                page,
-                new LambdaQueryWrapper<HospProfitAndLoss>()
-                        .eq(HospProfitAndLoss::getHospId, hospId)
-                        .eq(HospProfitAndLoss::getDateMonth, month)
-                        .eq(HospProfitAndLoss::getDateYear, year)
-        );
-        List<HospProfitAndLoss> records = pages.getRecords();
-        List<HospProfitVO> hospProfitVOS = BeanUtil.convertList(records, HospProfitVO.class);
-        PageUtils pageUtils = new PageUtils(pages);
-        pageUtils.setList(hospProfitVOS);
-        return pageUtils;
+        int startIndex = (current - 1) * pageSize;
+        List<HospProfitAndLoss> list = baseMapper.getPageList(startIndex, pageSize, year, month, hospId);
+        int totalCount = baseMapper.getPageCount(year, month, hospId);
+        return new PageUtils(list, totalCount, pageSize, current);
     }
 
     /**
@@ -395,7 +383,11 @@ public class HospProfitAndLossServiceImpl extends ServiceImpl<HospProfitAndLossM
         List<Responsibility> leafResp = responsibilityService.getLeafResp(hospId);
 
         // 得到上一层的title子节点
-        ExcelWriter writer = ExcelUtil.getWriter();
+//        ExcelWriter writer = ExcelUtil.getWriter();
+        String time = DateUtil.format(DateUtil.date(), "yyyy年MM月dd日HH时mm分ss秒");
+        String fileName = hospProfitReportUrl + "全院损益" + time + ".xlsx";
+        ExcelWriter writer = ExcelUtil.getWriter(fileName);
+
         List<String> secondTitleListCode = leafResp.stream().map(Responsibility::getResponsibilityCode).collect(Collectors.toList());
         writer.merge(leafResp.size() + 1, "全院损益计算导出 \n" + "制表时间:" + DateUtil.now());
         // 得到两层结构
@@ -441,7 +433,6 @@ public class HospProfitAndLossServiceImpl extends ServiceImpl<HospProfitAndLossM
         // 查询所有的全院损益数据  内存溢出问题
         List<HospProfitAndLoss> list = getAllDataByDate(year, month, hospId);
         int lastRow = 3;
-        Sheet sheet = writer.getSheet();
         for (int i = 0; i < allHospList.size(); i++) {
             ReportFormVO parentFormVO = allHospList.get(i);
             List<ReportFormVO> children = parentFormVO.getChildren();
@@ -470,28 +461,23 @@ public class HospProfitAndLossServiceImpl extends ServiceImpl<HospProfitAndLossM
             }
             lastRow = lastRow + size;
         }
-
-        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
-        response.setHeader("Content-Disposition", "attachment;filename=" + "全院损益列表" + ".xls");
-        ServletOutputStream out = null;
-
-        try {
-            out = response.getOutputStream();
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-        writer.flush(out, true);
+        FileRecord fileRecord = new FileRecord();
+        fileRecord.setFileName("全院损益" + time + ".xlsx").setFileSource(1).setFileType("全院损益").setFileUrl(serverUrl + fileName).setHospId(hospId)
+                .setDateYear(year).setDateMonth(month)
+                .setCreateTime(System.currentTimeMillis());
+        fileRecordService.save(fileRecord);
         writer.close();
-        IoUtil.close(out);
-
-
     }
 
-//    private List<String> getLeafRespOnlyOne(Long hospId, List<Responsibility> leafResp) {
-//        List<Long> parentIds = leafResp.stream().map(Responsibility::getParentId).collect(Collectors.toList());
-//        responsibilityService.getById(pare)
-//
-//    }
+    @Override
+    public PageUtils hospProfitReports(Integer current, Integer pageSize, Long hospId) {
+        Page<FileRecord> page = new Page<>(current, pageSize);
+        Page<FileRecord> pageUtils = fileRecordService.page(page,
+                new LambdaQueryWrapper<FileRecord>()
+                        .eq(FileRecord::getHospId, hospId)
+        );
+        return new PageUtils(pageUtils);
+    }
 
     private List<HospProfitAndLoss> getAllDataByDate(int year, int month, Long hospId) {
         return this.list(

+ 74 - 0
src/main/java/com/imed/costaccount/web/FileRecordController.java

@@ -0,0 +1,74 @@
+package com.imed.costaccount.web;
+
+import com.imed.costaccount.common.util.Result;
+import com.imed.costaccount.model.FileRecord;
+import com.imed.costaccount.model.User;
+import com.imed.costaccount.service.FileRecordService;
+import org.apache.shiro.SecurityUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Arrays;
+
+
+/**
+ * 文件记录
+ *
+ * @author huangrui
+ * @date 2021-09-01 15:49:14
+ */
+@RestController
+@RequestMapping("/costAccount/filerecord")
+public class FileRecordController {
+    @Autowired
+    private FileRecordService fileRecordService;
+
+    /**
+     * 分页查询列表
+     * 查询的是
+     */
+    @RequestMapping("/list")
+    public Result list(@RequestParam(value = "current", defaultValue = "1") Integer current,
+                       @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize){
+        User user = (User) SecurityUtils.getSubject().getPrincipal();
+        return Result.ok();
+    }
+
+
+    /**
+     * 信息
+     */
+    @RequestMapping("/info/{id}")
+    public Result info(@PathVariable("id") Long id){
+		FileRecord fileRecord = fileRecordService.getById(id);
+        return Result.ok(fileRecord);
+    }
+
+    /**
+     * 保存
+     */
+    @RequestMapping("/save")
+    public Result save(@RequestBody FileRecord fileRecord){
+		fileRecordService.save(fileRecord);
+        return Result.ok();
+    }
+
+    /**
+     * 修改
+     */
+    @RequestMapping("/update")
+    public Result update(@RequestBody FileRecord fileRecord){
+		fileRecordService.updateById(fileRecord);
+        return Result.ok();
+    }
+
+    /**
+     * 删除
+     */
+    @RequestMapping("/delete")
+    public Result delete(@RequestBody Long[] ids){
+		fileRecordService.removeByIds(Arrays.asList(ids));
+        return Result.ok();
+    }
+
+}

+ 17 - 2
src/main/java/com/imed/costaccount/web/HospProfitAndLossController.java

@@ -1,5 +1,6 @@
 package com.imed.costaccount.web;
 
+import com.baomidou.mybatisplus.extension.api.R;
 import com.imed.costaccount.common.util.PageUtils;
 import com.imed.costaccount.common.util.Result;
 import com.imed.costaccount.service.HospProfitAndLossService;
@@ -41,7 +42,21 @@ public class HospProfitAndLossController extends AbstractController {
 
     @ApiOperation("全院损益计算输出")
     @PostMapping("/report")
-    public void hospProfitReport(@RequestParam String date, HttpServletResponse response) {
-        hospProfitAndLossService.hospProfitReport(date,getHospId(),response);
+    public Result hospProfitReport(@RequestParam String date, HttpServletResponse response) {
+        try {
+            hospProfitAndLossService.hospProfitReport(date,getHospId(),response);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return Result.ok();
+    }
+
+    @ApiOperation("全院经营报表列表")
+    @GetMapping("/hospReports")
+    public Result hospReports(@RequestParam(value = "current", defaultValue = "1") Integer current,
+                              @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
+        PageUtils pageUtils = hospProfitAndLossService.hospProfitReports(current,pageSize,getHospId());
+        return Result.ok(pageUtils);
     }
 }

+ 5 - 0
src/main/resources/application-dev.yml

@@ -69,3 +69,8 @@ file:
   #  serverUrl: http://112.124.59.133:8082//
   #linux
   serverUrl: http://112.124.59.133:8082/
+  ##全院损益计算的报表URL
+  #windows
+  hospProfitReportUrl: d:/
+  #linux
+  #  hospProfitReportUrl:

+ 21 - 0
src/main/resources/mapper/FileRecordMapper.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="com.imed.costaccount.mapper.FileRecordMapper">
+
+	<!-- 可根据自己的需求,是否要使用 -->
+    <resultMap type="com.imed.costaccount.model.FileRecord" id="fileRecordMap">
+        <result property="id" column="id"/>
+        <result property="dateYear" column="date_year"/>
+        <result property="dateMonth" column="date_month"/>
+        <result property="fileSource" column="file_source"/>
+        <result property="fileType" column="file_type"/>
+        <result property="fileName" column="file_name"/>
+        <result property="fileUrl" column="file_url"/>
+        <result property="hospId" column="hosp_id"/>
+        <result property="createTime" column="create_time"/>
+        <result property="deleteTime" column="delete_time"/>
+    </resultMap>
+
+
+</mapper>

+ 31 - 0
src/main/resources/mapper/HospProfitAndLossMapper.xml

@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="com.imed.costaccount.mapper.HospProfitAndLossMapper">
+
+
+    <select id="getPageList" resultType="com.imed.costaccount.model.HospProfitAndLoss">
+        select id          as id,
+               date_year   as dateYear,
+               date_month  as dateMonth,
+               report_num  as reportNum,
+               report_name as reportName,
+               sum(amount) as amount
+        from cost_hosp_profit_and_loss
+        where date_year = #{year}
+          and date_month = #{month}
+          and hosp_id = #{hospId}
+        group by report_num
+            limit #{startIndex}, #{pageSize}
+    </select>
+    <select id="getPageCount" resultType="java.lang.Integer">
+        select count(*)
+        from (
+                 select *
+                 from cost_hosp_profit_and_loss
+                 where date_year = #{year}
+                   and date_month = #{month}
+                   and hosp_id = #{hospId}
+                 group by report_num) t
+    </select>
+</mapper>