|
|
|
@ -36,28 +36,26 @@ public class BasicProductCategoryServiceImpl implements BasicProductCategoryServ
|
|
|
|
|
BasicProductCategoryRelMapper basicProductCategoryRelMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<BasicProductCategoryTypeResponse> getTreeList() {
|
|
|
|
|
|
|
|
|
|
return basicProductCategoryMapper.getTreeList();
|
|
|
|
|
public List<BasicProductCategoryTypeResponse> getTreeList(BasicProductTypeRequest basicProductTypeRequest) {
|
|
|
|
|
return basicProductCategoryMapper.getTreeList(basicProductTypeRequest);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public BasicProductCategory selectBasicHospTypeEntity() {
|
|
|
|
|
QueryWrapper<BasicProductCategory> Wrapper = new QueryWrapper<>();
|
|
|
|
|
Wrapper.eq("code",10000).last("limit 1");
|
|
|
|
|
Wrapper.eq("code", 10000).last("limit 1");
|
|
|
|
|
return basicProductCategoryMapper.selectOne(Wrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<BasicProductCategory> getMenuList(BasicProductTypeFilterRequest basicProductTypeFilterRequest) {
|
|
|
|
|
QueryWrapper<BasicProductCategory> ew=new QueryWrapper<>();
|
|
|
|
|
ew.ne("code",10000);
|
|
|
|
|
if(basicProductTypeFilterRequest.getType()!=null && basicProductTypeFilterRequest.getType()==1 && StrUtil.isNotEmpty(basicProductTypeFilterRequest.getCode())){
|
|
|
|
|
QueryWrapper<BasicProductCategory> ew = new QueryWrapper<>();
|
|
|
|
|
ew.ne("code", 10000);
|
|
|
|
|
if (basicProductTypeFilterRequest.getType() != null && basicProductTypeFilterRequest.getType() == 1 && StrUtil.isNotEmpty(basicProductTypeFilterRequest.getCode())) {
|
|
|
|
|
List<BasicProductCategory> basicProductCategories = basicProductCategoryMapper.selectLowTypeAll(basicProductTypeFilterRequest.getCode());
|
|
|
|
|
List<Long> ids = basicProductCategories.stream().map(BasicProductCategory::getId).collect(Collectors.toList());
|
|
|
|
|
ew.notIn("id",ids);
|
|
|
|
|
ew.notIn("id", ids);
|
|
|
|
|
}
|
|
|
|
|
List<BasicProductCategory> list = basicProductCategoryMapper.selectList(ew);
|
|
|
|
|
return list;
|
|
|
|
@ -65,29 +63,29 @@ public class BasicProductCategoryServiceImpl implements BasicProductCategoryServ
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean checkName(BasicProductTypeRequest basicProductTypeRequest, Integer type) {
|
|
|
|
|
Long sum=null;
|
|
|
|
|
Long sum = null;
|
|
|
|
|
//1添加
|
|
|
|
|
if(type==1){
|
|
|
|
|
if (type == 1) {
|
|
|
|
|
//查看名字是不是重复
|
|
|
|
|
QueryWrapper<BasicProductCategory> ew=new QueryWrapper<>();
|
|
|
|
|
ew.eq("name",basicProductTypeRequest.getName());
|
|
|
|
|
sum=basicProductCategoryMapper.selectCount(ew);
|
|
|
|
|
}else{
|
|
|
|
|
QueryWrapper<BasicProductCategory> ew=new QueryWrapper<>();
|
|
|
|
|
ew.eq("name",basicProductTypeRequest.getName());
|
|
|
|
|
ew.ne("id",basicProductTypeRequest.getId());
|
|
|
|
|
sum=basicProductCategoryMapper.selectCount(ew);
|
|
|
|
|
}
|
|
|
|
|
if(sum>0){
|
|
|
|
|
QueryWrapper<BasicProductCategory> ew = new QueryWrapper<>();
|
|
|
|
|
ew.eq("name", basicProductTypeRequest.getName());
|
|
|
|
|
sum = basicProductCategoryMapper.selectCount(ew);
|
|
|
|
|
} else {
|
|
|
|
|
QueryWrapper<BasicProductCategory> ew = new QueryWrapper<>();
|
|
|
|
|
ew.eq("name", basicProductTypeRequest.getName());
|
|
|
|
|
ew.ne("id", basicProductTypeRequest.getId());
|
|
|
|
|
sum = basicProductCategoryMapper.selectCount(ew);
|
|
|
|
|
}
|
|
|
|
|
if (sum > 0) {
|
|
|
|
|
return false;
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean updateBasicHospType(BasicProductTypeRequest basicProductTypeRequest) {
|
|
|
|
|
boolean falg=true;
|
|
|
|
|
boolean falg = true;
|
|
|
|
|
BasicProductCategory basicProductCategory = new BasicProductCategory();
|
|
|
|
|
basicProductCategory.setId(basicProductTypeRequest.getId());
|
|
|
|
|
basicProductCategory.setCreateTime(new Date());
|
|
|
|
@ -95,19 +93,19 @@ public class BasicProductCategoryServiceImpl implements BasicProductCategoryServ
|
|
|
|
|
basicProductCategory.setName(basicProductTypeRequest.getName());
|
|
|
|
|
basicProductCategory.setParentCode(basicProductTypeRequest.getParentCode());
|
|
|
|
|
basicProductCategory.setRemark(basicProductTypeRequest.getRemark());
|
|
|
|
|
Long userId=customerService.getUserId();
|
|
|
|
|
basicProductCategory.setCreateUser(userId+"");
|
|
|
|
|
basicProductCategory.setUpdateUser(userId+"");
|
|
|
|
|
Long userId = customerService.getUserId();
|
|
|
|
|
basicProductCategory.setCreateUser(userId + "");
|
|
|
|
|
basicProductCategory.setUpdateUser(userId + "");
|
|
|
|
|
int i = basicProductCategoryMapper.updateById(basicProductCategory);
|
|
|
|
|
if(i == 0){
|
|
|
|
|
falg=false;
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
falg = false;
|
|
|
|
|
}
|
|
|
|
|
return falg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean saveBasicHospType(BasicProductTypeRequest basicProductTypeRequest) {
|
|
|
|
|
boolean falg=true;
|
|
|
|
|
boolean falg = true;
|
|
|
|
|
BasicProductCategory basicProductCategory = new BasicProductCategory();
|
|
|
|
|
basicProductCategory.setId(basicProductTypeRequest.getId());
|
|
|
|
|
basicProductCategory.setCreateTime(new Date());
|
|
|
|
@ -115,18 +113,18 @@ public class BasicProductCategoryServiceImpl implements BasicProductCategoryServ
|
|
|
|
|
basicProductCategory.setName(basicProductTypeRequest.getName());
|
|
|
|
|
basicProductCategory.setParentCode(basicProductTypeRequest.getParentCode());
|
|
|
|
|
basicProductCategory.setRemark(basicProductTypeRequest.getRemark());
|
|
|
|
|
Long userId=customerService.getUserId();
|
|
|
|
|
basicProductCategory.setCreateUser(userId+"");
|
|
|
|
|
basicProductCategory.setUpdateUser(userId+"");
|
|
|
|
|
Long userId = customerService.getUserId();
|
|
|
|
|
basicProductCategory.setCreateUser(userId + "");
|
|
|
|
|
basicProductCategory.setUpdateUser(userId + "");
|
|
|
|
|
//获取数据库最大的code
|
|
|
|
|
QueryWrapper<BasicProductCategory> ew=new QueryWrapper<>();
|
|
|
|
|
QueryWrapper<BasicProductCategory> ew = new QueryWrapper<>();
|
|
|
|
|
ew.select("max(code) as code");
|
|
|
|
|
BasicProductCategory basicProductCategory1 = basicProductCategoryMapper.selectOne(ew);
|
|
|
|
|
basicProductCategory.setCode(Integer.valueOf(basicProductCategory1.getCode())+1+"");
|
|
|
|
|
basicProductCategory.setCode(Integer.valueOf(basicProductCategory1.getCode()) + 1 + "");
|
|
|
|
|
basicProductCategory.setId(IdUtil.getSnowflakeNextId());
|
|
|
|
|
int insert = basicProductCategoryMapper.insert(basicProductCategory);
|
|
|
|
|
if(insert == 0){
|
|
|
|
|
falg=false;
|
|
|
|
|
if (insert == 0) {
|
|
|
|
|
falg = false;
|
|
|
|
|
}
|
|
|
|
|
return falg;
|
|
|
|
|
}
|
|
|
|
@ -134,15 +132,15 @@ public class BasicProductCategoryServiceImpl implements BasicProductCategoryServ
|
|
|
|
|
@Override
|
|
|
|
|
public String delectBasicHospType(BasicProductTypeRequest basicProductTypeRequest) {
|
|
|
|
|
//查询是否有自己的子集
|
|
|
|
|
QueryWrapper<BasicProductCategory> ew=new QueryWrapper<>();
|
|
|
|
|
ew.eq("parentCode",basicProductTypeRequest.getCode());
|
|
|
|
|
Long count=basicProductCategoryMapper.selectCount(ew);
|
|
|
|
|
if(count>0){
|
|
|
|
|
QueryWrapper<BasicProductCategory> ew = new QueryWrapper<>();
|
|
|
|
|
ew.eq("parentCode", basicProductTypeRequest.getCode());
|
|
|
|
|
Long count = basicProductCategoryMapper.selectCount(ew);
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
return "请先删除该节点底下的数据!";
|
|
|
|
|
}
|
|
|
|
|
//查询是否有绑定产品
|
|
|
|
|
count = basicProductCategoryMapper.selectProductByRelCode(basicProductTypeRequest.getCode());
|
|
|
|
|
if(count >0){
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
return "该节点还存在产品,请先删除!";
|
|
|
|
|
}
|
|
|
|
|
basicProductCategoryMapper.deleteById(basicProductTypeRequest.getId());
|
|
|
|
@ -166,32 +164,32 @@ public class BasicProductCategoryServiceImpl implements BasicProductCategoryServ
|
|
|
|
|
@Override
|
|
|
|
|
public boolean insertCateRel(BasicProductTypeRequest basicProductTypeRequest) {
|
|
|
|
|
BasicProductCategoryRel basicProductCategoryRel = new BasicProductCategoryRel();
|
|
|
|
|
int insert =0;
|
|
|
|
|
int insert = 0;
|
|
|
|
|
for (String id : basicProductTypeRequest.getIds()) {
|
|
|
|
|
basicProductCategoryRel.setRelId(id);
|
|
|
|
|
basicProductCategoryRel.setCode(basicProductTypeRequest.getCode());
|
|
|
|
|
insert = basicProductCategoryRelMapper.insert(basicProductCategoryRel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return insert>0;
|
|
|
|
|
return insert > 0;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public BasicProductCategory checkCode(String parentCode) {
|
|
|
|
|
return basicProductCategoryMapper.selectOne(new QueryWrapper<BasicProductCategory>().eq("code",parentCode).last("limit 1"));
|
|
|
|
|
return basicProductCategoryMapper.selectOne(new QueryWrapper<BasicProductCategory>().eq("code", parentCode).last("limit 1"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean deleterelByid(Integer id) {
|
|
|
|
|
|
|
|
|
|
return basicProductCategoryRelMapper.deleteById(id)>0;
|
|
|
|
|
return basicProductCategoryRelMapper.deleteById(id) > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean checkExist(String code) {
|
|
|
|
|
List<BasicProductCategory> list = basicProductCategoryMapper.selectList(new QueryWrapper<BasicProductCategory>().eq("parentCode", code));
|
|
|
|
|
if(list != null && list.size()>0){
|
|
|
|
|
if (list != null && list.size() > 0) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -202,7 +200,7 @@ public class BasicProductCategoryServiceImpl implements BasicProductCategoryServ
|
|
|
|
|
public boolean checkrel(String code) {
|
|
|
|
|
|
|
|
|
|
List<BasicProductCategoryRel> relList = basicProductCategoryRelMapper.selectList(new QueryWrapper<BasicProductCategoryRel>().eq("code", code));
|
|
|
|
|
if(relList != null && relList.size() > 0){
|
|
|
|
|
if (relList != null && relList.size() > 0) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|