Commit e187a9d4 authored by 刘凡's avatar 刘凡

优化:设备列表详细地址的展示

parent 172b2168
...@@ -124,4 +124,7 @@ public class JgChangeRegistrationTransferDto extends BaseDto { ...@@ -124,4 +124,7 @@ public class JgChangeRegistrationTransferDto extends BaseDto {
@ApiModelProperty (value = "下一节点可执行人") @ApiModelProperty (value = "下一节点可执行人")
private String nextExecuteUserIds; private String nextExecuteUserIds;
@ApiModelProperty(value = "设备移装完整详细地址")
private String fullAddress;
} }
...@@ -239,4 +239,11 @@ public class JgChangeRegistrationTransfer extends BaseEntity { ...@@ -239,4 +239,11 @@ public class JgChangeRegistrationTransfer extends BaseEntity {
@TableField(value = "next_execute_user_ids") @TableField(value = "next_execute_user_ids")
private String nextExecuteUserIds; private String nextExecuteUserIds;
/**
* 设备移装完整详细地址
*/
@TableField(value = "full_address")
private String fullAddress;
} }
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
crt.use_registration_code as useRegistrationCode, crt.use_registration_code as useRegistrationCode,
crt.next_execute_user_ids as nextExecuteUserIds, crt.next_execute_user_ids as nextExecuteUserIds,
crt.create_user_id as createUserId, crt.create_user_id as createUserId,
crt.full_address as address,
use.USE_UNIT_NAME as useUnitName, use.USE_UNIT_NAME as useUnitName,
(SELECT name from tz_equipment_category where code = jri.EQU_CATEGORY) as equCategory, (SELECT name from tz_equipment_category where code = jri.EQU_CATEGORY) as equCategory,
jri.PRODUCT_NAME as productName, jri.PRODUCT_NAME as productName,
......
...@@ -3,6 +3,8 @@ package com.yeejoin.amos.boot.module.jg.biz.service; ...@@ -3,6 +3,8 @@ package com.yeejoin.amos.boot.module.jg.biz.service;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo; import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo;
import java.util.List;
/** /**
* 使用信息表接口类 * 使用信息表接口类
* *
...@@ -14,4 +16,6 @@ public interface IIdxBizJgUseInfoService { ...@@ -14,4 +16,6 @@ public interface IIdxBizJgUseInfoService {
boolean saveOrUpdateData(IdxBizJgUseInfo useInfo); boolean saveOrUpdateData(IdxBizJgUseInfo useInfo);
IdxBizJgUseInfo getOneData(String record); IdxBizJgUseInfo getOneData(String record);
List<IdxBizJgUseInfo> getUseInfoListByEquIds(List<String> equIds);
} }
...@@ -1072,19 +1072,39 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste ...@@ -1072,19 +1072,39 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
String status = ConstructionEnum.getName.get(integer); String status = ConstructionEnum.getName.get(integer);
dto2.put(CONSTRUCTIONTYPE, status); dto2.put(CONSTRUCTIONTYPE, status);
} }
//查询设备是否正在使用
//设备的使用标识是,安装告知和使用登记中有使用记录。
String equId = (String) dto2.get("SEQUENCE_NBR");
dto2.put("record",equId);
List<JgInstallationNoticeEq> installationNoticeEqList = jgInstallationNoticeEqServiceImpl.getListByEquId(equId);
List<JgUseRegistrationEq> useRegistrationEqList = jgUseRegistrationEqServiceImpl.getListByEquId(equId);
if(!ValidationUtil.isEmpty(installationNoticeEqList) || !ValidationUtil.isEmpty(useRegistrationEqList)){
dto2.put("IS_USE", true);
}else {
dto2.put("IS_USE", false);
}
list.add(dto2); list.add(dto2);
} }
// 获取所有设备的Id
List<String> equIds = null;
if(!ValidationUtil.isEmpty(list)){
equIds = list.stream().map(item -> item.get("SEQUENCE_NBR").toString()).collect(Collectors.toList());
}
//查询设备是否正在使用
//设备的使用标识是,安装告知和使用登记中有使用记录。
List<JgInstallationNoticeEq> installationNoticeEqList = jgInstallationNoticeEqServiceImpl.getListByEquIds(equIds);
List<JgUseRegistrationEq> useRegistrationEqList = jgUseRegistrationEqServiceImpl.getListByEquIds(equIds);
Map<String, Boolean> equIsUseMap = new HashMap<>();
if(!ValidationUtil.isEmpty(installationNoticeEqList) ){
equIsUseMap.putAll(installationNoticeEqList.stream().collect(Collectors.toMap(JgInstallationNoticeEq::getEquId, obj -> true)));
}
if(!ValidationUtil.isEmpty(useRegistrationEqList)){
equIsUseMap.putAll(useRegistrationEqList.stream().collect(Collectors.toMap(JgUseRegistrationEq::getEquId, obj -> true)));
}
// 查询设备地址
List<IdxBizJgUseInfo> useInfoListByEquIds = idxBizJgUseInfoService.getUseInfoListByEquIds(equIds);
Map<String, String> equAddressMap = new HashMap<>();
if(!ValidationUtil.isEmpty(useInfoListByEquIds)){
equAddressMap = useInfoListByEquIds.stream().collect(Collectors.toMap(IdxBizJgUseInfo::getRecord,
useInfo -> useInfo.getProvinceName() + "/" + useInfo.getCityName() + "/" + useInfo.getCountyName() + "/" + useInfo.getStreetName() + "/" + useInfo.getAddress()));
}
// 更新设备使用情况和设备地址
for(JSONObject item : list){
Boolean isUse = equIsUseMap.get(item.getString("SEQUENCE_NBR"));
String fullAddress = equAddressMap.get(item.getString("SEQUENCE_NBR"));
item.put("IS_USE", isUse ? isUse : false);
item.put("ADDRESS", !ValidationUtil.isEmpty(fullAddress) ? fullAddress : "");
}
totle = response.getInternalResponse().hits().getTotalHits().value; totle = response.getInternalResponse().hits().getTotalHits().value;
result.setRecords(list); result.setRecords(list);
result.setTotal(totle); result.setTotal(totle);
......
...@@ -3,12 +3,13 @@ package com.yeejoin.amos.boot.module.jg.biz.service.impl; ...@@ -3,12 +3,13 @@ package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.module.jg.biz.service.IIdxBizJgUseInfoService; import com.yeejoin.amos.boot.module.jg.biz.service.IIdxBizJgUseInfoService;
import com.yeejoin.amos.boot.module.ymt.api.dto.IdxBizJgUseInfoDto; import com.yeejoin.amos.boot.module.ymt.api.dto.IdxBizJgUseInfoDto;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgRegisterInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo; import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgUseInfoMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgUseInfoMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.List;
/** /**
* 使用信息表服务实现类 * 使用信息表服务实现类
* *
...@@ -26,4 +27,11 @@ public class IdxBizJgUseInfoServiceImpl extends BaseService<IdxBizJgUseInfoDto,I ...@@ -26,4 +27,11 @@ public class IdxBizJgUseInfoServiceImpl extends BaseService<IdxBizJgUseInfoDto,I
public IdxBizJgUseInfo getOneData(String record) { public IdxBizJgUseInfo getOneData(String record) {
return this.getOne(new QueryWrapper<IdxBizJgUseInfo>().eq("RECORD", record)); return this.getOne(new QueryWrapper<IdxBizJgUseInfo>().eq("RECORD", record));
} }
@Override
public List<IdxBizJgUseInfo> getUseInfoListByEquIds(List<String> equIds) {
QueryWrapper<IdxBizJgUseInfo> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().in(IdxBizJgUseInfo::getRecord, equIds);
return list(queryWrapper);
}
} }
\ No newline at end of file
...@@ -228,6 +228,43 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -228,6 +228,43 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
oldTransfer.setAuditStatus(WorkFlowStatusEnum.TRANSFER_SUBMIT.getPass()); oldTransfer.setAuditStatus(WorkFlowStatusEnum.TRANSFER_SUBMIT.getPass());
oldTransfer.setStatus(WorkFlowStatusEnum.TRANSFER_SUBMIT.getPass()); oldTransfer.setStatus(WorkFlowStatusEnum.TRANSFER_SUBMIT.getPass());
String fullAddress = "";
String province = (String) tableData.get("province");
String city = (String) tableData.get("city");
String county = (String) tableData.get("county");
String street = (String) tableData.get("street");
String address = (String) tableData.get("address");
// 分割省市区街道字段
if (!ObjectUtils.isEmpty(province)) {
String[] provinceList = province.split("_");
if (provinceList.length > 1) {
fullAddress+=provinceList[1]+"/";
}
}
if (!ObjectUtils.isEmpty(city)) {
String[] cityList = city.split("_");
if (cityList.length > 1) {
fullAddress+=cityList[1]+"/";
}
}
if (!ObjectUtils.isEmpty(county)) {
String[] countyList = county.split("_");
if (countyList.length > 1) {
fullAddress+=countyList[1]+"/";
}
}
if (!ObjectUtils.isEmpty(street)) {
String[] streetList = street.split("_");
if (streetList.length > 1) {
fullAddress+=streetList[1]+"/";
}
}
if (!ObjectUtils.isEmpty(address)) {
fullAddress+=address;
}
//设备移装详细地址
oldTransfer.setFullAddress(fullAddress);
//es种查询设备信息 //es种查询设备信息
SearchRequest request = new SearchRequest(); SearchRequest request = new SearchRequest();
request.indices("idx_biz_view_jg_all"); request.indices("idx_biz_view_jg_all");
...@@ -581,53 +618,6 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -581,53 +618,6 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
*/ */
public Page<Map<String, Object>> queryListForPage(Page<Map<String, Object>> page, JgChangeRegistrationTransferDto params, String type) { public Page<Map<String, Object>> queryListForPage(Page<Map<String, Object>> page, JgChangeRegistrationTransferDto params, String type) {
Page<Map<String, Object>> listPage = this.baseMapper.getListPage(page, params, params.getRoleIds(), type); Page<Map<String, Object>> listPage = this.baseMapper.getListPage(page, params, params.getRoleIds(), type);
listPage.getRecords().stream().forEach(item -> {
// 流程未走完时,移装地址需从 历史表中获取
if (item.containsKey("status") && !FlowStatusEnum.TO_BE_FINISHED.getName().equals(item.get("status").toString())) {
String fullAddress = "";
if (item.containsKey("equipId") && item.containsKey("applyNo")) {
JgRegistrationHistory history = jgRegistrationHistoryService.getDteailByRecord(item.get("equipId").toString(), item.get("applyNo").toString());
if (!ValidationUtil.isEmpty(history)) {
JSONObject newPosition = JSON.parseObject(history.getChangeData());
String province = newPosition.getString("province");
String city = newPosition.getString("city");
String county = newPosition.getString("county");
String street = newPosition.getString("street");
String address = newPosition.getString("address");
// 分割省市区街道字段
if (!ObjectUtils.isEmpty(province)) {
String[] provinceList = province.split("_");
if (provinceList.length > 1) {
fullAddress += provinceList[1];
}
}
if (!ObjectUtils.isEmpty(city)) {
String[] cityList = city.split("_");
if (cityList.length > 1) {
fullAddress += cityList[1];
}
}
if (!ObjectUtils.isEmpty(county)) {
String[] countyList = county.split("_");
if (countyList.length > 1) {
fullAddress += countyList[1];
}
}
if (!ObjectUtils.isEmpty(street)) {
String[] streetList = street.split("_");
if (streetList.length > 1) {
fullAddress += streetList[1];
}
}
if (!ObjectUtils.isEmpty(address)) {
fullAddress += address;
}
}
}
item.put("allAddress", fullAddress);
}
});
return listPage; return listPage;
} }
...@@ -755,10 +745,14 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -755,10 +745,14 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
} }
//补充移装变更表 //补充移装变更表
this.updateTransferByBaseInfo(updateData); this.updateTransferByBaseInfo(updateData);
//查询移装记录
JgChangeRegistrationTransfer transfer = this.getBaseMapper().selectById(sequenceNbr);
//查询修改后的新数据
JgRegistrationHistory newData = jgRegistrationHistoryService.getDteailByRecord(transferEq.getEquId(), transfer.getApplyNo());
//替换历史数据表和设备使用表 //替换历史数据表和设备使用表
this.replacementHistoryData(transferEq.getEquId(), sequenceNbr, useRegistrationCode); this.replacementHistoryData(transferEq.getEquId(), transfer.getApplyNo(), newData, useRegistrationCode);
//更新使用注册登记证编号及ES中的信息 //更新使用注册登记证编号及ES中的信息
this.updataRegisterInfoAndEsData(transferEq.getEquId(), useRegistrationCode); this.updataRegisterInfoAndEsData(transferEq.getEquId(), newData, useRegistrationCode);
//修改各类告知列表,置为废弃 //修改各类告知列表,置为废弃
this.updataInvalidStatusByHistory(transferEq.getEquId(), transferEq.getEquipTransferId()); this.updataInvalidStatusByHistory(transferEq.getEquId(), transferEq.getEquipTransferId());
} }
...@@ -768,14 +762,13 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -768,14 +762,13 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
* 修改历史数据表和设备使用表 * 修改历史数据表和设备使用表
* *
* @param record 设备Id * @param record 设备Id
* @param sequenceNbr 当前单据Id * @param applyNo 申请记录编号
* @param newData 设备移装的新数据
* @param useRegistrationCode 使用登记编号 * @param useRegistrationCode 使用登记编号
*/ */
public void replacementHistoryData(String record, String sequenceNbr, String useRegistrationCode) { public void replacementHistoryData(String record, String applyNo, JgRegistrationHistory newData, String useRegistrationCode) {
JgChangeRegistrationTransfer transfer = this.getBaseMapper().selectById(sequenceNbr);
if (!ValidationUtil.isEmpty(transfer)) { if (!ValidationUtil.isEmpty(record) && !ValidationUtil.isEmpty(applyNo)) {
//查询修改后的新数据
JgRegistrationHistory newData = jgRegistrationHistoryService.getDteailByRecord(record, transfer.getApplyNo());
//查询设备旧数据 //查询设备旧数据
IdxBizJgUseInfo useInfo = useInfoService.getOneData(record); IdxBizJgUseInfo useInfo = useInfoService.getOneData(record);
...@@ -860,12 +853,54 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -860,12 +853,54 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
* @param equId 设备id * @param equId 设备id
* @param useRegistrationCode 使用注册登记证编号 * @param useRegistrationCode 使用注册登记证编号
*/ */
public void updataRegisterInfoAndEsData(String equId, String useRegistrationCode) { public void updataRegisterInfoAndEsData(String equId, JgRegistrationHistory newData, String useRegistrationCode) {
//更新使用注册登记证编号 //更新使用注册登记证编号
idxBizJgRegisterInfoMapper.updateUseOrgCodeByEquip(equId, useRegistrationCode); idxBizJgRegisterInfoMapper.updateUseOrgCodeByEquip(equId, useRegistrationCode);
//获取移装新位置,更新ES
String newUsePlace = "";
String newAddress = "";
String newLongitudeLatitude = "";
if (!ValidationUtil.isEmpty(newData)) {
JSONObject newPosition = JSON.parseObject(newData.getChangeData());
String province = newPosition.getString("province");
String city = newPosition.getString("city");
String county = newPosition.getString("county");
String address = newPosition.getString("address");
String longitudeLatitude = newPosition.getString("longitudeLatitude");
// 分割省市区街道字段
if (!ObjectUtils.isEmpty(province)) {
String[] provinceList = province.split("_");
if (provinceList.length > 1) {
newUsePlace += provinceList[1]+"/";
}
}
if (!ObjectUtils.isEmpty(city)) {
String[] cityList = city.split("_");
if (cityList.length > 1) {
newUsePlace += cityList[1]+"/";
}
}
if (!ObjectUtils.isEmpty(county)) {
String[] countyList = county.split("_");
if (countyList.length > 1) {
newUsePlace += countyList[1];
}
}
if (!ObjectUtils.isEmpty(address)) {
newAddress = address;
}
if (!ObjectUtils.isEmpty(longitudeLatitude)) {
newLongitudeLatitude = longitudeLatitude;
}
}
//es中的编号信息 //es中的编号信息
Map<String, Map<String, Object>> resultMap = new HashMap<>(); Map<String, Map<String, Object>> resultMap = new HashMap<>();
Map<String, Object> map1 = new HashMap<>(); Map<String, Object> map1 = new HashMap<>();
map1.put("USE_PLACE", newUsePlace);
map1.put("ADDRESS", newAddress);
map1.put("LONGITUDE_LATITUDE", newLongitudeLatitude);
map1.put("USE_ORG_CODE", useRegistrationCode); map1.put("USE_ORG_CODE", useRegistrationCode);
resultMap.put(equId, map1); resultMap.put(equId, map1);
tzsServiceFeignClient.commonUpdateEsDataByIds(resultMap); tzsServiceFeignClient.commonUpdateEsDataByIds(resultMap);
......
...@@ -32,9 +32,9 @@ public class JgInstallationNoticeEqServiceImpl extends BaseService<JgInstallatio ...@@ -32,9 +32,9 @@ public class JgInstallationNoticeEqServiceImpl extends BaseService<JgInstallatio
return this.queryForList("" , false); return this.queryForList("" , false);
} }
public List<JgInstallationNoticeEq> getListByEquId(String equId) { public List<JgInstallationNoticeEq> getListByEquIds(List<String> equIds) {
QueryWrapper<JgInstallationNoticeEq> queryWrapper = new QueryWrapper<>(); QueryWrapper<JgInstallationNoticeEq> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(JgInstallationNoticeEq::getEquId,equId); queryWrapper.lambda().in(JgInstallationNoticeEq::getEquId, equIds);
queryWrapper.lambda().eq(JgInstallationNoticeEq::getIsDelete,false); queryWrapper.lambda().eq(JgInstallationNoticeEq::getIsDelete,false);
return list(queryWrapper); return list(queryWrapper);
} }
......
...@@ -33,9 +33,9 @@ public class JgUseRegistrationEqServiceImpl extends BaseService<JgUseRegistratio ...@@ -33,9 +33,9 @@ public class JgUseRegistrationEqServiceImpl extends BaseService<JgUseRegistratio
} }
public List<JgUseRegistrationEq> getListByEquId(String equId) { public List<JgUseRegistrationEq> getListByEquIds(List<String> equIds) {
QueryWrapper<JgUseRegistrationEq> queryWrapper = new QueryWrapper<>(); QueryWrapper<JgUseRegistrationEq> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(JgUseRegistrationEq::getEquId,equId); queryWrapper.lambda().in(JgUseRegistrationEq::getEquId, equIds);
queryWrapper.lambda().eq(JgUseRegistrationEq::getIsDelete,false); queryWrapper.lambda().eq(JgUseRegistrationEq::getIsDelete,false);
return list(queryWrapper); return list(queryWrapper);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment