提交 3e73fc37 authored 作者: zhoushaopan's avatar zhoushaopan

提交代码

上级 5e1f4e54
...@@ -133,17 +133,14 @@ public class AllotBillController { ...@@ -133,17 +133,14 @@ public class AllotBillController {
List<DeviceLibrary> deviceLibraries = new ArrayList<>(); List<DeviceLibrary> deviceLibraries = new ArrayList<>();
rfidVo.getRfidResultList().forEach(s -> { rfidVo.getRfidResultList().forEach(s -> {
List<DeviceLibrary> deviceLibraries1 = deviceLibraryDao.getAllByRfidCardId(s); List<DeviceLibrary> deviceLibraries1 = deviceLibraryDao.getAllByRfidCardId(s);
if (deviceLibraries1.isEmpty()){ if (deviceLibraries1.isEmpty()) {
throw new ApiException("系统中不存在rfid为"+s+"的装备"); throw new ApiException("系统中不存在rfid为" + s + "的装备");
} } else {
else { if (!deviceLibraries1.get(0).getOwnUnit().equals(unit)) {
if (!deviceLibraries1.get(0).getOwnUnit().equals(unit)){ throw new ApiException("rfid为" + s + "的装备不属于本单位");
throw new ApiException("rfid为"+s+"的装备不属于本单位"); } else if (deviceLibraries1.get(0).getLifeStatus() != 2) {
} throw new ApiException("rfid为" + s + "的装备不在库");
else if (deviceLibraries1.get(0).getLifeStatus()!=2){ } else {
throw new ApiException("rfid为"+s+"的装备不在库");
}
else {
deviceLibraries.add(deviceLibraries1.get(0)); deviceLibraries.add(deviceLibraries1.get(0));
} }
} }
...@@ -156,7 +153,7 @@ public class AllotBillController { ...@@ -156,7 +153,7 @@ public class AllotBillController {
// @Transactional(rollbackFor = Exception.class) // @Transactional(rollbackFor = Exception.class)
public ResponseEntity addAllotBill(@RequestBody @Validated AllotBillSaveVo allotBillSaveVo) { public ResponseEntity addAllotBill(@RequestBody @Validated AllotBillSaveVo allotBillSaveVo) {
//判断发起配发的装备的生命状态 //判断发起配发的装备的生命状态
if (allotBillSaveVo.getAllotCheckDetail()!=null&&allotBillSaveVo.getAllotCheckDetail().length()>0) { if (allotBillSaveVo.getAllotCheckDetail() != null && allotBillSaveVo.getAllotCheckDetail().length() > 0) {
deviceLibraryService.isInStockOrWaitRetired(StringSplitUtil.split(allotBillSaveVo.getAllotCheckDetail())); deviceLibraryService.isInStockOrWaitRetired(StringSplitUtil.split(allotBillSaveVo.getAllotCheckDetail()));
} }
//1.添加配发单 //1.添加配发单
...@@ -164,7 +161,7 @@ public class AllotBillController { ...@@ -164,7 +161,7 @@ public class AllotBillController {
//保存后的实体 //保存后的实体
AllotBill allotBillEntity; AllotBill allotBillEntity;
//如果是直接发起(不是草稿,没有taskId),当前操作人为发件方A岗,添加账单 //如果是直接发起(不是草稿,没有taskId),当前操作人为发件方A岗,添加账单
if (allotBillSaveVo.getTaskId()==null){ if (allotBillSaveVo.getTaskId() == null) {
a.setSendUseraId(userUtils.getCurrentUserId()); a.setSendUseraId(userUtils.getCurrentUserId());
allotBillEntity = allotBillService.addEntity(a); allotBillEntity = allotBillService.addEntity(a);
} }
...@@ -173,12 +170,12 @@ public class AllotBillController { ...@@ -173,12 +170,12 @@ public class AllotBillController {
//获取草稿账单 //获取草稿账单
AllotBill allotBill = allotBillService.getOne(taskService.get(allotBillSaveVo.getTaskId()).getBillId()); AllotBill allotBill = allotBillService.getOne(taskService.get(allotBillSaveVo.getTaskId()).getBillId());
//copy非null相同字段值 //copy非null相同字段值
MapperUtils.copyNoNullProperties(a,allotBill); MapperUtils.copyNoNullProperties(a, allotBill);
//判断是否取消上传申请单和批复单据 //判断是否取消上传申请单和批复单据
if (a.getApplyFiles()==null||"".equals(a.getApplyFiles())){ if (a.getApplyFiles() == null || "".equals(a.getApplyFiles())) {
allotBill.setApplyFiles(null); allotBill.setApplyFiles(null);
} }
if (a.getReplyFiles()==null||"".equals(a.getReplyFiles())){ if (a.getReplyFiles() == null || "".equals(a.getReplyFiles())) {
allotBill.setReplyFiles(null); allotBill.setReplyFiles(null);
} }
allotBillEntity = allotBillService.update(allotBill); allotBillEntity = allotBillService.update(allotBill);
...@@ -192,12 +189,12 @@ public class AllotBillController { ...@@ -192,12 +189,12 @@ public class AllotBillController {
//生成接收方电子签章id //生成接收方电子签章id
Long signId2 = snowflake.creatNextId(); Long signId2 = snowflake.creatNextId();
//判断是否上传了发送方签章id //判断是否上传了发送方签章id
if (allotBillSaveVo.getLeftSignatureId()!=null) { if (allotBillSaveVo.getLeftSignatureId() != null) {
allotBillEntity.setLeftSignatureId(allotBillSaveVo.getLeftSignatureId()); allotBillEntity.setLeftSignatureId(allotBillSaveVo.getLeftSignatureId());
} }
allotBillEntity.setRightSignatureId(signId2.toString()); allotBillEntity.setRightSignatureId(signId2.toString());
//判断是否提交签发人 //判断是否提交签发人
if (allotBillSaveVo.getSendUserbId()!=null){ if (allotBillSaveVo.getSendUserbId() != null) {
allotBillEntity.setSendUserbId(allotBillSaveVo.getSendUserbId()); allotBillEntity.setSendUserbId(allotBillSaveVo.getSendUserbId());
allotBillEntity.setAgent(userPublicService.getOne(allotBillSaveVo.getSendUserbId()).getName()); allotBillEntity.setAgent(userPublicService.getOne(allotBillSaveVo.getSendUserbId()).getName());
} }
...@@ -213,25 +210,25 @@ public class AllotBillController { ...@@ -213,25 +210,25 @@ public class AllotBillController {
//保存后的taskBto //保存后的taskBto
TaskBto saveEntity; TaskBto saveEntity;
//纵向配发 //纵向配发
if (allotBillSaveVo.getAllotType()==1) { if (allotBillSaveVo.getAllotType() == 1) {
//直接发起 //直接发起
if (allotBillSaveVo.getTaskId() == null) { if (allotBillSaveVo.getTaskId() == null) {
TaskBto taskBto = new TaskBto(StatusEnum.ALLOTING.id, allotBillSaveVo.getSendUnit()+"配发型号"+StringSplitUtil.stringListToString(allotBillSaveVo.getScriptSaveVos().stream().map(ScriptSaveVo::getModel).distinct().collect(Collectors.toList())) +"的装备共"+allotBillSaveVo.getAllotCount()+"件至"+allotBillSaveVo.getReceiveUnit(), null, ".", billId, 3, userPublicService.findUnitIdByName(allotBillSaveVo.getReceiveUnit()), 1, null, userIds); TaskBto taskBto = new TaskBto(StatusEnum.ALLOTING.id, allotBillSaveVo.getSendUnit() + "配发型号" + StringSplitUtil.stringListToString(allotBillSaveVo.getScriptSaveVos().stream().map(ScriptSaveVo::getModel).distinct().collect(Collectors.toList())) + "的装备共" + allotBillSaveVo.getAllotCount() + "件至" + allotBillSaveVo.getReceiveUnit(), null, ".", billId, 3, userPublicService.findUnitIdByName(allotBillSaveVo.getReceiveUnit()), 1, null, userIds);
saveEntity = taskService.start(taskBto); saveEntity = taskService.start(taskBto);
} }
//从草稿发起 //从草稿发起
else { else {
TaskBto taskBto = taskService.get(allotBillSaveVo.getTaskId()); TaskBto taskBto = taskService.get(allotBillSaveVo.getTaskId());
taskBto.setTitle(allotBillSaveVo.getSendUnit()+"配发型号"+StringSplitUtil.stringListToString(allotBillSaveVo.getScriptSaveVos().stream().map(ScriptSaveVo::getModel).distinct().collect(Collectors.toList())) +"的装备共"+allotBillSaveVo.getAllotCount()+"件至"+allotBillSaveVo.getReceiveUnit()); taskBto.setTitle(allotBillSaveVo.getSendUnit() + "配发型号" + StringSplitUtil.stringListToString(allotBillSaveVo.getScriptSaveVos().stream().map(ScriptSaveVo::getModel).distinct().collect(Collectors.toList())) + "的装备共" + allotBillSaveVo.getAllotCount() + "件至" + allotBillSaveVo.getReceiveUnit());
//添加当前操作人为涉及人员 //添加当前操作人为涉及人员
TaskBto taskBto1 = taskService.addInvolveUser(taskBto,userId); TaskBto taskBto1 = taskService.addInvolveUser(taskBto, userId);
//任务所属单位改为收件单位 //任务所属单位改为收件单位
taskBto1.setOwnUnit(userPublicService.findUnitIdByName(allotBillSaveVo.getReceiveUnit())); taskBto1.setOwnUnit(userPublicService.findUnitIdByName(allotBillSaveVo.getReceiveUnit()));
//推动任务到配发中状态 //推动任务到配发中状态
saveEntity = taskService.moveToSpecial(taskBto1, StatusEnum.ALLOTING, 0); saveEntity = taskService.moveToSpecial(taskBto1, StatusEnum.ALLOTING, 0);
} }
//生成发件方上传配发单的子任务 //生成发件方上传配发单的子任务
TaskBto taskBto2 = new TaskBto(StatusEnum.WAIT_UPLOAD_ALLOT_FILE.id, allotBillSaveVo.getSendUnit()+"配发型号"+StringSplitUtil.stringListToString(allotBillSaveVo.getScriptSaveVos().stream().map(ScriptSaveVo::getModel).distinct().collect(Collectors.toList())) +"的装备共"+allotBillSaveVo.getAllotCount()+"件至"+allotBillSaveVo.getReceiveUnit(), saveEntity.getId(), saveEntity.getNodeIdDetail() + saveEntity.getId() + ".", saveEntity.getBillId(), 3, userPublicService.findUnitIdByName(allotBillEntity.getSendUnit()), 0, null, Collections.singletonList(0)); TaskBto taskBto2 = new TaskBto(StatusEnum.WAIT_UPLOAD_ALLOT_FILE.id, allotBillSaveVo.getSendUnit() + "配发型号" + StringSplitUtil.stringListToString(allotBillSaveVo.getScriptSaveVos().stream().map(ScriptSaveVo::getModel).distinct().collect(Collectors.toList())) + "的装备共" + allotBillSaveVo.getAllotCount() + "件至" + allotBillSaveVo.getReceiveUnit(), saveEntity.getId(), saveEntity.getNodeIdDetail() + saveEntity.getId() + ".", saveEntity.getBillId(), 3, userPublicService.findUnitIdByName(allotBillEntity.getSendUnit()), 0, null, Collections.singletonList(0));
taskService.start(taskBto2); taskService.start(taskBto2);
} }
//横向配发 //横向配发
...@@ -244,10 +241,10 @@ public class AllotBillController { ...@@ -244,10 +241,10 @@ public class AllotBillController {
//从草稿发起 //从草稿发起
else { else {
TaskBto taskBto = taskService.get(allotBillSaveVo.getTaskId()); TaskBto taskBto = taskService.get(allotBillSaveVo.getTaskId());
taskBto.setTitle(allotBillSaveVo.getSendUnit()+"配发型号"+StringSplitUtil.stringListToString(allotBillSaveVo.getScriptSaveVos().stream().map(ScriptSaveVo::getModel).distinct().collect(Collectors.toList())) +"的装备共"+allotBillSaveVo.getAllotCount()+"件至"+allotBillSaveVo.getReceiveUnit()); taskBto.setTitle(allotBillSaveVo.getSendUnit() + "配发型号" + StringSplitUtil.stringListToString(allotBillSaveVo.getScriptSaveVos().stream().map(ScriptSaveVo::getModel).distinct().collect(Collectors.toList())) + "的装备共" + allotBillSaveVo.getAllotCount() + "件至" + allotBillSaveVo.getReceiveUnit());
taskBto.setCustomInfo("country"); taskBto.setCustomInfo("country");
//添加当前操作人为涉及人员 //添加当前操作人为涉及人员
TaskBto taskBto1 = taskService.addInvolveUser(taskBto,userId); TaskBto taskBto1 = taskService.addInvolveUser(taskBto, userId);
//推动任务到配发中状态 //推动任务到配发中状态
saveEntity = taskService.moveToSpecial(taskBto1, StatusEnum.WAIT_UPLOAD_CROSS_FILE, userId); saveEntity = taskService.moveToSpecial(taskBto1, StatusEnum.WAIT_UPLOAD_CROSS_FILE, userId);
} }
...@@ -258,11 +255,14 @@ public class AllotBillController { ...@@ -258,11 +255,14 @@ public class AllotBillController {
//存放所有出库装备id //存放所有出库装备id
List<Integer> ids = new ArrayList<>(); List<Integer> ids = new ArrayList<>();
//横纵向列装转换map(key:转换前列装id,value:转换后列装id),减少数据库查询 //横纵向列装转换map(key:转换前列装id,value:转换后列装id),减少数据库查询
Map<Integer,Integer> changeMap = new HashMap<>(); Map<Integer, Integer> changeMap = new HashMap<>();
Map<String,PackingLibrary> packingLibraryHashMap = new HashMap<>(); Map<String, PackingLibrary> packingLibraryHashMap = new HashMap<>();
long s1=System.currentTimeMillis();
get(strings, allotBillSaveVo, packingLibraryHashMap);
log.info("------{}",System.currentTimeMillis()-s1);
long s2=System.currentTimeMillis();
get(strings,allotBillSaveVo,packingLibraryHashMap);
for (String s : strings) { for (String s : strings) {
//最后一位原来为装备扫码结果,已弃用 //最后一位原来为装备扫码结果,已弃用
if (s.length() >= 2) { if (s.length() >= 2) {
...@@ -272,102 +272,67 @@ public class AllotBillController { ...@@ -272,102 +272,67 @@ public class AllotBillController {
//改变装备状态 //改变装备状态
DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(id); DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(id);
//纵向配发 //纵向配发
// if (allotBillSaveVo.getAllotType() == 1){ Integer matchingRange = allotBillSaveVo.getMatchingRange();
if (allotBillSaveVo.getMatchingRange() == 1){ Integer matchingRange1 = deviceLibraryEntity.getMatchingRange();
//如果当前装备的配用范围不是省以下纵向
if (deviceLibraryEntity.getMatchingRange()!=1){ if (matchingRange == 1 || matchingRange == 2 || matchingRange == 3){
//判断changeMap是否存在该列装的转换信息 allotmentEquipment(id,changeMap,deviceLibraryEntity,packingLibraryHashMap,matchingRange1,fileVoList,saveEntity);
//判断是否存在省以下纵向的相同列装装备
PackingLibrary packingLibrary1 = packingLibraryHashMap.get(deviceLibraryEntity.getModel()+deviceLibraryEntity.getName()+1);
//不存在直接抛出异常
if (packingLibrary1 != null) {
changeMap.put(deviceLibraryEntity.getPackingId(),packingLibrary1.getId());
deviceLibraryEntity.setPackingId(packingLibrary1.getId());
deviceLibraryEntity.setMatchingRange(1);
}else {
log.info("[配发] 没有在packingLibraryHashMap找到key:{}的列装",deviceLibraryEntity.getModel()+deviceLibraryEntity.getName()+1);
}
//存装备日志
DeviceLogDto deviceLogDto = new DeviceLogDto(id, "纵向配发将所属列装由" + deviceLibraryEntity.getMatchingRangeName() + "的列装改为"+configCache.getMatchingRangeMap().get(1)+"的列装", fileVoList,saveEntity.getId(),null);
deviceLogService.addLog(deviceLogDto);
}
//改变装备生命状态为配发
deviceLibraryEntity.setLifeStatus(3);
//改变装备管理状态为不在本单位
deviceLibraryEntity.setManageStatus(0);
}else if(allotBillSaveVo.getMatchingRange() == 2){
//如果当前装备的配用范围不是省以下纵向
if (deviceLibraryEntity.getMatchingRange()!=2){
//判断changeMap是否存在该列装的转换信息
//判断是否存在省以下纵向的相同列装装备
PackingLibrary packingLibrary1 = packingLibraryHashMap.get(deviceLibraryEntity.getModel()+deviceLibraryEntity.getName()+2);
//不存在直接抛出异常
if (packingLibrary1 != null) {
changeMap.put(deviceLibraryEntity.getPackingId(),packingLibrary1.getId());
deviceLibraryEntity.setPackingId(packingLibrary1.getId());
deviceLibraryEntity.setMatchingRange(2);
}else {
log.info("[配发] 没有在packingLibraryHashMap找到key:{}的列装",deviceLibraryEntity.getModel()+deviceLibraryEntity.getName()+2);
}
//存装备日志
DeviceLogDto deviceLogDto = new DeviceLogDto(id, "纵向配发将所属列装由" + deviceLibraryEntity.getMatchingRangeName() + "的列装改为"+configCache.getMatchingRangeMap().get(1)+"的列装", fileVoList,saveEntity.getId(),null);
deviceLogService.addLog(deviceLogDto);
}
//改变装备生命状态为配发
deviceLibraryEntity.setLifeStatus(3);
//改变装备管理状态为不在本单位
deviceLibraryEntity.setManageStatus(0);
} }
//横向配发 //横向配发
else if (allotBillSaveVo.getMatchingRange() == 3){ // else if (matchingRange == 3) {
//如果当前装备的配用范围不是省以下横向 // //如果当前装备的配用范围不是省以下横向
if (deviceLibraryEntity.getMatchingRange()!=3) { // if (deviceLibraryEntity.getMatchingRange() != 3) {
//判断changeMap是否存在该列装的转换信息 // //判断changeMap是否存在该列装的转换信息
PackingLibrary packingLibrary1 = packingLibraryHashMap.get(deviceLibraryEntity.getModel()+deviceLibraryEntity.getName()+3); // PackingLibrary packingLibrary1 = packingLibraryHashMap.get(deviceLibraryEntity.getModel() + deviceLibraryEntity.getName() + 3);
//不存在直接抛出异常 // //不存在直接抛出异常
if (packingLibrary1 != null) { // if (packingLibrary1 != null) {
changeMap.put(deviceLibraryEntity.getPackingId(),packingLibrary1.getId()); // changeMap.put(deviceLibraryEntity.getPackingId(), packingLibrary1.getId());
deviceLibraryEntity.setPackingId(packingLibrary1.getId()); // deviceLibraryEntity.setPackingId(packingLibrary1.getId());
deviceLibraryEntity.setMatchingRange(3); // deviceLibraryEntity.setMatchingRange(3);
}else { // } else {
log.info("[配发] 没有在packingLibraryHashMap找到key:{}的列装",deviceLibraryEntity.getModel()+deviceLibraryEntity.getName()+3); // log.info("[配发] 没有在packingLibraryHashMap找到key:{}的列装", deviceLibraryEntity.getModel() + deviceLibraryEntity.getName() + 3);
} // }
} // }
//存装备日志 // //存装备日志
DeviceLogDto deviceLogDto = new DeviceLogDto(id, "横向配发将所属列装由" + deviceLibraryEntity.getMatchingRangeName() + "的列装改为" + configCache.getMatchingRangeMap().get(3) + "的列装", fileVoList,saveEntity.getId(),null); // DeviceLogDto deviceLogDto = new DeviceLogDto(id, "横向配发将所属列装由" + deviceLibraryEntity.getMatchingRangeName() + "的列装改为" + configCache.getMatchingRangeMap().get(3) + "的列装", fileVoList, saveEntity.getId(), null);
deviceLogService.addLog(deviceLogDto); // deviceLogService.addLog(deviceLogDto);
//
//横向直接改变装备所属所在 // //横向直接改变装备所属所在
deviceLibraryEntity.setLocationUnit(allotBillSaveVo.getReceiveUnit()); // deviceLibraryEntity.setLocationUnit(allotBillSaveVo.getReceiveUnit());
deviceLibraryEntity.setOwnUnit(allotBillSaveVo.getReceiveUnit()); // deviceLibraryEntity.setOwnUnit(allotBillSaveVo.getReceiveUnit());
} // }
deviceLibraryEntity.setLifeStatus(3);
//改变装备管理状态为不在本单位
deviceLibraryEntity.setManageStatus(0);
deviceLibraryService.update(deviceLibraryEntity); deviceLibraryService.update(deviceLibraryEntity);
//存装备日志 //存装备日志
DeviceLogDto deviceLogDto = new DeviceLogDto(id, "对" + allotBillEntity.getReceiveUnit() + "发起配发", fileVoList,saveEntity.getId(),null); DeviceLogDto deviceLogDto = new DeviceLogDto(id, "对" + allotBillEntity.getReceiveUnit() + "发起配发", fileVoList, saveEntity.getId(), null);
deviceLogService.addLog(deviceLogDto); deviceLogService.addLog(deviceLogDto);
} }
} }
log.info("------{}",System.currentTimeMillis()-s2);
//添加出库白名单 //添加出库白名单
inputOutputDeviceService.addWhiteDevices(ids, userUtils.getCurrentUnitId(), 1); inputOutputDeviceService.addWhiteDevices(ids, userUtils.getCurrentUnitId(), 1);
//发送阅知信息 //发送阅知信息
List<Integer> idList = userPublicService.findOtherUser(userId); List<Integer> idList = userPublicService.findOtherUser(userId);
//纵向配发阅知要发给收件单位的人 //纵向配发阅知要发给收件单位的人
if (allotBillSaveVo.getAllotType()==1) { if (allotBillSaveVo.getAllotType() == 1) {
idList.addAll(userDao.findAllByUnitsId(userPublicService.findUnitIdByName(allotBillEntity.getReceiveUnit())).stream() idList.addAll(userDao.findAllByUnitsId(userPublicService.findUnitIdByName(allotBillEntity.getReceiveUnit())).stream()
.map(User::getUserId) .map(User::getUserId)
.collect(Collectors.toList())); .collect(Collectors.toList()));
} }
//给被选签发人推阅知 //给被选签发人推阅知
if (allotBillSaveVo.getSendUserbId()!=null) { if (allotBillSaveVo.getSendUserbId() != null) {
List<Integer> idList1 = new ArrayList<>(); List<Integer> idList1 = new ArrayList<>();
idList1.add(allotBillSaveVo.getSendUserbId()); idList1.add(allotBillSaveVo.getSendUserbId());
MessageBto messageBto = new MessageBto(saveEntity.getId(), saveEntity.getBusinessType(), "被选为签发人", idList1, 1); MessageBto messageBto = new MessageBto(saveEntity.getId(), saveEntity.getBusinessType(), "被选为签发人", idList1, 1);
messageService.add(messageBto); messageService.add(messageBto);
} }
//给同单位专管员和收件单位专管员推阅知 //给同单位专管员和收件单位专管员推阅知
MessageBto messageBto = new MessageBto(saveEntity.getId(),saveEntity.getBusinessType(),"对" + userPublicService.getAreaNameByUnitName(allotBillEntity.getReceiveUnit()) + "发起配发",idList,1); MessageBto messageBto = new MessageBto(saveEntity.getId(), saveEntity.getBusinessType(), "对" + userPublicService.getAreaNameByUnitName(allotBillEntity.getReceiveUnit()) + "发起配发", idList, 1);
messageService.add(messageBto); messageService.add(messageBto);
log.info("[配发模块]:" + allotBillEntity.getSendUnit() + "对" + allotBillEntity.getReceiveUnit() + "发起配发"); log.info("[配发模块]:" + allotBillEntity.getSendUnit() + "对" + allotBillEntity.getReceiveUnit() + "发起配发");
myWebSocket.sendMessage1(); myWebSocket.sendMessage1();
...@@ -396,22 +361,22 @@ public class AllotBillController { ...@@ -396,22 +361,22 @@ public class AllotBillController {
//获取当前任务 //获取当前任务
TaskBto taskBto = taskService.get(allotReceiveVo.getTaskId()); TaskBto taskBto = taskService.get(allotReceiveVo.getTaskId());
//判断当前任务状态是否已经被操作 //判断当前任务状态是否已经被操作
List<StatusEnum> statusEnums = Arrays.asList(StatusEnum.ALLOTING,StatusEnum.WAIT_SIGN); List<StatusEnum> statusEnums = Arrays.asList(StatusEnum.ALLOTING, StatusEnum.WAIT_SIGN);
TaskDisposeUtil.isNotSubmit(taskBto.getBillStatus(),statusEnums); TaskDisposeUtil.isNotSubmit(taskBto.getBillStatus(), statusEnums);
//配发单 //配发单
AllotBill allotBillEntity = allotBillService.getOne(taskBto.getBillId()); AllotBill allotBillEntity = allotBillService.getOne(taskBto.getBillId());
//签发人是否上传 //签发人是否上传
boolean sendbIsExist = allotBillEntity.getSendUserbId()!=null; boolean sendbIsExist = allotBillEntity.getSendUserbId() != null;
//上传文件存储集合 //上传文件存储集合
List<FileVo> fileVoList = new ArrayList<>(); List<FileVo> fileVoList = new ArrayList<>();
if (allotReceiveVo.getReceiveFileList()!=null&&allotReceiveVo.getReceiveFileList().size()>0){ if (allotReceiveVo.getReceiveFileList() != null && allotReceiveVo.getReceiveFileList().size() > 0) {
allotReceiveVo.getReceiveFileList().forEach(fileRet -> { allotReceiveVo.getReceiveFileList().forEach(fileRet -> {
fileVoList.add(new FileVo("配发单", fileRet.getName(), fileRet.getPreviewPath())); fileVoList.add(new FileVo("配发单", fileRet.getName(), fileRet.getPreviewPath()));
}); });
allotBillEntity.setReceiveFiles(FilesUtil.stringFileToList(allotReceiveVo.getReceiveFileList())); allotBillEntity.setReceiveFiles(FilesUtil.stringFileToList(allotReceiveVo.getReceiveFileList()));
} }
//是否上传了收件单位签章id //是否上传了收件单位签章id
if (allotReceiveVo.getRightSignatureId()!=null&&!"".equals(allotReceiveVo.getRightSignatureId())) { if (allotReceiveVo.getRightSignatureId() != null && !"".equals(allotReceiveVo.getRightSignatureId())) {
allotBillEntity.setRightSignatureId(allotReceiveVo.getRightSignatureId()); allotBillEntity.setRightSignatureId(allotReceiveVo.getRightSignatureId());
} }
//更新账单状态为配发完成 //更新账单状态为配发完成
...@@ -421,11 +386,11 @@ public class AllotBillController { ...@@ -421,11 +386,11 @@ public class AllotBillController {
//set接收时间 //set接收时间
allotBillEntity.setReceiveTime(TimestampUtil.getCurrentTimestamp()); allotBillEntity.setReceiveTime(TimestampUtil.getCurrentTimestamp());
//如果收件方A岗未上传,默认为当前操作人 //如果收件方A岗未上传,默认为当前操作人
if (allotBillEntity.getReceiveUseraId()==null) { if (allotBillEntity.getReceiveUseraId() == null) {
allotBillEntity.setReceiveUseraId(userId); allotBillEntity.setReceiveUseraId(userId);
} }
//判断是否上传发件方签发人 //判断是否上传发件方签发人
if (allotReceiveVo.getSendUserbId()!=null){ if (allotReceiveVo.getSendUserbId() != null) {
allotBillEntity.setSendUserbId(allotReceiveVo.getSendUserbId()); allotBillEntity.setSendUserbId(allotReceiveVo.getSendUserbId());
allotBillEntity.setAgent(userPublicService.getOne(allotReceiveVo.getSendUserbId()).getName()); allotBillEntity.setAgent(userPublicService.getOne(allotReceiveVo.getSendUserbId()).getName());
} }
...@@ -433,14 +398,13 @@ public class AllotBillController { ...@@ -433,14 +398,13 @@ public class AllotBillController {
//添加当前用户为涉及人员 //添加当前用户为涉及人员
taskService.addInvolveUser(taskBto, userId); taskService.addInvolveUser(taskBto, userId);
//如果上传了单据或双方都盖章,该业务和子业务都办结 //如果上传了单据或双方都盖章,该业务和子业务都办结
if (allotReceiveVo.getStatus()==0) { if (allotReceiveVo.getStatus() == 0) {
taskService.moveToEnd(taskBto); taskService.moveToEnd(taskBto);
//子任务完结 //子任务完结
taskService.moveAllSonNodeToEnd(taskBto.getId()); taskService.moveAllSonNodeToEnd(taskBto.getId());
} } else {
else {
//推至待上传签收单的状态 //推至待上传签收单的状态
taskService.moveToSpecial(taskBto,StatusEnum.WAIT_UPLOAD_ALLOT_RECEIVE_FILE,0); taskService.moveToSpecial(taskBto, StatusEnum.WAIT_UPLOAD_ALLOT_RECEIVE_FILE, 0);
} }
//分隔装备id信息 //分隔装备id信息
String deviceIdDetail = allotReceiveVo.getReceiveCheckDetail(); String deviceIdDetail = allotReceiveVo.getReceiveCheckDetail();
...@@ -458,11 +422,11 @@ public class AllotBillController { ...@@ -458,11 +422,11 @@ public class AllotBillController {
deviceLibraryEntity.setOwnUnit(userUtils.getCurrentUserUnitName()); deviceLibraryEntity.setOwnUnit(userUtils.getCurrentUserUnitName());
deviceLibraryEntity.setManageStatus(1); deviceLibraryEntity.setManageStatus(1);
//如果接收时填写了生产号 //如果接收时填写了生产号
if(allotReceiveVo.getMap().get(id)!=null){ if (allotReceiveVo.getMap().get(id) != null) {
deviceLibraryEntity.setProdNumber(allotReceiveVo.getMap().get(id)); deviceLibraryEntity.setProdNumber(allotReceiveVo.getMap().get(id));
} }
//存装备日志 //存装备日志
DeviceLogDto deviceLogDto = new DeviceLogDto(id, "接收并发起入库", fileVoList,taskBto.getId(),null); DeviceLogDto deviceLogDto = new DeviceLogDto(id, "接收并发起入库", fileVoList, taskBto.getId(), null);
deviceLogService.addLog(deviceLogDto); deviceLogService.addLog(deviceLogDto);
deviceLibraryService.update(deviceLibraryEntity); deviceLibraryService.update(deviceLibraryEntity);
} }
...@@ -473,7 +437,7 @@ public class AllotBillController { ...@@ -473,7 +437,7 @@ public class AllotBillController {
DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(id); DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(id);
deviceLibraryEntity.setLifeStatus(11); deviceLibraryEntity.setLifeStatus(11);
//存装备日志 //存装备日志
DeviceLogDto deviceLogDto = new DeviceLogDto(id, "接收入库丢失", fileVoList,taskBto.getId(),null); DeviceLogDto deviceLogDto = new DeviceLogDto(id, "接收入库丢失", fileVoList, taskBto.getId(), null);
deviceLogService.addLog(deviceLogDto); deviceLogService.addLog(deviceLogDto);
deviceLibraryService.update(deviceLibraryEntity); deviceLibraryService.update(deviceLibraryEntity);
} }
...@@ -492,31 +456,31 @@ public class AllotBillController { ...@@ -492,31 +456,31 @@ public class AllotBillController {
// messageService.add(messageBto); // messageService.add(messageBto);
// } // }
//签发人阅知 //签发人阅知
if (allotReceiveVo.getSendUserbId()!=null&&sendbIsExist) { if (allotReceiveVo.getSendUserbId() != null && sendbIsExist) {
List<Integer> idList1 = new ArrayList<>(); List<Integer> idList1 = new ArrayList<>();
idList1.add(allotReceiveVo.getSendUserbId()); idList1.add(allotReceiveVo.getSendUserbId());
MessageBto messageBto = new MessageBto(taskBto.getId(), taskBto.getBusinessType(), "被选为签发人", idList1, 1); MessageBto messageBto = new MessageBto(taskBto.getId(), taskBto.getBusinessType(), "被选为签发人", idList1, 1);
messageService.add(messageBto); messageService.add(messageBto);
} }
//根据status判断是否业务完结,发送不同的阅知message //根据status判断是否业务完结,发送不同的阅知message
String message = allotReceiveVo.getStatus()==0?"业务办结":"接收配发装备"; String message = allotReceiveVo.getStatus() == 0 ? "业务办结" : "接收配发装备";
MessageBto messageBto = new MessageBto(taskBto.getId(),taskBto.getBusinessType(),message,ids,1); MessageBto messageBto = new MessageBto(taskBto.getId(), taskBto.getBusinessType(), message, ids, 1);
messageService.add(messageBto); messageService.add(messageBto);
log.info("[配发模块]:接收并发起入库"); log.info("[配发模块]:接收并发起入库");
myWebSocket.sendMessage1(); myWebSocket.sendMessage1();
return ResponseEntity.ok("配发接收入库"); return ResponseEntity.ok("配发接收入库");
} }
@ApiOperation(value = "保存配发操作(草稿)", notes = "可以通过这个接口保存配发操作") @ApiOperation(value = "保存配发操作(草稿)", notes = "可以通过这个接口保存配发操作")
@PostMapping(value = "/saveAllotBill") @PostMapping(value = "/saveAllotBill")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity saveAllotBill(@RequestBody AllotBillSaveVo allotBillSaveVo) { public ResponseEntity saveAllotBill(@RequestBody AllotBillSaveVo allotBillSaveVo) {
//判断装备的生命状态是否能配发 //判断装备的生命状态是否能配发
if (allotBillSaveVo.getAllotCheckDetail()!=null&&allotBillSaveVo.getAllotCheckDetail().length()>0) { if (allotBillSaveVo.getAllotCheckDetail() != null && allotBillSaveVo.getAllotCheckDetail().length() > 0) {
deviceLibraryService.isInStockOrWaitRetired(StringSplitUtil.split(allotBillSaveVo.getAllotCheckDetail())); deviceLibraryService.isInStockOrWaitRetired(StringSplitUtil.split(allotBillSaveVo.getAllotCheckDetail()));
} }
//第一次保存(没有taskId) //第一次保存(没有taskId)
if (allotBillSaveVo.getTaskId()==null){ if (allotBillSaveVo.getTaskId() == null) {
Integer userId = userUtils.getCurrentUserId(); Integer userId = userUtils.getCurrentUserId();
//保存入库单 //保存入库单
List<Integer> userIds = new ArrayList<>(); List<Integer> userIds = new ArrayList<>();
...@@ -529,23 +493,22 @@ public class AllotBillController { ...@@ -529,23 +493,22 @@ public class AllotBillController {
allotBill1.setSendUseraId(userId); allotBill1.setSendUseraId(userId);
AllotBill allotBill = allotBillService.addEntity(allotBill1); AllotBill allotBill = allotBillService.addEntity(allotBill1);
//发起草稿任务 //发起草稿任务
TaskBto taskBto = new TaskBto(StatusEnum.ALLOT_DRAFT.id, allotBillSaveVo.getSendUnit()+"配发型号"+StringSplitUtil.stringListToString(allotBillSaveVo.getScriptSaveVos().stream().map(ScriptSaveVo::getModel).distinct().collect(Collectors.toList())) +"的装备共"+allotBillSaveVo.getAllotCount()+"件至"+allotBillSaveVo.getReceiveUnit(), null, ".", allotBill.getId(), 3, userUtils.getCurrentUnitId(), 0, null, userIds); TaskBto taskBto = new TaskBto(StatusEnum.ALLOT_DRAFT.id, allotBillSaveVo.getSendUnit() + "配发型号" + StringSplitUtil.stringListToString(allotBillSaveVo.getScriptSaveVos().stream().map(ScriptSaveVo::getModel).distinct().collect(Collectors.toList())) + "的装备共" + allotBillSaveVo.getAllotCount() + "件至" + allotBillSaveVo.getReceiveUnit(), null, ".", allotBill.getId(), 3, userUtils.getCurrentUnitId(), 0, null, userIds);
TaskBto taskBto1 = taskService.start(taskBto); TaskBto taskBto1 = taskService.start(taskBto);
//返回保存成功的id //返回保存成功的id
Integer id = taskBto1.getId(); Integer id = taskBto1.getId();
myWebSocket.sendMessage1(); myWebSocket.sendMessage1();
return ResponseEntity.ok("保存成功"+id); return ResponseEntity.ok("保存成功" + id);
} } else {
else {
//更新账单 //更新账单
TaskBto taskBto = taskService.get(allotBillSaveVo.getTaskId()); TaskBto taskBto = taskService.get(allotBillSaveVo.getTaskId());
AllotBill allotBill = allotBillService.getOne(taskBto.getBillId()); AllotBill allotBill = allotBillService.getOne(taskBto.getBillId());
AllotBill allotBill1 = allotBillSaveVo.toDo(); AllotBill allotBill1 = allotBillSaveVo.toDo();
//状态设为草稿 //状态设为草稿
allotBill1.setAllotStatus(0); allotBill1.setAllotStatus(0);
MapperUtils.copyNoNullProperties(allotBill1,allotBill); MapperUtils.copyNoNullProperties(allotBill1, allotBill);
allotBillService.update(allotBill); allotBillService.update(allotBill);
return ResponseEntity.ok("更新成功"+taskBto.getId()); return ResponseEntity.ok("更新成功" + taskBto.getId());
} }
} }
...@@ -555,7 +518,7 @@ public class AllotBillController { ...@@ -555,7 +518,7 @@ public class AllotBillController {
public ResponseEntity deleteAllotBill(@PathVariable("taskId") int taskId) { public ResponseEntity deleteAllotBill(@PathVariable("taskId") int taskId) {
//任务封存 //任务封存
TaskBto taskBto = taskService.get(taskId); TaskBto taskBto = taskService.get(taskId);
TaskBto taskBto1 = taskService.addInvolveUser(taskBto,userUtils.getCurrentUserId()); TaskBto taskBto1 = taskService.addInvolveUser(taskBto, userUtils.getCurrentUserId());
taskService.moveToArchive(taskBto1); taskService.moveToArchive(taskBto1);
myWebSocket.sendMessage1(); myWebSocket.sendMessage1();
return ResponseEntity.ok("删除成功"); return ResponseEntity.ok("删除成功");
...@@ -564,18 +527,18 @@ public class AllotBillController { ...@@ -564,18 +527,18 @@ public class AllotBillController {
@ApiOperation(value = "申请电子签章", notes = "可以通过这个接口申请电子签章") @ApiOperation(value = "申请电子签章", notes = "可以通过这个接口申请电子签章")
@PostMapping(value = "/applySign/{taskId}/{userId}") @PostMapping(value = "/applySign/{taskId}/{userId}")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity applySign(@PathVariable("taskId") int taskId,@PathVariable("userId") int userId) { public ResponseEntity applySign(@PathVariable("taskId") int taskId, @PathVariable("userId") int userId) {
//获取任务和账单 //获取任务和账单
TaskBto taskBto = taskService.get(taskId); TaskBto taskBto = taskService.get(taskId);
AllotBill allotBill = allotBillService.getOne(taskBto.getBillId()); AllotBill allotBill = allotBillService.getOne(taskBto.getBillId());
//如果是收件方申请电子签章 //如果是收件方申请电子签章
if (allotBill.getAllotStatus()!=0){ if (allotBill.getAllotStatus() != 0) {
//当前用户设为接收A岗 //当前用户设为接收A岗
allotBill.setReceiveUseraId(userUtils.getCurrentUserId()); allotBill.setReceiveUseraId(userUtils.getCurrentUserId());
allotBillService.update(allotBill); allotBillService.update(allotBill);
} }
//推动任务到盖章待审核状态 //推动任务到盖章待审核状态
taskService.moveToSpecial(taskBto,StatusEnum.SIGN_WAIT_CONFIRM,userId); taskService.moveToSpecial(taskBto, StatusEnum.SIGN_WAIT_CONFIRM, userId);
myWebSocket.sendMessage1(); myWebSocket.sendMessage1();
return ResponseEntity.ok("申请成功"); return ResponseEntity.ok("申请成功");
} }
...@@ -583,16 +546,16 @@ public class AllotBillController { ...@@ -583,16 +546,16 @@ public class AllotBillController {
@ApiOperation(value = "申请电子签章审核", notes = "可以通过这个接口申请电子签章审核") @ApiOperation(value = "申请电子签章审核", notes = "可以通过这个接口申请电子签章审核")
@PostMapping(value = "/applySignConfirm/{taskId}/{status}") @PostMapping(value = "/applySignConfirm/{taskId}/{status}")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity applySignConfirm(@PathVariable("taskId") int taskId,@PathVariable("status") int status) { public ResponseEntity applySignConfirm(@PathVariable("taskId") int taskId, @PathVariable("status") int status) {
//获取任务和单据 //获取任务和单据
TaskBto taskBto = taskService.get(taskId); TaskBto taskBto = taskService.get(taskId);
AllotBill allotBill = allotBillService.getOne(taskBto.getBillId()); AllotBill allotBill = allotBillService.getOne(taskBto.getBillId());
//如果同意 //如果同意
if (status==1){ if (status == 1) {
//推动任务到等待盖章状态 //推动任务到等待盖章状态
taskService.moveToSpecial(taskBto,StatusEnum.WAIT_SIGN); taskService.moveToSpecial(taskBto, StatusEnum.WAIT_SIGN);
//发件方盖章 //发件方盖章
if (allotBill.getAllotStatus()==0) { if (allotBill.getAllotStatus() == 0) {
//当前用户设为签发人 //当前用户设为签发人
allotBill.setSendUserbId(userUtils.getCurrentUserId()); allotBill.setSendUserbId(userUtils.getCurrentUserId());
allotBill.setAgent(userUtils.getCurrentName()); allotBill.setAgent(userUtils.getCurrentName());
...@@ -603,10 +566,9 @@ public class AllotBillController { ...@@ -603,10 +566,9 @@ public class AllotBillController {
allotBill.setReceiveUserbId(userUtils.getCurrentUserId()); allotBill.setReceiveUserbId(userUtils.getCurrentUserId());
} }
allotBillService.update(allotBill); allotBillService.update(allotBill);
} } else {
else {
//发件方盖章不同意任务返回草稿状态 //发件方盖章不同意任务返回草稿状态
if (allotBill.getAllotStatus()==0) { if (allotBill.getAllotStatus() == 0) {
taskService.moveToSpecial(taskBto, StatusEnum.ALLOT_DRAFT, taskBto.getCreateUserId()); taskService.moveToSpecial(taskBto, StatusEnum.ALLOT_DRAFT, taskBto.getCreateUserId());
} }
//收件方返回到待入库状态 //收件方返回到待入库状态
...@@ -639,7 +601,7 @@ public class AllotBillController { ...@@ -639,7 +601,7 @@ public class AllotBillController {
allotBillEntity.setReceiveUserB(userPublicService.getOne(allotBillEntity.getReceiveUserbId()).getName()); allotBillEntity.setReceiveUserB(userPublicService.getOne(allotBillEntity.getReceiveUserbId()).getName());
} }
//分隔装备id得到装备信息 //分隔装备id得到装备信息
if (allotBillEntity.getAllotCheckDetail()!=null){ if (allotBillEntity.getAllotCheckDetail() != null) {
List<Integer> ids = StringSplitUtil.split(allotBillEntity.getAllotCheckDetail()); List<Integer> ids = StringSplitUtil.split(allotBillEntity.getAllotCheckDetail());
List<DeviceLibrary> deviceLibraryList = new ArrayList<>(); List<DeviceLibrary> deviceLibraryList = new ArrayList<>();
ids.forEach(integer -> deviceLibraryList.add(deviceLibraryService.getOne(integer))); ids.forEach(integer -> deviceLibraryList.add(deviceLibraryService.getOne(integer)));
...@@ -649,8 +611,9 @@ public class AllotBillController { ...@@ -649,8 +611,9 @@ public class AllotBillController {
allotBillEntity.setReplyFileList(FilesUtil.stringFileToList(allotBillEntity.getReplyFiles())); allotBillEntity.setReplyFileList(FilesUtil.stringFileToList(allotBillEntity.getReplyFiles()));
allotBillEntity.setApplyFileList(FilesUtil.stringFileToList(allotBillEntity.getApplyFiles())); allotBillEntity.setApplyFileList(FilesUtil.stringFileToList(allotBillEntity.getApplyFiles()));
//返回前端单据json详情 //返回前端单据json详情
if (allotBillEntity.getScriptJson()!=null){ if (allotBillEntity.getScriptJson() != null) {
allotBillEntity.setScripts(JacksonUtil.readValue(allotBillEntity.getScriptJson(),new TypeReference<List<ScriptSaveVo>>() {})); allotBillEntity.setScripts(JacksonUtil.readValue(allotBillEntity.getScriptJson(), new TypeReference<List<ScriptSaveVo>>() {
}));
} }
return ResponseEntity.ok(allotBillEntity); return ResponseEntity.ok(allotBillEntity);
} }
...@@ -658,18 +621,18 @@ public class AllotBillController { ...@@ -658,18 +621,18 @@ public class AllotBillController {
@ApiOperation(value = "上传接收方配发单", notes = "可以通过这个接口上传送修单") @ApiOperation(value = "上传接收方配发单", notes = "可以通过这个接口上传送修单")
@PostMapping(value = "/uploadAllotBill") @PostMapping(value = "/uploadAllotBill")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity uploadAllotBill(@RequestBody @Validated FileUploadVo fileUploadVo){ public ResponseEntity uploadAllotBill(@RequestBody @Validated FileUploadVo fileUploadVo) {
TaskBto taskBto = taskService.get(fileUploadVo.getTaskId()); TaskBto taskBto = taskService.get(fileUploadVo.getTaskId());
//判断业务状态是否被操作 //判断业务状态是否被操作
TaskDisposeUtil.isNotSubmit(taskBto.getBillStatus(),StatusEnum.WAIT_UPLOAD_ALLOT_RECEIVE_FILE); TaskDisposeUtil.isNotSubmit(taskBto.getBillStatus(), StatusEnum.WAIT_UPLOAD_ALLOT_RECEIVE_FILE);
Integer userId = userUtils.getCurrentUserId(); Integer userId = userUtils.getCurrentUserId();
taskService.addInvolveUser(taskBto,userId); taskService.addInvolveUser(taskBto, userId);
//业务和子业务办结 //业务和子业务办结
taskService.moveToEnd(taskBto); taskService.moveToEnd(taskBto);
taskService.moveAllSonNodeToEnd(taskBto.getId()); taskService.moveAllSonNodeToEnd(taskBto.getId());
AllotBill allotBill = allotBillService.getOne(taskBto.getBillId()); AllotBill allotBill = allotBillService.getOne(taskBto.getBillId());
//是否上传发件方签发人 //是否上传发件方签发人
if (fileUploadVo.getSendUserbId()!=null){ if (fileUploadVo.getSendUserbId() != null) {
allotBill.setSendUserbId(fileUploadVo.getSendUserbId()); allotBill.setSendUserbId(fileUploadVo.getSendUserbId());
allotBill.setAgent(userPublicService.getOne(fileUploadVo.getSendUserbId()).getName()); allotBill.setAgent(userPublicService.getOne(fileUploadVo.getSendUserbId()).getName());
} }
...@@ -681,26 +644,26 @@ public class AllotBillController { ...@@ -681,26 +644,26 @@ public class AllotBillController {
// } // }
//文件列表 //文件列表
List<FileVo> fileVoList = new ArrayList<>(); List<FileVo> fileVoList = new ArrayList<>();
if (fileUploadVo.getReceiveFileList()!=null&&fileUploadVo.getReceiveFileList().size()>0){ if (fileUploadVo.getReceiveFileList() != null && fileUploadVo.getReceiveFileList().size() > 0) {
fileUploadVo.getReceiveFileList().forEach(fileRet -> { fileUploadVo.getReceiveFileList().forEach(fileRet -> {
fileVoList.add(new FileVo("配发单", fileRet.getName(), fileRet.getPreviewPath())); fileVoList.add(new FileVo("配发单", fileRet.getName(), fileRet.getPreviewPath()));
}); });
allotBill.setReceiveFiles(FilesUtil.stringFileToList(fileUploadVo.getReceiveFileList())); allotBill.setReceiveFiles(FilesUtil.stringFileToList(fileUploadVo.getReceiveFileList()));
} }
//是否上传接收方B岗 //是否上传接收方B岗
if (fileUploadVo.getReceiveUserbId()!=null){ if (fileUploadVo.getReceiveUserbId() != null) {
allotBill.setReceiveUserbId(fileUploadVo.getReceiveUserbId()); allotBill.setReceiveUserbId(fileUploadVo.getReceiveUserbId());
} }
allotBillService.update(allotBill); allotBillService.update(allotBill);
//添加装备日志 //添加装备日志
List<Integer> deviceIds = StringSplitUtil.split(allotBill.getAllotCheckDetail()); List<Integer> deviceIds = StringSplitUtil.split(allotBill.getAllotCheckDetail());
deviceIds.forEach(integer -> { deviceIds.forEach(integer -> {
//存装备日志 //存装备日志
DeviceLogDto deviceLogDto = new DeviceLogDto(integer, "上传配发单据", fileVoList,taskBto.getId(),null); DeviceLogDto deviceLogDto = new DeviceLogDto(integer, "上传配发单据", fileVoList, taskBto.getId(), null);
deviceLogService.addLog(deviceLogDto); deviceLogService.addLog(deviceLogDto);
}); });
//签发人阅知 //签发人阅知
if (fileUploadVo.getSendUserbId()!=null) { if (fileUploadVo.getSendUserbId() != null) {
List<Integer> idList1 = new ArrayList<>(); List<Integer> idList1 = new ArrayList<>();
idList1.add(fileUploadVo.getSendUserbId()); idList1.add(fileUploadVo.getSendUserbId());
MessageBto messageBto = new MessageBto(taskBto.getId(), taskBto.getBusinessType(), "被选为签发人", idList1, 1); MessageBto messageBto = new MessageBto(taskBto.getId(), taskBto.getBusinessType(), "被选为签发人", idList1, 1);
...@@ -711,7 +674,7 @@ public class AllotBillController { ...@@ -711,7 +674,7 @@ public class AllotBillController {
ids.addAll(userDao.findAllByUnitsId(userPublicService.findUnitIdByName(allotBill.getSendUnit())).stream() ids.addAll(userDao.findAllByUnitsId(userPublicService.findUnitIdByName(allotBill.getSendUnit())).stream()
.map(User::getUserId) .map(User::getUserId)
.collect(Collectors.toList())); .collect(Collectors.toList()));
MessageBto messageBto = new MessageBto(taskBto.getId(),taskBto.getBusinessType(),"业务办结",ids,1); MessageBto messageBto = new MessageBto(taskBto.getId(), taskBto.getBusinessType(), "业务办结", ids, 1);
messageService.add(messageBto); messageService.add(messageBto);
return ResponseEntity.ok("上传成功"); return ResponseEntity.ok("上传成功");
} }
...@@ -719,29 +682,29 @@ public class AllotBillController { ...@@ -719,29 +682,29 @@ public class AllotBillController {
@ApiOperation(value = "上传发送方配发单", notes = "上传配发单") @ApiOperation(value = "上传发送方配发单", notes = "上传配发单")
@PostMapping(value = "/uploadFile") @PostMapping(value = "/uploadFile")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity uploadFile(@RequestBody @Validated com.tykj.dev.device.allot.subject.vo.FileVo fileVo){ public ResponseEntity uploadFile(@RequestBody @Validated com.tykj.dev.device.allot.subject.vo.FileVo fileVo) {
//获取task //获取task
TaskBto taskBto = taskService.get(fileVo.getTaskId()); TaskBto taskBto = taskService.get(fileVo.getTaskId());
taskService.addInvolveUser(taskBto,userUtils.getCurrentUserId()); taskService.addInvolveUser(taskBto, userUtils.getCurrentUserId());
//判断业务状态是否被操作 //判断业务状态是否被操作
List<StatusEnum> statusEnums = new ArrayList<>(); List<StatusEnum> statusEnums = new ArrayList<>();
statusEnums.add(StatusEnum.WAIT_UPLOAD_CROSS_FILE);//待上传横向配发单 statusEnums.add(StatusEnum.WAIT_UPLOAD_CROSS_FILE);//待上传横向配发单
statusEnums.add(StatusEnum.WAIT_UPLOAD_ALLOT_FILE);//待上传纵向配发单 statusEnums.add(StatusEnum.WAIT_UPLOAD_ALLOT_FILE);//待上传纵向配发单
TaskDisposeUtil.isNotSubmit(taskBto.getBillStatus(),statusEnums); TaskDisposeUtil.isNotSubmit(taskBto.getBillStatus(), statusEnums);
//获取账单 //获取账单
AllotBill allotBill = allotBillService.getOne(taskBto.getBillId()); AllotBill allotBill = allotBillService.getOne(taskBto.getBillId());
//存放接收方经办人id //存放接收方经办人id
List<Integer> idList = new ArrayList<>(); List<Integer> idList = new ArrayList<>();
if (fileVo.getReceiveUseraId()!=null) { if (fileVo.getReceiveUseraId() != null) {
allotBill.setReceiveUseraId(fileVo.getReceiveUseraId()); allotBill.setReceiveUseraId(fileVo.getReceiveUseraId());
idList.add(fileVo.getReceiveUseraId()); idList.add(fileVo.getReceiveUseraId());
} }
if (fileVo.getReceiveUserbId()!=null) { if (fileVo.getReceiveUserbId() != null) {
allotBill.setReceiveUserbId(fileVo.getReceiveUserbId()); allotBill.setReceiveUserbId(fileVo.getReceiveUserbId());
idList.add(fileVo.getReceiveUserbId()); idList.add(fileVo.getReceiveUserbId());
} }
//签发人阅知 //签发人阅知
if (fileVo.getSendUserbId()!=null){ if (fileVo.getSendUserbId() != null) {
allotBill.setSendUserbId(fileVo.getSendUserbId()); allotBill.setSendUserbId(fileVo.getSendUserbId());
allotBill.setAgent(userPublicService.getOne(fileVo.getSendUserbId()).getName()); allotBill.setAgent(userPublicService.getOne(fileVo.getSendUserbId()).getName());
List<Integer> idList1 = new ArrayList<>(); List<Integer> idList1 = new ArrayList<>();
...@@ -762,14 +725,14 @@ public class AllotBillController { ...@@ -762,14 +725,14 @@ public class AllotBillController {
//业务完结 //业务完结
taskService.moveToEnd(taskBto); taskService.moveToEnd(taskBto);
//主业务完结 //主业务完结
if (taskBto.getParentTaskId()!=null) { if (taskBto.getParentTaskId() != null) {
taskService.moveToEnd(taskService.get(taskBto.getParentTaskId())); taskService.moveToEnd(taskService.get(taskBto.getParentTaskId()));
} }
//添加装备日志,改变装备状态 //添加装备日志,改变装备状态
List<FileVo> fileVoList = new ArrayList<>(); List<FileVo> fileVoList = new ArrayList<>();
fileVo.getAllotFiles().forEach(fileRet -> fileVoList.add(new FileVo("配发单", fileRet.getName(), fileRet.getPreviewPath()))); fileVo.getAllotFiles().forEach(fileRet -> fileVoList.add(new FileVo("配发单", fileRet.getName(), fileRet.getPreviewPath())));
ids.forEach(integer -> { ids.forEach(integer -> {
DeviceLogDto deviceLogDto = new DeviceLogDto(integer, "上传配发单", fileVoList,taskBto.getId(),null); DeviceLogDto deviceLogDto = new DeviceLogDto(integer, "上传配发单", fileVoList, taskBto.getId(), null);
deviceLogService.addLog(deviceLogDto); deviceLogService.addLog(deviceLogDto);
DeviceLibrary deviceLibrary = deviceLibraryService.getOne(integer); DeviceLibrary deviceLibrary = deviceLibraryService.getOne(integer);
deviceLibrary.setLocationUnit(allotBill.getReceiveUnit()); deviceLibrary.setLocationUnit(allotBill.getReceiveUnit());
...@@ -788,20 +751,20 @@ public class AllotBillController { ...@@ -788,20 +751,20 @@ public class AllotBillController {
userIds.addAll(userDao.findAllByUnitsId(userPublicService.findUnitIdByName(allotBill.getReceiveUnit())).stream() userIds.addAll(userDao.findAllByUnitsId(userPublicService.findUnitIdByName(allotBill.getReceiveUnit())).stream()
.map(User::getUserId) .map(User::getUserId)
.collect(Collectors.toList())); .collect(Collectors.toList()));
MessageBto messageBto = new MessageBto(taskBto.getParentTaskId(),taskBto.getBusinessType(),"业务办结",userIds,1); MessageBto messageBto = new MessageBto(taskBto.getParentTaskId(), taskBto.getBusinessType(), "业务办结", userIds, 1);
messageService.add(messageBto); messageService.add(messageBto);
return ResponseEntity.ok("OK"); return ResponseEntity.ok("OK");
} }
@ApiOperation(value = "上传发送方签发人", notes = "上传发送方签发人") @ApiOperation(value = "上传发送方签发人", notes = "上传发送方签发人")
@PostMapping(value = "/updateAgent")//不用了 @PostMapping(value = "/updateAgent")//不用了
public ResponseEntity updateAgent(@RequestBody AgentVo agentVo){ public ResponseEntity updateAgent(@RequestBody AgentVo agentVo) {
//获取业务 //获取业务
TaskBto taskBto = taskService.get(agentVo.getId()); TaskBto taskBto = taskService.get(agentVo.getId());
List<Integer> idList = new ArrayList<>(); List<Integer> idList = new ArrayList<>();
idList.add(agentVo.getSendUserbId()); idList.add(agentVo.getSendUserbId());
//签发人阅知 //签发人阅知
MessageBto messageBto = new MessageBto(taskBto.getId(),taskBto.getBusinessType(),"被选为签发人",idList,1); MessageBto messageBto = new MessageBto(taskBto.getId(), taskBto.getBusinessType(), "被选为签发人", idList, 1);
messageService.add(messageBto); messageService.add(messageBto);
//账单保存签发人 //账单保存签发人
AllotBill allotBill = allotBillService.getOne(taskBto.getBillId()); AllotBill allotBill = allotBillService.getOne(taskBto.getBillId());
...@@ -813,7 +776,7 @@ public class AllotBillController { ...@@ -813,7 +776,7 @@ public class AllotBillController {
@ApiOperation(value = "配发撤回", notes = "根据任务id撤回配发") @ApiOperation(value = "配发撤回", notes = "根据任务id撤回配发")
@GetMapping("/revokeTask/taskId") @GetMapping("/revokeTask/taskId")
public ResponseEntity revokeTask(Integer taskId){ public ResponseEntity revokeTask(Integer taskId) {
//根据任务id查询子任务 发件方是子任务 收件方是主任务 //根据任务id查询子任务 发件方是子任务 收件方是主任务
TaskBto taskBto = taskService.get(taskId); TaskBto taskBto = taskService.get(taskId);
...@@ -826,7 +789,7 @@ public class AllotBillController { ...@@ -826,7 +789,7 @@ public class AllotBillController {
AllotBill allotBill = allotBillService.getOne(billId); AllotBill allotBill = allotBillService.getOne(billId);
if (allotBill.getAllotCheckDetail()!=null){ if (allotBill.getAllotCheckDetail() != null) {
List<Integer> ids = StringSplitUtil.split(allotBill.getAllotCheckDetail()); List<Integer> ids = StringSplitUtil.split(allotBill.getAllotCheckDetail());
List<DeviceLibrary> deviceLibraryList = new ArrayList<>(); List<DeviceLibrary> deviceLibraryList = new ArrayList<>();
for (Integer id : ids) { for (Integer id : ids) {
...@@ -837,273 +800,130 @@ public class AllotBillController { ...@@ -837,273 +800,130 @@ public class AllotBillController {
deviceLibraryList.add(deviceLibrary); deviceLibraryList.add(deviceLibrary);
} }
allotBill.setDeviceLibraries(deviceLibraryList); allotBill.setDeviceLibraries(deviceLibraryList);
allotBillService.delete(allotBill.getId());
} }
// List<DeviceLibrary> deviceLibraryList = deviceLibraryService.getListByBillId(billId);
//
// for (DeviceLibrary deviceLibrary : deviceLibraryList) {
// deviceLibrary.setLifeStatus(2);
// deviceLibraryService.update(deviceLibrary);
// }
//将任务都完结 //将任务都完结
taskService.moveToArchive(taskBto); taskService.moveToArchive(taskBto);
taskService.moveToArchive(parentTask); taskService.moveToArchive(parentTask);
return ResponseEntity.ok(title + "的任务撤回成功"); return ResponseEntity.ok(title + "的任务撤回成功");
} }
public PackingLibrary getPackingLibrary(PackingLibrary packingLibrary) {
// @ApiOperation(value = "创建列装装备")
//// @PostMapping("/createPackingLibrary")
// public Map<Integer,Integer> createPackingLibrary(PackingLibrary packingLibrary,Integer matchingRange,Integer devId){
// Map<Integer,Integer> map = new HashMap<>();
// //是否是配件
// Integer isPart = packingLibrary.getIsPart();
//
//// List<DeviceLibrary> deviceLibraries = deviceLibraryService.getAllDevByDevIds(ids);
//// //遍历所有装备的id
//// for (Integer id : ids) {
//// //先判断配发装备之间有没有父子结构
//// if (ids.contains(packingLibrary.getPartParentId())){
//// ids.remove()
//// }
//// }
// //如果是配件 需要找到父类
// if (isPart == 1){
// PackingLibrary packingLibrary1 = new PackingLibrary();
// BeanUtils.copyProperties(packingLibrary,packingLibrary1);
// packingLibrary1.setMatchingRange(matchingRange);
// //更新
// PackingLibrary packingLibrary2 = packingLibraryService.update(packingLibrary);
// //同时修改装备的状态
// DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(devId);
// deviceLibraryEntity.setMatchingRange(matchingRange);
// map.put(packingLibrary.getId(),packingLibrary2.getId());
// }else {
// //是装备
// //查询出父子结构
// SelectPack selectPack = new SelectPack();
// selectPack.setModel(packingLibrary.getModel());
// selectPack.setName(packingLibrary.getName());
// selectPack.setStatus(packingLibrary.getStatus());
// selectPack.setSecretLevel(packingLibrary.getSecretLevel());
// List<PackingLibrary> insertList = packingLibraryService.getInsertList(selectPack);
// //拿到装备
// for (PackingLibrary library : insertList) {
// if (library.getIsPart() == 0){
// PackingLibrary newPackingLibrary = new PackingLibrary();
// BeanUtils.copyProperties(library,newPackingLibrary);
// newPackingLibrary.setId(null);
// newPackingLibrary.setMatchingRange(matchingRange);
// //更新 新的装备
// PackingLibrary packingLibrary1 = packingLibraryService.addEntity(newPackingLibrary);
// //同时修改装备的状态
// DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(devId);
// deviceLibraryEntity.setPackingId(packingLibrary1.getId());
// deviceLibraryEntity.setMatchingRange(matchingRange);
// map.put(library.getId(),packingLibrary1.getId());
// }else {
// if (library.getMatchingRange() != matchingRange){
// PackingLibrary newPackingLibrary = new PackingLibrary();
// BeanUtils.copyProperties(library,newPackingLibrary);
// newPackingLibrary.setMatchingRange(matchingRange);
// //更新
// PackingLibrary packingLibrary2 = packingLibraryService.update(packingLibrary);
// //同时修改装备的状态
// DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(devId);
// deviceLibraryEntity.setMatchingRange(matchingRange);
// map.put(packingLibrary.getId(),packingLibrary2.getId());
// }
// }
// }
// }
// return map;
//
// }
public Map<Integer,Integer> createPackingLibrary(PackingLibrary packingLibrary,Integer matchingRange,Integer devId){
Map<Integer,Integer> map = new HashMap<>();
//是否是配件
Integer isPart = packingLibrary.getIsPart();
//如果是配件 需要找到父类
// if (isPart == 1){
// PackingLibrary packingLibrary1 = new PackingLibrary();
// BeanUtils.copyProperties(packingLibrary,packingLibrary1);
// packingLibrary1.setMatchingRange(matchingRange);
// //更新
// PackingLibrary packingLibrary2 = packingLibraryService.update(packingLibrary);
// //同时修改装备的状态
// DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(devId);
// deviceLibraryEntity.setMatchingRange(matchingRange);
// map.put(packingLibrary.getId(),packingLibrary2.getId());
// }else {
// //是装备
// //查询出父子结构
// SelectPack selectPack = new SelectPack();
// selectPack.setModel(packingLibrary.getModel());
// selectPack.setName(packingLibrary.getName());
// selectPack.setStatus(packingLibrary.getStatus());
// selectPack.setSecretLevel(packingLibrary.getSecretLevel());
// List<PackingLibrary> insertList = packingLibraryService.getInsertList(selectPack);
// //拿到装备
// for (PackingLibrary library : insertList) {
// if (library.getIsPart() == 0){
// PackingLibrary newPackingLibrary = new PackingLibrary();
// BeanUtils.copyProperties(library,newPackingLibrary);
// newPackingLibrary.setId(null);
// newPackingLibrary.setMatchingRange(matchingRange);
// //更新 新的装备
// PackingLibrary packingLibrary1 = packingLibraryService.addEntity(newPackingLibrary);
// //同时修改装备的状态
// DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(devId);
// deviceLibraryEntity.setPackingId(packingLibrary1.getId());
// deviceLibraryEntity.setMatchingRange(matchingRange);
// map.put(library.getId(),packingLibrary1.getId());
// }else {
// if (library.getMatchingRange() != matchingRange){
// PackingLibrary newPackingLibrary = new PackingLibrary();
// BeanUtils.copyProperties(library,newPackingLibrary);
// newPackingLibrary.setMatchingRange(matchingRange);
// //更新
// PackingLibrary packingLibrary2 = packingLibraryService.update(packingLibrary);
// //同时修改装备的状态
// DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(devId);
// deviceLibraryEntity.setMatchingRange(matchingRange);
// map.put(packingLibrary.getId(),packingLibrary2.getId());
// }
// }
// }
// }
return map;
}
public PackingLibrary getPackingLibrary(PackingLibrary packingLibrary){
Integer partParentId = packingLibrary.getPartParentId(); Integer partParentId = packingLibrary.getPartParentId();
PackingLibrary one = packingLibraryService.getOne(partParentId); PackingLibrary one = packingLibraryService.getOne(partParentId);
if (one.getIsRoot() == 0){ if (one.getIsRoot() == 0) {
PackingLibrary parentPackingLibrary = packingLibraryService.getOne(partParentId); PackingLibrary parentPackingLibrary = packingLibraryService.getOne(partParentId);
return getPackingLibrary(parentPackingLibrary); return getPackingLibrary(parentPackingLibrary);
}else { } else {
return packingLibrary; return packingLibrary;
} }
} }
public void getPackingLibrary2(PackingLibrary packingLibrary,Integer newId,Integer matchingRange,Map<String,PackingLibrary> packingLibraryMap){ public void getPackingLibrary2(PackingLibrary packingLibrary, Integer newId, Integer matchingRange, Map<String, PackingLibrary> packingLibraryMap) {
// PackingLibrary newPackingLibrary = mapper.map(packingLibrary,PackingLibrary.class);
PackingLibrary newPackingLibrary = new PackingLibrary(); PackingLibrary newPackingLibrary = new PackingLibrary();
BeanUtils.copyProperties(packingLibrary,newPackingLibrary); BeanUtils.copyProperties(packingLibrary, newPackingLibrary);
newPackingLibrary.setId(null); newPackingLibrary.setId(null);
newPackingLibrary.setPartParentId(newId); newPackingLibrary.setPartParentId(newId);
newPackingLibrary.setMatchingRange(matchingRange); newPackingLibrary.setMatchingRange(matchingRange);
packingLibraryService.addAllotPacking(newPackingLibrary); packingLibraryService.addAllotPacking(newPackingLibrary);
// packingLibraryDao.save(newPackingLibrary); packingLibraryMap.put(newPackingLibrary.getModel() + newPackingLibrary.getName() + newPackingLibrary.getMatchingRange(), newPackingLibrary);
packingLibraryMap.put(newPackingLibrary.getModel()+newPackingLibrary.getName()+newPackingLibrary.getMatchingRange(),newPackingLibrary);
List<PackingLibrary> packingLibraryList = packingLibraryService.getAllByPartPackingId(packingLibrary.getId()); List<PackingLibrary> packingLibraryList = packingLibraryService.getAllByPartPackingId(packingLibrary.getId());
if (packingLibraryList!=null||packingLibraryList.size()!=0){ if (packingLibraryList != null || packingLibraryList.size() != 0) {
packingLibraryList.forEach(packingLibrary1 -> { packingLibraryList.forEach(packingLibrary1 -> {
getPackingLibrary2(packingLibrary1,newPackingLibrary.getId(),matchingRange,packingLibraryMap); getPackingLibrary2(packingLibrary1, newPackingLibrary.getId(), matchingRange, packingLibraryMap);
}); });
} }
} }
public void get(String[] strings,AllotBillSaveVo allotBillSaveVo,Map<String,PackingLibrary> packingLibraryHashMap){ public void get(String[] strings, AllotBillSaveVo allotBillSaveVo, Map<String, PackingLibrary> packingLibraryHashMap) {
for (String s : strings) { for (String s : strings) {
//最后一位原来为装备扫码结果,已弃用 //最后一位原来为装备扫码结果,已弃用
if (s.length() >= 2) { if (s.length() >= 2) {
//去掉最后一位得到装备id //去掉最后一位得到装备id
Integer id = Integer.parseInt(s.substring(0, s.length() - 1)); Integer id = Integer.parseInt(s.substring(0, s.length() - 1));
// ids.add(id);
//改变装备状态 //改变装备状态
DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(id); DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(id);
//纵向配发
if (allotBillSaveVo.getMatchingRange() == 1){
//如果当前装备的配用范围不是省以下纵向
if (deviceLibraryEntity.getMatchingRange()!=1){
//判断是否存在省以下纵向的相同列装装备
PackingLibrary packingLibrary = packingLibraryService.getOne(deviceLibraryEntity.getPackingId());
PackingLibrary packingLibrary1;
if(packingLibrary.getIsPart() == 1){
//拿到装备目录
PackingLibrary devLibrary = getPackingLibrary(packingLibrary);
List<PackingLibrary> packingLibraries = packingLibraryService.findSamePacking1(devLibrary.getPartParentId(), 1, devLibrary.getType(), packingLibrary.getStyle(), devLibrary.getName(), packingLibrary.getSecretLevel(), devLibrary.getInvisibleRange());
List<PackingLibrary> collect = packingLibraries.stream().sorted(Comparator.comparing(PackingLibrary::getCreateTime).reversed()).collect(Collectors.toList());
packingLibrary1 = collect.get(0);
}else {
packingLibrary1 = packingLibraryService.findSamePacking(packingLibrary.getPartParentId(), 1, packingLibrary.getType(), packingLibrary.getStyle(), packingLibrary.getName(), packingLibrary.getSecretLevel(), packingLibrary.getInvisibleRange());
}
//不存在直接抛出异常
if (packingLibrary1 == null) {
PackingLibrary library = getPackingLibrary(packingLibrary);
getPackingLibrary2(library,library.getPartParentId(),1,packingLibraryHashMap);
}else {
packingLibraryHashMap.put(packingLibrary1.getModel()+packingLibrary1.getName()+1,packingLibrary1);
}
} Integer matchingRange = allotBillSaveVo.getMatchingRange();
}
//横向配发
else if (allotBillSaveVo.getMatchingRange() == 2){
//如果当前装备的配用范围不是省以下纵向
if (deviceLibraryEntity.getMatchingRange()!=2){
//判断是否存在省以下纵向的相同列装装备
PackingLibrary packingLibrary = packingLibraryService.getOne(deviceLibraryEntity.getPackingId());
PackingLibrary packingLibrary1;
if(packingLibrary.getIsPart() == 1){
//拿到装备目录
PackingLibrary devLibrary = getPackingLibrary(packingLibrary);
List<PackingLibrary> packingLibraries = packingLibraryService.findSamePacking1(devLibrary.getPartParentId(), 2, devLibrary.getType(), packingLibrary.getStyle(), devLibrary.getName(), packingLibrary.getSecretLevel(), devLibrary.getInvisibleRange());
List<PackingLibrary> collect = packingLibraries.stream().sorted(Comparator.comparing(PackingLibrary::getCreateTime).reversed()).collect(Collectors.toList());
packingLibrary1 = collect.get(0);
}else {
packingLibrary1 = packingLibraryService.findSamePacking(packingLibrary.getPartParentId(), 2, packingLibrary.getType(), packingLibrary.getStyle(), packingLibrary.getName(), packingLibrary.getSecretLevel(), packingLibrary.getInvisibleRange());
} //不存在直接抛出异常
if (packingLibrary1 == null) {
PackingLibrary library = getPackingLibrary(packingLibrary);
getPackingLibrary2(library,library.getPartParentId(),2,packingLibraryHashMap);
}else {
packingLibraryHashMap.put(packingLibrary1.getModel()+packingLibrary1.getName()+2,packingLibrary1);
}
} Integer matchingRange1 = deviceLibraryEntity.getMatchingRange();
} // if (matchingRange == 1 || matchingRange == 2 || matchingRange == 3){
else if (allotBillSaveVo.getMatchingRange() == 3){ // isMatching(1, matchingRange1, deviceLibraryEntity, packingLibraryHashMap);
//如果当前装备的配用范围不是省以下横向 // }
if (deviceLibraryEntity.getMatchingRange()!=3) {
PackingLibrary packingLibrary = packingLibraryService.getOne(deviceLibraryEntity.getPackingId());
PackingLibrary packingLibrary1;
if(packingLibrary.getIsPart() == 1){
//拿到装备目录
PackingLibrary devLibrary = getPackingLibrary(packingLibrary);
List<PackingLibrary> packingLibraries = packingLibraryService.findSamePacking1(devLibrary.getPartParentId(), 3, devLibrary.getType(), packingLibrary.getStyle(), devLibrary.getName(), packingLibrary.getSecretLevel(), devLibrary.getInvisibleRange());
List<PackingLibrary> collect = packingLibraries.stream().sorted(Comparator.comparing(PackingLibrary::getCreateTime).reversed()).collect(Collectors.toList());
packingLibrary1 = collect.get(0);
}else {
packingLibrary1 = packingLibraryService.findSamePacking(packingLibrary.getPartParentId(), 3, packingLibrary.getType(), packingLibrary.getStyle(), packingLibrary.getName(), packingLibrary.getSecretLevel(), packingLibrary.getInvisibleRange());
}
if (packingLibrary1 == null){
PackingLibrary library = getPackingLibrary(packingLibrary);
getPackingLibrary2(library,library.getPartParentId(),3,packingLibraryHashMap);
}else {
packingLibraryHashMap.put(packingLibrary1.getModel()+packingLibrary1.getName()+3,packingLibrary1);
}
}
} if(matchingRange == 1){
isMatching(1, matchingRange1, deviceLibraryEntity, packingLibraryHashMap);
}
if(matchingRange == 2){
isMatching(2, matchingRange1, deviceLibraryEntity, packingLibraryHashMap);
}
if(matchingRange == 3){
isMatching(3, matchingRange1, deviceLibraryEntity, packingLibraryHashMap);
} }
} }
} }
}
public void allotmentOfVariousRangeEquipment(DeviceLibrary deviceLibraryEntity, Map<String, PackingLibrary> packingLibraryHashMap, Integer matchingRange) {
//判断是否存在省以下纵向的相同列装装备
PackingLibrary packingLibrary = packingLibraryService.getOne(deviceLibraryEntity.getPackingId());
PackingLibrary packingLibrary1 = null;
if (packingLibrary.getIsPart() == 1) {
//拿到装备目录
PackingLibrary devLibrary = getPackingLibrary(packingLibrary);
List<PackingLibrary> packingLibraries = packingLibraryService.findSamePacking1(devLibrary.getPartParentId(), matchingRange, devLibrary.getType(), packingLibrary.getStyle(), devLibrary.getName(), packingLibrary.getSecretLevel(), devLibrary.getInvisibleRange());
if(packingLibraries != null){
List<PackingLibrary> collect = packingLibraries.stream().sorted(Comparator.comparing(PackingLibrary::getCreateTime).reversed()).collect(Collectors.toList());
packingLibrary1 = collect.get(0);
}
} else {
packingLibrary1 = packingLibraryService.findSamePacking(packingLibrary.getPartParentId(), matchingRange, packingLibrary.getType(), packingLibrary.getStyle(), packingLibrary.getName(), packingLibrary.getSecretLevel(), packingLibrary.getInvisibleRange());
}
//不存在直接抛出异常
if (packingLibrary1 == null) {
PackingLibrary library = getPackingLibrary(packingLibrary);
getPackingLibrary2(library, library.getPartParentId(), matchingRange, packingLibraryHashMap);
} else {
packingLibraryHashMap.put(packingLibrary1.getModel() + packingLibrary1.getName() + matchingRange, packingLibrary1);
}
}
public void isMatching(Integer matchingRange, Integer matchingRange1, DeviceLibrary deviceLibraryEntity, Map<String, PackingLibrary> packingLibraryHashMap) {
//如果当前装备的配用范围不是省以下纵向
if (matchingRange1 != matchingRange) {
allotmentOfVariousRangeEquipment(deviceLibraryEntity, packingLibraryHashMap, matchingRange);
}
}
public void allotmentEquipment(Integer id, Map<Integer,Integer> changeMap,DeviceLibrary deviceLibraryEntity,Map<String, PackingLibrary> packingLibraryHashMap, Integer matchingRange,List<FileVo> fileVoList,TaskBto saveEntity) {
//如果当前装备的配用范围不是省以下纵向
if (deviceLibraryEntity.getMatchingRange() != matchingRange) {
//判断changeMap是否存在该列装的转换信息
//判断是否存在省以下纵向的相同列装装备
PackingLibrary packingLibrary1 = packingLibraryHashMap.get(deviceLibraryEntity.getModel() + deviceLibraryEntity.getName() + 1);
//不存在直接抛出异常
if (packingLibrary1 != null) {
changeMap.put(deviceLibraryEntity.getPackingId(), packingLibrary1.getId());
deviceLibraryEntity.setPackingId(packingLibrary1.getId());
deviceLibraryEntity.setMatchingRange(matchingRange);
} else {
log.info("[配发] 没有在packingLibraryHashMap找到key:{}的列装", deviceLibraryEntity.getModel() + deviceLibraryEntity.getName() + 1);
}
//存装备日志
DeviceLogDto deviceLogDto = new DeviceLogDto(id, "纵向配发将所属列装由" + deviceLibraryEntity.getMatchingRangeName() + "的列装改为" + configCache.getMatchingRangeMap().get(1) + "的列装", fileVoList, saveEntity.getId(), null);
deviceLogService.addLog(deviceLogDto);
}
}
......
...@@ -12,6 +12,7 @@ import com.tykj.dev.device.library.repository.DeviceLibraryDao; ...@@ -12,6 +12,7 @@ import com.tykj.dev.device.library.repository.DeviceLibraryDao;
import com.tykj.dev.device.library.service.DeviceLibraryService; import com.tykj.dev.device.library.service.DeviceLibraryService;
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.service.TaskService;
import com.tykj.dev.device.user.subject.service.UserPublicService; import com.tykj.dev.device.user.subject.service.UserPublicService;
import com.tykj.dev.misc.utils.JacksonUtil; import com.tykj.dev.misc.utils.JacksonUtil;
import com.tykj.dev.misc.utils.StringSplitUtil; import com.tykj.dev.misc.utils.StringSplitUtil;
...@@ -50,6 +51,9 @@ public class AllotBillSelectController { ...@@ -50,6 +51,9 @@ public class AllotBillSelectController {
@Autowired @Autowired
private DeviceLibraryDao deviceLibraryDao; private DeviceLibraryDao deviceLibraryDao;
@Autowired
private TaskService taskService;
@ApiOperation(value = "查询配发单", notes = "可以通过这个接口查询配发单") @ApiOperation(value = "查询配发单", notes = "可以通过这个接口查询配发单")
@PostMapping(value = "/archives/allot/summary") @PostMapping(value = "/archives/allot/summary")
public ResponseEntity selectAllotBill(@RequestBody AllotBillSelectVo allotBillSelectVo) { public ResponseEntity selectAllotBill(@RequestBody AllotBillSelectVo allotBillSelectVo) {
...@@ -64,13 +68,14 @@ public class AllotBillSelectController { ...@@ -64,13 +68,14 @@ public class AllotBillSelectController {
return ResponseEntity.ok(page); return ResponseEntity.ok(page);
} }
@ApiOperation(value = "查询配发单详情页", notes = "可以通过这个接口查询配发单") @ApiOperation(value = "查询配发单详情页,通过billId查询", notes = "可以通过这个接口查询配发单")
@GetMapping(value = "/archives/allot/detail/{id}") @GetMapping(value = "/archives/allot/detail/{id}")
public ResponseEntity selectAllotBillDetail(@PathVariable("id") int id) { public ResponseEntity selectAllotBillDetail(@PathVariable("id") int id) {
//获取所有装备id map //获取所有装备id map
Map<Integer,DeviceLibrary> deviceLibraryMap = deviceLibraryService.getAllDeviceMap(); Map<Integer,DeviceLibrary> deviceLibraryMap = deviceLibraryService.getAllDeviceMap();
//返回的数组 //返回的数组
List<Object> list = new ArrayList<>(); List<Object> list = new ArrayList<>();
// Integer billId = taskService.get(id).getBillId();
//set账单用户名称并添加 //set账单用户名称并添加
AllotBill allotBillEntity = allotBillService.getOne(id); AllotBill allotBillEntity = allotBillService.getOne(id);
allotBillEntity.setSenderUserA(userService.getOne(allotBillEntity.getSendUseraId()).getName()); allotBillEntity.setSenderUserA(userService.getOne(allotBillEntity.getSendUseraId()).getName());
...@@ -102,14 +107,15 @@ public class AllotBillSelectController { ...@@ -102,14 +107,15 @@ public class AllotBillSelectController {
return ResponseEntity.ok(list); return ResponseEntity.ok(list);
} }
@ApiOperation(value = "查询退回单详情页", notes = "可以通过这个接口查询退回单") @ApiOperation(value = "查询退回单详情页,通过billId查询", notes = "可以通过这个接口查询退回单")
@GetMapping(value = "/archives/back/detail/{id}") @GetMapping(value = "/archives/back/detail/{id}")
public ResponseEntity selectBackBillDetail(@PathVariable("id") int id) { public ResponseEntity selectBackBillDetail(@PathVariable("id") int id) {
//获取所有装备id map //获取所有装备id map
Map<Integer,DeviceLibrary> deviceLibraryMap = deviceLibraryService.getAllDeviceMap(); Map<Integer,DeviceLibrary> deviceLibraryMap = deviceLibraryService.getAllDeviceMap();
//返回的数组 //返回的数组
List<Object> list = new ArrayList<>(); List<Object> list = new ArrayList<>();
//set账单用户名称并添加 //set账单用户名称并添
// Integer billId = taskService.get(id).getBillId();
AllotBackBill allotBillEntity = allotBackBillService.getOne(id); AllotBackBill allotBillEntity = allotBackBillService.getOne(id);
allotBillEntity.setSenderUserA(userService.getOne(allotBillEntity.getSendUseraId()).getName()); allotBillEntity.setSenderUserA(userService.getOne(allotBillEntity.getSendUseraId()).getName());
allotBillEntity.setSenderUserB(allotBillEntity.getAgent()); allotBillEntity.setSenderUserB(allotBillEntity.getAgent());
...@@ -139,4 +145,84 @@ public class AllotBillSelectController { ...@@ -139,4 +145,84 @@ public class AllotBillSelectController {
list.add(libraryEntities); list.add(libraryEntities);
return ResponseEntity.ok(list); return ResponseEntity.ok(list);
} }
@ApiOperation(value = "查询配发单详情页,通过taskId查询", notes = "可以通过这个接口查询配发单")
@GetMapping(value = "/archives/allot/detail1/{id}")
public ResponseEntity selectAllotBillDetail2(@PathVariable("id") int id) {
//获取所有装备id map
Map<Integer,DeviceLibrary> deviceLibraryMap = deviceLibraryService.getAllDeviceMap();
//返回的数组
List<Object> list = new ArrayList<>();
Integer billId = taskService.get(id).getBillId();
//set账单用户名称并添加
AllotBill allotBillEntity = allotBillService.getOne(billId);
allotBillEntity.setSenderUserA(userService.getOne(allotBillEntity.getSendUseraId()).getName());
allotBillEntity.setSenderUserB(allotBillEntity.getAgent());
if (allotBillEntity.getReceiveUseraId() != null) {
allotBillEntity.setReceiveUserA(userService.getOne(allotBillEntity.getReceiveUseraId()).getName());
}
if (allotBillEntity.getReceiveUserbId() != null) {
allotBillEntity.setReceiveUserB(userService.getOne(allotBillEntity.getReceiveUserbId()).getName());
}
//转换文件
allotBillEntity.setSendFileList(FilesUtil.stringFileToList(allotBillEntity.getSendFiles()));
allotBillEntity.setReceiveFileList(FilesUtil.stringFileToList(allotBillEntity.getReceiveFiles()));
allotBillEntity.setReplyFileList(FilesUtil.stringFileToList(allotBillEntity.getReplyFiles()));
allotBillEntity.setApplyFileList(FilesUtil.stringFileToList(allotBillEntity.getApplyFiles()));
//转换单据
if (allotBillEntity.getScriptJson()!=null){
allotBillEntity.setScripts(JacksonUtil.readValue(allotBillEntity.getScriptJson(),new TypeReference<List<ScriptSaveVo>>() {}));
}
list.add(allotBillEntity);
List<DeviceLibrary> libraryEntities = new ArrayList<>();
//如果接收装备详情不为空,分隔装备id并添加
if (allotBillEntity.getAllotCheckDetail() != null) {
for (Integer deviceId : StringSplitUtil.split(allotBillEntity.getAllotCheckDetail())) {
libraryEntities.add(deviceLibraryMap.get(deviceId));
}
}
list.add(libraryEntities);
return ResponseEntity.ok(list);
}
@ApiOperation(value = "查询退回单详情页,通过taskId查询", notes = "可以通过这个接口查询退回单")
@GetMapping(value = "/archives/back/detail1/{id}")
public ResponseEntity selectBackBillDetail2(@PathVariable("id") int id) {
//获取所有装备id map
Map<Integer,DeviceLibrary> deviceLibraryMap = deviceLibraryService.getAllDeviceMap();
//返回的数组
List<Object> list = new ArrayList<>();
//set账单用户名称并添
Integer billId = taskService.get(id).getBillId();
AllotBackBill allotBillEntity = allotBackBillService.getOne(billId);
allotBillEntity.setSenderUserA(userService.getOne(allotBillEntity.getSendUseraId()).getName());
allotBillEntity.setSenderUserB(allotBillEntity.getAgent());
if (allotBillEntity.getReceiveUseraId() != null) {
allotBillEntity.setReceiveUserA(userService.getOne(allotBillEntity.getReceiveUseraId()).getName());
}
if (allotBillEntity.getReceiveUserbId() !=null){
allotBillEntity.setReceiveUserB(userService.getOne(allotBillEntity.getReceiveUserbId()).getName());
}
//转换文件
allotBillEntity.setSendFileList(FilesUtil.stringFileToList(allotBillEntity.getSendFiles()));
allotBillEntity.setReceiveFileList(FilesUtil.stringFileToList(allotBillEntity.getReceiveFiles()));
allotBillEntity.setReplyFileList(FilesUtil.stringFileToList(allotBillEntity.getReplyFiles()));
allotBillEntity.setApplyFileList(FilesUtil.stringFileToList(allotBillEntity.getApplyFiles()));
//转换单据
if (allotBillEntity.getScriptJson()!=null){
allotBillEntity.setScripts(JacksonUtil.readValue(allotBillEntity.getScriptJson(),new TypeReference<List<ScriptSaveVo>>() {}));
}
list.add(allotBillEntity);
List<DeviceLibrary> libraryEntities = new ArrayList<>();
//如果接收装备详情不为空,分隔装备id并添加
if (allotBillEntity.getBackCheckDetail() != null) {
for (Integer deviceId : StringSplitUtil.split(allotBillEntity.getBackCheckDetail())) {
libraryEntities.add(deviceLibraryMap.get(deviceId));
}
}
list.add(libraryEntities);
return ResponseEntity.ok(list);
}
} }
...@@ -51,4 +51,10 @@ public interface AllotBillService { ...@@ -51,4 +51,10 @@ public interface AllotBillService {
* 根据id删除配发单 * 根据id删除配发单
*/ */
void delete(Integer id); void delete(Integer id);
// /**
// * @param
// * *在配发存储的时候用到存储数据库
// */
// void updateAllot();
} }
...@@ -608,6 +608,15 @@ public class DeviceLibraryController { ...@@ -608,6 +608,15 @@ public class DeviceLibraryController {
return ResultUtil.success(deviceLibraries.stream().filter(deviceLibrary1 -> !deviceLibrary1.getId().equals(id) && deviceLibrary1.getLifeStatus() == 2 && deviceLibrary1.getOwnUnit().equals(userUtils.getCurrentUserUnitName()) &&deviceLibrary1.getLocationUnit().equals(userUtils.getCurrentUserUnitName())).collect(Collectors.toList())); return ResultUtil.success(deviceLibraries.stream().filter(deviceLibrary1 -> !deviceLibrary1.getId().equals(id) && deviceLibrary1.getLifeStatus() == 2 && deviceLibrary1.getOwnUnit().equals(userUtils.getCurrentUserUnitName()) &&deviceLibrary1.getLocationUnit().equals(userUtils.getCurrentUserUnitName())).collect(Collectors.toList()));
} }
@ApiOperation(value = "修改装备的存放位置")
@PostMapping("/updateDeviceLibraryLocation")
public void updateDeviceLibraryLocation(@RequestBody DeviceStorageLocation deviceStorageLocation){
DeviceLibrary deviceLibrary = deviceLibraryService.getOne(deviceStorageLocation.getDevId());
//添加修改存放装备位置
deviceLibrary.setStorageLocation(deviceStorageLocation.getStorageLocation());
DeviceLogDto deviceLogDto = new DeviceLogDto(deviceStorageLocation.getDevId(), "将存放位置改为"+deviceStorageLocation.getStorageLocation(), null,null,null);
deviceLogService.addLog(deviceLogDto);
deviceLibraryService.update(deviceLibrary);
}
} }
package com.tykj.dev.device.library.subject.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* DATE:2021-6-24
* Author:zsp
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
@ApiModel("装备位置")
public class DeviceStorageLocation {
@ApiModelProperty(value = "装备id")
private Integer devId;
@ApiModelProperty(value = "库存位置")
private String storageLocation;
}
...@@ -386,7 +386,7 @@ public class StorageBillController { ...@@ -386,7 +386,7 @@ public class StorageBillController {
if (storageBillSaveVo.getTaskId()==null) { if (storageBillSaveVo.getTaskId()==null) {
storageBillEntity = storageBillService.addEntity(storageBillSaveVo.toDo()); storageBillEntity = storageBillService.addEntity(storageBillSaveVo.toDo());
//2.发起入库任务 //2.发起入库任务
TaskBto taskBto = new TaskBto(StatusEnum.END.id, storageBillSaveVo.getSendUnit()+"进行了入库业务", null, ".", storageBillEntity.getId(), 2, userUtils.getCurrentUnitId(), 0, null, userIds); TaskBto taskBto = new TaskBto(StatusEnum.END.id, "入库了"+storageBillSaveVo.getStorageBillDetails().stream().map(storageBillDetail -> storageBillDetail.getModel()).collect(Collectors.toList())+"型号"+"入库业务", null, ".", storageBillEntity.getId(), 2, userUtils.getCurrentUnitId(), 0, null, userIds);
taskEntity1 = taskService.start(taskBto); taskEntity1 = taskService.start(taskBto);
} }
else { else {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论