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

更新

上级 29e042b5
......@@ -232,6 +232,9 @@ public class DeviceApplyController {
allotBillEntity.setSendTime(new Date());
allotBillEntity.setAllotType(2);
allotBillEntity.setAllotStatus(2);
if (deviceApplyAllotSaveVo.getSendUserbId()!=null) {
allotBillEntity.setAgent(userPublicService.getOne(deviceApplyAllotSaveVo.getSendUserbId()).getName());
}
AllotBill allotBill = allotBillService.addEntity(allotBillEntity);
Calendar calendar = Calendar.getInstance();
calendar.setTime(allotBill.getCreateTime());
......
......@@ -15,13 +15,13 @@ public enum DeviceInvisibleRange {
*/
SHEN(1, "省一级"),
/**
* 一级
* 一级
*/
XIAN(3, "县一级"),
SHI(2, "市一级"),
/**
* 一级
* 一级
*/
SHI(2, "市一级");
XIAN(3, "县一级");
public Integer id;
......
package com.tykj.dev.device.packing.controller;
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.service.PackingLibraryService;
import com.tykj.dev.device.packing.subject.domin.PackingLibrary;
......@@ -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.StatusEnum;
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.ResultUtil;
import com.tykj.dev.socket.MyWebSocket;
......@@ -27,9 +30,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.Comparator;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
@RestController
......@@ -60,6 +61,9 @@ public class PackingController {
@Autowired
PackingLibraryDao packingLibraryDao;
@Autowired
DeviceLibraryService deviceLibraryService;
@ApiOperation(value = "新增列装", notes = "可以通过这个接口发起列装")
@PostMapping("/addPackingLibrary")
@Transactional(rollbackFor = Exception.class)
......@@ -150,6 +154,11 @@ public class PackingController {
@ApiOperation(value = "添加列装型号")
@PostMapping("/add/model")
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();
BeanUtils.copyProperties(addModel,packingLibrary);
packingLibrary.setIsRoot(1);
......@@ -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 = "编辑列装型号")
@PostMapping("/update/model")
public ResponseEntity updateModel(@RequestBody @Validated PackingModelEdit packingModelEdit){
......@@ -246,6 +307,11 @@ public class PackingController {
packingLibraryDao.saveAll(packingLibraries);
}
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);
packingLibraryService.update(packingLibrary);
}
......
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.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.SelectPack;
import org.springframework.data.domain.Page;
......@@ -105,4 +107,20 @@ public interface PackingLibraryService {
List<PackingLibrary> setOrder(List<PackingLibrary> packingLibraries);
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;
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.AllotSeqs;
import com.tykj.dev.device.packing.subject.vo.PackingLibrarySelectVo;
import com.tykj.dev.device.packing.subject.vo.SelectPack;
import com.tykj.dev.device.user.util.UserUtils;
......@@ -301,6 +302,73 @@ public class PackingLibraryServiceImpl implements PackingLibraryService {
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) {
PredicateBuilder<PackingLibrary> predicateBuilder = Specifications.and();
Integer level = userUtils.getCurrentUnitLevel();
......
......@@ -239,6 +239,9 @@ public class PackingLibrary {
@Transient
private String natureName;
@Transient
private Integer devNum;
public void addChildNode(PackingLibrary 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;
}
......@@ -2,11 +2,14 @@ package com.tykj.dev.rfid.controller;
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.DeviceLogService;
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.DeviceLog;
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.task.service.TaskLogService;
import com.tykj.dev.device.task.service.TaskService;
......@@ -44,10 +47,8 @@ import javax.transaction.Transactional;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author huangxiahao
......@@ -77,6 +78,8 @@ public class RfidController {
private final InventoryScheduled inventoryScheduled;
@Autowired
private AuthenticationUtils AuthenticationUtils;
@Autowired
private DeviceLogDao deviceLogDao;
public RfidController(RfidChangeLogService rfidChangeLogService, RfidService rfidService, LibraryWarningLogService libraryWarningLogService, RfidChangeBillService rfidChangeBillService, InventoryScheduled inventoryScheduled) {
this.rfidChangeLogService = rfidChangeLogService;
......@@ -295,6 +298,12 @@ public class RfidController {
rfidChangeLogSelectVo.setValidTag(1);
//获取装备信息
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<RfidChangeLogVo> vos = new ArrayList<>();
......@@ -306,7 +315,7 @@ public class RfidController {
vos.add(rfidChangeLogVo);
});
//组装
TagDetailVo tagDetailVo = new TagDetailVo(device, vos);
TagDetailVo tagDetailVo = new TagDetailVo(device, vos,deviceLogEntities);
return ResultUtil.success(tagDetailVo);
}
......
package com.tykj.dev.rfid.entity.vo;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.library.subject.vo.DeviceLogUserVo;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
......@@ -21,4 +22,6 @@ public class TagDetailVo {
private DeviceLibrary deviceLibraryEntity;
private List<RfidChangeLogVo> rfidChangeLogEntities;
private List<DeviceLogUserVo> deviceLogEntities;
}
......@@ -14,7 +14,6 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import org.modelmapper.ModelMapper;
import javax.persistence.*;
......@@ -32,7 +31,6 @@ import javax.persistence.*;
@Data
@Entity
@ApiModel(value = "用户对象", description = "用户详细信息")
@Where(clause = "is_del = 0")
@SQLDelete(sql = "update user set is_del = 1 where id = ?")
public class User {
/**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论