|
|
|
@ -1,37 +1,45 @@
|
|
|
|
|
package jnpf.service.impl;
|
|
|
|
|
|
|
|
|
|
import jnpf.entity.*;
|
|
|
|
|
import jnpf.mapper.YysBillMaterialMapper;
|
|
|
|
|
import jnpf.service.*;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import jnpf.model.yysbillmaterial.*;
|
|
|
|
|
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.dynamic.datasource.annotation.DS;
|
|
|
|
|
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.springframework.stereotype.Service;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import jnpf.database.model.superQuery.SuperJsonModel;
|
|
|
|
|
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 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
import com.google.common.collect.Maps;
|
|
|
|
|
import jnpf.base.UserInfo;
|
|
|
|
|
import jnpf.base.model.ColumnDataModel;
|
|
|
|
|
import jnpf.database.model.superQuery.SuperJsonModel;
|
|
|
|
|
import jnpf.entity.YysBillMaterialEntity;
|
|
|
|
|
import jnpf.entity.YysSubsetMaterialEntity;
|
|
|
|
|
import jnpf.mapper.YysBillMaterialMapper;
|
|
|
|
|
import jnpf.model.QueryModel;
|
|
|
|
|
import jnpf.model.yysbillmaterial.*;
|
|
|
|
|
import jnpf.model.yysmaterialinformation.MaterialInformationSync;
|
|
|
|
|
import jnpf.permission.entity.UserEntity;
|
|
|
|
|
import jnpf.service.YysBillMaterialService;
|
|
|
|
|
import jnpf.service.YysSubsetMaterialService;
|
|
|
|
|
import jnpf.util.*;
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
import org.apache.commons.collections4.MapUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
|
|
import org.springframework.jdbc.core.RowMapper;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.function.Function;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* yysBillMaterial
|
|
|
|
|
* 版本: V3.5
|
|
|
|
|
* 版权: 引迈信息技术有限公司(https://www.jnpfsoft.com)
|
|
|
|
@ -39,103 +47,112 @@ import jnpf.permission.entity.UserEntity;
|
|
|
|
|
* 日期: 2024-08-08
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
public class YysBillMaterialServiceImpl extends ServiceImpl<YysBillMaterialMapper, YysBillMaterialEntity> implements YysBillMaterialService{
|
|
|
|
|
public class YysBillMaterialServiceImpl extends ServiceImpl<YysBillMaterialMapper, YysBillMaterialEntity> implements YysBillMaterialService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private GeneraterSwapUtil generaterSwapUtil;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private UserProvider userProvider;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private YysSubsetMaterialService yysSubsetMaterialService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<YysBillMaterialEntity> getList(YysBillMaterialPagination yysBillMaterialPagination){
|
|
|
|
|
return getTypeList(yysBillMaterialPagination,yysBillMaterialPagination.getDataType());
|
|
|
|
|
public List<YysBillMaterialEntity> getList(YysBillMaterialPagination yysBillMaterialPagination) {
|
|
|
|
|
return getTypeList(yysBillMaterialPagination, yysBillMaterialPagination.getDataType());
|
|
|
|
|
}
|
|
|
|
|
/** 列表查询 */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 列表查询
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<YysBillMaterialEntity> getTypeList(YysBillMaterialPagination yysBillMaterialPagination,String dataType){
|
|
|
|
|
String userId=userProvider.get().getUserId();
|
|
|
|
|
List<String> AllIdList =new ArrayList();
|
|
|
|
|
List<List<String>> intersectionList =new ArrayList<>();
|
|
|
|
|
public List<YysBillMaterialEntity> getTypeList(YysBillMaterialPagination yysBillMaterialPagination, 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 ? YysBillMaterialConstant.getAppColumnData() : YysBillMaterialConstant.getColumnData();
|
|
|
|
|
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class);
|
|
|
|
|
String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList());
|
|
|
|
|
|
|
|
|
|
int total=0;
|
|
|
|
|
int yysBillMaterialNum =0;
|
|
|
|
|
QueryWrapper<YysBillMaterialEntity> yysBillMaterialQueryWrapper=new QueryWrapper<>();
|
|
|
|
|
int total = 0;
|
|
|
|
|
int yysBillMaterialNum = 0;
|
|
|
|
|
QueryWrapper<YysBillMaterialEntity> yysBillMaterialQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
List<String> allSuperIDlist = new ArrayList<>();
|
|
|
|
|
String superOp ="";
|
|
|
|
|
if (ObjectUtil.isNotEmpty(yysBillMaterialPagination.getSuperQueryJson())){
|
|
|
|
|
String superOp = "";
|
|
|
|
|
if (ObjectUtil.isNotEmpty(yysBillMaterialPagination.getSuperQueryJson())) {
|
|
|
|
|
List<String> allSuperList = new ArrayList<>();
|
|
|
|
|
List<List<String>> intersectionSuperList = new ArrayList<>();
|
|
|
|
|
String queryJson = yysBillMaterialPagination.getSuperQueryJson();
|
|
|
|
|
SuperJsonModel superJsonModel = JsonUtil.getJsonToBean(queryJson, SuperJsonModel.class);
|
|
|
|
|
int superNum = 0;
|
|
|
|
|
QueryWrapper<YysBillMaterialEntity> yysBillMaterialSuperWrapper = new QueryWrapper<>();
|
|
|
|
|
yysBillMaterialSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysBillMaterialSuperWrapper,YysBillMaterialEntity.class,queryJson,"0"));
|
|
|
|
|
yysBillMaterialSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysBillMaterialSuperWrapper, YysBillMaterialEntity.class, queryJson, "0"));
|
|
|
|
|
int yysBillMaterialNum1 = yysBillMaterialSuperWrapper.getExpression().getNormal().size();
|
|
|
|
|
if (yysBillMaterialNum1>0){
|
|
|
|
|
List<String> yysBillMaterialList =this.list(yysBillMaterialSuperWrapper).stream().map(YysBillMaterialEntity::getId).collect(Collectors.toList());
|
|
|
|
|
if (yysBillMaterialNum1 > 0) {
|
|
|
|
|
List<String> yysBillMaterialList = this.list(yysBillMaterialSuperWrapper).stream().map(YysBillMaterialEntity::getId).collect(Collectors.toList());
|
|
|
|
|
allSuperList.addAll(yysBillMaterialList);
|
|
|
|
|
intersectionSuperList.add(yysBillMaterialList);
|
|
|
|
|
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<>();
|
|
|
|
|
SuperJsonModel ruleJsonModel = JsonUtil.getJsonToBean(ruleJson, SuperJsonModel.class);
|
|
|
|
|
int ruleNum = 0;
|
|
|
|
|
QueryWrapper<YysBillMaterialEntity> yysBillMaterialSuperWrapper = new QueryWrapper<>();
|
|
|
|
|
yysBillMaterialSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysBillMaterialSuperWrapper,YysBillMaterialEntity.class,ruleJson,"0"));
|
|
|
|
|
yysBillMaterialSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysBillMaterialSuperWrapper, YysBillMaterialEntity.class, ruleJson, "0"));
|
|
|
|
|
int yysBillMaterialNum1 = yysBillMaterialSuperWrapper.getExpression().getNormal().size();
|
|
|
|
|
if (yysBillMaterialNum1>0){
|
|
|
|
|
List<String> yysBillMaterialList =this.list(yysBillMaterialSuperWrapper).stream().map(YysBillMaterialEntity::getId).collect(Collectors.toList());
|
|
|
|
|
if (yysBillMaterialNum1 > 0) {
|
|
|
|
|
List<String> yysBillMaterialList = this.list(yysBillMaterialSuperWrapper).stream().map(YysBillMaterialEntity::getId).collect(Collectors.toList());
|
|
|
|
|
allRuleList.addAll(yysBillMaterialList);
|
|
|
|
|
intersectionRuleList.add(yysBillMaterialList);
|
|
|
|
|
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 yysBillMaterialObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysBillMaterialQueryWrapper,YysBillMaterialEntity.class,yysBillMaterialPagination.getMenuId(),"0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(yysBillMaterialObj)){
|
|
|
|
|
if (isPc && pcPermission) {
|
|
|
|
|
if (!userProvider.get().getIsAdministrator()) {
|
|
|
|
|
Object yysBillMaterialObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysBillMaterialQueryWrapper, YysBillMaterialEntity.class, yysBillMaterialPagination.getMenuId(), "0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(yysBillMaterialObj)) {
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
yysBillMaterialQueryWrapper = (QueryWrapper<YysBillMaterialEntity>)yysBillMaterialObj;
|
|
|
|
|
if( yysBillMaterialQueryWrapper.getExpression().getNormal().size()>0){
|
|
|
|
|
yysBillMaterialQueryWrapper = (QueryWrapper<YysBillMaterialEntity>) yysBillMaterialObj;
|
|
|
|
|
if (yysBillMaterialQueryWrapper.getExpression().getNormal().size() > 0) {
|
|
|
|
|
yysBillMaterialNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!isPc && appPermission){
|
|
|
|
|
if (!userProvider.get().getIsAdministrator()){
|
|
|
|
|
Object yysBillMaterialObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysBillMaterialQueryWrapper,YysBillMaterialEntity.class,yysBillMaterialPagination.getMenuId(),"0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(yysBillMaterialObj)){
|
|
|
|
|
if (!isPc && appPermission) {
|
|
|
|
|
if (!userProvider.get().getIsAdministrator()) {
|
|
|
|
|
Object yysBillMaterialObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysBillMaterialQueryWrapper, YysBillMaterialEntity.class, yysBillMaterialPagination.getMenuId(), "0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(yysBillMaterialObj)) {
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
yysBillMaterialQueryWrapper = (QueryWrapper<YysBillMaterialEntity>)yysBillMaterialObj;
|
|
|
|
|
if( yysBillMaterialQueryWrapper.getExpression().getNormal().size()>0){
|
|
|
|
|
yysBillMaterialQueryWrapper = (QueryWrapper<YysBillMaterialEntity>) yysBillMaterialObj;
|
|
|
|
|
if (yysBillMaterialQueryWrapper.getExpression().getNormal().size() > 0) {
|
|
|
|
|
yysBillMaterialNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -143,143 +160,152 @@ public class YysBillMaterialServiceImpl extends ServiceImpl<YysBillMaterialMappe
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(isPc){
|
|
|
|
|
if(ObjectUtil.isNotEmpty(yysBillMaterialPagination.getPieceId())){
|
|
|
|
|
if (isPc) {
|
|
|
|
|
if (ObjectUtil.isNotEmpty(yysBillMaterialPagination.getPieceId())) {
|
|
|
|
|
yysBillMaterialNum++;
|
|
|
|
|
|
|
|
|
|
String value = yysBillMaterialPagination.getPieceId() instanceof List ?
|
|
|
|
|
JsonUtil.getObjectToString(yysBillMaterialPagination.getPieceId()) :
|
|
|
|
|
String.valueOf(yysBillMaterialPagination.getPieceId());
|
|
|
|
|
yysBillMaterialQueryWrapper.lambda().like(YysBillMaterialEntity::getPieceId,value);
|
|
|
|
|
yysBillMaterialQueryWrapper.lambda().like(YysBillMaterialEntity::getPieceId, value);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ObjectUtil.isNotEmpty(yysBillMaterialPagination.getPieceName())){
|
|
|
|
|
if (ObjectUtil.isNotEmpty(yysBillMaterialPagination.getPieceName())) {
|
|
|
|
|
yysBillMaterialNum++;
|
|
|
|
|
|
|
|
|
|
String value = yysBillMaterialPagination.getPieceName() instanceof List ?
|
|
|
|
|
JsonUtil.getObjectToString(yysBillMaterialPagination.getPieceName()) :
|
|
|
|
|
String.valueOf(yysBillMaterialPagination.getPieceName());
|
|
|
|
|
yysBillMaterialQueryWrapper.lambda().like(YysBillMaterialEntity::getPieceName,value);
|
|
|
|
|
yysBillMaterialQueryWrapper.lambda().like(YysBillMaterialEntity::getPieceName, value);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ObjectUtil.isNotEmpty(yysBillMaterialPagination.getDocumentStatus())){
|
|
|
|
|
if (ObjectUtil.isNotEmpty(yysBillMaterialPagination.getDocumentStatus())) {
|
|
|
|
|
yysBillMaterialNum++;
|
|
|
|
|
|
|
|
|
|
String value = yysBillMaterialPagination.getDocumentStatus() instanceof List ?
|
|
|
|
|
JsonUtil.getObjectToString(yysBillMaterialPagination.getDocumentStatus()) :
|
|
|
|
|
String.valueOf(yysBillMaterialPagination.getDocumentStatus());
|
|
|
|
|
yysBillMaterialQueryWrapper.lambda().like(YysBillMaterialEntity::getDocumentStatus,value);
|
|
|
|
|
yysBillMaterialQueryWrapper.lambda().like(YysBillMaterialEntity::getDocumentStatus, value);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
List<String> intersection = generaterSwapUtil.getIntersection(intersectionList);
|
|
|
|
|
if (total>0){
|
|
|
|
|
if (intersection.size()==0){
|
|
|
|
|
if (total > 0) {
|
|
|
|
|
if (intersection.size() == 0) {
|
|
|
|
|
intersection.add("jnpfNullList");
|
|
|
|
|
}
|
|
|
|
|
yysBillMaterialQueryWrapper.lambda().in(YysBillMaterialEntity::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;
|
|
|
|
|
yysBillMaterialQueryWrapper.lambda().and(t->t.in(YysBillMaterialEntity::getId, finalAllSuperIDlist));
|
|
|
|
|
yysBillMaterialQueryWrapper.lambda().and(t -> t.in(YysBillMaterialEntity::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;
|
|
|
|
|
yysBillMaterialQueryWrapper.lambda().and(t->t.in(YysBillMaterialEntity::getId, finalAllRuleIDlist));
|
|
|
|
|
yysBillMaterialQueryWrapper.lambda().and(t -> t.in(YysBillMaterialEntity::getId, finalAllRuleIDlist));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//排序
|
|
|
|
|
if(StringUtil.isEmpty(yysBillMaterialPagination.getSidx())){
|
|
|
|
|
if (StringUtil.isEmpty(yysBillMaterialPagination.getSidx())) {
|
|
|
|
|
yysBillMaterialQueryWrapper.lambda().orderByDesc(YysBillMaterialEntity::getId);
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
try {
|
|
|
|
|
String sidx = yysBillMaterialPagination.getSidx();
|
|
|
|
|
String[] strs= sidx.split("_name");
|
|
|
|
|
String[] strs = sidx.split("_name");
|
|
|
|
|
YysBillMaterialEntity yysBillMaterialEntity = new YysBillMaterialEntity();
|
|
|
|
|
Field declaredField = yysBillMaterialEntity.getClass().getDeclaredField(strs[0]);
|
|
|
|
|
declaredField.setAccessible(true);
|
|
|
|
|
String value = declaredField.getAnnotation(TableField.class).value();
|
|
|
|
|
yysBillMaterialQueryWrapper="asc".equals(yysBillMaterialPagination.getSort().toLowerCase())?yysBillMaterialQueryWrapper.orderByAsc(value):yysBillMaterialQueryWrapper.orderByDesc(value);
|
|
|
|
|
yysBillMaterialQueryWrapper = "asc".equals(yysBillMaterialPagination.getSort().toLowerCase()) ? yysBillMaterialQueryWrapper.orderByAsc(value) : yysBillMaterialQueryWrapper.orderByDesc(value);
|
|
|
|
|
} catch (NoSuchFieldException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if("0".equals(dataType)){
|
|
|
|
|
if((total>0 && AllIdList.size()>0) || total==0){
|
|
|
|
|
Page<YysBillMaterialEntity> page=new Page<>(yysBillMaterialPagination.getCurrentPage(), yysBillMaterialPagination.getPageSize());
|
|
|
|
|
IPage<YysBillMaterialEntity> userIPage=this.page(page, yysBillMaterialQueryWrapper);
|
|
|
|
|
return yysBillMaterialPagination.setData(userIPage.getRecords(),userIPage.getTotal());
|
|
|
|
|
}else{
|
|
|
|
|
if ("0".equals(dataType)) {
|
|
|
|
|
if ((total > 0 && AllIdList.size() > 0) || total == 0) {
|
|
|
|
|
Page<YysBillMaterialEntity> page = new Page<>(yysBillMaterialPagination.getCurrentPage(), yysBillMaterialPagination.getPageSize());
|
|
|
|
|
IPage<YysBillMaterialEntity> userIPage = this.page(page, yysBillMaterialQueryWrapper);
|
|
|
|
|
return yysBillMaterialPagination.setData(userIPage.getRecords(), userIPage.getTotal());
|
|
|
|
|
} else {
|
|
|
|
|
List<YysBillMaterialEntity> list = new ArrayList();
|
|
|
|
|
return yysBillMaterialPagination.setData(list, list.size());
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
return this.list(yysBillMaterialQueryWrapper);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public YysBillMaterialEntity getInfo(String id){
|
|
|
|
|
QueryWrapper<YysBillMaterialEntity> queryWrapper=new QueryWrapper<>();
|
|
|
|
|
queryWrapper.lambda().eq(YysBillMaterialEntity::getId,id);
|
|
|
|
|
public YysBillMaterialEntity getInfo(String id) {
|
|
|
|
|
QueryWrapper<YysBillMaterialEntity> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper.lambda().eq(YysBillMaterialEntity::getId, id);
|
|
|
|
|
return this.getOne(queryWrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void create(YysBillMaterialEntity entity){
|
|
|
|
|
public void create(YysBillMaterialEntity entity) {
|
|
|
|
|
this.save(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean update(String id, YysBillMaterialEntity entity){
|
|
|
|
|
public boolean update(String id, YysBillMaterialEntity entity) {
|
|
|
|
|
return this.updateById(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void delete(YysBillMaterialEntity entity){
|
|
|
|
|
if(entity!=null){
|
|
|
|
|
public void delete(YysBillMaterialEntity entity) {
|
|
|
|
|
if (entity != null) {
|
|
|
|
|
this.removeById(entity.getId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/** 验证表单唯一字段,正则,非空 i-0新增-1修改*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 验证表单唯一字段,正则,非空 i-0新增-1修改
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public String checkForm(YysBillMaterialForm form,int i) {
|
|
|
|
|
boolean isUp =StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0");
|
|
|
|
|
String id="";
|
|
|
|
|
public String checkForm(YysBillMaterialForm 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 yysBillMaterialForm
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public void saveOrUpdate(YysBillMaterialForm yysBillMaterialForm,String id, boolean isSave) throws Exception{
|
|
|
|
|
UserInfo userInfo=userProvider.get();
|
|
|
|
|
public void saveOrUpdate(YysBillMaterialForm yysBillMaterialForm, String id, boolean isSave) throws Exception {
|
|
|
|
|
UserInfo userInfo = userProvider.get();
|
|
|
|
|
UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId());
|
|
|
|
|
yysBillMaterialForm = JsonUtil.getJsonToBean(
|
|
|
|
|
generaterSwapUtil.swapDatetime(YysBillMaterialConstant.getFormData(),yysBillMaterialForm),YysBillMaterialForm.class);
|
|
|
|
|
generaterSwapUtil.swapDatetime(YysBillMaterialConstant.getFormData(), yysBillMaterialForm), YysBillMaterialForm.class);
|
|
|
|
|
YysBillMaterialEntity entity = JsonUtil.getJsonToBean(yysBillMaterialForm, YysBillMaterialEntity.class);
|
|
|
|
|
|
|
|
|
|
if(isSave){
|
|
|
|
|
String mainId = RandomUtil.uuId() ;
|
|
|
|
|
if (isSave) {
|
|
|
|
|
String mainId = RandomUtil.uuId();
|
|
|
|
|
entity.setId(mainId);
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
}
|
|
|
|
|
this.saveOrUpdate(entity);
|
|
|
|
|
|
|
|
|
@ -288,14 +314,94 @@ public class YysBillMaterialServiceImpl extends ServiceImpl<YysBillMaterialMappe
|
|
|
|
|
@Override
|
|
|
|
|
public YysBillMaterialEntity getByProductId(String id) {
|
|
|
|
|
QueryWrapper<YysBillMaterialEntity> wrapper = new QueryWrapper<>();
|
|
|
|
|
wrapper.lambda().eq(YysBillMaterialEntity::getPieceId,id);
|
|
|
|
|
wrapper.lambda().eq(YysBillMaterialEntity::getPieceId, id);
|
|
|
|
|
return this.getOne(wrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<YysBillMaterialEntity> getListByProductIds(List<String> id) {
|
|
|
|
|
QueryWrapper<YysBillMaterialEntity> wrapper = new QueryWrapper<>();
|
|
|
|
|
wrapper.lambda().in(YysBillMaterialEntity::getPieceId,id);
|
|
|
|
|
wrapper.lambda().in(YysBillMaterialEntity::getPieceId, id);
|
|
|
|
|
return this.list(wrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@DS("slave_2")
|
|
|
|
|
public String syncMaterial() {
|
|
|
|
|
List<String> syncList = this.list(new LambdaQueryWrapper<>(YysBillMaterialEntity.class).isNull(YysBillMaterialEntity::getDeleteMark))
|
|
|
|
|
.stream().map(YysBillMaterialEntity::getId).collect(Collectors.toList());
|
|
|
|
|
//母件物料
|
|
|
|
|
RowMapper<SyncMaterial> rowMapper = new BeanPropertyRowMapper<>(SyncMaterial.class);
|
|
|
|
|
String sql = "select * from v_bom_parent_rpt";
|
|
|
|
|
List<SyncMaterial> query = this.jdbcTemplate.query(sql, rowMapper);
|
|
|
|
|
if (CollectionUtils.isEmpty(query)) {
|
|
|
|
|
return "远程母件物料信息为空";
|
|
|
|
|
}
|
|
|
|
|
//过滤出同步过的
|
|
|
|
|
query = query.stream().filter(obj -> !syncList.contains(obj.getAutoId())).collect(Collectors.toList());
|
|
|
|
|
//子件物料
|
|
|
|
|
RowMapper<SyncSubsetMaterial> subMapper = new BeanPropertyRowMapper<>(SyncSubsetMaterial.class);
|
|
|
|
|
String subsetSql = "select * from v_bom_opcomponent_rpt";
|
|
|
|
|
List<SyncSubsetMaterial> subsetMaterials = this.jdbcTemplate.query(subsetSql, subMapper);
|
|
|
|
|
Map<String, List<SyncSubsetMaterial>> subsetCollect = Maps.newHashMap();
|
|
|
|
|
if (CollectionUtils.isNotEmpty(subsetMaterials)) {
|
|
|
|
|
subsetCollect = subsetMaterials.stream().collect(Collectors.groupingBy(SyncSubsetMaterial::getBomId));
|
|
|
|
|
}
|
|
|
|
|
//物料表数据 不从自己库取数据,防止自己库未同步,从而取不到数据
|
|
|
|
|
RowMapper<MaterialInformationSync> materialMapper = new BeanPropertyRowMapper<>(MaterialInformationSync.class);
|
|
|
|
|
String materialSql = "select * from dbo.Inventory";
|
|
|
|
|
List<MaterialInformationSync> informationSyncs = this.jdbcTemplate.query(materialSql, materialMapper);
|
|
|
|
|
Map<String, MaterialInformationSync> materialCollect = Maps.newHashMap();
|
|
|
|
|
if (CollectionUtils.isNotEmpty(informationSyncs)) {
|
|
|
|
|
materialCollect = informationSyncs.stream().collect(Collectors.toMap(MaterialInformationSync::getCInvCode, Function.identity()));
|
|
|
|
|
}
|
|
|
|
|
List<YysBillMaterialEntity> materialResult = Lists.newArrayList();
|
|
|
|
|
List<YysSubsetMaterialEntity> subsetResult = Lists.newArrayList();
|
|
|
|
|
for (SyncMaterial material : query) {
|
|
|
|
|
YysBillMaterialEntity yysBillMaterialEntity = new YysBillMaterialEntity();
|
|
|
|
|
yysBillMaterialEntity.setId(material.getAutoId());
|
|
|
|
|
yysBillMaterialEntity.setPieceId(material.getBomId());
|
|
|
|
|
if (MapUtils.isNotEmpty(materialCollect) && materialCollect.containsKey(material.getInvCode())) {
|
|
|
|
|
MaterialInformationSync sync = materialCollect.get(material.getInvCode());
|
|
|
|
|
yysBillMaterialEntity.setPieceName(sync.getCInvName());
|
|
|
|
|
yysBillMaterialEntity.setModels(sync.getEInvStd());
|
|
|
|
|
yysBillMaterialEntity.setUnit(sync.getCComUnitCode());
|
|
|
|
|
}
|
|
|
|
|
//处理子集
|
|
|
|
|
if (MapUtils.isNotEmpty(subsetCollect) && subsetCollect.containsKey(yysBillMaterialEntity.getPieceId())) {
|
|
|
|
|
List<SyncSubsetMaterial> list = subsetCollect.get(yysBillMaterialEntity.getPieceId());
|
|
|
|
|
for (SyncSubsetMaterial subsetMaterial : list) {
|
|
|
|
|
YysSubsetMaterialEntity yysSubsetMaterialEntity = new YysSubsetMaterialEntity();
|
|
|
|
|
yysSubsetMaterialEntity.setId(subsetMaterial.getOpComponentId());
|
|
|
|
|
yysSubsetMaterialEntity.setPieceId(yysBillMaterialEntity.getId());
|
|
|
|
|
yysSubsetMaterialEntity.setSubsetId(subsetMaterial.getBomId());
|
|
|
|
|
yysSubsetMaterialEntity.setBaseUse(subsetMaterial.getBaseQtyN());
|
|
|
|
|
yysSubsetMaterialEntity.setBaseNum(subsetMaterial.getBaseQtyD());
|
|
|
|
|
if (MapUtils.isNotEmpty(materialCollect) && materialCollect.containsKey(subsetMaterial.getInvCode())) {
|
|
|
|
|
MaterialInformationSync sync = materialCollect.get(subsetMaterial.getInvCode());
|
|
|
|
|
yysSubsetMaterialEntity.setSubsetName(sync.getCInvName());
|
|
|
|
|
yysSubsetMaterialEntity.setSubsetModel(sync.getEInvStd());
|
|
|
|
|
yysSubsetMaterialEntity.setUnit(sync.getCComUnitCode());
|
|
|
|
|
}
|
|
|
|
|
yysSubsetMaterialEntity.setCreatorTime(DateUtil.getNowDate());
|
|
|
|
|
//默认给个状态
|
|
|
|
|
yysSubsetMaterialEntity.setStatus("2");
|
|
|
|
|
subsetResult.add(yysSubsetMaterialEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//暂时默认单据状态为已审核
|
|
|
|
|
yysBillMaterialEntity.setDocumentStatus("2");
|
|
|
|
|
yysBillMaterialEntity.setCreatorTime(DateUtil.getNowDate());
|
|
|
|
|
materialResult.add(yysBillMaterialEntity);
|
|
|
|
|
}
|
|
|
|
|
if (CollectionUtils.isEmpty(materialResult)) {
|
|
|
|
|
return "没有需要同步的数据";
|
|
|
|
|
}
|
|
|
|
|
boolean material = this.saveBatch(materialResult);
|
|
|
|
|
boolean savedBatch = yysSubsetMaterialService.saveBatch(subsetResult);
|
|
|
|
|
if (material && savedBatch) {
|
|
|
|
|
return "同步成功";
|
|
|
|
|
}
|
|
|
|
|
return "同步失败";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|