提交 34ba2b91 authored 作者: zhoushaopan's avatar zhoushaopan

fix(配套设备模块): 新增接口

新增接口
上级 39df44c4
......@@ -187,31 +187,7 @@ public class DeviceLibraryController {
return ResultUtil.success(deviceLibraryEntities);
}
@ApiOperation(value = "查询检查装备列表", notes = "可以通过这个接口查询装备列表")
@PostMapping("/selectCheckDeviceList")
public ResponseEntity selectDeviceList(@RequestBody SelfCheckVo selfCheckVo) {
String unit = userUtils.getCurrentUserUnitName();
PredicateBuilder<DeviceLibrary> predicateBuilder = Specifications.and();
predicateBuilder.eq("locationUnit", unit);
predicateBuilder.eq(selfCheckVo.getStorageLocationId()!=null,"storageLocationId",selfCheckVo.getStorageLocationId());
List<Integer> status = new ArrayList<>(Arrays.asList(5,10,12));
List<DeviceLibrary> deviceLibraries = deviceLibraryDao.findAll(predicateBuilder.build())
.stream().filter(deviceLibrary -> !status.contains(deviceLibrary.getLifeStatus())).collect(Collectors.toList());
deviceLibraries.forEach(DeviceLibrary::setConfigName);
List<DeviceLibrary> deviceLibraryEntities = deviceLibraries.stream()
.filter(deviceLibrary -> deviceLibrary.getLocationUnit().equals(unit)&&(deviceLibrary.getLifeStatus()==2||deviceLibrary.getLifeStatus()==14))
.collect(Collectors.toList());
deviceLibraries.removeAll(deviceLibraryEntities);
Map<String,Object> map = new HashMap<>();
//在库排序
List<DeviceLibrary> stockDevices = deviceLibraryEntities.stream().sorted(Comparator.comparing(DeviceLibrary::getModel)).collect(Collectors.toList());
// map.put("stockDevices",deviceLibraryEntities);
map.put("stockDevices",stockDevices);
//不在库排序
List<DeviceLibrary> notInStockDevices = deviceLibraries.stream().sorted(Comparator.comparing(DeviceLibrary::getModel)).collect(Collectors.toList());
map.put("notInStockDevices",notInStockDevices);
return ResultUtil.success(map);
}
@ApiOperation(value = "查询某单位检查装备列表", notes = "可以通过这个接口查询装备列表")
@PostMapping("/selectCheckDeviceListByUnit")
......
......@@ -86,6 +86,13 @@ public class DeviceLogDto {
this.taskId = taskId;
}
public DeviceLogDto(Integer type, Integer deviceId, String remark, Integer createUserId) {
this.type = type;
this.deviceId = deviceId;
this.remark = remark;
this.createUserId = createUserId;
}
/**
* dto类转化为do类
*/
......
......@@ -19,4 +19,7 @@ public class SelfCheckVo {
@ApiModelProperty(value = "库存位置的id")
private Integer storageLocationId;
@ApiModelProperty(value = "自查的id")
private Integer selfBillId;
}
......@@ -379,6 +379,14 @@ public class MatchingDeviceController {
// }
// return ResponseEntity.ok(page);
List<MatchingDeviceLibrary> matchingDeviceLibraryList = matchingDeviceLibraryService.getMatchingDevicePage(matchingDeviceSelectVo);
if (matchingDeviceSelectVo.getMatchingType() == 1){
//只查询停用的
matchingDeviceLibraryList = matchingDeviceLibraryList.stream().filter(matchingDeviceLibrary ->
matchingDeviceLibrary.getMatchingDeviceStatus() == 3).collect(Collectors.toList());
}else {
matchingDeviceLibraryList = matchingDeviceLibraryList.stream().filter(matchingDeviceLibrary ->
matchingDeviceLibrary.getMatchingDeviceStatus() != 3).collect(Collectors.toList());
}
//处理装备的序列号
matchingDeviceLibraryList.forEach(matchingDeviceLibrary -> {
if (matchingDeviceLibrary.getDeviceId() != null && matchingDeviceLibrary.getDeviceId() != 0) {
......@@ -578,6 +586,22 @@ public class MatchingDeviceController {
deviceLogService.addLog(deviceLogDto);
m.setMatchingDeviceStatus(matchingDeviceEditVo.getMatchingDeviceStatus());
}
if (matchingDeviceEditVo.getRemake() != null &&
!matchingDeviceEditVo.getRemake().equals(m.getRemake())) {
//添加设备 设备的状态
String remark = "将设备的备注改为" + matchingDeviceEditVo.getMatchingDeviceStatusName();
DeviceLogDto deviceLogDto = new DeviceLogDto(1, matchingDeviceEditVo.getMatchingDeviceId(), remark, null, null);
deviceLogService.addLog(deviceLogDto);
m.setRemake(matchingDeviceEditVo.getRemake());
}
if (matchingDeviceEditVo.getFileRet() != null ) {
//添加设备 设备的状态
String remark = "将设备的文件改为" + matchingDeviceEditVo.getMatchingDeviceStatusName();
DeviceLogDto deviceLogDto = new DeviceLogDto(1, matchingDeviceEditVo.getMatchingDeviceId(), remark, null, null);
m.setStatusJson(JacksonUtil.toJSon(matchingDeviceEditVo.getFileRet()));
deviceLogService.addLog(deviceLogDto);
}
matchingDeviceLibraryService.update(m);
return ResponseEntity.ok("修改成功");
}
......@@ -908,6 +932,14 @@ public class MatchingDeviceController {
});
return ResponseEntity.ok("修改成功");
}
@ApiOperation(value = "批量配套设备的状态", notes = "批量配套设备的状态")
@PostMapping("/batchUpdateStatus")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity batchUpdateStatus(@RequestBody StatusVO statusVO) {
matchingDeviceLibraryService.batchUpdateStatus(statusVO);
return ResponseEntity.ok("修改成功");
}
/**
* @return 生成配套设备附件的序列号
*/
......
......@@ -27,4 +27,12 @@ public interface MatchingDeviceLibraryDao extends JpaRepository<MatchingDeviceLi
int updateCreateUnitName(@Param("originUnitName") String originUnitName,
@Param("updateUnitName") String updateUnitName);
@Transactional
@Modifying
@Query("update MatchingDeviceLibrary m set m.matchingDeviceStatus = :status, m.remake = :remake, m.statusJson = :statusJson where m.id in :matchingDeviceIds")
int batchUpdateStatus(@Param("status") Integer status,
@Param("remake") String remake,
@Param("statusJson") String statusJson,
@Param("matchingDeviceIds") List<Integer> matchingDeviceIds);
}
......@@ -4,6 +4,7 @@ import com.tykj.dev.device.matching.subject.domin.MatchingDeviceLibrary;
import com.tykj.dev.device.matching.subject.vo.MatchingUnitVo;
import com.tykj.dev.device.matching.subject.vo.MatchingDeviceSelectVo;
import com.tykj.dev.device.matching.subject.vo.RelationDeviceVo;
import com.tykj.dev.device.matching.subject.vo.StatusVO;
import com.tykj.dev.rfid.entity.vo.RfidPrintVo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
......@@ -112,4 +113,6 @@ public interface MatchingDeviceLibraryService {
* @param matchingUnitVo 修改单位名称的vo
*/
void updateMatchingDeviceCreateUnitNameByUnitName(MatchingUnitVo matchingUnitVo);
void batchUpdateStatus(StatusVO statusVO);
}
......@@ -15,6 +15,7 @@ import com.tykj.dev.device.matching.subject.domin.MatchingDeviceLibrary;
import com.tykj.dev.device.matching.subject.vo.MatchingUnitVo;
import com.tykj.dev.device.matching.subject.vo.MatchingDeviceSelectVo;
import com.tykj.dev.device.matching.subject.vo.RelationDeviceVo;
import com.tykj.dev.device.matching.subject.vo.StatusVO;
import com.tykj.dev.device.user.cache.UnitsCache;
import com.tykj.dev.device.user.subject.entity.Units;
import com.tykj.dev.device.user.subject.service.UnitsService;
......@@ -345,6 +346,26 @@ public class MatchingDeviceLibraryServiceImpl implements MatchingDeviceLibrarySe
matchingDeviceLibraryDao.updateCreateUnitName(matchingUnitVo.getOriginUnitName(),matchingUnitVo.getUpdateUnitName());
}
@Override
public void batchUpdateStatus(StatusVO statusVO) {
Integer status = statusVO.getStatus();
String remake = statusVO.getRemake();
List<Integer> matchingDeviceIds = statusVO.getMatchingDeviceIds();
String statusJson =null;
if (statusVO.getFileRet() != null){
statusJson = JacksonUtil.toJSon(statusVO.getFileRet());
}
matchingDeviceLibraryDao.batchUpdateStatus(status,remake,statusJson,matchingDeviceIds);
Integer currentUserId = userUtils.getCurrentUserId();
//增加日志
List<DeviceLogDto> deviceLogDtos = new ArrayList<>();
matchingDeviceIds.forEach(integer -> {
DeviceLogDto deviceLogDto = new DeviceLogDto(1, integer, "将设备的状态修改为停用",currentUserId );
deviceLogDtos.add(deviceLogDto);
});
deviceLogService.addAllLog(deviceLogDtos);
}
/**
* @param matchingDeviceSelectVo 配套设备查询vo
......
package com.tykj.dev.device.matching.subject.domin;
import com.fasterxml.jackson.core.type.TypeReference;
import com.tykj.dev.config.cache.ConfigCache;
import com.tykj.dev.device.file.entity.FileRet;
import com.tykj.dev.misc.utils.JacksonUtil;
import com.tykj.dev.misc.utils.SpringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
......@@ -142,16 +145,28 @@ public class MatchingDeviceLibrary {
@ApiModelProperty(value = "存放位置id")
private Integer matchingDeviceStorageLocationId;
@ApiModelProperty(value = "设备状态",example = "0 在库 1 使用中 2 维修")
@ApiModelProperty(value = "设备状态",example = "0 在库 1 使用中 2 维修 3停用")
private Integer matchingDeviceStatus = 0;
@ApiModelProperty(value = "备注")
@Column(name = "remake",columnDefinition = "TEXT")
private String remake;
@ApiModelProperty(value = "停用信息的文件")
private String statusJson;
@Transient
private FileRet statusJsonRet;
public MatchingDeviceLibrary setConfigName(){
ConfigCache configCache = SpringUtils.getBean("initConfigCache");
if (configCache != null) {
setLifeStatusName(configCache.getLifeStatusMap().get(this.lifeStatus)==null?"-":configCache.getLifeStatusMap().get(this.lifeStatus));
setTypeName(configCache.getMatchingTypeMap().get(Integer.valueOf(this.type))==null?"-":configCache.getMatchingTypeMap().get(Integer.valueOf(this.type)));
if (this.statusJson != null){
statusJsonRet = JacksonUtil.readValue(this.statusJson, new TypeReference<FileRet>() {
});
}
}
return this;
}
......
package com.tykj.dev.device.matching.subject.vo;
import com.tykj.dev.device.file.entity.FileRet;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -74,4 +75,10 @@ public class MatchingDeviceEditVo {
@ApiModelProperty(value = "设备状态",example = "0 在库 1 使用中 2 维修")
private String matchingDeviceStatusName;
@ApiModelProperty(value = "备注")
private String remake;
@ApiModelProperty(value = "文件")
private FileRet fileRet;
}
......@@ -49,4 +49,8 @@ public class MatchingDeviceSelectVo extends CustomPage {
@ApiModelProperty(value = "设备状态")
private Integer matchingDeviceStatus ;
@ApiModelProperty(value = "类型 1 代表只查询停用的")
private Integer matchingType ;
}
package com.tykj.dev.device.matching.subject.vo;
import com.tykj.dev.device.file.entity.FileRet;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author zsp
* @create 2022/4/28 9:46
*/
@Data
@ApiModel("状态vo")
public class StatusVO {
@ApiModelProperty(value = "配套设备的id的集合")
private List<Integer> matchingDeviceIds;
@ApiModelProperty(value = "状态Id")
private Integer status;
@ApiModelProperty(value = "状态名称")
private String statusName;
@ApiModelProperty(value = "备注")
private String remake;
@ApiModelProperty("单据")
private FileRet fileRet;
}
package com.tykj.dev.device.selfcheck.controller;
import com.fasterxml.jackson.core.type.TypeReference;
import com.github.wenhao.jpa.PredicateBuilder;
import com.github.wenhao.jpa.Specifications;
import com.tykj.dev.config.repository.SystemVariableDao;
import com.tykj.dev.config.service.SystemVariableService;
import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.device.file.service.FilesUtil;
//import com.tykj.dev.device.library.repository.DeviceLibraryDao;
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;
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.SelfCheckVo;
import com.tykj.dev.device.selfcheck.base.SelfCheckSchedulerTask;
import com.tykj.dev.device.selfcheck.repository.SelfCheckBillDao;
import com.tykj.dev.device.selfcheck.service.SelfCheckBillService;
import com.tykj.dev.device.selfcheck.subject.domin.SelfCheckBill;
import com.tykj.dev.device.selfcheck.subject.vo.*;
......@@ -19,6 +24,7 @@ import com.tykj.dev.device.task.service.TaskLogService;
import com.tykj.dev.device.task.service.TaskService;
import com.tykj.dev.device.task.subject.bto.TaskBto;
import com.tykj.dev.device.task.subject.domin.Task;
import com.tykj.dev.device.user.cache.StoreCache;
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.dao.UnitsDao;
......@@ -46,6 +52,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
......@@ -102,6 +109,12 @@ public class SelfCheckController {
@Qualifier("taskExecutor")
private Executor executor;
@Resource
private StoreCache storeCache;
@Resource
private DeviceLibraryDao deviceLibraryDao;
/**
* 月度
*/
......@@ -297,7 +310,10 @@ public class SelfCheckController {
userIds.add(userUtils.getCurrentUserId());
TaskBto taskBto = new TaskBto(StatusEnum.WAIT_SELF_CHECK.id,selfCheckBill1.getTitle(),null,".",selfCheckBill1.getId(),4,userUtils.getCurrentUnitId(),0,message,userIds);
TaskBto taskBto1 = taskService.start(taskBto);
return ResponseEntity.ok(taskBto1.getId());
SelfVO selfVO = new SelfVO();
selfVO.setSelfCheckId(selfCheckBill1.getId());
selfVO.setTaskId(taskBto1.getId());
return ResponseEntity.ok(selfVO);
}
@ApiOperation(value = "发起自查业务", notes = "可以通过这个接口发起自查业务")
......@@ -676,6 +692,9 @@ public class SelfCheckController {
if (s.getId()!=null){
s.setTaskId(taskService.get(s.getId(),4).getId());
}
if (s.getStorageLocationId() != null){
s.setStorageLocationName(storeCache.idToName(s.getStorageLocationId()));
}
}
return ResultUtil.success(page);
}
......@@ -701,7 +720,22 @@ public class SelfCheckController {
//获取自查详情
String str3 = selfExaminationBillEntity.getCheckDetail();
String str4 = selfExaminationBillEntity.getNewDeviceDetail();
String[] split = str3.split("x");
List<DeviceLibrary> libraryEntities1 = new ArrayList<>();
if (str3 != null) {
String[] split = str3.split("x");
//添加自查装备
for (String s:split) {
if (s.length()>=2) {
Integer i = Integer.parseInt(s.substring(0, s.length() - 1));
Integer checkResult = Integer.parseInt(s.substring(s.length()-1));
DeviceLibrary deviceLibraryEntity = deviceLibraryMap.get(i);
deviceLibraryEntity.setCheckResult(checkResult);
libraryEntities1.add(deviceLibraryEntity);
}
}
}
//添加新增不在系统的装备
List<DeviceLibrary> newDeviceList = new ArrayList<>();
if (str4!=null) {
......@@ -723,17 +757,7 @@ public class SelfCheckController {
}
}
list.add(newDeviceList);
List<DeviceLibrary> libraryEntities1 = new ArrayList<>();
//添加自查装备
for (String s:split) {
if (s.length()>=2) {
Integer i = Integer.parseInt(s.substring(0, s.length() - 1));
Integer checkResult = Integer.parseInt(s.substring(s.length()-1));
DeviceLibrary deviceLibraryEntity = deviceLibraryMap.get(i);
deviceLibraryEntity.setCheckResult(checkResult);
libraryEntities1.add(deviceLibraryEntity);
}
}
list.add(libraryEntities1);
//添加业务日志
list.add(taskLogService.getByTaskId(taskBto.getId()));
......@@ -748,13 +772,22 @@ public class SelfCheckController {
return ResultUtil.success(list);
}
@Resource
private SelfCheckBillDao selfCheckBillDao;
@ApiOperation(value = "是否保存自查任务", notes = "可以通过这个接口查询是否保存自查任务")
@PostMapping(value = "/isSaveSelfTask")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity isSaveSelfTask(@RequestBody SaveSelfTaskVo saveSelfTaskVo){
//保存自查任务
if (saveSelfTaskVo.getIsSave() == 0){
return this.selectDetail(taskService.get(saveSelfTaskVo.getTaskId()).getBillId());
SelfCheckBill checkBill = selfCheckBillService.getOne(saveSelfTaskVo.getSelfCheckId());
if (saveSelfTaskVo.getStorageLocationId() != null){
checkBill.setStorageLocationId(saveSelfTaskVo.getStorageLocationId());
}
//更新
selfCheckBillDao.save(checkBill);
return this.selectDetail(taskService.get(saveSelfTaskVo.getTaskId()).getBillId());
}else {
//删除task
TaskBto taskBto = taskService.get(saveSelfTaskVo.getTaskId());
......@@ -903,4 +936,40 @@ public class SelfCheckController {
return ResponseEntity.ok(selfCheckBillService.getFileList(taskId));
}
@ApiOperation(value = "查询检查装备列表", notes = "可以通过这个接口查询装备列表")
@PostMapping("/selectCheckDeviceList")
public ResponseEntity selectDeviceList(@RequestBody SelfCheckVo selfCheckVo) {
Integer selfBillId = selfCheckVo.getSelfBillId();
Integer storageLocationId = null;
if(selfBillId != null){
SelfCheckBill checkBill = selfCheckBillService.getOne(selfBillId);
storageLocationId = checkBill.getStorageLocationId();
}
String unit = userUtils.getCurrentUserUnitName();
PredicateBuilder<DeviceLibrary> predicateBuilder = Specifications.and();
predicateBuilder.eq("locationUnit", unit);
if (selfCheckVo.getStorageLocationId() != null){
predicateBuilder.eq(selfCheckVo.getStorageLocationId()!=null,"storageLocationId",selfCheckVo.getStorageLocationId());
} else {
predicateBuilder.eq("storageLocationId",storageLocationId);
}
List<Integer> status = new ArrayList<>(Arrays.asList(5,10,12));
List<DeviceLibrary> deviceLibraries = deviceLibraryDao.findAll(predicateBuilder.build())
.stream().filter(deviceLibrary -> !status.contains(deviceLibrary.getLifeStatus())).collect(Collectors.toList());
deviceLibraries.forEach(DeviceLibrary::setConfigName);
List<DeviceLibrary> deviceLibraryEntities = deviceLibraries.stream()
.filter(deviceLibrary -> deviceLibrary.getLocationUnit().equals(unit)&&(deviceLibrary.getLifeStatus()==2||deviceLibrary.getLifeStatus()==14))
.collect(Collectors.toList());
deviceLibraries.removeAll(deviceLibraryEntities);
Map<String,Object> map = new HashMap<>();
//在库排序
List<DeviceLibrary> stockDevices = deviceLibraryEntities.stream().sorted(Comparator.comparing(DeviceLibrary::getModel)).collect(Collectors.toList());
// map.put("stockDevices",deviceLibraryEntities);
map.put("stockDevices",stockDevices);
//不在库排序
List<DeviceLibrary> notInStockDevices = deviceLibraries.stream().sorted(Comparator.comparing(DeviceLibrary::getModel)).collect(Collectors.toList());
map.put("notInStockDevices",notInStockDevices);
return ResultUtil.success(map);
}
}
......@@ -144,6 +144,13 @@ public class SelfCheckBill {
@ApiModelProperty(value = "手持终端信息")
private String handheldTerminalInformation;
@ApiModelProperty(value = "装备存放位置Id",notes = "默认是库房, null代表是所有库房")
private Integer storageLocationId;
@ApiModelProperty(value = "装备存放位置Id",notes = "默认是库房, null代表是所有库房")
@Transient
private String storageLocationName;
@ApiModelProperty(value = "检查人")
@Transient
private String checkUser;
......
......@@ -18,4 +18,11 @@ public class SaveSelfTaskVo {
@ApiModelProperty("任务id")
private Integer taskId;
@ApiModelProperty("自查id")
private Integer selfCheckId;
@ApiModelProperty(value = "装备存放位置Id",notes = "默认是库房, null代表是所有库房")
private Integer storageLocationId;
}
package com.tykj.dev.device.selfcheck.subject.vo;
import lombok.Data;
/**
* @author zsp
* @create 2022/4/28 17:19
*/
@Data
public class SelfVO {
private Integer taskId;
private Integer selfCheckId;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论