wuxw
2024-01-21 4701e6cd5f7779a2da8215503570bcb0aa0b61ec
开发完成小区信息同步
6个文件已修改
269 ■■■■■ 已修改文件
java110-bean/src/main/java/com/java110/dto/owner/OwnerCarDto.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-db/src/main/resources/mapper/user/OwnerCarServiceDaoImplMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-job/src/main/java/com/java110/job/adapt/hcIotNew/SendCommunityDataToIotAdapt.java 240 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-job/src/main/java/com/java110/job/adapt/hcIotNew/http/SendIotImpl.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-user/src/main/java/com/java110/user/dao/impl/OwnerCarV1ServiceDaoImpl.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-user/src/main/java/com/java110/user/smo/impl/OwnerCarInnerServiceSMOImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-bean/src/main/java/com/java110/dto/owner/OwnerCarDto.java
@@ -109,6 +109,8 @@
    private String logStartTime;
    private String logEndTime;
    private String paId;
    private List<OwnerCarAttrDto> ownerCarAttrDto;
    public String getCarColor() {
@@ -566,4 +568,12 @@
    public void setLogEndTime(String logEndTime) {
        this.logEndTime = logEndTime;
    }
    public String getPaId() {
        return paId;
    }
    public void setPaId(String paId) {
        this.paId = paId;
    }
}
java110-db/src/main/resources/mapper/user/OwnerCarServiceDaoImplMapper.xml
@@ -128,7 +128,7 @@
        t.owner_id ownerId,t.b_id,t.b_id bId,t.user_id,t.user_id userId,t.car_id,t.car_id carId ,t.create_time
        createTime,t.community_id communityId,bow.name ownerName,bow.id_card idCard,bow.link,t2.name stateName,
        t.start_time,t.start_time startTime,t.end_time,t.end_time endTime,t.state,
        t.car_type_cd,t.car_type_cd carTypeCd,t.member_id,t.member_id memberId,ps.num,pa.num areaNum,t.lease_type
        t.car_type_cd,t.car_type_cd carTypeCd,t.member_id,t.member_id memberId,ps.num,pa.num areaNum,pa.pa_id paId,t.lease_type
        leaseType,
        t3.name leaseTypeName,t4.name carTypeCdName
        <if test="carTypeCd != '1003'">
service-job/src/main/java/com/java110/job/adapt/hcIotNew/SendCommunityDataToIotAdapt.java
@@ -4,18 +4,38 @@
import com.alibaba.fastjson.JSONObject;
import com.java110.dto.community.CommunityDto;
import com.java110.dto.community.CommunityMemberDto;
import com.java110.dto.fee.FeeDto;
import com.java110.dto.file.FileDto;
import com.java110.dto.file.FileRelDto;
import com.java110.dto.owner.OwnerCarDto;
import com.java110.dto.owner.OwnerDto;
import com.java110.dto.owner.OwnerRoomRelDto;
import com.java110.dto.room.RoomDto;
import com.java110.dto.store.StoreDto;
import com.java110.dto.system.Business;
import com.java110.intf.common.IFileInnerServiceSMO;
import com.java110.intf.common.IFileRelInnerServiceSMO;
import com.java110.intf.community.ICommunityMemberV1InnerServiceSMO;
import com.java110.intf.community.ICommunityV1InnerServiceSMO;
import com.java110.intf.community.IParkingSpaceV1InnerServiceSMO;
import com.java110.intf.community.IRoomV1InnerServiceSMO;
import com.java110.intf.store.IStoreV1InnerServiceSMO;
import com.java110.intf.user.IOwnerCarInnerServiceSMO;
import com.java110.intf.user.IOwnerCarV1InnerServiceSMO;
import com.java110.intf.user.IOwnerRoomRelV1InnerServiceSMO;
import com.java110.intf.user.IOwnerV1InnerServiceSMO;
import com.java110.job.adapt.DatabusAdaptImpl;
import com.java110.job.adapt.hcIotNew.http.ISendIot;
import com.java110.utils.exception.CmdException;
import com.java110.utils.util.Assert;
import com.java110.utils.util.ListUtil;
import com.java110.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
/**
@@ -34,6 +54,28 @@
    @Autowired
    private IStoreV1InnerServiceSMO storeV1InnerServiceSMOImpl;
    @Autowired
    private ISendIot sendIotImpl;
    @Autowired
    private IOwnerV1InnerServiceSMO ownerV1InnerServiceSMOImpl;
    @Autowired
    private IFileRelInnerServiceSMO fileRelInnerServiceSMOImpl;
    @Autowired
    private IFileInnerServiceSMO fileInnerServiceSMOImpl;
    @Autowired
    private IOwnerRoomRelV1InnerServiceSMO ownerRoomRelV1InnerServiceSMOImpl;
    @Autowired
    private IRoomV1InnerServiceSMO roomV1InnerServiceSMOImpl;
    @Autowired
    private IOwnerCarInnerServiceSMO ownerCarInnerServiceSMOImpl;
    public static final int DEFAULT_DEAL_COUNT = 200;
    /**
     * accessToken={access_token}
@@ -88,7 +130,7 @@
         * “cityCode”:”110101”,
         * “tel”:”18909711445”,
         * “storeId”:”11111”,
         * “storeId”:”演示物业”,
         * “storeName”:”演示物业”,
         * }
         */
@@ -97,13 +139,205 @@
        List<StoreDto> storeDtos = storeV1InnerServiceSMOImpl.queryStores(storeDto);
        Assert.listOnlyOne(storeDtos, "物业不存在");
//        HttpEntity httpEntity = new HttpEntity(JSONArray.toJSONString(staffs), getHeaders());
//        responseEntity = outRestTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class);
        JSONObject paramIn = new JSONObject();
        paramIn.put("communityId", communityDtos.get(0).getCommunityId());
        paramIn.put("name", communityDtos.get(0).getName());
        paramIn.put("address", communityDtos.get(0).getAddress());
        paramIn.put("cityCode", communityDtos.get(0).getCityCode());
        paramIn.put("tel", communityDtos.get(0).getTel());
        paramIn.put("storeId", storeDtos.get(0).getStoreId());
        paramIn.put("storeName", storeDtos.get(0).getStoreName());
        ResultVo resultVo = sendIotImpl.post("/iot/api/community.addCommunityApi", paramIn);
        if (resultVo.getCode() != ResultVo.CODE_OK) {
            throw new IllegalArgumentException("同步小区物业失败:" + resultVo.getMsg());
        }
    }
    private void sendOwner(String communityId) {
        OwnerDto ownerDto = new OwnerDto();
        ownerDto.setCommunityId(communityId);
        int count = ownerV1InnerServiceSMOImpl.queryOwnersCount(ownerDto);
        int page = 1;
        int max = 15;
        if (count < DEFAULT_DEAL_COUNT) {
            page = 1;
            max = count;
        } else {
            page = (int) Math.ceil((double) count / (double) DEFAULT_DEAL_COUNT);
            max = DEFAULT_DEAL_COUNT;
        }
        ownerDto = new OwnerDto();
        ownerDto.setCommunityId(communityId);
        //todo  每次按200条处理
        List<OwnerDto> ownerDtos = null;
        for (int pageIndex = 0; pageIndex < page; pageIndex++) {
            ownerDto.setPage(pageIndex + 1);
            ownerDto.setRow(max);
            ownerDtos = ownerV1InnerServiceSMOImpl.queryOwners(ownerDto);
            // 离散费用
            doSendOwners(communityId, ownerDtos);
        }
    }
    /**
     * 推送业主
     *
     * @param communityId
     * @param ownerDtos
     */
    private void doSendOwners(String communityId, List<OwnerDto> ownerDtos) {
        for (OwnerDto ownerDto : ownerDtos) {
            try {
                doSendSimple(ownerDto);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    private void doSendSimple(OwnerDto ownerDto) {
        JSONObject paramIn = new JSONObject();
        paramIn.put("communityId", ownerDto.getCommunityId());
        paramIn.put("memberId", ownerDto.getMemberId());
        paramIn.put("ownerId", ownerDto.getOwnerId());
        paramIn.put("name", ownerDto.getName());
        paramIn.put("ownerTypeCd", ownerDto.getOwnerTypeCd());
        paramIn.put("idCard", ownerDto.getIdCard());
        paramIn.put("ownerPhoto", getOwnerPhoto(ownerDto));
        //todo 查询业主房屋
        getOwnerRoom(paramIn, ownerDto);
        //todo 查询业主车辆
        getOwnerCars(paramIn, ownerDto);
    }
    /**
     * 查询业主车辆
     *
     * @param paramIn
     * @param ownerDto
     */
    private void getOwnerCars(JSONObject paramIn, OwnerDto ownerDto) {
        /**
         * carMemberId
         * carId
         * carNum
         * paId
         * psId
         * paNum
         * psNum
         * carTypeCd
         * startTime
         * endTime
         * leaseType
         */
        OwnerCarDto ownerCarDto = new OwnerCarDto();
        ownerCarDto.setOwnerId(ownerDto.getOwnerId());
        List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
        if (ListUtil.isNull(ownerCarDtos)) {
            return;
        }
        JSONArray cars = new JSONArray();
        JSONObject car = null;
        for (OwnerCarDto tmpOwnerCarDto : ownerCarDtos) {
            car = new JSONObject();
            car.put("carMemberId", tmpOwnerCarDto.getMemberId());
            car.put("carId", tmpOwnerCarDto.getCarId());
            car.put("carNum", tmpOwnerCarDto.getCarNum());
            car.put("paId", tmpOwnerCarDto.getPaId());
            car.put("psId", tmpOwnerCarDto.getPsId());
            car.put("paNum", tmpOwnerCarDto.getAreaNum());
            car.put("psNum", tmpOwnerCarDto.getNum());
            car.put("carTypeCd", tmpOwnerCarDto.getCarTypeCd());
            car.put("startTime", tmpOwnerCarDto.getStartTime());
            car.put("endTime", tmpOwnerCarDto.getEndTime());
            car.put("leaseType", tmpOwnerCarDto.getLeaseType());
            cars.add(car);
        }
        paramIn.put("cars", cars);
    }
    /**
     * 查询业主房屋
     *
     * @param paramIn
     * @param ownerDto
     */
    private void getOwnerRoom(JSONObject paramIn, OwnerDto ownerDto) {
        OwnerRoomRelDto ownerRoomRelDto = new OwnerRoomRelDto();
        ownerRoomRelDto.setOwnerId(ownerDto.getOwnerId());
        List<OwnerRoomRelDto> ownerRoomRelDtos = ownerRoomRelV1InnerServiceSMOImpl.queryOwnerRoomRels(ownerRoomRelDto);
        if (ListUtil.isNull(ownerRoomRelDtos)) {
            return;
        }
        List<String> roomIds = new ArrayList<>();
        for (OwnerRoomRelDto tmpOwnerRoomRelDto : ownerRoomRelDtos) {
            roomIds.add(tmpOwnerRoomRelDto.getRoomId());
        }
        RoomDto roomDto = new RoomDto();
        roomDto.setRoomIds(roomIds.toArray(new String[roomIds.size()]));
        roomDto.setCommunityId(ownerDto.getCommunityId());
        List<RoomDto> roomDtos = roomV1InnerServiceSMOImpl.queryRooms(roomDto);
        JSONArray rooms = new JSONArray();
        JSONObject room = null;
        for (RoomDto tmpRoomDto : roomDtos) {
            room = new JSONObject();
            room.put("roomId", tmpRoomDto.getRoomId());
            room.put("floorId", tmpRoomDto.getFloorId());
            room.put("unitId", tmpRoomDto.getUnitId());
            room.put("floorNum", tmpRoomDto.getFloorNum());
            room.put("unitNum", tmpRoomDto.getUnitNum());
            room.put("roomNum", tmpRoomDto.getRoomNum());
            rooms.add(room);
        }
        paramIn.put("rooms", rooms);
    }
    private String getOwnerPhoto(OwnerDto ownerDto) {
        FileRelDto fileRelDto = new FileRelDto();
        fileRelDto.setObjId(ownerDto.getMemberId());
        fileRelDto.setRelTypeCd("10000");
        List<FileRelDto> fileRelDtos = fileRelInnerServiceSMOImpl.queryFileRels(fileRelDto);
        if (ListUtil.isNull(fileRelDtos)) {
            return "";
        }
        FileDto fileDto = new FileDto();
        fileDto.setFileId(fileRelDtos.get(0).getFileSaveName());
        fileDto.setFileSaveName(fileRelDtos.get(0).getFileSaveName());
        fileDto.setCommunityId(ownerDto.getCommunityId());
        List<FileDto> fileDtos = fileInnerServiceSMOImpl.queryFiles(fileDto);
        if (ListUtil.isNull(fileDtos)) {
            return "";
        }
        return fileDtos.get(0).getFileName();
    }
service-job/src/main/java/com/java110/job/adapt/hcIotNew/http/SendIotImpl.java
@@ -48,6 +48,7 @@
    @Override
    public ResultVo post(String url, JSONObject paramIn) {
        url = getUrl(url);
        HttpHeaders header = getHeaders(url, paramIn.toJSONString(), HttpMethod.POST);
        HttpEntity<String> httpEntity = new HttpEntity<String>(paramIn.toJSONString(), header);
        ResponseEntity<String> tokenRes = outRestTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class);
@@ -124,7 +125,7 @@
            return DEFAULT_IOT_URL + param;
        }
        return url + url;
        return url + param;
    }
    /**
service-user/src/main/java/com/java110/user/dao/impl/OwnerCarV1ServiceDaoImpl.java
@@ -65,9 +65,9 @@
    public List<Map> getOwnerCarInfo(Map info) throws DAOException {
        logger.debug("查询 getOwnerCarInfo 入参 info : {}", info);
        List<Map> businessOwnerCarInfos = sqlSessionTemplate.selectList("ownerCarV1ServiceDaoImpl.getOwnerCarInfo", info);
        List<Map> infos = sqlSessionTemplate.selectList("ownerCarV1ServiceDaoImpl.getOwnerCarInfo", info);
        return businessOwnerCarInfos;
        return infos;
    }
@@ -96,12 +96,12 @@
    public int queryOwnerCarsCount(Map info) {
        logger.debug("查询 queryOwnerCarsCount 入参 info : {}", info);
        List<Map> businessOwnerCarInfos = sqlSessionTemplate.selectList("ownerCarV1ServiceDaoImpl.queryOwnerCarsCount", info);
        if (businessOwnerCarInfos.size() < 1) {
        List<Map> infos = sqlSessionTemplate.selectList("ownerCarV1ServiceDaoImpl.queryOwnerCarsCount", info);
        if (infos.size() < 1) {
            return 0;
        }
        return Integer.parseInt(businessOwnerCarInfos.get(0).get("count").toString());
        return Integer.parseInt(infos.get(0).get("count").toString());
    }
    @Override
service-user/src/main/java/com/java110/user/smo/impl/OwnerCarInnerServiceSMOImpl.java
@@ -61,9 +61,9 @@
            Map attrParamInfo = new HashMap();
            attrParamInfo.put("carIds", carIds);
            attrParamInfo.put("statusCd", StatusConstant.STATUS_CD_VALID);
            List<OwnerCarAttrDto> ownerCarAttrDtoList = BeanConvertUtil.covertBeanList(ownerCarAttrServiceDaoImpl.getOwnerCarAttrInfo(attrParamInfo), OwnerCarAttrDto.class);
            List<OwnerCarAttrDto> ownerCarAttrDtos = BeanConvertUtil.covertBeanList(ownerCarAttrServiceDaoImpl.getOwnerCarAttrInfo(attrParamInfo), OwnerCarAttrDto.class);
            for (OwnerCarDto ownerCarDto1 : ownerCars) {
                refreshOwnerCars(ownerCarDto1, ownerCarAttrDtoList);
                refreshOwnerCars(ownerCarDto1, ownerCarAttrDtos);
            }
        }
        return ownerCars;