|  | @ -1,7 +1,7 @@
 | 
												
													
														
															|  | package com.yihu.jw.healthyhouse.controller.facilities;
 |  | package com.yihu.jw.healthyhouse.controller.facilities;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | import com.yihu.jw.healthyhouse.model.facilities.Facilities;
 |  | 
 | 
												
													
														
															|  | import com.yihu.jw.healthyhouse.service.facilities.FacilitiesService;
 |  | 
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.healthyhouse.model.facility.Facility;
 | 
												
													
														
															|  | 
 |  | 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;
 | 
												
											
												
													
														
															|  | @ -27,15 +27,15 @@ import com.yihu.jw.restmodel.web.PageEnvelop;
 | 
												
													
														
															|  |  */
 |  |  */
 | 
												
													
														
															|  | @RestController
 |  | @RestController
 | 
												
													
														
															|  | @RequestMapping(HealthyHouseMapping.api_healthyHouse_common)
 |  | @RequestMapping(HealthyHouseMapping.api_healthyHouse_common)
 | 
												
													
														
															|  | @Api(value = "Facilities", description = "设施管理", tags = {"设施管理"})
 |  | 
 | 
												
													
														
															|  | 
 |  | @Api(value = "Facility", description = "设施管理", tags = {"设施管理"})
 | 
												
													
														
															|  | public class FacilitiesController extends EnvelopRestEndpoint {
 |  | public class FacilitiesController extends EnvelopRestEndpoint {
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     @Autowired
 |  |     @Autowired
 | 
												
													
														
															|  |     private FacilitiesService facilitiesService;
 |  | 
 | 
												
													
														
															|  | 
 |  |     private FacilityService facilityService;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     @ApiOperation(value = "获取设施列表", responseContainer = "List")
 |  |     @ApiOperation(value = "获取设施列表", responseContainer = "List")
 | 
												
													
														
															|  |     @GetMapping(value = HealthyHouseMapping.HealthyHouse.Facilities.PAGE)
 |  |     @GetMapping(value = HealthyHouseMapping.HealthyHouse.Facilities.PAGE)
 | 
												
													
														
															|  |     public PageEnvelop<Facilities> getDictionaries(
 |  | 
 | 
												
													
														
															|  | 
 |  |     public PageEnvelop<Facility> getDictionaries(
 | 
												
													
														
															|  |             @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 = "")
 | 
												
											
												
													
														
															|  | @ -46,90 +46,90 @@ public class FacilitiesController extends EnvelopRestEndpoint {
 | 
												
													
														
															|  |             @RequestParam(value = "size", required = false) Integer size,
 |  |             @RequestParam(value = "size", required = false) Integer size,
 | 
												
													
														
															|  |             @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<Facilities> FacilitiesList = facilitiesService.search(fields, filters, sorts, page, size);
 |  | 
 | 
												
													
														
															|  |         return success(FacilitiesList, FacilitiesList.size(), page, size);
 |  | 
 | 
												
													
														
															|  | 
 |  |         List<Facility> facilityList = facilityService.search(fields, filters, sorts, page, size);
 | 
												
													
														
															|  | 
 |  |         return success(facilityList, facilityList.size(), page, size);
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     @ApiOperation(value = "创建设施")
 |  |     @ApiOperation(value = "创建设施")
 | 
												
													
														
															|  |     @PostMapping(value = HealthyHouseMapping.HealthyHouse.Facilities.CREATE)
 |  |     @PostMapping(value = HealthyHouseMapping.HealthyHouse.Facilities.CREATE)
 | 
												
													
														
															|  |     public ObjEnvelop<Facilities> createDictionary(
 |  | 
 | 
												
													
														
															|  |             @ApiParam(name = "facilities", value = "设施JSON结构")
 |  | 
 | 
												
													
														
															|  |             @RequestBody Facilities facilities) throws IOException {
 |  | 
 | 
												
													
														
															|  |         List<Facilities> facilitiesList = null;
 |  | 
 | 
												
													
														
															|  |         if (StringUtils.isEmpty(facilities.getCode())) {
 |  | 
 | 
												
													
														
															|  | 
 |  |     public ObjEnvelop<Facility> createDictionary(
 | 
												
													
														
															|  | 
 |  |             @ApiParam(name = "facility", value = "设施JSON结构")
 | 
												
													
														
															|  | 
 |  |             @RequestBody Facility facility) throws IOException {
 | 
												
													
														
															|  | 
 |  |         List<Facility> facilityList = null;
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isEmpty(facility.getCode())) {
 | 
												
													
														
															|  |             return failed("设施编码不能为空!", ObjEnvelop.class);
 |  |             return failed("设施编码不能为空!", ObjEnvelop.class);
 | 
												
													
														
															|  |         } else {
 |  |         } else {
 | 
												
													
														
															|  |             facilitiesList = facilitiesService.findByField("code", facilities.getCode());
 |  | 
 | 
												
													
														
															|  |             if (null != facilitiesList && facilitiesList.size() > 0) {
 |  | 
 | 
												
													
														
															|  | 
 |  |             facilityList = facilityService.findByField("code", facility.getCode());
 | 
												
													
														
															|  | 
 |  |             if (null != facilityList && facilityList.size() > 0) {
 | 
												
													
														
															|  |                 return failed("设施编码已存在!", ObjEnvelop.class);
 |  |                 return failed("设施编码已存在!", ObjEnvelop.class);
 | 
												
													
														
															|  |             }
 |  |             }
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         if (StringUtils.isEmpty(facilities.getName())) {
 |  | 
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isEmpty(facility.getName())) {
 | 
												
													
														
															|  |             return failed("设施名称不能为空!", ObjEnvelop.class);
 |  |             return failed("设施名称不能为空!", ObjEnvelop.class);
 | 
												
													
														
															|  |         } else {
 |  |         } else {
 | 
												
													
														
															|  |             facilitiesList = facilitiesService.findByField("name", facilities.getName());
 |  | 
 | 
												
													
														
															|  |             if (null != facilitiesList && facilitiesList.size() > 0) {
 |  | 
 | 
												
													
														
															|  | 
 |  |             facilityList = facilityService.findByField("name", facility.getName());
 | 
												
													
														
															|  | 
 |  |             if (null != facilityList && facilityList.size() > 0) {
 | 
												
													
														
															|  |                 return failed("设施名称已存在!", ObjEnvelop.class);
 |  |                 return failed("设施名称已存在!", ObjEnvelop.class);
 | 
												
													
														
															|  |             }
 |  |             }
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         if (!(facilities.getLongitude() > 0)) {
 |  | 
 | 
												
													
														
															|  | 
 |  |         if (!(facility.getLongitude() > 0)) {
 | 
												
													
														
															|  |             return failed("设施经度不能为空!", ObjEnvelop.class);
 |  |             return failed("设施经度不能为空!", ObjEnvelop.class);
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         if (!(facilities.getLatitude() > 0)) {
 |  | 
 | 
												
													
														
															|  | 
 |  |         if (!(facility.getLatitude() > 0)) {
 | 
												
													
														
															|  |             return failed("设施纬度不能为空!", ObjEnvelop.class);
 |  |             return failed("设施纬度不能为空!", ObjEnvelop.class);
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         if (StringUtils.isEmpty(facilities.getCategory().toString())) {
 |  | 
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isEmpty(facility.getCategory().toString())) {
 | 
												
													
														
															|  |             return failed("设施类别不正确,请参考系统字典:设施类别!", ObjEnvelop.class);
 |  |             return failed("设施类别不正确,请参考系统字典:设施类别!", ObjEnvelop.class);
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         Facilities Facilities = facilitiesService.save(facilities);
 |  | 
 | 
												
													
														
															|  |         return success(Facilities);
 |  | 
 | 
												
													
														
															|  | 
 |  |         Facility Facility = facilityService.save(facility);
 | 
												
													
														
															|  | 
 |  |         return success(Facility);
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     @ApiOperation(value = "获取设施")
 |  |     @ApiOperation(value = "获取设施")
 | 
												
													
														
															|  |     @GetMapping(value = HealthyHouseMapping.HealthyHouse.Facilities.GET_FACILITIES_BY_ID)
 |  |     @GetMapping(value = HealthyHouseMapping.HealthyHouse.Facilities.GET_FACILITIES_BY_ID)
 | 
												
													
														
															|  |     public ObjEnvelop<Facilities> getDictionary(
 |  | 
 | 
												
													
														
															|  | 
 |  |     public ObjEnvelop<Facility> getDictionary(
 | 
												
													
														
															|  |             @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 {
 | 
												
													
														
															|  |         Facilities facilities = facilitiesService.findById(id);
 |  | 
 | 
												
													
														
															|  |         if (facilities == null) {
 |  | 
 | 
												
													
														
															|  | 
 |  |         Facility facility = facilityService.findById(id);
 | 
												
													
														
															|  | 
 |  |         if (facility == null) {
 | 
												
													
														
															|  |             return failed("设施不存在!", ObjEnvelop.class);
 |  |             return failed("设施不存在!", ObjEnvelop.class);
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         return success(facilities);
 |  | 
 | 
												
													
														
															|  | 
 |  |         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<Facilities> getDictionaryByPhoneticCode(
 |  | 
 | 
												
													
														
															|  | 
 |  |     public ListEnvelop<Facility> getDictionaryByPhoneticCode(
 | 
												
													
														
															|  |             @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<Facilities> facilitiesList = facilitiesService.findByField(field, value);
 |  | 
 | 
												
													
														
															|  |         return success(facilitiesList);
 |  | 
 | 
												
													
														
															|  | 
 |  |         List<Facility> facilityList = facilityService.findByField(field, value);
 | 
												
													
														
															|  | 
 |  |         return success(facilityList);
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     @ApiOperation(value = "更新设施")
 |  |     @ApiOperation(value = "更新设施")
 | 
												
													
														
															|  |     @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<Facilities> updateDictionary(
 |  | 
 | 
												
													
														
															|  |             @ApiParam(name = "facilities", value = "设施JSON结构")
 |  | 
 | 
												
													
														
															|  |             @RequestBody Facilities facilities) throws Exception {
 |  | 
 | 
												
													
														
															|  |         if (StringUtils.isEmpty(facilities.getCode())) {
 |  | 
 | 
												
													
														
															|  | 
 |  |     public ObjEnvelop<Facility> updateDictionary(
 | 
												
													
														
															|  | 
 |  |             @ApiParam(name = "facility", value = "设施JSON结构")
 | 
												
													
														
															|  | 
 |  |             @RequestBody Facility facility) throws Exception {
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isEmpty(facility.getCode())) {
 | 
												
													
														
															|  |             return failed("设施编码不能为空!", ObjEnvelop.class);
 |  |             return failed("设施编码不能为空!", ObjEnvelop.class);
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         if (StringUtils.isEmpty(facilities.getName())) {
 |  | 
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isEmpty(facility.getName())) {
 | 
												
													
														
															|  |             return failed("设施名称不能为空!", ObjEnvelop.class);
 |  |             return failed("设施名称不能为空!", ObjEnvelop.class);
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         if (!(facilities.getLongitude() > 0)) {
 |  | 
 | 
												
													
														
															|  | 
 |  |         if (!(facility.getLongitude() > 0)) {
 | 
												
													
														
															|  |             return failed("设施经度不能为空!", ObjEnvelop.class);
 |  |             return failed("设施经度不能为空!", ObjEnvelop.class);
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         if (!(facilities.getLatitude() > 0)) {
 |  | 
 | 
												
													
														
															|  | 
 |  |         if (!(facility.getLatitude() > 0)) {
 | 
												
													
														
															|  |             return failed("设施纬度不能为空!", ObjEnvelop.class);
 |  |             return failed("设施纬度不能为空!", ObjEnvelop.class);
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         if (StringUtils.isEmpty(facilities.getCategory().toString())) {
 |  | 
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isEmpty(facility.getCategory().toString())) {
 | 
												
													
														
															|  |             return failed("设施类别不正确,请参考系统字典:设施类别!", ObjEnvelop.class);
 |  |             return failed("设施类别不正确,请参考系统字典:设施类别!", ObjEnvelop.class);
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         facilities = facilitiesService.save(facilities);
 |  | 
 | 
												
													
														
															|  |         return success(facilities);
 |  | 
 | 
												
													
														
															|  | 
 |  |         facility = facilityService.save(facility);
 | 
												
													
														
															|  | 
 |  |         return success(facility);
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     @ApiOperation(value = "删除设施")
 |  |     @ApiOperation(value = "删除设施")
 | 
												
											
												
													
														
															|  | @ -137,9 +137,9 @@ public class FacilitiesController extends EnvelopRestEndpoint {
 | 
												
													
														
															|  |     public Envelop deleteDictionary(
 |  |     public Envelop deleteDictionary(
 | 
												
													
														
															|  |             @ApiParam(name = "facilitiesId", value = "设施ID")
 |  |             @ApiParam(name = "facilitiesId", value = "设施ID")
 | 
												
													
														
															|  |             @RequestParam(value = "facilitiesId") String facilitiesId) throws Exception {
 |  |             @RequestParam(value = "facilitiesId") String facilitiesId) throws Exception {
 | 
												
													
														
															|  |         Facilities facilities = new Facilities();
 |  | 
 | 
												
													
														
															|  |         facilities.setId(facilitiesId);
 |  | 
 | 
												
													
														
															|  |         facilitiesService.delete(facilities);
 |  | 
 | 
												
													
														
															|  | 
 |  |         Facility facility = new Facility();
 | 
												
													
														
															|  | 
 |  |         facility.setId(facilitiesId);
 | 
												
													
														
															|  | 
 |  |         facilityService.delete(facility);
 | 
												
													
														
															|  |         return success("success");
 |  |         return success("success");
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 |