|
|
|
@ -272,6 +272,9 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public Integer deleteApplicationOutRecordById(Integer id, UserByPort userByPort) { |
|
|
|
// 获取主单
|
|
|
|
ApplicationOutRecordP recordP = depositoryRecordMapper.findApplicationOutRecordPById(id); |
|
|
|
|
|
|
|
// 删除主单
|
|
|
|
Integer integer = depositoryRecordMapper.deleteApplicationOutRecordById(id); |
|
|
|
// 获取当前主单下的子单
|
|
|
|
@ -282,7 +285,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
// 获取该用户在redis中的订单记录
|
|
|
|
String key = "user:" + userByPort.getId().toString(); |
|
|
|
String key = "user:" + recordP.getApplicantId(); |
|
|
|
// 获取当前用户所有处理单
|
|
|
|
String minRecord = (String) redisTemplate.opsForHash().get(key, "minRecord"); |
|
|
|
for (ApplicationOutRecordMin recordMin : |
|
|
|
@ -295,7 +298,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
if (minRecord.length() == 2) { |
|
|
|
// []
|
|
|
|
// 如果当前用户已经没有剩余订单,则删除
|
|
|
|
redisTemplate.delete("user:" + userByPort.getId()); |
|
|
|
redisTemplate.delete(key); |
|
|
|
} else { |
|
|
|
redisTemplate.opsForHash().put(key, "minRecord", minRecord); |
|
|
|
} |
|
|
|
@ -322,42 +325,41 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public Integer deleteApplicationOutRecordByIds(List<Integer> list, UserByPort userByPort) { |
|
|
|
Integer integer = depositoryRecordMapper.deleteApplicationOutRecordByIds(list); |
|
|
|
// 获取出库单列表
|
|
|
|
List<ApplicationOutRecordP> recordPList = depositoryRecordMapper.findApplicationOutRecordPByIds(list); |
|
|
|
|
|
|
|
Integer integer = depositoryRecordMapper.deleteApplicationOutRecordByIds(list); |
|
|
|
|
|
|
|
List<ApplicationOutRecordMin> applicationOutRecordMinByParent = depositoryRecordMapper.findApplicationOutRecordMinByParents(list); |
|
|
|
// 开启一个线程去删除redis中的数据
|
|
|
|
new Thread(new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
|
|
|
|
|
|
|
|
for (ApplicationOutRecordP recordP : recordPList |
|
|
|
) { |
|
|
|
// 获取该用户在redis中的订单记录
|
|
|
|
String key = "user:" + userByPort.getId().toString(); |
|
|
|
String key = "user:" + recordP.getApplicantId(); |
|
|
|
|
|
|
|
List<ApplicationOutRecordMin> recordMinList = depositoryRecordMapper.findApplicationOutRecordMinByParent(recordP.getId()); |
|
|
|
for (ApplicationOutRecordMin recordMin : recordMinList |
|
|
|
) { |
|
|
|
// 获取当前用户所有订单
|
|
|
|
String minRecord = (String) redisTemplate.opsForHash().get(key, "minRecord"); |
|
|
|
for (ApplicationOutRecordMin recordMin : |
|
|
|
applicationOutRecordMinByParent) { |
|
|
|
|
|
|
|
|
|
|
|
Inventory inventoryById = materialMapper.findInventoryById(recordMin.getMid()); |
|
|
|
inventoryById.setNumberOfTemporary(inventoryById.getNumberOfTemporary() - recordMin.getQuantity()); |
|
|
|
materialMapper.updateInventory(inventoryById); |
|
|
|
|
|
|
|
String redisMinRecordKey = "minRecord:" + recordMin.getId(); |
|
|
|
minRecord = minRecord.replace(redisMinRecordKey + ",", ""); |
|
|
|
if (minRecord.length() == 2) { |
|
|
|
// []
|
|
|
|
// 如果当前用户已经没有剩余订单,则删除
|
|
|
|
redisTemplate.delete("user:" + userByPort.getId()); |
|
|
|
redisTemplate.delete(key); |
|
|
|
} else { |
|
|
|
redisTemplate.opsForHash().put(key, "minRecord", minRecord); |
|
|
|
} |
|
|
|
|
|
|
|
redisTemplate.delete(redisMinRecordKey); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (Integer value : list) { |
|
|
|
String redisMainRecordKey = "record:" + value; // 设置redis中主订单键值
|
|
|
|
String redisMainRecordKey = "record:" + recordP.getId(); // 设置redis中主订单键值
|
|
|
|
redisTemplate.delete(redisMainRecordKey); |
|
|
|
} |
|
|
|
|
|
|
|
|