提交 c53f6b3e authored 作者: zjm's avatar zjm

合并分支 'dev' 到 'master'

Dev 查看合并请求 !34
......@@ -180,6 +180,16 @@ public interface DeviceLibraryDao extends JpaRepository<DeviceLibrary, Integer>,
@Query("update DeviceLibrary d set d.ownUnit = :ownUnit,d.locationUnit = :ownUnit,d.lifeStatus = 2 where d.id in :deviceIds")
int updateDevicesOwnUnit(@Param("ownUnit") String ownUnit,@Param("deviceIds") List<Integer> deviceIds);
@Transactional
@Modifying
@Query("update DeviceLibrary o set o.matchingRange = :matchingRange ,o.updateTime=current_timestamp where o.packingId = :packingId")
int updateMatchingRange(Integer matchingRange,Integer packingId);
@Transactional
@Modifying
@Query("update DeviceLibrary o set o.matchingRange = :matchingRange ,o.updateTime=current_timestamp where o.id in :deviceIds")
int updateMatchingRange2(Integer matchingRange,@Param("deviceIds") List<Integer> deviceIds);
List<DeviceLibrary> findByModelAndIsPart(String model,Integer isPart);
}
......@@ -253,4 +253,15 @@ public interface DeviceLibraryService {
int getMaxSeqNumber(String model);
List<String> getMaxPartSeqNumber(String model,Integer isPart);
/**
* 通过 packing 查询装备
* @param packing 列装id
* @return
*/
List<DeviceLibrary> findDevicesByPacking(Integer packing);
void updateMatchingRange(List<DeviceLibrary> libraries);
}
......@@ -771,6 +771,16 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
}
@Override
public List<DeviceLibrary> findDevicesByPacking(Integer packing) {
return deviceLibraryDao.findAllByPackingId(packing);
}
@Override
public void updateMatchingRange(List<DeviceLibrary> libraries) {
}
@Override
public DeviceLibrary update(DeviceLibrary deviceLibraryEntity) {
......
......@@ -758,11 +758,50 @@ public class PackingController {
}
if (packingLibraryUpdateVo.getMatchingRange()!=null&&!packingLibraryUpdateVo.getMatchingRange().equals(packingLibrary.getMatchingRange())){
//添加列装配用范围日志
PackingLog packingLog = new PackingLog();
packingLog.setRemark("将配用范围从"+configCache.getMatchingRangeMap().getOrDefault(packingLibrary.getMatchingRange(),"空")+"改为"+configCache.getMatchingRangeMap().get(packingLibraryUpdateVo.getMatchingRange()));
packingLog.setPackingId(packingLibrary.getId());
packingLogService.add(packingLog);
packingLibrary.setMatchingRange(packingLibraryUpdateVo.getMatchingRange());
// PackingLog packingLog = new PackingLog();
// packingLog.setRemark("将配用范围从"+configCache.getMatchingRangeMap().getOrDefault(packingLibrary.getMatchingRange(),"空")+"改为"+configCache.getMatchingRangeMap().get(packingLibraryUpdateVo.getMatchingRange()));
// packingLog.setPackingId(packingLibrary.getId());
// packingLogService.add(packingLog);
// packingLibrary.setMatchingRange(packingLibraryUpdateVo.getMatchingRange());
updatePacking(packingLibrary,packingLibraryUpdateVo);
//修改子列装
// List<PackingLibrary> packingLibraryChilds = packingLibrary.getChilds();
// if(packingLibraryChilds.size()>0){
// packingLibraryChilds.forEach(packingLibrary1 -> {
// packingLibrary1.setMatchingRange(packingLibrary.getMatchingRange());
// packingLibraryDao.save(packingLibrary1);
// PackingLog packingLog1 = new PackingLog();
// packingLog.setRemark("将配用范围从"+configCache.getMatchingRangeMap().getOrDefault(packingLibrary1.getMatchingRange(),"空")+"改为"+configCache.getMatchingRangeMap().get(packingLibraryUpdateVo.getMatchingRange()));
// packingLog.setPackingId(packingLibrary1.getId());
// packingLogService.add(packingLog1);
// }
// );
// }
//从而修改装备
List<DeviceLibrary> deviceLibraries = deviceLibraryService.findDevicesByPacking(packingLibrary.getId());
List<DeviceLibrary> deviceLibraryList = new ArrayList<>();
if(deviceLibraries.size()>0){
deviceLibraries.forEach(deviceLibrary -> {
deviceLibrary.setMatchingRange(packingLibraryUpdateVo.getMatchingRange());
deviceLibraryList.add(deviceLibrary);
});
//批量修改装备和添加装备日志
List<Integer> ids = deviceLibraryList.stream().map(DeviceLibrary::getId).collect(Collectors.toList());
Integer userId = userUtils.getCurrentUserId();
if(ids.size()>0){
deviceLibraryDao.updateMatchingRange2(packingLibraryUpdateVo.getMatchingRange(),ids);
List<DeviceLog> logDtos=new ArrayList<>();
String remark = "将原配用范围"+packingLibrary.getMatchingRangeName()+"修改为"+packingLibraryUpdateVo.getMatchingRangeName();
ids.forEach(integer -> {
logDtos.add(new DeviceLogDto(integer,remark,null,userId,null).toDo());
});
//更新日志
executor.execute(()->{
deviceLogService.saveAllLog(logDtos);
});
}
}
deviceLibraryDao.upDateMatchingRange(packingLibrary.getMatchingRange(),packingLibrary.getId());
}
if (packingLibraryUpdateVo.getInvisibleRange()!=null&&!packingLibraryUpdateVo.getInvisibleRange().equals(packingLibrary.getInvisibleRange())){
......@@ -925,4 +964,27 @@ public class PackingController {
resultList.sort(Comparator.comparing(PackingLibrary::getShowOrder,Comparator.nullsLast(Integer::compareTo)).thenComparing(Comparator.comparing(PackingLibrary::getModel)));
return resultList;
}
/**
* 查询当前装备的子节点
* @param packing 列装id
* @return
*/
private List<DeviceLibrary> findDevicesByPacking(Integer packing){
return deviceLibraryService.findAllByPackingId(packing);
}
private void updatePacking(PackingLibrary packingLibrary,PackingLibraryUpdateVo packingLibraryUpdateVo){
PackingLog packingLog = new PackingLog();
packingLog.setRemark("将配用范围从"+configCache.getMatchingRangeMap().getOrDefault(packingLibrary.getMatchingRange(),"空")+"改为"+configCache.getMatchingRangeMap().get(packingLibraryUpdateVo.getMatchingRange()));
packingLog.setPackingId(packingLibrary.getId());
packingLogService.add(packingLog);
packingLibrary.setMatchingRange(packingLibraryUpdateVo.getMatchingRange());
List<PackingLibrary> byParentId = packingLibraryService.findByParentId(packingLibrary.getId());
if (byParentId.size() > 0){
byParentId.forEach(packingLibrary1 -> {
updatePacking(packingLibrary1,packingLibraryUpdateVo);
});
}
}
}
......@@ -8,6 +8,7 @@ import com.tykj.dev.device.packing.subject.vo.PackingLibrarySelectVo;
import com.tykj.dev.device.packing.subject.vo.SelectPack;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import java.util.List;
......@@ -214,4 +215,9 @@ public interface PackingLibraryService{
* 查询所有的列装model的排序
*/
void getSortMap();
/**
* 根据父id查询
*/
List<PackingLibrary> findByParentId(Integer parentId);
}
......@@ -5,6 +5,7 @@ import com.github.wenhao.jpa.Specifications;
import com.tykj.dev.blockcha.subject.entity.BcHash;
import com.tykj.dev.blockcha.subject.service.BlockChainUtil;
import com.tykj.dev.config.TaskBeanConfig;
import com.tykj.dev.config.base.DeviceLifeStatus;
import com.tykj.dev.config.cache.ConfigCache;
import com.tykj.dev.device.library.repository.DeviceLibraryDao;
import com.tykj.dev.device.library.service.DeviceLibraryService;
......@@ -291,6 +292,48 @@ public class PackingLibraryServiceImpl implements PackingLibraryService {
}).sorted(Comparator.comparing(PackingLibrary::getShowOrder,Comparator.nullsLast(Integer::compareTo))).collect(Collectors.toList());
}
// /**
// * @param id 列装主键id
// * 通过id逻辑删除该列装以及所有子列装
// */
// @Override
// @Transient
// public void deleteAll(Integer id) {
// PackingLibrary packingLibrary = getOne(id);
// if (packingLibrary.getPackingStatus()==2) {
// if (deviceLibraryDao.getAllByPackingId(id).size() > 0) {
// throw new ApiException(ResponseEntity.status(20000).body("该列装型号已有装备,请进行退装操作"));
// }
// if (packingLibrary.getIsRoot() == 1) {
// if (packingLibraryDao.findAllByPartParentIdAndPackingStatus(id, 2).size() > 0) {
// throw new ApiException(ResponseEntity.status(20000).body("该列装型号目录下存在列装装备"));
// }
// Integer order = packingLibrary.getShowOrder();
//// getInsertList(new SelectPack()).forEach(packingLibrary1 -> {
//// if (packingLibrary1.getShowOrder() > order) {
//// packingLibrary1.setShowOrder(packingLibrary1.getShowOrder() - 1);
//// update(packingLibrary1);
//// }
//// });
// }
// List<Integer> ids = packingLibraryDao.findAllByPartParentId(id).stream().map(PackingLibrary::getId).collect(Collectors.toList());
// delete(id);
// if (ids.size() > 0) {
// ids.forEach(integer -> {
// if (deviceLibraryDao.getAllByPackingId(integer).size() > 0) {
// throw new ApiException(ResponseEntity.status(20000).body("该列装型号已有装备,请进行退装操作"));
// }
// deleteAll(integer);
// });
// }
// //发送阅知信息
// List<Integer> userIds = userPublicService.findOtherUser(userUtils.getCurrentUserId());
// MessageBto messageBto = new MessageBto(0, 1, "手动删除列装", userIds, 0);
// messageBto.setRecord(id.toString());
// messageService.add(messageBto);
// }
// }
/**
* @param id 列装主键id
* 通过id逻辑删除该列装以及所有子列装
......@@ -299,27 +342,24 @@ public class PackingLibraryServiceImpl implements PackingLibraryService {
@Transient
public void deleteAll(Integer id) {
PackingLibrary packingLibrary = getOne(id);
List<Integer> status = new ArrayList<>(Arrays.asList(DeviceLifeStatus.RETIRE.id,DeviceLifeStatus.DESTROYED.id,DeviceLifeStatus.SCRAP_I.id));
List<DeviceLibrary> deviceLibraries = deviceLibraryDao.getAllByPackingId(id).stream()
.filter(deviceLibrary -> !status.contains(deviceLibrary.getLifeStatus())).collect(Collectors.toList());
if (packingLibrary.getPackingStatus()==2) {
if (deviceLibraryDao.getAllByPackingId(id).size() > 0) {
if (deviceLibraries.size() > 0) {
throw new ApiException(ResponseEntity.status(20000).body("该列装型号已有装备,请进行退装操作"));
}
if (packingLibrary.getIsRoot() == 1) {
if (packingLibraryDao.findAllByPartParentIdAndPackingStatus(id, 2).size() > 0) {
throw new ApiException(ResponseEntity.status(20000).body("该列装型号目录下存在列装装备"));
}
Integer order = packingLibrary.getShowOrder();
// getInsertList(new SelectPack()).forEach(packingLibrary1 -> {
// if (packingLibrary1.getShowOrder() > order) {
// packingLibrary1.setShowOrder(packingLibrary1.getShowOrder() - 1);
// update(packingLibrary1);
// }
// });
}
List<Integer> ids = packingLibraryDao.findAllByPartParentId(id).stream().map(PackingLibrary::getId).collect(Collectors.toList());
delete(id);
if (ids.size() > 0) {
ids.forEach(integer -> {
if (deviceLibraryDao.getAllByPackingId(integer).size() > 0) {
if (deviceLibraryDao.getAllByPackingId(integer).stream().allMatch(deviceLibrary ->
status.contains(deviceLibrary.getLifeStatus()))) {
throw new ApiException(ResponseEntity.status(20000).body("该列装型号已有装备,请进行退装操作"));
}
deleteAll(integer);
......@@ -356,27 +396,58 @@ public class PackingLibraryServiceImpl implements PackingLibraryService {
messageService.add(messageBto);
}
// /**
// * @param ids 列装主键id列表
// * 通过id将回收站装备清空删除
// */
// @Override
// public void cleanAll(List<Integer> ids) {
// for (Integer id:ids){
// PackingLibrary packingLibrary = getOne(id);
// packingLibrary.setDeleteTag(1);
// update(packingLibrary);
// //添加列装日志
// PackingLog packingLog = new PackingLog();
// packingLog.setRemark("回收站清空列装");
// packingLog.setPackingId(id);
// packingLogService.add(packingLog);
// }
// //发送阅知信息
// List<Integer> userIds = userPublicService.findOtherUser(userUtils.getCurrentUserId());
// MessageBto messageBto = new MessageBto(0,1,"回收站清空列装",userIds,0);
// messageBto.setRecord(StringSplitUtil.idListToString(ids));
// messageService.add(messageBto);
// }
/**
* @param ids 列装主键id列表
* 通过id将回收站装备清空删除
*/
@Override
public void cleanAll(List<Integer> ids) {
for (Integer id:ids){
PackingLibrary packingLibrary = getOne(id);
packingLibrary.setDeleteTag(1);
update(packingLibrary);
//添加列装日志
PackingLog packingLog = new PackingLog();
packingLog.setRemark("回收站清空列装");
packingLog.setPackingId(id);
packingLogService.add(packingLog);
List<DeviceLibrary> deviceLibraries = deviceLibraryDao.findAllByPackingIdIn(ids);
// Map<String,String> map = new HashMap<>();
if (deviceLibraries.size()>0){
// map.put("error","该列装目录下存在装备,不能被删除");
throw new ApiException("该列装目录下存在装备,不能被删除");
}else {
for (Integer id:ids){
PackingLibrary packingLibrary = getOne(id);
packingLibrary.setDeleteTag(1);
update(packingLibrary);
//添加列装日志
PackingLog packingLog = new PackingLog();
packingLog.setRemark("回收站清空列装");
packingLog.setPackingId(id);
packingLogService.add(packingLog);
}
//发送阅知信息
List<Integer> userIds = userPublicService.findOtherUser(userUtils.getCurrentUserId());
MessageBto messageBto = new MessageBto(0,1,"回收站清空列装",userIds,0);
messageBto.setRecord(StringSplitUtil.idListToString(ids));
messageService.add(messageBto);
}
//发送阅知信息
List<Integer> userIds = userPublicService.findOtherUser(userUtils.getCurrentUserId());
MessageBto messageBto = new MessageBto(0,1,"回收站清空列装",userIds,0);
messageBto.setRecord(StringSplitUtil.idListToString(ids));
messageService.add(messageBto);
}
/**
......@@ -771,6 +842,11 @@ public class PackingLibraryServiceImpl implements PackingLibraryService {
DeviceModelSort.mapModelSort=map;
}
@Override
public List<PackingLibrary> findByParentId(Integer parentId) {
return packingLibraryDao.findAllByPartParentId(parentId);
}
private Specification<PackingLibrary> getSelectSpecification(PackingLibrarySelectVo packingLibrarySelectVo) {
PredicateBuilder<PackingLibrary> predicateBuilder = Specifications.and();
Integer level = userUtils.getCurrentUnitLevel();
......
......@@ -39,6 +39,9 @@ public class PackingLibraryUpdateVo {
@ApiModelProperty(value = "配用范围", example = "1")
private Integer matchingRange;
@ApiModelProperty(value = "配用范围", example = "1")
private String matchingRangeName;
@NotNull(message = "invisibleRange不能为空")
@ApiModelProperty(value = "可见范围", example = "1")
private Integer invisibleRange;
......
......@@ -126,6 +126,16 @@ public class DeviceRetiredController {
d -> Optional.ofNullable(nodeCollect.get(d.getPartParentId())),
DeviceRetiredResultVo::addChildNode
);
// List<DeviceLibrary> deviceLibraryList = deviceLibraryService.findAllByModel(canRetiredDeviceSelectVo.getModel());
// if (deviceLibraryList.size()>0){
// //判断装备是否都在中办
// boolean allMatch = deviceLibraryList.stream().allMatch(deviceLibrary -> deviceLibrary.getLocationUnit().contains("中办"));
// if (allMatch){
// //
// containList.add()
// }
// }
//过滤出目录下面为空的目录
List<DeviceRetiredResultVo> finalContainList = containList.stream().filter(deviceRetiredResultVo -> deviceRetiredResultVo.getChilds() != null && deviceRetiredResultVo.getChilds().size() != 0).collect(Collectors.toList());
//分页
......@@ -339,12 +349,15 @@ public class DeviceRetiredController {
/**
* 筛选出可以退装的父子装备(父的所有子数量都为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))
.filter(deviceRetiredResultVo ->
deviceRetiredResultVo.getCount()==0&&(deviceRetiredResultVo.getPartParentId()==null
||map.get(deviceRetiredResultVo.getPartParentId())==null))
.collect(Collectors.toList());
deviceRetiredResultVoList.addAll(retiredResultVos);
if (retiredResultVos.size()>0) {
......
......@@ -642,7 +642,6 @@ public class TaskServiceImpl implements TaskService {
.filter(taskUserVo -> !Collections.disjoint(idLists, taskUserVo.getInvolveUserIdList())||(taskUserVo.getCreateUserId()!=null&&idLists.contains(taskUserVo.getCreateUserId())))
.collect(Collectors.toList());
}
if (taskSelectVo.getAreaId()!=null){
List<Integer> ids = areaService.findIdQuerySubordinateIds(taskSelectVo.getAreaId());
List<Integer> unitIds = unitsDao.findAllByAreaIdIn(ids).stream().map(Units::getUnitId).collect(Collectors.toList());
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论