提交 598d7b72 authored 作者: zhoushaopan's avatar zhoushaopan

fix(装备模块,配套设备模块,统计模块): 解决了配套设备的数量和序列号区间不一致,解决了工作台本级设备库和全省设备库的数量

解决了配套设备的数量和序列号区间不一致,解决了工作台本级设备库和全省设备库的数量
上级 a2f46ace
......@@ -171,6 +171,8 @@ public interface DeviceLibraryDao extends JpaRepository<DeviceLibrary, Integer>,
List<DeviceLibrary> findAllByPackingIdIn(List<Integer> packingIds);
List<DeviceLibrary> findAllByOwnUnitInOrLocationUnitIn(List<String> unitName,List<String> unitName1);
@Modifying
@Query("update DeviceLibrary d set d.model = :newModel where d.model = :oldModel")
......
......@@ -3,6 +3,7 @@ package com.tykj.dev.device.library.service;
import com.tykj.dev.config.UpdateCache;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.library.subject.vo.*;
import com.tykj.dev.device.user.util.DecryptMD5;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
......@@ -513,4 +514,9 @@ public interface DeviceLibraryService {
*/
void updateDeviceLocationAndOwnUnit(UpdateUnitVo updateUnitVo);
/**
* @param unitId 单位id
*/
List<DeviceLibrary> getDeviceByUnitNameAll(Integer unitId);
}
......@@ -1220,6 +1220,12 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
deviceLibraryDao.updateOwnUnit(updateUnitVo.getOriginUnitName(),updateUnitVo.getUpdateUnitName());
}
@Override
public List<DeviceLibrary> getDeviceByUnitNameAll(Integer unitId) {
List<String> unitNames = userPublicService.findByUnitIdSubordinateAll(unitId).stream().map(Units::getName).collect(Collectors.toList());
return deviceLibraryDao.findAllByOwnUnitInOrLocationUnitIn(unitNames,unitNames);
}
// @Override
// @UpdateCache
// public int updatePartParentId(List<Integer> deviceIds) {
......
......@@ -121,7 +121,8 @@ public class MatchingDeviceController {
//当手动输入序列号的时候 需要进行遍历成集合
matchingDeviceSaveVos.forEach(matchingDeviceSaveVo -> {
List<String> deviceSeqs = DeviceSeqUtil.createDeviceSeqs(matchingDeviceSaveVo.getSeqNumber(), matchingDeviceSaveVo.getStorageCount());
// List<String> deviceSeqs = DeviceSeqUtil.createDeviceSeqs(matchingDeviceSaveVo.getSeqNumber(), matchingDeviceSaveVo.getStorageCount());
List<String> deviceSeqs = DeviceSeqUtil.getIntervalSeqsForMatchingDevice(matchingDeviceSaveVo.getSeqNumber());
matchingDeviceSaveVo.setSeqList(deviceSeqs);
});
//做校验 数量跟序列号
......
......@@ -253,7 +253,8 @@ public class DeviceSeqUtil {
if (num1.length() != num2.length()){
throw new ApiException("序列号区间后面数字位数不相同");
}
else if(new BigInteger(num1).compareTo(new BigInteger(num2)) > 0){
else
if(new BigInteger(num1).compareTo(new BigInteger(num2)) > 0){
throw new ApiException("序列号区间前数字大于后数字");
}
else {
......@@ -278,7 +279,62 @@ public class DeviceSeqUtil {
}
}
else {
throw new ApiException("序列号区间包含多个-");
throw new ApiException("序列号区间包含多个-,或者输入不是序列号区间");
}
return stringList;
}
/**
* @param s 区间字符串
* 根据区间字符串获取该区间序列号列表
*/
public static List<String> getIntervalSeqsForMatchingDevice(String s){
List<String> stringList = new ArrayList<>();
//根据-分隔
String[] strings = s.split("-");
if(strings.length==2){
//左区间字符串
String s1 = strings[0];
//右区间字符串
String s2 = strings[1];
// if (s1.length()!=s2.length()){
// throw new ApiException("序列号区间前面字符位数不相同");
// }
// else {
//获得左区间最后几位的数字
String num1 = s1.replaceAll(".*[^\\d](?=(\\d+))", "");
//获得右区间最后几位的数字
String num2 = s2.replaceAll(".*[^\\d](?=(\\d+))", "");
// if (num1.length() != num2.length()){
//// throw new ApiException("序列号区间后面数字位数不相同");
// }
// else
if(new BigInteger(num1).compareTo(new BigInteger(num2)) > 0){
throw new ApiException("序列号区间前数字大于后数字");
}
else {
BigInteger minSeq = new BigInteger(num1);
BigInteger maxSeq = new BigInteger(num2);
if (maxSeq.compareTo(minSeq) < 0){
throw new ApiException("前区间数字大于后区间");
}
else {
while (minSeq.compareTo(maxSeq)<=0){
StringBuffer stringBuffer = new StringBuffer();
//拼接数字之前的字符串
stringBuffer.append(s1, 0, s1.length()-num1.length());
//将数字按长度格式化,缺位补0
String codeFormat = "%0"+ num1.length() +"d";
stringBuffer.append(String.format(codeFormat,minSeq));
stringList.add(stringBuffer.toString());
minSeq = minSeq.add(new BigInteger("1"));
}
}
}
}
// }
else {
throw new ApiException("序列号区间包含多个-,或者输入不是序列号区间");
}
return stringList;
}
......@@ -295,7 +351,8 @@ public class DeviceSeqUtil {
//左区间字符串
String s1 = strings[0];
if (s1.equals("0")){
s1 = s1+"0";
// s1 = s1+"0";
s1 = "0"+s1;
}
//右区间字符串
String s2 = strings[1];
......
......@@ -525,18 +525,13 @@ public class StatisticalServiceImpl implements StatisticalService {
// deviceLibrarySelectVo.setAreaId(areaCache.findByName("浙江省").getId());
deviceLibrarySelectVo.setAreaId(unitsService.findById(unit).getAreaId());
workBench.setPackingNum(packingLibraryDao.findAllByIsRootAndPackingStatus(0,2).size());
List<DeviceLibrary> deviceLibraries = deviceLibraryService.getCoreDevicePage(deviceLibrarySelectVo);
// List<DeviceLibrary> deviceLibraries = deviceLibraryService.getCoreDevicePage(deviceLibrarySelectVo);
List<DeviceLibrary> deviceLibraries = deviceLibraryService.getDeviceByUnitNameAll(unit);
workBench.setAllDeviceNum(deviceLibraries.size());
workBench.setSelfDeviceNum(Long.valueOf(deviceLibraries.stream().filter(deviceLibrary ->
deviceLibrary.getOwnUnit().equals(unitName)).count()).intValue());
//查询当前登录单位的配套设备 以及下级所有单位
// List<MatchingDeviceLibrary> allByCreateUnitId = matchingDeviceLibraryDao.findAllByCreateUnitId(unit);
// if (!allByCreateUnitId.isEmpty()){
// workBench.setMatchingDeviceNum(allByCreateUnitId.size());
// }else {
// workBench.setMatchingDeviceNum(0);
// }
//通过单位id查询区域id
Integer currentUnitId = userUtils.getCurrentUnitId();
List<MatchingDeviceLibrary> matchingDevicePage = matchingDeviceLibraryService.getMatchingByUnitIdAll(currentUnitId);
......@@ -551,10 +546,20 @@ public class StatisticalServiceImpl implements StatisticalService {
List<Task> allTasks = taskDao.findAll();
List<Task> tasks = allTasks.stream().filter(task -> task.getBusinessType()==7).collect(Collectors.toList());
List<Task> tasks2 = allTasks.stream().filter(task -> task.getBusinessType()==4).collect(Collectors.toList());
workBench.setCheckNum(Long.valueOf(tasks.stream().filter(task -> "check".equals(task.getCustomInfo())).count()).intValue());
workBench.setCompleteCheckNum(Long.valueOf(tasks.stream().filter(task -> task.getBillStatus()==9999&&"check".equals(task.getCustomInfo())).count()).intValue());
workBench.setExamNum(Long.valueOf(tasks.stream().filter(task -> task.getParentTaskId()==0&&"exam".equals(task.getCustomInfo())&&task.getOwnUnit().equals(unit)).count()).intValue());
workBench.setExamCompleteNum(Long.valueOf(tasks.stream().filter(task -> task.getBillStatus()==9999&&task.getParentTaskId()==0&&"exam".equals(task.getCustomInfo())&&task.getOwnUnit().equals(unit)).count()).intValue());
workBench.setCheckNum(Long.valueOf(tasks.stream().filter(task -> "check".equals(task.getCustomInfo())
&&unit.equals(task.getOwnUnit())&&task.getParentTaskId() == 0).count()).intValue());
workBench.setCompleteCheckNum(Long.valueOf(tasks.stream()
.filter(task -> (task.getBillStatus()==9999||task.getBillStatus() == 20001)&&"check".equals(task.getCustomInfo())
&&unit.equals(task.getOwnUnit())&&task.getParentTaskId() == 0)
.count()).intValue());
//检查
workBench.setExamNum(Long.valueOf(tasks.stream().filter(task -> task.getParentTaskId()==0&&
"exam".equals(task.getCustomInfo())&&task.getOwnUnit().equals(unit))
.count()).intValue());
workBench.setExamCompleteNum(Long.valueOf(tasks.stream().filter(task ->
(task.getBillStatus()==9999 ||task.getBillStatus() == 20001) &&task.getParentTaskId()==0&&"exam".equals(task.getCustomInfo())
&&task.getOwnUnit().equals(unit))
.count()).intValue());
workBench.setSelfCheckNum(Long.valueOf(tasks2.stream().filter(task -> task.getBillStatus()==9999&&unit.equals(task.getOwnUnit())).count()).intValue());
List<TrainTheme> themeList=trainThemeDao.findAll();
workBench.setTrainNum(themeList.size());
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论