Browse Source

代码修改

LAPTOP-KB9HII50\70708 3 years ago
parent
commit
a13bd628a3

+ 7 - 4
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/wlyygc/WlyygcDataEndpoint.java

@ -6,6 +6,7 @@ import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@ -25,9 +26,10 @@ public class WlyygcDataEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "signOlderNum")
    @ApiOperation(value = "社区签约老人数量")
    public ObjEnvelop signOlderNum() {
    public ObjEnvelop signOlderNum(@ApiParam(name = "code", value = "社区编码")
                                   @RequestParam(value = "code", required = true) String code) {
        try {
            Integer result = wlyygcStatisticsService.signOlderNum();
            Integer result = wlyygcStatisticsService.signOlderNum(code);
            return success(result);
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
@ -36,9 +38,10 @@ public class WlyygcDataEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "deviceInfo")
    @ApiOperation(value = "绑定设备在线数量,绑定设备总数")
    public ObjEnvelop deviceInfo() {
    public ObjEnvelop deviceInfo(@ApiParam(name = "code", value = "社区编码")
                                  @RequestParam(value = "code", required = true) String code) {
        try {
            JSONObject result = wlyygcStatisticsService.deviceInfo();
            JSONObject result = wlyygcStatisticsService.deviceInfo(code);
            return success(result);
        } catch (Exception e) {
            return failedObjEnvelopException2(e);

+ 26 - 5
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/WlyygcStatisticsService.java

@ -5,6 +5,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -17,14 +18,23 @@ public class WlyygcStatisticsService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 社区签约老人数量
     * @return
     */
    public Integer signOlderNum(){
    public Integer signOlderNum(String code){
        String sql = "select count(DISTINCT p.id) FROM  " +
                "base_patient p INNER JOIN base_service_package_sign_record sr on p.id = sr.patient and sr.`status`=1 and  p.id not in (SELECT dict_code from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older') " +
                "WHERE p.del = 1 and p.archive_type =1";
                "base_patient p INNER JOIN base_service_package_sign_record sr on p.id = sr.patient and sr.`status`=1 " +
                ", base_service_package_record r "+
                "WHERE p.del = 1 and p.archive_type =1  and r.patient = p.id";
        if("1".equals(code)){
            //1华联社区
            sql += "  and r.team_code = '8a92aba97a9f6f49017ae4fdbdmqteam' ";
        }else {
            return 0;
        }
        Integer res = jdbcTemplate.queryForObject(sql,Integer.class);
        return res;
    }
@ -33,11 +43,22 @@ public class WlyygcStatisticsService {
     * 绑定设备在线数量,绑定设备总数
     * @return
     */
    public JSONObject deviceInfo(){
    public JSONObject deviceInfo(String code){
        JSONObject json = new JSONObject();
        Integer total = 0;
        Integer online = 0;
        String sql = "SELECT IFNULL(contact_status,2) contact_status,COUNT(*) c from wlyy_devices WHERE is_binding = 1 GROUP BY contact_status ";
        String sql = "select count(DISTINCT d.id),d.contact_status FROM   " +
                "base_patient p INNER JOIN base_service_package_sign_record sr on p.id = sr.patient and sr.`status`=1 " +
                ", base_service_package_record r, wlyy_patient_device pd ,wlyy_devices d  " +
                "WHERE p.del = 1 and p.archive_type =1 and r.patient = p.id " +
                "and p.id = pd.`user` and d.device_code = pd.device_sn ";
        if("1".equals(code)){
            //1华联社区
            sql += "  and r.team_code = '8a92aba97a9f6f49017ae4fdbdmqteam' ";
        }else {
            return json;
        }
        sql += "  GROUP BY d.contact_status ";
        List<Map<String,Object>> res = jdbcTemplate.queryForList(sql);
        for (Map<String,Object> map : res){
            Integer num = Integer.valueOf(map.get("c").toString());