Bläddra i källkod

根据设施服务类型、编码等条件获取设施

zdm 6 år sedan
förälder
incheckning
31487e4a32

+ 2 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/health/house/HealthyHouseMapping.java

@ -57,6 +57,8 @@ public class HealthyHouseMapping {
            public static final String UPDATE_FACILITIES_AND_RELATION = "/update/facilitieAndRelations";
            public static final String GET_ALL_FACILITIELISTS_BY_CATEGORY_AND_SERVERCODE = "/list/getAllFacilitiesByCategoryAndServerCode";
        }
        //设施服务

+ 26 - 4
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/facilities/FacilitiesController.java

@ -1,7 +1,6 @@
package com.yihu.jw.healthyhouse.controller.facilities;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.cfg.ContextAttributes;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.yihu.jw.exception.business.ManageException;
import com.yihu.jw.healthyhouse.model.facility.Facility;
import com.yihu.jw.healthyhouse.model.facility.FacilityServer;
@ -28,6 +27,7 @@ import org.springframework.web.bind.annotation.*;
import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import com.yihu.jw.restmodel.web.Envelop;
@ -314,8 +314,30 @@ public class FacilitiesController extends EnvelopRestEndpoint {
            @ApiParam(name = "filters", value = "过滤器", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        List<Facility> facilityList = facilityService.search(fields, filters, sorts);
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "facilityCategory", value = "设施分类:1小屋、2步道、3餐厅", defaultValue = "1")
            @RequestParam(value = "facilityCategory", required = false) String facilityCategory,
            @ApiParam(name = "facilityServerType", value = "非必传参数:设施服务类型:dinner吃饭、measure测量、sports运动", defaultValue = "measure")
            @RequestParam(value = "facilityServerType", required = false) String facilityServerType,
            @ApiParam(name = "facilityServerCodes", value = "非必传参数:设施服务编码,可多个,用逗号隔开", defaultValue = "jkxwServer003,HFHS7C5B5")
            @RequestParam(value = "facilityServerCodes", required = false) String facilityServerCodes) throws Exception {
        List<Facility> facilityList = new ArrayList<>();
        //设施服务编码存在,查找使用该服务的设施
        if (StringUtils.isNotEmpty(facilityServerCodes)) {
            String[] faServerCodes = facilityServerCodes.split(",");
            List<String> facilityCodeList = facilityService.getFacilityCodeByServerCode(faServerCodes);
            facilityList = facilityService.getFacilityByFacilityCode(facilityCodeList);
        } else if (StringUtils.isNotEmpty(facilityServerType)) {
            //设施编码为空,设施服务类型不为空,按设施服务类型获取设施
            List<String> facilityCodeList = facilityService.getFacilityCodeByServerType(facilityServerType);
            facilityList = facilityService.getFacilityByFacilityCode(facilityCodeList);
        } else if (StringUtils.isNotEmpty(facilityCategory)) {
            //设施编码为空,设施服务类型为空,按照设施分类获取按设施服务类型获取设施
            filters = "category=" + facilityCategory;
            facilityList = facilityService.search(fields, filters, sorts);
        } else {
            facilityList = facilityService.search(fields, filters, sorts);
        }
        return success(facilityList);
    }

+ 11 - 1
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/dao/facility/FacilityDao.java

@ -2,9 +2,14 @@ package com.yihu.jw.healthyhouse.dao.facility;
import com.yihu.jw.healthyhouse.model.facility.Facility;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.List;
/**
 * 设施dao
 *
 * @author zdm
 * @version 1.0
 * @created 2018.09.19
@ -12,7 +17,12 @@ import org.springframework.data.jpa.repository.JpaRepository;
public interface FacilityDao extends JpaRepository<Facility, String> {
    Facility findById(String id);
    Facility findByLongitudeAndLatitude(double longitude,double latitude);
    Facility findByLongitudeAndLatitude(double longitude, double latitude);
    Facility findByCode(String code);
    @Query("select f from Facility f where f.code in :code ")
    List<Facility> findByCode(@Param("code") List<String> code);
}

+ 25 - 17
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/model/facility/Facility.java

@ -59,8 +59,8 @@ public class Facility extends UuidIdentityEntityWithOperator {
    @Column(name = "street")
    private String street;
    //地址
    @Column(name = "adress")
    private String adress;
    @Column(name = "address")
    private String address;
    //服务时间:周一至周天,用逗号隔开
    @Column(name = "service_day")
    private String serviceDay ;
@ -292,21 +292,29 @@ public class Facility extends UuidIdentityEntityWithOperator {
    public void setCategoryValue(String categoryValue) {
        this.categoryValue = categoryValue;
    }
    @Transient
    public String getAddress(){
        String address = "";
        if (this.getProvinceId()!=null ) {
        }
        if (this.getCityName() !=null ){
            address += this.getCityName();
        }
        if (this.getCountyName() !=null ){
            address += this.getCountyName();
        }
        if (this.getStreet() !=null) {
            address += this.getStreet();
        }
    public String getAddress() {
        return address;
    }
    public void setAddress(String address) {
        this.address = address;
    }
    //    @Transient
//    public String getAddress(){
//        String address = "";
//        if (this.getProvinceId()!=null ) {
//
//        }
//        if (this.getCityName() !=null ){
//            address += this.getCityName();
//        }
//        if (this.getCountyName() !=null ){
//            address += this.getCountyName();
//        }
//        if (this.getStreet() !=null) {
//            address += this.getStreet();
//        }
//        return address;
//    }
}

+ 7 - 0
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/service/facility/FacilityServerService.java

@ -1,12 +1,18 @@
package com.yihu.jw.healthyhouse.service.facility;
import com.yihu.jw.healthyhouse.dao.facility.FacilityServerDao;
import com.yihu.jw.healthyhouse.model.facility.Facility;
import com.yihu.jw.healthyhouse.model.facility.FacilityServer;
import com.yihu.mysql.query.BaseJpaService;
import org.hibernate.Query;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
 * 设施服务管理器.
 *
@ -25,4 +31,5 @@ public class FacilityServerService extends BaseJpaService<FacilityServer, Facili
        return  facilityServerDao.findById(id);
    }
}

+ 27 - 1
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/service/facility/FacilityService.java

@ -9,12 +9,15 @@ import com.yihu.jw.healthyhouse.service.dict.SystemDictEntryService;
import com.yihu.jw.healthyhouse.util.facility.msg.FacilityMsg;
import com.yihu.jw.healthyhouse.util.poi.ExcelUtils;
import com.yihu.mysql.query.BaseJpaService;
import io.swagger.models.auth.In;
import jxl.write.Colour;
import jxl.write.WritableCellFormat;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.hibernate.Query;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.transform.Transformers;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -212,5 +215,28 @@ public class FacilityService extends BaseJpaService<Facility, FacilityDao> {
        return "CSHF" + randomString(5);
    }
    /**
     * 根据服务类型获取设施
     */
    public List<String> getFacilityCodeByServerType(String type){
        Session s = currentSession();
        String hql = "(SELECT  DISTINCT fsr.facilitie_code FROM  facility_server_relation fsr,facility_server fs WHERE fsr.service_code=fs.code and fs.type=:type)";
        Query query = s.createSQLQuery(hql);
        query.setParameter("type",type);
        return query.list();
    }
    public List<String> getFacilityCodeByServerCode( String[] codes)
    {
        String sql =  "(SELECT  DISTINCT fsr.facilitie_code FROM  facility_server_relation fsr WHERE fsr.service_code IN(:codes))";
        SQLQuery sqlQuery = currentSession().createSQLQuery(sql);
        sqlQuery.setParameterList("codes", codes);
        return sqlQuery.list();
    }
    public List<Facility> getFacilityByFacilityCode( List<String> facilityCodes){
        return facilityDao.findByCode(facilityCodes);
    }
}