|
@@ -9,6 +9,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
|
|
|
import com.persagy.common.service.impl.SuperServiceImpl;
|
|
|
import com.persagy.common.utils.DateUtil;
|
|
@@ -48,35 +49,53 @@ public class HydomcAssetspecServiceImpl extends SuperServiceImpl<HydomcAssetspec
|
|
|
@Transactional
|
|
|
public boolean saveHydomcAssetspec(WdfacilityRelPersagy wdfacilityRelPersagy, RwdObjectWd rwdObjectWd, JSONObject infos, String wdProjectid, String classstructureid, String sbybm) {
|
|
|
Date updateTime = rwdObjectWd.getUpdateTime() == null ? DateUtil.date().toJdkDate() : rwdObjectWd.getUpdateTime();
|
|
|
-
|
|
|
+ String codeValue = StringTool.object2String(infos.get(wdfacilityRelPersagy.getCode()));
|
|
|
+
|
|
|
Integer result = null;
|
|
|
// 根据万达设备信息表的SITEID、SBYBM、ASSETATTRID查询数据是否存在
|
|
|
HydomcAssetspec hydomcAssetspec = this.getHydomcAssetspec(sbybm, wdProjectid, wdfacilityRelPersagy.getAssetattrid());
|
|
|
if (hydomcAssetspec == null) {
|
|
|
- hydomcAssetspec = this.buildHydomcAssetspec(infos, wdfacilityRelPersagy, null, wdProjectid, classstructureid, updateTime);
|
|
|
- result = this.baseMapper.insert(hydomcAssetspec);
|
|
|
+ if (StringUtil.isNotBlank(codeValue)) {
|
|
|
+ // 查询不到时,且code 有值,走插入逻辑
|
|
|
+ hydomcAssetspec = this.buildHydomcAssetspec(infos, wdfacilityRelPersagy, null, wdProjectid, classstructureid, updateTime);
|
|
|
+ hydomcAssetspec.setDatastatus(SwitchConstant.IS_UPDATE); // 数据状态 update/delete
|
|
|
+ result = this.baseMapper.insert(hydomcAssetspec);
|
|
|
+ }
|
|
|
return SqlHelper.retBool(result);
|
|
|
}
|
|
|
|
|
|
// key为wdfacility_rel_persagy的code值从debugs取 有值update 无值(空、空字符串)就是delete
|
|
|
if (StringUtils.isBlank(StringTool.object2String(infos.get(wdfacilityRelPersagy.getCode())))) {
|
|
|
hydomcAssetspec.setDatastatus(SwitchConstant.IS_DELETE); // 数据状态 update/delete
|
|
|
- hydomcAssetspec.setChangedate(updateTime); // 数据更新时间 增量字段
|
|
|
+ hydomcAssetspec.setChangedate(updateTime); // 数据更新时间 增量字段
|
|
|
} else {
|
|
|
hydomcAssetspec = this.buildHydomcAssetspec(infos, wdfacilityRelPersagy, hydomcAssetspec.getAssetspecid(), wdProjectid, classstructureid, updateTime);
|
|
|
+ hydomcAssetspec.setDatastatus(SwitchConstant.IS_UPDATE); // 数据状态 update/delete
|
|
|
}
|
|
|
result = this.baseMapper.updateById(hydomcAssetspec);
|
|
|
return SqlHelper.retBool(result);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
+ public boolean deleteHydomcAssetspec(String wdProjectId, String sbybm, Date updateTime) {
|
|
|
+ updateTime = updateTime == null ? DateUtil.date().toJdkDate() : updateTime;
|
|
|
+ LambdaUpdateWrapper<HydomcAssetspec> updateWrapper = new HydomcAssetspec.BuilderUpdateWrapper().sbybmEq(sbybm).siteidEq(wdProjectId).builder();
|
|
|
+ updateWrapper.set(HydomcAssetspec::getDatastatus, SwitchConstant.IS_DELETE); // 数据状态 update/delete 当数据状态为delete时,设备状态需改为报废
|
|
|
+ updateWrapper.set(HydomcAssetspec::getChangedate, updateTime); // 数据更新时间 增量字段
|
|
|
+ Integer result = this.baseMapper.update(null, updateWrapper);
|
|
|
+ return SqlHelper.retBool(result);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public HydomcAssetspec buildHydomcAssetspec(JSONObject infos, WdfacilityRelPersagy wdfacilityRelPersagy, String assetspecid,
|
|
|
String wdProjectid, String classstructureid, Date changedate) {
|
|
|
HydomcAssetspec hydomcAssetspec = HydomcAssetspec.builder().siteid(wdProjectid) // 广场id 关联设备信息 Pj4403070003
|
|
|
// 设备编码 关联设备信息 wD_gongchengxinxihua
|
|
|
.sbybm(StringTool.object2String(infos.get(InfosKeyConstant.EQUIPMENT_CODE)))
|
|
|
// 设备分类id 1507
|
|
|
- .classstructureid(classstructureid)
|
|
|
+ .classstructureid(StringTool.object2String(infos.get(InfosKeyConstant.EQUIPMENT_SORT)))
|
|
|
// 设备分类名称 电梯系统/扶梯/人行步道 (取自中间表wdfacility_rel_persagy)
|
|
|
.classqc(wdfacilityRelPersagy.getClassqc())
|
|
|
// 设备参数id 1106 (取自中间表wdfacility_rel_persagy)
|
|
@@ -99,12 +118,6 @@ public class HydomcAssetspecServiceImpl extends SuperServiceImpl<HydomcAssetspec
|
|
|
// 默认字符串
|
|
|
hydomcAssetspec.setAlnvalue(StringTool.object2String(infos.get(wdfacilityRelPersagy.getCode()))); // 设备参数文本值
|
|
|
}
|
|
|
- // key为wdfacility_rel_persagy的code值从debugs取 有值update 无值(空、空字符串)就是delete
|
|
|
- if (StringUtils.isBlank(StringTool.object2String(infos.get(wdfacilityRelPersagy.getCode())))) {
|
|
|
- hydomcAssetspec.setDatastatus(SwitchConstant.IS_DELETE); // 数据状态 update/delete
|
|
|
- } else {
|
|
|
- hydomcAssetspec.setDatastatus(SwitchConstant.IS_UPDATE); // 数据状态 update/delete
|
|
|
- }
|
|
|
|
|
|
// 主键ID 赋值
|
|
|
if (StringUtil.isNotBlank(assetspecid)) {
|