宿州记录仪基础数据定时认为修改
parent
c4316ecf1c
commit
79146e77c4
|
|
@ -38,4 +38,6 @@ public interface TDeviceMapper extends BaseMapperPlus<TDevice, TDeviceVo> {
|
||||||
|
|
||||||
int updateBatch(HashMap<String,Object> map);
|
int updateBatch(HashMap<String,Object> map);
|
||||||
|
|
||||||
|
int insertOrUpdateByCodeAndType(TDevice device);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ public class TDeviceServiceImpl implements ITDeviceService {
|
||||||
|
|
||||||
private final TDeviceMapper baseMapper;
|
private final TDeviceMapper baseMapper;
|
||||||
|
|
||||||
|
|
||||||
@DubboReference
|
@DubboReference
|
||||||
private RemoteDataScopeService remoteDataScopeService;
|
private RemoteDataScopeService remoteDataScopeService;
|
||||||
|
|
||||||
|
|
@ -232,18 +233,18 @@ public class TDeviceServiceImpl implements ITDeviceService {
|
||||||
public Boolean batchSaveOrUpdate(List<TDevice> list) {
|
public Boolean batchSaveOrUpdate(List<TDevice> list) {
|
||||||
boolean flag = true;
|
boolean flag = true;
|
||||||
// 先根据 field1 和 field2 查询出已存在的记录
|
// 先根据 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_code", list.stream().map(TDevice::getDeviceCode).collect(Collectors.toList()))
|
||||||
.in("device_type", list.stream().map(TDevice::getDeviceType).collect(Collectors.toList())));
|
.in("device_type", list.stream().map(TDevice::getDeviceType).collect(Collectors.toList())));
|
||||||
|
*/
|
||||||
// 找到需要更新的记录
|
// 找到需要更新的记录
|
||||||
List<TDevice> toUpdate = new ArrayList<>();
|
List<TDevice> toUpdate = new ArrayList<>();
|
||||||
// 找到需要插入的记录
|
// 找到需要插入的记录
|
||||||
List<TDevice> toInsert = new ArrayList<>();
|
List<TDevice> toInsert = new ArrayList<>();
|
||||||
|
|
||||||
for (TDevice entity : list) {
|
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())) {
|
if (entity.getDeviceCode().equals(existingEntity.getDeviceCode()) && entity.getDeviceType().equals(existingEntity.getDeviceType())) {
|
||||||
entity.setId(existingEntity.getId()); // 设置 ID 以便更新
|
entity.setId(existingEntity.getId()); // 设置 ID 以便更新
|
||||||
toUpdate.add(entity);
|
toUpdate.add(entity);
|
||||||
|
|
@ -253,18 +254,18 @@ public class TDeviceServiceImpl implements ITDeviceService {
|
||||||
}
|
}
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
toInsert.add(entity);
|
toInsert.add(entity);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// 批量更新
|
// 批量更新
|
||||||
if (!toUpdate.isEmpty()) {
|
/*if (!toUpdate.isEmpty()) {
|
||||||
flag = baseMapper.updateBatchById(toUpdate);
|
flag = baseMapper.updateBatchById(toUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 批量插入
|
// 批量插入
|
||||||
if (!toInsert.isEmpty()) {
|
if (!toInsert.isEmpty()) {
|
||||||
flag = baseMapper.insertBatch(toInsert); // insertBatchSomeColumn 是 MyBatis-Plus 提供的批量插入方法
|
flag = baseMapper.insertBatch(toInsert); // insertBatchSomeColumn 是 MyBatis-Plus 提供的批量插入方法
|
||||||
}
|
}*/
|
||||||
return flag;
|
return flag;
|
||||||
// return baseMapper.insertOrUpdateBatch(List);
|
// return baseMapper.insertOrUpdateBatch(List);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,4 +42,15 @@
|
||||||
</foreach>
|
</foreach>
|
||||||
</update>
|
</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>
|
</mapper>
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import java.sql.Timestamp;
|
||||||
* @date 2022-03-17 16:33
|
* @date 2022-03-17 16:33
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@TableName("zkxc_rs")
|
@TableName("sz_video")
|
||||||
public class OriginDevice {
|
public class OriginDevice {
|
||||||
@TableId(value = "ID",type = IdType.AUTO)
|
@TableId(value = "ID",type = IdType.AUTO)
|
||||||
private int ID;
|
private int ID;
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,9 @@ public class DeviceSchedule {
|
||||||
Timestamp updateTime = originDevice.getUpdateTime();
|
Timestamp updateTime = originDevice.getUpdateTime();
|
||||||
// DateTime dateTime = DateUtil.offsetHour(updateTime, 13);
|
// DateTime dateTime = DateUtil.offsetHour(updateTime, 13);
|
||||||
newDevice.setUpdateTime(DateUtil.formatDateTime(updateTime) );
|
newDevice.setUpdateTime(DateUtil.formatDateTime(updateTime) );
|
||||||
setZzjgdm(newDevice,originDevice);
|
newDevice.setZzjgdm("341300000000");
|
||||||
|
newDevice.setZzjgmc("宿州市公安局");
|
||||||
|
// setZzjgdm(newDevice,originDevice);
|
||||||
|
|
||||||
}
|
}
|
||||||
if(StringUtils.isBlank(newDevice.getZzjgdm())){
|
if(StringUtils.isBlank(newDevice.getZzjgdm())){
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue