|
|
|
@ -1,35 +1,14 @@
|
|
|
|
|
package jnpf.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import jnpf.entity.*;
|
|
|
|
|
import jnpf.mapper.RecycleDeviceMapper;
|
|
|
|
|
import jnpf.permission.entity.OrganizeEntity;
|
|
|
|
|
import jnpf.service.*;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import jnpf.model.recycledevice.*;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import cn.hutool.http.HttpRequest;
|
|
|
|
|
import cn.hutool.http.HttpResponse;
|
|
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.annotation.TableField;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
import jnpf.model.QueryModel;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
import jnpf.base.model.ColumnDataModel;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
@ -43,20 +22,24 @@ import jnpf.model.recycledevice.RecycleDeviceConstant;
|
|
|
|
|
import jnpf.model.recycledevice.RecycleDeviceForm;
|
|
|
|
|
import jnpf.model.recycledevice.RecycleDevicePagination;
|
|
|
|
|
import jnpf.permission.entity.UserEntity;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
import jnpf.service.RecycleDeviceService;
|
|
|
|
|
import jnpf.util.*;
|
|
|
|
|
import okhttp3.*;
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* 设备柜清单
|
|
|
|
|
* 版本: V3.5
|
|
|
|
|
* 版权: 引迈信息技术有限公司(https://www.jnpfsoft.com)
|
|
|
|
@ -64,7 +47,7 @@ import java.util.stream.Collectors;
|
|
|
|
|
* 日期: 2024-06-22
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
public class RecycleDeviceServiceImpl extends ServiceImpl<RecycleDeviceMapper, RecycleDeviceEntity> implements RecycleDeviceService{
|
|
|
|
|
public class RecycleDeviceServiceImpl extends ServiceImpl<RecycleDeviceMapper, RecycleDeviceEntity> implements RecycleDeviceService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private GeneraterSwapUtil generaterSwapUtil;
|
|
|
|
|
|
|
|
|
@ -76,317 +59,376 @@ public class RecycleDeviceServiceImpl extends ServiceImpl<RecycleDeviceMapper, R
|
|
|
|
|
@Value("${nxhs.url}")
|
|
|
|
|
private String wx_url;
|
|
|
|
|
|
|
|
|
|
@Value("${mqtt.host}")
|
|
|
|
|
private String HOST;
|
|
|
|
|
|
|
|
|
|
@Value("${mqtt.username}")
|
|
|
|
|
private String USERNAME;
|
|
|
|
|
|
|
|
|
|
@Value("${mqtt.password}")
|
|
|
|
|
private String PASSWORD;
|
|
|
|
|
|
|
|
|
|
@Value("${mqtt.authentication-method}")
|
|
|
|
|
private String AUTH;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 添加用户url
|
|
|
|
|
*/
|
|
|
|
|
private static final String SAVE_URL = "/api/v5/authentication/{id}/users";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除用户url
|
|
|
|
|
*/
|
|
|
|
|
private static final String DELETE_URL = "/api/v5/authentication/{id}/users/{user_id}";
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<RecycleDeviceEntity> getList(RecycleDevicePagination recycleDevicePagination){
|
|
|
|
|
return getTypeList(recycleDevicePagination,recycleDevicePagination.getDataType());
|
|
|
|
|
public List<RecycleDeviceEntity> getList(RecycleDevicePagination recycleDevicePagination) {
|
|
|
|
|
return getTypeList(recycleDevicePagination, recycleDevicePagination.getDataType());
|
|
|
|
|
}
|
|
|
|
|
/** 列表查询 */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 列表查询
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<RecycleDeviceEntity> getTypeList(RecycleDevicePagination recycleDevicePagination,String dataType){
|
|
|
|
|
String userId=userProvider.get().getUserId();
|
|
|
|
|
List<String> AllIdList =new ArrayList();
|
|
|
|
|
List<List<String>> intersectionList =new ArrayList<>();
|
|
|
|
|
public List<RecycleDeviceEntity> getTypeList(RecycleDevicePagination recycleDevicePagination, 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 ? RecycleDeviceConstant.getAppColumnData() : RecycleDeviceConstant.getColumnData();
|
|
|
|
|
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class);
|
|
|
|
|
String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList());
|
|
|
|
|
|
|
|
|
|
int total=0;
|
|
|
|
|
int recycleDeviceNum =0;
|
|
|
|
|
QueryWrapper<RecycleDeviceEntity> recycleDeviceQueryWrapper=new QueryWrapper<>();
|
|
|
|
|
int total = 0;
|
|
|
|
|
int recycleDeviceNum = 0;
|
|
|
|
|
QueryWrapper<RecycleDeviceEntity> recycleDeviceQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
List<String> allSuperIDlist = new ArrayList<>();
|
|
|
|
|
String superOp ="";
|
|
|
|
|
if (ObjectUtil.isNotEmpty(recycleDevicePagination.getSuperQueryJson())){
|
|
|
|
|
String superOp = "";
|
|
|
|
|
if (ObjectUtil.isNotEmpty(recycleDevicePagination.getSuperQueryJson())) {
|
|
|
|
|
List<String> allSuperList = new ArrayList<>();
|
|
|
|
|
List<List<String>> intersectionSuperList = new ArrayList<>();
|
|
|
|
|
List<List<String>> intersectionSuperList = new ArrayList<>();
|
|
|
|
|
String queryJson = recycleDevicePagination.getSuperQueryJson();
|
|
|
|
|
SuperJsonModel superJsonModel = JsonUtil.getJsonToBean(queryJson, SuperJsonModel.class);
|
|
|
|
|
int superNum = 0;
|
|
|
|
|
QueryWrapper<RecycleDeviceEntity> recycleDeviceSuperWrapper = new QueryWrapper<>();
|
|
|
|
|
recycleDeviceSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(recycleDeviceSuperWrapper,RecycleDeviceEntity.class,queryJson,"0"));
|
|
|
|
|
recycleDeviceSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(recycleDeviceSuperWrapper, RecycleDeviceEntity.class, queryJson, "0"));
|
|
|
|
|
int recycleDeviceNum1 = recycleDeviceSuperWrapper.getExpression().getNormal().size();
|
|
|
|
|
if (recycleDeviceNum1>0){
|
|
|
|
|
List<String> recycleDeviceList =this.list(recycleDeviceSuperWrapper).stream().map(RecycleDeviceEntity::getId).collect(Collectors.toList());
|
|
|
|
|
if (recycleDeviceNum1 > 0) {
|
|
|
|
|
List<String> recycleDeviceList = this.list(recycleDeviceSuperWrapper).stream().map(RecycleDeviceEntity::getId).collect(Collectors.toList());
|
|
|
|
|
allSuperList.addAll(recycleDeviceList);
|
|
|
|
|
intersectionSuperList.add(recycleDeviceList);
|
|
|
|
|
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<RecycleDeviceEntity> recycleDeviceSuperWrapper = new QueryWrapper<>();
|
|
|
|
|
recycleDeviceSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(recycleDeviceSuperWrapper,RecycleDeviceEntity.class,ruleJson,"0"));
|
|
|
|
|
recycleDeviceSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(recycleDeviceSuperWrapper, RecycleDeviceEntity.class, ruleJson, "0"));
|
|
|
|
|
int recycleDeviceNum1 = recycleDeviceSuperWrapper.getExpression().getNormal().size();
|
|
|
|
|
if (recycleDeviceNum1>0){
|
|
|
|
|
List<String> recycleDeviceList =this.list(recycleDeviceSuperWrapper).stream().map(RecycleDeviceEntity::getId).collect(Collectors.toList());
|
|
|
|
|
if (recycleDeviceNum1 > 0) {
|
|
|
|
|
List<String> recycleDeviceList = this.list(recycleDeviceSuperWrapper).stream().map(RecycleDeviceEntity::getId).collect(Collectors.toList());
|
|
|
|
|
allRuleList.addAll(recycleDeviceList);
|
|
|
|
|
intersectionRuleList.add(recycleDeviceList);
|
|
|
|
|
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 = true;
|
|
|
|
|
boolean appPermission = false;
|
|
|
|
|
if(isPc && pcPermission){
|
|
|
|
|
if (!userProvider.get().getIsAdministrator()){
|
|
|
|
|
Object recycleDeviceObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(recycleDeviceQueryWrapper,RecycleDeviceEntity.class,recycleDevicePagination.getMenuId(),"0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(recycleDeviceObj)){
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
recycleDeviceQueryWrapper = (QueryWrapper<RecycleDeviceEntity>)recycleDeviceObj;
|
|
|
|
|
if( recycleDeviceQueryWrapper.getExpression().getNormal().size()>0){
|
|
|
|
|
recycleDeviceNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!isPc && appPermission){
|
|
|
|
|
if (!userProvider.get().getIsAdministrator()){
|
|
|
|
|
Object recycleDeviceObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(recycleDeviceQueryWrapper,RecycleDeviceEntity.class,recycleDevicePagination.getMenuId(),"0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(recycleDeviceObj)){
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
recycleDeviceQueryWrapper = (QueryWrapper<RecycleDeviceEntity>)recycleDeviceObj;
|
|
|
|
|
if( recycleDeviceQueryWrapper.getExpression().getNormal().size()>0){
|
|
|
|
|
recycleDeviceNum++;
|
|
|
|
|
}
|
|
|
|
|
boolean pcPermission = true;
|
|
|
|
|
boolean appPermission = false;
|
|
|
|
|
if (isPc && pcPermission) {
|
|
|
|
|
if (!userProvider.get().getIsAdministrator()) {
|
|
|
|
|
Object recycleDeviceObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(recycleDeviceQueryWrapper, RecycleDeviceEntity.class, recycleDevicePagination.getMenuId(), "0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(recycleDeviceObj)) {
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
recycleDeviceQueryWrapper = (QueryWrapper<RecycleDeviceEntity>) recycleDeviceObj;
|
|
|
|
|
if (recycleDeviceQueryWrapper.getExpression().getNormal().size() > 0) {
|
|
|
|
|
recycleDeviceNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!isPc && appPermission) {
|
|
|
|
|
if (!userProvider.get().getIsAdministrator()) {
|
|
|
|
|
Object recycleDeviceObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(recycleDeviceQueryWrapper, RecycleDeviceEntity.class, recycleDevicePagination.getMenuId(), "0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(recycleDeviceObj)) {
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
recycleDeviceQueryWrapper = (QueryWrapper<RecycleDeviceEntity>) recycleDeviceObj;
|
|
|
|
|
if (recycleDeviceQueryWrapper.getExpression().getNormal().size() > 0) {
|
|
|
|
|
recycleDeviceNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(isPc){
|
|
|
|
|
if(ObjectUtil.isNotEmpty(recycleDevicePagination.getBeLongCompanyId())){
|
|
|
|
|
recycleDeviceNum++;
|
|
|
|
|
|
|
|
|
|
List<String> idList = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
String[][] beLongCompanyId = JsonUtil.getJsonToBean(recycleDevicePagination.getBeLongCompanyId(),String[][].class);
|
|
|
|
|
for(int i=0;i<beLongCompanyId.length;i++){
|
|
|
|
|
if(beLongCompanyId[i].length>0){
|
|
|
|
|
idList.add(JsonUtil.getObjectToString(Arrays.asList(beLongCompanyId[i])));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e1){
|
|
|
|
|
try {
|
|
|
|
|
List<String> beLongCompanyId = JsonUtil.getJsonToList(recycleDevicePagination.getBeLongCompanyId(),String.class);
|
|
|
|
|
if(beLongCompanyId.size()>0){
|
|
|
|
|
idList.add(JsonUtil.getObjectToString(beLongCompanyId));
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e2){
|
|
|
|
|
idList.add(String.valueOf(recycleDevicePagination.getBeLongCompanyId()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
recycleDeviceQueryWrapper.lambda().and(t->{
|
|
|
|
|
idList.forEach(tt->{
|
|
|
|
|
t.like(RecycleDeviceEntity::getBeLongCompanyId, tt).or();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
if (isPc) {
|
|
|
|
|
if (ObjectUtil.isNotEmpty(recycleDevicePagination.getBeLongCompanyId())) {
|
|
|
|
|
recycleDeviceNum++;
|
|
|
|
|
|
|
|
|
|
List<String> idList = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
String[][] beLongCompanyId = JsonUtil.getJsonToBean(recycleDevicePagination.getBeLongCompanyId(), String[][].class);
|
|
|
|
|
for (int i = 0; i < beLongCompanyId.length; i++) {
|
|
|
|
|
if (beLongCompanyId[i].length > 0) {
|
|
|
|
|
idList.add(JsonUtil.getObjectToString(Arrays.asList(beLongCompanyId[i])));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e1) {
|
|
|
|
|
try {
|
|
|
|
|
List<String> beLongCompanyId = JsonUtil.getJsonToList(recycleDevicePagination.getBeLongCompanyId(), String.class);
|
|
|
|
|
if (beLongCompanyId.size() > 0) {
|
|
|
|
|
idList.add(JsonUtil.getObjectToString(beLongCompanyId));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e2) {
|
|
|
|
|
idList.add(String.valueOf(recycleDevicePagination.getBeLongCompanyId()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
recycleDeviceQueryWrapper.lambda().and(t -> {
|
|
|
|
|
idList.forEach(tt -> {
|
|
|
|
|
t.like(RecycleDeviceEntity::getBeLongCompanyId, tt).or();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ObjectUtil.isNotEmpty(recycleDevicePagination.getBeLongStationId())){
|
|
|
|
|
recycleDeviceNum++;
|
|
|
|
|
|
|
|
|
|
List<String> idList = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
String[][] beLongStationId = JsonUtil.getJsonToBean(recycleDevicePagination.getBeLongStationId(),String[][].class);
|
|
|
|
|
for(int i=0;i<beLongStationId.length;i++){
|
|
|
|
|
if(beLongStationId[i].length>0){
|
|
|
|
|
idList.add(JsonUtil.getObjectToString(Arrays.asList(beLongStationId[i])));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e1){
|
|
|
|
|
try {
|
|
|
|
|
List<String> beLongStationId = JsonUtil.getJsonToList(recycleDevicePagination.getBeLongStationId(),String.class);
|
|
|
|
|
if(beLongStationId.size()>0){
|
|
|
|
|
idList.add(JsonUtil.getObjectToString(beLongStationId));
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e2){
|
|
|
|
|
idList.add(String.valueOf(recycleDevicePagination.getBeLongStationId()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
recycleDeviceQueryWrapper.lambda().and(t->{
|
|
|
|
|
idList.forEach(tt->{
|
|
|
|
|
t.like(RecycleDeviceEntity::getBeLongStationId, tt).or();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
if (ObjectUtil.isNotEmpty(recycleDevicePagination.getBeLongStationId())) {
|
|
|
|
|
recycleDeviceNum++;
|
|
|
|
|
|
|
|
|
|
List<String> idList = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
String[][] beLongStationId = JsonUtil.getJsonToBean(recycleDevicePagination.getBeLongStationId(), String[][].class);
|
|
|
|
|
for (int i = 0; i < beLongStationId.length; i++) {
|
|
|
|
|
if (beLongStationId[i].length > 0) {
|
|
|
|
|
idList.add(JsonUtil.getObjectToString(Arrays.asList(beLongStationId[i])));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e1) {
|
|
|
|
|
try {
|
|
|
|
|
List<String> beLongStationId = JsonUtil.getJsonToList(recycleDevicePagination.getBeLongStationId(), String.class);
|
|
|
|
|
if (beLongStationId.size() > 0) {
|
|
|
|
|
idList.add(JsonUtil.getObjectToString(beLongStationId));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e2) {
|
|
|
|
|
idList.add(String.valueOf(recycleDevicePagination.getBeLongStationId()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
recycleDeviceQueryWrapper.lambda().and(t -> {
|
|
|
|
|
idList.forEach(tt -> {
|
|
|
|
|
t.like(RecycleDeviceEntity::getBeLongStationId, tt).or();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ObjectUtil.isNotEmpty(recycleDevicePagination.getDeviceCode())){
|
|
|
|
|
recycleDeviceNum++;
|
|
|
|
|
if (ObjectUtil.isNotEmpty(recycleDevicePagination.getDeviceCode())) {
|
|
|
|
|
recycleDeviceNum++;
|
|
|
|
|
|
|
|
|
|
String value = recycleDevicePagination.getDeviceCode() instanceof List ?
|
|
|
|
|
JsonUtil.getObjectToString(recycleDevicePagination.getDeviceCode()) :
|
|
|
|
|
String.valueOf(recycleDevicePagination.getDeviceCode());
|
|
|
|
|
recycleDeviceQueryWrapper.lambda().like(RecycleDeviceEntity::getDeviceCode,value);
|
|
|
|
|
JsonUtil.getObjectToString(recycleDevicePagination.getDeviceCode()) :
|
|
|
|
|
String.valueOf(recycleDevicePagination.getDeviceCode());
|
|
|
|
|
recycleDeviceQueryWrapper.lambda().like(RecycleDeviceEntity::getDeviceCode, value);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ObjectUtil.isNotEmpty(recycleDevicePagination.getDeviceName())){
|
|
|
|
|
recycleDeviceNum++;
|
|
|
|
|
if (ObjectUtil.isNotEmpty(recycleDevicePagination.getDeviceName())) {
|
|
|
|
|
recycleDeviceNum++;
|
|
|
|
|
|
|
|
|
|
String value = recycleDevicePagination.getDeviceName() instanceof List ?
|
|
|
|
|
JsonUtil.getObjectToString(recycleDevicePagination.getDeviceName()) :
|
|
|
|
|
String.valueOf(recycleDevicePagination.getDeviceName());
|
|
|
|
|
recycleDeviceQueryWrapper.lambda().like(RecycleDeviceEntity::getDeviceName,value);
|
|
|
|
|
JsonUtil.getObjectToString(recycleDevicePagination.getDeviceName()) :
|
|
|
|
|
String.valueOf(recycleDevicePagination.getDeviceName());
|
|
|
|
|
recycleDeviceQueryWrapper.lambda().like(RecycleDeviceEntity::getDeviceName, value);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ObjectUtil.isNotEmpty(recycleDevicePagination.getUseStatus())){
|
|
|
|
|
recycleDeviceNum++;
|
|
|
|
|
if (ObjectUtil.isNotEmpty(recycleDevicePagination.getUseStatus())) {
|
|
|
|
|
recycleDeviceNum++;
|
|
|
|
|
|
|
|
|
|
recycleDeviceQueryWrapper.lambda().eq(RecycleDeviceEntity::getUseStatus,recycleDevicePagination.getUseStatus());
|
|
|
|
|
recycleDeviceQueryWrapper.lambda().eq(RecycleDeviceEntity::getUseStatus, recycleDevicePagination.getUseStatus());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ObjectUtil.isNotEmpty(recycleDevicePagination.getStatus())){
|
|
|
|
|
recycleDeviceNum++;
|
|
|
|
|
if (ObjectUtil.isNotEmpty(recycleDevicePagination.getStatus())) {
|
|
|
|
|
recycleDeviceNum++;
|
|
|
|
|
|
|
|
|
|
recycleDeviceQueryWrapper.lambda().eq(RecycleDeviceEntity::getStatus,recycleDevicePagination.getStatus());
|
|
|
|
|
recycleDeviceQueryWrapper.lambda().eq(RecycleDeviceEntity::getStatus, recycleDevicePagination.getStatus());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
List<String> intersection = generaterSwapUtil.getIntersection(intersectionList);
|
|
|
|
|
if (total>0){
|
|
|
|
|
if (intersection.size()==0){
|
|
|
|
|
if (total > 0) {
|
|
|
|
|
if (intersection.size() == 0) {
|
|
|
|
|
intersection.add("jnpfNullList");
|
|
|
|
|
}
|
|
|
|
|
recycleDeviceQueryWrapper.lambda().in(RecycleDeviceEntity::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;
|
|
|
|
|
recycleDeviceQueryWrapper.lambda().and(t->t.in(RecycleDeviceEntity::getId, finalAllSuperIDlist));
|
|
|
|
|
recycleDeviceQueryWrapper.lambda().and(t -> t.in(RecycleDeviceEntity::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;
|
|
|
|
|
recycleDeviceQueryWrapper.lambda().and(t->t.in(RecycleDeviceEntity::getId, finalAllRuleIDlist));
|
|
|
|
|
recycleDeviceQueryWrapper.lambda().and(t -> t.in(RecycleDeviceEntity::getId, finalAllRuleIDlist));
|
|
|
|
|
}
|
|
|
|
|
//假删除标志
|
|
|
|
|
recycleDeviceQueryWrapper.lambda().isNull(RecycleDeviceEntity::getDeleteMark);
|
|
|
|
|
|
|
|
|
|
//排序
|
|
|
|
|
if(StringUtil.isEmpty(recycleDevicePagination.getSidx())){
|
|
|
|
|
if (StringUtil.isEmpty(recycleDevicePagination.getSidx())) {
|
|
|
|
|
recycleDeviceQueryWrapper.lambda().orderByDesc(RecycleDeviceEntity::getId);
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
try {
|
|
|
|
|
String sidx = recycleDevicePagination.getSidx();
|
|
|
|
|
String[] strs= sidx.split("_name");
|
|
|
|
|
String[] strs = sidx.split("_name");
|
|
|
|
|
RecycleDeviceEntity recycleDeviceEntity = new RecycleDeviceEntity();
|
|
|
|
|
Field declaredField = recycleDeviceEntity.getClass().getDeclaredField(strs[0]);
|
|
|
|
|
declaredField.setAccessible(true);
|
|
|
|
|
String value = declaredField.getAnnotation(TableField.class).value();
|
|
|
|
|
recycleDeviceQueryWrapper="asc".equals(recycleDevicePagination.getSort().toLowerCase())?recycleDeviceQueryWrapper.orderByAsc(value):recycleDeviceQueryWrapper.orderByDesc(value);
|
|
|
|
|
recycleDeviceQueryWrapper = "asc".equals(recycleDevicePagination.getSort().toLowerCase()) ? recycleDeviceQueryWrapper.orderByAsc(value) : recycleDeviceQueryWrapper.orderByDesc(value);
|
|
|
|
|
} catch (NoSuchFieldException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if("0".equals(dataType)){
|
|
|
|
|
if((total>0 && AllIdList.size()>0) || total==0){
|
|
|
|
|
Page<RecycleDeviceEntity> page=new Page<>(recycleDevicePagination.getCurrentPage(), recycleDevicePagination.getPageSize());
|
|
|
|
|
IPage<RecycleDeviceEntity> userIPage=this.page(page, recycleDeviceQueryWrapper);
|
|
|
|
|
return recycleDevicePagination.setData(userIPage.getRecords(),userIPage.getTotal());
|
|
|
|
|
}else{
|
|
|
|
|
if ("0".equals(dataType)) {
|
|
|
|
|
if ((total > 0 && AllIdList.size() > 0) || total == 0) {
|
|
|
|
|
Page<RecycleDeviceEntity> page = new Page<>(recycleDevicePagination.getCurrentPage(), recycleDevicePagination.getPageSize());
|
|
|
|
|
IPage<RecycleDeviceEntity> userIPage = this.page(page, recycleDeviceQueryWrapper);
|
|
|
|
|
return recycleDevicePagination.setData(userIPage.getRecords(), userIPage.getTotal());
|
|
|
|
|
} else {
|
|
|
|
|
List<RecycleDeviceEntity> list = new ArrayList();
|
|
|
|
|
return recycleDevicePagination.setData(list, list.size());
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
return this.list(recycleDeviceQueryWrapper);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public RecycleDeviceEntity getInfo(String id){
|
|
|
|
|
QueryWrapper<RecycleDeviceEntity> queryWrapper=new QueryWrapper<>();
|
|
|
|
|
queryWrapper.lambda().eq(RecycleDeviceEntity::getId,id);
|
|
|
|
|
public RecycleDeviceEntity getInfo(String id) {
|
|
|
|
|
QueryWrapper<RecycleDeviceEntity> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper.lambda().eq(RecycleDeviceEntity::getId, id);
|
|
|
|
|
return this.getOne(queryWrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void create(RecycleDeviceEntity entity){
|
|
|
|
|
public void create(RecycleDeviceEntity entity) {
|
|
|
|
|
this.save(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean update(String id, RecycleDeviceEntity entity){
|
|
|
|
|
return this.updateById(entity);
|
|
|
|
|
public boolean update(String id, RecycleDeviceEntity entity) {
|
|
|
|
|
boolean result = this.updateById(entity);
|
|
|
|
|
if (result) {
|
|
|
|
|
CompletableFuture.runAsync(() -> {
|
|
|
|
|
String finalUrl = DELETE_URL.replace("{id}", AUTH).replace("{user_id}", entity.getDeviceCode());
|
|
|
|
|
HttpRequest.delete(HOST + finalUrl)
|
|
|
|
|
.header("Content-Type", "application/json")
|
|
|
|
|
.basicAuth(USERNAME, PASSWORD)
|
|
|
|
|
.execute();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return this.
|
|
|
|
|
|
|
|
|
|
updateById(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void delete(RecycleDeviceEntity entity){
|
|
|
|
|
if(entity!=null){
|
|
|
|
|
public void delete(RecycleDeviceEntity entity) {
|
|
|
|
|
if (entity != null) {
|
|
|
|
|
this.removeById(entity.getId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/** 验证表单唯一字段,正则,非空 i-0新增-1修改*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 验证表单唯一字段,正则,非空 i-0新增-1修改
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public String checkForm(RecycleDeviceForm form,int i) {
|
|
|
|
|
boolean isUp =StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0");
|
|
|
|
|
String id="";
|
|
|
|
|
public String checkForm(RecycleDeviceForm form, int i) {
|
|
|
|
|
boolean isUp = StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0");
|
|
|
|
|
String id = "";
|
|
|
|
|
String countRecover = "";
|
|
|
|
|
if (isUp){
|
|
|
|
|
if (isUp) {
|
|
|
|
|
id = form.getId();
|
|
|
|
|
}
|
|
|
|
|
//主表字段验证
|
|
|
|
|
if(StringUtil.isEmpty(form.getDeviceName())){
|
|
|
|
|
return "设备名称不能为空";
|
|
|
|
|
}
|
|
|
|
|
if(StringUtil.isEmpty(form.getAddress())){
|
|
|
|
|
return "地址不能为空";
|
|
|
|
|
}
|
|
|
|
|
if (StringUtil.isEmpty(form.getDeviceName())) {
|
|
|
|
|
return "设备名称不能为空";
|
|
|
|
|
}
|
|
|
|
|
if (StringUtil.isEmpty(form.getAddress())) {
|
|
|
|
|
return "地址不能为空";
|
|
|
|
|
}
|
|
|
|
|
return countRecover;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增修改数据(事务回滚)
|
|
|
|
|
* @param id
|
|
|
|
|
* @param recycleDeviceForm
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
* 新增修改数据(事务回滚)
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
* @param recycleDeviceForm
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public void saveOrUpdate(RecycleDeviceForm recycleDeviceForm,String id, boolean isSave) throws Exception{
|
|
|
|
|
UserInfo userInfo=userProvider.get();
|
|
|
|
|
public void saveOrUpdate(RecycleDeviceForm recycleDeviceForm, String id, boolean isSave) throws Exception {
|
|
|
|
|
UserInfo userInfo = userProvider.get();
|
|
|
|
|
UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId());
|
|
|
|
|
recycleDeviceForm = JsonUtil.getJsonToBean(
|
|
|
|
|
generaterSwapUtil.swapDatetime(RecycleDeviceConstant.getFormData(),recycleDeviceForm),RecycleDeviceForm.class);
|
|
|
|
|
generaterSwapUtil.swapDatetime(RecycleDeviceConstant.getFormData(), recycleDeviceForm), RecycleDeviceForm.class);
|
|
|
|
|
RecycleDeviceEntity entity = JsonUtil.getJsonToBean(recycleDeviceForm, RecycleDeviceEntity.class);
|
|
|
|
|
|
|
|
|
|
if(isSave){
|
|
|
|
|
String mainId = RandomUtil.uuId() ;
|
|
|
|
|
if (isSave) {
|
|
|
|
|
String mainId = RandomUtil.uuId();
|
|
|
|
|
entity.setDeviceCode(generaterSwapUtil.getBillNumber("deviceCode", false));
|
|
|
|
|
entity.setId(mainId);
|
|
|
|
|
String deviceCode = entity.getDeviceCode();
|
|
|
|
|
String qrCode = generateQRCode(deviceCode);
|
|
|
|
|
entity.setDeviceCodeQr(qrCode);
|
|
|
|
|
}else{
|
|
|
|
|
}
|
|
|
|
|
this.saveOrUpdate(entity);
|
|
|
|
|
|
|
|
|
|
boolean result = this.saveOrUpdate(entity);
|
|
|
|
|
//新增
|
|
|
|
|
if (isSave && result) {
|
|
|
|
|
CompletableFuture.runAsync(() -> {
|
|
|
|
|
String finalUrl = SAVE_URL.replace("{id}", AUTH);
|
|
|
|
|
HashMap<String, Object> param = new HashMap<>();
|
|
|
|
|
param.put("user_id", entity.getDeviceCode());
|
|
|
|
|
param.put("password", entity.getDeviceCode());
|
|
|
|
|
param.put("is_superuser", false);
|
|
|
|
|
HttpRequest.post(HOST + finalUrl)
|
|
|
|
|
.header("Content-Type", "application/json")
|
|
|
|
|
.basicAuth(USERNAME, PASSWORD)
|
|
|
|
|
.body(JSONUtil.toJsonStr(param))
|
|
|
|
|
.execute();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -406,8 +448,8 @@ public class RecycleDeviceServiceImpl extends ServiceImpl<RecycleDeviceMapper, R
|
|
|
|
|
|
|
|
|
|
public String generateQRCode(String deviceCode) {
|
|
|
|
|
HashMap<String, Object> param = new HashMap<>();
|
|
|
|
|
param.put("deviceCode",deviceCode);
|
|
|
|
|
param.put("page","");
|
|
|
|
|
param.put("deviceCode", deviceCode);
|
|
|
|
|
param.put("page", "");
|
|
|
|
|
HttpResponse response = HttpRequest.post(wx_url + "/api/wx/generateDeviceQRCode")
|
|
|
|
|
.header("Content-Type", "application/json")
|
|
|
|
|
.body(JSONUtil.toJsonStr(param))
|
|
|
|
|