|
|
@ -23,6 +23,7 @@ import lombok.extern.slf4j.Slf4j; |
|
|
import org.redisson.api.RLock; |
|
|
import org.redisson.api.RLock; |
|
|
import org.redisson.api.RedissonClient; |
|
|
import org.redisson.api.RedissonClient; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
@ -327,7 +328,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// 开启一个线程去删除子订单
|
|
|
// 开启一个线程去删除子订单
|
|
|
HandlesOtherFunctionalThreadPool.execute(() -> depositoryRecordMapper.deleteApplicationOutRecordMinById(id)); |
|
|
HandlesOtherFunctionalThreadPool.execute(() -> depositoryRecordMapper.deleteApplicationOutRecordMinByParentId(id)); |
|
|
|
|
|
|
|
|
return integer; |
|
|
return integer; |
|
|
} |
|
|
} |
|
|
@ -335,23 +336,97 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 用于退回出库子单 |
|
|
* 用于退回出库子单 |
|
|
|
|
|
* |
|
|
* @param id 退回的子单id |
|
|
* @param id 退回的子单id |
|
|
* @param userByPort 操作人 |
|
|
* @param userByPort 操作人 |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
public Integer refundedApplicationOutRecordMinById(Long id,UserByPort userByPort){ |
|
|
public Integer refundedApplicationOutRecordMinById(Long id, UserByPort userByPort, String userAgent, String userKey, String token) { |
|
|
// 获取当前要退回的子单信息
|
|
|
// 获取当前要退回的子单信息
|
|
|
ApplicationOutRecordMin recordMin = depositoryRecordMapper.findApplicationOutMinById(id); |
|
|
ApplicationOutRecordMin recordMin = depositoryRecordMapper.findApplicationOutMinById(id); |
|
|
// 获取主单信息
|
|
|
// 获取当前子单的主单
|
|
|
ApplicationOutRecord record = depositoryRecordMapper.findApplicationOutRecordPById(recordMin.getParentId()); |
|
|
Long parentId = recordMin.getParentId(); |
|
|
Integer trueOut = recordMin.getTrueOut(); |
|
|
ApplicationOutRecord record = depositoryRecordMapper.findApplicationOutRecordPById(parentId); |
|
|
if(trueOut > 0){ |
|
|
int trueOut = recordMin.getTrueOut(); |
|
|
|
|
|
if (trueOut > 0) { |
|
|
// 如果已经开始出库,则不允许退回
|
|
|
// 如果已经开始出库,则不允许退回
|
|
|
return -1; |
|
|
return -1; |
|
|
} |
|
|
} |
|
|
log.info(userByPort.getName()+"_"+userByPort.getNumber()+"删除了子单,数据为:"+JSONObject.toJSONString(recordMin)); |
|
|
|
|
|
|
|
|
|
|
|
return depositoryRecordMapper.deleteApplicationOutRecordMinById(id); |
|
|
String minRedisKey = "minRecord:" + id; |
|
|
|
|
|
RedisTemplate<String, String> redisTemplateByDb = redisPool.getRedisTemplateByDb(15); |
|
|
|
|
|
// 获取redis中存储的当前单的出库人
|
|
|
|
|
|
Object manager = redisTemplateByDb.opsForHash().get(minRedisKey, "manager"); |
|
|
|
|
|
if (manager != null) { |
|
|
|
|
|
String manageString = manager.toString(); |
|
|
|
|
|
String[] managerStringSplit = manageString.split(","); |
|
|
|
|
|
for (String s : managerStringSplit) { |
|
|
|
|
|
String managerRedisKey = "user:" + s; |
|
|
|
|
|
Object minRecord = redisTemplateByDb.opsForHash().get(managerRedisKey, "minRecord"); |
|
|
|
|
|
if (minRecord == null) { |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
String mindRecordString = minRecord.toString(); |
|
|
|
|
|
mindRecordString = mindRecordString.replace(minRedisKey + ",", ""); |
|
|
|
|
|
if (mindRecordString.length() == 2) { |
|
|
|
|
|
// []
|
|
|
|
|
|
// 如果当前用户已经没有剩余订单,则删除
|
|
|
|
|
|
redisTemplateByDb.delete(managerRedisKey); |
|
|
|
|
|
} else { |
|
|
|
|
|
redisTemplateByDb.opsForHash().put(managerRedisKey, "minRecord", minRecord); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 获取主单的所有子单
|
|
|
|
|
|
List<ApplicationOutRecordMin> recordMinList = depositoryRecordMapper.findApplicationOutRecordMinByParent(parentId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取删除结果
|
|
|
|
|
|
Integer result = depositoryRecordMapper.deleteApplicationOutRecordMinById(id); |
|
|
|
|
|
String mainRedisKey = "record:" + parentId; |
|
|
|
|
|
if (recordMinList.size() <= 1) { |
|
|
|
|
|
// 如果主单的子单数小于等于1个,则删除主单
|
|
|
|
|
|
Integer integer = depositoryRecordMapper.deleteApplicationOutRecordById(parentId); |
|
|
|
|
|
redisTemplateByDb.delete(mainRedisKey); |
|
|
|
|
|
} else { |
|
|
|
|
|
Object minRecord = redisTemplateByDb.opsForHash().get(mainRedisKey, "minRecord"); |
|
|
|
|
|
if (minRecord != null) { |
|
|
|
|
|
String minRecordList = minRecord.toString(); |
|
|
|
|
|
|
|
|
|
|
|
// 获取所有子订单键值
|
|
|
|
|
|
minRecordList = minRecordList.replace(minRedisKey + ",", ""); |
|
|
|
|
|
if (minRecordList.length() == 2) { |
|
|
|
|
|
// []
|
|
|
|
|
|
// 如果当前主单已经没有剩余订单,则删除
|
|
|
|
|
|
redisTemplateByDb.delete(mainRedisKey); |
|
|
|
|
|
} else { |
|
|
|
|
|
redisTemplateByDb.opsForHash().put(mainRedisKey, "minRecord", minRecordList); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String[] split = minRecordList.replace("[", "").replace("]", "").split(","); |
|
|
|
|
|
|
|
|
|
|
|
int pass = 1; // 设置主订单最终状态
|
|
|
|
|
|
for (String value : split) { |
|
|
|
|
|
// 获取所有子订单状态
|
|
|
|
|
|
String state = (String) redisPool.getRedisTemplateByDb(15).opsForHash().get(value, "state"); |
|
|
|
|
|
if ("1".equals(state)) { |
|
|
|
|
|
// 如果有子订单未完成
|
|
|
|
|
|
pass = 3; // 设置主订单状态为处理中
|
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (pass == 1) { |
|
|
|
|
|
|
|
|
|
|
|
CompleteOutboundOperations(record, userAgent, userKey, token); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
log.info(userByPort.getName() + "_" + userByPort.getNumber() + "删除了子单,数据为:" + JSONObject.toJSONString(recordMin)); |
|
|
|
|
|
HandlesOtherFunctionalThreadPool.execute(() -> qyWxOperationService.sendNotificationToApplicantForRefunded(userByPort, recordMin, record.getApplicantId(), userAgent)); |
|
|
|
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -393,7 +468,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
|
|
|
|
|
}); |
|
|
}); |
|
|
// 开启一个线程用于删除
|
|
|
// 开启一个线程用于删除
|
|
|
HandlesOtherFunctionalThreadPool.execute(() -> depositoryRecordMapper.deleteApplicationOutRecordMinByIds(list)); |
|
|
HandlesOtherFunctionalThreadPool.execute(() -> depositoryRecordMapper.deleteApplicationOutRecordMinByParentIds(list)); |
|
|
|
|
|
|
|
|
return integer; |
|
|
return integer; |
|
|
} |
|
|
} |
|
|
@ -2103,7 +2178,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
List<ApplicationOutRecordMin> applicationOutRecordMinByParent = depositoryRecordMapper.findApplicationOutRecordMinByParent(id); |
|
|
List<ApplicationOutRecordMin> applicationOutRecordMinByParent = depositoryRecordMapper.findApplicationOutRecordMinByParent(id); |
|
|
if (applicationOutRecordMinByParent != null) { |
|
|
if (applicationOutRecordMinByParent != null) { |
|
|
for (ApplicationOutRecordMin outRecordMin : applicationOutRecordMinByParent) { |
|
|
for (ApplicationOutRecordMin outRecordMin : applicationOutRecordMinByParent) { |
|
|
depositoryRecordMapper.deleteApplicationOutRecordMinById(outRecordMin.getId()); |
|
|
depositoryRecordMapper.deleteApplicationOutRecordMinByParentId(outRecordMin.getId()); |
|
|
log.warn(DateUtil.getNowTime() + ": 删除出错的出库子订单:" + JSONObject.toJSONString(record)); |
|
|
log.warn(DateUtil.getNowTime() + ": 删除出错的出库子订单:" + JSONObject.toJSONString(record)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -2319,30 +2394,6 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
String redisOutKey = "wms_notificationOut_" + id; |
|
|
String redisOutKey = "wms_notificationOut_" + id; |
|
|
redisPool.getRedisTemplateByDb(14).delete(redisOutKey); |
|
|
redisPool.getRedisTemplateByDb(14).delete(redisOutKey); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
// 设置子订单新编码
|
|
|
|
|
|
// 获取出库仓库信息
|
|
|
|
|
|
Depository depositoryRecordById = depositoryMapper.findDepositoryById(applicationOutMinById.getDepositoryId()); |
|
|
|
|
|
// 获取主订单单号
|
|
|
|
|
|
StringBuilder code = new StringBuilder(record.getCode()); |
|
|
|
|
|
// 获取申请用户信息
|
|
|
|
|
|
UserByPort applicantUser = userService.findUserByIdForNoPack(record.getApplicantId()); |
|
|
|
|
|
// 获取申请用户行政组织
|
|
|
|
|
|
Administration company = PublicConfig.getCompany(applicantUser.getMaindeparment(), userKey, token); |
|
|
|
|
|
// 获取部门名称简写
|
|
|
|
|
|
String conpanyName = WordUtil.getPinYinHeadChar(company.getName()); |
|
|
|
|
|
// 获取仓库名称简写
|
|
|
|
|
|
String depositoryName = WordUtil.getPinYinHeadChar(depositoryRecordById.getDname()); |
|
|
|
|
|
// 获取部门名称在单号的起始位置
|
|
|
|
|
|
int index = code.indexOf(conpanyName); |
|
|
|
|
|
// 生产新子订单编号
|
|
|
|
|
|
String newCode = code.replace(index, index + conpanyName.length(), depositoryName).toString(); |
|
|
|
|
|
// 设置新编码
|
|
|
|
|
|
applicationOutMinById.setCode(newCode); |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置完成人
|
|
|
// 设置完成人
|
|
|
applicationOutMinById.setCheckId(userByPort.getId()); |
|
|
applicationOutMinById.setCheckId(userByPort.getId()); |
|
|
// 设置新库位
|
|
|
// 设置新库位
|
|
|
@ -2368,11 +2419,27 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (pass == 1) { // 如果最终状态为完成
|
|
|
if (pass == 1) { // 如果最终状态为完成
|
|
|
|
|
|
// 完成出库的相关操作
|
|
|
|
|
|
CompleteOutboundOperations(record, userAgent, userKey, token); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 用于完成出库时修改数据及发送通知 |
|
|
|
|
|
* |
|
|
|
|
|
* @param record 完成的出库单 |
|
|
|
|
|
* @param userAgent userAgent |
|
|
|
|
|
* @param userKey userKey |
|
|
|
|
|
* @param token userToken |
|
|
|
|
|
*/ |
|
|
|
|
|
public void CompleteOutboundOperations(ApplicationOutRecord record, String userAgent, String userKey, String token) { |
|
|
|
|
|
String redisMainRecordKey = "record:" + record.getId(); // 设置redis中主订单键值
|
|
|
redisPool.getRedisTemplateByDb(15).delete(redisMainRecordKey); |
|
|
redisPool.getRedisTemplateByDb(15).delete(redisMainRecordKey); |
|
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
map.put("pass", pass); |
|
|
map.put("pass", 1); |
|
|
map.put("id", record.getId()); |
|
|
map.put("id", record.getId()); |
|
|
map.put("outTime", System.currentTimeMillis()); |
|
|
map.put("outTime", System.currentTimeMillis()); |
|
|
// 修改状态为完成
|
|
|
// 修改状态为完成
|
|
|
@ -2408,8 +2475,6 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
// 删除redis中本订单
|
|
|
// 删除redis中本订单
|
|
|
redisPool.getRedisTemplateByDb(15).delete("record:" + record.getId()); |
|
|
redisPool.getRedisTemplateByDb(15).delete("record:" + record.getId()); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 用于企业微信物料出库审批处理 |
|
|
* 用于企业微信物料出库审批处理 |
|
|
@ -5278,6 +5343,9 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
@Override |
|
|
@Override |
|
|
public ApplicationOutRecordP findApplicationOutRecordPById(Long id) { |
|
|
public ApplicationOutRecordP findApplicationOutRecordPById(Long id) { |
|
|
ApplicationOutRecord record = depositoryRecordMapper.findApplicationOutRecordPById(id); |
|
|
ApplicationOutRecord record = depositoryRecordMapper.findApplicationOutRecordPById(id); |
|
|
|
|
|
if (record == null) { |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
return new ApplicationOutRecordP(record); |
|
|
return new ApplicationOutRecordP(record); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|