提交 9641bece authored 作者: zhoushaopan's avatar zhoushaopan

feat(装备管理模块,列装模块): 新增装备修改序列号和父id的接口,优化了解绑速度

新增装备修改序列号和父id的接口,优化了解绑速度
上级 c163be52
......@@ -2,12 +2,14 @@ package com.tykj.dev.config.cache;
import com.tykj.dev.config.domin.SystemConfig;
import lombok.Data;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Data
@Component
public class ConfigCache {
private Map<Integer, String> lifeStatusMap;
......
......@@ -945,6 +945,13 @@ public class DeviceLibraryController {
return ResponseEntity.ok(map);
}
@ApiOperation("入库修改试用装备的序列号")
@PostMapping("updateSeq")
public ResponseEntity updateSeq(@RequestBody DeviceForApplyVo deviceForApplyVo){
deviceLibraryService.updateSeqNumber(deviceForApplyVo);
return ResponseEntity.ok("更新成功");
}
@ApiOperation(value = "根据装备id查询装备详情", notes = "根据装备id查询装备详情")
@PostMapping("/selectByIds1")
public List<DeviceNewVo> selectByIds1(@RequestBody DeviceSelectIdsVo deviceSelectIdsVo){
......@@ -1100,6 +1107,13 @@ public class DeviceLibraryController {
return setOrderNumber(sortNum, allListAndParent);
}
@ApiOperation("测试婴喜爱")
@PostMapping("test")
public ResponseEntity test(@RequestBody List<Integer> deviceIds){
deviceLibraryService.updatePartParentId(deviceIds);
return ResponseEntity.ok("更新成功");
}
public List<DeviceLibrary> getAllListAndParent(){
DeviceLibrarySelectVo deviceLibrarySelectVo = new DeviceLibrarySelectVo();
List<DeviceLibrary> deviceLibraryServiceAllList = deviceLibraryService.getAllList(deviceLibrarySelectVo);
......
......@@ -217,10 +217,10 @@ public interface DeviceLibraryDao extends JpaRepository<DeviceLibrary, Integer>,
@Param("packingId") Integer packingId,
@Param("deviceIds") List<Integer> deviceIds);
// @Transactional
// @Modifying
// @Query("update DeviceLibrary o set o.partParentId = null where o.id in :deviceIds")
// int updatePartParentId(
// @Param("deviceIds") List<Integer> deviceIds);
@Transactional
@Modifying
@Query("update DeviceLibrary o set o.partParentId = null where o.id in :deviceIds")
int updatePartParentId(
@Param("deviceIds") List<Integer> deviceIds);
}
......@@ -3,6 +3,7 @@ package com.tykj.dev.device.library.service;
import com.tykj.dev.config.UpdateCache;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.library.subject.vo.BindingDeviceVo;
import com.tykj.dev.device.library.subject.vo.DeviceForApplyVo;
import com.tykj.dev.device.library.subject.vo.DeviceLibrarySelectVo;
import com.tykj.dev.device.library.subject.vo.DeviceStatisticsVo;
import org.springframework.data.domain.Page;
......@@ -448,12 +449,12 @@ public interface DeviceLibraryService {
*/
List<DeviceLibrary> findAllDevices();
// /**
// * 根据装备id的集合更新列装id
// * @param deviceIds 装备id的集合
// * @return 影响行数
// */
// int updatePartParentId(List<Integer> deviceIds);
/**
* 根据装备id的集合更新列装id
* @param deviceIds 装备id的集合
*/
void updatePartParentId(List<Integer> deviceIds);
/**
......@@ -486,5 +487,16 @@ public interface DeviceLibraryService {
*/
void updateTry(List<DeviceLibrary> deviceLibraries);
/**
* 获取所有装备的集合
* @param deviceLibrarySelectVo 查询装备的vo
* @return 所有装备
*/
List<DeviceLibrary> getAlldevList(DeviceLibrarySelectVo deviceLibrarySelectVo);
/**
* 根据装备id更新装备
* @param deviceForApplyVo 更新试用装备序列号的vo
*/
void updateSeqNumber(DeviceForApplyVo deviceForApplyVo);
}
......@@ -15,10 +15,7 @@ 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.BindingDeviceVo;
import com.tykj.dev.device.library.subject.vo.DeviceLibraryCacheSelectVo;
import com.tykj.dev.device.library.subject.vo.DeviceLibrarySelectVo;
import com.tykj.dev.device.library.subject.vo.DeviceStatisticsVo;
import com.tykj.dev.device.library.subject.vo.*;
import com.tykj.dev.device.library.utils.DeviceNumberUtils;
import com.tykj.dev.device.user.subject.entity.Units;
import com.tykj.dev.device.user.subject.service.UnitsService;
......@@ -1003,6 +1000,12 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
return cacheLibraryService.getAllDeviceLibraryList();
}
@Override
@UpdateCache
public void updatePartParentId(List<Integer> deviceIds) {
deviceLibraryDao.updatePartParentId(deviceIds);
}
@Override
@UpdateCache
public void unboundDevice(List<DeviceLibrary> deviceLibraries) {
......@@ -1085,6 +1088,20 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
return list;
}
@Override
@UpdateCache
public void updateSeqNumber(DeviceForApplyVo deviceForApplyVo) {
DeviceLibrary library = getOne(deviceForApplyVo.getDeviceId());
library.setSeqNumber(deviceForApplyVo.getSeqNumber().trim());
//先判断序列号存不存在
DeviceLibrary bySeqNumber = deviceLibraryDao.findBySeqNumber(deviceForApplyVo.getSeqNumber().trim());
if (bySeqNumber != null){
throw new ApiException("序列号已经存在,请更换序列号");
}else {
deviceLibraryDao.save(library);
}
}
// @Override
// @UpdateCache
// public int updatePartParentId(List<Integer> deviceIds) {
......
package com.tykj.dev.device.library.subject.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.stereotype.Repository;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* @author zsp
*/
@Repository
@Data
@ApiModel("更新试用装备序列号的vo")
public class DeviceForApplyVo {
@NotNull(message = "deviceId不能为空")
@Min(value = 1,message = "deviceId不能小于1")
@ApiModelProperty(value = "装备id", example = "1")
private Integer deviceId;
@ApiModelProperty(value = "装备的序列号", example = "12344")
private String seqNumber;
}
......@@ -515,10 +515,7 @@ public class PackingController {
List<DeviceLibrary> deviceLibraries = deviceLibraryCacheService.getAllDeviceLibraryList();
List<String> existSeqs = deviceLibraries.stream().map(DeviceLibrary::getSeqNumber).collect(Collectors.toList());
List<String> inputSeqs = DeviceSeqUtil.selectDeviceSeqs(seq);
// if (inputSeqs.size()>0&&inputSeqs.size()!=num){
// return ResponseEntity.ok("序列号区间总数为"+inputSeqs.size()+",与装备数量不匹配");
// }
if (inputSeqs.size()>0&&inputSeqs.size()>num){
if (inputSeqs.size()>0&&inputSeqs.size()!=num){
return ResponseEntity.ok("序列号区间总数为"+inputSeqs.size()+",与装备数量不匹配");
}
else {
......
......@@ -977,14 +977,19 @@ public class PackingLibraryServiceImpl implements PackingLibraryService {
List<Integer> deviceIds = deviceLibraries.stream().map(DeviceLibrary::getId).collect(Collectors.toList());
//将装备的父id全部置空
Integer userId = userUtils.getCurrentUserId();
List<DeviceLogDto> deviceLogDtos = new ArrayList<>();
long l = System.currentTimeMillis();
deviceLibraryService.updatePartParentId(deviceIds);
log.info("更新父id时间为:{}",System.currentTimeMillis()-l);
deviceLibraries.forEach(deviceLibrary -> {
DeviceLogDto deviceLogDto = new DeviceLogDto();
deviceLibrary.setPartParentId(null);
deviceLibraryService.update(deviceLibrary);
deviceLogDto.setDeviceId(deviceLibrary.getId());
deviceLogDto.setRemark("由于列装进行了解绑,装备也伴随着解绑");
deviceLogDto.setRemark("由于列装进行了解绑,装备也需要进行解绑");
deviceLogDto.setCreateUserId(userId);
deviceLogService.addLog(deviceLogDto);
deviceLogDtos.add(deviceLogDto);
});
executor.execute(()->{
deviceLogService.addAllLog(deviceLogDtos);
});
//修改列装
packingLibrary.setPartParentId(null);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论