liusheng
8 天以前 7eb4c98f4d96bebf28685d801e7b978d6c3d251e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package com.ruoyi.web.controller.smartor;
 
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.smartor.domain.PatMedInhosp;
import com.smartor.domain.PatMedOuthosp;
import com.smartor.domain.PatMedReq;
import com.smartor.domain.PatMedRes;
import com.smartor.service.IHNGatherPatArchiveService;
import com.smartor.service.IPatMedOuthospService;
import com.smartor.service.impl.HNGatherPatArchiveServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Array;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
import java.util.List;
 
import static com.ruoyi.framework.datasource.DynamicDataSourceContextHolder.log;
 
/**
 * 河南采集患者信息接口Controller
 *
 * @author smartor
 * @date 2025-07-09
 */
@RestController
@RequestMapping("/smartor/hngather")
@Api(description = "河南采集患者信息接口")
public class HNGatherPatArchiveController extends BaseController {
    @Autowired
    private IHNGatherPatArchiveService ihnGatherPatArchiveService;
 
    /**
     * 河南数据采集
     */
    //@PreAuthorize("@ss.hasPermi('smartor:patouthosp:list')")
    @PostMapping("/selectGatherList")
    @ApiOperation("河南数据采集")
    public Integer selectUserList(@RequestBody PatMedInhosp patMedInhosp) {
//        Integer sd = ihnGatherPatArchiveService.selectDeptList(null);
//        Integer su = ihnGatherPatArchiveService.selectUserList(null);
//        Integer icd = ihnGatherPatArchiveService.selectIcd10List(null);
 
        log.info("开始按天同步用户数据,时间范围: {} 到 {}", patMedInhosp.getStartOutHospTime(), patMedInhosp.getEndOutHospTime());
 
        LocalDate startDate = patMedInhosp.getStartOutHospTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
        LocalDate endDate = patMedInhosp.getEndOutHospTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
 
        Integer po = null;
        // 循环处理每一天
        for (LocalDate currentDate = startDate; !currentDate.isAfter(endDate); currentDate = currentDate.plusDays(1)) {
            PatMedInhosp dailyCondition = new PatMedInhosp();
            LocalDateTime dayStart = currentDate.atStartOfDay();
            LocalDateTime dayEnd = currentDate.atTime(23, 59, 59);
            dailyCondition.setStartOutHospTime(Date.from(dayStart.atZone(ZoneId.systemDefault()).toInstant()));
            dailyCondition.setEndOutHospTime(Date.from(dayEnd.atZone(ZoneId.systemDefault()).toInstant()));
            Integer pi = ihnGatherPatArchiveService.selectPatMedInhospList(dailyCondition);
 
            PatMedOuthosp patMedOuthosp = new PatMedOuthosp();
            patMedOuthosp.setBeginTime(Date.from(dayStart.atZone(ZoneId.systemDefault()).toInstant()));
            patMedOuthosp.setEndTime(Date.from(dayEnd.atZone(ZoneId.systemDefault()).toInstant()));
            po = ihnGatherPatArchiveService.selectPatMedOuthospList(patMedOuthosp);
        }
        return po;
    }
 
}