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

更新业务查询

上级 89a22fd8
......@@ -16,14 +16,32 @@
<dependency>
<groupId>com.tykj.dev</groupId>
<artifactId>device-user</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-allot</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.tykj.dev</groupId>
<artifactId>device-library</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-allot</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.tykj.dev</groupId>
<artifactId>device-task</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-allot</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -14,18 +14,42 @@
<dependency>
<groupId>com.tykj.dev</groupId>
<artifactId>device-user</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-apply</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.tykj.dev</groupId>
<artifactId>device-task</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-apply</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.tykj.dev</groupId>
<artifactId>device-allot</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-apply</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.tykj.dev</groupId>
<artifactId>device-library</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-apply</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
......
......@@ -12,6 +12,12 @@
<dependency>
<groupId>com.tykj.dev</groupId>
<artifactId>device-user</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-library</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<artifactId>device-library</artifactId>
......
package com.tykj.dev.device.library.controller;
import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.device.library.repository.DeviceLibraryDao;
import com.tykj.dev.device.library.repository.DeviceLogDao;
import com.tykj.dev.device.library.service.DeviceLibraryService;
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.*;
import com.tykj.dev.misc.utils.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author dengdiyi
*/
@RestController
@RequestMapping(value = "/device")
@AutoDocument
@Api(tags = "装备管理模块",description = "装备管理接口")
public class DeviceLibraryController {
@Autowired
private DeviceLibraryService deviceLibraryService;
@Autowired
private DeviceLibraryDao deviceLibraryDao;
@Autowired
private DeviceLogDao deviceLogDao;
// @Autowired
// private PackingLibraryService packingLibraryService;
@ApiOperation(value = "模糊查询装备分页",notes = "可以通过这个接口查询装备")
@PostMapping("/selectDevicePage")
public ResponseEntity<Page<DeviceLibrary>> selectDevicePage(@RequestBody DeviceLibrarySelectVo deviceLibrarySelectVo){
Page<DeviceLibrary> deviceLibraryEntities = deviceLibraryService.getPage(deviceLibrarySelectVo, deviceLibrarySelectVo.getPageable());
return ResultUtil.success(deviceLibraryEntities);
}
@ApiOperation(value = "模糊查询装备列表",notes = "可以通过这个接口查询装备列表")
@PostMapping("/selectDeviceList")
public ResponseEntity<List<DeviceLibrary>> selectDeviceList(@RequestBody DeviceLibrarySelectVo deviceLibrarySelectVo){
List<DeviceLibrary> deviceLibraryEntities = deviceLibraryService.getList(deviceLibrarySelectVo);
return ResultUtil.success(deviceLibraryEntities);
}
@ApiOperation(value = "查询所有装备列表",notes = "可以通过这个接口查询所有装备列表")
@PostMapping("/selectAllDeviceList")
public ResponseEntity<List<DeviceLibrary>> selectAllDeviceList(@RequestBody DeviceLibrarySelectVo deviceLibrarySelectVo){
List<DeviceLibrary> deviceLibraryEntities = deviceLibraryService.getAllList(deviceLibrarySelectVo);
return ResultUtil.success(deviceLibraryEntities);
}
@ApiOperation(value = "查询检查装备列表",notes = "可以通过这个接口查询装备列表")
@GetMapping("/selectCheckDeviceList")
public ResponseEntity<List<DeviceLibrary>> selectDeviceList(){
List<DeviceLibrary> deviceLibraryEntities = deviceLibraryService.getCheckList();
return ResultUtil.success(deviceLibraryEntities);
}
@ApiOperation(value = "模糊查询可配发的在库装备列表",notes = "可以通过这个接口查询可配发装备")
@PostMapping("/selectAllotDeviceList")
public ResponseEntity<List<DeviceLibrary>> selectAllotDeviceList(@RequestBody DeviceLibrarySelectVo deviceLibrarySelectVo){
List<DeviceLibrary> deviceLibraryEntities = deviceLibraryService.getAllotList(deviceLibrarySelectVo);
return ResultUtil.success(deviceLibraryEntities);
}
@ApiOperation(value = "模糊查询核心装备分页",notes = "可以通过这个接口查询装备列表")
@PostMapping("/core/feature/summary")
public ResponseEntity<Page<DeviceLibrary>> selectCoreDevicePage(@RequestBody DeviceLibrarySelectVo deviceLibrarySelectVo){
Page<DeviceLibrary> deviceLibraryEntities = deviceLibraryService.getCoreDevicePage(deviceLibrarySelectVo,deviceLibrarySelectVo.getPageable());
return ResultUtil.success(deviceLibraryEntities);
}
@ApiOperation(value = "查询存在的装备名称",notes = "可以通过这个接口查询存在的装备名称")
@GetMapping("/selectAllName")
public ResponseEntity<List<String>> selectAllName(){
return ResultUtil.success(deviceLibraryService.getAllName());
}
@ApiOperation(value = "模糊查询标签管理装备分页",notes = "可以通过这个接口查询装备列表")
@PostMapping("/selectTagDevicePage")
public ResponseEntity<Page<DeviceLibrary>> selectTagDevicePage(@RequestBody DeviceLibrarySelectVo deviceLibrarySelectVo){
Page<DeviceLibrary> deviceLibraryEntities = deviceLibraryService.getTagPage(deviceLibrarySelectVo,deviceLibrarySelectVo.getPageable());
return ResultUtil.success(deviceLibraryEntities);
}
@ApiOperation(value = "模糊查询核心装备统计分页",notes = "可以通过这个接口查询装备列表")
@PostMapping("/core/stat/summary")
public ResponseEntity<Page<DeviceStatisticsVo>> getDeviceStatisticsPage(@RequestBody DeviceLibrarySelectVo deviceLibrarySelectVo){
Page<DeviceStatisticsVo> deviceStatisticsVos = deviceLibraryService.getDeviceStatisticsPage(deviceLibrarySelectVo,deviceLibrarySelectVo.getPageable());
return ResultUtil.success(deviceStatisticsVos);
}
@ApiOperation(value = "查询核心装备详情的详情",notes = "可以通过这个接口查询核心装备详情的详情")
@GetMapping("/core/feature/detail/{id}")
public ResponseEntity<DeviceDetailVo> getDeviceDetail(@PathVariable("id") int id){
DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(id);
DeviceDetailVo deviceDetailVo = new DeviceDetailVo();
List<DeviceLibrary> libraryEntities = new ArrayList<>();
//查询日志
List<DeviceLogUserVo> deviceLogEntities = orderByCreateTimeAsc(deviceLogDao.getAllByDeviceIdAndType(id,0).stream()
.map(DeviceLog::parse2Dto)
.map(DeviceLogDto::toVo)
.collect(Collectors.toList()));
libraryEntities.add(deviceLibraryEntity);
if (deviceLibraryEntity.getIsPart()==0){
List<DeviceLibrary> partList = deviceLibraryDao.getAllByPartParentIdAndIsPart(id,1);
libraryEntities.addAll(partList);
deviceDetailVo.setDeviceList(libraryEntities);
deviceDetailVo.setDeviceLogEntityList(deviceLogEntities);
// PackingLibrary p = packingLibraryService.getOne(deviceLibraryEntity.getPackingId());
// deviceDetailVo.setImageName(p.getImageName());
// deviceDetailVo.setImageUrl(p.getImageUrl());
return ResultUtil.success(deviceDetailVo);
}
else {
if (deviceLibraryEntity.getPartParentId()==null) {
deviceDetailVo.setDeviceList(libraryEntities);
deviceDetailVo.setDeviceLogEntityList(deviceLogEntities);
return ResultUtil.success(deviceDetailVo);
}
libraryEntities.add(deviceLibraryService.getOne(deviceLibraryEntity.getPartParentId()));
deviceDetailVo.setDeviceList(libraryEntities);
deviceDetailVo.setDeviceLogEntityList(deviceLogEntities);
return ResultUtil.success(deviceDetailVo);
}
}
@ApiOperation(value = "更新装备库",notes = "可以通过这个接口更新装备库")
@PostMapping("/updateDeviceLibrary")
public ResponseEntity<String> updateDeviceLibrary(@RequestBody DeviceEditVo deviceEditVo) {
DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(deviceEditVo.getDeviceId());
if(deviceEditVo.getUpdateVoList()!=null) {
DeviceLibraryUpdateVo libraryUpdateVo = deviceEditVo.getUpdateVoList();
if (libraryUpdateVo.getInvisibleRange()!=null){
deviceLibraryEntity.setInvisibleRange(libraryUpdateVo.getInvisibleRange());
}
if (libraryUpdateVo.getLifeStatus()!=null){
deviceLibraryEntity.setLifeStatus(libraryUpdateVo.getLifeStatus());
}
if (libraryUpdateVo.getLocationUnit()!=null){
deviceLibraryEntity.setLocationUnit(libraryUpdateVo.getLocationUnit());
}
if (libraryUpdateVo.getManageStatus()!=null){
deviceLibraryEntity.setManageStatus(libraryUpdateVo.getManageStatus());
}
if (libraryUpdateVo.getMatchingRange()!=null){
deviceLibraryEntity.setMatchingRange(libraryUpdateVo.getMatchingRange());
}
if (libraryUpdateVo.getModel()!=null){
deviceLibraryEntity.setModel(libraryUpdateVo.getModel());
}
if (libraryUpdateVo.getName()!=null){
deviceLibraryEntity.setName(libraryUpdateVo.getName());
}
if (libraryUpdateVo.getOwnUnit()!=null){
deviceLibraryEntity.setOwnUnit(libraryUpdateVo.getOwnUnit());
}
if (libraryUpdateVo.getProdNumber()!=null){
deviceLibraryEntity.setProdNumber(libraryUpdateVo.getProdNumber());
}
if (libraryUpdateVo.getSecretLevel()!=null){
deviceLibraryEntity.setSecretLevel(libraryUpdateVo.getSecretLevel());
}
if (libraryUpdateVo.getSeqNumber()!=null){
deviceLibraryEntity.setSeqNumber(libraryUpdateVo.getSeqNumber());
}
if (libraryUpdateVo.getStorageType()!=null){
deviceLibraryEntity.setStorageType(libraryUpdateVo.getStorageType());
}
if (libraryUpdateVo.getType()!=null){
deviceLibraryEntity.setType(libraryUpdateVo.getType());
}
deviceLibraryService.update(deviceLibraryEntity);
}
if (deviceEditVo.getPartAddIdList()!=null){
for (Integer id:deviceEditVo.getPartAddIdList()) {
if (id>0) {
DeviceLibrary d = deviceLibraryService.getOne(id);
if (deviceLibraryEntity.getIsPart()==0&&d.getIsPart()==1&&d.getPartParentId()==null){
d.setPartParentId(deviceEditVo.getDeviceId());
deviceLibraryService.update(d);
}
if (deviceLibraryEntity.getIsPart()==1&&d.getIsPart()==0){
deviceLibraryEntity.setPartParentId(id);
deviceLibraryService.update(deviceLibraryEntity);
}
}
}
}
if (deviceEditVo.getPartIdDeleteList()!=null){
for (Integer id:deviceEditVo.getPartIdDeleteList()) {
if (id>0) {
DeviceLibrary d = deviceLibraryService.getOne(id);
if (d.getIsPart()==1&&d.getPartParentId().equals(deviceEditVo.getDeviceId())){
d.setPartParentId(null);
deviceLibraryService.update(d);
}
if (deviceLibraryEntity.getIsPart()==1&&d.getIsPart()==0&&deviceLibraryEntity.getPartParentId().equals(id)){
deviceLibraryEntity.setPartParentId(null);
deviceLibraryService.update(deviceLibraryEntity);
}
}
}
}
return ResultUtil.success("更新成功");
}
@ApiOperation(value = "通过表面号查询配件",notes = "通过表面号查询配件")
@GetMapping("/selectPart/{rfid}")
public ResponseEntity<List<DeviceLibrary>> selectPart(@PathVariable("rfid") String rfid){
List<DeviceLibrary> libraryEntities = deviceLibraryDao.getAllByRfidSurfaceId(rfid);
List<DeviceLibrary> deviceLibraryEntityList = libraryEntities.stream().filter(deviceLibraryEntity -> deviceLibraryEntity.getIsPart()==1).collect(Collectors.toList());
return ResultUtil.success(deviceLibraryEntityList);
}
@ApiOperation(value = "通过表面号查询装备",notes = "通过表面号查询装备")
@GetMapping("/selectDevice/{rfid}")
public ResponseEntity<List<DeviceLibrary>> selectDevice(@PathVariable("rfid") String rfid){
List<DeviceLibrary> libraryEntities = deviceLibraryDao.getAllByRfidSurfaceId(rfid);
List<DeviceLibrary> deviceLibraryEntityList = libraryEntities.stream().filter(deviceLibraryEntity -> deviceLibraryEntity.getIsPart()==0).collect(Collectors.toList());
return ResultUtil.success(deviceLibraryEntityList);
}
private List<DeviceLogUserVo> orderByCreateTimeAsc(List<DeviceLogUserVo> list){
Collections.sort(list, (o1, o2) -> {
int flag = o1.getCreateTime().compareTo(o2.getCreateTime());
return flag;
});
return list;
}
}
......@@ -2,6 +2,7 @@ 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.library.subject.vo.DeviceStatisticsVo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
......@@ -11,9 +12,8 @@ import java.util.List;
* @author dengdiyi
*/
public interface DeviceLibraryService {
DeviceLibrary addEntity(DeviceLibrary deviceLibraryEntity);
List<DeviceLibrary> addEntityList(List<DeviceLibrary> list);
DeviceLibrary addEntity(DeviceLibrary deviceLibraryEntity);
Page<DeviceLibrary> getPage(DeviceLibrarySelectVo deviceLibrarySelectVo, Pageable pageable);
......@@ -23,7 +23,7 @@ public interface DeviceLibraryService {
Page<DeviceLibrary> getCoreDevicePage(DeviceLibrarySelectVo deviceLibrarySelectVo, Pageable pageable);
// Page<DeviceLibrary> getDeviceStatisticsPage(DeviceLibrarySelectVo deviceLibrarySelectVo, Pageable pageable);
Page<DeviceStatisticsVo> getDeviceStatisticsPage(DeviceLibrarySelectVo deviceLibrarySelectVo, Pageable pageable);
List<String> getAllName();
......
......@@ -6,11 +6,14 @@ 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.library.subject.vo.DeviceStatisticsVo;
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.PageUtil;
import com.tykj.dev.misc.utils.ResultUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
......@@ -38,19 +41,11 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
@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);
......@@ -87,23 +82,7 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
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());
}
}
return PageUtil.getPerPage(deviceLibrarySelectVo.getPage(),deviceLibrarySelectVo.getSize(),resultList,pageable);
}
else {
Integer selectLevel = userPublicService.getArea(selectAreaId).getType();
......@@ -117,23 +96,7 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
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());
}
}
return PageUtil.getPerPage(deviceLibrarySelectVo.getPage(),deviceLibrarySelectVo.getSize(),resultList,pageable);
}
if (selectLevel==1){
List<DeviceLibrary> libraryEntities = deviceLibraryDao.findAll();
......@@ -144,23 +107,7 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
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());
}
}
return PageUtil.getPerPage(deviceLibrarySelectVo.getPage(),deviceLibrarySelectVo.getSize(),resultList,pageable);
}
else{
throw new ApiException(ResultUtil.failed());
......@@ -168,98 +115,83 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
}
}
// @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 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);
int num = 0;
int inLibraryNum = 0;
int repairNum = 0;
int destoryNum = 0;
int scrappedNum = 0;
int allotNum = 0;
int retiredNum = 0;
int 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);
}
}
return PageUtil.getPerPage(deviceLibrarySelectVo.getPage(),deviceLibrarySelectVo.getSize(),deviceStatisticsVos,pageable);
}
return new PageImpl<>(deviceStatisticsVos, pageable, deviceStatisticsVos.size());
}
@Override
public List<String> getAllName() {
......@@ -276,46 +208,41 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
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(
return 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(
return 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(
return 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;
return deviceLibraryDao.findAll(getSelectSpecification(deviceLibrarySelectVo));
}
@Override
......@@ -346,13 +273,12 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
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(
return GetTreeUtils.parseTreeFromDown(
deviceLibraryEntities,
DeviceLibrary::getId,
deviceLibraryEntity -> Optional.ofNullable(nodeCollect.get(deviceLibraryEntity.getPartParentId())),
DeviceLibrary::addChildNode
);
return deviceLibraryEntities1;
}
@Override
......
package com.tykj.dev.device.library.subject.Dto;
import com.tykj.dev.device.library.subject.domin.DeviceLog;
import com.tykj.dev.device.library.subject.vo.DeviceLogUserVo;
import com.tykj.dev.device.library.subject.vo.FileVo;
import com.tykj.dev.device.user.subject.service.UserPublicService;
import com.tykj.dev.misc.base.BeanHelper;
import com.tykj.dev.misc.utils.SpringUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.modelmapper.ModelMapper;
import java.util.Date;
import java.util.List;
......@@ -75,4 +80,20 @@ public class DeviceLogDto {
this.remark = remark;
this.fileVoList = fileVoList;
}
/**
* dto类转化为vo类
*/
public DeviceLogUserVo toVo(){
UserPublicService userPublicService = SpringUtils.getBean("userPublicServiceImpl");
//复制相同属性
ModelMapper modelMapper = BeanHelper.getUserMapper();
DeviceLogUserVo deviceLogUserVo = modelMapper.map(this,DeviceLogUserVo.class);
//set vo字段
if (userPublicService!=null){
deviceLogUserVo.setUser(userPublicService.getOne(this.createUserId).getName());
deviceLogUserVo.setUnit(userPublicService.findUnitsNameByUserId(this.createUserId));
}
return deviceLogUserVo;
}
}
......@@ -89,18 +89,6 @@ public class DeviceLog {
@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;
/**
* do类转化为dto类
*/
......
......@@ -18,7 +18,7 @@ public class DeviceDetailVo {
private List<DeviceLibrary> deviceList;
private List<DeviceLog> deviceLogEntityList;
private List<DeviceLogUserVo> deviceLogEntityList;
private String imageName;
......
package com.tykj.dev.device.library.subject.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class DeviceLogUserVo {
@ApiModelProperty(name = "主键id")
private Integer id;
@ApiModelProperty(value = "业务id")
private Integer taskId;
@ApiModelProperty(value = "操作描述")
private String remark;
@ApiModelProperty(value = "附件信息")
private List<FileVo> fileVoList;
@ApiModelProperty(value = "操作用户")
private String user;
@ApiModelProperty(value = "操作单位")
private String unit;
@ApiModelProperty(value = "操作时间")
private Date createTime;
}
......@@ -14,7 +14,14 @@
<dependency>
<groupId>com.tykj.dev</groupId>
<artifactId>device-task</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-packing</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -55,7 +55,6 @@ public class PackingLibraryServiceImpl implements PackingLibraryService {
packingLibraryEntity -> Optional.ofNullable(nodeCollect.get(packingLibraryEntity.getPartParentId())),
PackingLibrary::addChildNode
);
return packingLibraryEntityList;
}
......
......@@ -14,10 +14,22 @@
<dependency>
<groupId>com.tykj.dev</groupId>
<artifactId>device-library</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-selfcheck</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.tykj.dev</groupId>
<artifactId>device-task</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-selfcheck</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
......
......@@ -15,14 +15,32 @@
<dependency>
<groupId>com.tykj.dev</groupId>
<artifactId>device-library</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-storage</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.tykj.dev</groupId>
<artifactId>device-packing</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-storage</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.tykj.dev</groupId>
<artifactId>device-task</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-storage</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -20,10 +20,22 @@
<dependency>
<groupId>com.tykj.dev</groupId>
<artifactId>device-user</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-task</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.tykj.dev</groupId>
<artifactId>device-library</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-task</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
......
package com.tykj.dev.device.task.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.task.repository.TaskLogDao;
import com.tykj.dev.device.task.service.TaskService;
import com.tykj.dev.device.task.subject.bto.TaskBto;
import com.tykj.dev.device.task.subject.bto.TaskLogBto;
import com.tykj.dev.device.task.subject.domin.Task;
import com.tykj.dev.device.task.subject.domin.TaskLog;
import com.tykj.dev.device.task.subject.vo.TaskLogUserVo;
import com.tykj.dev.device.task.subject.vo.TaskSelectVo;
import com.tykj.dev.device.task.subject.vo.TaskTopVo;
import com.tykj.dev.device.task.subject.vo.TaskUserVo;
import com.tykj.dev.device.user.subject.service.UserPublicService;
import com.tykj.dev.device.task.utils.TaskUtils;
import com.tykj.dev.device.user.util.UserUtils;
import com.tykj.dev.misc.utils.PageUtil;
import com.tykj.dev.misc.utils.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
......@@ -36,177 +43,65 @@ public class TaskController {
private UserUtils userUtils;
@Autowired
private DeviceLibraryService deviceLibraryService;
private TaskUtils taskUtils;
@Autowired
private UserPublicService userPublicService;
private TaskLogDao taskLogDao;
@Autowired
private DeviceLogDao deviceLogDao;
// @ApiOperation(value = "业务分页查询",notes = "可以通过这个接口分页查询业务")
// @RequestMapping(method = RequestMethod.POST , value = "/manage/summary",produces = MediaType.APPLICATION_JSON_VALUE)
// public ResultObj getTaskPage(@RequestBody TaskSelectVo taskSelectVo){
// List<TaskEntity> taskServicePage = taskService.getPage(taskSelectVo, taskSelectVo.getPageable());
// List<TaskEntity> list = new ArrayList<>();
// List<TaskEntity> list1 = new ArrayList<>();
// List<TaskEntity> list2 = new ArrayList<>();
// for (TaskEntity t:taskServicePage) {
// if (t.getIsTop()==1){
// list1.add(t);
// }
// }
// for (TaskEntity t:list1) {
// if (t.getIsRead()==0){
// list.add(t);
// }
// }
// for (TaskEntity t:list1) {
// if (t.getIsRead()==1){
// list.add(t);
// }
// }
// for (TaskEntity t:taskServicePage) {
// if (t.getIsTop()==0){
// list2.add(t);
// }
// }
// for (TaskEntity t:list2) {
// if (t.getIsRead()==0){
// list.add(t);
// }
// }
// for (TaskEntity t:list2) {
// if (t.getIsRead()==1){
// list.add(t);
// }
// }
// if (list.size()<=taskSelectVo.getSize()) {
// return new ResultObj(new PageImpl<>(list, taskSelectVo.getPageable(), list.size()),"查询成功");
// }
// else {
// Double d = Math.ceil(list.size()/taskSelectVo.getSize().doubleValue());
// int value = new Double(d).intValue();
// if (taskSelectVo.getPage()>=value){
// return null;
// }
// else {
// int index = taskSelectVo.getPage()*taskSelectVo.getSize();
// if (taskSelectVo.getPage()==value){
// return new ResultObj(new PageImpl<>(list.subList(index,list.size()), taskSelectVo.getPageable(), list.size()),"查询成功");
// }
// return new ResultObj(new PageImpl<>(list.subList(index,index+taskSelectVo.getSize()), taskSelectVo.getPageable(), list.size()),"查询成功");
// }
// }
// }
@ApiOperation(value = "业务分页查询",notes = "可以通过这个接口分页查询业务")
@RequestMapping(method = RequestMethod.POST , value = "/manage/summary",produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Page<TaskUserVo>> getTaskPage(@RequestBody TaskSelectVo taskSelectVo){
List<TaskUserVo> taskUserVos = taskService.getManageList(taskSelectVo);
return ResultUtil.success(PageUtil.getPerPage(taskSelectVo.getPage(),taskSelectVo.getSize(),taskUtils.orderByTopDescAndReadAsc(taskUserVos),taskSelectVo.getPageable()));
}
@ApiOperation(value = "业务跟踪待办列表查询",notes = "可以通过这个接口查询业务")
@RequestMapping(method = RequestMethod.POST , value = "/getTaskList",produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<TaskUserVo>> getTaskList(@RequestBody TaskSelectVo taskSelectVo){
List<TaskUserVo> taskEntities = taskService.getList(taskSelectVo);
//按置顶第一顺序,未读第二顺序排序输出
List<TaskUserVo> list = new ArrayList<>();
List<TaskUserVo> list1 = new ArrayList<>();
List<TaskUserVo> list2 = new ArrayList<>();
//将置顶筛选到list1
for (TaskUserVo t:taskEntities) {
if (t.getIsTop()==1){
list1.add(t);
}
}
//list1中将未读的放在list最前面
for (TaskUserVo t:list1) {
if (t.getIsRead()==0){
list.add(t);
List<TaskUserVo> taskUserVos = taskService.getList(taskSelectVo);
return ResultUtil.success(taskUtils.orderByTopDescAndReadAsc(taskUserVos));
}
@ApiOperation(value = "置顶设置",notes = "可以通过这个接口置顶业务")
@RequestMapping(method = RequestMethod.PUT , value = "/setTop",produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<TaskUserVo> setTop(@RequestBody TaskTopVo taskTopVo){
TaskBto taskBto = taskService.get(taskTopVo.getTaskId());
Integer userId = userUtils.getCurrentUserId();
List<Integer> userIds = taskBto.getTopFlagDetailList();
if (taskTopVo.getTopFlag()==1) {
if (userIds!=null) {
taskBto.getTopFlagDetailList().add(userId);
}
//list1中将已读的放在list最后面
for (TaskUserVo t:list1) {
if (t.getIsRead()==1){
list.add(t);
}
if (taskTopVo.getTopFlag()==0){
if (userIds!=null&&userIds.contains(userId)) {
userIds.removeAll(new ArrayList<>(Collections.singletonList(userId)));
}
//将未置顶的放入list2中
for (TaskUserVo t:taskEntities) {
if (t.getIsTop()==0){
list2.add(t);
}
Task task = taskService.update(taskBto);
return ResultUtil.success(task.parse2Bto().toVo());
}
//将未读的优先放入list中
for (TaskUserVo t:list2) {
if (t.getIsRead()==0){
list.add(t);
@ApiOperation(value = "是否已读设置",notes = "可以通过这个接口设置业务的是否已读")
@PostMapping("/setRead")
public ResponseEntity<TaskUserVo> setRead(@RequestBody TaskTopVo taskTopVo){
TaskBto taskBto = taskService.get(taskTopVo.getTaskId());
Integer userId = userUtils.getCurrentUserId();
List<Integer> userIds = taskBto.getUserReadDetailList();
if (taskTopVo.getTopFlag()==1) {
if (userIds!=null) {
taskBto.getTopFlagDetailList().add(userId);
}
}
//将已读的放入list
for (TaskUserVo t:list2) {
if (t.getIsRead()==1){
list.add(t);
if (taskTopVo.getTopFlag()==0){
if (userIds!=null&&userIds.contains(userId)) {
userIds.removeAll(new ArrayList<>(Collections.singletonList(userId)));
}
}
return ResultUtil.success(list);
Task task = taskService.update(taskBto);
return ResultUtil.success(task.parse2Bto().toVo());
}
// @ApiOperation(value = "置顶设置",notes = "可以通过这个接口置顶业务")
// @RequestMapping(method = RequestMethod.PUT , value = "/setTop",produces = MediaType.APPLICATION_JSON_VALUE)
// public ResultObj setTop(@RequestBody TaskTopVo taskTopVo){
// TaskEntity taskEntity = taskService.getOne(taskTopVo.getTaskId());
// Integer userId = userUtils.getCurrentUserId();
// if (taskTopVo.getTopFlag()==1) {
// if (taskEntity.getTopFlagDetail()!=null) {
// taskEntity.setTopFlagDetail(taskEntity.getTopFlagDetail() + userId + "x");
// }
// else {
// taskEntity.setTopFlagDetail("x" + userId + "x");
// }
// }
// if (taskTopVo.getTopFlag()==0){
// List<Integer> idList = StringSplitUtil.userIdSplit(taskEntity.getTopFlagDetail());
// StringBuffer stringBuffer = new StringBuffer();
// stringBuffer.append("x");
// if (idList.size()>0){
// for (Integer id:idList) {
// if (!id.equals(userId)){
// stringBuffer.append(id+"x");
// }
// }
// }
// taskEntity.setTopFlagDetail(stringBuffer.toString());
// }
// TaskEntity taskEntityUpdated = taskService.update(taskEntity);
// return new ResultObj(taskEntityUpdated,"修改置顶标志成功");
// }
//
// @ApiOperation(value = "是否已读设置",notes = "可以通过这个接口设置业务的是否已读")
// @PostMapping("/setRead")
// public ResultObj setRead(@RequestBody TaskTopVo taskTopVo){
// TaskEntity taskEntity = taskService.getOne(taskTopVo.getTaskId());
// Integer userId = userUtils.getCurrentUserId();
// if (taskTopVo.getTopFlag()==1) {
// if (taskEntity.getUserReadDetail()!=null) {
// taskEntity.setUserReadDetail(taskEntity.getUserReadDetail() + userId + "x");
// }
// else {
// taskEntity.setUserReadDetail("x" + userId + "x");
// }
// }
// if (taskTopVo.getTopFlag()==0){
// List<Integer> idList = StringSplitUtil.userIdSplit(taskEntity.getUserReadDetail());
// StringBuffer stringBuffer = new StringBuffer();
// stringBuffer.append("x");
// if (idList.size()>0){
// for (Integer id:idList) {
// if (!id.equals(userId)){
// stringBuffer.append(id+"x");
// }
// }
// }
// taskEntity.setUserReadDetail(stringBuffer.toString());
// }
// TaskEntity taskEntityUpdated = taskService.update(taskEntity);
// return new ResultObj(taskEntityUpdated,"修改阅读标志成功");
// }
// @ApiOperation(value = "查询业务对应页面的数据",notes = "可以通过这个接口查询业务对应页面的数据")
// @GetMapping("/manage/detail/{id}")
// public ResultObj selectData(@PathVariable("id") int taskId){
......@@ -395,48 +290,10 @@ public class TaskController {
// return list;
// }
//
// @ApiOperation(value = "查询业务日志",notes = "可以通过这个接口查询查询业务日志")
// @GetMapping("/manage/detail/log/{id}")
// public ResultObj selectLog(@PathVariable("id") int taskId){
// Set<String> remarkList = new HashSet<>();
// List<DeviceLogEntity> deviceLogEntities = new ArrayList<>();
// List<DeviceLogEntity> logEntities = orderByTime(deviceLogDao.getAllByTaskId(taskId));
// if (logEntities.size()>0){
// logEntities.forEach(deviceLogEntity -> {
// if (!remarkList.contains(deviceLogEntity.getRemark())){
// deviceLogEntities.add(deviceLogEntity);
// remarkList.add(deviceLogEntity.getRemark());
// }
// });
// }
// for (DeviceLogEntity d:deviceLogEntities) {
// d.setUser(userPublicService.getOne(d.getUserId()).getName());
// d.setUnit(userPublicService.findUnitsNameByUserId(d.getUserId()));
// String[] strings = d.getFileDetail().split("Ǵ");
// List<FileVo> fileVos = new ArrayList<>();
// if (strings.length>0){
// for (String s:strings) {
// if (s.length()>0){
// String[] strings1 = s.split("Ǒ");
// if ("".equals(strings1[0])&&strings1.length==4){
// FileVo fileVo = new FileVo();
// fileVo.setFileName(strings1[1]);
// fileVo.setFileUrl(strings1[2]);
// fileVo.setTitle(strings1[3]);
// fileVos.add(fileVo);
// }
// if (!"".equals(strings1[0])&&strings1.length==3){
// FileVo fileVo = new FileVo();
// fileVo.setFileName(strings1[0]);
// fileVo.setFileUrl(strings1[1]);
// fileVo.setTitle(strings1[2]);
// fileVos.add(fileVo);
// }
// }
// }
// }
// d.setFileVoList(fileVos);
// }
// return new ResultObj(deviceLogEntities,"查询成功");
// }
@ApiOperation(value = "查询业务日志",notes = "可以通过这个接口查询查询业务日志")
@GetMapping("/manage/detail/log/{id}")
public ResponseEntity<List<TaskLogUserVo>> selectLog(@PathVariable("id") int taskId){
List<TaskLog> taskLogs = taskUtils.orderByCreateTimeAsc(taskLogDao.getAllByTaskId(taskId));
return ResultUtil.success(taskLogs.stream().map(TaskLog::parse2bto).map(TaskLogBto::toVo).collect(Collectors.toList()));
}
}
......@@ -97,4 +97,10 @@ public interface TaskService {
* 获取跟踪和待办业务列表
*/
List<TaskUserVo> getList(TaskSelectVo taskSelectVo);
/**
* @param taskSelectVo
* 获取业务管理中的业务列表
*/
List<TaskUserVo> getManageList(TaskSelectVo taskSelectVo);
}
package com.tykj.dev.device.task.service.impl;
import com.github.wenhao.jpa.PredicateBuilder;
import com.github.wenhao.jpa.Specifications;
import com.tykj.dev.device.task.repository.TaskDao;
import com.tykj.dev.device.task.repository.TaskLogDao;
......@@ -17,12 +18,14 @@ import com.tykj.dev.device.user.util.UserUtils;
import com.tykj.dev.misc.exception.ApiException;
import com.tykj.dev.misc.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.ExceptionHandler;
import javax.persistence.Transient;
import java.lang.reflect.Field;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @author dengdiyi
......@@ -280,6 +283,97 @@ public class TaskServiceImpl implements TaskService {
return taskEntities;
}
/**
* @param taskSelectVo 获取业务管理中的业务列表
*/
@Override
public List<TaskUserVo> getManageList(TaskSelectVo taskSelectVo) {
Integer num = taskSelectVo.getSelectNum();
Integer userId = userUtils.getCurrentUserId();
//业务管理中的待办和跟踪
if (num==2||num==3){
//查询出符合筛选条件的所有task
List<TaskUserVo> list = taskDao.findAll(getSelectSpecification(taskSelectVo)).stream()
.map(Task::parse2Bto)
.map(TaskBto::toVo)
.collect(Collectors.toList());
//查询当前用户的跟踪和待办并和list按id取交集
List<TaskUserVo> taskUserVos = getList(taskSelectVo).stream()
.filter(taskUserVo -> find(taskUserVo.getId(),list)>-1)
.collect(Collectors.toList());
//判断是否需要按发起时间排序
if (taskSelectVo.getOrders()!=null) {
if ("createTime".equals(taskSelectVo.getOrders().get(0).getCoulmn())) {
if ("ASC".equals(taskSelectVo.getOrders().get(0).getDirection().toString())) {
return taskUtils.orderByCreateTimeAsc2(taskUserVos);
}
if ("DESC".equals(taskSelectVo.getOrders().get(0).getDirection().toString())) {
return taskUtils.orderByCreateTimeDesc2(taskUserVos);
}
}
}
return taskUserVos;
}
if (num==4||num==5||num==1||num==0) {
//获取单位等级
Integer level = userUtils.getCurrentUnitLevel();
//获取该单位以及下属单位所有用户Id
List<Integer> idLists = userPublicService.findAllUserIdByUnitsName(userUtils.getCurrentUserUnitName());
List<TaskUserVo> taskUserVos = new ArrayList<>();
//省能看到所有业务
if (level==1) {
taskUserVos = taskDao.findAll(getSelectSpecification(taskSelectVo)).stream()
.map(Task::parse2Bto)
.map(TaskBto::toVo)
.collect(Collectors.toList());
}
//市或县只能看到涉及人员和idLists有交集的
if (level==2||level==3){
taskUserVos = taskDao.findAll(getSelectSpecification(taskSelectVo)).stream()
.map(Task::parse2Bto)
.map(TaskBto::toVo)
.filter(taskUserVo -> !Collections.disjoint(idLists, taskUserVo.getInvolveUserIdList()))
.collect(Collectors.toList());
}
//set经办人,置顶以及阅读情况
for (TaskUserVo taskUserVo:taskUserVos) {
List<Integer> idList = taskUserVo.getUserReadDetailList();
List<Integer> idList2 = taskUserVo.getTopFlagDetailList();
if (taskUserVo.getInvolveUserIdList() != null && taskUserVo.getInvolveUserIdList().size() > 0) {
//筛选出userId大于0的
List<Integer> userIds = taskUserVo.getInvolveUserIdList().stream().filter(integer -> integer > 0).collect(Collectors.toList());
if (userIds.size() > 0) {
//List最后一个id即为最新经办人
taskUserVo.setProcessingUser(userPublicService.getOne(userIds.get(userIds.size() - 1)).getName());
}
}
//判断当前用户是否已读
if (idList.contains(userId)) {
taskUserVo.setIsRead(1);
}
//判断当前用户是否置顶
if (idList2.contains(userId)) {
taskUserVo.setIsTop(1);
}
}
//判断是否需要按发起时间排序
if (taskSelectVo.getOrders()!=null) {
if ("createTime".equals(taskSelectVo.getOrders().get(0).getCoulmn())) {
if ("ASC".equals(taskSelectVo.getOrders().get(0).getDirection().toString())) {
return taskUtils.orderByCreateTimeAsc2(taskUserVos);
}
if ("DESC".equals(taskSelectVo.getOrders().get(0).getDirection().toString())) {
return taskUtils.orderByCreateTimeDesc2(taskUserVos);
}
}
}
return taskUserVos;
}
else {
throw new ApiException(ResultUtil.failed("selectNum只能为0,1,2,3,4,5"));
}
}
/**
* @param taskSelectVo 查询vo
* 查询跟踪和待办列表
......@@ -423,4 +517,58 @@ public class TaskServiceImpl implements TaskService {
return null;
}
}
/**
* @param taskSelectVo
* task查询器
*/
private Specification<Task> getSelectSpecification(TaskSelectVo taskSelectVo){
PredicateBuilder<Task> predicateBuilder = Specifications.and();
if (taskSelectVo.getBussinessType()!=null){
predicateBuilder.eq("bussinessType", taskSelectVo.getBussinessType());
}
if (taskSelectVo.getContent()!=null){
Class<Task> taskEntityClass = Task.class;
Field[] declaredFields = taskEntityClass.getDeclaredFields();
PredicateBuilder<Task> p = Specifications.or();
for (Field field : declaredFields) {
if (field.getType().equals(String.class)&&field.getAnnotation(Transient.class)==null) {
p.like(field.getName(), "%" + taskSelectVo.getContent() + "%");
}
}
predicateBuilder.predicate(p.build());
}
if (taskSelectVo.getStartTime()!=null){
predicateBuilder.gt("createTime", taskSelectVo.getStartTime());
}
if (taskSelectVo.getEndTime()!=null){
predicateBuilder.lt("createTime", taskSelectVo.getEndTime());
}
if (taskSelectVo.getSelectNum()==4){
predicateBuilder.eq("billStatus",13);
}
if (taskSelectVo.getSelectNum()==5){
predicateBuilder.eq("billStatus",14);
}
if (taskSelectVo.getSelectNum()==1){
predicateBuilder.eq("createUserId",userUtils.getCurrentUnitId());
}
return predicateBuilder.build();
}
/**
* 判断list中是否包含某个id的taskUserVo,若不存在返回-1,存在则返回第一次出现的索引值
*/
int find(Integer id,List<TaskUserVo> list){
int index = -1;
if (list!=null&&list.size()>0){
for (int i=0;i<list.size();i++){
if (list.get(i).getId().equals(id)){
index = i;
break;
}
}
}
return index;
}
}
......@@ -5,6 +5,7 @@ import com.tykj.dev.device.task.subject.domin.Task;
import com.tykj.dev.device.task.subject.vo.TaskUserVo;
import com.tykj.dev.device.user.subject.service.UserPublicService;
import com.tykj.dev.misc.base.BeanHelper;
import com.tykj.dev.misc.utils.SpringUtils;
import com.tykj.dev.misc.utils.StringSplitUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
......@@ -13,6 +14,7 @@ import lombok.NoArgsConstructor;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
......@@ -23,12 +25,8 @@ import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Repository
public class TaskBto {
@Autowired
private UserPublicService userPublicService;
@ApiModelProperty(value = "主键id")
private Integer id;
......@@ -97,11 +95,14 @@ public class TaskBto {
* bto类转化为vo类
*/
public TaskUserVo toVo(){
UserPublicService userPublicService = SpringUtils.getBean("userPublicServiceImpl");
//复制相同属性
ModelMapper modelMapper = BeanHelper.getUserMapper();
TaskUserVo taskUserVo = modelMapper.map(this,TaskUserVo.class);
//set vo字段
if (userPublicService != null) {
taskUserVo.setStartUnit(userPublicService.findUnitsNameByUserId(this.createUserId));
}
taskUserVo.setStatus(GlobalMap.getStatusEnumMap().get(this.billStatus).name);
return taskUserVo;
}
......
......@@ -2,10 +2,15 @@ package com.tykj.dev.device.task.subject.bto;
import com.tykj.dev.device.task.subject.domin.TaskLog;
import com.tykj.dev.device.library.subject.vo.FileVo;
import com.tykj.dev.device.task.subject.vo.TaskLogUserVo;
import com.tykj.dev.device.user.subject.service.UserPublicService;
import com.tykj.dev.misc.base.BeanHelper;
import com.tykj.dev.misc.utils.SpringUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.modelmapper.ModelMapper;
import java.util.Date;
import java.util.List;
......@@ -64,4 +69,20 @@ public class TaskLogBto {
this.remark = remark;
this.fileVoList = fileVoList;
}
/**
* bto类转化为vo类
*/
public TaskLogUserVo toVo(){
UserPublicService userPublicService = SpringUtils.getBean("userPublicServiceImpl");
//复制相同属性
ModelMapper modelMapper = BeanHelper.getUserMapper();
TaskLogUserVo taskLogUserVo = modelMapper.map(this,TaskLogUserVo.class);
//set vo字段
if (userPublicService!=null){
taskLogUserVo.setUser(userPublicService.getOne(this.createUserId).getName());
taskLogUserVo.setUnit(userPublicService.findUnitsNameByUserId(this.createUserId));
}
return taskLogUserVo;
}
}
......@@ -84,18 +84,6 @@ public class TaskLog {
@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;
/**
* do类转化为bto类
*/
......
package com.tykj.dev.device.task.subject.vo;
import com.tykj.dev.device.library.subject.vo.FileVo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TaskLogUserVo {
@ApiModelProperty(name = "主键id")
private Integer id;
@ApiModelProperty(value = "业务id")
private Integer taskId;
@ApiModelProperty(value = "操作描述")
private String remark;
@ApiModelProperty(value = "附件信息")
private List<FileVo> fileVoList;
@ApiModelProperty(value = "操作用户")
private String user;
@ApiModelProperty(value = "操作单位")
private String unit;
@ApiModelProperty(value = "操作时间")
private Date createTime;
}
......@@ -4,6 +4,7 @@ import com.tykj.dev.device.task.subject.domin.TaskLog;
import com.tykj.dev.device.task.subject.vo.TaskUserVo;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
......@@ -26,6 +27,18 @@ public class TaskUtils {
return list;
}
/**
* @param list 业务日志list
* 按照日志创建时间增序排列
*/
public List<TaskLog> orderByCreateTimeAsc(List<TaskLog> list){
Collections.sort(list, (o1, o2) -> {
int flag = o1.getCreateTime().compareTo(o2.getCreateTime());
return flag;
});
return list;
}
/**
* @param list taskUserVo list
* 按照跟踪时间增序排列
......@@ -73,4 +86,75 @@ public class TaskUtils {
});
return list;
}
/**
* @param list taskUserVo list
* 按照发起时间降序排列
*/
public List<TaskUserVo> orderByCreateTimeDesc2(List<TaskUserVo> list){
Collections.sort(list, (o1, o2) -> {
int flag = o2.getCreateTime().compareTo(o1.getCreateTime());
return flag;
});
return list;
}
/**
* @param list taskUserVo list
* 按照发起时间升序排列
*/
public List<TaskUserVo> orderByCreateTimeAsc2(List<TaskUserVo> list){
Collections.sort(list, (o1, o2) -> {
int flag = o1.getCreateTime().compareTo(o2.getCreateTime());
return flag;
});
return list;
}
/**
* @param taskUserVos
* 按置顶第一顺序,未读第二顺序排序输出
*/
public List<TaskUserVo> orderByTopDescAndReadAsc(List<TaskUserVo> taskUserVos){
List<TaskUserVo> list = new ArrayList<>();
List<TaskUserVo> list1 = new ArrayList<>();
List<TaskUserVo> list2 = new ArrayList<>();
//将置顶筛选到list1
for (TaskUserVo t:taskUserVos) {
if (t.getIsTop()==1){
list1.add(t);
}
}
//list1中将未读的放在list最前面
for (TaskUserVo t:list1) {
if (t.getIsRead()==0){
list.add(t);
}
}
//list1中将已读的放在list最后面
for (TaskUserVo t:list1) {
if (t.getIsRead()==1){
list.add(t);
}
}
//将未置顶的放入list2中
for (TaskUserVo t:taskUserVos) {
if (t.getIsTop()==0){
list2.add(t);
}
}
//将未读的优先放入list中
for (TaskUserVo t:list2) {
if (t.getIsRead()==0){
list.add(t);
}
}
//将已读的放入list
for (TaskUserVo t:list2) {
if (t.getIsRead()==1){
list.add(t);
}
}
return list;
}
}
......@@ -2,6 +2,7 @@ package com.tykj.dev.device.user.util;
import com.tykj.dev.device.user.subject.entity.SecurityUser;
import com.tykj.dev.device.user.subject.service.UnitsService;
import com.tykj.dev.misc.utils.SpringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -12,8 +13,7 @@ import org.springframework.stereotype.Component;
@Component
public class UserUtils {
@Autowired
private UnitsService unitsService;
private UnitsService unitsService = SpringUtils.getBean("unitsServiceImpl");
public Integer getCurrentUserId(){
SecurityUser authentication = AuthenticationUtils.getAuthentication();
......
package com.tykj.dev.misc.utils;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import java.util.List;
/**
* @author dengdiyi
* 分页工具类
*/
public class PageUtil {
/**
* @param page 当前页数,默认0为第一页
* @param size 分页大小
* 获取分页后每一页的分页信息
*/
public static <T> Page<T> getPerPage(Integer page, Integer size, List<T> list, Pageable pageable){
//若List的size小于分页大小(只有一页)
if (list.size()<=size) {
return new PageImpl<>(list, pageable, list.size());
}
else {
//计算分了几页
double d = Math.ceil(list.size()/size.doubleValue());
int value = new Double(d).intValue();
//当前页数超出了最大页数
if (page>=value){
return null;
}
else {
//当前页的第一条记录的索引值
int index = page*size;
//当前页为最后一页
if (page==value-1){
return new PageImpl<>(list.subList(index,list.size()), pageable, list.size());
}
return new PageImpl<>(list.subList(index,index+size), pageable, list.size());
}
}
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论