提交 c35c8e1c authored 作者: zhoushaopan's avatar zhoushaopan

feat(装备申请模块): 上传批复单,统一进行校验

上传批复单,统一进行校验
上级 f690c5c3
...@@ -2,6 +2,7 @@ package com.tykj.dev.device.apply.service; ...@@ -2,6 +2,7 @@ package com.tykj.dev.device.apply.service;
import com.tykj.dev.device.apply.subject.domin.DeviceApplyBill; import com.tykj.dev.device.apply.subject.domin.DeviceApplyBill;
import com.tykj.dev.device.apply.subject.vo.ApplyTaskDeviceCheckVo;
import com.tykj.dev.device.library.subject.vo.ScriptSaveVo; import com.tykj.dev.device.library.subject.vo.ScriptSaveVo;
import java.util.List; import java.util.List;
...@@ -28,4 +29,6 @@ public interface DeviceApplyBillService { ...@@ -28,4 +29,6 @@ public interface DeviceApplyBillService {
*/ */
void updateCompleteNum(Integer applyType , List<ScriptSaveVo> scriptSaveVos); void updateCompleteNum(Integer applyType , List<ScriptSaveVo> scriptSaveVos);
List<StringBuffer> checkNumAndSeqNumber(List<ApplyTaskDeviceCheckVo> applyTaskDeviceCheckVos);
} }
...@@ -7,8 +7,11 @@ import com.tykj.dev.config.TaskBeanConfig; ...@@ -7,8 +7,11 @@ import com.tykj.dev.config.TaskBeanConfig;
import com.tykj.dev.device.apply.repository.DeviceApplyBillDao; import com.tykj.dev.device.apply.repository.DeviceApplyBillDao;
import com.tykj.dev.device.apply.service.DeviceApplyBillService; import com.tykj.dev.device.apply.service.DeviceApplyBillService;
import com.tykj.dev.device.apply.subject.domin.DeviceApplyBill; import com.tykj.dev.device.apply.subject.domin.DeviceApplyBill;
import com.tykj.dev.device.apply.subject.vo.ApplyTaskDeviceCheckVo;
import com.tykj.dev.device.apply.subject.vo.ReplyVo; import com.tykj.dev.device.apply.subject.vo.ReplyVo;
import com.tykj.dev.device.library.service.DeviceLibraryCacheService;
import com.tykj.dev.device.library.service.DeviceLibraryService; import com.tykj.dev.device.library.service.DeviceLibraryService;
import com.tykj.dev.device.library.service.impl.CacheLibraryServiceImpl;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary; import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.library.subject.vo.ScriptSaveVo; import com.tykj.dev.device.library.subject.vo.ScriptSaveVo;
import com.tykj.dev.device.task.repository.TaskDao; import com.tykj.dev.device.task.repository.TaskDao;
...@@ -63,6 +66,9 @@ public class DeviceApplyBillServiceImpl implements DeviceApplyBillService { ...@@ -63,6 +66,9 @@ public class DeviceApplyBillServiceImpl implements DeviceApplyBillService {
@Autowired @Autowired
private UserUtils userUtils; private UserUtils userUtils;
@Autowired
private DeviceLibraryCacheService deviceLibraryCacheService;
@Override @Override
public DeviceApplyBill addEntity(DeviceApplyBill deviceApplyBillEntity) { public DeviceApplyBill addEntity(DeviceApplyBill deviceApplyBillEntity) {
DeviceApplyBill deviceApplyBill = deviceApplyBillDao.save(deviceApplyBillEntity); DeviceApplyBill deviceApplyBill = deviceApplyBillDao.save(deviceApplyBillEntity);
...@@ -202,4 +208,52 @@ public class DeviceApplyBillServiceImpl implements DeviceApplyBillService { ...@@ -202,4 +208,52 @@ public class DeviceApplyBillServiceImpl implements DeviceApplyBillService {
} }
} }
} }
@Override
public List<StringBuffer> checkNumAndSeqNumber(List<ApplyTaskDeviceCheckVo> applyTaskDeviceCheckVos) {
List<StringBuffer> stringBufferList = new ArrayList<>();
applyTaskDeviceCheckVos.forEach(applyTaskDeviceCheckVo -> {
StringBuffer stringBuffer = new StringBuffer();
//先判断数量是否一致
//入库数量
Integer storageCount = applyTaskDeviceCheckVo.getStorageCount();
//批复数量
Integer replyNum = applyTaskDeviceCheckVo.getReplyNum();
//试用装备数量
Integer tryOutNum = applyTaskDeviceCheckVo.getTryOutNum();
stringBuffer.append("序号为").append(applyTaskDeviceCheckVo.getI()+1).append(":");
if (replyNum<tryOutNum){
//提示 批复数量不能小于试用数量
stringBuffer.append("批复数量不能小于试用数量").append(",");
}
if (replyNum>storageCount){
//提示 批复数量不能大于申请数量
stringBuffer.append("批复数量不能大于申请数量").append(",");
}
//获取序列号区间
String seqNumInter = applyTaskDeviceCheckVo.getSeqNumInter();
if (seqNumInter != null){
//然后进行拆分
//输入序列号的区间
List<String> inputSeqs = DeviceSeqUtil.selectDeviceSeqs(seqNumInter);
if (!replyNum.equals(inputSeqs.size())){
//提示 批复数量跟输入区间不一致
stringBuffer.append("批复数量与序列号区间不一致").append(",");
}
//查询所有的序列号 检验是否重复
List<String> allSeqList = deviceLibraryCacheService.getAllDeviceLibraryList().stream()
.map(DeviceLibrary::getSeqNumber).collect(Collectors.toList());
allSeqList.retainAll(inputSeqs);
if (allSeqList.size()>0){
//说明有重复的序列号
stringBuffer.append("序列号").append(allSeqList).append("已存在");
}
}
stringBufferList.add(stringBuffer);
});
return stringBufferList;
}
} }
package com.tykj.dev.device.apply.subject.vo;
import com.tykj.dev.device.apply.subject.domin.DeviceApplyBill;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.packing.subject.domin.PackingLibrary;
import com.tykj.dev.device.task.subject.vo.TaskLogUserVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author zsp
*/
@Data
@ApiModel("申请同意的校验vo")
public class ApplyTaskDeviceCheckVo {
@ApiModelProperty(value = "序列号")
private Integer i;
@ApiModelProperty(value = "申请数量")
private Integer storageCount;
@ApiModelProperty(value = "试用数量")
private Integer tryOutNum;
@ApiModelProperty(value = "批复数量")
private Integer replyNum;
@ApiModelProperty(value = "序列号区间")
private String seqNumInter;
}
...@@ -469,9 +469,6 @@ public class PackingController { ...@@ -469,9 +469,6 @@ public class PackingController {
if (inputSeqs.size()!=num){ if (inputSeqs.size()!=num){
return ResponseEntity.ok("序列号区间总数为"+inputSeqs.size()+",与装备数量不匹配"); return ResponseEntity.ok("序列号区间总数为"+inputSeqs.size()+",与装备数量不匹配");
} }
// if (inputSeqs.size()>num){
// return ResponseEntity.ok("序列号区间总数为"+inputSeqs.size()+",与装备数量不匹配");
// }
else { else {
Set<String> seqSet = new HashSet<>(inputSeqs); Set<String> seqSet = new HashSet<>(inputSeqs);
if (seqSet.size()!=inputSeqs.size()){ if (seqSet.size()!=inputSeqs.size()){
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论