提交 af593568 authored 作者: 133's avatar 133

[退役、报废、销毁] 决算相关接口提交

上级 c1b25f35
......@@ -72,6 +72,13 @@ public interface DeviceUseReportService {
*/
List<DeviceStatistics> getDestroyStatistics(Date startDate, Date endDate);
/**
* @param startDate 开始时间
* @param endDate 结束时间
* @return 这一段时间省退役的统计
*/
List<DeviceStatistics> getDecommissioningStatistics(Date startDate, Date endDate);
/**
* @param startDate 开始时间
* @param endDate 结束时间
......@@ -79,5 +86,6 @@ public interface DeviceUseReportService {
*/
List<DeviceStatistics> getScrapStatistics(Date startDate, Date endDate);
void delete(Integer id);
}
......@@ -4,9 +4,11 @@ import com.github.wenhao.jpa.PredicateBuilder;
import com.github.wenhao.jpa.Specifications;
import com.tykj.dev.blockcha.subject.entity.BcHash;
import com.tykj.dev.blockcha.subject.service.BlockChainUtil;
import com.tykj.dev.config.base.DeviceLifeStatus;
import com.tykj.dev.device.allot.repository.AllotBillDao;
import com.tykj.dev.device.allot.subject.domin.AllotBill;
import com.tykj.dev.device.destroy.repository.DeviceDestroyBillDao;
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;
......@@ -39,6 +41,7 @@ import org.springframework.stereotype.Service;
import javax.persistence.Transient;
import java.lang.reflect.Field;
import java.time.LocalDate;
import java.util.*;
import static java.util.stream.Collectors.groupingBy;
......@@ -65,6 +68,9 @@ public class DeviceUseReportServiceImpl implements DeviceUseReportService {
@Autowired
private AllotBillDao allotBillDao;
@Autowired
DeviceLibraryDao deviceLibraryDao;
@Autowired
private DeviceDestroyBillDao deviceDestroyBillDao;
......@@ -308,28 +314,15 @@ public class DeviceUseReportServiceImpl implements DeviceUseReportService {
*/
@Override
public List<DeviceStatistics> getDestroyStatistics(Date startDate, Date endDate) {
List<DeviceLibrary> deviceLibraries = new ArrayList<>();
//筛选出日期范围内所有销毁账单
// List<DeviceDestroyBill> deviceDestroyBills = deviceDestroyBillDao.findAll().stream()
// .filter(deviceDestroyBill -> deviceDestroyBill.getDestroyStatus() == 2 && deviceDestroyBill.getDestroyTime().after(startDate) && deviceDestroyBill.getDestroyTime().before(endDate))
// .collect(toList());
// //获取所有销毁的装备
// if (deviceDestroyBills.size() > 0) {
// for (DeviceDestroyBill s : deviceDestroyBills) {
// String[] strings = s.getDestroyDeviceDetail().split("x");
// for (String s1 : strings) {
// if (s1.length() >= 2) {
// //出库无误装备
// if ("1".equals(s1.substring(s1.length() - 1))) {
// Integer id = Integer.parseInt(s1.substring(0, s1.length() - 1));
// DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(id);
// deviceLibraries.add(deviceLibraryEntity);
// }
// }
// }
// }
// }
return getDeviceStatistics(deviceLibraries);
List<DeviceLibrary> libraryList= deviceLibraryDao.findAll(getPredicateBuilder(startDate,endDate,DeviceLifeStatus.DESTROYED));
return getDeviceStatistics(libraryList);
}
@Override
public List<DeviceStatistics> getDecommissioningStatistics(Date startDate, Date endDate) {
List<DeviceLibrary> libraryList= deviceLibraryDao.findAll(getPredicateBuilder(startDate,endDate,DeviceLifeStatus.RETIRE));
return getDeviceStatistics(libraryList);
}
/**
......@@ -339,19 +332,8 @@ public class DeviceUseReportServiceImpl implements DeviceUseReportService {
*/
@Override
public List<DeviceStatistics> getScrapStatistics(Date startDate, Date endDate) {
List<DeviceLibrary> deviceLibraries = new ArrayList<>();
//筛选出日期范围内所有报废账单
List<ScrapBill> scrapBills = scrapBillDao.findAll().stream()
.filter(scrapBill -> scrapBill.getScrapUnit().equals(userPublicService.findByUnitsToname(1)) && scrapBill.getScrapTime().after(startDate) && scrapBill.getScrapTime().before(endDate))
.collect(toList());
//获取所有报废的装备
if (scrapBills.size() > 0) {
for (ScrapBill s : scrapBills) {
List<Integer> integerList = StringSplitUtil.userIdSplit(s.getScrapDetail());
integerList.forEach(integer -> deviceLibraries.add(deviceLibraryService.getOne(integer)));
}
}
return getDeviceStatistics(deviceLibraries);
List<DeviceLibrary> libraryList= deviceLibraryDao.findAll(getPredicateBuilder(startDate,endDate,DeviceLifeStatus.SCRAP_I));
return getDeviceStatistics(libraryList);
}
@Override
......@@ -383,6 +365,29 @@ public class DeviceUseReportServiceImpl implements DeviceUseReportService {
return predicateBuilder.build();
}
/**
* 销毁、报废、退役使用
* @param startTime 开始时间
* @param endTime 结束时间
* @return 装备集合
*/
private Specification<DeviceLibrary> getPredicateBuilder(Date startTime, Date endTime, DeviceLifeStatus deviceLifeStatus) {
PredicateBuilder<DeviceLibrary> predicateBuilder = Specifications.and();
if (startTime!=null){
predicateBuilder.gt("updateTime",startTime);
}
if (endTime !=null){
predicateBuilder.lt("updateTime",endTime);
}
predicateBuilder.eq("lifeStatus", deviceLifeStatus.id);
return predicateBuilder.build();
}
/**
* 按型号组合统计
*/
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论