Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

LiTaohong 6 years ago
parent
commit
c9e68bc1e3

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

@ -36,6 +36,7 @@ public class HealthyHouseMapping {
            public static final String GETDICTENTRYBYDICTIDANDNAME = "/getDictEntryByDictIdAndName";
            public static final String DELETEBYDICTIDANDCODE = "/deleteByDictIdAndCode";
            public static final String ISEXISTSDICTENTRYBYDICTIDANDCODE = "/isExistsDictEntryByDictIdAndCode";
            public static final String GET_DICT_ENTRY_LIST_BY_DICT_ID = "/list/getSystemDictEntrysByList";
        }
        //设施

+ 3 - 0
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/constant/UserConstant.java

@ -7,6 +7,9 @@ package com.yihu.jw.healthyhouse.constant;
public class UserConstant {
    public static final String UNAUTHORIZED = "0";
    public static final String AUTHORIZED = "1";
    //服务分类字典id
    public static final String FACILITIES_SERVER_DICT_ID = "7";
    public static final String DEFAULT_PARENTID = "0";
}

+ 19 - 1
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/dict/SystemDictEntryController.java

@ -1,6 +1,7 @@
package com.yihu.jw.healthyhouse.controller.dict;
import com.yihu.jw.healthyhouse.constant.UserConstant;
import com.yihu.jw.healthyhouse.model.dict.DictEntryKey;
import com.yihu.jw.healthyhouse.model.dict.SystemDict;
import com.yihu.jw.healthyhouse.model.dict.SystemDictEntry;
@ -17,6 +18,7 @@ import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
/**
 * @author zdm
@ -131,11 +133,27 @@ public class SystemDictEntryController extends EnvelopRestEndpoint {
    @GetMapping(HealthyHouseMapping.HealthyHouse.SystemDictEntry.LIST)
    @ApiOperation(value = "根据dictId获取所有字典项")
    public ListEnvelop GetSystemDictEntryListByDictId(
    public ListEnvelop getSystemDictEntryListByDictId(
            @ApiParam(name = "dictId", value = "字典id")
            @RequestParam(value = "dictId") String dictId) throws Exception {
        List<SystemDictEntry> cardList = systemDictEntryService.getDictEntryCodeAndValueByDictId(dictId);
        return success(cardList);
    }
    @GetMapping(HealthyHouseMapping.HealthyHouse.SystemDictEntry.GET_DICT_ENTRY_LIST_BY_DICT_ID)
    @ApiOperation(value = "设施服务补充:根据dictId获取所有字典项-包含子类列表")
    public ListEnvelop getSystemDictEntrysByList(
            @ApiParam(name = "dictId", value = "字典id")
            @RequestParam(value = "dictId") String dictId) throws Exception {
        List<SystemDictEntry> cardList = systemDictEntryService.getSystemDictEntryListByDictId(dictId);
        // 根据父节点分组
        Map<String,List<SystemDictEntry>> map=cardList.stream().collect(Collectors.groupingBy(SystemDictEntry::getPcode));
        cardList.stream().forEach(systemDictEntry -> {
            List<SystemDictEntry> list=map.get(systemDictEntry.getCode());
            systemDictEntry.setSystemDictEntryChildrenList(list);
        });
        cardList=cardList.stream().filter(systemDictEntry-> UserConstant.DEFAULT_PARENTID.equals(systemDictEntry.getPcode())).collect(Collectors.toList());
        return success(cardList);
    }
}

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

@ -1,9 +1,11 @@
package com.yihu.jw.healthyhouse.controller.facilities;
import com.yihu.jw.exception.business.ManageException;
import com.yihu.jw.healthyhouse.constant.UserConstant;
import com.yihu.jw.healthyhouse.model.facility.Facility;
import com.yihu.jw.healthyhouse.model.facility.FacilityServer;
import com.yihu.jw.healthyhouse.model.facility.FacilityServerRelation;
import com.yihu.jw.healthyhouse.service.dict.SystemDictEntryService;
import com.yihu.jw.healthyhouse.service.facility.FacilityServerRelationService;
import com.yihu.jw.healthyhouse.service.facility.FacilityServerService;
import com.yihu.jw.healthyhouse.service.facility.FacilityService;
@ -52,6 +54,8 @@ public class FacilitiesController extends EnvelopRestEndpoint {
    private FacilityServerService facilityServerService;
    @Autowired
    private FacilityServerRelationService facilityServerRelationService;
    @Autowired
    private SystemDictEntryService systemDictEntryService;
    @ApiOperation(value = "获取设施列表", responseContainer = "List")
    @GetMapping(value = HealthyHouseMapping.HealthyHouse.Facilities.PAGE)
@ -333,7 +337,7 @@ public class FacilitiesController extends EnvelopRestEndpoint {
            @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")
            @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 {
@ -346,8 +350,10 @@ public class FacilitiesController extends EnvelopRestEndpoint {
                facilityList = facilityService.getFacilityByFacilityCode(facilityCodeList);
            }
        } else if (StringUtils.isNotEmpty(facilityServerType)) {
            //查找最小服务分类
             List<String> list= systemDictEntryService.getMinDictEntryCodeByCode(UserConstant.FACILITIES_SERVER_DICT_ID, facilityServerType);
            //设施编码为空,设施服务类型不为空,按设施服务类型获取设施
            List<String> facilityCodeList = facilityService.getFacilityCodeByServerType(facilityServerType);
            List<String> facilityCodeList = facilityService.getFacilityCodeByServerTypeList(list.toArray(new String[list.size()]));
            if (null != facilityCodeList && facilityCodeList.size() > 0) {
                facilityList = facilityService.getFacilityByFacilityCode(facilityCodeList);
            }
@ -475,7 +481,6 @@ public class FacilitiesController extends EnvelopRestEndpoint {
            if (dataList.size() > 0) {
                //TODO 导入
                facilityService.batchInsertDemo(dataList);
                System.out.println(dataList);
                return success("导入成功!");
            }

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

@ -20,6 +20,7 @@ import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -155,21 +156,25 @@ public class FacilitiesServerController extends EnvelopRestEndpoint {
    @ApiOperation(value = "app按照分类获取-设施服务列表", responseContainer = "List")
    @GetMapping(value = HealthyHouseMapping.HealthyHouse.FacilitiesServer.LIST_FACILITIESERVERS_BY_TYPE)
    public ObjEnvelop<Map> getFacilitiesServerByType() throws Exception {
        Map<String, List<FacilityServer>> map = new HashMap<>();
    public ListEnvelop<Map> getFacilitiesServerByType() throws Exception {
        List<Map> mapList=new ArrayList<>();
        Map<String, Object> map ;
        List<FacilityServer> facilityServerList;
        //获取系统字典-设施服务类型
        List<SystemDictEntry> systemDictEntryList = systemDictEntryService.getDictEntryCodeAndValueByDictId(SystemDictConstant.FACILITIE_SERVERS_TYPE_DICT_ID);
        List<SystemDictEntry> systemDictEntryList = systemDictEntryService.getDictEntryCodeAndValueByDictIdAndPcode(SystemDictConstant.FACILITIE_SERVERS_TYPE_DICT_ID);
        for (Object object : systemDictEntryList) {
            Object[] obj=(Object[])object;
            if(null!=obj[0]&&StringUtils.isNotEmpty(obj[0].toString()) ){
                map = new HashMap<>();
                String filters = "type=" + obj[0].toString();
                facilityServerList = facilityServerService.search("", filters, "");
                map.put("name",null==obj[1]?"":obj[1].toString());
                map.put(obj[0].toString(), facilityServerList);
                mapList.add(map);
            }
        }
        return success(map);
        return success("success",mapList);
    }

+ 2 - 0
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/dao/dict/SystemDictEntryDao.java

@ -36,5 +36,7 @@ public interface SystemDictEntryDao extends JpaRepository<SystemDictEntry, DictE
    @Query("select max(entry.sort) from SystemDictEntry entry where entry.dictId = :dictId")
    Integer getNextEntrySN(@Param("dictId") String dictId);
    List<SystemDictEntry> findAllByDictId(String dictId);
}

+ 0 - 1
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/interceptor/ActivatedInterceptor.java

@ -108,7 +108,6 @@ public class ActivatedInterceptor {
        }
        String userId = request.getHeader("userId");
        System.out.println(userId);
        if (userId == null) {
            response.setStatus(402);
            return joinPoint.proceed();

+ 0 - 1
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/listener/RedisKeyExpirationListener.java

@ -23,7 +23,6 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
//      super.onMessage(message, pattern);
        // 用户做自己的业务处理即可,注意message.toString()可以获取失效的key
        String expiredKey = message.toString();
        System.out.println(expiredKey);
    }
}

+ 11 - 0
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/model/dict/SystemDictEntry.java

@ -12,6 +12,7 @@ import org.springframework.data.annotation.LastModifiedDate;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
 *系统字典项。
@ -46,6 +47,7 @@ public class SystemDictEntry implements Serializable {
    protected String updateUser;
    //更新者
    protected String updateUserName;
    public List<SystemDictEntry> systemDictEntryChildrenList;
    public SystemDictEntry(){
    }
@ -172,4 +174,13 @@ public class SystemDictEntry implements Serializable {
    public void setUpdateUserName(String updateUserName) {
        this.updateUserName = updateUserName;
    }
    @Transient
    public List<SystemDictEntry> getSystemDictEntryChildrenList() {
        return systemDictEntryChildrenList;
    }
    public void setSystemDictEntryChildrenList(List<SystemDictEntry> systemDictEntryChildrenList) {
        this.systemDictEntryChildrenList = systemDictEntryChildrenList;
    }
}

+ 44 - 1
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/service/dict/SystemDictEntryService.java

@ -1,5 +1,6 @@
package com.yihu.jw.healthyhouse.service.dict;
import com.yihu.jw.healthyhouse.constant.UserConstant;
import com.yihu.jw.healthyhouse.dao.dict.SystemDictEntryDao;
import com.yihu.jw.healthyhouse.model.dict.DictEntryKey;
import com.yihu.jw.healthyhouse.model.dict.SystemDictEntry;
@ -11,6 +12,7 @@ import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
/**
@ -87,9 +89,22 @@ public class SystemDictEntryService extends BaseJpaService<SystemDictEntry, Syst
     * 根据字典id获取字典项编码和值
     */
    public List getDictEntryCodeAndValueByDictId(String dict_id) {
        String sql = "SELECT code,value FROM system_dict_entries where dict_id=:dict_id";
        String pcode = UserConstant.DEFAULT_PARENTID;
        String sql = "SELECT code,value FROM system_dict_entries where dict_id=:dict_id AND pcode =:pcode";
        SQLQuery sqlQuery = currentSession().createSQLQuery(sql);
        sqlQuery.setParameter("dict_id", dict_id);
        sqlQuery.setParameter("pcode", pcode);
        return sqlQuery.list();
    }
    /**
     * 根据字典id获取字典项编码和值
     */
    public List getDictEntryCodeAndValueByDictIdAndPcode(String dict_id) {
        String pcode = UserConstant.DEFAULT_PARENTID;
        String sql = "SELECT code,value FROM system_dict_entries where dict_id=:dict_id  AND pcode !=:pcode ";
        SQLQuery sqlQuery = currentSession().createSQLQuery(sql);
        sqlQuery.setParameter("dict_id", dict_id);
        sqlQuery.setParameter("pcode", pcode);
        return sqlQuery.list();
    }
@ -106,4 +121,32 @@ public class SystemDictEntryService extends BaseJpaService<SystemDictEntry, Syst
        }
    }
    public List<SystemDictEntry> getSystemDictEntryListByDictId(String dictId){
        return  systemDictEntryDao.findAllByDictId(dictId);
    }
    /**
     * 获取字典项,获取最小字典项。
     *
     * @param dictId
     * @param code
     * @return
     */
    public List<String> getMinDictEntryCodeByCode(String dictId, String code) {
        List<String> list = new ArrayList<>();
        list.add(code);
        SystemDictEntry systemDictEntry = systemDictEntryDao.findOne(new DictEntryKey(code, dictId));
        if (null != systemDictEntry && systemDictEntry.getPcode().equals(UserConstant.DEFAULT_PARENTID)) {
            list.remove(code);
            String sql = "SELECT code FROM system_dict_entries where dict_id=:dict_id AND pcode=:pcode";
            SQLQuery sqlQuery = currentSession().createSQLQuery(sql);
            sqlQuery.setParameter("dict_id", dictId);
            sqlQuery.setParameter("pcode", code);
            list = sqlQuery.list();
        }
        return list;
    }
}

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

@ -378,9 +378,20 @@ public class FacilityService extends BaseJpaService<Facility, FacilityDao> {
            Map<String,Double> location = (Map<String, Double>) result1.get("location");
            facility.setLatitude(location.get("lat"));
            facility.setLongitude(location.get("lng"));
            System.out.println(result);
//            System.out.println(result);
        }
    }
    /**
     * 根据服务类型获取设施
     */
    public List<String> getFacilityCodeByServerTypeList(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 IN(:type)";
        Query query = s.createSQLQuery(hql);
        query.setParameter("type", type);
        return query.list();
    }
}

+ 1 - 1
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/util/MapUtil.java

@ -28,7 +28,7 @@ public class MapUtil {
    public static void main(String[] args) {
        double distance = getDistance(118.191839, 24.49555, 118.15639977090478000000, 24.48613312327105300000);
        System.out.println(distance);
//        System.out.println(distance);
    }
}