宿州记录仪基础数据定时认为修改

ds-bozhou
luyya 2025-06-30 09:18:03 +08:00
parent c4316ecf1c
commit 79146e77c4
5 changed files with 26 additions and 10 deletions

View File

@ -38,4 +38,6 @@ public interface TDeviceMapper extends BaseMapperPlus<TDevice, TDeviceVo> {
int updateBatch(HashMap<String,Object> map);
int insertOrUpdateByCodeAndType(TDevice device);
}

View File

@ -42,6 +42,7 @@ public class TDeviceServiceImpl implements ITDeviceService {
private final TDeviceMapper baseMapper;
@DubboReference
private RemoteDataScopeService remoteDataScopeService;
@ -232,18 +233,18 @@ public class TDeviceServiceImpl implements ITDeviceService {
public Boolean batchSaveOrUpdate(List<TDevice> list) {
boolean flag = true;
// 先根据 field1 和 field2 查询出已存在的记录
List<TDevice> existingEntities = baseMapper.selectList(new QueryWrapper<TDevice>()
/*List<TDevice> existingEntities = baseMapper.selectList(new QueryWrapper<TDevice>()
.in("device_code", list.stream().map(TDevice::getDeviceCode).collect(Collectors.toList()))
.in("device_type", list.stream().map(TDevice::getDeviceType).collect(Collectors.toList())));
*/
// 找到需要更新的记录
List<TDevice> toUpdate = new ArrayList<>();
// 找到需要插入的记录
List<TDevice> toInsert = new ArrayList<>();
for (TDevice entity : list) {
boolean exists = false;
for (TDevice existingEntity : existingEntities) {
baseMapper.insertOrUpdateByCodeAndType(entity);
/*for (TDevice existingEntity : existingEntities) {
if (entity.getDeviceCode().equals(existingEntity.getDeviceCode()) && entity.getDeviceType().equals(existingEntity.getDeviceType())) {
entity.setId(existingEntity.getId()); // 设置 ID 以便更新
toUpdate.add(entity);
@ -253,18 +254,18 @@ public class TDeviceServiceImpl implements ITDeviceService {
}
if (!exists) {
toInsert.add(entity);
}
}*/
}
// 批量更新
if (!toUpdate.isEmpty()) {
/*if (!toUpdate.isEmpty()) {
flag = baseMapper.updateBatchById(toUpdate);
}
// 批量插入
if (!toInsert.isEmpty()) {
flag = baseMapper.insertBatch(toInsert); // insertBatchSomeColumn 是 MyBatis-Plus 提供的批量插入方法
}
}*/
return flag;
// return baseMapper.insertOrUpdateBatch(List);
}

View File

@ -42,4 +42,15 @@
</foreach>
</update>
<insert id="insertOrUpdateByCodeAndType">
insert into t_device (device_code, device_type, zzjgdm, zzjgmc, police_no, police_name, phone_num, car_num, valid,
remark1, remark2, card_num, create_time, update_time)
values (#{deviceCode},#{deviceType},#{zzjgdm},#{zzjgmc},#{policeNo},#{policeName},#{phoneNum},#{carNum},#{valid},
#{remark1},#{remark2},#{cardNum},#{createTime},#{updateTime})
ON DUPLICATE KEY UPDATE
police_no = values(police_no),police_name = values(police_name),phone_num = values(phone_num),
car_num = values(car_num),valid = values(valid),remark1 = values(remark1),remark2 = values(remark2),card_num = values(card_num),
update_time = now()
</insert>
</mapper>

View File

@ -15,7 +15,7 @@ import java.sql.Timestamp;
* @date 2022-03-17 16:33
*/
@Data
@TableName("zkxc_rs")
@TableName("sz_video")
public class OriginDevice {
@TableId(value = "ID",type = IdType.AUTO)
private int ID;

View File

@ -85,7 +85,9 @@ public class DeviceSchedule {
Timestamp updateTime = originDevice.getUpdateTime();
// DateTime dateTime = DateUtil.offsetHour(updateTime, 13);
newDevice.setUpdateTime(DateUtil.formatDateTime(updateTime) );
setZzjgdm(newDevice,originDevice);
newDevice.setZzjgdm("341300000000");
newDevice.setZzjgmc("宿州市公安局");
// setZzjgdm(newDevice,originDevice);
}
if(StringUtils.isBlank(newDevice.getZzjgdm())){