提交 b0ff8938 authored 作者: 邓砥奕's avatar 邓砥奕

更新

上级 f3833cc9
...@@ -5,7 +5,6 @@ import com.tykj.dev.config.cache.ConfigCache; ...@@ -5,7 +5,6 @@ import com.tykj.dev.config.cache.ConfigCache;
import com.tykj.dev.config.swagger.AutoDocument; import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.device.allot.service.AllotBackBillService; import com.tykj.dev.device.allot.service.AllotBackBillService;
import com.tykj.dev.device.allot.service.AllotBillService; import com.tykj.dev.device.allot.service.AllotBillService;
import com.tykj.dev.device.allot.subject.domin.AllotBackBill;
import com.tykj.dev.device.allot.subject.domin.AllotBill; import com.tykj.dev.device.allot.subject.domin.AllotBill;
import com.tykj.dev.device.allot.subject.vo.*; import com.tykj.dev.device.allot.subject.vo.*;
import com.tykj.dev.device.file.service.FilesUtil; import com.tykj.dev.device.file.service.FilesUtil;
...@@ -30,7 +29,6 @@ import com.tykj.dev.device.user.subject.service.AreaService; ...@@ -30,7 +29,6 @@ import com.tykj.dev.device.user.subject.service.AreaService;
import com.tykj.dev.device.user.subject.service.UnitsService; import com.tykj.dev.device.user.subject.service.UnitsService;
import com.tykj.dev.device.user.subject.service.UserPublicService; import com.tykj.dev.device.user.subject.service.UserPublicService;
import com.tykj.dev.device.user.util.UserUtils; import com.tykj.dev.device.user.util.UserUtils;
import com.tykj.dev.misc.base.BusinessEnum;
import com.tykj.dev.misc.base.ResultObj; import com.tykj.dev.misc.base.ResultObj;
import com.tykj.dev.misc.base.StatusEnum; import com.tykj.dev.misc.base.StatusEnum;
import com.tykj.dev.misc.exception.ApiException; import com.tykj.dev.misc.exception.ApiException;
...@@ -148,21 +146,26 @@ public class AllotBillController { ...@@ -148,21 +146,26 @@ public class AllotBillController {
@PostMapping(value = "/addAllotBill") @PostMapping(value = "/addAllotBill")
@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.添加配发单
AllotBill a = allotBillSaveVo.toDo(); AllotBill a = allotBillSaveVo.toDo();
if (allotBillSaveVo.getTaskId()==null) { //保存后的实体
a.setSendUseraId(userUtils.getCurrentUserId());
}
AllotBill allotBillEntity; AllotBill allotBillEntity;
//如果是直接发起(不是草稿,没有taskId),当前操作人为发件方A岗,添加账单
if (allotBillSaveVo.getTaskId()==null){ if (allotBillSaveVo.getTaskId()==null){
a.setSendUseraId(userUtils.getCurrentUserId());
allotBillEntity = allotBillService.addEntity(a); allotBillEntity = allotBillService.addEntity(a);
} }
//从草稿发起
else { else {
//获取草稿账单
AllotBill allotBill = allotBillService.getOne(taskService.get(allotBillSaveVo.getTaskId()).getBillId()); AllotBill allotBill = allotBillService.getOne(taskService.get(allotBillSaveVo.getTaskId()).getBillId());
//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);
} }
...@@ -171,18 +174,20 @@ public class AllotBillController { ...@@ -171,18 +174,20 @@ public class AllotBillController {
} }
allotBillEntity = allotBillService.update(allotBill); allotBillEntity = allotBillService.update(allotBill);
} }
//按照当前时间和保存账单的id拼接生成配发单号并保存
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date()); calendar.setTime(new Date());
int year = calendar.get(Calendar.YEAR); int year = calendar.get(Calendar.YEAR);
String num = "NO:第" + year + "PF" + allotBillEntity.getId() + "号"; String num = "NO:第" + year + "PF" + allotBillEntity.getId() + "号";
allotBillEntity.setNum(num); allotBillEntity.setNum(num);
//生成电子签章id //生成接收方电子签章id
// Long signId = snowflake.creatNextId();
Long signId2 = snowflake.creatNextId(); Long signId2 = snowflake.creatNextId();
//判断是否上传了发送方签章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());
...@@ -192,88 +197,122 @@ public class AllotBillController { ...@@ -192,88 +197,122 @@ public class AllotBillController {
Integer userId = userUtils.getCurrentUserId(); Integer userId = userUtils.getCurrentUserId();
String deviceIdDetail = allotBillEntity.getAllotCheckDetail(); String deviceIdDetail = allotBillEntity.getAllotCheckDetail();
//2.发起任务 //2.发起任务
//构建task涉及人员集合
List<Integer> userIds = new ArrayList<>(); List<Integer> userIds = new ArrayList<>();
userIds.add(userId); userIds.add(userId);
userIds.add(0); userIds.add(0);
//保存后的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, "配发业务", null, ".", billId, 3, userPublicService.findUnitIdByName(allotBillSaveVo.getReceiveUnit()), 1, null, userIds); TaskBto taskBto = new TaskBto(StatusEnum.ALLOTING.id, "配发业务", 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 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);
} }
// if (allotBillSaveVo.getIsSigned()==null||allotBillSaveVo.getIsSigned()!=1) { //生成发件方上传配发单的子任务
TaskBto taskBto2 = new TaskBto(StatusEnum.WAIT_UPLOAD_ALLOT_FILE.id, "配发业务", 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, "配发业务", saveEntity.getId(), saveEntity.getNodeIdDetail() + saveEntity.getId() + ".", saveEntity.getBillId(), 3, userPublicService.findUnitIdByName(allotBillEntity.getSendUnit()), 0, null, Collections.singletonList(0));
taskService.start(taskBto2); taskService.start(taskBto2);
// }
} }
//横向配发
else { else {
TaskBto taskBto2 = new TaskBto(StatusEnum.WAIT_UPLOAD_CROSS_FILE.id, "配发业务", null, ".", billId, 3, userPublicService.findUnitIdByName(allotBillEntity.getSendUnit()), 1, "country", userIds); TaskBto taskBto2 = new TaskBto(StatusEnum.WAIT_UPLOAD_CROSS_FILE.id, "配发业务", null, ".", billId, 3, userPublicService.findUnitIdByName(allotBillEntity.getSendUnit()), 1, "country", userIds);
saveEntity = taskService.start(taskBto2); saveEntity = taskService.start(taskBto2);
} }
List<FileVo> fileVoList = new ArrayList<>(); List<FileVo> fileVoList = new ArrayList<>();
// fileVoList.add(new FileVo("出库确认单", allotBillEntity.getFileName(), allotBillEntity.getFileUrl())); //分解装备id字符串
//存装备日志
String[] strings = deviceIdDetail.split("x"); String[] strings = deviceIdDetail.split("x");
//存放所有出库装备id
List<Integer> ids = new ArrayList<>(); List<Integer> ids = new ArrayList<>();
//横纵向列装转换map //横纵向列装转换map(key:转换前列装id,value:转换后列装id),减少数据库查询
Map<Integer,Integer> changeMap = new HashMap<>(); Map<Integer,Integer> changeMap = new HashMap<>();
for (String s : strings) { for (String s : strings) {
//最后一位原来为装备扫码结果,已弃用
if (s.length() >= 2) { if (s.length() >= 2) {
//去掉最后一位得到装备id
Integer id = Integer.parseInt(s.substring(0, s.length() - 1)); Integer id = Integer.parseInt(s.substring(0, s.length() - 1));
ids.add(id); ids.add(id);
//改变装备状态 //改变装备状态
DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(id); DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(id);
//纵向配发
if (allotBillSaveVo.getAllotType() == 1){ if (allotBillSaveVo.getAllotType() == 1){
//如果当前装备的配用范围不是省以下纵向
if (deviceLibraryEntity.getMatchingRange()!=1){ if (deviceLibraryEntity.getMatchingRange()!=1){
//判断changeMap是否存在该列装的转换信息
if (changeMap.get(deviceLibraryEntity.getPackingId())!=null){
//改变装备所属列装以及配用范围
deviceLibraryEntity.setPackingId(changeMap.get(deviceLibraryEntity.getPackingId()));
deviceLibraryEntity.setMatchingRange(1);
}
else {
//判断是否存在省以下纵向的相同列装装备
PackingLibrary packingLibrary = packingLibraryService.getOne(deviceLibraryEntity.getPackingId()); PackingLibrary packingLibrary = packingLibraryService.getOne(deviceLibraryEntity.getPackingId());
PackingLibrary packingLibrary1 = packingLibraryService.findSamePacking(packingLibrary.getPartParentId(),1,packingLibrary.getType(),packingLibrary.getStyle(),packingLibrary.getName(),packingLibrary.getSecretLevel(),packingLibrary.getInvisibleRange()); PackingLibrary packingLibrary1 = packingLibraryService.findSamePacking(packingLibrary.getPartParentId(), 1, packingLibrary.getType(), packingLibrary.getStyle(), packingLibrary.getName(), packingLibrary.getSecretLevel(), packingLibrary.getInvisibleRange());
if (packingLibrary1==null){ //不存在直接抛出异常
throw new ApiException(ResponseEntity.status(20000).body(new ResultObj("序列号为"+deviceLibraryEntity.getSeqNumber()+"的装备所属列装不存在配用范围为省对下纵向的相同列装装备"))); if (packingLibrary1 == null) {
throw new ApiException(ResponseEntity.status(20000).body(new ResultObj("序列号为" + deviceLibraryEntity.getSeqNumber() + "的装备所属列装不存在配用范围为省对下纵向的相同列装装备")));
} }
//存在的话改变装备所属列装以及配用范围
else { else {
changeMap.put(deviceLibraryEntity.getPackingId(),packingLibrary1.getId());
deviceLibraryEntity.setPackingId(packingLibrary1.getId()); deviceLibraryEntity.setPackingId(packingLibrary1.getId());
deviceLibraryEntity.setMatchingRange(1); deviceLibraryEntity.setMatchingRange(1);
} }
// deviceLibraryEntity.setAllotType(2); }
//存装备日志
DeviceLogDto deviceLogDto = new DeviceLogDto(id, "纵向配发将所属列装由" + deviceLibraryEntity.getMatchingRangeName() + "的列装改为"+configCache.getMatchingRangeMap().get(1)+"的列装", fileVoList); DeviceLogDto deviceLogDto = new DeviceLogDto(id, "纵向配发将所属列装由" + deviceLibraryEntity.getMatchingRangeName() + "的列装改为"+configCache.getMatchingRangeMap().get(1)+"的列装", fileVoList);
deviceLogService.addLog(deviceLogDto); deviceLogService.addLog(deviceLogDto);
} }
//改变装备生命状态为配发
deviceLibraryEntity.setLifeStatus(3); deviceLibraryEntity.setLifeStatus(3);
//改变装备管理状态为不在本单位
deviceLibraryEntity.setManageStatus(0); deviceLibraryEntity.setManageStatus(0);
} }
//横向配发
else { else {
if (deviceLibraryEntity.getMatchingRange()!=3){ //如果当前装备的配用范围不是省以下横向
if (deviceLibraryEntity.getMatchingRange()!=3) {
//判断changeMap是否存在该列装的转换信息
if (changeMap.get(deviceLibraryEntity.getPackingId())!=null){ if (changeMap.get(deviceLibraryEntity.getPackingId())!=null){
//改变装备所属列装以及配用范围
deviceLibraryEntity.setPackingId(changeMap.get(deviceLibraryEntity.getPackingId())); deviceLibraryEntity.setPackingId(changeMap.get(deviceLibraryEntity.getPackingId()));
deviceLibraryEntity.setMatchingRange(3); deviceLibraryEntity.setMatchingRange(3);
} }
else { else {
//判断是否存在省以下横向的相同列装装备
PackingLibrary packingLibrary = packingLibraryService.getOne(deviceLibraryEntity.getPackingId()); PackingLibrary packingLibrary = packingLibraryService.getOne(deviceLibraryEntity.getPackingId());
PackingLibrary packingLibrary1 = packingLibraryService.findSamePacking(packingLibrary.getPartParentId(), 3,packingLibrary.getType(),packingLibrary.getStyle(),packingLibrary.getName(),packingLibrary.getSecretLevel(),packingLibrary.getInvisibleRange()); PackingLibrary packingLibrary1 = packingLibraryService.findSamePacking(packingLibrary.getPartParentId(), 3, packingLibrary.getType(), packingLibrary.getStyle(), packingLibrary.getName(), packingLibrary.getSecretLevel(), packingLibrary.getInvisibleRange());
//不存在直接抛出异常
if (packingLibrary1 == null) { if (packingLibrary1 == null) {
throw new ApiException(ResponseEntity.status(20000).body(new ResultObj("序列号为" + deviceLibraryEntity.getSeqNumber() + "的装备所属列装不存在配用范围为省对下横向的相同列装装备"))); throw new ApiException(ResponseEntity.status(20000).body(new ResultObj("序列号为" + deviceLibraryEntity.getSeqNumber() + "的装备所属列装不存在配用范围为省对下横向的相同列装装备")));
} }
//存在的话改变装备所属列装以及配用范围
else { else {
changeMap.put(deviceLibraryEntity.getPackingId(),packingLibrary1.getId()); changeMap.put(deviceLibraryEntity.getPackingId(), packingLibrary1.getId());
changeMap.put(packingLibrary1.getId(),deviceLibraryEntity.getPackingId());
deviceLibraryEntity.setPackingId(packingLibrary1.getId()); deviceLibraryEntity.setPackingId(packingLibrary1.getId());
deviceLibraryEntity.setMatchingRange(3); deviceLibraryEntity.setMatchingRange(3);
} }
} }
// deviceLibraryEntity.setAllotType(1); //存装备日志
DeviceLogDto deviceLogDto = new DeviceLogDto(id, "横向配发将所属列装由" + deviceLibraryEntity.getMatchingRangeName() + "的列装改为"+configCache.getMatchingRangeMap().get(3)+"的列装", fileVoList); DeviceLogDto deviceLogDto = new DeviceLogDto(id, "横向配发将所属列装由" + deviceLibraryEntity.getMatchingRangeName() + "的列装改为" + configCache.getMatchingRangeMap().get(3) + "的列装", fileVoList);
deviceLogService.addLog(deviceLogDto); deviceLogService.addLog(deviceLogDto);
} }
//横向直接改变装备所属所在
deviceLibraryEntity.setLocationUnit(allotBillSaveVo.getReceiveUnit()); deviceLibraryEntity.setLocationUnit(allotBillSaveVo.getReceiveUnit());
deviceLibraryEntity.setOwnUnit(allotBillSaveVo.getReceiveUnit()); deviceLibraryEntity.setOwnUnit(allotBillSaveVo.getReceiveUnit());
} }
deviceLibraryService.update(deviceLibraryEntity); deviceLibraryService.update(deviceLibraryEntity);
//存装备日志
DeviceLogDto deviceLogDto = new DeviceLogDto(id, "对" + allotBillEntity.getReceiveUnit() + "发起配发", fileVoList); DeviceLogDto deviceLogDto = new DeviceLogDto(id, "对" + allotBillEntity.getReceiveUnit() + "发起配发", fileVoList);
deviceLogService.addLog(deviceLogDto); deviceLogService.addLog(deviceLogDto);
} }
...@@ -282,21 +321,25 @@ public class AllotBillController { ...@@ -282,21 +321,25 @@ public class AllotBillController {
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();
//set配发单四个人中文名
allotBill.setSenderUserA(userService.getOne(allotBill.getSendUseraId()).getName()); allotBill.setSenderUserA(userService.getOne(allotBill.getSendUseraId()).getName());
allotBill.setSenderUserB(allotBill.getAgent()); allotBill.setSenderUserB(allotBill.getAgent());
if (allotBill.getReceiveUseraId() != null) { if (allotBill.getReceiveUseraId() != null) {
...@@ -305,132 +348,68 @@ public class AllotBillController { ...@@ -305,132 +348,68 @@ public class AllotBillController {
if (allotBill.getReceiveUserbId() != null) { if (allotBill.getReceiveUserbId() != null) {
allotBill.setReceiveUserB(userService.getOne(allotBill.getReceiveUserbId()).getName()); allotBill.setReceiveUserB(userService.getOne(allotBill.getReceiveUserbId()).getName());
} }
//set单据集合
allotBill.setSendFileList(FilesUtil.stringFileToList(allotBill.getSendFiles())); allotBill.setSendFileList(FilesUtil.stringFileToList(allotBill.getSendFiles()));
allotBill.setReplyFileList(FilesUtil.stringFileToList(allotBill.getReplyFiles())); allotBill.setReplyFileList(FilesUtil.stringFileToList(allotBill.getReplyFiles()));
//输出配发单给前端
return ResponseEntity.ok(new ResultObj(allotBill, "发起成功")); return ResponseEntity.ok(new ResultObj(allotBill, "发起成功"));
} }
@ApiOperation(value = "配发审核", notes = "可以通过这个接口对配发审核")
@PostMapping(value = "/allotConfirm")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity allotConfirm(@RequestBody @Validated AllotBillConfirmVo allotBillConfirmVo) {
TaskBto taskBto = taskService.get(allotBillConfirmVo.getTaskId());
//1.审核通过,改变装备状态,审核任务完成,发起新的配发接收任务
if (allotBillConfirmVo.getStatus() == 0) {
//更新账单状态
AllotBill allotBillEntity = allotBillService.getOne(taskBto.getBillId());
allotBillEntity.setAllotStatus(2);
allotBillEntity.setSendTime(TimestampUtil.getCurrentTimestamp());
allotBillService.update(allotBillEntity);
//task推至下一阶段
TaskBto taskBto1 = taskService.moveToNext(taskBto, allotBillEntity.getReceiveUseraId());
taskBto1.setOwnUnit(userPublicService.findUnitIdByName(allotBillEntity.getReceiveUnit()));
taskService.update(taskBto1);
//获取装备信息
String deviceIdDetail = allotBillEntity.getAllotCheckDetail();
String[] strings = deviceIdDetail.split("x");
List<Integer> ids = new ArrayList<>();
for (String s : strings) {
if (s.length() >= 2) {
Integer id = Integer.parseInt(s.substring(0, s.length() - 1));
ids.add(id);
//改变装备状态
DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(id);
deviceLibraryEntity.setLifeStatus(3);
deviceLibraryEntity.setManageStatus(0);
//存装备日志
DeviceLogDto deviceLogDto = new DeviceLogDto(id, "审核成功并出库", null);
deviceLogService.addLog(deviceLogDto);
deviceLibraryService.update(deviceLibraryEntity);
}
}
//添加出库白名单
inputOutputDeviceService.addWhiteDevices(ids, userUtils.getCurrentUnitId(), 1);
log.info("[配发模块]:配发审核成功并出库");
myWebSocket.sendMessage1();
return ResponseEntity.ok("审核成功");
}
//2.审核失败
if (allotBillConfirmVo.getStatus() == 1) {
//业务封存
taskService.update(taskService.moveToArchive(taskBto));
//更新账单状态
AllotBill allotBillEntity = allotBillService.getOne(taskBto.getBillId());
allotBillEntity.setAllotStatus(1);
allotBillService.update(allotBillEntity);
String deviceIdDetail = allotBillEntity.getAllotCheckDetail();
String[] strings = deviceIdDetail.split("x");
//添加装备日志
for (String s : strings) {
if (s.length() >= 2) {
Integer id = Integer.parseInt(s.substring(0, s.length() - 1));
DeviceLogDto deviceLogDto = new DeviceLogDto(id, "配发出库审核失败", null);
deviceLogService.addLog(deviceLogDto);
}
}
log.info("[配发模块]:配发出库审核失败");
myWebSocket.sendMessage1();
return ResponseEntity.ok("配发审核失败");
} else {
return ResponseEntity.ok("status只能为0或1");
}
}
@ApiOperation(value = "接收配发装备", notes = "可以通过这个接口接收配发装备") @ApiOperation(value = "接收配发装备", notes = "可以通过这个接口接收配发装备")
@PostMapping(value = "/receiveDevice") @PostMapping(value = "/receiveDevice")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity receiveDevice(@RequestBody @Validated AllotReceiveVo allotReceiveVo) { public ResponseEntity receiveDevice(@RequestBody @Validated AllotReceiveVo allotReceiveVo) {
//当前操作人id
Integer userId = userUtils.getCurrentUserId(); Integer userId = userUtils.getCurrentUserId();
//获取当前任务 //获取当前任务
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.getBillFileName()!=null&&allotReceiveVo.getBillFileUrl()!=null) {
// fileVoList.add(new FileVo("配发单", allotReceiveVo.getBillFileName(), allotReceiveVo.getBillFileUrl()));
// }
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
if (allotReceiveVo.getRightSignatureId()!=null&&!"".equals(allotReceiveVo.getRightSignatureId())) { if (allotReceiveVo.getRightSignatureId()!=null&&!"".equals(allotReceiveVo.getRightSignatureId())) {
allotBillEntity.setRightSignatureId(allotReceiveVo.getRightSignatureId()); allotBillEntity.setRightSignatureId(allotReceiveVo.getRightSignatureId());
} }
// fileVoList.add(new FileVo("入库确认单", allotReceiveVo.getReceiveFileName(), allotReceiveVo.getReceiveFileUrl())); //更新账单状态为配发完成
//更新账单状态
allotBillEntity.setAllotStatus(5); allotBillEntity.setAllotStatus(5);
//复制非空相同字段
MapperUtils.copyNoNullProperties(allotReceiveVo, allotBillEntity); MapperUtils.copyNoNullProperties(allotReceiveVo, allotBillEntity);
//set接收时间
allotBillEntity.setReceiveTime(TimestampUtil.getCurrentTimestamp()); allotBillEntity.setReceiveTime(TimestampUtil.getCurrentTimestamp());
//如果收件方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());
} }
allotBillEntity.setBillFileName(allotReceiveVo.getBillFileName());
allotBillEntity.setBillFileUrl(allotReceiveVo.getBillFileUrl());
allotBillService.update(allotBillEntity); allotBillService.update(allotBillEntity);
//添加当前用户为涉及人员
taskService.addInvolveUser(taskBto, userId); taskService.addInvolveUser(taskBto, userId);
// //推至下一阶段 //如果上传了单据或双方都盖章,该业务和子业务都办结
// taskService.update(taskService.moveToNext(taskBto, allotReceiveVo.getReceiveUserbId()));
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);
} }
//生成上级上传单据任务
// List<Integer> userIds = new ArrayList();
// userIds.add(0);
// TaskBto taskBto2 = new TaskBto(StatusEnum.WAIT_UPLOAD_ALLOT_FILE.id, "配发单据", taskBto.getId(), taskBto.getNodeIdDetail()+taskBto.getId()+".", taskBto.getBillId(), 3, userPublicService.findUnitIdByName(allotBillEntity.getSendUnit()), 0, null, userIds);
// taskService.start(taskBto);
//分隔装备id信息 //分隔装备id信息
String deviceIdDetail = allotReceiveVo.getReceiveCheckDetail(); String deviceIdDetail = allotReceiveVo.getReceiveCheckDetail();
String[] strings = deviceIdDetail.split("x"); String[] strings = deviceIdDetail.split("x");
...@@ -438,15 +417,15 @@ public class AllotBillController { ...@@ -438,15 +417,15 @@ public class AllotBillController {
if (s.length() >= 2) { if (s.length() >= 2) {
//接收无误 //接收无误
if ("1".equals(s.substring(s.length() - 1))) { if ("1".equals(s.substring(s.length() - 1))) {
//装备id
Integer id = Integer.parseInt(s.substring(0, s.length() - 1)); Integer id = Integer.parseInt(s.substring(0, s.length() - 1));
//改变装备状态 //改变装备状态、所属所在
DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(id); DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(id);
// deviceLibraryEntity.setLifeStatus(0);
deviceLibraryEntity.setLocationUnit(userUtils.getCurrentUserUnitName()); deviceLibraryEntity.setLocationUnit(userUtils.getCurrentUserUnitName());
deviceLibraryEntity.setLifeStatus(2); deviceLibraryEntity.setLifeStatus(2);
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));
} }
...@@ -473,18 +452,21 @@ public class AllotBillController { ...@@ -473,18 +452,21 @@ public class AllotBillController {
ids.addAll(userDao.findAllByUnitsId(userPublicService.findUnitIdByName(allotBillEntity.getSendUnit())).stream() ids.addAll(userDao.findAllByUnitsId(userPublicService.findUnitIdByName(allotBillEntity.getSendUnit())).stream()
.map(User::getUserId) .map(User::getUserId)
.collect(Collectors.toList())); .collect(Collectors.toList()));
//经办人阅知
if (allotReceiveVo.getReceiveUserbId()!=null) { if (allotReceiveVo.getReceiveUserbId()!=null) {
List<Integer> idList1 = new ArrayList<>(); List<Integer> idList1 = new ArrayList<>();
idList1.add(allotReceiveVo.getReceiveUserbId()); idList1.add(allotReceiveVo.getReceiveUserbId());
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);
} }
//签发人阅知
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
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);
...@@ -493,127 +475,31 @@ public class AllotBillController { ...@@ -493,127 +475,31 @@ public class AllotBillController {
return ResponseEntity.ok("配发接收入库"); return ResponseEntity.ok("配发接收入库");
} }
@ApiOperation(value = "接收配发装备审核", notes = "可以通过这个接口对接收配发装备审核") @ApiOperation(value = "保存配发操作(草稿)", notes = "可以通过这个接口保存配发操作")
@PostMapping(value = "/receiveConfirm")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity receiveConfirm(@RequestBody @Validated AllotReceiveConfirmVo allotReceiveConfirmVo) {
//获取任务和账单
TaskBto taskBto = taskService.get(allotReceiveConfirmVo.getTaskId());
TaskDisposeUtil.isNotSubmit(taskBto.getBillStatus(),StatusEnum.ALLOTING);
AllotBill allotBillEntity = allotBillService.getOne(taskBto.getBillId());
String deviceIdDetail = allotBillEntity.getAllotCheckDetail();
String[] strings = deviceIdDetail.split("x");
//审核通过
// if (allotReceiveConfirmVo.getStatus() == 0) {
// //业务完结
// taskService.update(taskService.moveToEnd(taskBto));
// //更新账单
// allotBillEntity.setAllotStatus(5);
// allotBillService.update(allotBillEntity);
// for (String s : strings) {
// //改变接收无误的装备的状态
// if (s.length() >= 2 && "1".equals(s.substring(s.length() - 1))) {
// Integer id = Integer.parseInt(s.substring(0, s.length() - 1));
// DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(id);
// deviceLibraryEntity.setLifeStatus(2);
// deviceLibraryEntity.setOwnUnit(userUtils.getCurrentUserUnitName());
// deviceLibraryEntity.setManageStatus(1);
// DeviceLogDto deviceLogDto = new DeviceLogDto(id, "审核成功并入库", null);
// deviceLogService.addLog(deviceLogDto);
// deviceLibraryService.update(deviceLibraryEntity);
// }
// }
// log.info("[配发模块]:审核成功并入库");
// myWebSocket.sendMessage1();
// return ResponseEntity.ok("审核成功");
// }
//拒绝接收
if (allotReceiveConfirmVo.getStatus() == 1) {
taskService.addInvolveUser(taskBto, userUtils.getCurrentUserId());
//业务封存
taskService.moveToEnd(taskBto);
//更新账单状态
AllotBill allotBillEntity2 = allotBillService.getOne(taskBto.getBillId());
allotBillEntity2.setAllotStatus(4);
allotBillService.update(allotBillEntity2);
for (String s : strings) {
//改变接收无误的装备的状态
if (s.length() >= 2 && "1".equals(s.substring(s.length() - 1))) {
Integer id = Integer.parseInt(s.substring(0, s.length() - 1));
DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(id);
deviceLibraryEntity.setLifeStatus(3);
deviceLibraryEntity.setLocationUnit(userUtils.getCurrentUserUnitName());
DeviceLogDto deviceLogDto = new DeviceLogDto(id, "拒绝接收配发装备", null);
deviceLogService.addLog(deviceLogDto);
deviceLibraryService.update(deviceLibraryEntity);
}
}
//发送阅知信息
List<Integer> ids = userPublicService.findOtherUser(userUtils.getCurrentUserId());
ids.addAll(userDao.findAllByUnitsId(userPublicService.findUnitIdByName(allotBillEntity.getSendUnit())).stream()
.map(User::getUserId)
.collect(Collectors.toList()));
MessageBto messageBto = new MessageBto(taskBto.getId(),taskBto.getBusinessType(),"拒绝接收配发装备",ids);
messageService.add(messageBto);
//生成配发退回单
AllotBackBill allotBackBill =new AllotBackBill();
allotBackBill.setAllotBillId(taskBto.getBillId());
allotBackBill.setSendUseraId(userUtils.getCurrentUserId());
allotBackBill.setSendUnit(userUtils.getCurrentUserUnitName());
allotBackBill.setReceiveUnit(allotBillEntity.getSendUnit());
allotBackBill.setBackCheckDetail(allotBillEntity.getAllotCheckDetail());
AllotBackBill allotBackBill1 = allotBackBillService.addEntity(allotBackBill);
Calendar calendar = Calendar.getInstance();
calendar.setTime(allotBackBill1.getCreateTime());
int year = calendar.get(Calendar.YEAR);
String num = "NO:第" + year + "TH" + allotBackBill1.getId() + "号";
allotBackBill1.setNum(num);
allotBackBillService.update(allotBackBill1);
//生成配发退回子业务
List<Integer> userIds = new ArrayList<>();
userIds.add(userUtils.getCurrentUserId());
userIds.add(0);
TaskBto taskBto1 = new TaskBto(StatusEnum.ALLOT_BACKING.id, "配发退回业务", taskBto.getId(), taskBto.getNodeIdDetail() + taskBto.getId() + ".", allotBackBill1.getId(), BusinessEnum.ALLOT_BACK.id, userPublicService.findUnitIdByName(allotBillEntity.getSendUnit()), 1, null, userIds);
TaskBto task = taskService.start(taskBto1);
log.info("[配发模块]:配发入库审核失败");
myWebSocket.sendMessage1();
return ResponseEntity.ok(task);
} else {
return ResponseEntity.ok("status只能为0或1");
}
}
@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)
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<>();
userIds.add(userId); userIds.add(userId);
//转Do
AllotBill allotBill1 = allotBillSaveVo.toDo(); AllotBill allotBill1 = allotBillSaveVo.toDo();
//状态设为草稿
allotBill1.setAllotStatus(0); allotBill1.setAllotStatus(0);
//发件A岗设为当前操作人
allotBill1.setSendUseraId(userId); allotBill1.setSendUseraId(userId);
AllotBill allotBill = allotBillService.addEntity(allotBill1); AllotBill allotBill = allotBillService.addEntity(allotBill1);
//发起任务 //发起草稿任务
TaskBto taskBto = new TaskBto(StatusEnum.ALLOT_DRAFT.id, "配发业务", null, ".", allotBill.getId(), 3, userUtils.getCurrentUnitId(), 0, null, userIds); TaskBto taskBto = new TaskBto(StatusEnum.ALLOT_DRAFT.id, "配发业务", null, ".", allotBill.getId(), 3, userUtils.getCurrentUnitId(), 0, null, userIds);
TaskBto taskBto1 = taskService.start(taskBto); TaskBto taskBto1 = taskService.start(taskBto);
//改变装备状态为待配发 //返回保存成功的id
// if (allotBillSaveVo.getAllotCheckDetail()!=null){
// Map<Integer,DeviceLibrary> map = deviceLibraryService.getAllDeviceMap();
// StringSplitUtil.split(allotBillSaveVo.getAllotCheckDetail()).forEach(integer -> {
// if (map.get(integer)!=null){
// DeviceLibrary deviceLibrary = map.get(integer);
// deviceLibrary.setLifeStatus(21);
// deviceLibraryService.update(deviceLibrary);
// }
// });
// }
Integer id = taskBto1.getId(); Integer id = taskBto1.getId();
myWebSocket.sendMessage1(); myWebSocket.sendMessage1();
return ResponseEntity.ok("保存成功"+id); return ResponseEntity.ok("保存成功"+id);
...@@ -623,10 +509,10 @@ public class AllotBillController { ...@@ -623,10 +509,10 @@ public class AllotBillController {
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());
} }
} }
...@@ -639,18 +525,6 @@ public class AllotBillController { ...@@ -639,18 +525,6 @@ public class AllotBillController {
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);
//更改装备状态为在库
// AllotBill allotBill = allotBillService.getOne(taskBto1.getBillId());
// if (allotBill.getAllotCheckDetail()!=null){
// Map<Integer,DeviceLibrary> map = deviceLibraryService.getAllDeviceMap();
// StringSplitUtil.split(allotBill.getAllotCheckDetail()).forEach(integer -> {
// if (map.get(integer)!=null){
// DeviceLibrary deviceLibrary = map.get(integer);
// deviceLibrary.setLifeStatus(2);
// deviceLibraryService.update(deviceLibrary);
// }
// });
// }
myWebSocket.sendMessage1(); myWebSocket.sendMessage1();
return ResponseEntity.ok("删除成功"); return ResponseEntity.ok("删除成功");
} }
...@@ -659,13 +533,16 @@ public class AllotBillController { ...@@ -659,13 +533,16 @@ public class AllotBillController {
@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岗
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("申请成功");
...@@ -675,24 +552,32 @@ public class AllotBillController { ...@@ -675,24 +552,32 @@ public class AllotBillController {
@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());
} }
//收件方盖章
else { else {
//当前用户设为接收方B岗
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());
} }
//收件方返回到待入库状态
else { else {
taskService.moveToSpecial(taskBto, StatusEnum.ALLOTING, allotBill.getReceiveUseraId()); taskService.moveToSpecial(taskBto, StatusEnum.ALLOTING, allotBill.getReceiveUseraId());
} }
...@@ -705,8 +590,10 @@ public class AllotBillController { ...@@ -705,8 +590,10 @@ public class AllotBillController {
@PostMapping(value = "/selectAllotDetail/{taskId}") @PostMapping(value = "/selectAllotDetail/{taskId}")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity selectAllotDetail(@PathVariable("taskId") int taskId) { public ResponseEntity selectAllotDetail(@PathVariable("taskId") int taskId) {
//获取业务和账单
TaskBto taskBto = taskService.get(taskId); TaskBto taskBto = taskService.get(taskId);
AllotBill allotBillEntity = allotBillService.getOne(taskBto.getBillId()); AllotBill allotBillEntity = allotBillService.getOne(taskBto.getBillId());
//将用户id转为名字
if (allotBillEntity.getSendUseraId() != null) { if (allotBillEntity.getSendUseraId() != null) {
allotBillEntity.setSenderUserA(userPublicService.getOne(allotBillEntity.getSendUseraId()).getName()); allotBillEntity.setSenderUserA(userPublicService.getOne(allotBillEntity.getSendUseraId()).getName());
} }
...@@ -719,14 +606,17 @@ public class AllotBillController { ...@@ -719,14 +606,17 @@ public class AllotBillController {
if (allotBillEntity.getReceiveUserbId() != null) { if (allotBillEntity.getReceiveUserbId() != null) {
allotBillEntity.setReceiveUserB(userPublicService.getOne(allotBillEntity.getReceiveUserbId()).getName()); allotBillEntity.setReceiveUserB(userPublicService.getOne(allotBillEntity.getReceiveUserbId()).getName());
} }
//分隔装备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)));
allotBillEntity.setDeviceLibraries(deviceLibraryList); allotBillEntity.setDeviceLibraries(deviceLibraryList);
} }
//设置申请和批复文件列表
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详情
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>>() {}));
} }
...@@ -738,23 +628,26 @@ public class AllotBillController { ...@@ -738,23 +628,26 @@ public class AllotBillController {
@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());
allotBill.setBillFileName(fileUploadVo.getBillFileName()); //是否上传发件方签发人
allotBill.setBillFileUrl(fileUploadVo.getBillFileUrl());
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());
} }
//是否上传接收方B岗
if (fileUploadVo.getReceiveUserbId()!=null){ if (fileUploadVo.getReceiveUserbId()!=null){
allotBill.setReceiveUserbId(fileUploadVo.getReceiveUserbId()); allotBill.setReceiveUserbId(fileUploadVo.getReceiveUserbId());
MessageBto messageBto = new MessageBto(taskBto.getId(), taskBto.getBusinessType(), "被选为经办人", Collections.singletonList(fileUploadVo.getReceiveUserbId()), 1); MessageBto messageBto = new MessageBto(taskBto.getId(), taskBto.getBusinessType(), "被选为经办人", Collections.singletonList(fileUploadVo.getReceiveUserbId()), 1);
messageService.add(messageBto); messageService.add(messageBto);
} }
//文件列表
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 -> {
...@@ -762,7 +655,6 @@ public class AllotBillController { ...@@ -762,7 +655,6 @@ public class AllotBillController {
}); });
allotBill.setReceiveFiles(FilesUtil.stringFileToList(fileUploadVo.getReceiveFileList())); allotBill.setReceiveFiles(FilesUtil.stringFileToList(fileUploadVo.getReceiveFileList()));
} }
// fileVoList.add(new FileVo("配发单", allotBill.getBillFileName(), allotBill.getBillFileUrl()));
allotBillService.update(allotBill); allotBillService.update(allotBill);
//添加装备日志 //添加装备日志
List<Integer> deviceIds = StringSplitUtil.split(allotBill.getAllotCheckDetail()); List<Integer> deviceIds = StringSplitUtil.split(allotBill.getAllotCheckDetail());
...@@ -771,6 +663,7 @@ public class AllotBillController { ...@@ -771,6 +663,7 @@ public class AllotBillController {
DeviceLogDto deviceLogDto = new DeviceLogDto(integer, "上传配发单据", fileVoList); DeviceLogDto deviceLogDto = new DeviceLogDto(integer, "上传配发单据", fileVoList);
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());
...@@ -794,11 +687,14 @@ public class AllotBillController { ...@@ -794,11 +687,14 @@ public class AllotBillController {
//获取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
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());
...@@ -808,6 +704,7 @@ public class AllotBillController { ...@@ -808,6 +704,7 @@ public class AllotBillController {
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());
...@@ -817,10 +714,14 @@ public class AllotBillController { ...@@ -817,10 +714,14 @@ public class AllotBillController {
messageService.add(messageBto); messageService.add(messageBto);
} }
//保存账单 //保存账单
//回执单
allotBill.setSendFiles(FilesUtil.stringFileToList(fileVo.getAllotFiles())); allotBill.setSendFiles(FilesUtil.stringFileToList(fileVo.getAllotFiles()));
//状态配发完成
allotBill.setAllotStatus(5); allotBill.setAllotStatus(5);
//接收时间
allotBill.setReceiveTime(TimestampUtil.getCurrentTimestamp()); allotBill.setReceiveTime(TimestampUtil.getCurrentTimestamp());
allotBillService.update(allotBill); allotBillService.update(allotBill);
//装备Id集合
List<Integer> ids = StringSplitUtil.split(allotBill.getAllotCheckDetail()); List<Integer> ids = StringSplitUtil.split(allotBill.getAllotCheckDetail());
//业务完结 //业务完结
taskService.moveToEnd(taskBto); taskService.moveToEnd(taskBto);
...@@ -828,7 +729,7 @@ public class AllotBillController { ...@@ -828,7 +729,7 @@ public class AllotBillController {
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 -> {
...@@ -841,6 +742,7 @@ public class AllotBillController { ...@@ -841,6 +742,7 @@ public class AllotBillController {
deviceLibrary.setManageStatus(1); deviceLibrary.setManageStatus(1);
deviceLibraryService.update(deviceLibrary); deviceLibraryService.update(deviceLibrary);
}); });
//经办人阅知
if (idList.size()>0) { if (idList.size()>0) {
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);
...@@ -858,11 +760,14 @@ public class AllotBillController { ...@@ -858,11 +760,14 @@ public class AllotBillController {
@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());
allotBill.setAgent(agentVo.getName()); allotBill.setAgent(agentVo.getName());
allotBill.setSendUserbId(agentVo.getSendUserbId()); allotBill.setSendUserbId(agentVo.getSendUserbId());
......
...@@ -87,21 +87,26 @@ public class BackController { ...@@ -87,21 +87,26 @@ public class BackController {
@PostMapping(value = "/addBackBill") @PostMapping(value = "/addBackBill")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity addBackBill(@RequestBody @Validated AllotBillSaveVo allotBillSaveVo) { public ResponseEntity addBackBill(@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.添加退回
AllotBackBill a = allotBillSaveVo.toBackDo(); AllotBackBill a = allotBillSaveVo.toBackDo();
if (allotBillSaveVo.getTaskId()==null) { //保存后的实体
a.setSendUseraId(userUtils.getCurrentUserId());
}
AllotBackBill allotBackBill; AllotBackBill allotBackBill;
//如果是直接发起(不是草稿,没有taskId),当前操作人为发件方A岗,添加账单
if (allotBillSaveVo.getTaskId()==null){ if (allotBillSaveVo.getTaskId()==null){
a.setSendUseraId(userUtils.getCurrentUserId());
allotBackBill = allotBackBillService.addEntity(a); allotBackBill = allotBackBillService.addEntity(a);
} }
//从草稿发起
else { else {
//获取草稿账单
allotBackBill = allotBackBillService.getOne(taskService.get(allotBillSaveVo.getTaskId()).getBillId()); allotBackBill = allotBackBillService.getOne(taskService.get(allotBillSaveVo.getTaskId()).getBillId());
//copy非null相同字段值
MapperUtils.copyNoNullProperties(a,allotBackBill); MapperUtils.copyNoNullProperties(a,allotBackBill);
//判断是否取消上传申请单和批复单据
if (a.getApplyFiles()==null||"".equals(a.getApplyFiles())){ if (a.getApplyFiles()==null||"".equals(a.getApplyFiles())){
allotBackBill.setApplyFiles(null); allotBackBill.setApplyFiles(null);
} }
...@@ -110,14 +115,15 @@ public class BackController { ...@@ -110,14 +115,15 @@ public class BackController {
} }
allotBackBill = allotBackBillService.update(allotBackBill); allotBackBill = allotBackBillService.update(allotBackBill);
} }
//按照当前时间和保存账单的id拼接生成退回单号并保存
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date()); calendar.setTime(new Date());
int year = calendar.get(Calendar.YEAR); int year = calendar.get(Calendar.YEAR);
String num = "NO:第" + year + "TH" + allotBackBill.getId() + "号"; String num = "NO:第" + year + "TH" + allotBackBill.getId() + "号";
allotBackBill.setNum(num); allotBackBill.setNum(num);
//生成电子签章id //生成接收方电子签章id
// Long signId = snowflake.creatNextId();
Long signId2 = snowflake.creatNextId(); Long signId2 = snowflake.creatNextId();
//判断是否上传了发送方签章id
if (allotBillSaveVo.getLeftSignatureId()!=null) { if (allotBillSaveVo.getLeftSignatureId()!=null) {
allotBackBill.setLeftSignatureId(allotBillSaveVo.getLeftSignatureId()); allotBackBill.setLeftSignatureId(allotBillSaveVo.getLeftSignatureId());
} }
...@@ -127,26 +133,34 @@ public class BackController { ...@@ -127,26 +133,34 @@ public class BackController {
Integer userId = userUtils.getCurrentUserId(); Integer userId = userUtils.getCurrentUserId();
String deviceIdDetail = allotBackBill.getBackCheckDetail(); String deviceIdDetail = allotBackBill.getBackCheckDetail();
//2.发起任务 //2.发起任务
//构建task涉及人员集合
List<Integer> userIds = new ArrayList<>(); List<Integer> userIds = new ArrayList<>();
userIds.add(userId); userIds.add(userId);
userIds.add(0); userIds.add(0);
//保存后的taskBto
TaskBto saveEntity; TaskBto saveEntity;
//直接发起
if (allotBillSaveVo.getTaskId()==null) { if (allotBillSaveVo.getTaskId()==null) {
TaskBto taskBto = new TaskBto(StatusEnum.ALLOT_BACKING.id, "退回业务", null, ".", billId, 22, userPublicService.findUnitIdByName(allotBillSaveVo.getReceiveUnit()), 1, null, userIds); TaskBto taskBto = new TaskBto(StatusEnum.ALLOT_BACKING.id, "退回业务", null, ".", billId, 22, 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 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.ALLOT_BACKING,0); saveEntity = taskService.moveToSpecial(taskBto1,StatusEnum.ALLOT_BACKING,0);
} }
//生成发件方上传退回单的子任务
TaskBto taskBto2 = new TaskBto(StatusEnum.WAIT_UPLOAD_BACK_FILE_2.id, "退回业务", saveEntity.getId(), saveEntity.getNodeIdDetail() + saveEntity.getId() + ".", saveEntity.getBillId(), 22, userPublicService.findUnitIdByName(allotBackBill1.getSendUnit()), 0, null, Collections.singletonList(0)); TaskBto taskBto2 = new TaskBto(StatusEnum.WAIT_UPLOAD_BACK_FILE_2.id, "退回业务", saveEntity.getId(), saveEntity.getNodeIdDetail() + saveEntity.getId() + ".", saveEntity.getBillId(), 22, userPublicService.findUnitIdByName(allotBackBill1.getSendUnit()), 0, null, Collections.singletonList(0));
taskService.start(taskBto2); taskService.start(taskBto2);
List<FileVo> fileVoList = new ArrayList<>(); List<FileVo> fileVoList = new ArrayList<>();
// fileVoList.add(new FileVo("出库确认单", allotBillEntity.getFileName(), allotBillEntity.getFileUrl()));
//存装备日志 //存装备日志
String[] strings = deviceIdDetail.split("x"); String[] strings = deviceIdDetail.split("x");
//存放所有出库装备id
List<Integer> ids = new ArrayList<>(); List<Integer> ids = new ArrayList<>();
for (String s : strings) { for (String s : strings) {
if (s.length() >= 2) { if (s.length() >= 2) {
...@@ -157,6 +171,7 @@ public class BackController { ...@@ -157,6 +171,7 @@ public class BackController {
deviceLibraryEntity.setLifeStatus(3); deviceLibraryEntity.setLifeStatus(3);
deviceLibraryEntity.setManageStatus(0); deviceLibraryEntity.setManageStatus(0);
deviceLibraryService.update(deviceLibraryEntity); deviceLibraryService.update(deviceLibraryEntity);
//存装备日志
DeviceLogDto deviceLogDto = new DeviceLogDto(id, "对" + allotBackBill.getReceiveUnit() + "发起退回", fileVoList); DeviceLogDto deviceLogDto = new DeviceLogDto(id, "对" + allotBackBill.getReceiveUnit() + "发起退回", fileVoList);
deviceLogService.addLog(deviceLogDto); deviceLogService.addLog(deviceLogDto);
} }
...@@ -168,12 +183,14 @@ public class BackController { ...@@ -168,12 +183,14 @@ public class BackController {
idList.addAll(userDao.findAllByUnitsId(userPublicService.findUnitIdByName(allotBackBill.getReceiveUnit())).stream() idList.addAll(userDao.findAllByUnitsId(userPublicService.findUnitIdByName(allotBackBill.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(allotBackBill.getReceiveUnit()) + "发起退回",idList,1); MessageBto messageBto = new MessageBto(saveEntity.getId(),saveEntity.getBusinessType(),"对" + userPublicService.getAreaNameByUnitName(allotBackBill.getReceiveUnit()) + "发起退回",idList,1);
messageService.add(messageBto); messageService.add(messageBto);
log.info("[退回模块]:" + allotBackBill.getSendUnit() + "对" + allotBackBill.getReceiveUnit() + "发起退回"); log.info("[退回模块]:" + allotBackBill.getSendUnit() + "对" + allotBackBill.getReceiveUnit() + "发起退回");
...@@ -185,12 +202,16 @@ public class BackController { ...@@ -185,12 +202,16 @@ public class BackController {
@PostMapping(value = "/receiveDevice") @PostMapping(value = "/receiveDevice")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity receiveDevice(@RequestBody @Validated AllotBackReceiveVo allotBackReceiveVo) { public ResponseEntity receiveDevice(@RequestBody @Validated AllotBackReceiveVo allotBackReceiveVo) {
//当前操作人id
Integer userId = userUtils.getCurrentUserId(); Integer userId = userUtils.getCurrentUserId();
//获取当前任务 //获取当前任务
TaskBto taskBto = taskService.get(allotBackReceiveVo.getTaskId()); TaskBto taskBto = taskService.get(allotBackReceiveVo.getTaskId());
//判断当前任务状态是否已经被操作
List<StatusEnum> statusEnums = Arrays.asList(StatusEnum.ALLOT_BACKING,StatusEnum.BACK_WAIT_SIGN); List<StatusEnum> statusEnums = Arrays.asList(StatusEnum.ALLOT_BACKING,StatusEnum.BACK_WAIT_SIGN);
TaskDisposeUtil.isNotSubmit(taskBto.getBillStatus(),statusEnums); TaskDisposeUtil.isNotSubmit(taskBto.getBillStatus(),statusEnums);
//退回单
AllotBackBill allotBackBill = allotBackBillService.getOne(taskBto.getBillId()); AllotBackBill allotBackBill = allotBackBillService.getOne(taskBto.getBillId());
//上传文件存储集合
List<FileVo> fileVoList = new ArrayList<>(); List<FileVo> fileVoList = new ArrayList<>();
if (allotBackReceiveVo.getReceiveFileList()!=null&&allotBackReceiveVo.getReceiveFileList().size()>0){ if (allotBackReceiveVo.getReceiveFileList()!=null&&allotBackReceiveVo.getReceiveFileList().size()>0){
allotBackReceiveVo.getReceiveFileList().forEach(fileRet -> { allotBackReceiveVo.getReceiveFileList().forEach(fileRet -> {
...@@ -198,31 +219,36 @@ public class BackController { ...@@ -198,31 +219,36 @@ public class BackController {
}); });
allotBackBill.setReceiveFiles(FilesUtil.stringFileToList(allotBackReceiveVo.getReceiveFileList())); allotBackBill.setReceiveFiles(FilesUtil.stringFileToList(allotBackReceiveVo.getReceiveFileList()));
} }
// fileVoList.add(new FileVo("退回单", allotBackReceiveVo.getBillFileName(), allotBackReceiveVo.getBillFileUrl())); //是否上传了收件单位签章id
// fileVoList.add(new FileVo("入库确认单", allotReceiveVo.getReceiveFileName(), allotReceiveVo.getReceiveFileUrl()));
//更新账单状态
if (allotBackReceiveVo.getRightSignatureId()!=null&&!"".equals(allotBackReceiveVo.getRightSignatureId())) { if (allotBackReceiveVo.getRightSignatureId()!=null&&!"".equals(allotBackReceiveVo.getRightSignatureId())) {
allotBackBill.setRightSignatureId(allotBackReceiveVo.getRightSignatureId()); allotBackBill.setRightSignatureId(allotBackReceiveVo.getRightSignatureId());
} }
//更新账单状态为退回完成
allotBackBill.setBackStatus(3); allotBackBill.setBackStatus(3);
//复制非空相同字段
MapperUtils.copyNoNullProperties(allotBackReceiveVo, allotBackBill); MapperUtils.copyNoNullProperties(allotBackReceiveVo, allotBackBill);
//set接收时间
allotBackBill.setReceiveTime(TimestampUtil.getCurrentTimestamp()); allotBackBill.setReceiveTime(TimestampUtil.getCurrentTimestamp());
//如果收件方A岗未上传,默认为当前操作人
if (allotBackBill.getReceiveUseraId()==null) { if (allotBackBill.getReceiveUseraId()==null) {
allotBackBill.setReceiveUseraId(userId); allotBackBill.setReceiveUseraId(userId);
} }
//判断是否上传发件方签发人
if (allotBackReceiveVo.getSendUserbId()!=null){ if (allotBackReceiveVo.getSendUserbId()!=null){
allotBackBill.setSendUserbId(allotBackReceiveVo.getSendUserbId()); allotBackBill.setSendUserbId(allotBackReceiveVo.getSendUserbId());
allotBackBill.setAgent(userPublicService.getOne(allotBackReceiveVo.getSendUserbId()).getName()); allotBackBill.setAgent(userPublicService.getOne(allotBackReceiveVo.getSendUserbId()).getName());
} }
allotBackBillService.update(allotBackBill); allotBackBillService.update(allotBackBill);
//添加当前用户为涉及人员
taskService.addInvolveUser(taskBto, userId); taskService.addInvolveUser(taskBto, userId);
// //推至下一阶段 //如果上传了单据或双方都盖章,该业务和子业务都办结
// taskService.update(taskService.moveToNext(taskBto, allotReceiveVo.getReceiveUserbId()));
if (allotBackReceiveVo.getStatus()==0) { if (allotBackReceiveVo.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_BACK_FILE,0); taskService.moveToSpecial(taskBto,StatusEnum.WAIT_UPLOAD_ALLOT_BACK_FILE,0);
} }
//分隔装备id信息 //分隔装备id信息
...@@ -232,10 +258,10 @@ public class BackController { ...@@ -232,10 +258,10 @@ public class BackController {
if (s.length() >= 2) { if (s.length() >= 2) {
//接收无误 //接收无误
if ("1".equals(s.substring(s.length() - 1))) { if ("1".equals(s.substring(s.length() - 1))) {
//装备id
Integer id = Integer.parseInt(s.substring(0, s.length() - 1)); Integer id = Integer.parseInt(s.substring(0, s.length() - 1));
//改变装备状态 //改变装备状态、所属所在
DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(id); DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(id);
// deviceLibraryEntity.setLifeStatus(0);
deviceLibraryEntity.setLocationUnit(userUtils.getCurrentUserUnitName()); deviceLibraryEntity.setLocationUnit(userUtils.getCurrentUserUnitName());
deviceLibraryEntity.setLifeStatus(2); deviceLibraryEntity.setLifeStatus(2);
deviceLibraryEntity.setOwnUnit(userUtils.getCurrentUserUnitName()); deviceLibraryEntity.setOwnUnit(userUtils.getCurrentUserUnitName());
...@@ -263,18 +289,21 @@ public class BackController { ...@@ -263,18 +289,21 @@ public class BackController {
ids.addAll(userDao.findAllByUnitsId(userPublicService.findUnitIdByName(allotBackBill.getSendUnit())).stream() ids.addAll(userDao.findAllByUnitsId(userPublicService.findUnitIdByName(allotBackBill.getSendUnit())).stream()
.map(User::getUserId) .map(User::getUserId)
.collect(Collectors.toList())); .collect(Collectors.toList()));
//经办人阅知
if (allotBackReceiveVo.getReceiveUserbId()!=null) { if (allotBackReceiveVo.getReceiveUserbId()!=null) {
List<Integer> idList1 = new ArrayList<>(); List<Integer> idList1 = new ArrayList<>();
idList1.add(allotBackReceiveVo.getReceiveUserbId()); idList1.add(allotBackReceiveVo.getReceiveUserbId());
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);
} }
//签发人阅知
if (allotBackReceiveVo.getSendUserbId()!=null) { if (allotBackReceiveVo.getSendUserbId()!=null) {
List<Integer> idList1 = new ArrayList<>(); List<Integer> idList1 = new ArrayList<>();
idList1.add(allotBackReceiveVo.getSendUserbId()); idList1.add(allotBackReceiveVo.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
String message = allotBackReceiveVo.getStatus()==0?"业务办结":"接收退回装备"; String message = allotBackReceiveVo.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);
...@@ -288,23 +317,28 @@ public class BackController { ...@@ -288,23 +317,28 @@ public class BackController {
@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_BACK_FILE); TaskDisposeUtil.isNotSubmit(taskBto.getBillStatus(),StatusEnum.WAIT_UPLOAD_ALLOT_BACK_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());
AllotBackBill allotBackBill = allotBackBillService.getOne(taskBto.getBillId()); AllotBackBill allotBackBill = allotBackBillService.getOne(taskBto.getBillId());
allotBackBill.setBillFileName(fileUploadVo.getBillFileName()); allotBackBill.setBillFileName(fileUploadVo.getBillFileName());
allotBackBill.setBillFileUrl(fileUploadVo.getBillFileUrl()); allotBackBill.setBillFileUrl(fileUploadVo.getBillFileUrl());
//是否上传发件方签发人
if (fileUploadVo.getSendUserbId()!=null){ if (fileUploadVo.getSendUserbId()!=null){
allotBackBill.setSendUserbId(fileUploadVo.getSendUserbId()); allotBackBill.setSendUserbId(fileUploadVo.getSendUserbId());
allotBackBill.setAgent(userPublicService.getOne(fileUploadVo.getSendUserbId()).getName()); allotBackBill.setAgent(userPublicService.getOne(fileUploadVo.getSendUserbId()).getName());
} }
//是否上传接收方B岗
if (fileUploadVo.getReceiveUserbId()!=null){ if (fileUploadVo.getReceiveUserbId()!=null){
allotBackBill.setReceiveUserbId(fileUploadVo.getReceiveUserbId()); allotBackBill.setReceiveUserbId(fileUploadVo.getReceiveUserbId());
MessageBto messageBto = new MessageBto(taskBto.getId(), taskBto.getBusinessType(), "被选为经办人", Collections.singletonList(fileUploadVo.getReceiveUserbId()), 1); MessageBto messageBto = new MessageBto(taskBto.getId(), taskBto.getBusinessType(), "被选为经办人", Collections.singletonList(fileUploadVo.getReceiveUserbId()), 1);
messageService.add(messageBto); messageService.add(messageBto);
} }
//文件列表
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 -> {
...@@ -313,7 +347,6 @@ public class BackController { ...@@ -313,7 +347,6 @@ public class BackController {
allotBackBill.setReceiveFiles(FilesUtil.stringFileToList(fileUploadVo.getReceiveFileList())); allotBackBill.setReceiveFiles(FilesUtil.stringFileToList(fileUploadVo.getReceiveFileList()));
} }
allotBackBillService.update(allotBackBill); allotBackBillService.update(allotBackBill);
// fileVoList.add(new FileVo("退回单", allotBackBill.getBillFileName(), allotBackBill.getBillFileUrl()));
//添加装备日志 //添加装备日志
List<Integer> deviceIds = StringSplitUtil.split(allotBackBill.getBackCheckDetail()); List<Integer> deviceIds = StringSplitUtil.split(allotBackBill.getBackCheckDetail());
deviceIds.forEach(integer -> { deviceIds.forEach(integer -> {
...@@ -321,6 +354,7 @@ public class BackController { ...@@ -321,6 +354,7 @@ public class BackController {
DeviceLogDto deviceLogDto = new DeviceLogDto(integer, "上传退回单据", fileVoList); DeviceLogDto deviceLogDto = new DeviceLogDto(integer, "上传退回单据", fileVoList);
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());
...@@ -344,10 +378,13 @@ public class BackController { ...@@ -344,10 +378,13 @@ public class BackController {
//获取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_BACK_FILE_2); statusEnums.add(StatusEnum.WAIT_UPLOAD_BACK_FILE_2);
TaskDisposeUtil.isNotSubmit(taskBto.getBillStatus(),statusEnums); TaskDisposeUtil.isNotSubmit(taskBto.getBillStatus(),statusEnums);
//获取账单
AllotBackBill allotBackBill = allotBackBillService.getOne(taskBto.getBillId()); AllotBackBill allotBackBill = allotBackBillService.getOne(taskBto.getBillId());
//存放接收方经办人id
List<Integer> idList = new ArrayList<>(); List<Integer> idList = new ArrayList<>();
if (fileVo.getReceiveUseraId()!=null) { if (fileVo.getReceiveUseraId()!=null) {
allotBackBill.setReceiveUseraId(fileVo.getReceiveUseraId()); allotBackBill.setReceiveUseraId(fileVo.getReceiveUseraId());
...@@ -357,6 +394,7 @@ public class BackController { ...@@ -357,6 +394,7 @@ public class BackController {
allotBackBill.setReceiveUserbId(fileVo.getReceiveUserbId()); allotBackBill.setReceiveUserbId(fileVo.getReceiveUserbId());
idList.add(fileVo.getReceiveUserbId()); idList.add(fileVo.getReceiveUserbId());
} }
//签发人阅知
if (fileVo.getSendUserbId()!=null){ if (fileVo.getSendUserbId()!=null){
allotBackBill.setSendUserbId(fileVo.getSendUserbId()); allotBackBill.setSendUserbId(fileVo.getSendUserbId());
allotBackBill.setAgent(userPublicService.getOne(fileVo.getSendUserbId()).getName()); allotBackBill.setAgent(userPublicService.getOne(fileVo.getSendUserbId()).getName());
...@@ -366,15 +404,20 @@ public class BackController { ...@@ -366,15 +404,20 @@ public class BackController {
messageService.add(messageBto); messageService.add(messageBto);
} }
//保存账单 //保存账单
//回执单
allotBackBill.setSendFiles(FilesUtil.stringFileToList(fileVo.getAllotFiles())); allotBackBill.setSendFiles(FilesUtil.stringFileToList(fileVo.getAllotFiles()));
//状态退回完成
allotBackBill.setBackStatus(3); allotBackBill.setBackStatus(3);
//接收时间
allotBackBill.setReceiveTime(TimestampUtil.getCurrentTimestamp());
allotBackBillService.update(allotBackBill); allotBackBillService.update(allotBackBill);
//装备Id集合
List<Integer> ids = StringSplitUtil.split(allotBackBill.getBackCheckDetail()); List<Integer> ids = StringSplitUtil.split(allotBackBill.getBackCheckDetail());
//业务完结 //业务完结
taskService.moveToEnd(taskBto); taskService.moveToEnd(taskBto);
//主业务完结 //主业务完结
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 -> {
...@@ -387,6 +430,7 @@ public class BackController { ...@@ -387,6 +430,7 @@ public class BackController {
deviceLibrary.setManageStatus(1); deviceLibrary.setManageStatus(1);
deviceLibraryService.update(deviceLibrary); deviceLibraryService.update(deviceLibrary);
}); });
//经办人阅知
if (idList.size()>0) { if (idList.size()>0) {
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);
...@@ -404,48 +448,45 @@ public class BackController { ...@@ -404,48 +448,45 @@ public class BackController {
@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);
//账单保存签发人
AllotBackBill allotBackBill = allotBackBillService.getOne(taskBto.getBillId()); AllotBackBill allotBackBill = allotBackBillService.getOne(taskBto.getBillId());
allotBackBill.setAgent(agentVo.getName()); allotBackBill.setAgent(agentVo.getName());
allotBackBill.setSendUserbId(agentVo.getSendUserbId()); allotBackBill.setSendUserbId(agentVo.getSendUserbId());
return ResponseEntity.ok(allotBackBillService.update(allotBackBill)); return ResponseEntity.ok(allotBackBillService.update(allotBackBill));
} }
@ApiOperation(value = "保存退回操作", notes = "可以通过这个接口保存退回操作") @ApiOperation(value = "保存退回操作(草稿)", notes = "可以通过这个接口保存退回操作")
@PostMapping(value = "/saveBackBill") @PostMapping(value = "/saveBackBill")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity saveBackBill(@RequestBody AllotBillSaveVo allotBillSaveVo) { public ResponseEntity saveBackBill(@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)
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<>();
userIds.add(userId); userIds.add(userId);
//转Do
AllotBackBill allotBackBill = allotBillSaveVo.toBackDo(); AllotBackBill allotBackBill = allotBillSaveVo.toBackDo();
//状态设为草稿
allotBackBill.setBackStatus(1); allotBackBill.setBackStatus(1);
//发件A岗设为当前操作人
allotBackBill.setSendUseraId(userId); allotBackBill.setSendUseraId(userId);
AllotBackBill allotBackBill1 = allotBackBillService.addEntity(allotBackBill); AllotBackBill allotBackBill1 = allotBackBillService.addEntity(allotBackBill);
//发起任务 //发起草稿任务
TaskBto taskBto = new TaskBto(StatusEnum.BACK_DRAFT.id, "退回业务", null, ".", allotBackBill1.getId(), 22, userUtils.getCurrentUnitId(), 0, null, userIds); TaskBto taskBto = new TaskBto(StatusEnum.BACK_DRAFT.id, "退回业务", null, ".", allotBackBill1.getId(), 22, userUtils.getCurrentUnitId(), 0, null, userIds);
TaskBto taskBto1 = taskService.start(taskBto); TaskBto taskBto1 = taskService.start(taskBto);
//改变装备状态为待退回 //返回保存成功的id
// if (allotBillSaveVo.getAllotCheckDetail()!=null){
// Map<Integer,DeviceLibrary> map = deviceLibraryService.getAllDeviceMap();
// StringSplitUtil.split(allotBillSaveVo.getAllotCheckDetail()).forEach(integer -> {
// if (map.get(integer)!=null){
// DeviceLibrary deviceLibrary = map.get(integer);
// deviceLibrary.setLifeStatus(22);
// deviceLibraryService.update(deviceLibrary);
// }
// });
// }
Integer id = taskBto1.getId(); Integer id = taskBto1.getId();
myWebSocket.sendMessage1(); myWebSocket.sendMessage1();
return ResponseEntity.ok("保存成功"+id); return ResponseEntity.ok("保存成功"+id);
...@@ -455,6 +496,7 @@ public class BackController { ...@@ -455,6 +496,7 @@ public class BackController {
TaskBto taskBto = taskService.get(allotBillSaveVo.getTaskId()); TaskBto taskBto = taskService.get(allotBillSaveVo.getTaskId());
AllotBackBill allotBackBill = allotBackBillService.getOne(taskBto.getBillId()); AllotBackBill allotBackBill = allotBackBillService.getOne(taskBto.getBillId());
AllotBackBill allotBackBill1 = allotBillSaveVo.toBackDo(); AllotBackBill allotBackBill1 = allotBillSaveVo.toBackDo();
//状态设为草稿
allotBackBill1.setBackStatus(1); allotBackBill1.setBackStatus(1);
MapperUtils.copyNoNullProperties(allotBackBill1,allotBackBill); MapperUtils.copyNoNullProperties(allotBackBill1,allotBackBill);
allotBackBillService.update(allotBackBill); allotBackBillService.update(allotBackBill);
...@@ -470,18 +512,6 @@ public class BackController { ...@@ -470,18 +512,6 @@ public class BackController {
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);
//更改装备状态为在库
// AllotBackBill allotBackBill = allotBackBillService.getOne(taskBto1.getBillId());
// if (allotBackBill.getBackCheckDetail()!=null){
// Map<Integer,DeviceLibrary> map = deviceLibraryService.getAllDeviceMap();
// StringSplitUtil.split(allotBackBill.getBackCheckDetail()).forEach(integer -> {
// if (map.get(integer)!=null){
// DeviceLibrary deviceLibrary = map.get(integer);
// deviceLibrary.setLifeStatus(2);
// deviceLibraryService.update(deviceLibrary);
// }
// });
// }
myWebSocket.sendMessage1(); myWebSocket.sendMessage1();
return ResponseEntity.ok("删除成功"); return ResponseEntity.ok("删除成功");
} }
...@@ -490,13 +520,16 @@ public class BackController { ...@@ -490,13 +520,16 @@ public class BackController {
@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);
AllotBackBill allotBill = allotBackBillService.getOne(taskBto.getBillId()); AllotBackBill allotBill = allotBackBillService.getOne(taskBto.getBillId());
//如果是收件方申请电子签章
if (allotBill.getBackStatus()!=1){ if (allotBill.getBackStatus()!=1){
//当前用户设为接收A岗
allotBill.setReceiveUseraId(userUtils.getCurrentUserId()); allotBill.setReceiveUseraId(userUtils.getCurrentUserId());
allotBackBillService.update(allotBill); allotBackBillService.update(allotBill);
} }
//推动任务到盖章待审核状态
taskService.moveToSpecial(taskBto,StatusEnum.BACK_SIGN_WAIT_CONFIRM,userId); taskService.moveToSpecial(taskBto,StatusEnum.BACK_SIGN_WAIT_CONFIRM,userId);
myWebSocket.sendMessage1(); myWebSocket.sendMessage1();
return ResponseEntity.ok("申请成功"); return ResponseEntity.ok("申请成功");
...@@ -506,24 +539,32 @@ public class BackController { ...@@ -506,24 +539,32 @@ public class BackController {
@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);
AllotBackBill allotBill = allotBackBillService.getOne(taskBto.getBillId()); AllotBackBill allotBill = allotBackBillService.getOne(taskBto.getBillId());
//如果同意
if (status==1){ if (status==1){
//推动任务到等待盖章状态
taskService.moveToSpecial(taskBto,StatusEnum.BACK_WAIT_SIGN); taskService.moveToSpecial(taskBto,StatusEnum.BACK_WAIT_SIGN);
//发件方盖章
if (allotBill.getBackStatus()==1) { if (allotBill.getBackStatus()==1) {
//当前用户设为签发人
allotBill.setSendUserbId(userUtils.getCurrentUserId()); allotBill.setSendUserbId(userUtils.getCurrentUserId());
allotBill.setAgent(userUtils.getCurrentName()); allotBill.setAgent(userUtils.getCurrentName());
} }
//收件方盖章
else { else {
//当前用户设为接收方B岗
allotBill.setReceiveUserbId(userUtils.getCurrentUserId()); allotBill.setReceiveUserbId(userUtils.getCurrentUserId());
} }
allotBackBillService.update(allotBill); allotBackBillService.update(allotBill);
} }
else { else {
//发件方盖章不同意任务返回草稿状态
if (allotBill.getBackStatus()==1) { if (allotBill.getBackStatus()==1) {
taskService.moveToSpecial(taskBto, StatusEnum.BACK_DRAFT, taskBto.getCreateUserId()); taskService.moveToSpecial(taskBto, StatusEnum.BACK_DRAFT, taskBto.getCreateUserId());
} }
//收件方返回到待入库状态
else { else {
taskService.moveToSpecial(taskBto, StatusEnum.ALLOT_BACKING, allotBill.getReceiveUseraId()); taskService.moveToSpecial(taskBto, StatusEnum.ALLOT_BACKING, allotBill.getReceiveUseraId());
} }
...@@ -536,8 +577,10 @@ public class BackController { ...@@ -536,8 +577,10 @@ public class BackController {
@PostMapping(value = "/selectBackDetail/{taskId}") @PostMapping(value = "/selectBackDetail/{taskId}")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity selectBackDetail(@PathVariable("taskId") int taskId) { public ResponseEntity selectBackDetail(@PathVariable("taskId") int taskId) {
//获取业务和账单
TaskBto taskBto = taskService.get(taskId); TaskBto taskBto = taskService.get(taskId);
AllotBackBill allotBillEntity = allotBackBillService.getOne(taskBto.getBillId()); AllotBackBill allotBillEntity = allotBackBillService.getOne(taskBto.getBillId());
//将用户id转为名字
if (allotBillEntity.getSendUseraId() != null) { if (allotBillEntity.getSendUseraId() != null) {
allotBillEntity.setSenderUserA(userPublicService.getOne(allotBillEntity.getSendUseraId()).getName()); allotBillEntity.setSenderUserA(userPublicService.getOne(allotBillEntity.getSendUseraId()).getName());
} }
...@@ -550,14 +593,17 @@ public class BackController { ...@@ -550,14 +593,17 @@ public class BackController {
if (allotBillEntity.getReceiveUserbId() != null) { if (allotBillEntity.getReceiveUserbId() != null) {
allotBillEntity.setReceiveUserB(userPublicService.getOne(allotBillEntity.getReceiveUserbId()).getName()); allotBillEntity.setReceiveUserB(userPublicService.getOne(allotBillEntity.getReceiveUserbId()).getName());
} }
//分隔装备id得到装备信息
if (allotBillEntity.getBackCheckDetail()!=null){ if (allotBillEntity.getBackCheckDetail()!=null){
List<Integer> ids = StringSplitUtil.split(allotBillEntity.getBackCheckDetail()); List<Integer> ids = StringSplitUtil.split(allotBillEntity.getBackCheckDetail());
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)));
allotBillEntity.setDeviceLibraries(deviceLibraryList); allotBillEntity.setDeviceLibraries(deviceLibraryList);
} }
//设置申请和批复文件列表
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详情
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>>() {}));
} }
......
...@@ -143,8 +143,10 @@ public class AllotBillSaveVo { ...@@ -143,8 +143,10 @@ public class AllotBillSaveVo {
if(this.applyFiles!=null){ if(this.applyFiles!=null){
allotBillEntity.setApplyFiles(FilesUtil.stringFileToList(this.applyFiles)); allotBillEntity.setApplyFiles(FilesUtil.stringFileToList(this.applyFiles));
} }
//退回状态为退回中
allotBillEntity.setBackStatus(0); allotBillEntity.setBackStatus(0);
allotBillEntity.setSendTime(TimestampUtil.getCurrentTimestamp()); allotBillEntity.setSendTime(TimestampUtil.getCurrentTimestamp());
//字段和配发不同的单独set
allotBillEntity.setBackCheckDetail(this.allotCheckDetail); allotBillEntity.setBackCheckDetail(this.allotCheckDetail);
allotBillEntity.setBackCheckResult(this.allotCheckResult); allotBillEntity.setBackCheckResult(this.allotCheckResult);
allotBillEntity.setBackCount(this.allotCount); allotBillEntity.setBackCount(this.allotCount);
......
...@@ -125,29 +125,29 @@ public interface DeviceLibraryService { ...@@ -125,29 +125,29 @@ public interface DeviceLibraryService {
List<DeviceLibrary> getSendBackDevice(DeviceLibrarySelectVo deviceLibrarySelectVo); List<DeviceLibrary> getSendBackDevice(DeviceLibrarySelectVo deviceLibrarySelectVo);
/** /**
* 判断装备状态是否在库 * 判断装备状态是否在库(若不是抛出303异常)
*/ */
void isInStock(List<Integer> ids); void isInStock(List<Integer> ids);
/** /**
* 判断装备状态是否待退役 * 判断装备状态是否待退役(若不是抛出303异常)
*/ */
void isWaitRetired(List<Integer> ids); void isWaitRetired(List<Integer> ids);
/** /**
* 判断装备状态是否在库或待退役 * 判断装备状态是否在库或待退役(若不是抛出303异常)
*/ */
void isInStockOrWaitRetired(List<Integer> ids); void isInStockOrWaitRetired(List<Integer> ids);
/** /**
* 判断装备状态是否丢失 * 判断装备状态是否丢失(若不是抛出303异常)
* @param ids * @param ids
*/ */
void isNotLoss(List<Integer> ids); void isNotLoss(List<Integer> ids);
/** /**
* 判断装备状态是否在库或维修中 * 判断装备状态是否在库或维修中(若不是抛出303异常)
*/ */
void isInStockOrRepairing(List<Integer> ids); void isInStockOrRepairing(List<Integer> ids);
......
...@@ -469,7 +469,7 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService { ...@@ -469,7 +469,7 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
} }
/** /**
* 判断装备状态是否在库或待退役 * 判断装备状态是否在库或待退役(若不是抛出303异常)
* *
* @param ids 装备id集合 * @param ids 装备id集合
*/ */
......
...@@ -166,7 +166,7 @@ public class PackingController { ...@@ -166,7 +166,7 @@ public class PackingController {
} }
if (packingLibraryService.matchingRangeIsExist(addPack.getPartParentId(),addPack.getMatchingRange(),addPack.getType(),addPack.getStyle(),addPack.getName(),addPack.getSecretLevel(),addPack.getInvisibleRange())){ if (packingLibraryService.matchingRangeIsExist(addPack.getPartParentId(),addPack.getMatchingRange(),addPack.getType(),addPack.getStyle(),addPack.getName(),addPack.getSecretLevel(),addPack.getInvisibleRange())){
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
map.put("error","型号"+addPack.getModel()+"下配用范围为"+configCache.getMatchingRangeMap().get(addPack.getMatchingRange())+"的装备已存在"); map.put("error","型号"+addPack.getModel()+"下配用范围为"+configCache.getMatchingRangeMap().get(addPack.getMatchingRange())+"的装备已存在");
return ResponseEntity.ok(map); return ResponseEntity.ok(map);
} }
PackingLibrary packingLibrary = addPack.toDo(); PackingLibrary packingLibrary = addPack.toDo();
...@@ -448,7 +448,7 @@ public class PackingController { ...@@ -448,7 +448,7 @@ public class PackingController {
public ResponseEntity updateDevice(@RequestBody @Validated PackingLibraryUpdateVo packingLibraryUpdateVo){ public ResponseEntity updateDevice(@RequestBody @Validated PackingLibraryUpdateVo packingLibraryUpdateVo){
PackingLibrary packingLibrary = packingLibraryService.getOne(packingLibraryUpdateVo.getPackingId()); PackingLibrary packingLibrary = packingLibraryService.getOne(packingLibraryUpdateVo.getPackingId());
if (!packingLibraryUpdateVo.getMatchingRange().equals(packingLibrary.getMatchingRange())&&packingLibraryService.matchingRangeIsExist(packingLibrary.getPartParentId(),packingLibraryUpdateVo.getMatchingRange(),packingLibraryUpdateVo.getType(),packingLibraryUpdateVo.getStyle(),packingLibraryUpdateVo.getName(),packingLibraryUpdateVo.getSecretLevel(),packingLibraryUpdateVo.getInvisibleRange())){ if (!packingLibraryUpdateVo.getMatchingRange().equals(packingLibrary.getMatchingRange())&&packingLibraryService.matchingRangeIsExist(packingLibrary.getPartParentId(),packingLibraryUpdateVo.getMatchingRange(),packingLibraryUpdateVo.getType(),packingLibraryUpdateVo.getStyle(),packingLibraryUpdateVo.getName(),packingLibraryUpdateVo.getSecretLevel(),packingLibraryUpdateVo.getInvisibleRange())){
throw new ApiException("该型号下已存在配用范围为"+configCache.getMatchingRangeMap().get(packingLibraryUpdateVo.getMatchingRange())+"的装备"); throw new ApiException("该型号下已存在配用范围为"+configCache.getMatchingRangeMap().get(packingLibraryUpdateVo.getMatchingRange())+"的相同装备");
} }
//复制相同的字段 //复制相同的字段
if (packingLibraryUpdateVo.getName()!=null&&!packingLibraryUpdateVo.getName().equals(packingLibrary.getName())&&!packingLibraryService.nameIsExist(packingLibrary.getModel(),packingLibraryUpdateVo.getName())){ if (packingLibraryUpdateVo.getName()!=null&&!packingLibraryUpdateVo.getName().equals(packingLibrary.getName())&&!packingLibraryService.nameIsExist(packingLibrary.getModel(),packingLibraryUpdateVo.getName())){
......
...@@ -165,6 +165,12 @@ public class TaskController { ...@@ -165,6 +165,12 @@ public class TaskController {
} }
} }
} }
//set新增的task高亮字段
taskUserVos.forEach(taskUserVo -> {
if (taskIds.contains(taskUserVo.getId())){
taskUserVo.setIsNew(1);
}
});
} }
} }
return ResultUtil.success(taskUtils.orderByTopDescAndReadAsc(taskUserVos)); return ResultUtil.success(taskUtils.orderByTopDescAndReadAsc(taskUserVos));
......
...@@ -91,6 +91,10 @@ public class TaskUserVo { ...@@ -91,6 +91,10 @@ public class TaskUserVo {
@Transient @Transient
private Integer isTop = 0; private Integer isTop = 0;
@ApiModelProperty(value = "是否新高亮待办(0:不是,1:是)")
@Transient
private Integer isNew = 0;
@ApiModelProperty(value = "状态描述") @ApiModelProperty(value = "状态描述")
private String status; private String status;
......
...@@ -121,6 +121,12 @@ public class MessageServiceImpl implements MessageService { ...@@ -121,6 +121,12 @@ public class MessageServiceImpl implements MessageService {
userRecordService.save(userRecord); userRecordService.save(userRecord);
} }
} }
//设置新增的阅知字段
messageUserVos.forEach(messageUserVo -> {
if (ids.contains(messageUserVo.getId())){
messageUserVo.setIsNew(1);
}
});
return messageUserVos; return messageUserVos;
} }
......
...@@ -54,6 +54,9 @@ public class MessageUserVo { ...@@ -54,6 +54,9 @@ public class MessageUserVo {
@ApiModelProperty(value = "是否高亮(0:不是,1:是)") @ApiModelProperty(value = "是否高亮(0:不是,1:是)")
private Integer isHighLight = 0; private Integer isHighLight = 0;
@ApiModelProperty(value = "是否新增(0:不是,1:是)")
private Integer isNew = 0;
@ApiModelProperty(value = "操作人") @ApiModelProperty(value = "操作人")
private String operator; private String operator;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论