| | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void saveMapPayloadInBatches(Integer lev, String data, String originData, Date updateTime) { |
| | | if (lev == null || lev <= 0) { |
| | | throw new CoolException("楼层不能为空"); |
| | | } |
| | | Date now = updateTime == null ? new Date() : updateTime; |
| | | BasMap basMap = this.getOne(new QueryWrapper<BasMap>().select("id", "data").eq("lev", lev)); |
| | | boolean existingMap = basMap != null; |
| | | if (basMap == null) { |
| | | basMap = insertLightMap(lev, now); |
| | | } |
| | | |
| | | if (existingMap) { |
| | | updateLastDataOnly(basMap.getId(), basMap.getData()); |
| | | } |
| | | updateDataOnly(basMap.getId(), data, now); |
| | | updateOriginDataOnly(basMap.getId(), originData); |
| | | } |
| | | |
| | | private BasMap insertLightMap(Integer lev, Date now) { |
| | | BasMap insertMap = new BasMap(); |
| | | insertMap.setLev(lev); |
| | | insertMap.setCreateTime(now); |
| | | insertMap.setUpdateTime(now); |
| | | if (!this.save(insertMap)) { |
| | | throw new CoolException("地图基础信息保存失败"); |
| | | } |
| | | return insertMap; |
| | | } |
| | | |
| | | private void updateLastDataOnly(Integer id, String lastData) { |
| | | UpdateWrapper<BasMap> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.eq("id", id) |
| | | .set("last_data", lastData); |
| | | if (!this.update(updateWrapper)) { |
| | | throw new CoolException("地图历史数据保存失败"); |
| | | } |
| | | } |
| | | |
| | | private void updateDataOnly(Integer id, String data, Date updateTime) { |
| | | UpdateWrapper<BasMap> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.eq("id", id) |
| | | .set("data", data) |
| | | .set("update_time", updateTime); |
| | | if (!this.update(updateWrapper)) { |
| | | throw new CoolException("地图运行数据保存失败"); |
| | | } |
| | | } |
| | | |
| | | private void updateOriginDataOnly(Integer id, String originData) { |
| | | UpdateWrapper<BasMap> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.eq("id", id) |
| | | .set("origin_data", originData); |
| | | if (!this.update(updateWrapper)) { |
| | | throw new CoolException("地图编辑数据保存失败"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public int syncLocMastByMap(Integer lev) { |
| | | if (lev == null || lev <= 0) { |
| | | throw new CoolException("请输入有效楼层"); |