|
|
@ -28,6 +28,8 @@ import com.elink.esua.epdc.commons.tools.constant.StrConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.exception.ErrorCode; |
|
|
|
import com.elink.esua.epdc.commons.tools.exception.RenException; |
|
|
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
|
|
|
import com.elink.esua.epdc.commons.tools.redis.RedisKeys; |
|
|
|
import com.elink.esua.epdc.commons.tools.redis.RedisUtils; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.*; |
|
|
|
import com.elink.esua.epdc.dto.AllDeptDTO; |
|
|
|
import com.elink.esua.epdc.dto.SysSimpleDictDTO; |
|
|
@ -88,6 +90,9 @@ public class EpidemicPlotBuildingServiceImpl extends CrudServiceImpl<EpidemicPlo |
|
|
|
@Autowired |
|
|
|
public EpidemicPlotGridDao epidemicPlotGridDao; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private RedisUtils redisUtils; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<EpidemicPlotBuildingDTO> page(Map<String, Object> params) { |
|
|
|
IPage<EpidemicPlotBuildingDTO> page = getPage(params); |
|
|
@ -105,12 +110,14 @@ public class EpidemicPlotBuildingServiceImpl extends CrudServiceImpl<EpidemicPlo |
|
|
|
String id = (String) params.get(FieldConstant.ID_HUMP); |
|
|
|
String name = (String) params.get("buildingName"); |
|
|
|
String type = (String) params.get("buildingType"); |
|
|
|
Long plotId = (Long) params.get("plotId"); |
|
|
|
String buildingMaCode = (String) params.get("buildingMaCode"); |
|
|
|
|
|
|
|
QueryWrapper<EpidemicPlotBuildingEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(name), "BUILDING_NAME", name); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(type), "BUILDING_TYPE", type); |
|
|
|
wrapper.eq(plotId != null, "PLOT_ID", plotId); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(buildingMaCode), "BUILDING_MA_CODE", buildingMaCode); |
|
|
|
|
|
|
|
return wrapper; |
|
|
@ -139,8 +146,11 @@ public class EpidemicPlotBuildingServiceImpl extends CrudServiceImpl<EpidemicPlo |
|
|
|
entity.setBuildingLongitudeDsf(BigDecimal.valueOf(coordinates[1])); |
|
|
|
entity.setBuildingLatitudeDsf(BigDecimal.valueOf(coordinates[0])); |
|
|
|
} |
|
|
|
int code = getMaxCode(); |
|
|
|
entity.setBuildingMaCode(code); |
|
|
|
if (dto.getPlotId() != null) { |
|
|
|
int code = getMaxCode(dto.getPlotId()); |
|
|
|
entity.setBuildingMaCode(code); |
|
|
|
} |
|
|
|
|
|
|
|
insert(entity); |
|
|
|
} |
|
|
|
|
|
|
@ -340,8 +350,10 @@ public class EpidemicPlotBuildingServiceImpl extends CrudServiceImpl<EpidemicPlo |
|
|
|
//保存楼栋唯一编码
|
|
|
|
// entity.setBuildingCode(allDeptInfo.getGridId()+getNewMaxIndex(newMaxIndex));
|
|
|
|
// newMaxIndex++;
|
|
|
|
int code = getMaxCode(); |
|
|
|
entity.setBuildingMaCode(code); |
|
|
|
if (record.getPlotId() != null) { |
|
|
|
int code = getMaxCode(record.getPlotId()); |
|
|
|
entity.setBuildingMaCode(code); |
|
|
|
} |
|
|
|
baseDao.insert(entity); |
|
|
|
} else {//更新
|
|
|
|
// isExist = ConvertUtils.sourceToTarget(record, EpidemicPlotBuildingEntity.class);
|
|
|
@ -414,8 +426,8 @@ public class EpidemicPlotBuildingServiceImpl extends CrudServiceImpl<EpidemicPlo |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public int getMaxCode() { |
|
|
|
Integer maxCode = baseDao.getMaxCode(); |
|
|
|
public int getMaxCode(Long plotId) { |
|
|
|
Integer maxCode = baseDao.getMaxCode(plotId); |
|
|
|
if (maxCode == null) { |
|
|
|
maxCode = 0; |
|
|
|
} |
|
|
@ -428,13 +440,32 @@ public class EpidemicPlotBuildingServiceImpl extends CrudServiceImpl<EpidemicPlo |
|
|
|
params.put("buildingMaCode", "0"); |
|
|
|
List<EpidemicPlotBuildingEntity> list = baseDao.selectList(getWrapper(params)); |
|
|
|
if (!list.isEmpty()) { |
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
list.get(i).setBuildingMaCode(i + 1); |
|
|
|
for (EpidemicPlotBuildingEntity entity : list) { |
|
|
|
// 没有绑定楼栋的没有这个码
|
|
|
|
if (entity.getPlotId() != null) { |
|
|
|
updateBuildingMaCode(entity); |
|
|
|
} |
|
|
|
} |
|
|
|
updateBatchById(list); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void updateBuildingMaCode(EpidemicPlotBuildingEntity entity) { |
|
|
|
String key = RedisKeys.getMaBuildingCodeKey(entity.getPlotId().toString()); |
|
|
|
Object obj = redisUtils.get(key); |
|
|
|
if (null != obj) { |
|
|
|
int maCodeCache = (int) obj; |
|
|
|
maCodeCache = maCodeCache + 1; |
|
|
|
entity.setBuildingMaCode(maCodeCache); |
|
|
|
redisUtils.set(key, maCodeCache, RedisUtils.HOUR_ONE_EXPIRE); |
|
|
|
return; |
|
|
|
} |
|
|
|
int maCode = getMaxCode(entity.getPlotId()); |
|
|
|
maCode = maCode + 1; |
|
|
|
entity.setBuildingMaCode(maCode); |
|
|
|
redisUtils.set(key, maCode, RedisUtils.HOUR_ONE_EXPIRE); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @return void |
|
|
|
* @describe: 创建数据库里不存在的小区 |
|
|
|