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

更新

上级 0d8e7b36
......@@ -8,6 +8,7 @@ import com.tykj.dev.device.apply.service.DeviceApplyBillService;
import com.tykj.dev.device.apply.subject.domin.DeviceApplyBill;
import com.tykj.dev.device.apply.subject.vo.*;
import com.tykj.dev.device.file.service.FilesUtil;
import com.tykj.dev.device.library.repository.DeviceLibraryDao;
import com.tykj.dev.device.library.service.DeviceLibraryService;
import com.tykj.dev.device.library.service.DeviceLogService;
import com.tykj.dev.device.library.subject.Dto.DeviceLogDto;
......@@ -108,6 +109,9 @@ public class DeviceApplyController {
@Autowired
private PackingController packingController;
@Autowired
private DeviceLibraryDao deviceLibraryDao;
@ApiOperation(value = "发起装备申请", notes = "可以通过这个接口发起装备申请")
@PostMapping("/addDeviceApplyBill")
@Transactional(rollbackFor = Exception.class)
......@@ -402,7 +406,7 @@ public class DeviceApplyController {
return ResponseEntity.ok(applyDetailVo);
}
@ApiOperation(value = "上传回执单", notes = "上传回执单")
@ApiOperation(value = "批复上传回执单", notes = "批复上传回执单")
@PostMapping("/uploadFile")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity uploadFile(@RequestBody @Validated UploadApplyFile uploadApplyFile) {
......@@ -440,7 +444,18 @@ public class DeviceApplyController {
if (uploadApplyFile.getApplyBillDetailVos()!=null&&uploadApplyFile.getApplyBillDetailVos().size()>0){
deviceApplyBill.setApplyStat(JacksonUtil.toJSon(uploadApplyFile.getApplyBillDetailVos()));
}
deviceApplyBillService.update(deviceApplyBill);
DeviceApplyBill deviceApplyBill1 = deviceApplyBillService.update(deviceApplyBill);
if (deviceApplyBill.getApplyType()>1){
List<String> seqs = new ArrayList<>();
List<ReplyVo> replyVos = JacksonUtil.readValue(deviceApplyBill1.getReplyVos(), new TypeReference<List<ReplyVo>>() {
});
if (replyVos!=null) {
for (ReplyVo r : replyVos) {
seqs.addAll(DeviceSeqUtil.selectDeviceSeqs(r.getSeqInterval()));
}
}
deviceLibraryDao.upDateSeqNumbersApplyTaskId(deviceApplyBill1.getId(),seqs);
}
return ResponseEntity.ok("ok");
}
......
......@@ -2,6 +2,7 @@ package com.tykj.dev.device.apply.service;
import com.tykj.dev.device.apply.subject.domin.DeviceApplyBill;
import com.tykj.dev.device.library.subject.vo.ScriptSaveVo;
import java.util.List;
......@@ -21,4 +22,10 @@ public interface DeviceApplyBillService {
DeviceApplyBill getOne(Integer id);
/**
* @param applyType 申请类型
* @param scriptSaveVos 退役/报废/销毁装备单据详情
*/
Boolean updateCompleteNum(Integer applyType,List<ScriptSaveVo> scriptSaveVos);
}
......@@ -6,6 +6,8 @@ import com.tykj.dev.config.TaskBeanConfig;
import com.tykj.dev.device.apply.repository.DeviceApplyBillDao;
import com.tykj.dev.device.apply.service.DeviceApplyBillService;
import com.tykj.dev.device.apply.subject.domin.DeviceApplyBill;
import com.tykj.dev.device.library.subject.vo.ScriptSaveVo;
import com.tykj.dev.misc.exception.ApiException;
import com.tykj.dev.misc.utils.JacksonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
......@@ -72,4 +74,20 @@ public class DeviceApplyBillServiceImpl implements DeviceApplyBillService {
return deviceApplyBillEntity.orElse(null);
}
@Override
public Boolean updateCompleteNum(Integer applyType, List<ScriptSaveVo> scriptSaveVos) {
if (applyType==2){
}
else if (applyType==3){
}
else if (applyType==4) {
}
else {
throw new ApiException("applyType只能为2,3,4");
}
return null;
}
}
......@@ -19,4 +19,7 @@ public class ReplyVo {
@ApiModelProperty(value = "序列号区间", example = "1")
private String seqInterval;
@ApiModelProperty(value = "已完成数量")
private Integer completeCount = 0;
}
......@@ -91,6 +91,11 @@ public interface DeviceLibraryDao extends JpaRepository<DeviceLibrary, Integer>,
@Query("update DeviceLibrary o set o.lifeStatus = :lifeStatus ,o.updateTime=current_timestamp where o.seqNumber in :seqNumbers")
int upDateSeqNumbersLeftStatus(Integer lifeStatus,@Param("seqNumbers") List<String> seqNumbers);
@Transactional
@Modifying
@Query("update DeviceLibrary o set o.applyTaskId = :applyTaskId ,o.updateTime=current_timestamp where o.seqNumber in :seqNumbers")
int upDateSeqNumbersApplyTaskId(Integer applyTaskId,@Param("seqNumbers") List<String> seqNumbers);
@Transactional
@Modifying
@Query("update DeviceLibrary o set o.lifeStatus = :lifeStatus ,o.lockStatus=:lock ,o.updateTime=current_timestamp where o.id in :idList")
......
......@@ -11,6 +11,8 @@ import com.tykj.dev.device.library.service.DeviceLibraryService;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.library.subject.vo.DeviceLibrarySelectVo;
import com.tykj.dev.device.library.subject.vo.DeviceStatisticsVo;
import com.tykj.dev.device.user.subject.entity.Units;
import com.tykj.dev.device.user.subject.service.UnitsService;
import com.tykj.dev.device.user.subject.service.UserPublicService;
import com.tykj.dev.device.user.util.UserUtils;
import com.tykj.dev.misc.exception.ApiException;
......@@ -48,6 +50,9 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
@Autowired
private BlockChainUtil blockChainUtil;
@Autowired
private UnitsService unitsService;
@Override
public DeviceLibrary addEntity(DeviceLibrary deviceLibraryEntity) {
DeviceLibrary deviceLibrary = deviceLibraryDao.save(deviceLibraryEntity);
......@@ -141,7 +146,11 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
}
//省能看到所有装备
if (selectLevel == 1) {
List<DeviceLibrary> libraryEntities = getList4(getAllList(deviceLibrarySelectVo));
List<String> unitNames = unitsService.findSuperiorUnitsList().stream().map(Units::getName).collect(Collectors.toList());
List<DeviceLibrary> deviceLibraries = getAllList(deviceLibrarySelectVo).stream()
.filter(deviceLibraryEntity -> !unitNames.contains(deviceLibraryEntity.getOwnUnit()))
.collect(Collectors.toList());
List<DeviceLibrary> libraryEntities = getList4(deviceLibraries);
// List<DeviceLibrary> resultList = new ArrayList<>();
// for (DeviceLibrary d : libraryEntities) {
// resultList.add(d);
......
......@@ -226,6 +226,9 @@ public class DeviceLibrary {
@ApiModelProperty(value = "备注")
private String record;
@ApiModelProperty(value = "对应申请任务id")
private Integer applyTaskId;
@Transient
private List<DeviceLibrary> childs = new ArrayList<>();
......
......@@ -101,4 +101,7 @@ public class DeviceLibrarySelectVo extends CustomPage {
@ApiModelProperty(value = "更新时间模糊查询字段")
private String updateTimeDim;
@ApiModelProperty(value = "更新时间年份")
private Integer year;
}
......@@ -10,6 +10,7 @@ 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.DeviceLogUserVo;
import com.tykj.dev.device.library.subject.vo.FileVo;
import com.tykj.dev.device.matching.repository.MatchingDeviceLibraryDao;
import com.tykj.dev.device.matching.repository.MatchingRepairBillDao;
import com.tykj.dev.device.matching.service.MatchingDeviceBillService;
import com.tykj.dev.device.matching.service.MatchingDeviceLibraryService;
......@@ -94,10 +95,19 @@ public class MatchingDeviceController {
@Autowired
private MessageService messageService;
@Autowired
private MatchingDeviceLibraryDao matchingDeviceLibraryDao;
@ApiOperation(value = "添加配套设备", notes = "可以通过这个接口添加配套设备")
@PostMapping(value = "/add")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity addStorageBill(@RequestBody @Validated MatchingDeviceBillSaveVo matchingDeviceBillSaveVo) {
List<String> existSeqs = matchingDeviceLibraryDao.findAll().stream().map(MatchingDeviceLibrary::getSeqNumber).collect(Collectors.toList());
List<String> addSeqs = matchingDeviceBillSaveVo.getMatchingDeviceSaveVoList().stream().map(MatchingDeviceSaveVo::getSeqNumber).collect(Collectors.toList());
existSeqs.retainAll(addSeqs);
if (existSeqs.size()>0){
return ResponseEntity.ok(StringSplitUtil.stringListToString(existSeqs));
}
//添加账单
MatchingDeviceBill matchingDeviceBillEntity = matchingDeviceBillSaveVo.toDo();
MatchingDeviceBill m = matchingDeviceBillService.addEntity(matchingDeviceBillEntity);
......@@ -133,7 +143,7 @@ public class MatchingDeviceController {
MessageBto messageBto = new MessageBto(taskBto1.getId(),taskBto1.getBusinessType(),"业务办结",ids,1);
messageService.add(messageBto);
myWebSocket.sendMessage1();
return ResponseEntity.ok("添加成功");
return ResponseEntity.ok("ok");
}
@ApiOperation(value = "添加配套设备审核", notes = "可以通过这个接口添加配套设备审核")
......
......@@ -316,12 +316,25 @@ public class PackingController {
List<DeviceLibrary> deviceLibraries = packingLibraryService.getAllDevSeqs(id);
List<String> existSeqs = deviceLibraries.stream().map(DeviceLibrary::getSeqNumber).collect(Collectors.toList());
List<String> inputSeqs = DeviceSeqUtil.selectDeviceSeqs(seq);
List<String> hasApplySeqs = deviceLibraries.stream()
.filter(deviceLibrary -> deviceLibrary.getApplyTaskId()!=null)
.map(DeviceLibrary::getSeqNumber)
.collect(Collectors.toList());
if (inputSeqs.size()!=num){
return ResponseEntity.ok("序列号区间总数为"+inputSeqs.size()+",与装备数量不匹配");
}
else {
if (existSeqs.containsAll(inputSeqs)){
return ResponseEntity.ok("ok");
hasApplySeqs.retainAll(inputSeqs);
if (hasApplySeqs.size()==0) {
return ResponseEntity.ok("ok");
}
else {
StringBuffer stringBuffer = new StringBuffer();
hasApplySeqs.forEach(s -> stringBuffer.append(s).append(","));
stringBuffer.deleteCharAt(stringBuffer.length()-1);
return ResponseEntity.ok("该型号序列号为"+stringBuffer.toString()+"的装备已经发过申请");
}
}
else {
existSeqs.retainAll(inputSeqs);
......
......@@ -8,6 +8,7 @@ import com.tykj.dev.device.packing.repository.PackingLibraryDao;
import com.tykj.dev.device.packing.service.PackingLibraryService;
import com.tykj.dev.device.packing.subject.domin.PackingLibrary;
import com.tykj.dev.device.packing.subject.vo.*;
import com.tykj.dev.misc.utils.GetTreeUtils;
import com.tykj.dev.misc.utils.PageUtil;
import com.tykj.dev.misc.utils.ResultUtil;
import io.swagger.annotations.Api;
......@@ -21,10 +22,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.Min;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
......@@ -74,7 +72,16 @@ public class PackingLibraryController {
@PostMapping("/retired/summary")
public ResponseEntity getInvalidPage(@RequestBody PackingLibrarySelectVo packingLibrarySelectVo) {
List<PackingLibrary> resultList = packingLibraryService.getInvalidPage(packingLibrarySelectVo, packingLibrarySelectVo.getPageable());
Page<PackingLibrary> packingLibraries = PageUtil.getPerPage(packingLibrarySelectVo.getPage(),packingLibrarySelectVo.getSize(),resultList,packingLibrarySelectVo.getPageable());
//返回父子结构
Map<Integer, PackingLibrary> nodeCollect =
resultList.stream().collect(Collectors.toMap(PackingLibrary::getId, packingLibrary -> packingLibrary));
List<PackingLibrary> resultList2 = GetTreeUtils.parseTreeFromDown(
resultList,
PackingLibrary::getId,
packingLibrary -> Optional.ofNullable(nodeCollect.get(packingLibrary.getPartParentId())),
PackingLibrary::addChildNode
);
Page<PackingLibrary> packingLibraries = PageUtil.getPerPage(packingLibrarySelectVo.getPage(),packingLibrarySelectVo.getSize(),resultList2,packingLibrarySelectVo.getPageable());
Map<String,Object> map = new HashMap<>();
map.put("pages",packingLibraries);
map.put("models",resultList.stream().map(PackingLibrary::getModel).collect(Collectors.toSet()));
......
......@@ -20,6 +20,8 @@ import com.tykj.dev.device.packing.subject.vo.PackingLibrarySelectVo;
import com.tykj.dev.device.packing.subject.vo.SelectPack;
import com.tykj.dev.device.user.read.service.MessageService;
import com.tykj.dev.device.user.read.subject.bto.MessageBto;
import com.tykj.dev.device.user.subject.entity.Units;
import com.tykj.dev.device.user.subject.service.UnitsService;
import com.tykj.dev.device.user.subject.service.UserPublicService;
import com.tykj.dev.device.user.util.UserUtils;
import com.tykj.dev.misc.exception.ApiException;
......@@ -73,6 +75,9 @@ public class PackingLibraryServiceImpl implements PackingLibraryService {
@Autowired
private MessageService messageService;
@Autowired
private UnitsService unitsService;
@Override
public PackingLibrary addEntity(PackingLibrary packingLibraryEntity) {
PackingLibrary packingLibrary = packingLibraryDao.save(packingLibraryEntity);
......@@ -114,15 +119,7 @@ public class PackingLibraryServiceImpl implements PackingLibraryService {
public List<PackingLibrary> getInvalidPage(PackingLibrarySelectVo packingLibrarySelectVo, Pageable pageable) {
List<PackingLibrary> packingLibraryEntities = packingLibraryDao.findAll(getSelectSpecification2(packingLibrarySelectVo),pageable.getSort());
packingLibraryEntities.forEach(PackingLibrary::setConfigName);
//返回父子结构
Map<Integer, PackingLibrary> nodeCollect =
packingLibraryEntities.stream().collect(Collectors.toMap(PackingLibrary::getId, packingLibrary -> packingLibrary));
return GetTreeUtils.parseTreeFromDown(
packingLibraryEntities,
PackingLibrary::getId,
packingLibrary -> Optional.ofNullable(nodeCollect.get(packingLibrary.getPartParentId())),
PackingLibrary::addChildNode
);
return packingLibraryEntities;
}
@Override
......@@ -518,8 +515,11 @@ public class PackingLibraryServiceImpl implements PackingLibraryService {
@Override
public List<DeviceLibrary> getAllDevSeqs(Integer packingId) {
List<String> unitNames = unitsService.findSuperiorUnitsList().stream().map(Units::getName).collect(Collectors.toList());
PredicateBuilder<DeviceLibrary> predicateBuilder = Specifications.and();
// predicateBuilder.eq("ownUnit", userUtils.getCurrentUserUnitName());
if (unitNames.size()>0) {
predicateBuilder.notIn("ownUnit", unitNames.toArray());
}
// predicateBuilder.eq("lifeStatus", 2);
predicateBuilder.eq("packingId", packingId);
return deviceLibraryDao.findAll(predicateBuilder.build());
......
......@@ -1488,7 +1488,7 @@ public class RepairController {
repairDetails.forEach(repairDetail -> {
repairDetail.setConfigName();
});
List<String> units = unitsService.findListById(0).stream().map(Units::getName).collect(Collectors.toList());
List<String> units = unitsService.findSuperiorUnitsList().stream().map(Units::getName).collect(Collectors.toList());
units.addAll(unitsService.findBySubordinateNotOneself(userUtils.getCurrentUnitId()).stream().map(Units::getName).collect(Collectors.toList()));
List<RepairDetail> repairDetails2 = repairDetails.stream().filter(repairDetail -> units.contains(repairDetail.getLocationUnit())&&(!hasYear||repairDetail.getUpdateTime().getYear()==year-1900)).collect(Collectors.toList());
return ResponseEntity.ok(PageUtil.getPerPage(repairTaskSelectVo.getPage(),repairTaskSelectVo.getSize(),repairDetails2,repairTaskSelectVo.getPageable()));
......
......@@ -40,6 +40,7 @@ import org.springframework.web.bind.annotation.*;
import javax.transaction.Transactional;
import java.sql.Timestamp;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
......@@ -106,14 +107,15 @@ public class DeviceRetiredController {
DeviceRetiredResultVo deviceRetiredResultVo = calcDeviceRetiredResultVo(packingLibrary);
deviceRetiredResultVos.add(deviceRetiredResultVo);
}
List<DeviceRetiredResultVo> deviceRetiredResultVos2 = canRetired(deviceRetiredResultVos);
Map<Integer, DeviceRetiredResultVo> nodeCollect =
deviceRetiredResultVos.stream().collect(Collectors.toMap(DeviceRetiredResultVo::getId, deviceRetiredResultVo -> deviceRetiredResultVo));
deviceRetiredResultVos2.stream().collect(Collectors.toMap(DeviceRetiredResultVo::getId, deviceRetiredResultVo -> deviceRetiredResultVo));
List<DeviceRetiredResultVo> containList = GetTreeUtils.parseTreeFromDown(
deviceRetiredResultVos,
deviceRetiredResultVos2,
DeviceRetiredResultVo::getId,
d -> Optional.ofNullable(nodeCollect.get(d.getPartParentId())),
DeviceRetiredResultVo::addChildNode
).stream().filter(DeviceRetiredResultVo::devNumIsZero).collect(Collectors.toList());
);
return ResultUtil.success(containList);
}
......@@ -293,4 +295,20 @@ public class DeviceRetiredController {
ListUtil.createList(retiredBill.getUserAId()));
}
/**
* 筛选出可以退装的父子装备(父的所有子数量都为0)
*/
private List<DeviceRetiredResultVo> canRetired(List<DeviceRetiredResultVo> deviceRetiredResultVos){
List<DeviceRetiredResultVo> deviceRetiredResultVoList = new ArrayList<>();
Map<Integer,DeviceRetiredResultVo> map = deviceRetiredResultVos.stream().collect(Collectors.toMap(DeviceRetiredResultVo::getId, Function.identity()));
List<DeviceRetiredResultVo> retiredResultVos = deviceRetiredResultVos.stream()
.filter(deviceRetiredResultVo -> deviceRetiredResultVo.getCount()==0&&(deviceRetiredResultVo.getPartParentId()==null||map.get(deviceRetiredResultVo.getPartParentId())==null))
.collect(Collectors.toList());
deviceRetiredResultVoList.addAll(retiredResultVos);
if (retiredResultVos.size()>0) {
deviceRetiredResultVos.removeAll(retiredResultVos);
deviceRetiredResultVoList.addAll(canRetired(deviceRetiredResultVos));
}
return deviceRetiredResultVoList;
}
}
......@@ -35,4 +35,7 @@ public class DeviceRetiredDetailResultVo {
@ApiModelProperty(value = "销毁装备列表", example = "1")
private List<PackingLibrary> packingLibrarys = new ArrayList<>();
@ApiModelProperty(value = "是否能退装")
private Boolean canRetired;
}
......@@ -203,6 +203,7 @@ public class StatisticalController {
Boolean hasOwnUnitDim = deviceLibrarySelectVo.getOwnUnitDim()!=null;
Boolean hasLifeStatusDim = deviceLibrarySelectVo.getLifeStatusDim()!=null;
Boolean hasUpdateTimeDim = deviceLibrarySelectVo.getUpdateTimeDim()!=null;
Boolean hasYear = deviceLibrarySelectVo.getYear()!=null;
SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" );
List<DeviceLibrary> resultList = deviceLibraryService.getAllList(deviceLibrarySelectVo);
resultList.forEach(DeviceLibrary::setConfigName);
......@@ -215,7 +216,8 @@ public class StatisticalController {
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());
return containModelDim&&containNameDim&&containSeqDim&&containLocationUnitDim&&containOwnUnitDim&&containLifeStatusDim&&containUpdateTimeDim;
Boolean sameYear = !hasYear||deviceLibrary.getUpdateTime().getYear()==deviceLibrarySelectVo.getYear()-1900;
return containModelDim&&containNameDim&&containSeqDim&&containLocationUnitDim&&containOwnUnitDim&&containLifeStatusDim&&containUpdateTimeDim&&sameYear;
}).collect(Collectors.toList());
}
List<DeviceLibrary> deviceLibraryEntities = resultList;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论