|
|
|
@ -1,5 +1,8 @@
|
|
|
|
|
package jnpf.material.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import jnpf.material.entity.*;
|
|
|
|
|
import jnpf.material.mapper.MaterialMapper;
|
|
|
|
|
import jnpf.material.service.*;
|
|
|
|
@ -22,14 +25,13 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
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 org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -50,23 +52,25 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, MaterialEnt
|
|
|
|
|
@Autowired
|
|
|
|
|
private AuthorizeService authorizeService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private MaterialMapper materialMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<MaterialEntity> getList(MaterialPagination materialPagination){
|
|
|
|
|
public List<MaterialMobileEntity> getList(MaterialPagination materialPagination){
|
|
|
|
|
String userId=userProvider.get().getUserId();
|
|
|
|
|
List<String> AllIdList =new ArrayList();
|
|
|
|
|
int total=0;
|
|
|
|
|
int materialNum =0;
|
|
|
|
|
int materialNum =0;
|
|
|
|
|
QueryWrapper<MaterialEntity> materialQueryWrapper=new QueryWrapper<>();
|
|
|
|
|
boolean pcPermission = false;
|
|
|
|
|
boolean appPermission = false;
|
|
|
|
|
boolean isPc = ServletUtil.getHeader("jnpf-origin").equals("pc");
|
|
|
|
|
boolean isPc = ServletUtil.getHeader("jnpf-origin").equals("pc");
|
|
|
|
|
if(isPc && pcPermission){
|
|
|
|
|
if (!userProvider.get().getIsAdministrator()){
|
|
|
|
|
Object materialObj=authorizeService.getCondition(new AuthorizeConditionModel(materialQueryWrapper,materialPagination.getMenuId(),"material"));
|
|
|
|
|
if (!userProvider.get().getIsAdministrator()){
|
|
|
|
|
Object materialObj=authorizeService.getCondition(new AuthorizeConditionModel(materialQueryWrapper,materialPagination.getMenuId(),"material"));
|
|
|
|
|
if (ObjectUtil.isEmpty(materialObj)){
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
@ -76,24 +80,24 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, MaterialEnt
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!isPc && appPermission){
|
|
|
|
|
if (!userProvider.get().getIsAdministrator()){
|
|
|
|
|
Object materialObj=authorizeService.getCondition(new AuthorizeConditionModel(materialQueryWrapper,materialPagination.getMenuId(),"material"));
|
|
|
|
|
if (!userProvider.get().getIsAdministrator()){
|
|
|
|
|
Object materialObj=authorizeService.getCondition(new AuthorizeConditionModel(materialQueryWrapper,materialPagination.getMenuId(),"material"));
|
|
|
|
|
if (ObjectUtil.isEmpty(materialObj)){
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
materialQueryWrapper = (QueryWrapper<MaterialEntity>)materialObj;
|
|
|
|
|
materialNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(StringUtil.isNotEmpty(materialPagination.getItemCode())){
|
|
|
|
|
if(StringUtil.isNotEmpty(materialPagination.getItemCode())){
|
|
|
|
|
materialNum++;
|
|
|
|
|
materialQueryWrapper.lambda().like(MaterialEntity::getItemCode,materialPagination.getItemCode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(StringUtil.isNotEmpty(materialPagination.getDescription())){
|
|
|
|
|
if(StringUtil.isNotEmpty(materialPagination.getDescription())){
|
|
|
|
|
materialNum++;
|
|
|
|
|
materialQueryWrapper.lambda().like(MaterialEntity::getDescription,materialPagination.getDescription());
|
|
|
|
|
}
|
|
|
|
@ -116,28 +120,35 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, MaterialEnt
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ArrayList<MaterialMobileEntity> list1 = new ArrayList<>();
|
|
|
|
|
if((total>0 && AllIdList.size()>0) || total==0){
|
|
|
|
|
Page<MaterialEntity> page=new Page<>(materialPagination.getCurrentPage(), materialPagination.getPageSize());
|
|
|
|
|
IPage<MaterialEntity> userIPage=this.page(page, materialQueryWrapper);
|
|
|
|
|
return materialPagination.setData(userIPage.getRecords(),userIPage.getTotal());
|
|
|
|
|
Page<MaterialMobileEntity> page=new Page<>(materialPagination.getCurrentPage(), materialPagination.getPageSize());
|
|
|
|
|
IPage<MaterialMobileEntity> userIPage=this.pagee(page, materialQueryWrapper);
|
|
|
|
|
List<MaterialMobileEntity> materialEntities = materialPagination.setData(userIPage.getRecords(), userIPage.getTotal());
|
|
|
|
|
|
|
|
|
|
return materialEntities;
|
|
|
|
|
}else{
|
|
|
|
|
List<MaterialEntity> list = new ArrayList();
|
|
|
|
|
return materialPagination.setData(list, list.size());
|
|
|
|
|
List<MaterialEntity> materialEntities = materialPagination.setData(list, list.size());
|
|
|
|
|
for (MaterialEntity materialEntity : materialEntities) {
|
|
|
|
|
list1.add(materialEntity.convertTo());
|
|
|
|
|
}
|
|
|
|
|
return list1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public List<MaterialEntity> getTypeList(MaterialPagination materialPagination,String dataType){
|
|
|
|
|
public List<MaterialMobileEntity> getTypeList(MaterialPagination materialPagination,String dataType){
|
|
|
|
|
String userId=userProvider.get().getUserId();
|
|
|
|
|
List<String> AllIdList =new ArrayList();
|
|
|
|
|
int total=0;
|
|
|
|
|
int materialNum =0;
|
|
|
|
|
int total=0;
|
|
|
|
|
int materialNum =0;
|
|
|
|
|
QueryWrapper<MaterialEntity> materialQueryWrapper=new QueryWrapper<>();
|
|
|
|
|
boolean pcPermission = false;
|
|
|
|
|
boolean appPermission = false;
|
|
|
|
|
boolean isPc = ServletUtil.getHeader("jnpf-origin").equals("pc");
|
|
|
|
|
boolean isPc = ServletUtil.getHeader("jnpf-origin").equals("pc");
|
|
|
|
|
if(isPc && pcPermission){
|
|
|
|
|
if (!userProvider.get().getIsAdministrator()){
|
|
|
|
|
Object materialObj=authorizeService.getCondition(new AuthorizeConditionModel(materialQueryWrapper,materialPagination.getMenuId(),"material"));
|
|
|
|
|
if (!userProvider.get().getIsAdministrator()){
|
|
|
|
|
Object materialObj=authorizeService.getCondition(new AuthorizeConditionModel(materialQueryWrapper,materialPagination.getMenuId(),"material"));
|
|
|
|
|
if (ObjectUtil.isEmpty(materialObj)){
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
@ -147,41 +158,41 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, MaterialEnt
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!isPc && appPermission){
|
|
|
|
|
if (!userProvider.get().getIsAdministrator()){
|
|
|
|
|
Object materialObj=authorizeService.getCondition(new AuthorizeConditionModel(materialQueryWrapper,materialPagination.getMenuId(),"material"));
|
|
|
|
|
if (!userProvider.get().getIsAdministrator()){
|
|
|
|
|
Object materialObj=authorizeService.getCondition(new AuthorizeConditionModel(materialQueryWrapper,materialPagination.getMenuId(),"material"));
|
|
|
|
|
if (ObjectUtil.isEmpty(materialObj)){
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
materialQueryWrapper = (QueryWrapper<MaterialEntity>)materialObj;
|
|
|
|
|
materialNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(StringUtil.isNotEmpty(materialPagination.getItemCode())){
|
|
|
|
|
if(StringUtil.isNotEmpty(materialPagination.getItemCode())){
|
|
|
|
|
materialNum++;
|
|
|
|
|
materialQueryWrapper.lambda().like(MaterialEntity::getItemCode,materialPagination.getItemCode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(StringUtil.isNotEmpty(materialPagination.getDescription())){
|
|
|
|
|
if(StringUtil.isNotEmpty(materialPagination.getDescription())){
|
|
|
|
|
materialNum++;
|
|
|
|
|
materialQueryWrapper.lambda().like(MaterialEntity::getDescription,materialPagination.getDescription());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(AllIdList.size()>0){
|
|
|
|
|
if(AllIdList.size()>0){
|
|
|
|
|
materialQueryWrapper.lambda().in(MaterialEntity::getId, AllIdList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//排序
|
|
|
|
|
if(StringUtil.isEmpty(materialPagination.getSidx())){
|
|
|
|
|
materialQueryWrapper.lambda().orderByDesc(MaterialEntity::getId);
|
|
|
|
|
}else{
|
|
|
|
|
try {
|
|
|
|
|
String sidx = materialPagination.getSidx();
|
|
|
|
|
String sidx = materialPagination.getSidx();
|
|
|
|
|
MaterialEntity materialEntity = new MaterialEntity();
|
|
|
|
|
Field declaredField = materialEntity.getClass().getDeclaredField(sidx);
|
|
|
|
|
declaredField.setAccessible(true);
|
|
|
|
|
String value = declaredField.getAnnotation(TableField.class).value();
|
|
|
|
|
Field declaredField = materialEntity.getClass().getDeclaredField(sidx);
|
|
|
|
|
declaredField.setAccessible(true);
|
|
|
|
|
String value = declaredField.getAnnotation(TableField.class).value();
|
|
|
|
|
materialQueryWrapper="asc".equals(materialPagination.getSort().toLowerCase())?materialQueryWrapper.orderByAsc(value):materialQueryWrapper.orderByDesc(value);
|
|
|
|
|
} catch (NoSuchFieldException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
@ -189,15 +200,20 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, MaterialEnt
|
|
|
|
|
}
|
|
|
|
|
if("0".equals(dataType)){
|
|
|
|
|
if((total>0 && AllIdList.size()>0) || total==0){
|
|
|
|
|
Page<MaterialEntity> page=new Page<>(materialPagination.getCurrentPage(), materialPagination.getPageSize());
|
|
|
|
|
IPage<MaterialEntity> userIPage=this.page(page, materialQueryWrapper);
|
|
|
|
|
Page<MaterialMobileEntity> page=new Page<>(materialPagination.getCurrentPage(), materialPagination.getPageSize());
|
|
|
|
|
IPage<MaterialMobileEntity> userIPage=this.pagee(page, materialQueryWrapper);
|
|
|
|
|
return materialPagination.setData(userIPage.getRecords(),userIPage.getTotal());
|
|
|
|
|
}else{
|
|
|
|
|
List<MaterialEntity> list = new ArrayList();
|
|
|
|
|
List<MaterialMobileEntity> list = new ArrayList();
|
|
|
|
|
return materialPagination.setData(list, list.size());
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
return this.list(materialQueryWrapper);
|
|
|
|
|
List<MaterialEntity> list = list(materialQueryWrapper);
|
|
|
|
|
List<MaterialMobileEntity> list2 = new ArrayList<>();
|
|
|
|
|
for (MaterialEntity materialEntity : list) {
|
|
|
|
|
list2.add(materialEntity.convertTo());
|
|
|
|
|
}
|
|
|
|
|
return list2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -224,6 +240,24 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, MaterialEnt
|
|
|
|
|
this.removeById(entity.getId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public <E extends IPage<MaterialEntity>> E page(E page) {
|
|
|
|
|
return super.page(page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public IPage<MaterialMobileEntity> pagee(Page<MaterialMobileEntity> page, Wrapper<MaterialEntity> queryWrapper) {
|
|
|
|
|
IPage<MaterialMobileEntity> materialMobileList = materialMapper.getMaterialMobileList(page, queryWrapper);
|
|
|
|
|
// IPage<MaterialMobileEntity> materialMobileList = materialMapper.getMaterialMobileList(null, null);
|
|
|
|
|
// return super.page(page, queryWrapper);
|
|
|
|
|
return materialMobileList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Object tesx() {
|
|
|
|
|
return materialMapper.getMaterialMobileList111();
|
|
|
|
|
}
|
|
|
|
|
//子表方法
|
|
|
|
|
|
|
|
|
|
//列表子表数据方法
|
|
|
|
|