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

更新

上级 883e72ea
......@@ -8,7 +8,17 @@
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<dependencies>
<dependency>
<groupId>com.tykj.dev</groupId>
<artifactId>device-task</artifactId>
</dependency>
<dependency>
<groupId>com.tykj.dev</groupId>
<artifactId>device-storage</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<artifactId>device-library</artifactId>
......
package com.tykj.dev.device.library;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @author zjm
* @version 1.0.0
* @ClassName userApp.java
* @Description TODO
* @createTime 2020年09月01日 14:32:00
*/
@SpringBootApplication(scanBasePackages={
"com.tykj.dev.*",
}
)
public class libraryApp {
public static void main(String[] args) {
SpringApplication.run(libraryApp.class, args);
}
}
package com.tykj.dev.device.library.repository;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.List;
/**
* @author dengdiyi
*/
@SuppressWarnings("SqlResolve")
public interface DeviceLibraryDao extends JpaRepository<DeviceLibrary,Integer>, JpaSpecificationExecutor<DeviceLibrary> {
List<DeviceLibrary> getAllByModel(String model);
List<DeviceLibrary> getAllByOwnUnit(String unit);
/**
* 根据装备型号与装备所在地(多个地区)查询装备数量
* @param model 装备型号
* @param locations 装备所在地列表
* @return 装备数量
*/
int countByModelAndLocationUnitContains(String model, List<String> locations);
/**
* 根据装备型号与装备所在地(一个地区)查询装备数量
* @param model 装备型号
* @param location 装备所在地
* @return 装备数量
*/
int countByModelAndLocationUnit(String model, String location);
List<DeviceLibrary> getAllByPartParentIdAndIsPart(Integer parentId,Integer isPart);
List<DeviceLibrary> getAllByRfidCardId(String rfidCardId);
@Query(nativeQuery = true ,value= "select * from device_library where id in :idList")
List<DeviceLibrary> getDeviceLibraryEntitiesByIdIn(@Param("idList")List<Integer> idList);
List<DeviceLibrary> getAllByRfidSurfaceId(String rfid);
}
package com.tykj.dev.device.library.service;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.library.subject.vo.DeviceLibrarySelectVo;
import com.tykj.dev.device.task.subject.vo.BussinessLogVo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.List;
/**
* @author dengdiyi
*/
public interface DeviceLibraryService {
DeviceLibrary addEntity(DeviceLibrary deviceLibraryEntity);
List<DeviceLibrary> addEntityList(List<DeviceLibrary> list);
Page<DeviceLibrary> getPage(DeviceLibrarySelectVo deviceLibrarySelectVo, Pageable pageable);
Page<DeviceLibrary> getTagPage(DeviceLibrarySelectVo deviceLibrarySelectVo, Pageable pageable);
List<DeviceLibrary> getAllotPage(DeviceLibrarySelectVo deviceLibrarySelectVo);
Page<DeviceLibrary> getCoreDevicePage(DeviceLibrarySelectVo deviceLibrarySelectVo, Pageable pageable);
// Page<DeviceLibrary> getDeviceStatisticsPage(DeviceLibrarySelectVo deviceLibrarySelectVo, Pageable pageable);
List<String> getAllName();
List<BussinessLogVo> getDeviceLog(Integer id);
List<DeviceLibrary> getList(DeviceLibrarySelectVo deviceLibrarySelectVo);
List<DeviceLibrary> getAllList(DeviceLibrarySelectVo deviceLibrarySelectVo);
List<DeviceLibrary> getCheckList();
List<DeviceLibrary> getAllotList(DeviceLibrarySelectVo deviceLibrarySelectVo);
List<DeviceLibrary> getListByBillId(Integer id);
DeviceLibrary update(DeviceLibrary deviceLibraryEntity);
DeviceLibrary getOne(Integer id);
void delete(Integer id);
List<DeviceLibrary> getListWithoutParent(DeviceLibrarySelectVo deviceLibrarySelectVo);
List<String> getAllUnit();
}
package com.tykj.dev.device.library.service.impl;
import com.github.wenhao.jpa.PredicateBuilder;
import com.github.wenhao.jpa.Specifications;
import com.tykj.dev.device.library.repository.DeviceLibraryDao;
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.storage.subject.domin.StorageBill;
import com.tykj.dev.device.task.subject.vo.BussinessLogVo;
import com.tykj.dev.device.user.subject.service.UserPublicService;
import com.tykj.dev.device.user.util.UserUtils;
import com.tykj.dev.misc.exception.ApiException;
import com.tykj.dev.misc.utils.GetTreeUtils;
import com.tykj.dev.misc.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import javax.persistence.Column;
import java.lang.reflect.Field;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author dengdiyi
*/
@Service
public class DeviceLibraryServiceImpl implements DeviceLibraryService {
@Autowired
private DeviceLibraryDao deviceLibraryDao;
@Autowired
UserUtils userUtils;
@Autowired
private UserPublicService userPublicService;
// @Autowired
// private StorageBillService storageBillService;
@Override
public DeviceLibrary addEntity(DeviceLibrary deviceLibraryEntity) {
return deviceLibraryDao.save(deviceLibraryEntity);
}
@Override
public List<DeviceLibrary> addEntityList(List<DeviceLibrary> list) {
return null;
}
@Override
public Page<DeviceLibrary> getPage(DeviceLibrarySelectVo deviceLibrarySelectVo, Pageable pageable) {
Specification<DeviceLibrary> selectSpecification = getSelectSpecification(deviceLibrarySelectVo);
return deviceLibraryDao.findAll(selectSpecification, pageable);
}
@Override
public Page<DeviceLibrary> getTagPage(DeviceLibrarySelectVo deviceLibrarySelectVo, Pageable pageable) {
Page<DeviceLibrary> page = deviceLibraryDao.findAll(getSelectSpecification7(deviceLibrarySelectVo),deviceLibrarySelectVo.getPageable());
// for (DeviceLibrary d:page.getContent()) {
// Integer storageBillId = d.getStorageBillId();
// Integer userAID = storageBillService.getOne(storageBillId).getReceiveUserAId();
// Integer userBID = storageBillService.getOne(storageBillId).getReceiveUserBId();
// String user = userPublicService.getOne(userAID).getName();
// String user2 = userPublicService.getOne(userBID).getName();
// d.setStorageProcessingUser(user);
// d.setStorageConfirmUser(user2);
// deviceLibraryDao.save(d);
// }
return page;
}
@Override
public List<DeviceLibrary> getAllotPage(DeviceLibrarySelectVo deviceLibrarySelectVo) {
return deviceLibraryDao.findAll(getAllotSelectSpecification(deviceLibrarySelectVo));
}
@Override
public Page<DeviceLibrary> getCoreDevicePage(DeviceLibrarySelectVo deviceLibrarySelectVo, Pageable pageable) {
Integer selectUnitId = deviceLibrarySelectVo.getUnitId();
Integer selectAreaId = deviceLibrarySelectVo.getAreaId();
if (selectAreaId==null) {
List<DeviceLibrary> libraryEntities;
if (selectUnitId==null) {
libraryEntities = getList2(deviceLibrarySelectVo);
}
else {
String unitName = userPublicService.findByUnitsToname(selectUnitId);
libraryEntities = getList3(deviceLibrarySelectVo,unitName);
}
List<DeviceLibrary> resultList = new ArrayList<>();
for (DeviceLibrary d:libraryEntities) {
resultList.add(d);
if (d.getChilds().size()>0){
resultList.addAll(d.getChilds());
}
}
if (resultList.size()<=deviceLibrarySelectVo.getSize()) {
return new PageImpl<>(resultList, pageable, resultList.size());
}
else {
Double d = Math.ceil(resultList.size()/deviceLibrarySelectVo.getSize().doubleValue());
int num = new Double(d).intValue();
if (deviceLibrarySelectVo.getPage()>=num){
return null;
}
else {
int index = deviceLibrarySelectVo.getPage()*deviceLibrarySelectVo.getSize();
if (deviceLibrarySelectVo.getPage()==num-1){
return new PageImpl<>(resultList.subList(index,resultList.size()), pageable, resultList.size());
}
return new PageImpl<>(resultList.subList(index,index+deviceLibrarySelectVo.getSize()), pageable, resultList.size());
}
}
}
else {
Integer selectLevel = userPublicService.getArea(selectAreaId).getType();
List<String> units = userPublicService.findAllUnitNameByAreaId(selectAreaId);
if (selectLevel==3||selectLevel==2){
List<DeviceLibrary> libraryEntities = deviceLibraryDao.findAll().stream().filter(deviceLibraryEntity -> units.contains(deviceLibraryEntity.getOwnUnit())).collect(Collectors.toList());
List<DeviceLibrary> resultList = new ArrayList<>();
for (DeviceLibrary d:libraryEntities) {
resultList.add(d);
if (d.getChilds().size()>0){
resultList.addAll(d.getChilds());
}
}
if (resultList.size()<=deviceLibrarySelectVo.getSize()) {
return new PageImpl<>(resultList, pageable, resultList.size());
}
else {
Double d = Math.ceil(resultList.size()/deviceLibrarySelectVo.getSize().doubleValue());
int num = new Double(d).intValue();
if (deviceLibrarySelectVo.getPage()>=num){
return null;
}
else {
int index = deviceLibrarySelectVo.getPage()*deviceLibrarySelectVo.getSize();
if (deviceLibrarySelectVo.getPage()==num-1){
return new PageImpl<>(resultList.subList(index,resultList.size()), pageable, resultList.size());
}
return new PageImpl<>(resultList.subList(index,index+deviceLibrarySelectVo.getSize()), pageable, resultList.size());
}
}
}
if (selectLevel==1){
List<DeviceLibrary> libraryEntities = deviceLibraryDao.findAll();
List<DeviceLibrary> resultList = new ArrayList<>();
for (DeviceLibrary d:libraryEntities) {
resultList.add(d);
if (d.getChilds().size()>0){
resultList.addAll(d.getChilds());
}
}
if (resultList.size()<=deviceLibrarySelectVo.getSize()) {
return new PageImpl<>(resultList, pageable, resultList.size());
}
else {
Double d = Math.ceil(resultList.size()/deviceLibrarySelectVo.getSize().doubleValue());
int num = new Double(d).intValue();
if (deviceLibrarySelectVo.getPage()>=num){
return null;
}
else {
int index = deviceLibrarySelectVo.getPage()*deviceLibrarySelectVo.getSize();
if (deviceLibrarySelectVo.getPage()==num-1){
return new PageImpl<>(resultList.subList(index,resultList.size()), pageable, resultList.size());
}
return new PageImpl<>(resultList.subList(index,index+deviceLibrarySelectVo.getSize()), pageable, resultList.size());
}
}
}
else{
throw new ApiException(ResultUtil.failed());
}
}
}
// @Override
// public Page<DeviceStatisticsVo> getDeviceStatisticsPage(DeviceLibrarySelectVo deviceLibrarySelectVo, Pageable pageable) {
// List<String> list = getAllModel();
// List<DeviceStatisticsVo> deviceStatisticsVos = new ArrayList<>();
// DeviceLibrarySelectVo d = new DeviceLibrarySelectVo();
// BeanUtils.copyProperties(deviceLibrarySelectVo,d);
// d.setSize(Integer.MAX_VALUE);
// List<DeviceLibrary> libraryEntities = getCoreDevicePage(d,d.getPageable()).getContent();
// if (libraryEntities.size()>0) {
// for (String model : list) {
// DeviceStatisticsVo deviceStatisticsVo = new DeviceStatisticsVo();
// deviceStatisticsVo.setModel(model);
// Integer num = 0;
// Integer inLibraryNum = 0;
// Integer repairNum = 0;
// Integer destoryNum = 0;
// Integer scrappedNum = 0;
// Integer allotNum = 0;
// Integer retiredNum = 0;
// Integer useNum = 0;
// for (DeviceLibrary d2 : libraryEntities) {
// if (d2.getModel().equals(model)) {
// deviceStatisticsVo.setName(d2.getName());
// num++;
// switch (d2.getLifeStatus()) {
// case 2:
// inLibraryNum++;
// break;
// case 3:
// allotNum++;
// break;
// case 4:
// repairNum++;
// break;
// case 5:
// scrappedNum++;
// break;
// case 6:
// allotNum++;
// break;
// case 12:
// retiredNum++;
// break;
// case 9:
// destoryNum++;
// break;
// case 10:
// destoryNum++;
// break;
// case 13:
// scrappedNum++;
// break;
// case 14:
// useNum++;
// break;
// default:
// break;
// }
// }
// }
// if (num > 0) {
// deviceStatisticsVo.setDeviceNumber(num);
// deviceStatisticsVo.setAllotNum(allotNum);
// deviceStatisticsVo.setInLibraryNum(inLibraryNum);
// deviceStatisticsVo.setRepairNum(repairNum);
// deviceStatisticsVo.setDestoryNum(destoryNum);
// deviceStatisticsVo.setScrappedNum(scrappedNum);
// deviceStatisticsVo.setRetiredNum(retiredNum);
// deviceStatisticsVo.setUseNum(useNum);
// deviceStatisticsVos.add(deviceStatisticsVo);
// }
//
// }
//
// if (deviceStatisticsVos.size() <= deviceLibrarySelectVo.getSize()) {
// return new PageImpl<>(deviceStatisticsVos, pageable, deviceStatisticsVos.size());
// } else {
// Double v = Math.ceil(deviceStatisticsVos.size() / deviceLibrarySelectVo.getSize().doubleValue());
// int value = new Double(v).intValue();
// if (deviceLibrarySelectVo.getPage() >= value) {
// return null;
// } else {
// int index = deviceLibrarySelectVo.getPage() * deviceLibrarySelectVo.getSize();
// if (deviceLibrarySelectVo.getPage() == value - 1) {
// return new PageImpl<>(deviceStatisticsVos.subList(index, deviceStatisticsVos.size()), pageable, deviceStatisticsVos.size());
// }
// return new PageImpl<>(deviceStatisticsVos.subList(index, index + deviceLibrarySelectVo.getSize()), pageable, deviceStatisticsVos.size());
// }
// }
// }
// return new PageImpl<>(deviceStatisticsVos, pageable, deviceStatisticsVos.size());
// }
@Override
public List<String> getAllName() {
List<DeviceLibrary> strings = deviceLibraryDao.findAll();
Set<String> s = new HashSet<>();
for (DeviceLibrary d:strings) {
s.add(d.getName());
}
return new ArrayList<>(s);
}
@Override
public List<BussinessLogVo> getDeviceLog(Integer id) {
return null;
}
@Override
public List<DeviceLibrary> getList(DeviceLibrarySelectVo deviceLibrarySelectVo) {
List<DeviceLibrary> deviceLibraryEntities = deviceLibraryDao.findAll(getSelectSpecification(deviceLibrarySelectVo));
Map<Integer, DeviceLibrary> nodeCollect =
deviceLibraryEntities.stream().collect(Collectors.toMap(DeviceLibrary::getId, deviceLibraryEntity -> deviceLibraryEntity));
List<DeviceLibrary> deviceLibraryEntities1 = GetTreeUtils.parseTreeFromDown(
deviceLibraryEntities,
DeviceLibrary::getId,
deviceLibraryEntity -> Optional.ofNullable(nodeCollect.get(deviceLibraryEntity.getPartParentId())),
DeviceLibrary::addChildNode
);
return deviceLibraryEntities1;
}
public List<DeviceLibrary> getList2(DeviceLibrarySelectVo deviceLibrarySelectVo) {
List<DeviceLibrary> deviceLibraryEntities = deviceLibraryDao.findAll(getSelectSpecification6(deviceLibrarySelectVo));
Map<Integer, DeviceLibrary> nodeCollect =
deviceLibraryEntities.stream().collect(Collectors.toMap(DeviceLibrary::getId, deviceLibraryEntity -> deviceLibraryEntity));
List<DeviceLibrary> deviceLibraryEntities1 = GetTreeUtils.parseTreeFromDown(
deviceLibraryEntities,
DeviceLibrary::getId,
deviceLibraryEntity -> Optional.ofNullable(nodeCollect.get(deviceLibraryEntity.getPartParentId())),
DeviceLibrary::addChildNode
);
return deviceLibraryEntities1;
}
public List<DeviceLibrary> getList3(DeviceLibrarySelectVo deviceLibrarySelectVo,String name) {
List<DeviceLibrary> deviceLibraryEntities = deviceLibraryDao.findAll(getSelectSpecification2(deviceLibrarySelectVo,name));
Map<Integer, DeviceLibrary> nodeCollect =
deviceLibraryEntities.stream().collect(Collectors.toMap(DeviceLibrary::getId, deviceLibraryEntity -> deviceLibraryEntity));
List<DeviceLibrary> deviceLibraryEntities1 = GetTreeUtils.parseTreeFromDown(
deviceLibraryEntities,
DeviceLibrary::getId,
deviceLibraryEntity -> Optional.ofNullable(nodeCollect.get(deviceLibraryEntity.getPartParentId())),
DeviceLibrary::addChildNode
);
return deviceLibraryEntities1;
}
@Override
public List<DeviceLibrary> getListWithoutParent(DeviceLibrarySelectVo deviceLibrarySelectVo) {
List<DeviceLibrary> deviceLibraryEntities = deviceLibraryDao.findAll(getSelectSpecification(deviceLibrarySelectVo));
return deviceLibraryEntities;
}
@Override
public List<String> getAllUnit() {
List<DeviceLibrary> strings = deviceLibraryDao.findAll();
Set<String> s = new HashSet<>();
for (DeviceLibrary d:strings) {
s.add(d.getOwnUnit());
}
return new ArrayList<>(s);
}
@Override
public List<DeviceLibrary> getAllList(DeviceLibrarySelectVo deviceLibrarySelectVo) {
return deviceLibraryDao.findAll(getSelectSpecification4(deviceLibrarySelectVo));
}
@Override
public List<DeviceLibrary> getCheckList() {
PredicateBuilder<DeviceLibrary> predicateBuilder = Specifications.and();
predicateBuilder.eq("ownUnit",userUtils.getCurrentUserUnitName());
predicateBuilder.eq("lifeStatus",2);
return deviceLibraryDao.findAll(predicateBuilder.build());
}
@Override
public List<DeviceLibrary> getAllotList(DeviceLibrarySelectVo deviceLibrarySelectVo) {
List<DeviceLibrary> deviceLibraryEntities = deviceLibraryDao.findAll(getAllotSelectSpecification(deviceLibrarySelectVo));
Map<Integer, DeviceLibrary> nodeCollect =
deviceLibraryEntities.stream().collect(Collectors.toMap(DeviceLibrary::getId, deviceLibraryEntity -> deviceLibraryEntity));
List<DeviceLibrary> deviceLibraryEntities1 = GetTreeUtils.parseTreeFromDown(
deviceLibraryEntities,
DeviceLibrary::getId,
deviceLibraryEntity -> Optional.ofNullable(nodeCollect.get(deviceLibraryEntity.getPartParentId())),
DeviceLibrary::addChildNode
);
return deviceLibraryEntities1;
}
@Override
public List<DeviceLibrary> getListByBillId(Integer id) {
PredicateBuilder<DeviceLibrary> predicateBuilder = Specifications.and();
predicateBuilder.eq("storageBillId",id);
return deviceLibraryDao.findAll(predicateBuilder.build());
}
@Override
public DeviceLibrary update(DeviceLibrary deviceLibraryEntity) {
return deviceLibraryDao.save(deviceLibraryEntity);
}
@Override
public DeviceLibrary getOne(Integer id) {
Optional<DeviceLibrary> deviceLibraryEntity = deviceLibraryDao.findById(id);
return deviceLibraryEntity.orElse(null);
}
@Override
public void delete(Integer id) {
deviceLibraryDao.deleteById(id);
}
private Specification<DeviceLibrary> getSelectSpecification(DeviceLibrarySelectVo deviceLibrarySelectVo){
PredicateBuilder<DeviceLibrary> predicateBuilder = getPredicateBuilder(deviceLibrarySelectVo);
if (deviceLibrarySelectVo.getUnitId()==null){
String unit = userUtils.getCurrentUserUnitName();
predicateBuilder.eq("ownUnit",unit);
}
else {
String unit = userPublicService.findByUnitsToname(deviceLibrarySelectVo.getUnitId());
predicateBuilder.eq("ownUnit",unit);
}
return predicateBuilder.build();
}
private Specification<DeviceLibrary> getSelectSpecification2(DeviceLibrarySelectVo deviceLibrarySelectVo,String name){
PredicateBuilder<DeviceLibrary> predicateBuilder = getPredicateBuilder(deviceLibrarySelectVo);
predicateBuilder.eq("ownUnit",name);
return predicateBuilder.build();
}
private Specification<DeviceLibrary> getSelectSpecification3(DeviceLibrarySelectVo deviceLibrarySelectVo){
PredicateBuilder<DeviceLibrary> predicateBuilder = getPredicateBuilder(deviceLibrarySelectVo);
String unit = userUtils.getCurrentUserUnitName();
predicateBuilder.eq("ownUnit",unit);
predicateBuilder.eq("isPart",1);
return predicateBuilder.build();
}
private Specification<DeviceLibrary> getSelectSpecification4(DeviceLibrarySelectVo deviceLibrarySelectVo){
PredicateBuilder<DeviceLibrary> predicateBuilder = getPredicateBuilder(deviceLibrarySelectVo);
return predicateBuilder.build();
}
private Specification<DeviceLibrary> getSelectSpecification5(DeviceLibrarySelectVo deviceLibrarySelectVo){
PredicateBuilder<DeviceLibrary> predicateBuilder = getPredicateBuilder(deviceLibrarySelectVo);
predicateBuilder.eq("isPart",1);
return predicateBuilder.build();
}
private Specification<DeviceLibrary> getSelectSpecification6(DeviceLibrarySelectVo deviceLibrarySelectVo){
PredicateBuilder<DeviceLibrary> predicateBuilder = getPredicateBuilder(deviceLibrarySelectVo);
if (deviceLibrarySelectVo.getUnitId()==null){
String unit = userUtils.getCurrentUserUnitName();
predicateBuilder.eq("ownUnit",unit);
}
return predicateBuilder.build();
}
private Specification<DeviceLibrary> getSelectSpecification7(DeviceLibrarySelectVo deviceLibrarySelectVo){
PredicateBuilder<DeviceLibrary> predicateBuilder = getPredicateBuilder(deviceLibrarySelectVo);
PredicateBuilder<StorageBill> p = Specifications.and();
if (deviceLibrarySelectVo.getUserAId()!=null){
p.eq("receiveUserAId",deviceLibrarySelectVo.getUserAId());
}
if (deviceLibrarySelectVo.getUserBId()!=null){
p.eq("receiveUserBId",deviceLibrarySelectVo.getUserBId());
}
predicateBuilder.predicate(p.build());
return predicateBuilder.build();
}
private Specification<DeviceLibrary> getAllotSelectSpecification(DeviceLibrarySelectVo deviceLibrarySelectVo){
PredicateBuilder<DeviceLibrary> predicateBuilder = getPredicateBuilder(deviceLibrarySelectVo);
String unit = userUtils.getCurrentUserUnitName();
predicateBuilder.eq("ownUnit",unit);
predicateBuilder.eq("lifeStatus",2);
return predicateBuilder.build();
}
private Specification<DeviceLibrary> getStatisticsSelectSpecification(DeviceLibrarySelectVo deviceLibrarySelectVo){
PredicateBuilder<DeviceLibrary> predicateBuilder = getPredicateBuilder(deviceLibrarySelectVo);
String unit = userUtils.getCurrentUserUnitName();
return predicateBuilder.build();
}
private PredicateBuilder<DeviceLibrary> getPredicateBuilder(DeviceLibrarySelectVo deviceLibrarySelectVo){
PredicateBuilder<DeviceLibrary> predicateBuilder = Specifications.and();
if (deviceLibrarySelectVo!=null) {
if (deviceLibrarySelectVo.getModel()!=null){
predicateBuilder.eq("model",deviceLibrarySelectVo.getModel());
}
if (deviceLibrarySelectVo.getName()!=null){
predicateBuilder.eq("name",deviceLibrarySelectVo.getName());
}
if (deviceLibrarySelectVo.getSecretLevel()!=null){
predicateBuilder.eq("secretLevel",deviceLibrarySelectVo.getSecretLevel());
}
if (deviceLibrarySelectVo.getMatchingRange()!=null){
predicateBuilder.eq("matchingRange",deviceLibrarySelectVo.getMatchingRange());
}
if (deviceLibrarySelectVo.getStorageType()!=null){
predicateBuilder.eq("storageType",deviceLibrarySelectVo.getStorageType());
}
if (deviceLibrarySelectVo.getManageStatus()!=null){
predicateBuilder.eq("manageStatus",deviceLibrarySelectVo.getManageStatus());
}
if (deviceLibrarySelectVo.getLifeStatus()!=null){
predicateBuilder.in("lifeStatus",deviceLibrarySelectVo.getLifeStatus().toArray(new Integer[]{}));
}
if (deviceLibrarySelectVo.getType()!=null){
predicateBuilder.eq("type",deviceLibrarySelectVo.getType());
}
if (deviceLibrarySelectVo.getInvisibleRange()!=null){
predicateBuilder.eq("invisibleRange",deviceLibrarySelectVo.getInvisibleRange());
}
if (deviceLibrarySelectVo.getInvisibleRange()!=null){
predicateBuilder.eq("locationUnit",deviceLibrarySelectVo.getLocationUnit());
}
if (deviceLibrarySelectVo.getRfidCardId()!=null){
predicateBuilder.eq("rfidCardId",deviceLibrarySelectVo.getRfidCardId());
}
if (deviceLibrarySelectVo.getContent() != null) {
Class<DeviceLibrary> deviceLibraryEntity = DeviceLibrary.class;
Field[] declaredFields = deviceLibraryEntity.getDeclaredFields();
PredicateBuilder<DeviceLibrary> p = Specifications.or();
for (Field field : declaredFields) {
if (field.getType().equals(String.class)&&field.getAnnotation(Column.class)!=null) {
p.like(field.getName(), "%" + deviceLibrarySelectVo.getContent() + "%");
}
}
predicateBuilder.predicate(p.build());
}
if (deviceLibrarySelectVo.getStartTime() != null) {
predicateBuilder.gt("createTime", deviceLibrarySelectVo.getStartTime());
}
if (deviceLibrarySelectVo.getEndTime() != null) {
predicateBuilder.lt("updateTime", deviceLibrarySelectVo.getEndTime());
}
}
return predicateBuilder;
}
private List<String> getAllModel() {
List<DeviceLibrary> strings = deviceLibraryDao.findAll();
Set<String> s = new HashSet<>();
for (DeviceLibrary d:strings) {
s.add(d.getModel());
}
return new ArrayList<>(s);
}
}
package com.tykj.dev.device.library.subject.domin;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
/**
* entity class for device_library
* 装备库
*/
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@SQLDelete(sql = "update device_library set delete_tag = 1 where id = ?")
@Where(clause = "delete_tag = 0")
@ApiModel("装备库")
public class DeviceLibrary {
/**
* 主键id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty(name = "主键id")
private Integer id;
/**
* 入库单id
*/
@ApiModelProperty(value = "入库单id")
private Integer storageBillId;
/**
* 列装id
*/
@ApiModelProperty(value = "列装id")
private Integer packingId;
/**
* 是不是配件(0:不是,1:是)
*/
@ApiModelProperty(value = "是不是配件(0:不是,1:是)")
private Integer isPart;
/**
* 配件对应装备id
*/
@ApiModelProperty(value = "配件对应装备id")
private Integer partParentId;
/**
* 型号
*/
@ApiModelProperty(value = "型号")
private String model;
/**
* 密级
*/
@ApiModelProperty(value = "密级")
private Integer secretLevel;
/**
* 装备名称
*/
@ApiModelProperty(value = "装备名称")
private String name;
/**
* 装备序列号
*/
@ApiModelProperty(value = "装备序列号")
private String seqNumber;
/**
* 生产序列号
*/
@ApiModelProperty(value = "生产序列号")
private String prodNumber;
/**
* rfid表面号
*/
@ApiModelProperty(value = "rfid表面号")
private String rfidSurfaceId;
/**
* rfid卡号
*/
@ApiModelProperty(value = "rfid卡号")
private String rfidCardId;
/**
* 所在单位
*/
@ApiModelProperty(value = "所在单位")
private String locationUnit;
/**
* 所属单位
*/
@ApiModelProperty(value = "所属单位")
private String ownUnit;
/**
* 配用范围,1-省对下纵向
*/
@ApiModelProperty(value = "配用范围,1-省对下纵向")
private Integer matchingRange;
/**
* 可见范围
*/
@ApiModelProperty(value = "可见范围")
private Integer invisibleRange;
/**
* 类型
*/
@ApiModelProperty(value = "类型")
private Integer type;
/**
* 入库类型,1-横向,2-纵向
*/
@ApiModelProperty(value = "入库类型,1-横向,2-纵向")
private Integer storageType;
/**
* 管理状态,0-不再所属单位,1-在所属单位
*/
@ApiModelProperty(value = "管理状态,0-不再所属单位,1-在所属单位")
private Integer manageStatus;
/**
* 生命状态,0-入库待审核,1-入库审核失败,2-在库,3-配发,4-维修,5,维修失败,6-退回,7-待退装,8-退装,9-待销毁,10-已销毁,11-丢失
*/
@ApiModelProperty(value = "生命状态,0-入库待审核,1-入库审核失败,2-在库,3-配发,4-维修,5,维修失败,6-退回,7-待退装,8-退装,9-待销毁,10-已销毁,11-丢失")
private Integer lifeStatus;
/**
* 锁定状态,0-未锁定可用,1-锁定不可用
*/
@ApiModelProperty(value = "锁定状态,0-未锁定可用,1-锁定不可用")
private Integer lockStatus = 0;
/**
* 创建用户id
*/
@CreatedBy
@ApiModelProperty(value = "创建用户id")
private Integer createUserId;
/**
* 创建时间
*/
@CreatedDate
@ApiModelProperty(value = "创建时间")
private java.util.Date createTime;
/**
* 更新用户id
*/
@LastModifiedBy
@ApiModelProperty(value = "更新用户id")
private Integer updateUserId;
/**
* 更新时间
*/
@LastModifiedDate
@ApiModelProperty(value = "更新时间")
private java.util.Date updateTime;
/**
* 删除标记(0:未删除,1:已删除)
*/
@ApiModelProperty(value = "删除标记(0:未删除,1:已删除)")
private Integer deleteTag = 0;
@ApiModelProperty(value = "入库操作人")
@Transient
private String storageProcessingUser;
@ApiModelProperty(value = "入库审核人")
@Transient
private String storageConfirmUser;
@ApiModelProperty(value = "从属于")
@Transient
private String parentDevice;
/**
* 检查结果(0:丢失,1:无误,2:新增)
*/
@ApiModelProperty(value = "检查结果(0:丢失,1:无误,2:新增)")
@Transient
private Integer checkResult;
@Transient
private List<DeviceLibrary> childs = new ArrayList<>();
public void addChildNode(DeviceLibrary deviceLibraryEntity) {
childs.add(deviceLibraryEntity);
}
}
package com.tykj.dev.device.library.subject.domin;
import com.tykj.dev.device.task.subject.vo.FileVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.util.Date;
import java.util.List;
/**
* entity class for device_log
* 设备履历日志
*/
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@SQLDelete(sql = "update device_log set delete_tag = 1 where id = ?")
@Where(clause = "delete_tag = 0")
@ApiModel("设备履历日志")
public class DeviceLog {
/**
* 主键id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty(name = "主键id")
private Integer id;
/**
* 日志类型(默认0为装备日志,1为设备日志)
*/
@ApiModelProperty(value = "日志类型(默认0为装备日志,1为设备日志)")
private Integer type = 0;
/**
* 装备id
*/
@ApiModelProperty(value = "装备id")
private Integer deviceId;
/**
* 操作人主键id
*/
@ApiModelProperty(value = "操作人主键id")
private Integer userId;
/**
* 操作时间
*/
@ApiModelProperty(value = "操作时间")
private Date logTime;
/**
* 操作描述
*/
@ApiModelProperty(value = "操作描述")
private String remark;
/**
* 相关附件信息(Ǵ作为每个附件分隔符,Ǒ作为附件内部分隔符,例如name1Ǒurl1Ǒ配发单Ǵname2Ǒurl2Ǒ入库确认单Ǵ)
*/
@ApiModelProperty(value = "相关附件信息(Ǵ作为每个附件分隔符,Ǒ作为附件内部分隔符,例如name1Ǒurl1Ǒ配发单Ǵname2Ǒurl2Ǒ入库确认单Ǵ)")
private String fileDetail;
/**
* 创建用户id
*/
@ApiModelProperty(value = "创建用户id")
@CreatedBy
private Integer createUserId;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间")
@CreatedDate
private Date createTime;
/**
* 更新用户id
*/
@ApiModelProperty(value = "更新用户id")
@LastModifiedBy
private Integer updateUserId;
/**
* 更新时间
*/
@ApiModelProperty(value = "更新时间")
@LastModifiedDate
private Date updateTime;
/**
* 删除标记(0:未删除,1:已删除)
*/
@ApiModelProperty(value = "删除标记(0:未删除,1:已删除)")
private Integer deleteTag = 0;
@ApiModelProperty(value = "操作用户")
@Transient
private String user;
@ApiModelProperty(value = "操作单位")
@Transient
private String unit;
@ApiModelProperty(value = "附件信息")
@Transient
private List<FileVo> fileVoList;
}
package com.tykj.dev.device.library.subject.domin;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.util.Date;
/**
* entity class for device_use_report
* 装备使用报告
*/
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@SQLDelete(sql = "update device_use_report set delete_tag = 1 where id = ?")
@Where(clause = "delete_tag = 0")
@ApiModel("装备使用报告")
public class DeviceUseReport {
/**
* 主键id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty(name = "主键id")
private Integer id;
/**
* 报告标题
*/
@ApiModelProperty(value = "报告标题")
private String title;
/**
* 报告所属单位
*/
@ApiModelProperty(value = "报告所属单位")
private String unit;
/**
* 报告详情(入库数x退回数x退装数x维修数x销毁数x配发数x列装数)
*/
@ApiModelProperty(value = "报告详情(入库数x退回数x退装数x维修数x销毁数x配发数x列装数)")
private String reportDetail;
/**
* 创建用户id
*/
@CreatedBy
@ApiModelProperty(value = "创建用户id")
private Integer createUserId;
/**
* 创建时间
*/
@CreatedDate
@ApiModelProperty(value = "创建时间")
private Date createTime;
/**
* 更新用户id
*/
@LastModifiedBy
@ApiModelProperty(value = "更新用户id")
private Integer updateUserId;
/**
* 更新时间
*/
@LastModifiedDate
@ApiModelProperty(value = "更新时间")
private Date updateTime;
/**
* 删除标记(0:未删除,1:已删除)
*/
@ApiModelProperty(value = "删除标记(0:未删除,1:已删除)")
private Integer deleteTag = 0;
}
package com.tykj.dev.device.library.subject.vo;
import com.tykj.dev.misc.base.CustomPage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @author dengdiyi
*/
@Data
@ApiModel("装备查询类")
public class DeviceLibrarySelectVo extends CustomPage {
@ApiModelProperty(value = "操作人",example = "1")
public Integer UserAId;
@ApiModelProperty(value = "审核人",example = "1")
public Integer UserBId;
@ApiModelProperty(value = "型号",example = "bmxx")
public String model;
@ApiModelProperty(value = "类型",example = "1")
public Integer type;
@ApiModelProperty(value = "密级",example = "1")
public Integer secretLevel;
@ApiModelProperty(value = "可见范围(应用领域)",example = "1")
public Integer invisibleRange;
@ApiModelProperty(value = "名称",example = "BM-1")
public String name;
@ApiModelProperty(value = "配用范围",example = "1")
public Integer matchingRange;
@ApiModelProperty(value = "入库类型",example = "1")
public Integer storageType;
@ApiModelProperty(value = "管理状态",example = "1")
public Integer manageStatus;
@ApiModelProperty(value = "单位id",example = "1")
public Integer unitId;
@ApiModelProperty(value = "区域id",example = "1")
public Integer areaId;
@ApiModelProperty(value = "模糊查询内容",example = "测试")
public String content;
@ApiModelProperty(value = "发起时间",example = "2020-10-10 01:10:10")
public Date startTime;
@ApiModelProperty(value = "确认时间",example = "2020-10-10 01:10:10")
public Date endTime;
@ApiModelProperty(value = "装备状态",example = "1,2,3,4")
public List<Integer> lifeStatus;
@ApiModelProperty(value = "列装id")
private Integer packingId;
@ApiModelProperty(value = "所在单位")
private String locationUnit;
@ApiModelProperty(value = "所属单位")
private String ownUnit;
@ApiModelProperty(value = "rfid卡号")
private String rfidCardId;
}
......@@ -9,7 +9,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>device-stotage</artifactId>
<artifactId>device-storage</artifactId>
</project>
\ No newline at end of file
package com.tykj.dev.device.storage.repository;
import com.tykj.dev.device.storage.subject.domin.StorageBill;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @author dengdiyi
*/
public interface StorageBillDao extends JpaRepository<StorageBill, Integer>, JpaSpecificationExecutor<StorageBill> {
}
package com.tykj.dev.device.storage.service;
import com.tykj.dev.device.storage.subject.domin.StorageBill;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.List;
/**
* @author dengdiyi
*/
public interface StorageBillService {
StorageBill addEntity(StorageBill storageBillEntity);
Page<StorageBill> getPage(StorageBill storageBillEntity, Pageable pageable);
List<StorageBill> getList(StorageBill storageBillEntity);
StorageBill update(StorageBill storageBillEntity);
StorageBill getOne(Integer id);
void delete(Integer id);
}
package com.tykj.dev.device.storage.service.impl;
import com.tykj.dev.device.storage.repository.StorageBillDao;
import com.tykj.dev.device.storage.service.StorageBillService;
import com.tykj.dev.device.storage.subject.domin.StorageBill;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
/**
* @author dengdiyi
*/
@Service
public class StorageBillServiceImpl implements StorageBillService {
@Autowired
private StorageBillDao storageBillDao;
@Override
public StorageBill addEntity(StorageBill storageBillEntity) {
return storageBillDao.save(storageBillEntity);
}
@Override
public Page<StorageBill> getPage(StorageBill storageBillEntity, Pageable pageable) {
return null;
}
@Override
public List<StorageBill> getList(StorageBill storageBillEntity) {
return null;
}
@Override
public StorageBill update(StorageBill storageBillEntity) {
return storageBillDao.save(storageBillEntity);
}
@Override
public StorageBill getOne(Integer id) {
Optional<StorageBill> storageBillEntity = storageBillDao.findById(id);
return storageBillEntity.orElse(null);
}
@Override
public void delete(Integer id) {
storageBillDao.deleteById(id);
}
}
package com.tykj.dev.device.storage;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @author zjm
* @version 1.0.0
* @ClassName userApp.java
* @Description TODO
* @createTime 2020年09月01日 14:32:00
*/
@SpringBootApplication(scanBasePackages={
"com.tykj.dev.*",
}
)
public class storageApp {
public static void main(String[] args) {
SpringApplication.run(storageApp.class, args);
}
}
package com.tykj.dev.device.storage.subject.domin;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.util.Date;
/**
* entity class for storage_bill
* 入库账单
*/
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@SQLDelete(sql = "update storage_bill set delete_tag = 1 where id = ?")
@Where(clause = "delete_tag = 0")
@ApiModel("入库账单")
public class StorageBill {
/**
* 主键id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty(name = "主键id")
private Integer id;
/**
* 申请文号
*/
@ApiModelProperty(value = "申请文号")
private String applyNumber;
/**
* 批复文号
*/
@ApiModelProperty(value = "批复文号")
private String replayNumber;
/**
* 配发单位
*/
@ApiModelProperty(value = "配发单位")
private String sendUnit;
/**
* 配发时间
*/
@ApiModelProperty(value = "配发时间")
private Date sendTime;
/**
* 发件方id
*/
@ApiModelProperty(value = "发件方")
private String sendUserId;
/**
* 收件方id(A岗位)
*/
@ApiModelProperty(value = "收件方id(A岗位)")
private Integer receiveUseraId;
/**
* 收件方id(B岗位)
*/
@ApiModelProperty(value = "收件方id(B岗位)")
private Integer receiveUserbId;
/**
* 入库状态(0:待审核,1:审核失败,2:已入库)
*/
@ApiModelProperty(value = "入库状态(0:待审核,1:审核失败,2:已入库)")
private Integer storageStatus;
/**
* 账单文件地址URL
*/
@ApiModelProperty(value = "账单文件地址URL")
private String fileName;
/**
* 账单文件地址URL
*/
@ApiModelProperty(value = "账单文件地址URL")
private String fileUrl;
/**
* 入库附件文件名
*/
@ApiModelProperty(value = "入库附件文件名")
private String receiveFileName;
/**
* 入库附件文件地址URL
*/
@ApiModelProperty(value = "入库附件文件地址URL")
private String receiveFileUrl;
/**
* 待入库装备数量
*/
@ApiModelProperty(value = "待入库装备数量")
private Integer storagingCount;
/**
* 已入库装备数量
*/
@ApiModelProperty(value = "已入库装备数量")
private Integer storagedCount;
/**
* 入库详情(列装主键idx列装数量x装备主键id(字符,作为不同列装的分隔符)),例如1x2x3x4,2x1x5,意为列装库中id为1的入库2件(装备id分别为3,4),列装库中id为2的入库1件(装备id为5)
*/
@ApiModelProperty(value = "入库详情(装备主键id+核对结果(0缺失1无误2不匹配,字符x作为分隔符)),例如10x21x32,意为主键id为1的装备缺失,为2的无误,为3的不匹配")
private String storageDetail;
/**
* 创建用户id
*/
@CreatedBy
@ApiModelProperty(value = "创建用户id")
private Integer createUserId;
/**
* 创建时间
*/
@CreatedDate
@ApiModelProperty(value = "创建时间")
private java.sql.Timestamp createTime;
/**
* 更新用户id
*/
@LastModifiedBy
@ApiModelProperty(value = "更新用户id")
private Integer updateUserId;
/**
* 更新时间
*/
@LastModifiedDate
@ApiModelProperty(value = "更新时间")
private java.sql.Timestamp updateTime;
/**
* 删除标记(0:未删除,1:已删除)
*/
@ApiModelProperty(value = "删除标记(0:未删除,1:已删除)")
private Integer deleteTag = 0;
@ApiModelProperty(value = "经办人")
@Transient
private String receiveUserA;
@ApiModelProperty(value = "审核人")
@Transient
private String receiveUserB;
}
......@@ -30,7 +30,7 @@ public class TaskServiceImpl implements TaskService {
//status++
taskBto.setBillStatus(StatusMap.getHashMap().getOrDefault(taskBto.getBillStatus()+1, StatusEnum.END).id);
//list add 0,point++
taskBto.getInvoleUserIdList().add(0);
taskBto.getInvolveUserIdList().add(0);
taskBto.setCurrentPoint(taskBto.getCurrentPoint()+1);
//set readList empty
taskBto.setUserReadDetailList(Collections.emptyList());
......@@ -48,7 +48,7 @@ public class TaskServiceImpl implements TaskService {
//status++
taskBto.setBillStatus(StatusMap.getHashMap().getOrDefault(taskBto.getBillStatus()+1,StatusEnum.END).id);
//list add 0,point++
taskBto.getInvoleUserIdList().add(0);
taskBto.getInvolveUserIdList().add(0);
taskBto.setCurrentPoint(taskBto.getCurrentPoint()+1);
//set readList empty
taskBto.setUserReadDetailList(Collections.emptyList());
......@@ -67,7 +67,7 @@ public class TaskServiceImpl implements TaskService {
//status++
taskBto.setBillStatus(StatusMap.getHashMap().getOrDefault(taskBto.getBillStatus()+1,StatusEnum.END).id);
//list add userId,point++
taskBto.getInvoleUserIdList().add(userId);
taskBto.getInvolveUserIdList().add(userId);
taskBto.setCurrentPoint(taskBto.getCurrentPoint()+1);
//set readList empty
taskBto.setUserReadDetailList(Collections.emptyList());
......@@ -86,7 +86,7 @@ public class TaskServiceImpl implements TaskService {
//status++
taskBto.setBillStatus(StatusMap.getHashMap().getOrDefault(taskBto.getBillStatus()+1,StatusEnum.END).id);
//list add userId,point++
taskBto.getInvoleUserIdList().add(userId);
taskBto.getInvolveUserIdList().add(userId);
taskBto.setCurrentPoint(taskBto.getCurrentPoint()+1);
//set readList empty
taskBto.setUserReadDetailList(Collections.emptyList());
......@@ -105,7 +105,7 @@ public class TaskServiceImpl implements TaskService {
//status++
taskBto.setBillStatus(statusEnum.id);
//list add 0,point++
taskBto.getInvoleUserIdList().add(0);
taskBto.getInvolveUserIdList().add(0);
taskBto.setCurrentPoint(taskBto.getCurrentPoint()+1);
//set readList empty
taskBto.setUserReadDetailList(Collections.emptyList());
......@@ -124,7 +124,7 @@ public class TaskServiceImpl implements TaskService {
//status++
taskBto.setBillStatus(statusEnum.id);
//list add 0,point++
taskBto.getInvoleUserIdList().add(0);
taskBto.getInvolveUserIdList().add(0);
taskBto.setCurrentPoint(taskBto.getCurrentPoint()+1);
//set readList empty
taskBto.setUserReadDetailList(Collections.emptyList());
......@@ -144,7 +144,7 @@ public class TaskServiceImpl implements TaskService {
//status++
taskBto.setBillStatus(statusEnum.id);
//list add userId,point++
taskBto.getInvoleUserIdList().add(userId);
taskBto.getInvolveUserIdList().add(userId);
taskBto.setCurrentPoint(taskBto.getCurrentPoint()+1);
//set readList empty
taskBto.setUserReadDetailList(Collections.emptyList());
......@@ -164,7 +164,7 @@ public class TaskServiceImpl implements TaskService {
//status++
taskBto.setBillStatus(statusEnum.id);
//list add userId,point++
taskBto.getInvoleUserIdList().add(userId);
taskBto.getInvolveUserIdList().add(userId);
taskBto.setCurrentPoint(taskBto.getCurrentPoint()+1);
//set readList empty
taskBto.setUserReadDetailList(Collections.emptyList());
......
......@@ -44,7 +44,7 @@ public class TaskBto {
private Integer billId;
@ApiModelProperty(value = "业务类型主键id")
private Integer bussinessType;
private Integer businessType;
@ApiModelProperty(value = "所属单位")
private Integer ownUnit;
......@@ -62,7 +62,7 @@ public class TaskBto {
private List<Integer> userReadDetailList;
@ApiModelProperty(value = "工作涉及人员id")
private List<Integer> involeUserIdList;
private List<Integer> involveUserIdList;
/**
* bto类转化为do类
......@@ -71,7 +71,7 @@ public class TaskBto {
//复制相同属性
ModelMapper modelMapper = BeanHelper.getUserMapper();
Task task = modelMapper.map(this,Task.class);
task.setInvolveUsers(StringSplitUtil.idListToString(this.involeUserIdList));
task.setInvolveUsers(StringSplitUtil.idListToString(this.involveUserIdList));
task.setUserReadDetail(StringSplitUtil.idListToString(this.userReadDetailList));
task.setTopFlagDetail(StringSplitUtil.idListToString(this.topFlagDetailList));
return task;
......
......@@ -10,14 +10,14 @@ import java.util.stream.Collectors;
*/
public class StatusMap {
private static Map<Integer, StatusEnum> hashMap;
private static Map<Integer, StatusEnum> statusEnumMap;
static {
hashMap = Arrays.stream(StatusEnum.values())
statusEnumMap = Arrays.stream(StatusEnum.values())
.collect(Collectors.toMap(statusEnum -> statusEnum.id, Function.identity()));
}
public static Map<Integer, StatusEnum> getHashMap() {
return hashMap;
return statusEnumMap;
}
}
......@@ -75,7 +75,7 @@ public class Task {
private Integer deleteTag = 0;
@ApiModelProperty(value = "业务类型主键id")
private Integer bussinessType;
private Integer businessType;
@ApiModelProperty(value = "所属单位")
private Integer ownUnit;
......@@ -139,7 +139,7 @@ public class Task {
ModelMapper mapper = BeanHelper.getUserMapper();
TaskBto taskBto = mapper.map(this,TaskBto.class);
//解析组合字段并添加
taskBto.setInvoleUserIdList(StringSplitUtil.userIdSplit(this.involveUsers));
taskBto.setInvolveUserIdList(StringSplitUtil.userIdSplit(this.involveUsers));
taskBto.setTopFlagDetailList(StringSplitUtil.userIdSplit(this.topFlagDetail));
taskBto.setUserReadDetailList(StringSplitUtil.userIdSplit(this.userReadDetail));
return taskBto;
......
package com.tykj.dev.device.task.subject.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @author dengdiyi
*/
@Data
@ApiModel("业务详情/装备详情日志返回类")
public class BussinessLogVo {
@ApiModelProperty(value = "时间")
private Date time;
@ApiModelProperty(value = "单位")
private String unit;
@ApiModelProperty(value = "用户")
private String user;
@ApiModelProperty(value = "操作")
private String operation;
@ApiModelProperty(value = "单据列表")
private List<FileVo> fileVoList;
}
package com.tykj.dev.device.task.subject.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author dengdiyi
*/
@Data
@ApiModel("附件信息返回类")
public class FileVo {
@ApiModelProperty(value = "标题")
private String title;
@ApiModelProperty(value = "附件名")
private String fileName;
@ApiModelProperty(value = "附件url")
private String fileUrl;
}
......@@ -24,6 +24,7 @@
<module>device-task</module>
<module>device-train</module>
<module>device-user</module>
<module>device-storage</module>
</modules>
<name>device</name>
<description>Demo project for Spring Boot</description>
......@@ -156,6 +157,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.wenhao</groupId>
<artifactId>jpa-spec</artifactId>
<version>3.1.1</version>
</dependency>
</dependencies>
</project>
......@@ -6,7 +6,7 @@ import org.springframework.http.ResponseEntity;
* 全局错误处理类,用于处理一些不容易定义的错误
* @author HuangXiahao
**/
public class ApiException extends Exception {
public class ApiException extends RuntimeException {
private ResponseEntity responseEntity;
......
package com.tykj.dev.misc.utils;
import java.util.*;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author HuangXiahao
* @version V1.0
* @class getTreeUtils
* @packageName com.tykj.dev.device.utils
**/
public class GetTreeUtils {
/**
* 自底向上整理出树结构,并存放在Node对象中
* 利用Map将原始List的对象的位置重新整理,并将所有的指针都设置好
*
* @param originList 原始待整理的列表
* @param getId 列表里每个对象获取自身id的方法,用于避免重复计算
* @param getParent 列表里每个对象获取父对象的方法
* @param targetSetChild 用于最终对象设置子节点的方法,形如R.setChild(R),或者R.addChildList(R)
* @param <V> 原始对象
* @param <T> 主键类型
* @return 根节点对象集合
*/
public static <V, T extends Number> List<V> parseTreeFromDown(List<V> originList,
Function<V, T> getId,
Function<V, Optional<V>> getParent,
BiConsumer<V, V> targetSetChild) {
//K为主键id , Value 为最终对象
Map<T, V> map = new HashMap<>(32);
List<T> rootIds = new ArrayList<>();
for (V originNode : originList) {
//对于所有节点,如果已经遍历过了则直接取已经设置过子节点的引用
V targetNode = map.getOrDefault(getId.apply(originNode), originNode);
Optional<V> parentNode = getParent.apply(originNode);
//查询父节点,如果不存在父节点则证明该节点为根节点,直接放入map中
if (parentNode.isPresent()) {
//否则查询该父节点是否已经已经被连接过指针,如果连接过则取出连接过的继续连接,否则进行第一次连接并存入map
V parent = parentNode.get();
T parentId = getId.apply(parent);
V parentInMap = map.get(parentId);
if (parentInMap == null) {
targetSetChild.accept(parent, targetNode);
map.put(parentId, parent);
} else {
targetSetChild.accept(parentInMap, targetNode);
}
//连接完处理之后还需要将自身这个节点存入map
map.put(getId.apply(originNode), targetNode);
} else {
//root node
map.put(getId.apply(originNode), targetNode);
rootIds.add(getId.apply(originNode));
}
}
//根据rootIds返回所有的顶层节点
return rootIds.stream().map(map::get).collect(Collectors.toList());
}
}
......@@ -207,7 +207,7 @@
<dependency>
<groupId>com.tykj.dev</groupId>
<artifactId>device-stotage</artifactId>
<artifactId>device-storage</artifactId>
<version>1.0-SNAPSHOT</version>
<exclusions>
<exclusion>
......
......@@ -22,6 +22,7 @@
<module>dev-misc</module>
<module>dev-rfid</module>
<module>dev-union</module>
<module>device-storage</module>
</modules>
<properties>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论