|
|
|
@ -1,23 +1,23 @@
|
|
|
|
|
package jnpf.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import jnpf.entity.*;
|
|
|
|
|
import jnpf.mapper.YysMonthlyProductionMapper;
|
|
|
|
|
import jnpf.service.*;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import jnpf.model.yysmonthlyproduction.*;
|
|
|
|
|
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 +25,14 @@ 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;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* yysMonthlyProduction
|
|
|
|
|
* 版本: V3.5
|
|
|
|
|
* 版权: 引迈信息技术有限公司(https://www.jnpfsoft.com)
|
|
|
|
@ -39,7 +40,7 @@ import jnpf.permission.entity.UserEntity;
|
|
|
|
|
* 日期: 2024-08-06
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
public class YysMonthlyProductionServiceImpl extends ServiceImpl<YysMonthlyProductionMapper, YysMonthlyProductionEntity> implements YysMonthlyProductionService{
|
|
|
|
|
public class YysMonthlyProductionServiceImpl extends ServiceImpl<YysMonthlyProductionMapper, YysMonthlyProductionEntity> implements YysMonthlyProductionService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private GeneraterSwapUtil generaterSwapUtil;
|
|
|
|
|
|
|
|
|
@ -47,246 +48,291 @@ public class YysMonthlyProductionServiceImpl extends ServiceImpl<YysMonthlyProdu
|
|
|
|
|
private UserProvider userProvider;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<YysMonthlyProductionEntity> getList(YysMonthlyProductionPagination yysMonthlyProductionPagination){
|
|
|
|
|
return getTypeList(yysMonthlyProductionPagination,yysMonthlyProductionPagination.getDataType());
|
|
|
|
|
public List<YysMonthlyProductionEntity> getList(YysMonthlyProductionPagination yysMonthlyProductionPagination) {
|
|
|
|
|
// QueryWrapper<YysMonthlyProductionEntity> wrapper = new QueryWrapper<>();
|
|
|
|
|
// if (ObjectUtil.isNotEmpty(yysMonthlyProductionPagination.getYears())) {
|
|
|
|
|
// wrapper.lambda().eq(YysMonthlyProductionEntity::getYears, yysMonthlyProductionPagination.getYears().toString());
|
|
|
|
|
// }
|
|
|
|
|
// wrapper.lambda().isNull(YysMonthlyProductionEntity::getDeleteMark);
|
|
|
|
|
// wrapper.last("ORDER BY CAST(day AS UNSIGNED)");
|
|
|
|
|
// Page<YysMonthlyProductionEntity> page = new Page<>(yysMonthlyProductionPagination.getCurrentPage(), yysMonthlyProductionPagination.getPageSize());
|
|
|
|
|
// IPage<YysMonthlyProductionEntity> userIPage = this.page(page, wrapper);
|
|
|
|
|
// return yysMonthlyProductionPagination.setData(userIPage.getRecords(), userIPage.getTotal());
|
|
|
|
|
return getTypeList(yysMonthlyProductionPagination, yysMonthlyProductionPagination.getDataType());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
/** 列表查询 */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 列表查询
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<YysMonthlyProductionEntity> getTypeList(YysMonthlyProductionPagination yysMonthlyProductionPagination,String dataType){
|
|
|
|
|
String userId=userProvider.get().getUserId();
|
|
|
|
|
List<String> AllIdList =new ArrayList();
|
|
|
|
|
List<List<String>> intersectionList =new ArrayList<>();
|
|
|
|
|
public List<YysMonthlyProductionEntity> getTypeList(YysMonthlyProductionPagination yysMonthlyProductionPagination, 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 ? YysMonthlyProductionConstant.getAppColumnData() : YysMonthlyProductionConstant.getColumnData();
|
|
|
|
|
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class);
|
|
|
|
|
String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList());
|
|
|
|
|
|
|
|
|
|
int total=0;
|
|
|
|
|
int yysMonthlyProductionNum =0;
|
|
|
|
|
QueryWrapper<YysMonthlyProductionEntity> yysMonthlyProductionQueryWrapper=new QueryWrapper<>();
|
|
|
|
|
int total = 0;
|
|
|
|
|
int yysMonthlyProductionNum = 0;
|
|
|
|
|
QueryWrapper<YysMonthlyProductionEntity> yysMonthlyProductionQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
List<String> allSuperIDlist = new ArrayList<>();
|
|
|
|
|
String superOp ="";
|
|
|
|
|
if (ObjectUtil.isNotEmpty(yysMonthlyProductionPagination.getSuperQueryJson())){
|
|
|
|
|
String superOp = "";
|
|
|
|
|
if (ObjectUtil.isNotEmpty(yysMonthlyProductionPagination.getSuperQueryJson())) {
|
|
|
|
|
List<String> allSuperList = new ArrayList<>();
|
|
|
|
|
List<List<String>> intersectionSuperList = new ArrayList<>();
|
|
|
|
|
List<List<String>> intersectionSuperList = new ArrayList<>();
|
|
|
|
|
String queryJson = yysMonthlyProductionPagination.getSuperQueryJson();
|
|
|
|
|
SuperJsonModel superJsonModel = JsonUtil.getJsonToBean(queryJson, SuperJsonModel.class);
|
|
|
|
|
int superNum = 0;
|
|
|
|
|
QueryWrapper<YysMonthlyProductionEntity> yysMonthlyProductionSuperWrapper = new QueryWrapper<>();
|
|
|
|
|
yysMonthlyProductionSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysMonthlyProductionSuperWrapper,YysMonthlyProductionEntity.class,queryJson,"0"));
|
|
|
|
|
yysMonthlyProductionSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysMonthlyProductionSuperWrapper, YysMonthlyProductionEntity.class, queryJson, "0"));
|
|
|
|
|
int yysMonthlyProductionNum1 = yysMonthlyProductionSuperWrapper.getExpression().getNormal().size();
|
|
|
|
|
if (yysMonthlyProductionNum1>0){
|
|
|
|
|
List<String> yysMonthlyProductionList =this.list(yysMonthlyProductionSuperWrapper).stream().map(YysMonthlyProductionEntity::getId).collect(Collectors.toList());
|
|
|
|
|
if (yysMonthlyProductionNum1 > 0) {
|
|
|
|
|
List<String> yysMonthlyProductionList = this.list(yysMonthlyProductionSuperWrapper).stream().map(YysMonthlyProductionEntity::getId).collect(Collectors.toList());
|
|
|
|
|
allSuperList.addAll(yysMonthlyProductionList);
|
|
|
|
|
intersectionSuperList.add(yysMonthlyProductionList);
|
|
|
|
|
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<YysMonthlyProductionEntity> yysMonthlyProductionSuperWrapper = new QueryWrapper<>();
|
|
|
|
|
yysMonthlyProductionSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysMonthlyProductionSuperWrapper,YysMonthlyProductionEntity.class,ruleJson,"0"));
|
|
|
|
|
yysMonthlyProductionSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysMonthlyProductionSuperWrapper, YysMonthlyProductionEntity.class, ruleJson, "0"));
|
|
|
|
|
int yysMonthlyProductionNum1 = yysMonthlyProductionSuperWrapper.getExpression().getNormal().size();
|
|
|
|
|
if (yysMonthlyProductionNum1>0){
|
|
|
|
|
List<String> yysMonthlyProductionList =this.list(yysMonthlyProductionSuperWrapper).stream().map(YysMonthlyProductionEntity::getId).collect(Collectors.toList());
|
|
|
|
|
if (yysMonthlyProductionNum1 > 0) {
|
|
|
|
|
List<String> yysMonthlyProductionList = this.list(yysMonthlyProductionSuperWrapper).stream().map(YysMonthlyProductionEntity::getId).collect(Collectors.toList());
|
|
|
|
|
allRuleList.addAll(yysMonthlyProductionList);
|
|
|
|
|
intersectionRuleList.add(yysMonthlyProductionList);
|
|
|
|
|
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 yysMonthlyProductionObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysMonthlyProductionQueryWrapper,YysMonthlyProductionEntity.class,yysMonthlyProductionPagination.getMenuId(),"0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(yysMonthlyProductionObj)){
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
yysMonthlyProductionQueryWrapper = (QueryWrapper<YysMonthlyProductionEntity>)yysMonthlyProductionObj;
|
|
|
|
|
if( yysMonthlyProductionQueryWrapper.getExpression().getNormal().size()>0){
|
|
|
|
|
yysMonthlyProductionNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!isPc && appPermission){
|
|
|
|
|
if (!userProvider.get().getIsAdministrator()){
|
|
|
|
|
Object yysMonthlyProductionObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysMonthlyProductionQueryWrapper,YysMonthlyProductionEntity.class,yysMonthlyProductionPagination.getMenuId(),"0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(yysMonthlyProductionObj)){
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
yysMonthlyProductionQueryWrapper = (QueryWrapper<YysMonthlyProductionEntity>)yysMonthlyProductionObj;
|
|
|
|
|
if( yysMonthlyProductionQueryWrapper.getExpression().getNormal().size()>0){
|
|
|
|
|
yysMonthlyProductionNum++;
|
|
|
|
|
}
|
|
|
|
|
boolean pcPermission = false;
|
|
|
|
|
boolean appPermission = false;
|
|
|
|
|
if (isPc && pcPermission) {
|
|
|
|
|
if (!userProvider.get().getIsAdministrator()) {
|
|
|
|
|
Object yysMonthlyProductionObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysMonthlyProductionQueryWrapper, YysMonthlyProductionEntity.class, yysMonthlyProductionPagination.getMenuId(), "0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(yysMonthlyProductionObj)) {
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
yysMonthlyProductionQueryWrapper = (QueryWrapper<YysMonthlyProductionEntity>) yysMonthlyProductionObj;
|
|
|
|
|
if (yysMonthlyProductionQueryWrapper.getExpression().getNormal().size() > 0) {
|
|
|
|
|
yysMonthlyProductionNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!isPc && appPermission) {
|
|
|
|
|
if (!userProvider.get().getIsAdministrator()) {
|
|
|
|
|
Object yysMonthlyProductionObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysMonthlyProductionQueryWrapper, YysMonthlyProductionEntity.class, yysMonthlyProductionPagination.getMenuId(), "0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(yysMonthlyProductionObj)) {
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
yysMonthlyProductionQueryWrapper = (QueryWrapper<YysMonthlyProductionEntity>) yysMonthlyProductionObj;
|
|
|
|
|
if (yysMonthlyProductionQueryWrapper.getExpression().getNormal().size() > 0) {
|
|
|
|
|
yysMonthlyProductionNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(isPc){
|
|
|
|
|
if(ObjectUtil.isNotEmpty(yysMonthlyProductionPagination.getYears())){
|
|
|
|
|
yysMonthlyProductionNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (isPc) {
|
|
|
|
|
if (ObjectUtil.isNotEmpty(yysMonthlyProductionPagination.getYears())) {
|
|
|
|
|
yysMonthlyProductionNum++;
|
|
|
|
|
|
|
|
|
|
String value = yysMonthlyProductionPagination.getYears() instanceof List ?
|
|
|
|
|
JsonUtil.getObjectToString(yysMonthlyProductionPagination.getYears()) :
|
|
|
|
|
String.valueOf(yysMonthlyProductionPagination.getYears());
|
|
|
|
|
yysMonthlyProductionQueryWrapper.lambda().eq(YysMonthlyProductionEntity::getYears,value);
|
|
|
|
|
JsonUtil.getObjectToString(yysMonthlyProductionPagination.getYears()) :
|
|
|
|
|
String.valueOf(yysMonthlyProductionPagination.getYears());
|
|
|
|
|
yysMonthlyProductionQueryWrapper.lambda().eq(YysMonthlyProductionEntity::getYears, value);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ObjectUtil.isNotEmpty(yysMonthlyProductionPagination.getProductId())){
|
|
|
|
|
yysMonthlyProductionNum++;
|
|
|
|
|
if (ObjectUtil.isNotEmpty(yysMonthlyProductionPagination.getProductId())) {
|
|
|
|
|
yysMonthlyProductionNum++;
|
|
|
|
|
|
|
|
|
|
String value = yysMonthlyProductionPagination.getProductId() instanceof List ?
|
|
|
|
|
JsonUtil.getObjectToString(yysMonthlyProductionPagination.getProductId()) :
|
|
|
|
|
String.valueOf(yysMonthlyProductionPagination.getProductId());
|
|
|
|
|
yysMonthlyProductionQueryWrapper.lambda().like(YysMonthlyProductionEntity::getProductId,value);
|
|
|
|
|
JsonUtil.getObjectToString(yysMonthlyProductionPagination.getProductId()) :
|
|
|
|
|
String.valueOf(yysMonthlyProductionPagination.getProductId());
|
|
|
|
|
yysMonthlyProductionQueryWrapper.lambda().like(YysMonthlyProductionEntity::getProductId, value);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
List<String> intersection = generaterSwapUtil.getIntersection(intersectionList);
|
|
|
|
|
if (total>0){
|
|
|
|
|
if (intersection.size()==0){
|
|
|
|
|
if (total > 0) {
|
|
|
|
|
if (intersection.size() == 0) {
|
|
|
|
|
intersection.add("jnpfNullList");
|
|
|
|
|
}
|
|
|
|
|
yysMonthlyProductionQueryWrapper.lambda().in(YysMonthlyProductionEntity::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;
|
|
|
|
|
yysMonthlyProductionQueryWrapper.lambda().and(t->t.in(YysMonthlyProductionEntity::getId, finalAllSuperIDlist));
|
|
|
|
|
yysMonthlyProductionQueryWrapper.lambda().and(t -> t.in(YysMonthlyProductionEntity::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;
|
|
|
|
|
yysMonthlyProductionQueryWrapper.lambda().and(t->t.in(YysMonthlyProductionEntity::getId, finalAllRuleIDlist));
|
|
|
|
|
yysMonthlyProductionQueryWrapper.lambda().and(t -> t.in(YysMonthlyProductionEntity::getId, finalAllRuleIDlist));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//排序
|
|
|
|
|
if(StringUtil.isEmpty(yysMonthlyProductionPagination.getSidx())){
|
|
|
|
|
if (StringUtil.isEmpty(yysMonthlyProductionPagination.getSidx())) {
|
|
|
|
|
yysMonthlyProductionQueryWrapper.lambda().orderByDesc(YysMonthlyProductionEntity::getId);
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
try {
|
|
|
|
|
String sidx = yysMonthlyProductionPagination.getSidx();
|
|
|
|
|
String[] strs= sidx.split("_name");
|
|
|
|
|
String[] strs = sidx.split("_name");
|
|
|
|
|
YysMonthlyProductionEntity yysMonthlyProductionEntity = new YysMonthlyProductionEntity();
|
|
|
|
|
Field declaredField = yysMonthlyProductionEntity.getClass().getDeclaredField(strs[0]);
|
|
|
|
|
declaredField.setAccessible(true);
|
|
|
|
|
String value = declaredField.getAnnotation(TableField.class).value();
|
|
|
|
|
yysMonthlyProductionQueryWrapper="asc".equals(yysMonthlyProductionPagination.getSort().toLowerCase())?yysMonthlyProductionQueryWrapper.orderByAsc(value):yysMonthlyProductionQueryWrapper.orderByDesc(value);
|
|
|
|
|
yysMonthlyProductionQueryWrapper = "asc".equals(yysMonthlyProductionPagination.getSort().toLowerCase()) ? yysMonthlyProductionQueryWrapper.orderByAsc(value) : yysMonthlyProductionQueryWrapper.orderByDesc(value);
|
|
|
|
|
} catch (NoSuchFieldException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if("0".equals(dataType)){
|
|
|
|
|
if((total>0 && AllIdList.size()>0) || total==0){
|
|
|
|
|
Page<YysMonthlyProductionEntity> page=new Page<>(yysMonthlyProductionPagination.getCurrentPage(), yysMonthlyProductionPagination.getPageSize());
|
|
|
|
|
IPage<YysMonthlyProductionEntity> userIPage=this.page(page, yysMonthlyProductionQueryWrapper);
|
|
|
|
|
return yysMonthlyProductionPagination.setData(userIPage.getRecords(),userIPage.getTotal());
|
|
|
|
|
}else{
|
|
|
|
|
if ("0".equals(dataType)) {
|
|
|
|
|
if ((total > 0 && AllIdList.size() > 0) || total == 0) {
|
|
|
|
|
Page<YysMonthlyProductionEntity> page = new Page<>(yysMonthlyProductionPagination.getCurrentPage(), yysMonthlyProductionPagination.getPageSize());
|
|
|
|
|
IPage<YysMonthlyProductionEntity> userIPage = this.page(page, yysMonthlyProductionQueryWrapper);
|
|
|
|
|
return yysMonthlyProductionPagination.setData(userIPage.getRecords(), userIPage.getTotal());
|
|
|
|
|
} else {
|
|
|
|
|
List<YysMonthlyProductionEntity> list = new ArrayList();
|
|
|
|
|
return yysMonthlyProductionPagination.setData(list, list.size());
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
return this.list(yysMonthlyProductionQueryWrapper);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public YysMonthlyProductionEntity getInfo(String id){
|
|
|
|
|
QueryWrapper<YysMonthlyProductionEntity> queryWrapper=new QueryWrapper<>();
|
|
|
|
|
queryWrapper.lambda().eq(YysMonthlyProductionEntity::getId,id);
|
|
|
|
|
public YysMonthlyProductionEntity getInfo(String id) {
|
|
|
|
|
QueryWrapper<YysMonthlyProductionEntity> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper.lambda().eq(YysMonthlyProductionEntity::getId, id);
|
|
|
|
|
return this.getOne(queryWrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void create(YysMonthlyProductionEntity entity){
|
|
|
|
|
public void create(YysMonthlyProductionEntity entity) {
|
|
|
|
|
this.save(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean update(String id, YysMonthlyProductionEntity entity){
|
|
|
|
|
public boolean update(String id, YysMonthlyProductionEntity entity) {
|
|
|
|
|
return this.updateById(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void delete(YysMonthlyProductionEntity entity){
|
|
|
|
|
if(entity!=null){
|
|
|
|
|
public void delete(YysMonthlyProductionEntity entity) {
|
|
|
|
|
if (entity != null) {
|
|
|
|
|
this.removeById(entity.getId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/** 验证表单唯一字段,正则,非空 i-0新增-1修改*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 验证表单唯一字段,正则,非空 i-0新增-1修改
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public String checkForm(YysMonthlyProductionForm form,int i) {
|
|
|
|
|
boolean isUp =StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0");
|
|
|
|
|
String id="";
|
|
|
|
|
public String checkForm(YysMonthlyProductionForm 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.getYears())){
|
|
|
|
|
return "年月不能为空";
|
|
|
|
|
}
|
|
|
|
|
if(StringUtil.isEmpty(form.getProductId())){
|
|
|
|
|
return "产品编码不能为空";
|
|
|
|
|
}
|
|
|
|
|
if(StringUtil.isEmpty(form.getModel())){
|
|
|
|
|
return "规格型号不能为空";
|
|
|
|
|
}
|
|
|
|
|
if(StringUtil.isEmpty(form.getMeasurementUnit())){
|
|
|
|
|
return "计量单位不能为空";
|
|
|
|
|
}
|
|
|
|
|
if(StringUtil.isEmpty(form.getCurrentInventory())){
|
|
|
|
|
return "当前库存不能为空";
|
|
|
|
|
}
|
|
|
|
|
if (StringUtil.isEmpty(form.getYears())) {
|
|
|
|
|
return "年月不能为空";
|
|
|
|
|
}
|
|
|
|
|
if (StringUtil.isEmpty(form.getProductId())) {
|
|
|
|
|
return "产品编码不能为空";
|
|
|
|
|
}
|
|
|
|
|
if (StringUtil.isEmpty(form.getModel())) {
|
|
|
|
|
return "规格型号不能为空";
|
|
|
|
|
}
|
|
|
|
|
if (StringUtil.isEmpty(form.getMeasurementUnit())) {
|
|
|
|
|
return "计量单位不能为空";
|
|
|
|
|
}
|
|
|
|
|
if (StringUtil.isEmpty(form.getCurrentInventory())) {
|
|
|
|
|
return "当前库存不能为空";
|
|
|
|
|
}
|
|
|
|
|
return countRecover;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增修改数据(事务回滚)
|
|
|
|
|
* @param id
|
|
|
|
|
* @param yysMonthlyProductionForm
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
* 新增修改数据(事务回滚)
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
* @param yysMonthlyProductionForm
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public void saveOrUpdate(YysMonthlyProductionForm yysMonthlyProductionForm,String id, boolean isSave) throws Exception{
|
|
|
|
|
UserInfo userInfo=userProvider.get();
|
|
|
|
|
public String saveOrUpdate(YysMonthlyProductionForm yysMonthlyProductionForm, String id, boolean isSave) {
|
|
|
|
|
UserInfo userInfo = userProvider.get();
|
|
|
|
|
LambdaQueryWrapper<YysMonthlyProductionEntity> wrapper = new LambdaQueryWrapper<>(YysMonthlyProductionEntity.class);
|
|
|
|
|
|
|
|
|
|
UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId());
|
|
|
|
|
yysMonthlyProductionForm = JsonUtil.getJsonToBean(
|
|
|
|
|
generaterSwapUtil.swapDatetime(YysMonthlyProductionConstant.getFormData(),yysMonthlyProductionForm),YysMonthlyProductionForm.class);
|
|
|
|
|
generaterSwapUtil.swapDatetime(YysMonthlyProductionConstant.getFormData(), yysMonthlyProductionForm), YysMonthlyProductionForm.class);
|
|
|
|
|
YysMonthlyProductionEntity entity = JsonUtil.getJsonToBean(yysMonthlyProductionForm, YysMonthlyProductionEntity.class);
|
|
|
|
|
|
|
|
|
|
if(isSave){
|
|
|
|
|
String mainId = RandomUtil.uuId() ;
|
|
|
|
|
if (isSave) {
|
|
|
|
|
wrapper.eq(YysMonthlyProductionEntity::getYears, yysMonthlyProductionForm.getYears());
|
|
|
|
|
wrapper.eq(YysMonthlyProductionEntity::getProductName, yysMonthlyProductionForm.getProductName());
|
|
|
|
|
if (CollectionUtils.isNotEmpty(this.list(wrapper))) {
|
|
|
|
|
return "所选年月与产品已被创建";
|
|
|
|
|
}
|
|
|
|
|
String mainId = RandomUtil.uuId();
|
|
|
|
|
entity.setCreatorTime(DateUtil.getNowDate());
|
|
|
|
|
entity.setCreatorUserId(userInfo.getUserId());
|
|
|
|
|
entity.setId(mainId);
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
wrapper.ne(YysMonthlyProductionEntity::getYears, yysMonthlyProductionForm.getYears());
|
|
|
|
|
wrapper.ne(YysMonthlyProductionEntity::getProductName, yysMonthlyProductionForm.getProductName());
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(this.list(wrapper))) {
|
|
|
|
|
return "所选年月与产品已被创建";
|
|
|
|
|
}
|
|
|
|
|
entity.setLastModifyTime(DateUtil.getNowDate());
|
|
|
|
|
entity.setLastModifyUserId(userInfo.getUserId());
|
|
|
|
|
}
|
|
|
|
|
boolean result = this.saveOrUpdate(entity);
|
|
|
|
|
if (result) {
|
|
|
|
|
return "操作成功";
|
|
|
|
|
}
|
|
|
|
|
this.saveOrUpdate(entity);
|
|
|
|
|
return "操作失败";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|