| 
															
																@ -1,16 +1,22 @@ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																package com.yihu.jw.healthyhouse.controller.facilities; 
															 | 
															
															 | 
															
																package com.yihu.jw.healthyhouse.controller.facilities; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																import com.fasterxml.jackson.databind.JavaType; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import com.yihu.jw.healthyhouse.model.facility.Facility; 
															 | 
															
															 | 
															
																import com.yihu.jw.healthyhouse.model.facility.Facility; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																import com.yihu.jw.healthyhouse.model.facility.FacilityServerRelation; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																import com.yihu.jw.healthyhouse.service.facility.FacilityServerRelationService; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import com.yihu.jw.healthyhouse.service.facility.FacilityService; 
															 | 
															
															 | 
															
																import com.yihu.jw.healthyhouse.service.facility.FacilityService; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import com.yihu.jw.restmodel.web.*; 
															 | 
															
															 | 
															
																import com.yihu.jw.restmodel.web.*; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint; 
															 | 
															
															 | 
															
																import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import com.yihu.jw.rm.health.house.HealthyHouseMapping; 
															 | 
															
															 | 
															
																import com.yihu.jw.rm.health.house.HealthyHouseMapping; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																import com.yihu.jw.util.date.DateUtil; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import io.swagger.annotations.Api; 
															 | 
															
															 | 
															
																import io.swagger.annotations.Api; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import io.swagger.annotations.ApiOperation; 
															 | 
															
															 | 
															
																import io.swagger.annotations.ApiOperation; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import io.swagger.annotations.ApiParam; 
															 | 
															
															 | 
															
																import io.swagger.annotations.ApiParam; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import org.apache.commons.lang3.StringUtils; 
															 | 
															
															 | 
															
																import org.apache.commons.lang3.StringUtils; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import org.springframework.beans.factory.annotation.Autowired; 
															 | 
															
															 | 
															
																import org.springframework.beans.factory.annotation.Autowired; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import org.springframework.http.MediaType; 
															 | 
															
															 | 
															
																import org.springframework.http.MediaType; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																import org.springframework.transaction.annotation.Propagation; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																import org.springframework.transaction.annotation.Transactional; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import org.springframework.web.bind.annotation.*; 
															 | 
															
															 | 
															
																import org.springframework.web.bind.annotation.*; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import java.io.IOException; 
															 | 
															
															 | 
															
																import java.io.IOException; 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@ -32,10 +38,12 @@ public class FacilitiesController extends EnvelopRestEndpoint { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    @Autowired 
															 | 
															
															 | 
															
																    @Autowired 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    private FacilityService facilityService; 
															 | 
															
															 | 
															
																    private FacilityService facilityService; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    @Autowired 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    private FacilityServerRelationService facilityServerRelationService; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    @ApiOperation(value = "获取设施列表", responseContainer = "List") 
															 | 
															
															 | 
															
																    @ApiOperation(value = "获取设施列表", responseContainer = "List") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    @GetMapping(value = HealthyHouseMapping.HealthyHouse.Facilities.PAGE) 
															 | 
															
															 | 
															
																    @GetMapping(value = HealthyHouseMapping.HealthyHouse.Facilities.PAGE) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    public PageEnvelop<Facility> getDictionaries( 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    public PageEnvelop<Facility> getFacilities( 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "") 
															 | 
															
															 | 
															
																            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            @RequestParam(value = "fields", required = false) String fields, 
															 | 
															
															 | 
															
																            @RequestParam(value = "fields", required = false) String fields, 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            @ApiParam(name = "filters", value = "过滤器", defaultValue = "") 
															 | 
															
															 | 
															
																            @ApiParam(name = "filters", value = "过滤器", defaultValue = "") 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@ -47,71 +55,89 @@ public class FacilitiesController extends EnvelopRestEndpoint { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            @ApiParam(name = "page", value = "页码", defaultValue = "1") 
															 | 
															
															 | 
															
																            @ApiParam(name = "page", value = "页码", defaultValue = "1") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            @RequestParam(value = "page", required = false) Integer page) throws Exception { 
															 | 
															
															 | 
															
																            @RequestParam(value = "page", required = false) Integer page) throws Exception { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        List<Facility> facilityList = facilityService.search(fields, filters, sorts, page, size); 
															 | 
															
															 | 
															
																        List<Facility> facilityList = facilityService.search(fields, filters, sorts, page, size); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        return success(facilityList, facilityList.size(), page, size); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        return success(facilityList, (null == facilityList) ? 0 : facilityList.size(), page, size); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    } 
															 | 
															
															 | 
															
																    } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    @ApiOperation(value = "创建设施") 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    @ApiOperation(value = "创建/更新(id存在)设施,包含设施与服务的关联关系") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    @Transactional(rollbackFor = Exception.class) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    @PostMapping(value = HealthyHouseMapping.HealthyHouse.Facilities.CREATE) 
															 | 
															
															 | 
															
																    @PostMapping(value = HealthyHouseMapping.HealthyHouse.Facilities.CREATE) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    public ObjEnvelop<Facility> createDictionary( 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    public ObjEnvelop<Facility> createFacilities( 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            @ApiParam(name = "facility", value = "设施JSON结构") 
															 | 
															
															 | 
															
																            @ApiParam(name = "facility", value = "设施JSON结构") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            @RequestBody Facility facility) throws IOException { 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            @RequestParam(value = "facility") String facility, 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            @ApiParam(name = "facilityServerJson", value = "设施与服务关联关系") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            @RequestParam(value = "facilityServerJson") String facilityServerJson) throws IOException { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        Facility facility1 = toEntity(facility, Facility.class); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        List<Facility> facilityList = null; 
															 | 
															
															 | 
															
																        List<Facility> facilityList = null; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        if (StringUtils.isEmpty(facility.getCode())) { 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        if (StringUtils.isEmpty(facility1.getCode())) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            return failed("设施编码不能为空!", ObjEnvelop.class); 
															 | 
															
															 | 
															
																            return failed("设施编码不能为空!", ObjEnvelop.class); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        } else { 
															 | 
															
															 | 
															
																        } else { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            facilityList = facilityService.findByField("code", facility.getCode()); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            facilityList = facilityService.findByField("code", facility1.getCode()); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            if (null != facilityList && facilityList.size() > 0) { 
															 | 
															
															 | 
															
																            if (null != facilityList && facilityList.size() > 0) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                return failed("设施编码已存在!", ObjEnvelop.class); 
															 | 
															
															 | 
															
																                return failed("设施编码已存在!", ObjEnvelop.class); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            } 
															 | 
															
															 | 
															
																            } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        } 
															 | 
															
															 | 
															
																        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        if (StringUtils.isEmpty(facility.getName())) { 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        if (StringUtils.isEmpty(facility1.getName())) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            return failed("设施名称不能为空!", ObjEnvelop.class); 
															 | 
															
															 | 
															
																            return failed("设施名称不能为空!", ObjEnvelop.class); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        } else { 
															 | 
															
															 | 
															
																        } else { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            facilityList = facilityService.findByField("name", facility.getName()); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            facilityList = facilityService.findByField("name", facility1.getName()); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            if (null != facilityList && facilityList.size() > 0) { 
															 | 
															
															 | 
															
																            if (null != facilityList && facilityList.size() > 0) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                return failed("设施名称已存在!", ObjEnvelop.class); 
															 | 
															
															 | 
															
																                return failed("设施名称已存在!", ObjEnvelop.class); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            } 
															 | 
															
															 | 
															
																            } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        } 
															 | 
															
															 | 
															
																        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        if (!(facility.getLongitude() > 0)) { 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        if (!(facility1.getLongitude() > 0)) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            return failed("设施经度不能为空!", ObjEnvelop.class); 
															 | 
															
															 | 
															
																            return failed("设施经度不能为空!", ObjEnvelop.class); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        } 
															 | 
															
															 | 
															
																        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        if (!(facility.getLatitude() > 0)) { 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        if (!(facility1.getLatitude() > 0)) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            return failed("设施纬度不能为空!", ObjEnvelop.class); 
															 | 
															
															 | 
															
																            return failed("设施纬度不能为空!", ObjEnvelop.class); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        } 
															 | 
															
															 | 
															
																        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        if (StringUtils.isEmpty(facility.getCategory().toString())) { 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        if (StringUtils.isEmpty(facility1.getCategory().toString())) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            return failed("设施类别不正确,请参考系统字典:设施类别!", ObjEnvelop.class); 
															 | 
															
															 | 
															
																            return failed("设施类别不正确,请参考系统字典:设施类别!", ObjEnvelop.class); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        } 
															 | 
															
															 | 
															
																        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        Facility Facility = facilityService.save(facility); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        return success(Facility); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        Facility facilityBack = facilityService.save(facility1); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        JavaType javaType = objectMapper.getTypeFactory().constructParametricType(List.class, FacilityServerRelation.class); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        List<FacilityServerRelation> models = objectMapper.readValue(facilityServerJson, javaType); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        if (null != models && models.size() > 0) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            for (FacilityServerRelation facilityServerRelation : models) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                facilityServerRelationService.save(facilityServerRelation); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        facilityBack.setFacilityServerRelation(models); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        return success(facilityBack); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    } 
															 | 
															
															 | 
															
																    } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    @ApiOperation(value = "获取设施") 
															 | 
															
															 | 
															
																    @ApiOperation(value = "获取设施") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    @GetMapping(value = HealthyHouseMapping.HealthyHouse.Facilities.GET_FACILITIES_BY_ID) 
															 | 
															
															 | 
															
																    @GetMapping(value = HealthyHouseMapping.HealthyHouse.Facilities.GET_FACILITIES_BY_ID) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    public ObjEnvelop<Facility> getDictionary( 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    public ObjEnvelop<Facility> getFacilitie( 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            @ApiParam(name = "id", value = "设施ID", defaultValue = "") 
															 | 
															
															 | 
															
																            @ApiParam(name = "id", value = "设施ID", defaultValue = "") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            @RequestParam(value = "id") String id) throws Exception { 
															 | 
															
															 | 
															
																            @RequestParam(value = "id") String id) throws Exception { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        Facility facility = facilityService.findById(id); 
															 | 
															
															 | 
															
																        Facility facility = facilityService.findById(id); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        List<FacilityServerRelation> facilityServerRelationList = facilityServerRelationService.findByField("facilitieCode", facility.getCode()); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        if (facility == null) { 
															 | 
															
															 | 
															
																        if (facility == null) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            return failed("设施不存在!", ObjEnvelop.class); 
															 | 
															
															 | 
															
																            return failed("设施不存在!", ObjEnvelop.class); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        } 
															 | 
															
															 | 
															
																        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        facility.setFacilityServerRelation(facilityServerRelationList); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        return success(facility); 
															 | 
															
															 | 
															
																        return success(facility); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    } 
															 | 
															
															 | 
															
																    } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    @ApiOperation(value = "获取设施") 
															 | 
															
															 | 
															
																    @ApiOperation(value = "获取设施") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    @GetMapping(value = HealthyHouseMapping.HealthyHouse.Facilities.GET_FACILITIES_BY_FIELD) 
															 | 
															
															 | 
															
																    @GetMapping(value = HealthyHouseMapping.HealthyHouse.Facilities.GET_FACILITIES_BY_FIELD) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    public ListEnvelop<Facility> getDictionaryByPhoneticCode( 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    public ListEnvelop<Facility> getFacilitiesByfield( 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            @ApiParam(name = "field", value = "查找字段名", required = true) 
															 | 
															
															 | 
															
																            @ApiParam(name = "field", value = "查找字段名", required = true) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            @RequestParam(value = "field") String field, 
															 | 
															
															 | 
															
																            @RequestParam(value = "field") String field, 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            @ApiParam(name = "value", value = "检索值") 
															 | 
															
															 | 
															
																            @ApiParam(name = "value", value = "检索值") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            @RequestParam(value = "value") String value) throws Exception { 
															 | 
															
															 | 
															
																            @RequestParam(value = "value") String value) throws Exception { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        List<Facility> facilityList = facilityService.findByField(field, value); 
															 | 
															
															 | 
															
																        List<Facility> facilityList = facilityService.findByField(field, value); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        for (Facility facility : facilityList) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            List<FacilityServerRelation> facilityServerRelationList = facilityServerRelationService.findByField("facilitieCode", facility.getCode()); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            facility.setFacilityServerRelation(facilityServerRelationList); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        return success(facilityList); 
															 | 
															
															 | 
															
																        return success(facilityList); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    } 
															 | 
															
															 | 
															
																    } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    @ApiOperation(value = "更新设施") 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    @ApiOperation(value = "新增/更新(idy已存在)设施") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    @PutMapping(value = HealthyHouseMapping.HealthyHouse.Facilities.UPDATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) 
															 | 
															
															 | 
															
																    @PutMapping(value = HealthyHouseMapping.HealthyHouse.Facilities.UPDATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    public ObjEnvelop<Facility> updateDictionary( 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            @ApiParam(name = "facility", value = "设施JSON结构") 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    public ObjEnvelop<Facility> updateFacilities( 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            @ApiParam(name = "facility", value = "设施JSON结构(不包括设施与服务关联关系)") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            @RequestBody Facility facility) throws Exception { 
															 | 
															
															 | 
															
																            @RequestBody Facility facility) throws Exception { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        if (StringUtils.isEmpty(facility.getCode())) { 
															 | 
															
															 | 
															
																        if (StringUtils.isEmpty(facility.getCode())) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            return failed("设施编码不能为空!", ObjEnvelop.class); 
															 | 
															
															 | 
															
																            return failed("设施编码不能为空!", ObjEnvelop.class); 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@ -134,14 +160,34 @@ public class FacilitiesController extends EnvelopRestEndpoint { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    @ApiOperation(value = "删除设施") 
															 | 
															
															 | 
															
																    @ApiOperation(value = "删除设施") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    @DeleteMapping(value = HealthyHouseMapping.HealthyHouse.Facilities.DELETE) 
															 | 
															
															 | 
															
																    @DeleteMapping(value = HealthyHouseMapping.HealthyHouse.Facilities.DELETE) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    public Envelop deleteDictionary( 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    public Envelop deleteFacilities( 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            @ApiParam(name = "facilitiesId", value = "设施ID") 
															 | 
															
															 | 
															
																            @ApiParam(name = "facilitiesId", value = "设施ID") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            @RequestParam(value = "facilitiesId") String facilitiesId) throws Exception { 
															 | 
															
															 | 
															
																            @RequestParam(value = "facilitiesId") String facilitiesId) throws Exception { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        Facility facility = new Facility(); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        facility.setId(facilitiesId); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        Facility facility = facilityService.findById(facilitiesId); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        facilityServerRelationService.deleteByFacilitieCode(facility.getCode()); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        facilityService.delete(facility); 
															 | 
															
															 | 
															
																        facilityService.delete(facility); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        return success("success"); 
															 | 
															
															 | 
															
																        return success("success"); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    } 
															 | 
															
															 | 
															
																    } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    @ApiOperation(value = "设施统计:设施总数/今日新增设施") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    @DeleteMapping(value = HealthyHouseMapping.HealthyHouse.Facilities.COUNT_FACILITIES) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    public ObjEnvelop<Long> countFacilities( 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            @ApiParam(name = "totalCountFlag", value = "设施总数:true;今日新增设施:false", defaultValue = "true") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            @RequestParam(value = "totalCountFlag") boolean totalCountFlag) throws Exception { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        String filters = ""; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        long count; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        //设施总数:true 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        if (totalCountFlag) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            count = facilityService.getCount(filters); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        } else { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            //今日新增设施:false 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            String todayStart = DateUtil.getStringDateShort() + " " + "00:00:00"; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            String todayEnd = DateUtil.getStringDateShort() + " " + "23:59:59"; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            filters = "createTime>=" + todayStart + ";createTime<=" + todayEnd; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            count = facilityService.getCount(filters); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        return success("success", count); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																} 
															 | 
															
															 | 
															
																} 
															 |