|
|
|
@ -1,23 +1,34 @@
|
|
|
|
|
package jnpf.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
import jnpf.entity.*;
|
|
|
|
|
import jnpf.mapper.YysDeviceWarnMapper;
|
|
|
|
|
import jnpf.service.*;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import jnpf.model.yysdevicewarn.*;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import jnpf.permission.model.authorize.AuthorizeConditionModel;
|
|
|
|
|
import jnpf.util.GeneraterSwapUtil;
|
|
|
|
|
import jnpf.database.model.superQuery.SuperQueryJsonModel;
|
|
|
|
|
import jnpf.database.model.superQuery.ConditionJsonModel;
|
|
|
|
|
import jnpf.database.model.superQuery.SuperQueryConditionModel;
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.annotation.TableField;
|
|
|
|
|
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
|
|
import jnpf.model.QueryModel;
|
|
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import jnpf.base.model.ColumnDataModel;
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import jnpf.database.model.superQuery.SuperJsonModel;
|
|
|
|
@ -25,13 +36,17 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
|
|
|
|
|
import jnpf.util.*;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
import jnpf.base.UserInfo;
|
|
|
|
|
import jnpf.permission.entity.UserEntity;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* yysDeviceWarn
|
|
|
|
|
* 版本: V3.5
|
|
|
|
|
* 版权: 引迈信息技术有限公司(https://www.jnpfsoft.com)
|
|
|
|
@ -39,7 +54,7 @@ import jnpf.permission.entity.UserEntity;
|
|
|
|
|
* 日期: 2024-08-09
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
public class YysDeviceWarnServiceImpl extends ServiceImpl<YysDeviceWarnMapper, YysDeviceWarnEntity> implements YysDeviceWarnService{
|
|
|
|
|
public class YysDeviceWarnServiceImpl extends ServiceImpl<YysDeviceWarnMapper, YysDeviceWarnEntity> implements YysDeviceWarnService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private GeneraterSwapUtil generaterSwapUtil;
|
|
|
|
|
|
|
|
|
@ -47,233 +62,298 @@ public class YysDeviceWarnServiceImpl extends ServiceImpl<YysDeviceWarnMapper, Y
|
|
|
|
|
private UserProvider userProvider;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<YysDeviceWarnEntity> getList(YysDeviceWarnPagination yysDeviceWarnPagination){
|
|
|
|
|
return getTypeList(yysDeviceWarnPagination,yysDeviceWarnPagination.getDataType());
|
|
|
|
|
public List<YysDeviceWarnEntity> getList(YysDeviceWarnPagination yysDeviceWarnPagination) {
|
|
|
|
|
return getTypeList(yysDeviceWarnPagination, yysDeviceWarnPagination.getDataType());
|
|
|
|
|
}
|
|
|
|
|
/** 列表查询 */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 列表查询
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<YysDeviceWarnEntity> getTypeList(YysDeviceWarnPagination yysDeviceWarnPagination,String dataType){
|
|
|
|
|
String userId=userProvider.get().getUserId();
|
|
|
|
|
List<String> AllIdList =new ArrayList();
|
|
|
|
|
List<List<String>> intersectionList =new ArrayList<>();
|
|
|
|
|
public List<YysDeviceWarnEntity> getTypeList(YysDeviceWarnPagination yysDeviceWarnPagination, String dataType) {
|
|
|
|
|
String userId = userProvider.get().getUserId();
|
|
|
|
|
List<String> AllIdList = new ArrayList();
|
|
|
|
|
List<List<String>> intersectionList = new ArrayList<>();
|
|
|
|
|
boolean isPc = ServletUtil.getHeader("jnpf-origin").equals("pc");
|
|
|
|
|
String columnData = !isPc ? YysDeviceWarnConstant.getAppColumnData() : YysDeviceWarnConstant.getColumnData();
|
|
|
|
|
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class);
|
|
|
|
|
String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList());
|
|
|
|
|
|
|
|
|
|
int total=0;
|
|
|
|
|
int yysDeviceWarnNum =0;
|
|
|
|
|
QueryWrapper<YysDeviceWarnEntity> yysDeviceWarnQueryWrapper=new QueryWrapper<>();
|
|
|
|
|
int total = 0;
|
|
|
|
|
int yysDeviceWarnNum = 0;
|
|
|
|
|
QueryWrapper<YysDeviceWarnEntity> yysDeviceWarnQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
List<String> allSuperIDlist = new ArrayList<>();
|
|
|
|
|
String superOp ="";
|
|
|
|
|
if (ObjectUtil.isNotEmpty(yysDeviceWarnPagination.getSuperQueryJson())){
|
|
|
|
|
String superOp = "";
|
|
|
|
|
if (ObjectUtil.isNotEmpty(yysDeviceWarnPagination.getSuperQueryJson())) {
|
|
|
|
|
List<String> allSuperList = new ArrayList<>();
|
|
|
|
|
List<List<String>> intersectionSuperList = new ArrayList<>();
|
|
|
|
|
List<List<String>> intersectionSuperList = new ArrayList<>();
|
|
|
|
|
String queryJson = yysDeviceWarnPagination.getSuperQueryJson();
|
|
|
|
|
SuperJsonModel superJsonModel = JsonUtil.getJsonToBean(queryJson, SuperJsonModel.class);
|
|
|
|
|
int superNum = 0;
|
|
|
|
|
QueryWrapper<YysDeviceWarnEntity> yysDeviceWarnSuperWrapper = new QueryWrapper<>();
|
|
|
|
|
yysDeviceWarnSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysDeviceWarnSuperWrapper,YysDeviceWarnEntity.class,queryJson,"0"));
|
|
|
|
|
yysDeviceWarnSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysDeviceWarnSuperWrapper, YysDeviceWarnEntity.class, queryJson, "0"));
|
|
|
|
|
int yysDeviceWarnNum1 = yysDeviceWarnSuperWrapper.getExpression().getNormal().size();
|
|
|
|
|
if (yysDeviceWarnNum1>0){
|
|
|
|
|
List<String> yysDeviceWarnList =this.list(yysDeviceWarnSuperWrapper).stream().map(YysDeviceWarnEntity::getId).collect(Collectors.toList());
|
|
|
|
|
if (yysDeviceWarnNum1 > 0) {
|
|
|
|
|
List<String> yysDeviceWarnList = this.list(yysDeviceWarnSuperWrapper).stream().map(YysDeviceWarnEntity::getId).collect(Collectors.toList());
|
|
|
|
|
allSuperList.addAll(yysDeviceWarnList);
|
|
|
|
|
intersectionSuperList.add(yysDeviceWarnList);
|
|
|
|
|
superNum++;
|
|
|
|
|
}
|
|
|
|
|
superOp = superNum > 0 ? superJsonModel.getMatchLogic() : "";
|
|
|
|
|
//and or
|
|
|
|
|
if(superOp.equalsIgnoreCase("and")){
|
|
|
|
|
if (superOp.equalsIgnoreCase("and")) {
|
|
|
|
|
allSuperIDlist = generaterSwapUtil.getIntersection(intersectionSuperList);
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
allSuperIDlist = allSuperList;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
List<String> allRuleIDlist = new ArrayList<>();
|
|
|
|
|
String ruleOp ="";
|
|
|
|
|
if (ObjectUtil.isNotEmpty(ruleJson)){
|
|
|
|
|
String ruleOp = "";
|
|
|
|
|
if (ObjectUtil.isNotEmpty(ruleJson)) {
|
|
|
|
|
List<String> allRuleList = new ArrayList<>();
|
|
|
|
|
List<List<String>> intersectionRuleList = new ArrayList<>();
|
|
|
|
|
List<List<String>> intersectionRuleList = new ArrayList<>();
|
|
|
|
|
SuperJsonModel ruleJsonModel = JsonUtil.getJsonToBean(ruleJson, SuperJsonModel.class);
|
|
|
|
|
int ruleNum = 0;
|
|
|
|
|
QueryWrapper<YysDeviceWarnEntity> yysDeviceWarnSuperWrapper = new QueryWrapper<>();
|
|
|
|
|
yysDeviceWarnSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysDeviceWarnSuperWrapper,YysDeviceWarnEntity.class,ruleJson,"0"));
|
|
|
|
|
yysDeviceWarnSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysDeviceWarnSuperWrapper, YysDeviceWarnEntity.class, ruleJson, "0"));
|
|
|
|
|
int yysDeviceWarnNum1 = yysDeviceWarnSuperWrapper.getExpression().getNormal().size();
|
|
|
|
|
if (yysDeviceWarnNum1>0){
|
|
|
|
|
List<String> yysDeviceWarnList =this.list(yysDeviceWarnSuperWrapper).stream().map(YysDeviceWarnEntity::getId).collect(Collectors.toList());
|
|
|
|
|
if (yysDeviceWarnNum1 > 0) {
|
|
|
|
|
List<String> yysDeviceWarnList = this.list(yysDeviceWarnSuperWrapper).stream().map(YysDeviceWarnEntity::getId).collect(Collectors.toList());
|
|
|
|
|
allRuleList.addAll(yysDeviceWarnList);
|
|
|
|
|
intersectionRuleList.add(yysDeviceWarnList);
|
|
|
|
|
ruleNum++;
|
|
|
|
|
}
|
|
|
|
|
ruleOp = ruleNum > 0 ? ruleJsonModel.getMatchLogic() : "";
|
|
|
|
|
//and or
|
|
|
|
|
if(ruleOp.equalsIgnoreCase("and")){
|
|
|
|
|
if (ruleOp.equalsIgnoreCase("and")) {
|
|
|
|
|
allRuleIDlist = generaterSwapUtil.getIntersection(intersectionRuleList);
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
allRuleIDlist = allRuleList;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
boolean pcPermission = false;
|
|
|
|
|
boolean appPermission = false;
|
|
|
|
|
if(isPc && pcPermission){
|
|
|
|
|
if (!userProvider.get().getIsAdministrator()){
|
|
|
|
|
Object yysDeviceWarnObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysDeviceWarnQueryWrapper,YysDeviceWarnEntity.class,yysDeviceWarnPagination.getMenuId(),"0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(yysDeviceWarnObj)){
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
yysDeviceWarnQueryWrapper = (QueryWrapper<YysDeviceWarnEntity>)yysDeviceWarnObj;
|
|
|
|
|
if( yysDeviceWarnQueryWrapper.getExpression().getNormal().size()>0){
|
|
|
|
|
yysDeviceWarnNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!isPc && appPermission){
|
|
|
|
|
if (!userProvider.get().getIsAdministrator()){
|
|
|
|
|
Object yysDeviceWarnObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysDeviceWarnQueryWrapper,YysDeviceWarnEntity.class,yysDeviceWarnPagination.getMenuId(),"0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(yysDeviceWarnObj)){
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
yysDeviceWarnQueryWrapper = (QueryWrapper<YysDeviceWarnEntity>)yysDeviceWarnObj;
|
|
|
|
|
if( yysDeviceWarnQueryWrapper.getExpression().getNormal().size()>0){
|
|
|
|
|
yysDeviceWarnNum++;
|
|
|
|
|
}
|
|
|
|
|
boolean pcPermission = false;
|
|
|
|
|
boolean appPermission = false;
|
|
|
|
|
if (isPc && pcPermission) {
|
|
|
|
|
if (!userProvider.get().getIsAdministrator()) {
|
|
|
|
|
Object yysDeviceWarnObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysDeviceWarnQueryWrapper, YysDeviceWarnEntity.class, yysDeviceWarnPagination.getMenuId(), "0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(yysDeviceWarnObj)) {
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
yysDeviceWarnQueryWrapper = (QueryWrapper<YysDeviceWarnEntity>) yysDeviceWarnObj;
|
|
|
|
|
if (yysDeviceWarnQueryWrapper.getExpression().getNormal().size() > 0) {
|
|
|
|
|
yysDeviceWarnNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!isPc && appPermission) {
|
|
|
|
|
if (!userProvider.get().getIsAdministrator()) {
|
|
|
|
|
Object yysDeviceWarnObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysDeviceWarnQueryWrapper, YysDeviceWarnEntity.class, yysDeviceWarnPagination.getMenuId(), "0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(yysDeviceWarnObj)) {
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
yysDeviceWarnQueryWrapper = (QueryWrapper<YysDeviceWarnEntity>) yysDeviceWarnObj;
|
|
|
|
|
if (yysDeviceWarnQueryWrapper.getExpression().getNormal().size() > 0) {
|
|
|
|
|
yysDeviceWarnNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(isPc){
|
|
|
|
|
if(ObjectUtil.isNotEmpty(yysDeviceWarnPagination.getProductionLine())){
|
|
|
|
|
yysDeviceWarnNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (isPc) {
|
|
|
|
|
if (ObjectUtil.isNotEmpty(yysDeviceWarnPagination.getProductionLine())) {
|
|
|
|
|
yysDeviceWarnNum++;
|
|
|
|
|
|
|
|
|
|
String value = yysDeviceWarnPagination.getProductionLine() instanceof List ?
|
|
|
|
|
JsonUtil.getObjectToString(yysDeviceWarnPagination.getProductionLine()) :
|
|
|
|
|
String.valueOf(yysDeviceWarnPagination.getProductionLine());
|
|
|
|
|
yysDeviceWarnQueryWrapper.lambda().like(YysDeviceWarnEntity::getProductionLine,value);
|
|
|
|
|
JsonUtil.getObjectToString(yysDeviceWarnPagination.getProductionLine()) :
|
|
|
|
|
String.valueOf(yysDeviceWarnPagination.getProductionLine());
|
|
|
|
|
yysDeviceWarnQueryWrapper.lambda().like(YysDeviceWarnEntity::getProductionLine, value);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ObjectUtil.isNotEmpty(yysDeviceWarnPagination.getCreatorTime())){
|
|
|
|
|
yysDeviceWarnNum++;
|
|
|
|
|
if (ObjectUtil.isNotEmpty(yysDeviceWarnPagination.getCreatorTime())) {
|
|
|
|
|
yysDeviceWarnNum++;
|
|
|
|
|
|
|
|
|
|
List CreatorTimeList = JsonUtil.getJsonToList(yysDeviceWarnPagination.getCreatorTime(),String.class);
|
|
|
|
|
String fir = String.valueOf(CreatorTimeList.get(0));
|
|
|
|
|
String sec = String.valueOf(CreatorTimeList.get(1));
|
|
|
|
|
yysDeviceWarnQueryWrapper.lambda().ge(YysDeviceWarnEntity::getCreatorTime, fir)
|
|
|
|
|
.le(YysDeviceWarnEntity::getCreatorTime, sec);
|
|
|
|
|
List CreatorTimeList = JsonUtil.getJsonToList(yysDeviceWarnPagination.getCreatorTime(), String.class);
|
|
|
|
|
String fir = String.valueOf(CreatorTimeList.get(0));
|
|
|
|
|
String sec = String.valueOf(CreatorTimeList.get(1));
|
|
|
|
|
yysDeviceWarnQueryWrapper.lambda().ge(YysDeviceWarnEntity::getCreatorTime, fir)
|
|
|
|
|
.le(YysDeviceWarnEntity::getCreatorTime, sec);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
List<String> intersection = generaterSwapUtil.getIntersection(intersectionList);
|
|
|
|
|
if (total>0){
|
|
|
|
|
if (intersection.size()==0){
|
|
|
|
|
if (total > 0) {
|
|
|
|
|
if (intersection.size() == 0) {
|
|
|
|
|
intersection.add("jnpfNullList");
|
|
|
|
|
}
|
|
|
|
|
yysDeviceWarnQueryWrapper.lambda().in(YysDeviceWarnEntity::getId, intersection);
|
|
|
|
|
}
|
|
|
|
|
//是否有高级查询
|
|
|
|
|
if (StringUtil.isNotEmpty(superOp)){
|
|
|
|
|
if (allSuperIDlist.size()==0){
|
|
|
|
|
//是否有高级查询
|
|
|
|
|
if (StringUtil.isNotEmpty(superOp)) {
|
|
|
|
|
if (allSuperIDlist.size() == 0) {
|
|
|
|
|
allSuperIDlist.add("jnpfNullList");
|
|
|
|
|
}
|
|
|
|
|
List<String> finalAllSuperIDlist = allSuperIDlist;
|
|
|
|
|
yysDeviceWarnQueryWrapper.lambda().and(t->t.in(YysDeviceWarnEntity::getId, finalAllSuperIDlist));
|
|
|
|
|
yysDeviceWarnQueryWrapper.lambda().and(t -> t.in(YysDeviceWarnEntity::getId, finalAllSuperIDlist));
|
|
|
|
|
}
|
|
|
|
|
//是否有数据过滤查询
|
|
|
|
|
if (StringUtil.isNotEmpty(ruleOp)){
|
|
|
|
|
if (allRuleIDlist.size()==0){
|
|
|
|
|
//是否有数据过滤查询
|
|
|
|
|
if (StringUtil.isNotEmpty(ruleOp)) {
|
|
|
|
|
if (allRuleIDlist.size() == 0) {
|
|
|
|
|
allRuleIDlist.add("jnpfNullList");
|
|
|
|
|
}
|
|
|
|
|
List<String> finalAllRuleIDlist = allRuleIDlist;
|
|
|
|
|
yysDeviceWarnQueryWrapper.lambda().and(t->t.in(YysDeviceWarnEntity::getId, finalAllRuleIDlist));
|
|
|
|
|
yysDeviceWarnQueryWrapper.lambda().and(t -> t.in(YysDeviceWarnEntity::getId, finalAllRuleIDlist));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//排序
|
|
|
|
|
if(StringUtil.isEmpty(yysDeviceWarnPagination.getSidx())){
|
|
|
|
|
if (StringUtil.isEmpty(yysDeviceWarnPagination.getSidx())) {
|
|
|
|
|
yysDeviceWarnQueryWrapper.lambda().orderByDesc(YysDeviceWarnEntity::getId);
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
try {
|
|
|
|
|
String sidx = yysDeviceWarnPagination.getSidx();
|
|
|
|
|
String[] strs= sidx.split("_name");
|
|
|
|
|
String[] strs = sidx.split("_name");
|
|
|
|
|
YysDeviceWarnEntity yysDeviceWarnEntity = new YysDeviceWarnEntity();
|
|
|
|
|
Field declaredField = yysDeviceWarnEntity.getClass().getDeclaredField(strs[0]);
|
|
|
|
|
declaredField.setAccessible(true);
|
|
|
|
|
String value = declaredField.getAnnotation(TableField.class).value();
|
|
|
|
|
yysDeviceWarnQueryWrapper="asc".equals(yysDeviceWarnPagination.getSort().toLowerCase())?yysDeviceWarnQueryWrapper.orderByAsc(value):yysDeviceWarnQueryWrapper.orderByDesc(value);
|
|
|
|
|
yysDeviceWarnQueryWrapper = "asc".equals(yysDeviceWarnPagination.getSort().toLowerCase()) ? yysDeviceWarnQueryWrapper.orderByAsc(value) : yysDeviceWarnQueryWrapper.orderByDesc(value);
|
|
|
|
|
} catch (NoSuchFieldException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if("0".equals(dataType)){
|
|
|
|
|
if((total>0 && AllIdList.size()>0) || total==0){
|
|
|
|
|
Page<YysDeviceWarnEntity> page=new Page<>(yysDeviceWarnPagination.getCurrentPage(), yysDeviceWarnPagination.getPageSize());
|
|
|
|
|
IPage<YysDeviceWarnEntity> userIPage=this.page(page, yysDeviceWarnQueryWrapper);
|
|
|
|
|
return yysDeviceWarnPagination.setData(userIPage.getRecords(),userIPage.getTotal());
|
|
|
|
|
}else{
|
|
|
|
|
if ("0".equals(dataType)) {
|
|
|
|
|
if ((total > 0 && AllIdList.size() > 0) || total == 0) {
|
|
|
|
|
Page<YysDeviceWarnEntity> page = new Page<>(yysDeviceWarnPagination.getCurrentPage(), yysDeviceWarnPagination.getPageSize());
|
|
|
|
|
IPage<YysDeviceWarnEntity> userIPage = this.page(page, yysDeviceWarnQueryWrapper);
|
|
|
|
|
return yysDeviceWarnPagination.setData(userIPage.getRecords(), userIPage.getTotal());
|
|
|
|
|
} else {
|
|
|
|
|
List<YysDeviceWarnEntity> list = new ArrayList();
|
|
|
|
|
return yysDeviceWarnPagination.setData(list, list.size());
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
return this.list(yysDeviceWarnQueryWrapper);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public YysDeviceWarnEntity getInfo(String id){
|
|
|
|
|
QueryWrapper<YysDeviceWarnEntity> queryWrapper=new QueryWrapper<>();
|
|
|
|
|
queryWrapper.lambda().eq(YysDeviceWarnEntity::getId,id);
|
|
|
|
|
public YysDeviceWarnEntity getInfo(String id) {
|
|
|
|
|
QueryWrapper<YysDeviceWarnEntity> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper.lambda().eq(YysDeviceWarnEntity::getId, id);
|
|
|
|
|
return this.getOne(queryWrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void create(YysDeviceWarnEntity entity){
|
|
|
|
|
public void create(YysDeviceWarnEntity entity) {
|
|
|
|
|
this.save(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean update(String id, YysDeviceWarnEntity entity){
|
|
|
|
|
public boolean update(String id, YysDeviceWarnEntity entity) {
|
|
|
|
|
return this.updateById(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void delete(YysDeviceWarnEntity entity){
|
|
|
|
|
if(entity!=null){
|
|
|
|
|
public void delete(YysDeviceWarnEntity entity) {
|
|
|
|
|
if (entity != null) {
|
|
|
|
|
this.removeById(entity.getId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/** 验证表单唯一字段,正则,非空 i-0新增-1修改*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 验证表单唯一字段,正则,非空 i-0新增-1修改
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public String checkForm(YysDeviceWarnForm form,int i) {
|
|
|
|
|
boolean isUp =StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0");
|
|
|
|
|
String id="";
|
|
|
|
|
public String checkForm(YysDeviceWarnForm form, int i) {
|
|
|
|
|
boolean isUp = StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0");
|
|
|
|
|
String id = "";
|
|
|
|
|
String countRecover = "";
|
|
|
|
|
if (isUp){
|
|
|
|
|
if (isUp) {
|
|
|
|
|
id = form.getId();
|
|
|
|
|
}
|
|
|
|
|
//主表字段验证
|
|
|
|
|
return countRecover;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增修改数据(事务回滚)
|
|
|
|
|
* @param id
|
|
|
|
|
* @param yysDeviceWarnForm
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
* 新增修改数据(事务回滚)
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
* @param yysDeviceWarnForm
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public void saveOrUpdate(YysDeviceWarnForm yysDeviceWarnForm,String id, boolean isSave) throws Exception{
|
|
|
|
|
UserInfo userInfo=userProvider.get();
|
|
|
|
|
public void saveOrUpdate(YysDeviceWarnForm yysDeviceWarnForm, String id, boolean isSave) throws Exception {
|
|
|
|
|
UserInfo userInfo = userProvider.get();
|
|
|
|
|
UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId());
|
|
|
|
|
yysDeviceWarnForm = JsonUtil.getJsonToBean(
|
|
|
|
|
generaterSwapUtil.swapDatetime(YysDeviceWarnConstant.getFormData(),yysDeviceWarnForm),YysDeviceWarnForm.class);
|
|
|
|
|
generaterSwapUtil.swapDatetime(YysDeviceWarnConstant.getFormData(), yysDeviceWarnForm), YysDeviceWarnForm.class);
|
|
|
|
|
YysDeviceWarnEntity entity = JsonUtil.getJsonToBean(yysDeviceWarnForm, YysDeviceWarnEntity.class);
|
|
|
|
|
|
|
|
|
|
if(isSave){
|
|
|
|
|
String mainId = RandomUtil.uuId() ;
|
|
|
|
|
if (isSave) {
|
|
|
|
|
String mainId = RandomUtil.uuId();
|
|
|
|
|
entity.setId(mainId);
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
}
|
|
|
|
|
this.saveOrUpdate(entity);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void syncCount(List<YysDeviceWarnStatisticsEntity> collect) {
|
|
|
|
|
if (CollectionUtils.isEmpty(collect)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Map<String, List<YysDeviceWarnStatisticsEntity>> collect1 = collect
|
|
|
|
|
.stream().collect(Collectors.groupingBy(entity -> String.join("-", entity.getDeviceName(), entity.getWarnType(), entity.getWarnDetails())));
|
|
|
|
|
|
|
|
|
|
LambdaQueryWrapper<YysDeviceWarnEntity> wrapper = new LambdaQueryWrapper<>(YysDeviceWarnEntity.class);
|
|
|
|
|
wrapper.isNull(YysDeviceWarnEntity::getDeleteMark);
|
|
|
|
|
List<YysDeviceWarnEntity> list = this.list(wrapper);
|
|
|
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
|
|
|
List<YysDeviceWarnEntity> result = Lists.newArrayList();
|
|
|
|
|
for (Map.Entry<String, List<YysDeviceWarnStatisticsEntity>> entry : collect1.entrySet()) {
|
|
|
|
|
String mainId = RandomUtil.uuId();
|
|
|
|
|
YysDeviceWarnStatisticsEntity entity1 = entry.getValue().get(0);
|
|
|
|
|
YysDeviceWarnEntity entity = new YysDeviceWarnEntity();
|
|
|
|
|
entity.setId(mainId);
|
|
|
|
|
entity.setProductionLine(entity1.getDeviceName());
|
|
|
|
|
entity.setProductionTime(entity1.getProductionTime());
|
|
|
|
|
entity.setWarnName(entity1.getWarnType());
|
|
|
|
|
entity.setWarnDetails(entity1.getWarnDetails());
|
|
|
|
|
entity.setWarnNums(String.valueOf(entry.getValue().size()));
|
|
|
|
|
entity.setCreatorUserId(userProvider.get().getUserId());
|
|
|
|
|
entity.setCreatorTime(DateUtil.getNowDate());
|
|
|
|
|
result.add(entity);
|
|
|
|
|
}
|
|
|
|
|
this.saveBatch(result);
|
|
|
|
|
} else {
|
|
|
|
|
for (YysDeviceWarnEntity entity : list) {
|
|
|
|
|
String key = String.join("-", entity.getProductionLine(), entity.getWarnName(), entity.getWarnDetails());
|
|
|
|
|
if (collect1.containsKey(key)) {
|
|
|
|
|
entity.setWarnNums(String.valueOf(Integer.parseInt(entity.getWarnNums()) + collect1.get(key).size()));
|
|
|
|
|
} else {
|
|
|
|
|
List<YysDeviceWarnStatisticsEntity> entities = collect1.get(key);
|
|
|
|
|
String mainId = RandomUtil.uuId();
|
|
|
|
|
YysDeviceWarnStatisticsEntity entity2 = entities.get(0);
|
|
|
|
|
YysDeviceWarnEntity entity3 = new YysDeviceWarnEntity();
|
|
|
|
|
entity3.setId(mainId);
|
|
|
|
|
entity3.setProductionLine(entity2.getDeviceName());
|
|
|
|
|
entity3.setProductionTime(entity2.getProductionTime());
|
|
|
|
|
entity3.setWarnName(entity2.getWarnType());
|
|
|
|
|
entity3.setWarnDetails(entity2.getWarnDetails());
|
|
|
|
|
entity3.setWarnNums(String.valueOf(entities.size()));
|
|
|
|
|
entity3.setCreatorUserId(userProvider.get().getUserId());
|
|
|
|
|
entity3.setCreatorTime(DateUtil.getNowDate());
|
|
|
|
|
list.add(entity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.saveOrUpdateBatch(list);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|