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

更新

上级 29e042b5
...@@ -232,6 +232,9 @@ public class DeviceApplyController { ...@@ -232,6 +232,9 @@ public class DeviceApplyController {
allotBillEntity.setSendTime(new Date()); allotBillEntity.setSendTime(new Date());
allotBillEntity.setAllotType(2); allotBillEntity.setAllotType(2);
allotBillEntity.setAllotStatus(2); allotBillEntity.setAllotStatus(2);
if (deviceApplyAllotSaveVo.getSendUserbId()!=null) {
allotBillEntity.setAgent(userPublicService.getOne(deviceApplyAllotSaveVo.getSendUserbId()).getName());
}
AllotBill allotBill = allotBillService.addEntity(allotBillEntity); AllotBill allotBill = allotBillService.addEntity(allotBillEntity);
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime(allotBill.getCreateTime()); calendar.setTime(allotBill.getCreateTime());
......
...@@ -15,13 +15,13 @@ public enum DeviceInvisibleRange { ...@@ -15,13 +15,13 @@ public enum DeviceInvisibleRange {
*/ */
SHEN(1, "省一级"), SHEN(1, "省一级"),
/** /**
* 一级 * 一级
*/ */
XIAN(3, "县一级"), SHI(2, "市一级"),
/** /**
* 一级 * 一级
*/ */
SHI(2, "市一级"); XIAN(3, "县一级");
public Integer id; public Integer id;
......
package com.tykj.dev.device.packing.controller; package com.tykj.dev.device.packing.controller;
import com.tykj.dev.config.swagger.AutoDocument; import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.device.library.service.DeviceLibraryService;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.packing.repository.PackingLibraryDao; import com.tykj.dev.device.packing.repository.PackingLibraryDao;
import com.tykj.dev.device.packing.service.PackingLibraryService; import com.tykj.dev.device.packing.service.PackingLibraryService;
import com.tykj.dev.device.packing.subject.domin.PackingLibrary; import com.tykj.dev.device.packing.subject.domin.PackingLibrary;
...@@ -14,6 +16,7 @@ import com.tykj.dev.device.user.util.UserUtils; ...@@ -14,6 +16,7 @@ import com.tykj.dev.device.user.util.UserUtils;
import com.tykj.dev.misc.base.BusinessEnum; import com.tykj.dev.misc.base.BusinessEnum;
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;
import com.tykj.dev.misc.utils.DeviceSeqUtil;
import com.tykj.dev.misc.utils.PageUtil; import com.tykj.dev.misc.utils.PageUtil;
import com.tykj.dev.misc.utils.ResultUtil; import com.tykj.dev.misc.utils.ResultUtil;
import com.tykj.dev.socket.MyWebSocket; import com.tykj.dev.socket.MyWebSocket;
...@@ -27,9 +30,7 @@ import org.springframework.validation.annotation.Validated; ...@@ -27,9 +30,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.Min; import javax.validation.constraints.Min;
import java.util.ArrayList; import java.util.*;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@RestController @RestController
...@@ -60,6 +61,9 @@ public class PackingController { ...@@ -60,6 +61,9 @@ public class PackingController {
@Autowired @Autowired
PackingLibraryDao packingLibraryDao; PackingLibraryDao packingLibraryDao;
@Autowired
DeviceLibraryService deviceLibraryService;
@ApiOperation(value = "新增列装", notes = "可以通过这个接口发起列装") @ApiOperation(value = "新增列装", notes = "可以通过这个接口发起列装")
@PostMapping("/addPackingLibrary") @PostMapping("/addPackingLibrary")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
...@@ -150,6 +154,11 @@ public class PackingController { ...@@ -150,6 +154,11 @@ public class PackingController {
@ApiOperation(value = "添加列装型号") @ApiOperation(value = "添加列装型号")
@PostMapping("/add/model") @PostMapping("/add/model")
public ResponseEntity addModel(@RequestBody @Validated AddModel addModel){ public ResponseEntity addModel(@RequestBody @Validated AddModel addModel){
if (packingLibraryService.modelIsExist(addModel.getModel())){
Map<String,Object> map = new HashMap<>();
map.put("error","型号"+addModel.getModel()+"已存在");
return ResponseEntity.ok(map);
}
PackingLibrary packingLibrary = new PackingLibrary(); PackingLibrary packingLibrary = new PackingLibrary();
BeanUtils.copyProperties(addModel,packingLibrary); BeanUtils.copyProperties(addModel,packingLibrary);
packingLibrary.setIsRoot(1); packingLibrary.setIsRoot(1);
...@@ -210,6 +219,58 @@ public class PackingController { ...@@ -210,6 +219,58 @@ public class PackingController {
} }
} }
@ApiOperation(value = "根据型号查询所有装备附件")
@PostMapping("/selectByModel")
public ResponseEntity selectByModel(@RequestBody PackingLibrarySelectVo packingLibrarySelectVo){
List<PackingLibrary> packingLibraryEntities = packingLibraryService.getList(packingLibrarySelectVo);
return ResponseEntity.ok(packingLibraryService.setAllotNum(packingLibraryEntities));
}
@ApiOperation(value = "根据型号查询所有装备附件")
@PostMapping("/getAllotSeqs/{num}")
public ResponseEntity getAllotSeqs(@RequestBody List<Integer> ids,@PathVariable("num") int num){
List<String> strings = new ArrayList<>();
List<List<Integer>> deviceIds = new ArrayList<>();
List<Integer> devIds = new ArrayList<>();
AllotSeqs allotSeqs1 = new AllotSeqs();
ids.forEach(integer -> {
AllotSeqs allotSeqs = packingLibraryService.getAllotAutoSeqs(integer,num);
strings.add(allotSeqs.getStrings().get(0));
deviceIds.add(allotSeqs.getIds());
devIds.addAll(allotSeqs.getIds());
});
allotSeqs1.setIdLists(deviceIds);
allotSeqs1.setIds(devIds);
allotSeqs1.setStrings(strings);
return ResponseEntity.ok(allotSeqs1);
}
@ApiOperation(value = "配发设置区间")
@PostMapping("/setAllotSeqs/{id}/{num}/{seq}")
public ResponseEntity setAllotSeqs(@PathVariable("id") int id,@PathVariable("num") int num,@PathVariable("seq") String seq){
List<DeviceLibrary> deviceLibraries = packingLibraryService.getAllDevSeqs(id);
List<String> existSeqs = deviceLibraries.stream().map(DeviceLibrary::getSeqNumber).collect(Collectors.toList());
List<String> inputSeqs = DeviceSeqUtil.selectDeviceSeqs(seq);
if (existSeqs.containsAll(inputSeqs)){
if (inputSeqs.size()!=num){
return ResponseEntity.ok("序列号区间装备数量为"+inputSeqs.size()+",与填写数量不符");
}
else {
List<Integer> ids = deviceLibraries.stream().filter(deviceLibrary -> inputSeqs.contains(deviceLibrary.getSeqNumber())).map(DeviceLibrary::getId).collect(Collectors.toList());
return ResponseEntity.ok(ids);
}
}
else {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("序列号");
inputSeqs.removeAll(existSeqs);
inputSeqs.forEach(s -> stringBuffer.append(s).append(","));
stringBuffer.deleteCharAt(stringBuffer.length()-1);
stringBuffer.append("不存在");
return ResponseEntity.ok(stringBuffer.toString());
}
}
@ApiOperation(value = "编辑列装型号") @ApiOperation(value = "编辑列装型号")
@PostMapping("/update/model") @PostMapping("/update/model")
public ResponseEntity updateModel(@RequestBody @Validated PackingModelEdit packingModelEdit){ public ResponseEntity updateModel(@RequestBody @Validated PackingModelEdit packingModelEdit){
...@@ -246,6 +307,11 @@ public class PackingController { ...@@ -246,6 +307,11 @@ public class PackingController {
packingLibraryDao.saveAll(packingLibraries); packingLibraryDao.saveAll(packingLibraries);
} }
if (packingLibrary.getIsRoot()==1){ if (packingLibrary.getIsRoot()==1){
if (!packingLibrary.getModel().equals(packingModelEdit.getModel())&&packingLibraryService.modelIsExist(packingModelEdit.getModel())){
Map<String,Object> map = new HashMap<>();
map.put("error","型号"+packingModelEdit.getModel()+"已存在");
return ResponseEntity.ok(map);
}
BeanUtils.copyProperties(packingModelEdit,packingLibrary); BeanUtils.copyProperties(packingModelEdit,packingLibrary);
packingLibraryService.update(packingLibrary); packingLibraryService.update(packingLibrary);
} }
......
package com.tykj.dev.device.packing.service; package com.tykj.dev.device.packing.service;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.library.subject.vo.Script; import com.tykj.dev.device.library.subject.vo.Script;
import com.tykj.dev.device.packing.subject.domin.PackingLibrary; import com.tykj.dev.device.packing.subject.domin.PackingLibrary;
import com.tykj.dev.device.packing.subject.vo.AllotSeqs;
import com.tykj.dev.device.packing.subject.vo.PackingLibrarySelectVo; import com.tykj.dev.device.packing.subject.vo.PackingLibrarySelectVo;
import com.tykj.dev.device.packing.subject.vo.SelectPack; import com.tykj.dev.device.packing.subject.vo.SelectPack;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
...@@ -105,4 +107,20 @@ public interface PackingLibraryService { ...@@ -105,4 +107,20 @@ public interface PackingLibraryService {
List<PackingLibrary> setOrder(List<PackingLibrary> packingLibraries); List<PackingLibrary> setOrder(List<PackingLibrary> packingLibraries);
List<Script> getDevcieScript(List<Integer> ids); List<Script> getDevcieScript(List<Integer> ids);
/**
* @param packingId 列装id
* @param num 配发数量
* @return 自动选择装备生成的序列号区间
* 配发按照序列号排序自动选择装备
*/
AllotSeqs getAllotAutoSeqs(Integer packingId, Integer num);
Integer getAllotNum(Integer packingId);
List<PackingLibrary> setAllotNum(List<PackingLibrary> packingLibraries);
List<DeviceLibrary> getAllDevSeqs(Integer packingId);
Boolean modelIsExist(String model);
} }
...@@ -13,6 +13,7 @@ import com.tykj.dev.device.library.subject.vo.Script; ...@@ -13,6 +13,7 @@ import com.tykj.dev.device.library.subject.vo.Script;
import com.tykj.dev.device.packing.repository.PackingLibraryDao; import com.tykj.dev.device.packing.repository.PackingLibraryDao;
import com.tykj.dev.device.packing.service.PackingLibraryService; import com.tykj.dev.device.packing.service.PackingLibraryService;
import com.tykj.dev.device.packing.subject.domin.PackingLibrary; import com.tykj.dev.device.packing.subject.domin.PackingLibrary;
import com.tykj.dev.device.packing.subject.vo.AllotSeqs;
import com.tykj.dev.device.packing.subject.vo.PackingLibrarySelectVo; import com.tykj.dev.device.packing.subject.vo.PackingLibrarySelectVo;
import com.tykj.dev.device.packing.subject.vo.SelectPack; import com.tykj.dev.device.packing.subject.vo.SelectPack;
import com.tykj.dev.device.user.util.UserUtils; import com.tykj.dev.device.user.util.UserUtils;
...@@ -301,6 +302,73 @@ public class PackingLibraryServiceImpl implements PackingLibraryService { ...@@ -301,6 +302,73 @@ public class PackingLibraryServiceImpl implements PackingLibraryService {
return scripts; return scripts;
} }
/**
* @param packingId 列装id
* @param num 配发数量
* @return 自动选择装备生成的序列号区间
* 配发按照序列号排序自动选择装备
*/
@Override
public AllotSeqs getAllotAutoSeqs(Integer packingId, Integer num) {
AllotSeqs allotSeqs = new AllotSeqs();
PredicateBuilder<DeviceLibrary> predicateBuilder = Specifications.and();
predicateBuilder.eq("ownUnit", userUtils.getCurrentUserUnitName());
predicateBuilder.eq("lifeStatus", 2);
predicateBuilder.eq("packingId", packingId);
List<DeviceLibrary> deviceLibraries = deviceLibraryDao.findAll(predicateBuilder.build()).stream().sorted(Comparator.comparing(DeviceLibrary::getSeqNumber,Comparator.nullsLast(String::compareTo))).collect(Collectors.toList());
List<String> seqs = deviceLibraries.stream().map(DeviceLibrary::getSeqNumber).collect(Collectors.toList());
if (seqs.size()>=num) {
allotSeqs.setStrings(Collections.singletonList(StringSplitUtil.stringListToString(DeviceSeqUtil.getContinuousSeqs(seqs.subList(0, num)))));
allotSeqs.setIds(deviceLibraries.subList(0,num).stream().map(DeviceLibrary::getId).collect(Collectors.toList()));
return allotSeqs;
}
else {
throw new ApiException("选择数量大于在库数量");
}
}
@Override
public Integer getAllotNum(Integer packingId) {
PredicateBuilder<DeviceLibrary> predicateBuilder = Specifications.and();
predicateBuilder.eq("ownUnit", userUtils.getCurrentUserUnitName());
predicateBuilder.eq("lifeStatus", 2);
predicateBuilder.eq("packingId", packingId);
return deviceLibraryDao.findAll(predicateBuilder.build()).size();
}
@Override
public List<PackingLibrary> setAllotNum(List<PackingLibrary> packingLibraries) {
List<PackingLibrary> result = new ArrayList<>();
packingLibraries.forEach(packingLibrary -> {
packingLibrary.setDevNum(getAllotNum(packingLibrary.getId()));
if (packingLibrary.getIsPart()==1){
packingLibrary.setName("[附件]"+packingLibrary.getName());
}
result.add(packingLibrary);
if (packingLibrary.getChilds()!=null&&packingLibrary.getChilds().size()>0){
result.addAll(setAllotNum(packingLibrary.getChilds()));
}
});
return result;
}
@Override
public List<DeviceLibrary> getAllDevSeqs(Integer packingId) {
PredicateBuilder<DeviceLibrary> predicateBuilder = Specifications.and();
predicateBuilder.eq("ownUnit", userUtils.getCurrentUserUnitName());
predicateBuilder.eq("lifeStatus", 2);
predicateBuilder.eq("packingId", packingId);
return deviceLibraryDao.findAll(predicateBuilder.build());
}
@Override
public Boolean modelIsExist(String model) {
PredicateBuilder<PackingLibrary> predicateBuilder = Specifications.and();
predicateBuilder.eq("isRoot", 1);
predicateBuilder.eq("model", model);
return packingLibraryDao.findAll(predicateBuilder.build()).size()>0;
}
private Specification<PackingLibrary> getSelectSpecification(PackingLibrarySelectVo packingLibrarySelectVo) { private Specification<PackingLibrary> getSelectSpecification(PackingLibrarySelectVo packingLibrarySelectVo) {
PredicateBuilder<PackingLibrary> predicateBuilder = Specifications.and(); PredicateBuilder<PackingLibrary> predicateBuilder = Specifications.and();
Integer level = userUtils.getCurrentUnitLevel(); Integer level = userUtils.getCurrentUnitLevel();
......
...@@ -239,6 +239,9 @@ public class PackingLibrary { ...@@ -239,6 +239,9 @@ public class PackingLibrary {
@Transient @Transient
private String natureName; private String natureName;
@Transient
private Integer devNum;
public void addChildNode(PackingLibrary packingLibraryEntity) { public void addChildNode(PackingLibrary packingLibraryEntity) {
childs.add(packingLibraryEntity); childs.add(packingLibraryEntity);
} }
......
package com.tykj.dev.device.packing.subject.vo;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @author dengdiyi
*/
@Repository
@Data
@ApiModel("配发自动生成序列号返回类")
public class AllotSeqs {
private List<String> strings;
private List<Integer> ids;
private List<List<Integer>> idLists;
}
...@@ -130,6 +130,34 @@ public class RepairController { ...@@ -130,6 +130,34 @@ public class RepairController {
@Autowired @Autowired
private DeviceLibraryDao deviceLibraryDao; private DeviceLibraryDao deviceLibraryDao;
@ApiOperation(value = "添加维修装备", notes = "可以通过这个接口发起维修")
@PostMapping(value = "/add")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity addRepairDevice(@RequestBody List<Integer> ids) {
deviceLibraryService.isInStock(ids);
ids.forEach(integer -> {
DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(integer);
deviceLibraryEntity.setLifeStatus(4);
deviceLibraryService.update(deviceLibraryEntity);
RepairDetail repairDetail = new RepairDetail();
repairDetail.setDeviceId(integer);
repairDetail.setLocationUnit(userUtils.getCurrentUserUnitName());
repairDetail.setModel(deviceLibraryEntity.getModel());
repairDetail.setName(deviceLibraryEntity.getName());
repairDetail.setOwnUnit(deviceLibraryEntity.getOwnUnit());
repairDetail.setRepairStatus(1);
repairDetail.setRfidSurfaceId(deviceLibraryEntity.getRfidSurfaceId());
repairDetail.setSeqNumber(deviceLibraryEntity.getSeqNumber());
repairDetail.setType(deviceLibraryEntity.getType());
repairDetail.setDeviceRepairBillId(0);
deviceRepairDetailService.save(repairDetail);
//存装备日志
DeviceLogDto deviceLogDto = new DeviceLogDto(integer, "将装备添加到待维修列表", null);
deviceLogService.addLog(deviceLogDto);
});
return ResponseEntity.ok("添加成功");
}
@ApiOperation(value = "发起维修", notes = "可以通过这个接口发起维修") @ApiOperation(value = "发起维修", notes = "可以通过这个接口发起维修")
@PostMapping(value = "/form") @PostMapping(value = "/form")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
...@@ -201,40 +229,47 @@ public class RepairController { ...@@ -201,40 +229,47 @@ public class RepairController {
} }
//存维修详情单 //存维修详情单
for (DeviceDetailVo d : repairBillSaveVo.getDeviceList()) { for (DeviceDetailVo d : repairBillSaveVo.getDeviceList()) {
RepairDetail oldRepairDetail = deviceRepairDetailService.getOne(d.getId());
stringBuffer.append(d.getDeviceId()); stringBuffer.append(d.getDeviceId());
stringBuffer.append("Ǵ"); stringBuffer.append("Ǵ");
stringBuffer.append(d.getRemark()); stringBuffer.append(d.getRemark());
stringBuffer.append("Ǵ"); stringBuffer.append("Ǵ");
RepairDetail repairDetail = new RepairDetail();
if (d.getId()!=null){
repairDetail.setPid(d.getId());
RepairDetail repairDetail1 = deviceRepairDetailService.getOne(d.getId());
repairDetail1.setRepairStatus(8);
deviceRepairDetailService.update(repairDetail1);
}
repairDetail.setDeviceId(d.getDeviceId());
DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(d.getDeviceId()); DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(d.getDeviceId());
repairDetail.setLocationUnit(userUtils.getCurrentUserUnitName()); if (oldRepairDetail.getDeviceRepairBillId()==0) {
repairDetail.setModel(deviceLibraryEntity.getModel()); oldRepairDetail.setRemark(d.getRemark());
repairDetail.setName(deviceLibraryEntity.getName()); oldRepairDetail.setDeviceRepairBillId(repairBill1.getId());
repairDetail.setOwnUnit(deviceLibraryEntity.getOwnUnit()); deviceRepairDetailService.update(oldRepairDetail);
if (d.getRemark()==null){
for (RepairDetail r :repairDetails){
if (r.getDeviceId().equals(d.getDeviceId())){
repairDetail.setRemark(r.getRemark());
break;
}
}
} }
else { else {
repairDetail.setRemark(d.getRemark()); RepairDetail repairDetail = new RepairDetail();
if (d.getId() != null) {
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());
if (d.getRemark() == null) {
for (RepairDetail r : repairDetails) {
if (r.getDeviceId().equals(d.getDeviceId())) {
repairDetail.setRemark(r.getRemark());
break;
}
}
} else {
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);
} }
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) { if (level == 1) {
deviceLibraryEntity.setLifeStatus(4); deviceLibraryEntity.setLifeStatus(4);
...@@ -1200,19 +1235,30 @@ public class RepairController { ...@@ -1200,19 +1235,30 @@ public class RepairController {
for (Integer id : repairStatusChangeVo.getId()) { for (Integer id : repairStatusChangeVo.getId()) {
//获取维修详情单 //获取维修详情单
RepairDetail repairDetail1 = deviceRepairDetailService.getOne(id); RepairDetail repairDetail1 = deviceRepairDetailService.getOne(id);
//获取旧状态 if (repairDetail1.getDeviceRepairBillId()==0){
Integer oldStatus = repairDetail1.getRepairStatus(); repairDetail1.setRepairStatus(5);
//修改当前任务维修详情单该装备状态 deviceRepairDetailService.update(repairDetail1);
repairDetail1.setRepairStatus(repairStatusChangeVo.getNewStatus());
//如果修改为已报废,更改新装备详情id为0,,更新装备状态
if (repairStatusChangeVo.getNewStatus() == 4) {
repairDetail1.setNewDeviceDetailId(0);
DeviceLibrary deviceLibrary = deviceLibraryService.getOne(repairDetail1.getDeviceId()); DeviceLibrary deviceLibrary = deviceLibraryService.getOne(repairDetail1.getDeviceId());
deviceLibrary.setLifeStatus(5); deviceLibrary.setLifeStatus(2);
deviceLibraryService.update(deviceLibrary); deviceLibraryService.update(deviceLibrary);
//存装备日志
DeviceLogDto deviceLogDto = new DeviceLogDto(deviceLibrary.getId(), "维修完成,装备状态改为在库", null);
deviceLogService.addLog(deviceLogDto);
} }
deviceRepairDetailService.update(repairDetail1); else {
//修改父任务中所有维修详情单中的该装备的状态 //获取旧状态
Integer oldStatus = repairDetail1.getRepairStatus();
//修改当前任务维修详情单该装备状态
repairDetail1.setRepairStatus(repairStatusChangeVo.getNewStatus());
//如果修改为已报废,更改新装备详情id为0,,更新装备状态
if (repairStatusChangeVo.getNewStatus() == 4) {
repairDetail1.setNewDeviceDetailId(0);
DeviceLibrary deviceLibrary = deviceLibraryService.getOne(repairDetail1.getDeviceId());
deviceLibrary.setLifeStatus(5);
deviceLibraryService.update(deviceLibrary);
}
deviceRepairDetailService.update(repairDetail1);
//修改父任务中所有维修详情单中的该装备的状态
// if (fathers.size() > 0) { // if (fathers.size() > 0) {
// fathers.forEach(integer -> { // fathers.forEach(integer -> {
// deviceRepairDetailService.findByBillId(integer).stream() // deviceRepairDetailService.findByBillId(integer).stream()
...@@ -1223,43 +1269,42 @@ public class RepairController { ...@@ -1223,43 +1269,42 @@ public class RepairController {
// }); // });
// }); // });
// } // }
//获取装备名称 //获取装备名称
String deviceName = deviceLibraryService.getOne(repairDetail1.getDeviceId()).getName(); String deviceName = deviceLibraryService.getOne(repairDetail1.getDeviceId()).getName();
//添加业务日志 //添加业务日志
List<FileVo> fileVos = new ArrayList<>(); List<FileVo> fileVos = new ArrayList<>();
if (repairStatusChangeVo.getFileName() != null && repairStatusChangeVo.getFileUrl() != null) { if (repairStatusChangeVo.getFileName() != null && repairStatusChangeVo.getFileUrl() != null) {
FileVo fileVo = new FileVo("报废单", repairStatusChangeVo.getFileName(), repairStatusChangeVo.getFileUrl()); FileVo fileVo = new FileVo("报废单", repairStatusChangeVo.getFileName(), repairStatusChangeVo.getFileUrl());
fileVos.add(fileVo); fileVos.add(fileVo);
} }
String remark = "将装备" + deviceName + "状态由" + GlobalMap.getRepairStatusMap().get(oldStatus).name + "改为" + GlobalMap.getRepairStatusMap().get(repairStatusChangeVo.getNewStatus()).name; String remark = "将装备" + deviceName + "状态由" + GlobalMap.getRepairStatusMap().get(oldStatus).name + "改为" + GlobalMap.getRepairStatusMap().get(repairStatusChangeVo.getNewStatus()).name;
//业务日志 //业务日志
// TaskLogBto taskLogBto = new TaskLogBto(taskBto.getId(), remark, fileVos); // TaskLogBto taskLogBto = new TaskLogBto(taskBto.getId(), remark, fileVos);
// taskLogService.addLog(taskLogBto); // taskLogService.addLog(taskLogBto);
//装备日志 //装备日志
DeviceLogDto deviceLogDto = new DeviceLogDto(repairDetail1.getDeviceId(), remark, fileVos); DeviceLogDto deviceLogDto = new DeviceLogDto(repairDetail1.getDeviceId(), remark, fileVos);
deviceLogService.addLog(deviceLogDto); deviceLogService.addLog(deviceLogDto);
if (repairStatusChangeVo.getNewStatus()==2) { if (repairStatusChangeVo.getNewStatus() == 2) {
if (repairDetail1.getPid()!=null) { if (repairDetail1.getPid() != null) {
RepairDetail repairDetail = deviceRepairDetailService.getOne(repairDetail1.getPid()); RepairDetail repairDetail = deviceRepairDetailService.getOne(repairDetail1.getPid());
Integer unitId = userPublicService.getOne(repairDetail.getCreateUserId()).getUnitsId(); Integer unitId = userPublicService.getOne(repairDetail.getCreateUserId()).getUnitsId();
if (messageMap.get(unitId) == null) { if (messageMap.get(unitId) == null) {
messageMap.put(unitId, Collections.singletonList(repairDetail.getId())); messageMap.put(unitId, Collections.singletonList(repairDetail.getId()));
} else { } else {
List<Integer> ids = new ArrayList<Integer>(messageMap.getOrDefault(unitId, new ArrayList<>())); List<Integer> ids = new ArrayList<Integer>(messageMap.getOrDefault(unitId, new ArrayList<>()));
ids.add(repairDetail.getId()); ids.add(repairDetail.getId());
messageMap.put(unitId, ids); messageMap.put(unitId, ids);
} }
}
else {
Integer unitId = userPublicService.getOne(repairDetail1.getCreateUserId()).getUnitsId();
if (messageMap.get(unitId) == null) {
messageMap.put(unitId, Collections.singletonList(repairDetail1.getId()));
} else { } else {
List<Integer> ids = new ArrayList<Integer>(messageMap.getOrDefault(unitId, new ArrayList<>())); Integer unitId = userPublicService.getOne(repairDetail1.getCreateUserId()).getUnitsId();
ids.add(repairDetail1.getId()); if (messageMap.get(unitId) == null) {
messageMap.put(unitId, ids); messageMap.put(unitId, Collections.singletonList(repairDetail1.getId()));
} else {
List<Integer> ids = new ArrayList<Integer>(messageMap.getOrDefault(unitId, new ArrayList<>()));
ids.add(repairDetail1.getId());
messageMap.put(unitId, ids);
}
} }
}
// List<Integer> ids2 = new ArrayList<>(); // List<Integer> ids2 = new ArrayList<>();
// ids2.addAll(userDao.findAllByUnitsId(userPublicService.getOne(repairDetail1.getCreateUserId()).getUnitsId()).stream() // ids2.addAll(userDao.findAllByUnitsId(userPublicService.getOne(repairDetail1.getCreateUserId()).getUnitsId()).stream()
// .map(User::getUserId) // .map(User::getUserId)
...@@ -1267,6 +1312,7 @@ public class RepairController { ...@@ -1267,6 +1312,7 @@ public class RepairController {
// MessageBto messageBto2 = new MessageBto(0, 0, "待领取送修装备", ids2); // MessageBto messageBto2 = new MessageBto(0, 0, "待领取送修装备", ids2);
// messageBto2.setRecord(); // messageBto2.setRecord();
// messageService.add(messageBto2); // messageService.add(messageBto2);
}
} }
} }
// List<Integer> ids2 = new ArrayList<>(); // List<Integer> ids2 = new ArrayList<>();
......
...@@ -2,11 +2,14 @@ package com.tykj.dev.rfid.controller; ...@@ -2,11 +2,14 @@ package com.tykj.dev.rfid.controller;
import com.tykj.dev.config.swagger.AutoDocument; import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.device.library.repository.DeviceLogDao;
import com.tykj.dev.device.library.service.DeviceLibraryService; import com.tykj.dev.device.library.service.DeviceLibraryService;
import com.tykj.dev.device.library.service.DeviceLogService; import com.tykj.dev.device.library.service.DeviceLogService;
import com.tykj.dev.device.library.subject.Dto.DeviceLogDto; 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.domin.DeviceLibrary;
import com.tykj.dev.device.library.subject.domin.DeviceLog;
import com.tykj.dev.device.library.subject.vo.DeviceLibrarySelectVo; import com.tykj.dev.device.library.subject.vo.DeviceLibrarySelectVo;
import com.tykj.dev.device.library.subject.vo.DeviceLogUserVo;
import com.tykj.dev.device.library.subject.vo.FileVo; import com.tykj.dev.device.library.subject.vo.FileVo;
import com.tykj.dev.device.task.service.TaskLogService; import com.tykj.dev.device.task.service.TaskLogService;
import com.tykj.dev.device.task.service.TaskService; import com.tykj.dev.device.task.service.TaskService;
...@@ -44,10 +47,8 @@ import javax.transaction.Transactional; ...@@ -44,10 +47,8 @@ import javax.transaction.Transactional;
import javax.validation.constraints.Min; import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.text.ParseException; import java.text.ParseException;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap; import java.util.stream.Collectors;
import java.util.List;
import java.util.Objects;
/** /**
* @author huangxiahao * @author huangxiahao
...@@ -77,6 +78,8 @@ public class RfidController { ...@@ -77,6 +78,8 @@ public class RfidController {
private final InventoryScheduled inventoryScheduled; private final InventoryScheduled inventoryScheduled;
@Autowired @Autowired
private AuthenticationUtils AuthenticationUtils; private AuthenticationUtils AuthenticationUtils;
@Autowired
private DeviceLogDao deviceLogDao;
public RfidController(RfidChangeLogService rfidChangeLogService, RfidService rfidService, LibraryWarningLogService libraryWarningLogService, RfidChangeBillService rfidChangeBillService, InventoryScheduled inventoryScheduled) { public RfidController(RfidChangeLogService rfidChangeLogService, RfidService rfidService, LibraryWarningLogService libraryWarningLogService, RfidChangeBillService rfidChangeBillService, InventoryScheduled inventoryScheduled) {
this.rfidChangeLogService = rfidChangeLogService; this.rfidChangeLogService = rfidChangeLogService;
...@@ -295,6 +298,12 @@ public class RfidController { ...@@ -295,6 +298,12 @@ public class RfidController {
rfidChangeLogSelectVo.setValidTag(1); rfidChangeLogSelectVo.setValidTag(1);
//获取装备信息 //获取装备信息
DeviceLibrary device = deviceLibraryService.getOne(tagId); DeviceLibrary device = deviceLibraryService.getOne(tagId);
//查询日志
List<DeviceLogUserVo> deviceLogEntities = deviceLogDao.getAllByDeviceIdAndType(tagId, 0).stream()
.map(DeviceLog::parse2Dto)
.map(DeviceLogDto::toVo)
.sorted(Comparator.comparing(DeviceLogUserVo::getCreateTime,Comparator.nullsLast(Date::compareTo)).reversed())
.collect(Collectors.toList());
//获取标签日志信息 //获取标签日志信息
List<RfidChangeLog> rfidChangeLogEntities = rfidChangeLogService.getList(rfidChangeLogSelectVo); List<RfidChangeLog> rfidChangeLogEntities = rfidChangeLogService.getList(rfidChangeLogSelectVo);
List<RfidChangeLogVo> vos = new ArrayList<>(); List<RfidChangeLogVo> vos = new ArrayList<>();
...@@ -306,7 +315,7 @@ public class RfidController { ...@@ -306,7 +315,7 @@ public class RfidController {
vos.add(rfidChangeLogVo); vos.add(rfidChangeLogVo);
}); });
//组装 //组装
TagDetailVo tagDetailVo = new TagDetailVo(device, vos); TagDetailVo tagDetailVo = new TagDetailVo(device, vos,deviceLogEntities);
return ResultUtil.success(tagDetailVo); return ResultUtil.success(tagDetailVo);
} }
......
package com.tykj.dev.rfid.entity.vo; package com.tykj.dev.rfid.entity.vo;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary; import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.library.subject.vo.DeviceLogUserVo;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
...@@ -21,4 +22,6 @@ public class TagDetailVo { ...@@ -21,4 +22,6 @@ public class TagDetailVo {
private DeviceLibrary deviceLibraryEntity; private DeviceLibrary deviceLibraryEntity;
private List<RfidChangeLogVo> rfidChangeLogEntities; private List<RfidChangeLogVo> rfidChangeLogEntities;
private List<DeviceLogUserVo> deviceLogEntities;
} }
...@@ -14,7 +14,6 @@ import lombok.AllArgsConstructor; ...@@ -14,7 +14,6 @@ import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import org.modelmapper.ModelMapper; import org.modelmapper.ModelMapper;
import javax.persistence.*; import javax.persistence.*;
...@@ -32,7 +31,6 @@ import javax.persistence.*; ...@@ -32,7 +31,6 @@ import javax.persistence.*;
@Data @Data
@Entity @Entity
@ApiModel(value = "用户对象", description = "用户详细信息") @ApiModel(value = "用户对象", description = "用户详细信息")
@Where(clause = "is_del = 0")
@SQLDelete(sql = "update user set is_del = 1 where id = ?") @SQLDelete(sql = "update user set is_del = 1 where id = ?")
public class User { public class User {
/** /**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论