|
|
|
@ -0,0 +1,496 @@
|
|
|
|
|
package jnpf.service.impl;
|
|
|
|
|
|
|
|
|
|
import jnpf.entity.*;
|
|
|
|
|
import jnpf.mapper.ProductWarehouseMapper;
|
|
|
|
|
import jnpf.service.*;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import jnpf.model.productwarehouse.*;
|
|
|
|
|
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.springframework.stereotype.Service;
|
|
|
|
|
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 jnpf.base.UserInfo;
|
|
|
|
|
import jnpf.permission.entity.UserEntity;
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* productWarehouse
|
|
|
|
|
* 版本: V3.5
|
|
|
|
|
* 版权: 引迈信息技术有限公司(https://www.jnpfsoft.com)
|
|
|
|
|
* 作者: JNPF开发平台组
|
|
|
|
|
* 日期: 2024-01-31
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
public class ProductWarehouseServiceImpl extends ServiceImpl<ProductWarehouseMapper, ProductWarehouseEntity> implements ProductWarehouseService{
|
|
|
|
|
@Autowired
|
|
|
|
|
private GeneraterSwapUtil generaterSwapUtil;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private UserProvider userProvider;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ProductBusinessService productBusinessService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ProductUnitService productUnitService;
|
|
|
|
|
@Override
|
|
|
|
|
public List<ProductWarehouseEntity> getList(ProductWarehousePagination productWarehousePagination){
|
|
|
|
|
return getTypeList(productWarehousePagination,productWarehousePagination.getDataType());
|
|
|
|
|
}
|
|
|
|
|
/** 列表查询 */
|
|
|
|
|
@Override
|
|
|
|
|
public List<ProductWarehouseEntity> getTypeList(ProductWarehousePagination productWarehousePagination,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 ? ProductWarehouseConstant.getAppColumnData() : ProductWarehouseConstant.getColumnData();
|
|
|
|
|
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class);
|
|
|
|
|
String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList());
|
|
|
|
|
|
|
|
|
|
int total=0;
|
|
|
|
|
int productWarehouseNum =0;
|
|
|
|
|
QueryWrapper<ProductWarehouseEntity> productWarehouseQueryWrapper=new QueryWrapper<>();
|
|
|
|
|
int productBusinessNum =0;
|
|
|
|
|
QueryWrapper<ProductBusinessEntity> productBusinessQueryWrapper=new QueryWrapper<>();
|
|
|
|
|
int productUnitNum =0;
|
|
|
|
|
QueryWrapper<ProductUnitEntity> productUnitQueryWrapper=new QueryWrapper<>();
|
|
|
|
|
long productBusinesscount = productBusinessService.count();
|
|
|
|
|
long productUnitcount = productUnitService.count();
|
|
|
|
|
List<String> allSuperIDlist = new ArrayList<>();
|
|
|
|
|
String superOp ="";
|
|
|
|
|
if (ObjectUtil.isNotEmpty(productWarehousePagination.getSuperQueryJson())){
|
|
|
|
|
List<String> allSuperList = new ArrayList<>();
|
|
|
|
|
List<List<String>> intersectionSuperList = new ArrayList<>();
|
|
|
|
|
String queryJson = productWarehousePagination.getSuperQueryJson();
|
|
|
|
|
SuperJsonModel superJsonModel = JsonUtil.getJsonToBean(queryJson, SuperJsonModel.class);
|
|
|
|
|
int superNum = 0;
|
|
|
|
|
QueryWrapper<ProductWarehouseEntity> productWarehouseSuperWrapper = new QueryWrapper<>();
|
|
|
|
|
productWarehouseSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(productWarehouseSuperWrapper,ProductWarehouseEntity.class,queryJson,"0"));
|
|
|
|
|
int productWarehouseNum1 = productWarehouseSuperWrapper.getExpression().getNormal().size();
|
|
|
|
|
if (productWarehouseNum1>0){
|
|
|
|
|
List<String> productWarehouseList =this.list(productWarehouseSuperWrapper).stream().map(ProductWarehouseEntity::getId).collect(Collectors.toList());
|
|
|
|
|
allSuperList.addAll(productWarehouseList);
|
|
|
|
|
intersectionSuperList.add(productWarehouseList);
|
|
|
|
|
superNum++;
|
|
|
|
|
}
|
|
|
|
|
String productBusinessTable = "jg_product_business";
|
|
|
|
|
boolean productBusinessHasSql = queryJson.contains(productBusinessTable);
|
|
|
|
|
List<String> productBusinessList = generaterSwapUtil.selectIdsByChildCondition(ProductWarehouseConstant.getTableList(), productBusinessTable , queryJson, null);
|
|
|
|
|
if (productBusinessHasSql){
|
|
|
|
|
allSuperList.addAll(productBusinessList);
|
|
|
|
|
intersectionSuperList.add(productBusinessList);
|
|
|
|
|
superNum++;
|
|
|
|
|
}
|
|
|
|
|
String productUnitTable = "jg_product_unit";
|
|
|
|
|
boolean productUnitHasSql = queryJson.contains(productUnitTable);
|
|
|
|
|
List<String> productUnitList = generaterSwapUtil.selectIdsByChildCondition(ProductWarehouseConstant.getTableList(), productUnitTable , queryJson, null);
|
|
|
|
|
if (productUnitHasSql){
|
|
|
|
|
allSuperList.addAll(productUnitList);
|
|
|
|
|
intersectionSuperList.add(productUnitList);
|
|
|
|
|
superNum++;
|
|
|
|
|
}
|
|
|
|
|
superOp = superNum > 0 ? superJsonModel.getMatchLogic() : "";
|
|
|
|
|
//and or
|
|
|
|
|
if(superOp.equalsIgnoreCase("and")){
|
|
|
|
|
allSuperIDlist = generaterSwapUtil.getIntersection(intersectionSuperList);
|
|
|
|
|
}else{
|
|
|
|
|
allSuperIDlist = allSuperList;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
List<String> allRuleIDlist = new ArrayList<>();
|
|
|
|
|
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<ProductWarehouseEntity> productWarehouseSuperWrapper = new QueryWrapper<>();
|
|
|
|
|
productWarehouseSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(productWarehouseSuperWrapper,ProductWarehouseEntity.class,ruleJson,"0"));
|
|
|
|
|
int productWarehouseNum1 = productWarehouseSuperWrapper.getExpression().getNormal().size();
|
|
|
|
|
if (productWarehouseNum1>0){
|
|
|
|
|
List<String> productWarehouseList =this.list(productWarehouseSuperWrapper).stream().map(ProductWarehouseEntity::getId).collect(Collectors.toList());
|
|
|
|
|
allRuleList.addAll(productWarehouseList);
|
|
|
|
|
intersectionRuleList.add(productWarehouseList);
|
|
|
|
|
ruleNum++;
|
|
|
|
|
}
|
|
|
|
|
String productBusinessTable = "jg_product_business";
|
|
|
|
|
boolean productBusinessHasSql = ruleJson.contains(productBusinessTable);
|
|
|
|
|
List<String> productBusinessList = generaterSwapUtil.selectIdsByChildCondition(ProductWarehouseConstant.getTableList(), productBusinessTable , ruleJson, null);
|
|
|
|
|
if (productBusinessHasSql){
|
|
|
|
|
allRuleList.addAll(productBusinessList);
|
|
|
|
|
intersectionRuleList.add(productBusinessList);
|
|
|
|
|
ruleNum++;
|
|
|
|
|
}
|
|
|
|
|
String productUnitTable = "jg_product_unit";
|
|
|
|
|
boolean productUnitHasSql = ruleJson.contains(productUnitTable);
|
|
|
|
|
List<String> productUnitList = generaterSwapUtil.selectIdsByChildCondition(ProductWarehouseConstant.getTableList(), productUnitTable , ruleJson, null);
|
|
|
|
|
if (productUnitHasSql){
|
|
|
|
|
allRuleList.addAll(productUnitList);
|
|
|
|
|
intersectionRuleList.add(productUnitList);
|
|
|
|
|
ruleNum++;
|
|
|
|
|
}
|
|
|
|
|
ruleOp = ruleNum > 0 ? ruleJsonModel.getMatchLogic() : "";
|
|
|
|
|
//and or
|
|
|
|
|
if(ruleOp.equalsIgnoreCase("and")){
|
|
|
|
|
allRuleIDlist = generaterSwapUtil.getIntersection(intersectionRuleList);
|
|
|
|
|
}else{
|
|
|
|
|
allRuleIDlist = allRuleList;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
boolean pcPermission = false;
|
|
|
|
|
boolean appPermission = false;
|
|
|
|
|
if(isPc && pcPermission){
|
|
|
|
|
if (!userProvider.get().getIsAdministrator()){
|
|
|
|
|
Object productWarehouseObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(productWarehouseQueryWrapper,ProductWarehouseEntity.class,productWarehousePagination.getMenuId(),"0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(productWarehouseObj)){
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
productWarehouseQueryWrapper = (QueryWrapper<ProductWarehouseEntity>)productWarehouseObj;
|
|
|
|
|
if( productWarehouseQueryWrapper.getExpression().getNormal().size()>0){
|
|
|
|
|
productWarehouseNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Object productBusinessObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(productBusinessQueryWrapper,ProductBusinessEntity.class,productWarehousePagination.getMenuId(),"0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(productBusinessObj)){
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
productBusinessQueryWrapper = (QueryWrapper<ProductBusinessEntity>)productBusinessObj;
|
|
|
|
|
if( productBusinessQueryWrapper.getExpression().getNormal().size()>0){
|
|
|
|
|
productBusinessNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Object productUnitObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(productUnitQueryWrapper,ProductUnitEntity.class,productWarehousePagination.getMenuId(),"0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(productUnitObj)){
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
productUnitQueryWrapper = (QueryWrapper<ProductUnitEntity>)productUnitObj;
|
|
|
|
|
if( productUnitQueryWrapper.getExpression().getNormal().size()>0){
|
|
|
|
|
productUnitNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!isPc && appPermission){
|
|
|
|
|
if (!userProvider.get().getIsAdministrator()){
|
|
|
|
|
Object productWarehouseObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(productWarehouseQueryWrapper,ProductWarehouseEntity.class,productWarehousePagination.getMenuId(),"0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(productWarehouseObj)){
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
productWarehouseQueryWrapper = (QueryWrapper<ProductWarehouseEntity>)productWarehouseObj;
|
|
|
|
|
if( productWarehouseQueryWrapper.getExpression().getNormal().size()>0){
|
|
|
|
|
productWarehouseNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object productBusinessObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(productBusinessQueryWrapper,ProductBusinessEntity.class,productWarehousePagination.getMenuId(),"0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(productBusinessObj)){
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
productBusinessQueryWrapper = (QueryWrapper<ProductBusinessEntity>)productBusinessObj;
|
|
|
|
|
if( productBusinessQueryWrapper.getExpression().getNormal().size()>0){
|
|
|
|
|
productBusinessNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object productUnitObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(productUnitQueryWrapper,ProductUnitEntity.class,productWarehousePagination.getMenuId(),"0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(productUnitObj)){
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
productUnitQueryWrapper = (QueryWrapper<ProductUnitEntity>)productUnitObj;
|
|
|
|
|
if( productUnitQueryWrapper.getExpression().getNormal().size()>0){
|
|
|
|
|
productUnitNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(isPc){
|
|
|
|
|
if(ObjectUtil.isNotEmpty(productWarehousePagination.getCode())){
|
|
|
|
|
productWarehouseNum++;
|
|
|
|
|
|
|
|
|
|
String value = productWarehousePagination.getCode() instanceof List ?
|
|
|
|
|
JsonUtil.getObjectToString(productWarehousePagination.getCode()) :
|
|
|
|
|
String.valueOf(productWarehousePagination.getCode());
|
|
|
|
|
productWarehouseQueryWrapper.lambda().like(ProductWarehouseEntity::getCode,value);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ObjectUtil.isNotEmpty(productWarehousePagination.getName())){
|
|
|
|
|
productWarehouseNum++;
|
|
|
|
|
|
|
|
|
|
String value = productWarehousePagination.getName() instanceof List ?
|
|
|
|
|
JsonUtil.getObjectToString(productWarehousePagination.getName()) :
|
|
|
|
|
String.valueOf(productWarehousePagination.getName());
|
|
|
|
|
productWarehouseQueryWrapper.lambda().like(ProductWarehouseEntity::getName,value);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ObjectUtil.isNotEmpty(productWarehousePagination.getProductTypeId())){
|
|
|
|
|
productWarehouseNum++;
|
|
|
|
|
|
|
|
|
|
productWarehouseQueryWrapper.lambda().eq(ProductWarehouseEntity::getProductTypeId,productWarehousePagination.getProductTypeId());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ObjectUtil.isNotEmpty(productWarehousePagination.getInventoryType())){
|
|
|
|
|
productWarehouseNum++;
|
|
|
|
|
|
|
|
|
|
List<String> idList = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
String[][] inventoryType = JsonUtil.getJsonToBean(productWarehousePagination.getInventoryType(),String[][].class);
|
|
|
|
|
for(int i=0;i<inventoryType.length;i++){
|
|
|
|
|
if(inventoryType[i].length>0){
|
|
|
|
|
idList.add(JsonUtil.getObjectToString(Arrays.asList(inventoryType[i])));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e1){
|
|
|
|
|
try {
|
|
|
|
|
List<String> inventoryType = JsonUtil.getJsonToList(productWarehousePagination.getInventoryType(),String.class);
|
|
|
|
|
if(inventoryType.size()>0){
|
|
|
|
|
idList.addAll(inventoryType);
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e2){
|
|
|
|
|
idList.add(String.valueOf(productWarehousePagination.getInventoryType()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
productWarehouseQueryWrapper.lambda().and(t->{
|
|
|
|
|
idList.forEach(tt->{
|
|
|
|
|
t.like(ProductWarehouseEntity::getInventoryType, tt).or();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if(productBusinessNum>0){
|
|
|
|
|
List<String> productBusinessIdList = productBusinessService.list(productBusinessQueryWrapper).stream().filter(t->StringUtil.isNotEmpty(t.getProductId())).map(t->t.getProductId()).collect(Collectors.toList());
|
|
|
|
|
long count = productBusinessService.count();
|
|
|
|
|
if (count>0){
|
|
|
|
|
intersectionList.add(productBusinessIdList);
|
|
|
|
|
}
|
|
|
|
|
AllIdList.addAll(productBusinessIdList);
|
|
|
|
|
}
|
|
|
|
|
total+=productBusinessNum;
|
|
|
|
|
if(productUnitNum>0){
|
|
|
|
|
List<String> productUnitIdList = productUnitService.list(productUnitQueryWrapper).stream().filter(t->StringUtil.isNotEmpty(t.getProuctId())).map(t->t.getProuctId()).collect(Collectors.toList());
|
|
|
|
|
long count = productUnitService.count();
|
|
|
|
|
if (count>0){
|
|
|
|
|
intersectionList.add(productUnitIdList);
|
|
|
|
|
}
|
|
|
|
|
AllIdList.addAll(productUnitIdList);
|
|
|
|
|
}
|
|
|
|
|
total+=productUnitNum;
|
|
|
|
|
List<String> intersection = generaterSwapUtil.getIntersection(intersectionList);
|
|
|
|
|
if (total>0){
|
|
|
|
|
if (intersection.size()==0){
|
|
|
|
|
intersection.add("jnpfNullList");
|
|
|
|
|
}
|
|
|
|
|
productWarehouseQueryWrapper.lambda().in(ProductWarehouseEntity::getId, intersection);
|
|
|
|
|
}
|
|
|
|
|
//是否有高级查询
|
|
|
|
|
if (StringUtil.isNotEmpty(superOp)){
|
|
|
|
|
if (allSuperIDlist.size()==0){
|
|
|
|
|
allSuperIDlist.add("jnpfNullList");
|
|
|
|
|
}
|
|
|
|
|
List<String> finalAllSuperIDlist = allSuperIDlist;
|
|
|
|
|
productWarehouseQueryWrapper.lambda().and(t->t.in(ProductWarehouseEntity::getId, finalAllSuperIDlist));
|
|
|
|
|
}
|
|
|
|
|
//是否有数据过滤查询
|
|
|
|
|
if (StringUtil.isNotEmpty(ruleOp)){
|
|
|
|
|
if (allRuleIDlist.size()==0){
|
|
|
|
|
allRuleIDlist.add("jnpfNullList");
|
|
|
|
|
}
|
|
|
|
|
List<String> finalAllRuleIDlist = allRuleIDlist;
|
|
|
|
|
productWarehouseQueryWrapper.lambda().and(t->t.in(ProductWarehouseEntity::getId, finalAllRuleIDlist));
|
|
|
|
|
}
|
|
|
|
|
//假删除标志
|
|
|
|
|
productWarehouseQueryWrapper.lambda().isNull(ProductWarehouseEntity::getDeleteMark);
|
|
|
|
|
|
|
|
|
|
//排序
|
|
|
|
|
if(StringUtil.isEmpty(productWarehousePagination.getSidx())){
|
|
|
|
|
productWarehouseQueryWrapper.lambda().orderByDesc(ProductWarehouseEntity::getId);
|
|
|
|
|
}else{
|
|
|
|
|
try {
|
|
|
|
|
String sidx = productWarehousePagination.getSidx();
|
|
|
|
|
String[] strs= sidx.split("_name");
|
|
|
|
|
ProductWarehouseEntity productWarehouseEntity = new ProductWarehouseEntity();
|
|
|
|
|
Field declaredField = productWarehouseEntity.getClass().getDeclaredField(strs[0]);
|
|
|
|
|
declaredField.setAccessible(true);
|
|
|
|
|
String value = declaredField.getAnnotation(TableField.class).value();
|
|
|
|
|
productWarehouseQueryWrapper="asc".equals(productWarehousePagination.getSort().toLowerCase())?productWarehouseQueryWrapper.orderByAsc(value):productWarehouseQueryWrapper.orderByDesc(value);
|
|
|
|
|
} catch (NoSuchFieldException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if("0".equals(dataType)){
|
|
|
|
|
if((total>0 && AllIdList.size()>0) || total==0){
|
|
|
|
|
Page<ProductWarehouseEntity> page=new Page<>(productWarehousePagination.getCurrentPage(), productWarehousePagination.getPageSize());
|
|
|
|
|
IPage<ProductWarehouseEntity> userIPage=this.page(page, productWarehouseQueryWrapper);
|
|
|
|
|
return productWarehousePagination.setData(userIPage.getRecords(),userIPage.getTotal());
|
|
|
|
|
}else{
|
|
|
|
|
List<ProductWarehouseEntity> list = new ArrayList();
|
|
|
|
|
return productWarehousePagination.setData(list, list.size());
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
return this.list(productWarehouseQueryWrapper);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public ProductWarehouseEntity getInfo(String id){
|
|
|
|
|
QueryWrapper<ProductWarehouseEntity> queryWrapper=new QueryWrapper<>();
|
|
|
|
|
queryWrapper.lambda().eq(ProductWarehouseEntity::getId,id);
|
|
|
|
|
return this.getOne(queryWrapper);
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void create(ProductWarehouseEntity entity){
|
|
|
|
|
this.save(entity);
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public boolean update(String id, ProductWarehouseEntity entity){
|
|
|
|
|
return this.updateById(entity);
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void delete(ProductWarehouseEntity entity){
|
|
|
|
|
if(entity!=null){
|
|
|
|
|
this.removeById(entity.getId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/** ProductUnit子表方法 */
|
|
|
|
|
@Override
|
|
|
|
|
public List<ProductUnitEntity> getProductUnitList(String id,ProductWarehousePagination productWarehousePagination){
|
|
|
|
|
Map<String, Object> newtabMap=ProductWarehouseConstant.TABLEFIELDKEY.entrySet()
|
|
|
|
|
.stream().collect( Collectors.toMap(e->e.getValue(),e->e.getKey()));
|
|
|
|
|
String tableName="productUnit";
|
|
|
|
|
tableName=newtabMap.get(tableName)==null?tableName:newtabMap.get(tableName).toString();
|
|
|
|
|
QueryWrapper<ProductUnitEntity> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper = productUnitService.getChild(productWarehousePagination,queryWrapper);
|
|
|
|
|
queryWrapper.lambda().eq(ProductUnitEntity::getProuctId, id);
|
|
|
|
|
generaterSwapUtil.wrapperHandle(ProductWarehouseConstant.getColumnData(), ProductWarehouseConstant.getAppColumnData(), queryWrapper,ProductUnitEntity.class,"sub",tableName);
|
|
|
|
|
return productUnitService.list(queryWrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** ProductUnit子表方法 */
|
|
|
|
|
@Override
|
|
|
|
|
public List<ProductUnitEntity> getProductUnitList(String id){
|
|
|
|
|
QueryWrapper<ProductUnitEntity> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper.lambda().eq(ProductUnitEntity::getProuctId, id);
|
|
|
|
|
return productUnitService.list(queryWrapper);
|
|
|
|
|
}
|
|
|
|
|
/** ProductBusiness副表方法 */
|
|
|
|
|
@Override
|
|
|
|
|
public ProductBusinessEntity getProductBusiness(String id){
|
|
|
|
|
QueryWrapper<ProductBusinessEntity> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper.lambda().eq(ProductBusinessEntity::getProductId, id);
|
|
|
|
|
return productBusinessService.getOne(queryWrapper);
|
|
|
|
|
}
|
|
|
|
|
/** 验证表单唯一字段,正则,非空 i-0新增-1修改*/
|
|
|
|
|
@Override
|
|
|
|
|
public String checkForm(ProductWarehouseForm form,int i) {
|
|
|
|
|
boolean isUp =StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0");
|
|
|
|
|
String id="";
|
|
|
|
|
String countRecover = "";
|
|
|
|
|
if (isUp){
|
|
|
|
|
id = form.getId();
|
|
|
|
|
}
|
|
|
|
|
//主表字段验证
|
|
|
|
|
if(StringUtil.isEmpty(form.getName())){
|
|
|
|
|
return "商品名称不能为空";
|
|
|
|
|
}
|
|
|
|
|
if(StringUtil.isEmpty(form.getSpec())){
|
|
|
|
|
return "商品规格不能为空";
|
|
|
|
|
}
|
|
|
|
|
if(StringUtil.isEmpty(form.getAvailableInventory())){
|
|
|
|
|
return "可售库存不能为空";
|
|
|
|
|
}
|
|
|
|
|
//副表字段验证
|
|
|
|
|
//子表字段验证
|
|
|
|
|
if (form.getProductUnitList()!=null){
|
|
|
|
|
}
|
|
|
|
|
return countRecover;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 新增修改数据(事务回滚)
|
|
|
|
|
* @param id
|
|
|
|
|
* @param productWarehouseForm
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public void saveOrUpdate(ProductWarehouseForm productWarehouseForm,String id, boolean isSave) throws Exception{
|
|
|
|
|
UserInfo userInfo=userProvider.get();
|
|
|
|
|
UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId());
|
|
|
|
|
productWarehouseForm = JsonUtil.getJsonToBean(
|
|
|
|
|
generaterSwapUtil.swapDatetime(ProductWarehouseConstant.getFormData(),productWarehouseForm),ProductWarehouseForm.class);
|
|
|
|
|
ProductWarehouseEntity entity = JsonUtil.getJsonToBean(productWarehouseForm, ProductWarehouseEntity.class);
|
|
|
|
|
|
|
|
|
|
if(isSave){
|
|
|
|
|
String mainId = id ;
|
|
|
|
|
entity.setCode(generaterSwapUtil.getBillNumber("productcode", false));
|
|
|
|
|
entity.setBarCode(generaterSwapUtil.getBillNumber("productBarCode", false));
|
|
|
|
|
entity.setId(mainId);
|
|
|
|
|
entity.setFlowId(productWarehouseForm.getFlowId());
|
|
|
|
|
entity.setVersion(0);
|
|
|
|
|
}else{
|
|
|
|
|
entity.setCode(generaterSwapUtil.getBillNumber("productcode", false));
|
|
|
|
|
entity.setBarCode(generaterSwapUtil.getBillNumber("productBarCode", false));
|
|
|
|
|
entity.setFlowId(productWarehouseForm.getFlowId());
|
|
|
|
|
}
|
|
|
|
|
this.saveOrUpdate(entity);
|
|
|
|
|
|
|
|
|
|
//ProductUnit子表数据新增修改
|
|
|
|
|
if(!isSave){
|
|
|
|
|
QueryWrapper<ProductUnitEntity> ProductUnitqueryWrapper = new QueryWrapper<>();
|
|
|
|
|
ProductUnitqueryWrapper.lambda().eq(ProductUnitEntity::getProuctId, entity.getId());
|
|
|
|
|
productUnitService.remove(ProductUnitqueryWrapper);
|
|
|
|
|
}
|
|
|
|
|
if (productWarehouseForm.getProductUnitList()!=null){
|
|
|
|
|
List<ProductUnitEntity> tableField141 = JsonUtil.getJsonToList(productWarehouseForm.getProductUnitList(),ProductUnitEntity.class);
|
|
|
|
|
for(ProductUnitEntity entitys : tableField141){
|
|
|
|
|
entitys.setId(RandomUtil.uuId());
|
|
|
|
|
entitys.setProuctId(entity.getId());
|
|
|
|
|
if(isSave){
|
|
|
|
|
}else{
|
|
|
|
|
}
|
|
|
|
|
productUnitService.saveOrUpdate(entitys);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//jg_product_business副表数据新增修改
|
|
|
|
|
Map<String, Object> ProductBusinessMap = generaterSwapUtil.getMastTabelData(productWarehouseForm,"jg_product_business");
|
|
|
|
|
ProductBusinessEntity jg_product_businessentity = JsonUtil.getJsonToBean(ProductBusinessMap,ProductBusinessEntity.class);
|
|
|
|
|
//自动生成的字段
|
|
|
|
|
if(isSave){
|
|
|
|
|
jg_product_businessentity.setProductId(entity.getId());
|
|
|
|
|
jg_product_businessentity.setId(RandomUtil.uuId());
|
|
|
|
|
}else{
|
|
|
|
|
QueryWrapper<ProductBusinessEntity> queryWrapperProductBusiness =new QueryWrapper<>();
|
|
|
|
|
queryWrapperProductBusiness.lambda().eq(ProductBusinessEntity::getProductId,entity.getId());
|
|
|
|
|
ProductBusinessEntity jg_product_businessOneEntity= productBusinessService.getOne(queryWrapperProductBusiness);
|
|
|
|
|
jg_product_businessentity.setId(jg_product_businessOneEntity.getId());
|
|
|
|
|
jg_product_businessentity.setProductId(entity.getId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
productBusinessService.saveOrUpdate(jg_product_businessentity);
|
|
|
|
|
}
|
|
|
|
|
}
|