提交 02f56769 authored 作者: zhoushaopan's avatar zhoushaopan

feat(维修模块,退回模块,装备模块,日志模块,任务模块): 维修新增省直属发起维修,维修草稿,维修撤回,退回模块新增省直属发起退回,草稿,以及撤回

维修新增省直属发起维修,维修草稿,维修撤回,退回模块新增省直属发起退回,草稿,以及撤回 ,修改装备的所属所在,新增状态
上级 5b77f4e9
package com.tykj.dev.device.allot.controller;
import com.fasterxml.jackson.core.type.TypeReference;
import com.tykj.dev.config.base.DeviceLifeStatus;
import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.device.allot.service.AllotBackBillService;
import com.tykj.dev.device.allot.subject.domin.AllotBackBill;
......@@ -15,6 +16,10 @@ import com.tykj.dev.device.library.subject.Dto.DeviceLogDto;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.library.subject.vo.FileVo;
import com.tykj.dev.device.library.subject.vo.ScriptSaveVo;
import com.tykj.dev.device.repair.subject.domin.RepairDetail;
import com.tykj.dev.device.repair.subject.domin.RepairSendBill;
import com.tykj.dev.device.repair.subject.vo.DeviceDetailVo;
import com.tykj.dev.device.repair.subject.vo.RevokeUnderTask;
import com.tykj.dev.device.task.service.TaskService;
import com.tykj.dev.device.task.subject.bto.TaskBto;
import com.tykj.dev.device.user.read.service.MessageService;
......@@ -689,4 +694,193 @@ public class BackController {
return ResponseEntity.ok(allotBackBillService.getFileList(taskId));
}
@ApiOperation(value = "省直属发起退回业务", notes = "可以通过这个接口发起退回任务")
@PostMapping(value = "/addDirectlyUnderBackBill")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity addDirectlyUnderBackBill(@RequestBody @Validated AllotBillSaveVo allotBillSaveVo) {
//当前登录单位的级别
Integer currentUnitLevel = userUtils.getCurrentUnitLevel();
AllotBackBill allotBackBill1 = new AllotBackBill();
if (currentUnitLevel == 1){
//判断发起退回的装备的生命状态
if (allotBillSaveVo.getAllotCheckDetail()!=null&&allotBillSaveVo.getAllotCheckDetail().length()>0) {
deviceLibraryService.isInStockOrWaitRetired(StringSplitUtil.split(allotBillSaveVo.getAllotCheckDetail()));
}
//1.添加退回单
AllotBackBill a = allotBillSaveVo.toBackDo();
//保存后的实体
AllotBackBill allotBackBill;
//如果是直接发起(不是草稿,没有taskId),当前操作人为发件方A岗,添加账单
if (allotBillSaveVo.getTaskId()==null){
// a.setSendUseraId(userUtils.getCurrentUserId());
allotBackBill = allotBackBillService.addEntity(a);
}
//从草稿发起
else {
//获取草稿账单
allotBackBill = allotBackBillService.getOne(taskService.get(allotBillSaveVo.getTaskId()).getBillId());
//copy非null相同字段值
MapperUtils.copyNoNullProperties(a,allotBackBill);
//判断是否取消上传申请单和批复单据
if (a.getApplyFiles()==null||"".equals(a.getApplyFiles())){
allotBackBill.setApplyFiles(null);
}
if (a.getReplyFiles()==null||"".equals(a.getReplyFiles())){
allotBackBill.setReplyFiles(null);
}
allotBackBill = allotBackBillService.update(allotBackBill);
}
//按照当前时间和保存账单的id拼接生成退回单号并保存
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
int year = calendar.get(Calendar.YEAR);
String num = "NO:第" + year + "TH" + allotBackBill.getId() + "号";
allotBackBill.setNum(num);
//进行赋值
BeanUtils.copyProperties(allotBillSaveVo,allotBackBill);
allotBackBill1 = allotBackBillService.update(allotBackBill);
Integer billId = allotBackBill.getId();
Integer userId = userUtils.getCurrentUserId();
String deviceIdDetail = allotBackBill.getBackCheckDetail();
//2.发起任务
//构建task涉及人员集合
List<Integer> userIds = new ArrayList<>();
userIds.add(userId);
userIds.add(0);
//保存后的taskBto
TaskBto saveEntity = new TaskBto();
//直接发起
if (allotBillSaveVo.getTaskId()==null) {
TaskBto taskBto = new TaskBto(StatusEnum.REPAIR_BACK_UNDER_DRAFT.id, "["+allotBillSaveVo.getReceiveUnit().substring(0,3)+"]型号"+StringSplitUtil.stringListToString(allotBillSaveVo.getScriptSaveVos().stream().map(ScriptSaveVo::getModel).distinct().collect(Collectors.toList()))+"的装备共有"+allotBillSaveVo.getAllotCount()+"件", null, ".", billId, 22, userPublicService.findUnitIdByName(allotBillSaveVo.getReceiveUnit()), 1, "country", userIds);
taskService.moveToEnd(taskBto);
}
//从草稿发起
else {
TaskBto taskBto = taskService.get(allotBillSaveVo.getTaskId());
//添加当前操作人为涉及人员
TaskBto taskBto1 = taskService.addInvolveUser(taskBto,userId);
taskBto1.setCustomInfo("country");
//任务所属单位改为收件单位
taskBto1.setOwnUnit(userPublicService.findUnitIdByName(allotBillSaveVo.getReceiveUnit()));
taskService.moveToEnd(taskBto);
}
List<FileVo> fileVoList = new ArrayList<>();
//存装备日志
String[] strings = deviceIdDetail.split("x");
//存放所有出库装备id
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);
deviceLibraryEntity.setOwnUnit(allotBackBill.getReceiveUnit());
deviceLibraryEntity.setLocationUnit(allotBackBill.getReceiveUnit());
deviceLibraryService.update(deviceLibraryEntity);
//存装备日志
DeviceLogDto deviceLogDto = new DeviceLogDto(id, "对" + allotBackBill.getReceiveUnit() + "发起退回", fileVoList,saveEntity.getId(),saveEntity.getId());
deviceLogService.addLog(deviceLogDto);
}
}
//添加出库白名单
inputOutputDeviceService.addWhiteDevices(ids, userUtils.getCurrentUnitId(), 1);
//发送阅知信息
List<Integer> idList = userPublicService.findOtherUser(userId);
idList.addAll(userDao.findAllByUnitsId(userPublicService.findUnitIdByName(allotBackBill.getReceiveUnit())).stream()
.map(User::getUserId)
.collect(Collectors.toList()));
//给被选签发人推阅知
if (allotBillSaveVo.getSendUserbId()!=null) {
List<Integer> idList1 = new ArrayList<>();
idList1.add(allotBillSaveVo.getSendUserbId());
MessageBto messageBto = new MessageBto(saveEntity.getId(), saveEntity.getBusinessType(), "被选为签发人", idList1, 1);
messageService.add(messageBto);
}
//给同单位专管员和收件单位专管员推阅知
MessageBto messageBto = new MessageBto(saveEntity.getId(),saveEntity.getBusinessType(),"对" + userPublicService.getAreaNameByUnitName(allotBackBill.getReceiveUnit()) + "发起退回",idList,1);
messageService.add(messageBto);
log.info("[退回模块]:" + allotBackBill.getSendUnit() + "对" + allotBackBill.getReceiveUnit() + "发起退回");
//添加taskId
allotBackBill1.setTaskId(saveEntity.getId());
myWebSocket.sendMessage1();
}
return ResponseEntity.ok(new ResultObj(allotBackBill1, "发起成功"));
}
@ApiOperation(value = "保存省直属退回操作(草稿)", notes = "可以通过这个接口保存退回操作")
@PostMapping(value = "/saveUnderBackBill")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity saveUnderBackBill(@RequestBody AllotBillSaveVo allotBillSaveVo) {
//判断装备的生命状态是否能退回
if (allotBillSaveVo.getAllotCheckDetail()!=null&&allotBillSaveVo.getAllotCheckDetail().length()>0) {
deviceLibraryService.isInStockOrWaitRetired(StringSplitUtil.split(allotBillSaveVo.getAllotCheckDetail()));
}
//第一次保存(没有taskId)
if (allotBillSaveVo.getTaskId()==null){
Integer userId = userUtils.getCurrentUserId();
//保存退回单
List<Integer> userIds = new ArrayList<>();
userIds.add(userId);
userIds.add(0);
//转Do
AllotBackBill allotBackBill = allotBillSaveVo.toBackDo();
//状态设为草稿
allotBackBill.setBackStatus(1);
//发件A岗设为当前操作人
allotBackBill.setReceiveUseraId(userId);
BeanUtils.copyProperties(allotBillSaveVo,allotBackBill);
//按照当前时间和保存账单的id拼接生成退回单号并保存
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
int year = calendar.get(Calendar.YEAR);
String num = "NO:第" + year + "TH" + allotBackBill.getId() + "号";
allotBackBill.setNum(num);
AllotBackBill allotBackBill1 = allotBackBillService.addEntity(allotBackBill);
//发起草稿任务
TaskBto taskBto = new TaskBto(StatusEnum.BACK_UNDER_DRAFT.id, "["+allotBillSaveVo.getReceiveUnit().substring(0,3)+"]型号"+StringSplitUtil.stringListToString(allotBillSaveVo.getScriptSaveVos().stream().map(ScriptSaveVo::getModel).distinct().collect(Collectors.toList()))+"的装备共有"+allotBillSaveVo.getAllotCount()+"件", null, ".", allotBackBill1.getId(), 22, userUtils.getCurrentUnitId(), 0, "country", userIds);
TaskBto taskBto1 = taskService.start(taskBto);
//返回保存成功的id
Integer id = taskBto1.getId();
myWebSocket.sendMessage1();
return ResponseEntity.ok("保存成功"+id);
}
else {
//更新账单
TaskBto taskBto = taskService.get(allotBillSaveVo.getTaskId());
AllotBackBill allotBackBill = allotBackBillService.getOne(taskBto.getBillId());
AllotBackBill allotBackBill1 = allotBillSaveVo.toBackDo();
//状态设为草稿
allotBackBill1.setBackStatus(1);
MapperUtils.copyNoNullProperties(allotBackBill1,allotBackBill);
allotBackBillService.update(allotBackBill);
return ResponseEntity.ok("更新成功"+taskBto.getId());
}
}
@ApiOperation(value = "省直属草稿的撤回", notes = "可以通过这个接口保存维修操作")
@PostMapping(value = "/revokeUnderBackBill")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity revokeUnderBackBill(@RequestBody RevokeUnderTask revokeUnderTask) {
Integer taskId = revokeUnderTask.getTaskId();
List<DeviceDetailVo> deviceDetailVos = revokeUnderTask.getDeviceDetailVos();
//取出装备id
List<Integer> deviceIds = deviceDetailVos.stream().map(DeviceDetailVo::getDeviceId).collect(Collectors.toList());
//根据taskId查询task
TaskBto taskBto = taskService.get(taskId);
//查询账单
Integer billId = taskBto.getBillId();
//查询退回单
AllotBackBill allotBackBill = allotBackBillService.getOne(billId);
//修改装备得所属所在
deviceLibraryService.updateLocalAndOwn(allotBackBill.getReceiveUnit(),deviceIds);
allotBackBillService.deleteByAllotBackId(billId);
taskService.deleteById(taskId);
return ResponseEntity.ok("撤回成功");
}
}
......@@ -51,14 +51,20 @@ public class AllotBillSaveVo {
@ApiModelProperty(value = "发件方(B岗位)")
private Integer sendUserbId;
@ApiModelProperty(value = "发件经办人id(A岗位)")
private Integer sendUseraId;
// @ApiModelProperty(value = "签章审核方")
// private Integer confirmUserId;
// @NotNull(message = "receiveUseraId不能为空")
@Min(value = 1,message = "receiveUseraId不能小于1")
// @Min(value = 1,message = "receiveUseraId不能小于1")
@ApiModelProperty(value = "收件方(A岗位)")
private Integer receiveUseraId;
@ApiModelProperty(value = "收件方审核人id(B岗位)")
private Integer receiveUserbId;
// @NotNull(message = "fileName不能为空")
@ApiModelProperty(value = "账单文件名")
private String fileName;
......
......@@ -328,6 +328,7 @@ public enum LogType {
REPAIR_SEND_19(129,REPAIR.id, REPAIR_SEND_WAIT_SIGN.id, END.id, "上传相关单据,业务办结"),
REPAIR_SEND_20(130,REPAIR.id, REPAIR_SEND_WAIT_SIGN.id, WAIT_UPLOAD_FILE.id, "盖电子签章并入库"),
REPAIR_SEND_21(131,REPAIR.id, REPAIR_SEND_SIGN_WAIT_CONFIRM.id, WAIT_RECEIVE.id, "拒绝电子签章申请"),
// REPAIR_SEND_22(131,REPAIR.id, REPAIR_SEND_SIGN_WAIT_CONFIRM.id, WAIT_RECEIVE.id, "拒绝电子签章申请"),
REPAIR_BACK_14(132, REPAIR.id, ORIGIN_STATUS.id, REPAIR_BACK_SIGN_WAIT_CONFIRM.id, "申请电子签章"),
REPAIR_BACK_16(134,REPAIR.id, REPAIR_BACK_SIGN_WAIT_CONFIRM.id, REPAIR_BACK_DRAFT.id, "拒绝电子签章申请"),
......@@ -337,7 +338,6 @@ public enum LogType {
REPAIR_BACK_19(137,REPAIR.id, REPAIR_BACK_WAIT_SIGN.id, END.id, "盖电子签章并出库"),
// REPAIR_BACK_20(138,REPAIR.id, REPAIR_BACK_WAIT_SIGN.id, WAIT_UPLOAD_BACK_FILE.id, "盖电子签章并入库"),
REPAIR_BACK_20(138,REPAIR.id, REPAIR_BACK_WAIT_SIGN.id, WAIT_UPLOAD_BACK_FILE.id, "上传签收单"),
REPAIR_BACK_21(139,REPAIR.id, REPAIR_BACK_SIGN_WAIT_CONFIRM.id, WAIT_BACK_RECEIVE.id, "拒绝电子签章申请"),
APPLY_7(140,APPLY.id, WAIT_APPLY_FILE.id, END.id, "申请不同意,业务办结"),
// ALLOT_BACK_16(141,ALLOT_BACK.id, BACK_DRAFT.id, ALLOT_BACKING.id, "从草稿发起退回"),
......@@ -372,7 +372,8 @@ public enum LogType {
SELF_CHECK_7(169, SELF_CHECK.id,ORIGIN_STATUS.id,WAIT_SELF_CHECK.id,"待自查任务"),
//[业务操作日志]存储失败:找不到业务类型为+4,旧状态为400,新状态为8888的日志模板
SELF_CHECK_8(170,SELF_CHECK.id,WAIT_SELF_CHECK.id,ARCHIVE.id,"核查结束,系统发起的自查自动结束"),
;
REPAIR_BACK_21(171,REPAIR.id, ORIGIN_STATUS.id, REPAIR_SEND_UNDER_DRAFT.id, "省直属等待出库"),
ALLOT_BACK_21(172,ALLOT_BACK.id,ORIGIN_STATUS.id,BACK_UNDER_DRAFT.id,"省直属等待出库");
public Integer id;
......
......@@ -292,8 +292,125 @@ public class DeviceLibraryController {
map.put("models",modelToSort);
List<String> nameList = names.stream().distinct().sorted(Comparator.comparing(s -> s)).collect(Collectors.toList());
map.put("names",nameList);
// map.put("ownUnits",ownUnits);
// map.put("locationUnits",locationUnits);
List<String> finalOwnUnits = DeviceModelSort.unitToSort(ownUnits);
map.put("ownUnits",finalOwnUnits.stream().distinct().collect(Collectors.toList()));
List<String> finalLocationUnits = DeviceModelSort.unitToSort(locationUnits);
map.put("locationUnits",finalLocationUnits.stream().distinct().collect(Collectors.toList()));
map.put("lifeStatus",status.stream().map(integer -> new LifeStatusVo(integer,lifeStatusMap.get(integer))).collect(Collectors.toList()));
map.put("storageLocation",storageLocation);
//形态
List<TypeVo> typeVoList = types.stream().distinct().map(integer -> new TypeVo(integer, styleMap.get(integer))).sorted(Comparator.comparing(TypeVo::getType)).collect(Collectors.toList());
map.put("types",typeVoList);
return ResultUtil.success(map);
}
@ApiOperation(value = "查询省直属模糊查询核心装备分页", notes = "可以通过这个接口查询装备列表")
@PostMapping("/core/feature/under/summary")
public ResponseEntity selectUnderCoreDevicePage(@RequestBody DeviceLibrarySelectVo deviceLibrarySelectVo) {
Boolean hasModelDim = deviceLibrarySelectVo.getModelDim()!=null;
Boolean hasNameDim = deviceLibrarySelectVo.getNameDim()!=null;
Boolean hasSeqDim = deviceLibrarySelectVo.getSeqDim()!=null;
Boolean hasLocationUnitDim = deviceLibrarySelectVo.getLocationUnitDim()!=null;
Boolean hasOwnUnitDim = deviceLibrarySelectVo.getOwnUnitDim()!=null;
Boolean hasLifeStatusDim = deviceLibrarySelectVo.getLifeStatusDim()!=null;
Boolean hasUpdateTimeDim = deviceLibrarySelectVo.getUpdateTimeDim()!=null;
Boolean hasRfidCardDim = deviceLibrarySelectVo.getRfidCardDim()!=null;
//库存位置
Boolean hasStorageLocationDim = deviceLibrarySelectVo.getRfidCardDim()!=null;
//形态
// Boolean hasTypeDim = deviceLibrarySelectVo.getTypeDim()!=null;
SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" );
List<DeviceLibrary> resultList = deviceLibraryService.getCoreDevicePage(deviceLibrarySelectVo);
if (hasModelDim||hasLifeStatusDim||hasLocationUnitDim||hasNameDim||hasOwnUnitDim||hasSeqDim) {
resultList = resultList.stream().filter(deviceLibrary -> {
Boolean containModelDim = !hasModelDim||deviceLibrary.getModel().contains(deviceLibrarySelectVo.getModelDim());
Boolean containNameDim = !hasNameDim||deviceLibrary.getName().contains(deviceLibrarySelectVo.getNameDim());
Boolean containSeqDim = !hasSeqDim||deviceLibrary.getSeqNumber().contains(deviceLibrarySelectVo.getSeqDim());
Boolean containLocationUnitDim = !hasLocationUnitDim||deviceLibrary.getLocationUnit().contains(deviceLibrarySelectVo.getLocationUnitDim());
Boolean containOwnUnitDim = !hasOwnUnitDim||deviceLibrary.getOwnUnit().contains(deviceLibrarySelectVo.getOwnUnitDim());
Boolean containLifeStatusDim = !hasLifeStatusDim||deviceLibrary.getLifeStatusName().contains(deviceLibrarySelectVo.getLifeStatusDim());
Boolean containUpdateTimeDim = !hasUpdateTimeDim||sdf.format(deviceLibrary.getUpdateTime()).contains(deviceLibrarySelectVo.getUpdateTimeDim());
Boolean containRfidCardDim = !hasRfidCardDim||(deviceLibrary.getRfidCardId()!=null&&deviceLibrary.getRfidCardId().contains(deviceLibrarySelectVo.getRfidCardDim()));
Boolean containStorageLocationDim = !hasStorageLocationDim||deviceLibrary.getStorageLocation().contains(deviceLibrarySelectVo.getStorageLocationDim());
// Boolean containTypeDim = !hasTypeDim||deviceLibrary.getType().contains(deviceLibrarySelectVo.getTypeDim());
return containModelDim&&containNameDim&&containSeqDim&&containLocationUnitDim&&containOwnUnitDim&&containLifeStatusDim&&containUpdateTimeDim&&containRfidCardDim&&containStorageLocationDim;
}).collect(Collectors.toList());
}
// List<DeviceVo> deviceVos = resultList.stream().map(DeviceLibrary::parseVo).collect(Collectors.toList());
resultList.forEach(DeviceLibrary::setConfigName);
Map<Integer, DeviceLibrary> nodeCollect =
resultList.stream().collect(Collectors.toMap(DeviceLibrary::getId, deviceLibraryEntity -> deviceLibraryEntity));
// List<Comparator<DeviceVo>> comparators = new ArrayList<>();
// if (deviceLibrarySelectVo.getOrders().size() > 0) {
// for (CustomOrder c:deviceLibrarySelectVo.getOrders()) {
// if ("model".equals(c.getCoulmn())){
// if ("ASC".equals(c.getDirection().toString())) {
// comparators.add(Comparator.comparing(DeviceVo::getModel,Comparator.nullsFirst(String::compareTo)));
// }
// else if ("DESC".equals(c.getDirection().toString())) {
// comparators.add(Comparator.comparing(DeviceVo::getModel,Comparator.nullsFirst(String::compareTo)).reversed());
// }
// }
// else if ("name".equals(c.getCoulmn())){
// if ("ASC".equals(c.getDirection().toString())) {
// comparators.add(Comparator.comparing(DeviceVo::getName,Comparator.nullsFirst(String::compareTo)));
// }
// else if ("DESC".equals(c.getDirection().toString())) {
// comparators.add(Comparator.comparing(DeviceVo::getName,Comparator.nullsFirst(String::compareTo)).reversed());
// }
// }
// else if ("seqNumber".equals(c.getCoulmn())){
// if ("ASC".equals(c.getDirection().toString())) {
// comparators.add(Comparator.comparing(DeviceVo::getSeqNumber,Comparator.nullsFirst(String::compareTo)));
// }
// else if ("DESC".equals(c.getDirection().toString())) {
// comparators.add(Comparator.comparing(DeviceVo::getSeqNumber,Comparator.nullsFirst(String::compareTo)).reversed());
// }
// }
// }
// }
List<DeviceLibrary> containList = GetTreeUtils.parseTreeFromDown(
resultList,
DeviceLibrary::getId,
deviceLibraryEntity -> Optional.ofNullable(nodeCollect.get(deviceLibraryEntity.getPartParentId())),
DeviceLibrary::addChildNode
);
Page<DeviceLibrary> deviceLibraryEntities = PageUtil.getPerPage(deviceLibrarySelectVo.getPage(), deviceLibrarySelectVo.getSize(), containList, deviceLibrarySelectVo.getPageable());
Map<String,Object> map = new HashMap<>();
Map<Integer,String> lifeStatusMap = configCache.getLifeStatusMap();
//
Map<Integer, String> styleMap = configCache.getStyleMap();
Set<Integer> status = new HashSet<>();
List<String> models = new ArrayList<>();
List<String> names = new ArrayList<>();
List<String> ownUnits = new ArrayList<>();
List<String> locationUnits = new ArrayList<>();
Set<String> storageLocation = new HashSet<>();
//形态
List<Integer> types = new ArrayList<>();
resultList.forEach(deviceVo -> {
deviceVo.setConfigName();
status.add(deviceVo.getLifeStatus());
models.add(deviceVo.getModel());
names.add(deviceVo.getName());
ownUnits.add(deviceVo.getOwnUnit());
locationUnits.add(deviceVo.getLocationUnit());
storageLocation.add(deviceVo.getStorageLocation());
types.add(deviceVo.getType());
});
map.put("pages",deviceLibraryEntities);
//修改 增加排序
//做一下去重
List<String> finalModels = models.stream().distinct().collect(Collectors.toList());
List<String> modelToSort = DeviceModelSort.modelToSort(finalModels);
map.put("models",modelToSort);
List<String> nameList = names.stream().distinct().sorted(Comparator.comparing(s -> s)).collect(Collectors.toList());
map.put("names",nameList);
List<String> finalOwnUnits = DeviceModelSort.unitToSort(ownUnits);
map.put("ownUnits",finalOwnUnits.stream().distinct().collect(Collectors.toList()));
List<String> finalLocationUnits = DeviceModelSort.unitToSort(locationUnits);
......@@ -484,12 +601,9 @@ public class DeviceLibraryController {
List<DeviceStatisticsVo> deviceStatisticsVoList = deviceLibraryService.getDeviceStatisticsPage(deviceLibrarySelectVo, deviceLibrarySelectVo.getPageable(),deviceLibrarySelectVo.getPageable().getSort());
List<DeviceStatisticsVo> deviceStatisticsVoSorts = deviceStatisticsVoList.stream()
.sorted(Comparator.comparing(DeviceStatisticsVo::getModel).thenComparing(DeviceStatisticsVo::getName)).collect(Collectors.toList());
// Page<DeviceStatisticsVo> deviceStatisticsVos = PageUtil.getPerPage(deviceLibrarySelectVo.getPage(), deviceLibrarySelectVo.getSize(), deviceStatisticsVoList, deviceLibrarySelectVo.getPageable());
Page<DeviceStatisticsVo> deviceStatisticsVos = PageUtil.getPerPage(deviceLibrarySelectVo.getPage(), deviceLibrarySelectVo.getSize(), deviceStatisticsVoSorts, deviceLibrarySelectVo.getPageable());
Map<String,Object> map = new HashMap<>();
Map<Integer, String> styleMap = configCache.getStyleMap();
// Set<String> models = deviceStatisticsVoList.stream().map(DeviceStatisticsVo::getModel).collect(Collectors.toSet());
// Set<String> modelToSort = DeviceModelSort.modelToSort(models);
List<String> models = deviceStatisticsVoList.stream().map(DeviceStatisticsVo::getModel).distinct().collect(Collectors.toList());
List<String> modelToSort = DeviceModelSort.modelToSort(models);
map.put("pages",deviceStatisticsVos);
......@@ -497,7 +611,6 @@ public class DeviceLibraryController {
//名称排序
map.put("names",deviceStatisticsVoList.stream().map(DeviceStatisticsVo::getName).distinct().sorted(Comparator.comparing(String::toString)).collect(Collectors.toList()));
//形态
// map.put("typeName",deviceStatisticsVoList.stream().map(DeviceStatisticsVo::getTypeName).distinct().sorted(Comparator.comparing(String::toString)).collect(Collectors.toList()));
List<Integer> types = deviceStatisticsVoList.stream().map(DeviceStatisticsVo::getType).distinct().collect(Collectors.toList());
Collections.sort(types);
map.put("types",types.stream().map(integer -> new TypeVo(integer,styleMap.get(integer))).collect(Collectors.toList()));
......
......@@ -174,5 +174,10 @@ public interface DeviceLibraryDao extends JpaRepository<DeviceLibrary, Integer>,
@Modifying
@Query("update DeviceLibrary d set d.ownUnit = d.locationUnit ,d.lifeStatus = 2 where d.id in :deviceIds")
int updateDevicesOwnUnit(@Param("deviceIds") List<Integer> deviceIds);
@Transactional
@Modifying
@Query("update DeviceLibrary d set d.ownUnit = :ownUnit,d.locationUnit = :ownUnit,d.lifeStatus = 2 where d.id in :deviceIds")
int updateDevicesOwnUnit(@Param("ownUnit") String ownUnit,@Param("deviceIds") List<Integer> deviceIds);
}
......@@ -241,4 +241,9 @@ public interface DeviceLibraryService {
* @param deviceIds 装备id
*/
void updateDevicesOwnUnit(List<Integer> deviceIds);
/**
* @param
*/
void updateLocalAndOwn(String localUnit,List<Integer> deviceIds);
}
......@@ -735,6 +735,11 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
deviceLibraryDao.updateDevicesOwnUnit(deviceIds);
}
@Override
public void updateLocalAndOwn(String localUnit,List<Integer> deviceIds) {
deviceLibraryDao.updateDevicesOwnUnit(localUnit,deviceIds);
}
@Override
public DeviceLibrary update(DeviceLibrary deviceLibraryEntity) {
......
......@@ -272,6 +272,7 @@ public enum StatusEnum {
REPAIR_SEND_DRAFT(788,"等待出库"),
REPAIR_SEND_SIGN_WAIT_CONFIRM(790,"申请签章待审核"),
REPAIR_SEND_WAIT_SIGN(791,"等待盖章"),
REPAIR_SEND_UNDER_DRAFT(799,"省直属等待出库"),
/**
* 维修完成退回状态
*/
......@@ -283,6 +284,7 @@ public enum StatusEnum {
REPAIR_BACK_SIGN_WAIT_CONFIRM(820,"申请签章待审核"),
REPAIR_BACK_WAIT_SIGN(821,"等待盖章"),
REPAIR_BACK_DRAFT(888,"等待出库"),
REPAIR_BACK_UNDER_DRAFT(889,"省直属等待出库"),
/**
* 配发退回状态
......@@ -294,7 +296,7 @@ public enum StatusEnum {
BACK_DRAFT(922,"草稿"),
BACK_SIGN_WAIT_CONFIRM(930,"申请签章待审核"),
BACK_WAIT_SIGN(931,"等待盖章"),
BACK_UNDER_DRAFT(932,"等待省直属退回"),
/**
* 报废状态
*/
......
......@@ -139,6 +139,9 @@ public class RepairController {
@Autowired
private RepairBillService repairBillService;
@Autowired
private RepairDetailService repairDetailService;
@ApiOperation(value = "判断维修装备是否同一个送修单位", notes = "可以通过这个接口判断维修装备是否同一个送修单位")
@PostMapping(value = "/judge")
@Transactional(rollbackFor = Exception.class)
......@@ -162,6 +165,7 @@ public class RepairController {
@PostMapping(value = "/saveRepairBill")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity saveRepairBill(@RequestBody RepairBillSaveVo repairBillSaveVo) {
Integer currentUnitLevel = userUtils.getCurrentUnitLevel();
//判断装备的状态是否在库或维修中
deviceLibraryService.isInStockOrRepairing(StringSplitUtil.split(repairBillSaveVo.getRepairDeviceCheckDetail()));
//第一次保存
......@@ -199,11 +203,16 @@ public class RepairController {
deviceRepairSendBillService.addEntity(deviceRepairSendBillEntity);
//发起任务
TaskBto taskBto = new TaskBto(StatusEnum.REPAIR_SEND_DRAFT.id, "["+repairBillSaveVo.getReceiveUnit().substring(0,3) + "]型号" + StringSplitUtil.stringListToString(repairBillSaveVo.getScriptSaveVos().stream().map(ScriptSaveVo::getModel).distinct().collect(Collectors.toList())) + "共有" + repairBillSaveVo.getSendingCount() + "件",null, ".", repairBill1.getId(), 5, userUtils.getCurrentUnitId(), 0, null, userIds);
//如果是省发起的维修
if (currentUnitLevel == 1){
taskBto.setCustomInfo("country");
}
TaskBto taskBto1 = taskService.start(taskBto);
Integer id = taskBto1.getId();
myWebSocket.sendMessage1();
return ResponseEntity.ok("保存成功" + id + "&" + s1);
} else {
}
else {
//更新账单
TaskBto taskBto = taskService.get(repairBillSaveVo.getTaskId());
RepairBill repairBill1 = deviceRepairBillService.getOne(taskBto.getBillId());
......@@ -859,6 +868,7 @@ public class RepairController {
@PostMapping(value = "/saveRepairBackBill")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity saveRepairBackBill(@RequestBody RepairBackBillSaveVo repairBackBillSaveVo) {
Integer currentUnitLevel = userUtils.getCurrentUnitLevel();
//第一次保存
if (repairBackBillSaveVo.getTaskId() == null) {
Integer userId = userUtils.getCurrentUserId();
......@@ -879,6 +889,9 @@ public class RepairController {
deviceRepairBackBillService.update(repairBackBill1);
//发起任务
TaskBto taskBto = new TaskBto(StatusEnum.REPAIR_BACK_DRAFT.id, "["+repairBackBillSaveVo.getReceiveUnit().substring(0,3) + "]型号" + repairBackBillSaveVo.getScriptSaveVos().get(0).getModel() + "共有" + repairBackBillSaveVo.getSendingCount() + "件至", null, ".", repairBackBill1.getId(), BusinessEnum.REPAIR_BACK.id, userUtils.getCurrentUnitId(), 0, null, userIds);
if (currentUnitLevel == 1){
taskBto.setCustomInfo("country");
}
TaskBto taskBto1 = taskService.start(taskBto);
Integer id = taskBto1.getId();
myWebSocket.sendMessage1();
......@@ -2433,7 +2446,7 @@ public class RepairController {
@Autowired
private Executor executor;
@GetMapping("updateRemark")
@ApiOperation("通过任务id查询维修退回账单中文件")
@ApiOperation("更新备注")
public void updateRemark(UpdateRemarkVos updateRemarkVos){
List<UpdateRemarkVo> remarkVos = updateRemarkVos.getUpdateRemarkVos();
//通过维修详情id查询
......@@ -2457,6 +2470,459 @@ public class RepairController {
});
}
@PostMapping("AddDirectlyUnderRepairBill")
@ApiOperation("省直属发起维修")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity AddDirectlyUnderRepairBill(@RequestBody @Validated RepairBillSaveVo repairBillSaveVo){
//判断装备状态是不是在库和维修中
deviceLibraryService.isInStockOrRepairing(StringSplitUtil.split(repairBillSaveVo.getRepairDeviceCheckDetail()));
//存放详情id
List<Integer> detailIds = new ArrayList<>();
repairBillSaveVo.getDeviceList().forEach(deviceDetailVo -> {
if (deviceDetailVo.getId() != null) {
detailIds.add(deviceDetailVo.getId());
}
});
//判断维修详情的状态
if (detailIds.size() > 0) {
detailIds.forEach(integer -> {
RepairDetail repairDetail = deviceRepairDetailService.getOne(integer);
if ((repairDetail.getRepairStatus() != 1 && repairDetail.getRepairStatus() != 9) || repairDetailDao.findAllByPid(repairDetail.getId()).size() > 0) {
throw new ApiException(ResponseEntity.status(303).body("序列号" + repairDetail.getSeqNumber() + "的装备已被其他专管员操作"));
}
});
}
Integer userId = userUtils.getCurrentUserId();
Integer level = userUtils.getCurrentUnitLevel();
//添加维修单和送修单
RepairBill repairBill;
RepairSendBill deviceRepairSendBillEntity;
//草稿发起的
if (repairBillSaveVo.getTaskId() != null) {
repairBill = deviceRepairBillService.getOne(taskService.get(repairBillSaveVo.getTaskId()).getBillId());
deviceRepairSendBillEntity = deviceRepairSendBillDao.findByDeviceRepairBillId(repairBill.getId());
MapperUtils.copyNoNullProperties(repairBillSaveVo, repairBill);
MapperUtils.copyNoNullProperties(repairBillSaveVo, deviceRepairSendBillEntity);
} else {
RepairBill repairBill1 = new RepairBill();
RepairSendBill deviceRepairSendBillEntity1 = new RepairSendBill();
BeanUtils.copyProperties(repairBillSaveVo, repairBill1);
BeanUtils.copyProperties(repairBillSaveVo, deviceRepairSendBillEntity1);
repairBill = deviceRepairBillService.addEntity(repairBill1);
deviceRepairSendBillEntity1.setDeviceRepairBillId(repairBill.getId());
deviceRepairSendBillEntity = deviceRepairSendBillService.addEntity(deviceRepairSendBillEntity1);
}
if (repairBillSaveVo.getScriptSaveVos() != null) {
deviceRepairSendBillEntity.setScriptJson(JacksonUtil.toJSon(repairBillSaveVo.getScriptSaveVos()));
}
repairBill.setRepairStatus(2);//运输中
deviceRepairSendBillEntity.setRepairStatus(2);
if (repairBillSaveVo.getRepairUseraId() != null) {
repairBill.setRepairUserA(userPublicService.getOne(repairBillSaveVo.getRepairUseraId()).getName());
}
repairBill.setStartUserB(repairBillSaveVo.getAgent());
repairBill.setStartUserA(userPublicService.getOne(repairBillSaveVo.getStartUseraId()).getName());
//生成单据号
Calendar calendar = Calendar.getInstance();
String s1 = "NO:第" + calendar.get(Calendar.YEAR) + "WX" + repairBill.getId() + "号";
repairBill.setDocNum(s1);
RepairBill repairBill1 = deviceRepairBillService.update(repairBill);
//发起维修业务
List<Integer> userIds = new ArrayList<>();
userIds.add(userId);
userIds.add(0);
//发送时间
deviceRepairSendBillEntity.setSendTime(new Date());
//存放维修装备id和维修原因的组合字段
StringBuffer stringBuffer = new StringBuffer();
//存维修详情单
// for (DeviceDetailVo d : repairBillSaveVo.getDeviceList()) {
// //存放旧详情
// RepairDetail oldRepairDetail = null;
// //从待维修列表发起维修的
// if (d.getId() != null) {
// oldRepairDetail = deviceRepairDetailService.getOne(d.getId());
// }
// stringBuffer.append(d.getDeviceId());
// stringBuffer.append("Ǵ");
// stringBuffer.append(d.getRemark());
// stringBuffer.append("Ǵ");
// //获取装备信息
// DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(d.getDeviceId());
// //待维修列表当前单位自己添加的维修记录
// if (oldRepairDetail != null && oldRepairDetail.getDeviceRepairBillId() == 0) {
// oldRepairDetail.setRemark(d.getRemark());
// oldRepairDetail.setDeviceRepairBillId(repairBill1.getId());
// oldRepairDetail.setRepairStatus(0);
// deviceRepairDetailService.update(oldRepairDetail);
// } else {
// RepairDetail repairDetail = new RepairDetail();
// //如果是下级待维修装备继续发起维修
// if (d.getId() != null) {
// //set父id
// repairDetail.setPid(d.getId());
// RepairDetail repairDetail1 = deviceRepairDetailService.getOne(d.getId());
// repairDetail1.setRepairStatus(8);
// deviceRepairDetailService.update(repairDetail1);
// }
// repairDetail.setDeviceId(d.getDeviceId());
// repairDetail.setLocationUnit(userUtils.getCurrentUserUnitName());
// repairDetail.setModel(deviceLibraryEntity.getModel());
// repairDetail.setName(deviceLibraryEntity.getName());
// repairDetail.setOwnUnit(deviceLibraryEntity.getOwnUnit());
// repairDetail.setRemark(d.getRemark());
// repairDetail.setRepairStatus(0);
// repairDetail.setRfidSurfaceId(deviceLibraryEntity.getRfidSurfaceId());
// repairDetail.setSeqNumber(deviceLibraryEntity.getSeqNumber());
// repairDetail.setType(deviceLibraryEntity.getType());
// repairDetail.setDeviceRepairBillId(repairBill1.getId());
// deviceRepairDetailService.save(repairDetail);
// }
// //如果当前为省像国家发起的
// if (level == 1) {
// deviceLibraryEntity.setLifeStatus(4);
// deviceLibraryEntity.setLocationUnit(repairBillSaveVo.getReceiveUnit());
// } else {
// deviceLibraryEntity.setLifeStatus(4);
// }
// deviceLibraryEntity.setManageStatus(0);
// deviceLibraryService.update(deviceLibraryEntity);
// //存装备日志
//// DeviceLogDto deviceLogDto = new DeviceLogDto(d.getDeviceId(), "向" + repairBillSaveVo.getReceiveUnit() + "发起装备维修", null, null);
// DeviceLogDto deviceLogDto = new DeviceLogDto(d.getDeviceId(), "向" + repairBillSaveVo.getReceiveUnit() + "发起装备维修", null, null);
// deviceLogService.addLog(deviceLogDto);
// }
//存送修单
deviceRepairSendBillEntity.setRepairDeviceDetail(stringBuffer.toString());
deviceRepairSendBillEntity.setDeviceRepairBillId(repairBill1.getId());
deviceRepairSendBillEntity.setAgent(repairBillSaveVo.getAgent());
deviceRepairSendBillEntity.setTitle("["+repairBillSaveVo.getReceiveUnit().substring(0,3) + "]型号" + StringSplitUtil.stringListToString(repairBillSaveVo.getScriptSaveVos().stream().map(ScriptSaveVo::getModel).distinct().collect(Collectors.toList())) + "共有" + repairBillSaveVo.getSendingCount() + "件");
if (repairBillSaveVo.getSendFileList() != null && repairBillSaveVo.getSendFileList().size() > 0) {
deviceRepairSendBillEntity.setSendFiles(FilesUtil.stringFileToList(repairBillSaveVo.getSendFileList()));
}
if (repairBillSaveVo.getReceiveFileList() != null && repairBillSaveVo.getReceiveFileList().size() > 0) {
deviceRepairSendBillEntity.setReceiveFiles(FilesUtil.stringFileToList(repairBillSaveVo.getReceiveFileList()));
}
RepairSendBill repairSendBill = deviceRepairSendBillService.update(deviceRepairSendBillEntity);
//业务的待办所属单位
Integer ownUnit;
//保存后的taskBto
TaskBto saveEntity = new TaskBto();
//当前单位其他专管员id集合
List<Integer> ids = userPublicService.findOtherUser(userUtils.getCurrentUserId());
//省向国家发起的
if (level == 1) {
ownUnit = userUtils.getCurrentUnitId();
//直接发起的
if (repairBillSaveVo.getTaskId() == null) {
TaskBto taskBto = new TaskBto(StatusEnum.WAIT_UPLOAD_FILE.id, "["+repairBillSaveVo.getReceiveUnit() + "]型号" + StringSplitUtil.stringListToString(repairBillSaveVo.getScriptSaveVos().stream().map(ScriptSaveVo::getModel).distinct().collect(Collectors.toList())) + "共有" + repairBillSaveVo.getSendingCount() + "件", null, ".", repairBill1.getId(), 5, ownUnit, 1, "country", userIds);
taskService.moveToEnd(taskBto);
}
//从草稿发起的
else {
TaskBto taskBto1 = taskService.get(repairBillSaveVo.getTaskId());
taskBto1.setTitle("["+repairBillSaveVo.getReceiveUnit() + "]型号" + StringSplitUtil.stringListToString(repairBillSaveVo.getScriptSaveVos().stream().map(ScriptSaveVo::getModel).distinct().collect(Collectors.toList())) + "共有" + repairBillSaveVo.getSendingCount() + "件");
taskBto1.setCustomInfo("country");
taskService.moveToEnd(taskBto1);
}
}
for (DeviceDetailVo d : repairBillSaveVo.getDeviceList()) {
//存放旧详情
RepairDetail oldRepairDetail = null;
//从待维修列表发起维修的
if (d.getId() != null) {
oldRepairDetail = deviceRepairDetailService.getOne(d.getId());
}
stringBuffer.append(d.getDeviceId());
stringBuffer.append("Ǵ");
stringBuffer.append(d.getRemark());
stringBuffer.append("Ǵ");
//获取装备信息
DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(d.getDeviceId());
//待维修列表当前单位自己添加的维修记录
if (oldRepairDetail != null && oldRepairDetail.getDeviceRepairBillId() == 0) {
oldRepairDetail.setRemark(d.getRemark());
oldRepairDetail.setDeviceRepairBillId(repairBill1.getId());
oldRepairDetail.setRepairStatus(0);
deviceRepairDetailService.update(oldRepairDetail);
}
else {
RepairDetail repairDetail = new RepairDetail();
//如果是下级待维修装备继续发起维修
if (d.getId() != null) {
//set父id
repairDetail.setPid(d.getId());
RepairDetail repairDetail1 = deviceRepairDetailService.getOne(d.getId());
repairDetail1.setRepairStatus(8);
deviceRepairDetailService.update(repairDetail1);
}
repairDetail.setDeviceId(d.getDeviceId());
repairDetail.setLocationUnit(userUtils.getCurrentUserUnitName());
repairDetail.setModel(deviceLibraryEntity.getModel());
repairDetail.setName(deviceLibraryEntity.getName());
repairDetail.setOwnUnit(deviceLibraryEntity.getOwnUnit());
repairDetail.setRemark(d.getRemark());
repairDetail.setRepairStatus(0);
repairDetail.setRfidSurfaceId(deviceLibraryEntity.getRfidSurfaceId());
repairDetail.setSeqNumber(deviceLibraryEntity.getSeqNumber());
repairDetail.setType(deviceLibraryEntity.getType());
repairDetail.setDeviceRepairBillId(repairBill1.getId());
deviceRepairDetailService.save(repairDetail);
}
//如果当前为省像国家发起的
if (level == 1) {
deviceLibraryEntity.setLifeStatus(4);
deviceLibraryEntity.setLocationUnit(repairBillSaveVo.getReceiveUnit());
}
deviceLibraryEntity.setManageStatus(0);
deviceLibraryService.update(deviceLibraryEntity);
//存装备日志
DeviceLogDto deviceLogDto = new DeviceLogDto(d.getDeviceId(), "向" + repairBillSaveVo.getReceiveUnit() + "发起装备维修", null, userId,saveEntity.getId());
deviceLogService.addLog(deviceLogDto);
}
// //gg
//获取装备id集合
String deviceIdDetail = deviceRepairSendBillEntity.getRepairDeviceCheckDetail();
List<Integer> idList = StringSplitUtil.split(deviceIdDetail);
//如果当前为省,改变装备的所在为中办
if (level == 1) {
//获取当前业务维修详情 记录
List<RepairDetail> repairDetailEntities = deviceRepairDetailService.findByBillId(repairBill.getId());
//改变维修详情装备所在单位为中办,状态为维修中
repairDetailEntities.forEach(repairDetail -> {
repairDetail.setLocationUnit(repairBillSaveVo.getReceiveUnit());
repairDetail.setRepairStatus(1);
deviceRepairDetailService.update(repairDetail);
});
}
//添加出库白名单
inputOutputDeviceService.addWhiteDevices(idList, userUtils.getCurrentUnitId(), 1);
//发送阅知信息
if (repairBillSaveVo.getStartUserbId() != null) {
List<Integer> idList1 = new ArrayList<>();
idList1.add(repairBillSaveVo.getStartUserbId());
MessageBto messageBto = new MessageBto(saveEntity.getId(), saveEntity.getBusinessType(), "被选为签发人", idList1, 1);
messageService.add(messageBto);
}
MessageBto messageBto = new MessageBto(saveEntity.getId(), saveEntity.getBusinessType(), "向" + userPublicService.getAreaNameByUnitName(repairBill.getReceiveUnit()) + "发起装备维修", ids, 1);
messageService.add(messageBto);
myWebSocket.sendMessage1();
//添加taskId
repairBill1.setTaskId(saveEntity.getId());
return ResultUtil.success(repairBill1);
}
@ApiOperation(value = "省修好装备出库给省直属", notes = "可以通过这个接口修好装备出库")
@PostMapping(value = "/AddDirectlyUnderBackBill")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity AddDirectlyUnderBackBill(@RequestBody @Validated RepairBackBillSaveVo repairBackBillSaveVo) {
//存放详情id
List<Integer> detailIds = new ArrayList<>();
repairBackBillSaveVo.getDeviceList().forEach(deviceDetailVo -> {
if (deviceDetailVo.getId() != null) {
detailIds.add(deviceDetailVo.getId());
}
});
//判断维修记录的状态
if (detailIds.size() > 0) {
detailIds.forEach(integer -> {
RepairDetail repairDetail = deviceRepairDetailService.getOne(integer);
if (repairDetail.getRepairStatus() != 2) {
throw new ApiException(ResponseEntity.status(303).body("序列号" + repairDetail.getSeqNumber() + "的装备已被其他专管员操作"));
}
});
}
//获取当前维修业务,维修单
Integer userId = userUtils.getCurrentUserId();
//生成维修退回单
RepairBackBill repairBackBill;
//草稿发起
if (repairBackBillSaveVo.getTaskId() != null) {
repairBackBill = deviceRepairBackBillService.getOne(taskService.get(repairBackBillSaveVo.getTaskId()).getBillId());
MapperUtils.copyNoNullProperties(repairBackBillSaveVo, repairBackBill);
} else {
RepairBackBill repairBackBill1 = new RepairBackBill();
BeanUtils.copyProperties(repairBackBillSaveVo, repairBackBill1);
repairBackBill = deviceRepairBackBillService.save(repairBackBill1);
}
repairBackBill.setBackStatus(2);
repairBackBill.setSendTime(new Date());
repairBackBill.setTitle("["+repairBackBillSaveVo.getReceiveUnit().substring(0,3) + "]型号" + StringSplitUtil.stringListToString(repairBackBillSaveVo.getScriptSaveVos().stream().map(ScriptSaveVo::getModel).distinct().collect(Collectors.toList())) + "共有" + repairBackBillSaveVo.getSendingCount() + "件");
repairBackBill.setAgent(repairBackBillSaveVo.getAgent());
if (repairBackBillSaveVo.getScriptSaveVos() != null) {
repairBackBill.setScriptJson(JacksonUtil.toJSon(repairBackBillSaveVo.getScriptSaveVos()));
}
RepairBackBill deviceRepairBackBillEntity1 = deviceRepairBackBillService.update(repairBackBill);
Calendar calendar = Calendar.getInstance();
String s1 = "NO:第" + calendar.get(Calendar.YEAR) + "LQ" + repairBackBill.getId() + "号";
deviceRepairBackBillEntity1.setDocNum(s1);
RepairBackBill repairBackBill1 = deviceRepairBackBillService.update(deviceRepairBackBillEntity1);
//发起维修退回子业务
List<Integer> userIds = new ArrayList<>();
userIds.add(userId);
userIds.add(0);
TaskBto task = new TaskBto();
//草稿发起
if (repairBackBillSaveVo.getTaskId() == null) {
task = new TaskBto(StatusEnum.WAIT_BACK_RECEIVE.id, "["+repairBackBillSaveVo.getReceiveUnit().substring(0,3) + "]型号" + StringSplitUtil.stringListToString(repairBackBillSaveVo.getScriptSaveVos().stream().map(ScriptSaveVo::getModel).distinct().collect(Collectors.toList())) + "共有" + repairBackBillSaveVo.getSendingCount() + "件", null, ".", deviceRepairBackBillEntity1.getId(), BusinessEnum.REPAIR_BACK.id, userPublicService.findUnitIdByName(repairBackBill.getReceiveUnit()), 1, "country", userIds);
} else {
task = taskService.get(repairBackBillSaveVo.getTaskId());
task.setOwnUnit(userPublicService.findUnitIdByName(repairBackBill.getReceiveUnit()));
}
taskService.moveToEnd(task);
//添加业务日志
List<FileVo> fileVoList = new ArrayList<>();
//更新装备和详情的状态,添加装备日志
for (DeviceDetailVo d : repairBackBillSaveVo.getDeviceList()) {
RepairDetail repairDetail = deviceRepairDetailService.getOne(d.getId());
repairDetail.setRepairBackBillId(deviceRepairBackBillEntity1.getId());
repairDetail.setRepairStatus(7);
repairDetail.setBackRemark(d.getRemark());
deviceRepairDetailService.update(repairDetail);
DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(d.getDeviceId());
deviceLibraryEntity.setLifeStatus(4);
deviceLibraryEntity.setManageStatus(0);
DeviceLogDto deviceLogDto = new DeviceLogDto(d.getDeviceId(), "向" + repairBackBillSaveVo.getReceiveUnit() + "退还维修装备", fileVoList, userId,task.getId());
deviceLogService.addLog(deviceLogDto);
}
String deviceIdDetail = repairBackBill.getBackCheckDetail();
List<Integer> idList = StringSplitUtil.split(deviceIdDetail);
//添加出库白名单
inputOutputDeviceService.addWhiteDevices(idList, userUtils.getCurrentUnitId(), 1);
//发送阅知信息
List<Integer> ids = userPublicService.findOtherUser(userUtils.getCurrentUserId());
ids.addAll(userDao.findAllByUnitsId(userPublicService.findUnitIdByName(repairBackBill.getReceiveUnit())).stream()
.map(User::getUserId)
.collect(Collectors.toList()));
if (repairBackBillSaveVo.getStartUserbId() != null) {
List<Integer> idList1 = new ArrayList<>();
idList1.add(repairBackBillSaveVo.getStartUserbId());
MessageBto messageBto = new MessageBto(task.getId(), task.getBusinessType(), "被选为签发人", idList1, 1);
messageService.add(messageBto);
}
MessageBto messageBto = new MessageBto(task.getId(), task.getBusinessType(), "向" + userPublicService.getAreaNameByUnitName(repairBackBill.getReceiveUnit()) + "退回维修装备", ids, 1);
messageService.add(messageBto);
myWebSocket.sendMessage1();
//添加taskId字段
repairBackBill1.setTaskId(task.getId());
return ResultUtil.success(repairBackBill1);
}
@ApiOperation(value = "查询装备是否可以被清退")
@PostMapping("/underRepair")
public ClearRepairVo underRepair(@RequestBody List<Integer> deviceIds){
return repairDetailService.underRepair(deviceIds);
}
@ApiOperation(value = "省直属发起维修保存草稿", notes = "可以通过这个接口保存维修操作")
@PostMapping(value = "/saveRepairUnderBill")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity saveRepairUnderBill(@RequestBody RepairBillSaveVo repairBillSaveVo) {
Integer currentUnitLevel = userUtils.getCurrentUnitLevel();
//判断装备的状态是否在库或维修中
deviceLibraryService.isInStockOrRepairing(StringSplitUtil.split(repairBillSaveVo.getRepairDeviceCheckDetail()));
//第一次保存
if (repairBillSaveVo.getTaskId() == null) {
Integer userId = userUtils.getCurrentUserId();
//保存入库单
List<Integer> userIds = new ArrayList<>();
userIds.add(userId);
userIds.add(0);
//添加维修单和送修单
RepairBill repairBill = new RepairBill();
RepairSendBill deviceRepairSendBillEntity = new RepairSendBill();
//相同字段直接拷贝
BeanUtils.copyProperties(repairBillSaveVo, repairBill);
BeanUtils.copyProperties(repairBillSaveVo, deviceRepairSendBillEntity);
//维修状态为草稿
repairBill.setRepairStatus(0);
deviceRepairSendBillEntity.setRepairStatus(0);
//set不相同的字段
if (repairBillSaveVo.getScriptSaveVos() != null) {
deviceRepairSendBillEntity.setScriptJson(JacksonUtil.toJSon(repairBillSaveVo.getScriptSaveVos()));
}
if (repairBillSaveVo.getRepairUseraId() != null) {
repairBill.setRepairUserA(userPublicService.getOne(repairBillSaveVo.getRepairUseraId()).getName());
}
repairBill.setRepairUserB(userUtils.getCurrentName());
repairBill.setStartUserB(userPublicService.getOne(repairBillSaveVo.getStartUserbId()).getName());
repairBill.setStartUserA(userPublicService.getOne(repairBillSaveVo.getStartUseraId()).getName());
RepairBill repairBill1 = deviceRepairBillService.addEntity(repairBill);
//生成单据号
Calendar calendar = Calendar.getInstance();
String s1 = "NO:第" + calendar.get(Calendar.YEAR) + "WX" + repairBill1.getId() + "号";
repairBill1.setDocNum(s1);
deviceRepairBillService.update(repairBill1);
//set 关联id
deviceRepairSendBillEntity.setDeviceRepairBillId(repairBill1.getId());
deviceRepairSendBillService.addEntity(deviceRepairSendBillEntity);
//发起任务
TaskBto taskBto = new TaskBto(StatusEnum.REPAIR_SEND_UNDER_DRAFT.id, "["+repairBillSaveVo.getReceiveUnit().substring(0,3) + "]型号" + StringSplitUtil.stringListToString(repairBillSaveVo.getScriptSaveVos().stream().map(ScriptSaveVo::getModel).distinct().collect(Collectors.toList())) + "共有" + repairBillSaveVo.getSendingCount() + "件",null, ".", repairBill1.getId(), 5, userUtils.getCurrentUnitId(), 0, null, userIds);
//如果是省发起的维修
if (currentUnitLevel == 1){
taskBto.setCustomInfo("country");
}
TaskBto taskBto1 = taskService.start(taskBto);
Integer id = taskBto1.getId();
myWebSocket.sendMessage1();
return ResponseEntity.ok("保存成功" + id + "&" + s1);
}
else {
//更新账单
TaskBto taskBto = taskService.get(repairBillSaveVo.getTaskId());
RepairBill repairBill1 = deviceRepairBillService.getOne(taskBto.getBillId());
RepairSendBill repairSendBill = deviceRepairSendBillDao.findByDeviceRepairBillId(repairBill1.getId());
RepairBill repairBill = new RepairBill();
RepairSendBill deviceRepairSendBillEntity = new RepairSendBill();
//复制到新的二个对象
BeanUtils.copyProperties(repairBillSaveVo, repairBill);
BeanUtils.copyProperties(repairBillSaveVo, deviceRepairSendBillEntity);
repairBill.setRepairStatus(0);
deviceRepairSendBillEntity.setRepairStatus(0);
if (repairBillSaveVo.getScriptSaveVos() != null) {
deviceRepairSendBillEntity.setScriptJson(JacksonUtil.toJSon(repairBillSaveVo.getScriptSaveVos()));
}
if (repairBillSaveVo.getRepairUseraId() != null) {
repairBill.setRepairUserA(userPublicService.getOne(repairBillSaveVo.getRepairUseraId()).getName());
}
repairBill.setStartUserB(repairBillSaveVo.getAgent());
repairBill.setStartUserA(userPublicService.getOne(repairBillSaveVo.getStartUseraId()).getName());
//将新对象不为null的值拷贝到真实对象
MapperUtils.copyNoNullProperties(repairBill, repairBill1);
MapperUtils.copyNoNullProperties(deviceRepairSendBillEntity, repairSendBill);
deviceRepairBillService.update(repairBill1);
deviceRepairSendBillService.update(repairSendBill);
return ResponseEntity.ok("更新成功" + taskBto.getId());
}
}
@ApiOperation(value = "省直属草稿的撤回", notes = "可以通过这个接口保存维修操作")
@PostMapping(value = "/revokeUnderRepairBill")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity revokeRepairUnderBill(@RequestBody RevokeUnderTask revokeUnderTask) {
Integer taskId = revokeUnderTask.getTaskId();
List<DeviceDetailVo> deviceDetailVos = revokeUnderTask.getDeviceDetailVos();
//取出装备id
List<Integer> deviceIds = deviceDetailVos.stream().map(DeviceDetailVo::getDeviceId).collect(Collectors.toList());
//根据taskId查询task
TaskBto taskBto = taskService.get(taskId);
//查询账单
Integer billId = taskBto.getBillId();
//查询送修单和维修单
RepairSendBill sendBill = repairSendBillService.findByRepairdId(billId);
//维修详情
List<RepairDetail> byBillId = repairDetailService.findByBillId(billId);
if (byBillId.size()>0){
byBillId.forEach(repairDetail -> repairDetailService.delete(repairDetail.getId()));
}
repairBillService.delete(billId);
repairSendBillService.delete(sendBill.getId());
taskService.deleteById(taskId);
deviceLibraryService.updateLifeStatus2(DeviceLifeStatus.IN_LIBRARY.id,deviceIds);
return ResponseEntity.ok("撤回成功");
}
private List<RepairDetail> sortMethod(List<CustomOrder> orders, List<RepairDetail> repairDetails2, List<RepairDetail> repairDetails1){
List<String> list = orders.stream().map(CustomOrder::getDirection).collect(Collectors.toList());
List<RepairDetail> finalList = new ArrayList<>();
......
......@@ -3,6 +3,7 @@ package com.tykj.dev.device.repair.service;
import com.tykj.dev.device.repair.subject.domin.RepairDetail;
import com.tykj.dev.device.repair.subject.vo.BillVo;
import com.tykj.dev.device.repair.subject.vo.ClearRepairVo;
import com.tykj.dev.device.repair.subject.vo.ClearTaskVo;
import com.tykj.dev.device.repair.subject.vo.SetDevicesOwnUnit;
......@@ -57,4 +58,9 @@ public interface RepairDetailService extends RepairPublicService<RepairDetail> {
*/
void setDevicesOwnUnit(List<BillVo> billVos);
/**
* @param deviceIds 装备id
*/
ClearRepairVo underRepair(List<Integer> deviceIds);
}
......@@ -14,6 +14,7 @@ import com.tykj.dev.device.repair.subject.domin.RepairBill;
import com.tykj.dev.device.repair.subject.domin.RepairDetail;
import com.tykj.dev.device.repair.subject.domin.RepairSendBill;
import com.tykj.dev.device.repair.subject.vo.BillVo;
import com.tykj.dev.device.repair.subject.vo.ClearRepairVo;
import com.tykj.dev.device.repair.subject.vo.ClearTaskVo;
import com.tykj.dev.device.repair.subject.vo.SetDevicesOwnUnit;
import com.tykj.dev.device.task.service.TaskService;
......@@ -22,6 +23,7 @@ import com.tykj.dev.device.task.subject.domin.Task;
import com.tykj.dev.device.user.read.subject.bto.MessageBto;
import com.tykj.dev.device.user.subject.entity.User;
import com.tykj.dev.misc.base.BusinessEnum;
import com.tykj.dev.misc.base.RepairStatusEnum;
import com.tykj.dev.misc.base.StatusEnum;
import com.tykj.dev.misc.exception.ApiException;
import com.tykj.dev.misc.utils.JacksonUtil;
......@@ -30,6 +32,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.concurrent.CompletableFuture;
......@@ -137,25 +140,80 @@ public class RepairDetailServiceImpl implements RepairDetailService {
});
}
// @Override
// public Map<Integer, ClearTaskVo> getClearTaskVo(List<Integer> deviceIds) {
// List<ClearTaskVo> clearTaskVos = new ArrayList<>();
// Map<Integer,ClearTaskVo> map1 = new HashMap<>();
// //通过装备id查询出账单id (送修单repairBill)
// List<RepairDetail> repairDetails = deviceRepairDetailDao.findAllByDeviceIdIn(deviceIds);
// //取出装备id相同的最新时间
// Map<Integer,RepairDetail> map =new HashMap<>();
// repairDetails.sort(Comparator.comparing(RepairDetail::getCreateTime));
// repairDetails.forEach(
// repairDetail -> {
// if (!map.containsKey(repairDetail.getDeviceId())){
// map.put(repairDetail.getDeviceId(),repairDetail);
// }
// }
// );
// List<BillVo> billVos = new ArrayList<>();
// map.forEach(
// (k,v)->{
// BillVo billVo = new BillVo();
// billVo.setRepairBillId(v.getDeviceRepairBillId());
// billVo.setDevicesId(v.getDeviceId());
// billVo.setRepairDetailId(v.getId());
// billVos.add(billVo);
// //根据装备id查询装备
// DeviceLibrary library = deviceLibraryService.getOne(v.getDeviceId());
// DeviceLibrary deviceLibrary = library.setConfigName();
// BeanUtils.copyProperties(deviceLibrary,billVo);
// //通过账单id和businessType查询task对象
// //过滤出状态是 StatusEnum.REVOKEALLOTTASK.id
// List<Task> taskList = taskService.findByBillIdAndBusinessType(v.getDeviceRepairBillId(), BusinessEnum.REPAIR.id);
// List<Task> tasks = taskList.stream().filter(task -> task.getParentTaskId() == null).collect(Collectors.toList());
// ClearTaskVo clearTaskVo = new ClearTaskVo();
// clearTaskVo.setTaskId(tasks.get(0).getId());
// clearTaskVo.setBusinessType(BusinessEnum.REPAIR.id);
// clearTaskVo.setBillVos(billVos);
// clearTaskVos.add(clearTaskVo);
// }
// );
// clearTaskVos.forEach(
// clearTaskVo -> {
// if (!map1.containsKey(clearTaskVo.getTaskId())){
// map1.put(clearTaskVo.getTaskId(),clearTaskVo);
// }else {
// ClearTaskVo clearTaskVo1 = map1.get(clearTaskVo.getTaskId());
// List<BillVo> billVos1 = clearTaskVo1.getBillVos();
// billVos1.addAll(clearTaskVo.getBillVos());
// clearTaskVo1.setBillVos(billVos1);
// map1.put(clearTaskVo.getTaskId(),clearTaskVo1);
// }
// }
// );
// return map1;
// }
@Override
public Map<Integer, ClearTaskVo> getClearTaskVo(List<Integer> deviceIds) {
List<ClearTaskVo> clearTaskVos = new ArrayList<>();
Map<Integer,ClearTaskVo> map1 = new HashMap<>();
//通过装备id查询出账单id (送修单repairBill)
List<RepairDetail> repairDetails = deviceRepairDetailDao.findAllByDeviceIdIn(deviceIds);
ClearRepairVo clearRepairVo = underRepair(deviceIds);
List<RepairDetail> endRepairList = clearRepairVo.getEndRepairList();
//取出装备id相同的最新时间
Map<Integer,RepairDetail> map =new HashMap<>();
repairDetails.sort(Comparator.comparing(RepairDetail::getCreateTime));
repairDetails.forEach(
Map<Integer, RepairDetail> map = new HashMap<>();
endRepairList.forEach(
repairDetail -> {
if (!map.containsKey(repairDetail.getDeviceId())){
map.put(repairDetail.getDeviceId(),repairDetail);
if (!map.containsKey(repairDetail.getDeviceId())) {
map.put(repairDetail.getDeviceId(), repairDetail);
}
}
);
List<BillVo> billVos = new ArrayList<>();
map.forEach(
(k,v)->{
(k, v) -> {
BillVo billVo = new BillVo();
billVo.setRepairBillId(v.getDeviceRepairBillId());
billVo.setDevicesId(v.getDeviceId());
......@@ -164,7 +222,7 @@ public class RepairDetailServiceImpl implements RepairDetailService {
//根据装备id查询装备
DeviceLibrary library = deviceLibraryService.getOne(v.getDeviceId());
DeviceLibrary deviceLibrary = library.setConfigName();
BeanUtils.copyProperties(deviceLibrary,billVo);
BeanUtils.copyProperties(deviceLibrary, billVo);
//通过账单id和businessType查询task对象
//过滤出状态是 StatusEnum.REVOKEALLOTTASK.id
List<Task> taskList = taskService.findByBillIdAndBusinessType(v.getDeviceRepairBillId(), BusinessEnum.REPAIR.id);
......@@ -178,22 +236,26 @@ public class RepairDetailServiceImpl implements RepairDetailService {
);
clearTaskVos.forEach(
clearTaskVo -> {
if (!map1.containsKey(clearTaskVo.getTaskId())){
map1.put(clearTaskVo.getTaskId(),clearTaskVo);
}else {
if (!map1.containsKey(clearTaskVo.getTaskId())) {
map1.put(clearTaskVo.getTaskId(), clearTaskVo);
} else {
ClearTaskVo clearTaskVo1 = map1.get(clearTaskVo.getTaskId());
List<BillVo> billVos1 = clearTaskVo1.getBillVos();
billVos1.addAll(clearTaskVo.getBillVos());
clearTaskVo1.setBillVos(billVos1);
map1.put(clearTaskVo.getTaskId(),clearTaskVo1);
map1.put(clearTaskVo.getTaskId(), clearTaskVo1);
}
}
);
return map1;
}
@Override
public void setDevicesOwnUnit(List<BillVo> billVos) {
//待维修:
//1.下级送修,本级未入库,则需要先将入库任务完成则变成待维修 入库任务完成后则可以将装备的所属改为自己的 装备状态为在库
//2.本级的待维修 直接修改装备为在库
//修改装备的所属以及备注
//1 通过装备id修改装备的所属
//1.2 获取装备的id
......@@ -222,4 +284,22 @@ public class RepairDetailServiceImpl implements RepairDetailService {
});
}
/**
* 查询哪些装备正在运输中(出库方已发起,但是入库方未入库)
*/
@Override
public ClearRepairVo underRepair(List<Integer> deviceIds){
ClearRepairVo clearRepairVo = new ClearRepairVo();
//通过装备id查询出账单id (送修单repairBill)
List<RepairDetail> repairDetails = deviceRepairDetailDao.findAllByDeviceIdIn(deviceIds);
//维修未入库
List<RepairDetail> repairIngList = repairDetails.stream().filter(repairDetail -> repairDetail.getRepairStatus() == RepairStatusEnum.WAIT_REPAIR.id).sorted(Comparator.comparing(RepairDetail::getCreateTime)).collect(Collectors.toList());
//维修已入库
List<Integer> repairStatus = new ArrayList<>(Arrays.asList(RepairStatusEnum.REPAIRING.id, RepairStatusEnum.WAIT_SEND.id));
List<RepairDetail> endRepairList = repairDetails.stream().filter(repairDetail -> repairStatus.contains(repairDetail.getRepairStatus())).sorted(Comparator.comparing(RepairDetail::getCreateTime)).collect(Collectors.toList());
clearRepairVo.setRepairingList(repairIngList);
clearRepairVo.setEndRepairList(endRepairList);
return clearRepairVo;
}
}
package com.tykj.dev.device.repair.subject.vo;
import com.tykj.dev.device.repair.subject.domin.RepairDetail;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@ApiModel("返回清退任务")
@AllArgsConstructor
@NoArgsConstructor
public class ClearRepairVo {
@ApiModelProperty(value = "正在维修中维修详情列表")
private List<RepairDetail> repairingList;
@ApiModelProperty(value = "已入库的维修详情列表")
private List<RepairDetail> endRepairList;
}
......@@ -72,11 +72,11 @@ public class RepairBillSaveVo {
@ApiModelProperty(value = "已出库装备数量")
private Integer sendedCount;
@NotNull(message = "repairDeviceCheckDetail不能为空")
// @NotNull(message = "repairDeviceCheckDetail不能为空")
@ApiModelProperty(value = "送修装备出库详情(装备主键id+核对结果(0缺失1无误3新增,字符x作为分隔符)),例如10x21x32,意为主键id为1的装备缺失,为2的无误,为3的新增")
private String repairDeviceCheckDetail;
@NotNull(message = "repairDeviceCheckResult不能为空")
// @NotNull(message = "repairDeviceCheckResult不能为空")
@ApiModelProperty(value = "送修装备出库检查结果")
private String repairDeviceCheckResult;
......@@ -95,6 +95,9 @@ public class RepairBillSaveVo {
@ApiModelProperty(value = "发送方附件")
private List<FileRet> sendFileList;
@ApiModelProperty(value = "收件方附件")
private List<FileRet> receiveFileList;
@ApiModelProperty(value = "单据保存vo")
private List<ScriptSaveVo> scriptSaveVos;
}
package com.tykj.dev.device.repair.subject.vo;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.repair.subject.domin.RepairDetail;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@ApiModel("省直属任务撤回")
@AllArgsConstructor
@NoArgsConstructor
public class RevokeUnderTask {
@ApiModelProperty(value = "维修的装备")
private List<DeviceDetailVo> deviceDetailVos;
@ApiModelProperty(value = "任务id")
private Integer taskId;
}
......@@ -257,4 +257,11 @@ public interface TaskService {
* 根据billId和businessType获得Task
*/
List<Task> findByBillIdAndBusinessType(Integer billId, Integer businessType);
/**
* 根据taskId删除task
* @param taskId 任务id
*/
void deleteById(Integer taskId);
}
......@@ -1181,6 +1181,11 @@ public class TaskServiceImpl implements TaskService {
.collect(Collectors.toList());
}
@Override
public void deleteById(Integer taskId) {
taskDao.deleteById(taskId);
}
@Override
public void moveAllSonNodeToEnd(Integer taaskId) {
List<Task> tasks = taskDao.findAllByParentTaskId(taaskId);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论