|
|
|
@ -1,23 +1,38 @@
|
|
|
|
|
package jnpf.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
import jnpf.entity.*;
|
|
|
|
|
import jnpf.mapper.YysMaterialProcurementOrderMapper;
|
|
|
|
|
import jnpf.service.*;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import jnpf.model.yysmaterialprocurementorder.*;
|
|
|
|
|
|
|
|
|
|
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.time.LocalDate;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
|
|
import jnpf.model.QueryModel;
|
|
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import jnpf.base.model.ColumnDataModel;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
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 +40,20 @@ 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;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* YysMaterialProcurementOrder
|
|
|
|
|
* 版本: V3.5
|
|
|
|
|
* 版权: 引迈信息技术有限公司(https://www.jnpfsoft.com)
|
|
|
|
@ -39,293 +61,342 @@ import jnpf.permission.entity.UserEntity;
|
|
|
|
|
* 日期: 2024-08-08
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
public class YysMaterialProcurementOrderServiceImpl extends ServiceImpl<YysMaterialProcurementOrderMapper, YysMaterialProcurementOrderEntity> implements YysMaterialProcurementOrderService{
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class YysMaterialProcurementOrderServiceImpl extends ServiceImpl<YysMaterialProcurementOrderMapper, YysMaterialProcurementOrderEntity> implements YysMaterialProcurementOrderService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private GeneraterSwapUtil generaterSwapUtil;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private UserProvider userProvider;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private YysMaterialProcurementItemService yysMaterialProcurementItemService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<YysMaterialProcurementOrderEntity> getList(YysMaterialProcurementOrderPagination yysMaterialProcurementOrderPagination){
|
|
|
|
|
return getTypeList(yysMaterialProcurementOrderPagination,yysMaterialProcurementOrderPagination.getDataType());
|
|
|
|
|
public List<YysMaterialProcurementOrderEntity> getList(YysMaterialProcurementOrderPagination yysMaterialProcurementOrderPagination) {
|
|
|
|
|
return getTypeList(yysMaterialProcurementOrderPagination, yysMaterialProcurementOrderPagination.getDataType());
|
|
|
|
|
}
|
|
|
|
|
/** 列表查询 */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 列表查询
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<YysMaterialProcurementOrderEntity> getTypeList(YysMaterialProcurementOrderPagination yysMaterialProcurementOrderPagination,String dataType){
|
|
|
|
|
String userId=userProvider.get().getUserId();
|
|
|
|
|
List<String> AllIdList =new ArrayList();
|
|
|
|
|
List<List<String>> intersectionList =new ArrayList<>();
|
|
|
|
|
public List<YysMaterialProcurementOrderEntity> getTypeList(YysMaterialProcurementOrderPagination yysMaterialProcurementOrderPagination, 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 ? YysMaterialProcurementOrderConstant.getAppColumnData() : YysMaterialProcurementOrderConstant.getColumnData();
|
|
|
|
|
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class);
|
|
|
|
|
String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList());
|
|
|
|
|
|
|
|
|
|
int total=0;
|
|
|
|
|
int yysMaterialProcurementOrderNum =0;
|
|
|
|
|
QueryWrapper<YysMaterialProcurementOrderEntity> yysMaterialProcurementOrderQueryWrapper=new QueryWrapper<>();
|
|
|
|
|
int total = 0;
|
|
|
|
|
int yysMaterialProcurementOrderNum = 0;
|
|
|
|
|
QueryWrapper<YysMaterialProcurementOrderEntity> yysMaterialProcurementOrderQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
List<String> allSuperIDlist = new ArrayList<>();
|
|
|
|
|
String superOp ="";
|
|
|
|
|
if (ObjectUtil.isNotEmpty(yysMaterialProcurementOrderPagination.getSuperQueryJson())){
|
|
|
|
|
String superOp = "";
|
|
|
|
|
if (ObjectUtil.isNotEmpty(yysMaterialProcurementOrderPagination.getSuperQueryJson())) {
|
|
|
|
|
List<String> allSuperList = new ArrayList<>();
|
|
|
|
|
List<List<String>> intersectionSuperList = new ArrayList<>();
|
|
|
|
|
List<List<String>> intersectionSuperList = new ArrayList<>();
|
|
|
|
|
String queryJson = yysMaterialProcurementOrderPagination.getSuperQueryJson();
|
|
|
|
|
SuperJsonModel superJsonModel = JsonUtil.getJsonToBean(queryJson, SuperJsonModel.class);
|
|
|
|
|
int superNum = 0;
|
|
|
|
|
QueryWrapper<YysMaterialProcurementOrderEntity> yysMaterialProcurementOrderSuperWrapper = new QueryWrapper<>();
|
|
|
|
|
yysMaterialProcurementOrderSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysMaterialProcurementOrderSuperWrapper,YysMaterialProcurementOrderEntity.class,queryJson,"0"));
|
|
|
|
|
yysMaterialProcurementOrderSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysMaterialProcurementOrderSuperWrapper, YysMaterialProcurementOrderEntity.class, queryJson, "0"));
|
|
|
|
|
int yysMaterialProcurementOrderNum1 = yysMaterialProcurementOrderSuperWrapper.getExpression().getNormal().size();
|
|
|
|
|
if (yysMaterialProcurementOrderNum1>0){
|
|
|
|
|
List<String> yysMaterialProcurementOrderList =this.list(yysMaterialProcurementOrderSuperWrapper).stream().map(YysMaterialProcurementOrderEntity::getId).collect(Collectors.toList());
|
|
|
|
|
if (yysMaterialProcurementOrderNum1 > 0) {
|
|
|
|
|
List<String> yysMaterialProcurementOrderList = this.list(yysMaterialProcurementOrderSuperWrapper).stream().map(YysMaterialProcurementOrderEntity::getId).collect(Collectors.toList());
|
|
|
|
|
allSuperList.addAll(yysMaterialProcurementOrderList);
|
|
|
|
|
intersectionSuperList.add(yysMaterialProcurementOrderList);
|
|
|
|
|
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<YysMaterialProcurementOrderEntity> yysMaterialProcurementOrderSuperWrapper = new QueryWrapper<>();
|
|
|
|
|
yysMaterialProcurementOrderSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysMaterialProcurementOrderSuperWrapper,YysMaterialProcurementOrderEntity.class,ruleJson,"0"));
|
|
|
|
|
yysMaterialProcurementOrderSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysMaterialProcurementOrderSuperWrapper, YysMaterialProcurementOrderEntity.class, ruleJson, "0"));
|
|
|
|
|
int yysMaterialProcurementOrderNum1 = yysMaterialProcurementOrderSuperWrapper.getExpression().getNormal().size();
|
|
|
|
|
if (yysMaterialProcurementOrderNum1>0){
|
|
|
|
|
List<String> yysMaterialProcurementOrderList =this.list(yysMaterialProcurementOrderSuperWrapper).stream().map(YysMaterialProcurementOrderEntity::getId).collect(Collectors.toList());
|
|
|
|
|
if (yysMaterialProcurementOrderNum1 > 0) {
|
|
|
|
|
List<String> yysMaterialProcurementOrderList = this.list(yysMaterialProcurementOrderSuperWrapper).stream().map(YysMaterialProcurementOrderEntity::getId).collect(Collectors.toList());
|
|
|
|
|
allRuleList.addAll(yysMaterialProcurementOrderList);
|
|
|
|
|
intersectionRuleList.add(yysMaterialProcurementOrderList);
|
|
|
|
|
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 yysMaterialProcurementOrderObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysMaterialProcurementOrderQueryWrapper,YysMaterialProcurementOrderEntity.class,yysMaterialProcurementOrderPagination.getMenuId(),"0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(yysMaterialProcurementOrderObj)){
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
yysMaterialProcurementOrderQueryWrapper = (QueryWrapper<YysMaterialProcurementOrderEntity>)yysMaterialProcurementOrderObj;
|
|
|
|
|
if( yysMaterialProcurementOrderQueryWrapper.getExpression().getNormal().size()>0){
|
|
|
|
|
yysMaterialProcurementOrderNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!isPc && appPermission){
|
|
|
|
|
if (!userProvider.get().getIsAdministrator()){
|
|
|
|
|
Object yysMaterialProcurementOrderObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysMaterialProcurementOrderQueryWrapper,YysMaterialProcurementOrderEntity.class,yysMaterialProcurementOrderPagination.getMenuId(),"0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(yysMaterialProcurementOrderObj)){
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
yysMaterialProcurementOrderQueryWrapper = (QueryWrapper<YysMaterialProcurementOrderEntity>)yysMaterialProcurementOrderObj;
|
|
|
|
|
if( yysMaterialProcurementOrderQueryWrapper.getExpression().getNormal().size()>0){
|
|
|
|
|
yysMaterialProcurementOrderNum++;
|
|
|
|
|
}
|
|
|
|
|
boolean pcPermission = true;
|
|
|
|
|
boolean appPermission = false;
|
|
|
|
|
if (isPc && pcPermission) {
|
|
|
|
|
if (!userProvider.get().getIsAdministrator()) {
|
|
|
|
|
Object yysMaterialProcurementOrderObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysMaterialProcurementOrderQueryWrapper, YysMaterialProcurementOrderEntity.class, yysMaterialProcurementOrderPagination.getMenuId(), "0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(yysMaterialProcurementOrderObj)) {
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
yysMaterialProcurementOrderQueryWrapper = (QueryWrapper<YysMaterialProcurementOrderEntity>) yysMaterialProcurementOrderObj;
|
|
|
|
|
if (yysMaterialProcurementOrderQueryWrapper.getExpression().getNormal().size() > 0) {
|
|
|
|
|
yysMaterialProcurementOrderNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!isPc && appPermission) {
|
|
|
|
|
if (!userProvider.get().getIsAdministrator()) {
|
|
|
|
|
Object yysMaterialProcurementOrderObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysMaterialProcurementOrderQueryWrapper, YysMaterialProcurementOrderEntity.class, yysMaterialProcurementOrderPagination.getMenuId(), "0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(yysMaterialProcurementOrderObj)) {
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
yysMaterialProcurementOrderQueryWrapper = (QueryWrapper<YysMaterialProcurementOrderEntity>) yysMaterialProcurementOrderObj;
|
|
|
|
|
if (yysMaterialProcurementOrderQueryWrapper.getExpression().getNormal().size() > 0) {
|
|
|
|
|
yysMaterialProcurementOrderNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(isPc){
|
|
|
|
|
if(ObjectUtil.isNotEmpty(yysMaterialProcurementOrderPagination.getOrderNumber())){
|
|
|
|
|
yysMaterialProcurementOrderNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (isPc) {
|
|
|
|
|
if (ObjectUtil.isNotEmpty(yysMaterialProcurementOrderPagination.getOrderNumber())) {
|
|
|
|
|
yysMaterialProcurementOrderNum++;
|
|
|
|
|
|
|
|
|
|
String value = yysMaterialProcurementOrderPagination.getOrderNumber() instanceof List ?
|
|
|
|
|
JsonUtil.getObjectToString(yysMaterialProcurementOrderPagination.getOrderNumber()) :
|
|
|
|
|
String.valueOf(yysMaterialProcurementOrderPagination.getOrderNumber());
|
|
|
|
|
yysMaterialProcurementOrderQueryWrapper.lambda().like(YysMaterialProcurementOrderEntity::getOrderNumber,value);
|
|
|
|
|
JsonUtil.getObjectToString(yysMaterialProcurementOrderPagination.getOrderNumber()) :
|
|
|
|
|
String.valueOf(yysMaterialProcurementOrderPagination.getOrderNumber());
|
|
|
|
|
yysMaterialProcurementOrderQueryWrapper.lambda().like(YysMaterialProcurementOrderEntity::getOrderNumber, value);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ObjectUtil.isNotEmpty(yysMaterialProcurementOrderPagination.getProcurementNumber())){
|
|
|
|
|
yysMaterialProcurementOrderNum++;
|
|
|
|
|
if (ObjectUtil.isNotEmpty(yysMaterialProcurementOrderPagination.getProcurementNumber())) {
|
|
|
|
|
yysMaterialProcurementOrderNum++;
|
|
|
|
|
|
|
|
|
|
String value = yysMaterialProcurementOrderPagination.getProcurementNumber() instanceof List ?
|
|
|
|
|
JsonUtil.getObjectToString(yysMaterialProcurementOrderPagination.getProcurementNumber()) :
|
|
|
|
|
String.valueOf(yysMaterialProcurementOrderPagination.getProcurementNumber());
|
|
|
|
|
yysMaterialProcurementOrderQueryWrapper.lambda().like(YysMaterialProcurementOrderEntity::getProcurementNumber,value);
|
|
|
|
|
JsonUtil.getObjectToString(yysMaterialProcurementOrderPagination.getProcurementNumber()) :
|
|
|
|
|
String.valueOf(yysMaterialProcurementOrderPagination.getProcurementNumber());
|
|
|
|
|
yysMaterialProcurementOrderQueryWrapper.lambda().like(YysMaterialProcurementOrderEntity::getProcurementNumber, value);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ObjectUtil.isNotEmpty(yysMaterialProcurementOrderPagination.getMaterialName())){
|
|
|
|
|
yysMaterialProcurementOrderNum++;
|
|
|
|
|
if (ObjectUtil.isNotEmpty(yysMaterialProcurementOrderPagination.getMaterialName())) {
|
|
|
|
|
yysMaterialProcurementOrderNum++;
|
|
|
|
|
|
|
|
|
|
String value = yysMaterialProcurementOrderPagination.getMaterialName() instanceof List ?
|
|
|
|
|
JsonUtil.getObjectToString(yysMaterialProcurementOrderPagination.getMaterialName()) :
|
|
|
|
|
String.valueOf(yysMaterialProcurementOrderPagination.getMaterialName());
|
|
|
|
|
yysMaterialProcurementOrderQueryWrapper.lambda().like(YysMaterialProcurementOrderEntity::getMaterialName,value);
|
|
|
|
|
JsonUtil.getObjectToString(yysMaterialProcurementOrderPagination.getMaterialName()) :
|
|
|
|
|
String.valueOf(yysMaterialProcurementOrderPagination.getMaterialName());
|
|
|
|
|
yysMaterialProcurementOrderQueryWrapper.lambda().like(YysMaterialProcurementOrderEntity::getMaterialName, value);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ObjectUtil.isNotEmpty(yysMaterialProcurementOrderPagination.getSupplier())){
|
|
|
|
|
yysMaterialProcurementOrderNum++;
|
|
|
|
|
if (ObjectUtil.isNotEmpty(yysMaterialProcurementOrderPagination.getSupplier())) {
|
|
|
|
|
yysMaterialProcurementOrderNum++;
|
|
|
|
|
|
|
|
|
|
String value = yysMaterialProcurementOrderPagination.getSupplier() instanceof List ?
|
|
|
|
|
JsonUtil.getObjectToString(yysMaterialProcurementOrderPagination.getSupplier()) :
|
|
|
|
|
String.valueOf(yysMaterialProcurementOrderPagination.getSupplier());
|
|
|
|
|
yysMaterialProcurementOrderQueryWrapper.lambda().like(YysMaterialProcurementOrderEntity::getSupplier,value);
|
|
|
|
|
JsonUtil.getObjectToString(yysMaterialProcurementOrderPagination.getSupplier()) :
|
|
|
|
|
String.valueOf(yysMaterialProcurementOrderPagination.getSupplier());
|
|
|
|
|
yysMaterialProcurementOrderQueryWrapper.lambda().like(YysMaterialProcurementOrderEntity::getSupplier, value);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ObjectUtil.isNotEmpty(yysMaterialProcurementOrderPagination.getOrderStatus())){
|
|
|
|
|
yysMaterialProcurementOrderNum++;
|
|
|
|
|
if (ObjectUtil.isNotEmpty(yysMaterialProcurementOrderPagination.getOrderStatus())) {
|
|
|
|
|
yysMaterialProcurementOrderNum++;
|
|
|
|
|
|
|
|
|
|
List<String> idList = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
String[][] orderStatus = JsonUtil.getJsonToBean(yysMaterialProcurementOrderPagination.getOrderStatus(),String[][].class);
|
|
|
|
|
for(int i=0;i<orderStatus.length;i++){
|
|
|
|
|
if(orderStatus[i].length>0){
|
|
|
|
|
idList.add(JsonUtil.getObjectToString(Arrays.asList(orderStatus[i])));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e1){
|
|
|
|
|
try {
|
|
|
|
|
List<String> orderStatus = JsonUtil.getJsonToList(yysMaterialProcurementOrderPagination.getOrderStatus(),String.class);
|
|
|
|
|
if(orderStatus.size()>0){
|
|
|
|
|
idList.addAll(orderStatus);
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e2){
|
|
|
|
|
idList.add(String.valueOf(yysMaterialProcurementOrderPagination.getOrderStatus()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
yysMaterialProcurementOrderQueryWrapper.lambda().and(t->{
|
|
|
|
|
idList.forEach(tt->{
|
|
|
|
|
t.like(YysMaterialProcurementOrderEntity::getOrderStatus, tt).or();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
List<String> idList = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
String[][] orderStatus = JsonUtil.getJsonToBean(yysMaterialProcurementOrderPagination.getOrderStatus(), String[][].class);
|
|
|
|
|
for (int i = 0; i < orderStatus.length; i++) {
|
|
|
|
|
if (orderStatus[i].length > 0) {
|
|
|
|
|
idList.add(JsonUtil.getObjectToString(Arrays.asList(orderStatus[i])));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e1) {
|
|
|
|
|
try {
|
|
|
|
|
List<String> orderStatus = JsonUtil.getJsonToList(yysMaterialProcurementOrderPagination.getOrderStatus(), String.class);
|
|
|
|
|
if (orderStatus.size() > 0) {
|
|
|
|
|
idList.addAll(orderStatus);
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e2) {
|
|
|
|
|
idList.add(String.valueOf(yysMaterialProcurementOrderPagination.getOrderStatus()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
yysMaterialProcurementOrderQueryWrapper.lambda().and(t -> {
|
|
|
|
|
idList.forEach(tt -> {
|
|
|
|
|
t.like(YysMaterialProcurementOrderEntity::getOrderStatus, tt).or();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
List<String> intersection = generaterSwapUtil.getIntersection(intersectionList);
|
|
|
|
|
if (total>0){
|
|
|
|
|
if (intersection.size()==0){
|
|
|
|
|
if (total > 0) {
|
|
|
|
|
if (intersection.size() == 0) {
|
|
|
|
|
intersection.add("jnpfNullList");
|
|
|
|
|
}
|
|
|
|
|
yysMaterialProcurementOrderQueryWrapper.lambda().in(YysMaterialProcurementOrderEntity::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;
|
|
|
|
|
yysMaterialProcurementOrderQueryWrapper.lambda().and(t->t.in(YysMaterialProcurementOrderEntity::getId, finalAllSuperIDlist));
|
|
|
|
|
yysMaterialProcurementOrderQueryWrapper.lambda().and(t -> t.in(YysMaterialProcurementOrderEntity::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;
|
|
|
|
|
yysMaterialProcurementOrderQueryWrapper.lambda().and(t->t.in(YysMaterialProcurementOrderEntity::getId, finalAllRuleIDlist));
|
|
|
|
|
yysMaterialProcurementOrderQueryWrapper.lambda().and(t -> t.in(YysMaterialProcurementOrderEntity::getId, finalAllRuleIDlist));
|
|
|
|
|
}
|
|
|
|
|
//假删除标志
|
|
|
|
|
yysMaterialProcurementOrderQueryWrapper.lambda().isNull(YysMaterialProcurementOrderEntity::getDeleteMark);
|
|
|
|
|
|
|
|
|
|
//排序
|
|
|
|
|
if(StringUtil.isEmpty(yysMaterialProcurementOrderPagination.getSidx())){
|
|
|
|
|
if (StringUtil.isEmpty(yysMaterialProcurementOrderPagination.getSidx())) {
|
|
|
|
|
yysMaterialProcurementOrderQueryWrapper.lambda().orderByDesc(YysMaterialProcurementOrderEntity::getId);
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
try {
|
|
|
|
|
String sidx = yysMaterialProcurementOrderPagination.getSidx();
|
|
|
|
|
String[] strs= sidx.split("_name");
|
|
|
|
|
String[] strs = sidx.split("_name");
|
|
|
|
|
YysMaterialProcurementOrderEntity yysMaterialProcurementOrderEntity = new YysMaterialProcurementOrderEntity();
|
|
|
|
|
Field declaredField = yysMaterialProcurementOrderEntity.getClass().getDeclaredField(strs[0]);
|
|
|
|
|
declaredField.setAccessible(true);
|
|
|
|
|
String value = declaredField.getAnnotation(TableField.class).value();
|
|
|
|
|
yysMaterialProcurementOrderQueryWrapper="asc".equals(yysMaterialProcurementOrderPagination.getSort().toLowerCase())?yysMaterialProcurementOrderQueryWrapper.orderByAsc(value):yysMaterialProcurementOrderQueryWrapper.orderByDesc(value);
|
|
|
|
|
yysMaterialProcurementOrderQueryWrapper = "asc".equals(yysMaterialProcurementOrderPagination.getSort().toLowerCase()) ? yysMaterialProcurementOrderQueryWrapper.orderByAsc(value) : yysMaterialProcurementOrderQueryWrapper.orderByDesc(value);
|
|
|
|
|
} catch (NoSuchFieldException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if("0".equals(dataType)){
|
|
|
|
|
if((total>0 && AllIdList.size()>0) || total==0){
|
|
|
|
|
Page<YysMaterialProcurementOrderEntity> page=new Page<>(yysMaterialProcurementOrderPagination.getCurrentPage(), yysMaterialProcurementOrderPagination.getPageSize());
|
|
|
|
|
IPage<YysMaterialProcurementOrderEntity> userIPage=this.page(page, yysMaterialProcurementOrderQueryWrapper);
|
|
|
|
|
return yysMaterialProcurementOrderPagination.setData(userIPage.getRecords(),userIPage.getTotal());
|
|
|
|
|
}else{
|
|
|
|
|
if ("0".equals(dataType)) {
|
|
|
|
|
if ((total > 0 && AllIdList.size() > 0) || total == 0) {
|
|
|
|
|
Page<YysMaterialProcurementOrderEntity> page = new Page<>(yysMaterialProcurementOrderPagination.getCurrentPage(), yysMaterialProcurementOrderPagination.getPageSize());
|
|
|
|
|
IPage<YysMaterialProcurementOrderEntity> userIPage = this.page(page, yysMaterialProcurementOrderQueryWrapper);
|
|
|
|
|
return yysMaterialProcurementOrderPagination.setData(userIPage.getRecords(), userIPage.getTotal());
|
|
|
|
|
} else {
|
|
|
|
|
List<YysMaterialProcurementOrderEntity> list = new ArrayList();
|
|
|
|
|
return yysMaterialProcurementOrderPagination.setData(list, list.size());
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
return this.list(yysMaterialProcurementOrderQueryWrapper);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public YysMaterialProcurementOrderEntity getInfo(String id){
|
|
|
|
|
QueryWrapper<YysMaterialProcurementOrderEntity> queryWrapper=new QueryWrapper<>();
|
|
|
|
|
queryWrapper.lambda().eq(YysMaterialProcurementOrderEntity::getId,id);
|
|
|
|
|
public YysMaterialProcurementOrderEntity getInfo(String id) {
|
|
|
|
|
QueryWrapper<YysMaterialProcurementOrderEntity> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper.lambda().eq(YysMaterialProcurementOrderEntity::getId, id);
|
|
|
|
|
return this.getOne(queryWrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void create(YysMaterialProcurementOrderEntity entity){
|
|
|
|
|
public void create(YysMaterialProcurementOrderEntity entity) {
|
|
|
|
|
this.save(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean update(String id, YysMaterialProcurementOrderEntity entity){
|
|
|
|
|
public boolean update(String id, YysMaterialProcurementOrderEntity entity) {
|
|
|
|
|
return this.updateById(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void delete(YysMaterialProcurementOrderEntity entity){
|
|
|
|
|
if(entity!=null){
|
|
|
|
|
public void delete(YysMaterialProcurementOrderEntity entity) {
|
|
|
|
|
if (entity != null) {
|
|
|
|
|
this.removeById(entity.getId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/** 验证表单唯一字段,正则,非空 i-0新增-1修改*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 验证表单唯一字段,正则,非空 i-0新增-1修改
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public String checkForm(YysMaterialProcurementOrderForm form,int i) {
|
|
|
|
|
boolean isUp =StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0");
|
|
|
|
|
String id="";
|
|
|
|
|
public String checkForm(YysMaterialProcurementOrderForm 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.getSupplier())){
|
|
|
|
|
return "供应商不能为空";
|
|
|
|
|
}
|
|
|
|
|
if (StringUtil.isEmpty(form.getSupplier())) {
|
|
|
|
|
return "供应商不能为空";
|
|
|
|
|
}
|
|
|
|
|
return countRecover;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增修改数据(事务回滚)
|
|
|
|
|
* @param id
|
|
|
|
|
* @param yysMaterialProcurementOrderForm
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
* 新增修改数据(事务回滚)
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
* @param yysMaterialProcurementOrderForm
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public void saveOrUpdate(YysMaterialProcurementOrderForm yysMaterialProcurementOrderForm,String id, boolean isSave) throws Exception{
|
|
|
|
|
UserInfo userInfo=userProvider.get();
|
|
|
|
|
public void saveOrUpdate(YysMaterialProcurementOrderForm yysMaterialProcurementOrderForm, String id, boolean isSave) throws Exception {
|
|
|
|
|
UserInfo userInfo = userProvider.get();
|
|
|
|
|
UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId());
|
|
|
|
|
yysMaterialProcurementOrderForm = JsonUtil.getJsonToBean(
|
|
|
|
|
generaterSwapUtil.swapDatetime(YysMaterialProcurementOrderConstant.getFormData(),yysMaterialProcurementOrderForm),YysMaterialProcurementOrderForm.class);
|
|
|
|
|
generaterSwapUtil.swapDatetime(YysMaterialProcurementOrderConstant.getFormData(), yysMaterialProcurementOrderForm), YysMaterialProcurementOrderForm.class);
|
|
|
|
|
YysMaterialProcurementOrderEntity entity = JsonUtil.getJsonToBean(yysMaterialProcurementOrderForm, YysMaterialProcurementOrderEntity.class);
|
|
|
|
|
|
|
|
|
|
if(isSave){
|
|
|
|
|
String mainId = RandomUtil.uuId() ;
|
|
|
|
|
if (isSave) {
|
|
|
|
|
String mainId = RandomUtil.uuId();
|
|
|
|
|
entity.setId(mainId);
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
}
|
|
|
|
|
this.saveOrUpdate(entity);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String initOrder(YysMaterialProcurementOrderForm form) {
|
|
|
|
|
log.info("生成采购订单,form:{}", form);
|
|
|
|
|
if (CollectionUtils.isEmpty(form.getOrderData())) {
|
|
|
|
|
return "采购单信息为空";
|
|
|
|
|
}
|
|
|
|
|
String currentDate = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
|
|
|
|
List<YysMaterialProcurementOrderEntity> collect = form.getOrderData().stream().map(obj -> {
|
|
|
|
|
YysMaterialProcurementOrderEntity entity = BeanUtil.copyProperties(obj, YysMaterialProcurementOrderEntity.class);
|
|
|
|
|
String mainId = RandomUtil.uuId();
|
|
|
|
|
int index = 1;
|
|
|
|
|
String number = String.format("%03d" + "d", index);
|
|
|
|
|
entity.setId(mainId);
|
|
|
|
|
entity.setOrderNumber("PO" + currentDate + number);
|
|
|
|
|
entity.setCreatorTime(DateUtil.getNowDate());
|
|
|
|
|
entity.setCreatorUserId(userProvider.get().getUserId());
|
|
|
|
|
index++;
|
|
|
|
|
return entity;
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
boolean result = this.saveBatch(collect);
|
|
|
|
|
if (result) {
|
|
|
|
|
//需要更新采购物料表中的总下单数量以及单号
|
|
|
|
|
List<String> orders = collect.stream().map(YysMaterialProcurementOrderEntity::getOrderNumber).collect(Collectors.toList());
|
|
|
|
|
BigDecimal nums = collect.stream()
|
|
|
|
|
.map(YysMaterialProcurementOrderEntity::getOrderQuantity)
|
|
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
String materialId = collect.get(0).getMaterialId();
|
|
|
|
|
CompletableFuture.runAsync(() -> yysMaterialProcurementItemService.syncNums(materialId, String.join(",", orders), nums));
|
|
|
|
|
return "生成成功";
|
|
|
|
|
}
|
|
|
|
|
return "生成失败";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|