|  | @ -0,0 +1,294 @@
 | 
	
		
			
				|  |  | package com.yihu.jw.care.endpoint.doctor.admin;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONArray;
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | import com.yihu.jw.care.service.common.PermissionService;
 | 
	
		
			
				|  |  | import com.yihu.jw.care.service.statistics.DetectionPlatformService;
 | 
	
		
			
				|  |  | import com.yihu.jw.care.service.statistics.StatisticsService;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.web.Envelop;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.web.ListEnvelop;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.web.ObjEnvelop;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.web.PageEnvelop;
 | 
	
		
			
				|  |  | 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.*;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | /**
 | 
	
		
			
				|  |  |  * Created by Bing on 2022/3/21.
 | 
	
		
			
				|  |  |  * APP管理员部分
 | 
	
		
			
				|  |  |  */
 | 
	
		
			
				|  |  | @RestController
 | 
	
		
			
				|  |  | @RequestMapping("admin" )
 | 
	
		
			
				|  |  | @Api(tags = "管理员部分", description = "管理员部分")
 | 
	
		
			
				|  |  | public class AdminInfoEndpoint extends EnvelopRestEndpoint {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PermissionService permissionService;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private StatisticsService statisticsService;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private DetectionPlatformService platformService;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @GetMapping(value = "getOlderOverview")
 | 
	
		
			
				|  |  |     @ApiOperation("获取老人概况")
 | 
	
		
			
				|  |  |     public ObjEnvelop getOlderOverview(@ApiParam(name = "currentUserRole", value = "登录角色")
 | 
	
		
			
				|  |  |                                        @RequestParam(value = "currentUserRole", required = false) String currentUserRole,
 | 
	
		
			
				|  |  |                                        @ApiParam(name = "currentUserRoleLevel", value = "登录角色等级(1省2市3区4社区、机构)")
 | 
	
		
			
				|  |  |                                        @RequestParam(value = "currentUserRoleLevel", required = false)String currentUserRoleLevel){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             JSONObject param = new JSONObject();
 | 
	
		
			
				|  |  |             String doctorId =  permissionService.getUID();
 | 
	
		
			
				|  |  |             param.put("doctorId",doctorId);
 | 
	
		
			
				|  |  |             if(permissionService.noPermission(0,param)){
 | 
	
		
			
				|  |  |                 return ObjEnvelop.getError("该操作没有权限");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             return ObjEnvelop.getSuccess("查询成功",statisticsService.getOlderOverview(currentUserRole,currentUserRoleLevel));
 | 
	
		
			
				|  |  |         }catch (Exception e){
 | 
	
		
			
				|  |  |             return failedObjEnvelopException2(e);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @GetMapping(value = "statisticsTotalAmount")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "统计总数")
 | 
	
		
			
				|  |  |     public ObjEnvelop statisticsTotalAmount(
 | 
	
		
			
				|  |  |             @RequestParam(required = true) String endDate,
 | 
	
		
			
				|  |  |             @RequestParam(required = true) String area,
 | 
	
		
			
				|  |  |             @RequestParam(required = true) int level,
 | 
	
		
			
				|  |  |             @RequestParam(required = true) String index,
 | 
	
		
			
				|  |  |             @ApiParam(name="type",value="类型:1本周,2本月",defaultValue = "")@RequestParam(required = false) String type) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             JSONObject param = new JSONObject();
 | 
	
		
			
				|  |  |             String doctorId =  permissionService.getUID();
 | 
	
		
			
				|  |  |             param.put("doctorId",doctorId);
 | 
	
		
			
				|  |  |             if(permissionService.noPermission(0,param)){
 | 
	
		
			
				|  |  |                 return ObjEnvelop.getError("该操作没有权限");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             JSONObject result = statisticsService.statisticsTotalAmount(endDate, area, level, index, type);
 | 
	
		
			
				|  |  |             return success(result);
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             return failedObjEnvelopException2(e);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @GetMapping(value = "patientAnalysis")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "居民分析")
 | 
	
		
			
				|  |  |     public ObjEnvelop patientAnalysis(
 | 
	
		
			
				|  |  |             @RequestParam(required = true) String endDate,
 | 
	
		
			
				|  |  |             @RequestParam(required = true) String area,
 | 
	
		
			
				|  |  |             @RequestParam(required = true) int level,
 | 
	
		
			
				|  |  |             @ApiParam(name="index",value="42幼儿,37老人",defaultValue = "")@RequestParam(required = true) String index) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             JSONObject param = new JSONObject();
 | 
	
		
			
				|  |  |             String doctorId =  permissionService.getUID();
 | 
	
		
			
				|  |  |             param.put("doctorId",doctorId);
 | 
	
		
			
				|  |  |             if(permissionService.noPermission(0,param)){
 | 
	
		
			
				|  |  |                 return ObjEnvelop.getError("该操作没有权限");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             JSONObject result = statisticsService.patientAnalysis(endDate, area, level, index);
 | 
	
		
			
				|  |  |             return success(result);
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             return failedObjEnvelopException2(e);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @GetMapping(value = "deviceAndService")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "获取安防设备种类、安防服务、预警类型 数量")
 | 
	
		
			
				|  |  |     public ObjEnvelop deviceAndService() {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             JSONObject param = new JSONObject();
 | 
	
		
			
				|  |  |             String doctorId =  permissionService.getUID();
 | 
	
		
			
				|  |  |             param.put("doctorId",doctorId);
 | 
	
		
			
				|  |  |             if(permissionService.noPermission(0,param)){
 | 
	
		
			
				|  |  |                 return ObjEnvelop.getError("该操作没有权限");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             return success("查询成功", 200, platformService.deviceAndService());
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             return failedObjEnvelopException(e);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @GetMapping(value = "addLine")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "通用折线图")
 | 
	
		
			
				|  |  |     public ListEnvelop addLine(
 | 
	
		
			
				|  |  |             @RequestParam(required = true) String startDate,
 | 
	
		
			
				|  |  |             @RequestParam(required = true) String endDate,
 | 
	
		
			
				|  |  |             @RequestParam(required = true) String area,
 | 
	
		
			
				|  |  |             @RequestParam(required = true) int level,
 | 
	
		
			
				|  |  |             @RequestParam(required = true) String index,
 | 
	
		
			
				|  |  |             @RequestParam(required = false) String timeLevel,
 | 
	
		
			
				|  |  |             @RequestParam(required = false) String interval,
 | 
	
		
			
				|  |  |             @RequestParam(required = false) String lowLevel) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             JSONObject param = new JSONObject();
 | 
	
		
			
				|  |  |             String doctorId =  permissionService.getUID();
 | 
	
		
			
				|  |  |             param.put("doctorId",doctorId);
 | 
	
		
			
				|  |  |             if(permissionService.noPermission(0,param)){
 | 
	
		
			
				|  |  |                 return ListEnvelop.getError("该操作没有权限");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             JSONArray result = statisticsService.addLine(startDate,endDate, area, level, index, timeLevel,interval,lowLevel);
 | 
	
		
			
				|  |  |             return success(result);
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             return failedListEnvelopException2(e);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @GetMapping(value = "getServiceSituation")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "设备库存、使用、总备案、照护类型设备数量")
 | 
	
		
			
				|  |  |     public ObjEnvelop getServiceSituation() {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             JSONObject param = new JSONObject();
 | 
	
		
			
				|  |  |             String doctorId =  permissionService.getUID();
 | 
	
		
			
				|  |  |             param.put("doctorId",doctorId);
 | 
	
		
			
				|  |  |             if(permissionService.noPermission(0,param)){
 | 
	
		
			
				|  |  |                 return ObjEnvelop.getError("该操作没有权限");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             return success("查询成功", 200, platformService.getServiceSituation());
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             return failedObjEnvelopException(e);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @GetMapping(value = "getDeviceCompany")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "设备物联率、失联率")
 | 
	
		
			
				|  |  |     public ObjEnvelop getDeviceCompany() {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             JSONObject param = new JSONObject();
 | 
	
		
			
				|  |  |             String doctorId =  permissionService.getUID();
 | 
	
		
			
				|  |  |             param.put("doctorId",doctorId);
 | 
	
		
			
				|  |  |             if(permissionService.noPermission(0,param)){
 | 
	
		
			
				|  |  |                 return ObjEnvelop.getError("该操作没有权限");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             JSONObject o = platformService.getDeviceComapny();
 | 
	
		
			
				|  |  |             return success(o);
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             return failedObjEnvelopException(e);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @GetMapping(value = "statisticsEmeWarnServer")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "紧急预警事件饼图、预警数量")
 | 
	
		
			
				|  |  |     public ObjEnvelop statisticsOrderServer(@RequestParam(required = true) String endDate,
 | 
	
		
			
				|  |  |                                             @RequestParam(required = true) String area,
 | 
	
		
			
				|  |  |                                             @RequestParam(required = true) int level) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             JSONObject param = new JSONObject();
 | 
	
		
			
				|  |  |             String doctorId =  permissionService.getUID();
 | 
	
		
			
				|  |  |             param.put("doctorId",doctorId);
 | 
	
		
			
				|  |  |             if(permissionService.noPermission(0,param)){
 | 
	
		
			
				|  |  |                 return ObjEnvelop.getError("该操作没有权限");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             JSONObject result = statisticsService.adminStatisticsEmeWarnServer(endDate,area,level);
 | 
	
		
			
				|  |  |             return success(result);
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             return failedObjEnvelopException2(e);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @GetMapping(value = "statisticsEmeWarnList")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "紧急预警响应率")
 | 
	
		
			
				|  |  |     public ObjEnvelop statisticsEmeWarnList(@RequestParam(required = true) String endDate,
 | 
	
		
			
				|  |  |                                             @RequestParam(required = true) String area,
 | 
	
		
			
				|  |  |                                             @RequestParam(required = true) int level) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             JSONObject param = new JSONObject();
 | 
	
		
			
				|  |  |             String doctorId =  permissionService.getUID();
 | 
	
		
			
				|  |  |             param.put("doctorId",doctorId);
 | 
	
		
			
				|  |  |             if(permissionService.noPermission(0,param)){
 | 
	
		
			
				|  |  |                 return ObjEnvelop.getError("该操作没有权限");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             JSONObject result = statisticsService.statisticsEmeWarnList(endDate,area,level);
 | 
	
		
			
				|  |  |             return success(result);
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             return failedObjEnvelopException2(e);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @GetMapping(value = "statisticsNotWishesList")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "人文关怀祝福未发送率")
 | 
	
		
			
				|  |  |     public ObjEnvelop statisticsNotWishesList(@RequestParam(required = true) String endDate,
 | 
	
		
			
				|  |  |                                               @RequestParam(required = true) String area,
 | 
	
		
			
				|  |  |                                               @RequestParam(required = true) int level) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             JSONObject param = new JSONObject();
 | 
	
		
			
				|  |  |             String doctorId =  permissionService.getUID();
 | 
	
		
			
				|  |  |             param.put("doctorId",doctorId);
 | 
	
		
			
				|  |  |             if(permissionService.noPermission(0,param)){
 | 
	
		
			
				|  |  |                 return ObjEnvelop.getError("该操作没有权限");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             JSONObject result = statisticsService.statisticsNotWishesList(endDate,area,level);
 | 
	
		
			
				|  |  |             return success(result);
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             return failedObjEnvelopException2(e);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /******设备保修**********/
 | 
	
		
			
				|  |  |     @GetMapping(value = "getDeviceRepairList")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "获取设备保修列表")
 | 
	
		
			
				|  |  |     public PageEnvelop getDeviceRepairList(@ApiParam(name="name",value = "姓名/身份证",required = false)
 | 
	
		
			
				|  |  |                                            @RequestParam(value = "name",required = false) String name,
 | 
	
		
			
				|  |  |                                            @ApiParam(name="status",value = "保修状态0保修中 1已完成",required = false)
 | 
	
		
			
				|  |  |                                            @RequestParam(value = "status",required = false) String status,
 | 
	
		
			
				|  |  |                                            @ApiParam(name="page",value = "页码",required = true)
 | 
	
		
			
				|  |  |                                            @RequestParam(value = "page",required = true,defaultValue = "1") Integer page,
 | 
	
		
			
				|  |  |                                            @ApiParam(name="size",value = "分页大小",required = true)
 | 
	
		
			
				|  |  |                                            @RequestParam(value = "size",required = true,defaultValue = "15") Integer size) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             page = page>0?page-1:0;
 | 
	
		
			
				|  |  |             JSONObject param = new JSONObject();
 | 
	
		
			
				|  |  |             String doctorId =  permissionService.getUID();
 | 
	
		
			
				|  |  |             param.put("doctorId",doctorId);
 | 
	
		
			
				|  |  |             if(permissionService.noPermission(0,param)){
 | 
	
		
			
				|  |  |                 return PageEnvelop.getError("该操作没有权限");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //todo
 | 
	
		
			
				|  |  |             return PageEnvelop.getSuccessListWithPage(null,null,page,size,null);
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             return failedPageEnvelopException2(e);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @GetMapping(value = "getDeviceRepairDetail")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "获取设备报修工单详细信息")
 | 
	
		
			
				|  |  |     public ObjEnvelop getDeviceRepairDetail(@ApiParam(name="orderId",value = "保修工单号",required = true)
 | 
	
		
			
				|  |  |                                        @RequestParam(value = "orderId",required = true) String orderId) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             JSONObject param = new JSONObject();
 | 
	
		
			
				|  |  |             String doctorId =  permissionService.getUID();
 | 
	
		
			
				|  |  |             param.put("doctorId",doctorId);
 | 
	
		
			
				|  |  |             if(permissionService.noPermission(0,param)){
 | 
	
		
			
				|  |  |                 return ObjEnvelop.getError("该操作没有权限");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //todo
 | 
	
		
			
				|  |  |             return ObjEnvelop.getSuccess("获取成功",null);
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             return failedObjEnvelopException2(e);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @PostMapping(value = "dealDeviceRepair")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "处理设备报修工单")
 | 
	
		
			
				|  |  |     public Envelop dealDeviceRepair(@ApiParam(name="orderId",value = "保修工单号",required = true)
 | 
	
		
			
				|  |  |                                     @RequestParam(value = "orderId",required = true) String orderId,
 | 
	
		
			
				|  |  |                                     @ApiParam(name="dealContent",value = "报修反馈",required = true)
 | 
	
		
			
				|  |  |                                     @RequestParam(value = "dealContent",required = true) String dealContent) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             JSONObject param = new JSONObject();
 | 
	
		
			
				|  |  |             String doctorId =  permissionService.getUID();
 | 
	
		
			
				|  |  |             param.put("doctorId",doctorId);
 | 
	
		
			
				|  |  |             if(permissionService.noPermission(0,param)){
 | 
	
		
			
				|  |  |                 return Envelop.getError("该操作没有权限");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //todo
 | 
	
		
			
				|  |  |             return Envelop.getSuccess("填写成功");
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             return failedObjEnvelopException2(e);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | }
 |