提交 317d7fbe authored 作者: zjm's avatar zjm

fix(统计,配套设备): 修改了配套设备的统计查询接口,以及修改了配套设备绑定的bug,删除设备和添加设备同时存在时会出现

修改了配套设备的统计查询接口,以及修改了配套设备绑定的bug
上级 e56c95f7
......@@ -522,7 +522,8 @@ public class MatchingDeviceController {
m.setDeviceId(matchingDeviceEditVo.getAddDeviceId());
}
//删除
if (matchingDeviceEditVo.getDeleteDeviceId() != null){
//zjm 上面执行了下面回覆盖上面的赋值
if (matchingDeviceEditVo.getAddDeviceId() == null && matchingDeviceEditVo.getDeleteDeviceId() != null){
DeviceLibrary deviceLibrary = deviceLibraryService.getOne(matchingDeviceEditVo.getDeleteDeviceId());
String remark = "将序列号为" + m.getSeqNumber() + "的配套装备与序列号为" + deviceLibrary.getSeqNumber() + "的装备进行解除绑定";
DeviceLogDto deviceLogDto = new DeviceLogDto(1,m.getId(), remark,null,null);
......
......@@ -15,4 +15,6 @@ public interface MatchingDeviceLibraryDao extends JpaRepository<MatchingDeviceLi
List<MatchingDeviceLibrary> findAllByCreateUnitId(Integer unitId);
List<MatchingDeviceLibrary> findAllByCreateUnitIdIn(List<Integer> unitIds);
}
......@@ -53,6 +53,15 @@ public interface MatchingDeviceLibraryService {
*/
List<MatchingDeviceLibrary> getMatchingDevicePage(MatchingDeviceSelectVo matchingDeviceSelectVo);
/**
* @param unitId 单位id
*/
List<MatchingDeviceLibrary> getMatchingByUnitIdAll(Integer unitId);
/**
* @return 所有类型
*/
......
......@@ -180,8 +180,8 @@ public class MatchingDeviceLibraryServiceImpl implements MatchingDeviceLibrarySe
}
//如果areaId为Null,unitId不为null,返回对应单位的配套设备
else {
String unitName = userPublicService.findByUnitsToname(selectUnitId);
predicateBuilder.eq("createUnit", unitName);
// String unitName = userPublicService.findByUnitsToname(selectUnitId);
predicateBuilder.eq("createUnitId", selectUnitId);
return matchingDeviceLibraryDao.findAll(predicateBuilder.build());
}
}
......@@ -221,6 +221,13 @@ public class MatchingDeviceLibraryServiceImpl implements MatchingDeviceLibrarySe
}
}
@Override
public List<MatchingDeviceLibrary> getMatchingByUnitIdAll(Integer unitId) {
List<Integer> unitIds = userPublicService.findByUnitIdSubordinateAll(unitId).stream().map(Units::getUnitId).collect(Collectors.toList());
return matchingDeviceLibraryDao.findAllByCreateUnitIdIn(unitIds);
}
/**
* @return 所有类型
*/
......
......@@ -537,12 +537,9 @@ public class StatisticalServiceImpl implements StatisticalService {
// }else {
// workBench.setMatchingDeviceNum(0);
// }
MatchingDeviceSelectVo matchingDeviceSelectVo = new MatchingDeviceSelectVo();
//通过单位id查询区域id
Integer currentUnitId = userUtils.getCurrentUnitId();
Units units = unitsService.findById(currentUnitId);
matchingDeviceSelectVo.setAreaId(units.getAreaId());
List<MatchingDeviceLibrary> matchingDevicePage = matchingDeviceLibraryService.getMatchingDevicePage(matchingDeviceSelectVo);
List<MatchingDeviceLibrary> matchingDevicePage = matchingDeviceLibraryService.getMatchingByUnitIdAll(currentUnitId);
if (!matchingDevicePage.isEmpty()){
workBench.setMatchingDeviceNum(matchingDevicePage.size());
}else {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论