|
@ -4,12 +4,20 @@ import cn.hutool.core.bean.BeanUtil; |
|
|
import cn.hutool.core.date.DateTime; |
|
|
import cn.hutool.core.date.DateTime; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
|
import com.yxt.base.biz.base.basebrandinfo.BaseBrandInfo; |
|
|
|
|
|
import com.yxt.base.biz.base.basegoodsspu.BaseGoodsSpuListVo; |
|
|
|
|
|
import com.yxt.base.feign.portal.privilege.PrivilegeQuery; |
|
|
|
|
|
import com.yxt.base.feign.portal.sysorganization.SysOrganizationFeign; |
|
|
|
|
|
import com.yxt.base.feign.portal.sysorganization.SysOrganizationVo; |
|
|
|
|
|
import com.yxt.base.feign.portal.sysstafforg.SysStaffOrgFeign; |
|
|
|
|
|
import com.yxt.base.feign.portal.sysuser.SysUserFeign; |
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
import com.yxt.common.base.utils.PagerUtil; |
|
|
import com.yxt.common.base.utils.PagerUtil; |
|
|
import com.yxt.common.base.utils.StringUtils; |
|
|
import com.yxt.common.base.utils.StringUtils; |
|
|
import com.yxt.common.core.query.PagerQuery; |
|
|
import com.yxt.common.core.query.PagerQuery; |
|
|
import com.yxt.common.core.result.ResultBean; |
|
|
import com.yxt.common.core.result.ResultBean; |
|
|
import com.yxt.common.core.vo.PagerVo; |
|
|
import com.yxt.common.core.vo.PagerVo; |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
import java.text.SimpleDateFormat; |
|
@ -25,25 +33,68 @@ import java.util.stream.Collectors; |
|
|
@Service |
|
|
@Service |
|
|
public class BaseGoodsTypeService extends MybatisBaseService<BaseGoodsTypeMapper, BaseGoodsType> { |
|
|
public class BaseGoodsTypeService extends MybatisBaseService<BaseGoodsTypeMapper, BaseGoodsType> { |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private SysUserFeign sysUserFeign; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private SysOrganizationFeign sysOrganizationFeign; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private SysStaffOrgFeign sysStaffOrgFeign; |
|
|
public ResultBean<PagerVo<BaseGoodsTypeVo>> listPage(PagerQuery<BaseGoodsTypeQuery> pq) { |
|
|
public ResultBean<PagerVo<BaseGoodsTypeVo>> listPage(PagerQuery<BaseGoodsTypeQuery> pq) { |
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
BaseGoodsTypeQuery query = pq.getParams(); |
|
|
BaseGoodsTypeQuery query = pq.getParams(); |
|
|
QueryWrapper<BaseGoodsType> qw = new QueryWrapper<>(); |
|
|
QueryWrapper<BaseGoodsType> qw = new QueryWrapper<>(); |
|
|
|
|
|
if (StringUtils.isNotBlank(query.getMenuUrl())) { |
|
|
|
|
|
PrivilegeQuery privilegeQuery = new PrivilegeQuery(); |
|
|
|
|
|
privilegeQuery.setOrgPath(query.getOrgPath()); |
|
|
|
|
|
privilegeQuery.setMenuUrl(query.getMenuUrl()); |
|
|
|
|
|
privilegeQuery.setUserSid(query.getUserSid()); |
|
|
|
|
|
ResultBean<String> defaultIdReltBean = sysUserFeign.selectPrivilegeLevel(privilegeQuery); |
|
|
|
|
|
if (StringUtils.isNotBlank(defaultIdReltBean.getData())) { |
|
|
|
|
|
//数据权限ID(1集团、2事业部、3分公司、4部门、5个人)
|
|
|
|
|
|
String orgSidPath = query.getOrgPath(); |
|
|
|
|
|
orgSidPath = orgSidPath + "/"; |
|
|
|
|
|
int i1 = orgSidPath.indexOf("/"); |
|
|
|
|
|
int i2 = orgSidPath.indexOf("/", i1 + 1); |
|
|
|
|
|
int i3 = orgSidPath.indexOf("/", i2 + 1); |
|
|
|
|
|
int i4 = orgSidPath.indexOf("/", i3 + 1); |
|
|
|
|
|
String orgLevelKey = defaultIdReltBean.getData(); |
|
|
|
|
|
if ("1".equals(orgLevelKey)) { |
|
|
|
|
|
orgSidPath = orgSidPath.substring(0, i1); |
|
|
|
|
|
qw.like("u.orgSidPath", orgSidPath); |
|
|
|
|
|
} else if ("2".equals(orgLevelKey)) { |
|
|
|
|
|
orgSidPath = orgSidPath.substring(0, i2); |
|
|
|
|
|
qw.like("u.orgSidPath", orgSidPath); |
|
|
|
|
|
} else if ("3".equals(orgLevelKey)) { |
|
|
|
|
|
orgSidPath = orgSidPath.substring(0, i3); |
|
|
|
|
|
qw.like("u.orgSidPath", orgSidPath); |
|
|
|
|
|
} else if ("4".equals(orgLevelKey)) { |
|
|
|
|
|
orgSidPath = orgSidPath.substring(0, i4); |
|
|
|
|
|
qw.like("u.orgSidPath", orgSidPath); |
|
|
|
|
|
} else if ("5".equals(orgLevelKey)) { |
|
|
|
|
|
qw.eq("p.createBySid", query.getUserSid()); |
|
|
|
|
|
} else { |
|
|
|
|
|
PagerVo<BaseGoodsTypeVo> p = new PagerVo<>(); |
|
|
|
|
|
return rb.success().setData(p); |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
PagerVo<BaseGoodsTypeVo> p = new PagerVo<>(); |
|
|
|
|
|
return rb.success().setData(p); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
if(StringUtils.isNotBlank(query.getName())){ |
|
|
if(StringUtils.isNotBlank(query.getName())){ |
|
|
qw.like("goodsTypeName",query.getName()); |
|
|
qw.like("p.goodsTypeName",query.getName()); |
|
|
} |
|
|
} |
|
|
if(StringUtils.isNotBlank(query.getCode())){ |
|
|
if(StringUtils.isNotBlank(query.getCode())){ |
|
|
qw.like("goodsTypeCode",query.getCode()); |
|
|
qw.like("p.goodsTypeCode",query.getCode()); |
|
|
} |
|
|
} |
|
|
if(StringUtils.isNotBlank(query.getGoodID())){ |
|
|
if(StringUtils.isNotBlank(query.getGoodID())){ |
|
|
qw.eq("isGoodsID",query.getGoodID()); |
|
|
qw.eq("p.isGoodsID",query.getGoodID()); |
|
|
} |
|
|
} |
|
|
if(StringUtils.isNotBlank(query.getOutStockRule())){ |
|
|
if(StringUtils.isNotBlank(query.getOutStockRule())){ |
|
|
qw.eq("outStockRule",query.getOutStockRule()); |
|
|
qw.eq("p.outStockRule",query.getOutStockRule()); |
|
|
} |
|
|
} |
|
|
qw.ne("isDelete","1"); |
|
|
qw.ne("p.isDelete","1"); |
|
|
qw.orderByDesc("sortNo"); |
|
|
qw.orderByAsc("sortNo"); |
|
|
IPage<BaseGoodsType> page = PagerUtil.queryToPage(pq); |
|
|
IPage<BaseGoodsType> page = PagerUtil.queryToPage(pq); |
|
|
IPage<BaseGoodsTypeVo> pagging = baseMapper.listPage(page, qw); |
|
|
IPage<BaseGoodsTypeVo> pagging = baseMapper.listPage(page, qw); |
|
|
PagerVo<BaseGoodsTypeVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
PagerVo<BaseGoodsTypeVo> p = PagerUtil.pageToVo(pagging, null); |
|
@ -70,6 +121,7 @@ public class BaseGoodsTypeService extends MybatisBaseService<BaseGoodsTypeMapper |
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
String sid = ""; |
|
|
String sid = ""; |
|
|
dto.setPSid(dto.getSids()); |
|
|
dto.setPSid(dto.getSids()); |
|
|
|
|
|
String orgPath = dto.getOrgPath(); |
|
|
if (StringUtils.isNotBlank(dto.getSid())) { |
|
|
if (StringUtils.isNotBlank(dto.getSid())) { |
|
|
sid = dto.getSid(); |
|
|
sid = dto.getSid(); |
|
|
BaseGoodsType wmsGoodsType = fetchBySid(dto.getSid()); |
|
|
BaseGoodsType wmsGoodsType = fetchBySid(dto.getSid()); |
|
@ -79,6 +131,10 @@ public class BaseGoodsTypeService extends MybatisBaseService<BaseGoodsTypeMapper |
|
|
if(StringUtils.isBlank(wmsGoodsType.getPSid())){ |
|
|
if(StringUtils.isBlank(wmsGoodsType.getPSid())){ |
|
|
wmsGoodsType.setIsParent("1"); |
|
|
wmsGoodsType.setIsParent("1"); |
|
|
} |
|
|
} |
|
|
|
|
|
BaseGoodsType goods=baseMapper.checkForUpdate(dto.getGoodsTypeCode(),wmsGoodsType.getUseOrgSid(),sid); |
|
|
|
|
|
if(null!=goods){ |
|
|
|
|
|
return rb.setMsg("类别编码不能重复"); |
|
|
|
|
|
} |
|
|
baseMapper.updateById(wmsGoodsType); |
|
|
baseMapper.updateById(wmsGoodsType); |
|
|
} else { |
|
|
} else { |
|
|
BaseGoodsType wmsGoods = new BaseGoodsType(); |
|
|
BaseGoodsType wmsGoods = new BaseGoodsType(); |
|
@ -86,9 +142,40 @@ public class BaseGoodsTypeService extends MybatisBaseService<BaseGoodsTypeMapper |
|
|
BeanUtil.copyProperties(dto, wmsGoods, "id", "sid"); |
|
|
BeanUtil.copyProperties(dto, wmsGoods, "id", "sid"); |
|
|
wmsGoods.setCreateTime(new DateTime()); |
|
|
wmsGoods.setCreateTime(new DateTime()); |
|
|
wmsGoods.setIsParent("0"); |
|
|
wmsGoods.setIsParent("0"); |
|
|
|
|
|
wmsGoods.setCreateBySid(dto.getUserSid()); |
|
|
if(StringUtils.isBlank(wmsGoods.getPSid())){ |
|
|
if(StringUtils.isBlank(wmsGoods.getPSid())){ |
|
|
wmsGoods.setIsParent("1"); |
|
|
wmsGoods.setIsParent("1"); |
|
|
} |
|
|
} |
|
|
|
|
|
String deptName = ""; |
|
|
|
|
|
String deptSid = ""; |
|
|
|
|
|
String createOrgSid = ""; |
|
|
|
|
|
if (StringUtils.isNotBlank(orgPath)) { |
|
|
|
|
|
List<String> split = Arrays.asList(orgPath.split("/")); |
|
|
|
|
|
if (split.size() > 1) { |
|
|
|
|
|
//获取本级sid获取本级部门信息
|
|
|
|
|
|
SysOrganizationVo sysOrganization = sysOrganizationFeign.fetchBySid(split.get(split.size() - 2)).getData(); |
|
|
|
|
|
SysOrganizationVo sysOrganization1 = sysOrganizationFeign.fetchBySid(split.get(split.size() - 1)).getData(); |
|
|
|
|
|
deptName = sysOrganization.getName() + "/" + sysOrganization1.getName(); |
|
|
|
|
|
deptName = sysOrganization1.getName(); |
|
|
|
|
|
deptSid = sysOrganization1.getSid(); |
|
|
|
|
|
} else { |
|
|
|
|
|
SysOrganizationVo sysOrganization = sysOrganizationFeign.fetchBySid(split.get(0)).getData(); |
|
|
|
|
|
deptName = sysOrganization.getName(); |
|
|
|
|
|
deptName = sysOrganization.getName(); |
|
|
|
|
|
deptSid = sysOrganization.getSid(); |
|
|
|
|
|
} |
|
|
|
|
|
wmsGoods.setUseOrgSid(deptSid); |
|
|
|
|
|
createOrgSid = sysStaffOrgFeign.getOrgSidByPath(orgPath).getData(); |
|
|
|
|
|
//创建组织使用组织
|
|
|
|
|
|
ResultBean<SysOrganizationVo> organizationResultBean = sysOrganizationFeign.fetchBySid(createOrgSid); |
|
|
|
|
|
if (organizationResultBean.getData() != null) { |
|
|
|
|
|
wmsGoods.setCreateOrgSid(createOrgSid); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
BaseGoodsType goods=baseMapper.checkForInsert(dto.getGoodsTypeCode(),deptSid); |
|
|
|
|
|
if(null!=goods){ |
|
|
|
|
|
return rb.setMsg("类别编码不能重复"); |
|
|
|
|
|
} |
|
|
baseMapper.insert(wmsGoods); |
|
|
baseMapper.insert(wmsGoods); |
|
|
} |
|
|
} |
|
|
return rb.success().setMsg("成功"); |
|
|
return rb.success().setMsg("成功"); |
|
@ -110,6 +197,7 @@ public class BaseGoodsTypeService extends MybatisBaseService<BaseGoodsTypeMapper |
|
|
vo.setPName(wmsGoodsType1.getGoodsTypeName()); |
|
|
vo.setPName(wmsGoodsType1.getGoodsTypeName()); |
|
|
} |
|
|
} |
|
|
vo.setSids(wmsGoodsType.getPSid()); |
|
|
vo.setSids(wmsGoodsType.getPSid()); |
|
|
|
|
|
vo.setUserSid(wmsGoodsType.getCreateBySid()); |
|
|
if(StringUtils.isNotBlank(wmsGoodsType.getOutStockRule())){ |
|
|
if(StringUtils.isNotBlank(wmsGoodsType.getOutStockRule())){ |
|
|
if(wmsGoodsType.getOutStockRule().equals("0")){ |
|
|
if(wmsGoodsType.getOutStockRule().equals("0")){ |
|
|
vo.setOutStockRuleValue("先进先出"); |
|
|
vo.setOutStockRuleValue("先进先出"); |
|
|