产品管理
This commit is contained in:
58
src/main/java/com/yxt/goods/apiadmin/BaseProductRest.java
Normal file
58
src/main/java/com/yxt/goods/apiadmin/BaseProductRest.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package com.yxt.goods.apiadmin;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.api.R;
|
||||
import com.yxt.common.core.query.PagerQuery;
|
||||
import com.yxt.common.core.result.ResultBean;
|
||||
import com.yxt.common.core.vo.PagerVo;
|
||||
import com.yxt.goods.biz.baseproduct.*;
|
||||
import com.yxt.goods.biz.goodsspu.*;
|
||||
import com.yxt.goods.utils.OrgPathQuery;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wangpengfei
|
||||
* @date 2024/3/7 16:58
|
||||
*/
|
||||
@Api(tags = "产品管理")
|
||||
@RestController
|
||||
@RequestMapping("/v1/product")
|
||||
public class BaseProductRest {
|
||||
@Autowired
|
||||
private BaseProductService baseProductService;
|
||||
|
||||
@ApiOperation("根据条件分页查询数据的列表")
|
||||
@PostMapping("/listPage")
|
||||
public ResultBean<PagerVo<BaseProductVo>> listPage(@RequestBody PagerQuery<BaseProductQuery> pq) {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
PagerVo<BaseProductVo> pv = baseProductService.listPageVo(pq);
|
||||
return rb.success().setData(pv);
|
||||
}
|
||||
|
||||
@ApiOperation("保存修改")
|
||||
@PostMapping("/saveOrUpdate")
|
||||
public ResultBean saveOrUpdate(@RequestBody BaseProductDto dto) {
|
||||
return baseProductService.saveProduct(dto);
|
||||
}
|
||||
|
||||
@ApiOperation("编辑回显")
|
||||
@GetMapping("/fetchBySid")
|
||||
public ResultBean<BaseProductDetailsVo> fetchBySid(@RequestParam("sid") String sid) {
|
||||
return baseProductService.fetchDetailsBySid(sid);
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除")
|
||||
@DeleteMapping("/delBySids")
|
||||
public ResultBean delBySids(@RequestBody String[] sids) {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
baseProductService.deleteBySids(sids);
|
||||
return rb.success();
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,12 @@ public class GoodsSpuRest {
|
||||
return goodsSpuService.getGoodsForSales(pq);
|
||||
}
|
||||
|
||||
@ApiOperation("产品管理获取商品")
|
||||
@PostMapping("/getGoodsForProduct")
|
||||
public ResultBean<List<ProductGoodsVo>> getGoodsForProduct(@RequestBody ProductGoodsQuery query) {
|
||||
return goodsSpuService.getGoodsForProduct(query);
|
||||
}
|
||||
|
||||
@ApiOperation("分页列表")
|
||||
@PostMapping("/listPage")
|
||||
public ResultBean<PagerVo<GoodsSpuVo>> listPage(@RequestBody PagerQuery<GoodsSpuQuery> pq) {
|
||||
|
||||
21
src/main/java/com/yxt/goods/biz/baseproduct/BaseProduct.java
Normal file
21
src/main/java/com/yxt/goods/biz/baseproduct/BaseProduct.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.yxt.goods.biz.baseproduct;
|
||||
|
||||
import com.yxt.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author wangpengfei
|
||||
* @date 2024/2/26 13:36
|
||||
*/
|
||||
@Data
|
||||
public class BaseProduct extends BaseEntity {
|
||||
|
||||
|
||||
@ApiModelProperty("对应商品sid")
|
||||
private String goodsSid; // 对应商品sid
|
||||
@ApiModelProperty("0产出率/1配比(初加工/深加工)")
|
||||
private Integer rateType; // 0产出率/1配比(初加工/深加工)
|
||||
private String useOrgSid;
|
||||
private String createOrgSid;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.yxt.goods.biz.baseproduct;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Fan
|
||||
* @description
|
||||
* @date 2024/8/13 9:34
|
||||
*/
|
||||
@Data
|
||||
public class BaseProductChildVo {
|
||||
|
||||
private String sid;
|
||||
private String cSid;
|
||||
private String productCode; //产品编码
|
||||
private String productName; //产品名称
|
||||
private String rateType; //产出率/配比 0/1
|
||||
private String materialName; //原料名称
|
||||
private String materialCode;//原料编码
|
||||
private String rate;//产出比例
|
||||
private List<BaseProductChildVo> children = new ArrayList<>();
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.yxt.goods.biz.baseproduct;
|
||||
|
||||
import com.yxt.common.core.dto.Dto;
|
||||
import com.yxt.common.core.vo.Vo;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Fan
|
||||
* @description
|
||||
* @date 2024/8/13 10:37
|
||||
*/
|
||||
@Data
|
||||
public class BaseProductDetailsVo implements Vo {
|
||||
private String sid;
|
||||
private String createBySid;
|
||||
private String useOrgSid;
|
||||
private String createOrgSid;
|
||||
@ApiModelProperty("对应商品sid")
|
||||
private String goodsSid; // 产品对应商品sid
|
||||
private String productName; // 产品名称
|
||||
@ApiModelProperty("0产出率/1配比(初加工/深加工)")
|
||||
private String rateType; // 0产出率/1配比(初加工/深加工)
|
||||
private List<BaseProductMaterialDetailsVo> list = new ArrayList<>(); //原料列表
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.yxt.goods.biz.baseproduct;
|
||||
|
||||
import com.yxt.common.core.dto.Dto;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Fan
|
||||
* @description
|
||||
* @date 2024/8/13 10:37
|
||||
*/
|
||||
@Data
|
||||
public class BaseProductDto implements Dto {
|
||||
|
||||
private String sid;
|
||||
private String createBySid;
|
||||
private String useOrgSid;
|
||||
private String createOrgSid;
|
||||
@ApiModelProperty("对应商品sid")
|
||||
private String goodsSid; // 产品对应商品sid
|
||||
private String productName; // 产品名称
|
||||
@ApiModelProperty("0产出率/1配比(初加工/深加工)")
|
||||
private String rateType; // 0产出率/1配比(初加工/深加工)
|
||||
private List<BaseProductMaterialDetailsVo> list = new ArrayList<>(); //原料列表
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.yxt.goods.biz.baseproduct;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wangpengfei
|
||||
* @date 2024/2/26 13:40
|
||||
*/
|
||||
@Mapper
|
||||
public interface BaseProductMapper extends BaseMapper<BaseProduct> {
|
||||
|
||||
IPage<BaseProductVo> selectPageVo(IPage<BaseProduct> page,@Param(Constants.WRAPPER) QueryWrapper<BaseProduct> qw);
|
||||
|
||||
List<BaseProductChildVo> selChildrenList(@Param("sid") String sid, @Param("cSid") String cSid);
|
||||
|
||||
int checkByGoodsSidAndUseOrgSid(@Param("goodsSid") String goodsSid, @Param("useOrgSid") String useOrgSid);
|
||||
|
||||
int checkByGoodsSidAndUseOrgSidAndSid(@Param("goodsSid")String goodsSid, @Param("useOrgSid")String useOrgSid, @Param("sid")String sid);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.yxt.goods.biz.baseproduct.BaseProductMapper">
|
||||
<!-- <where> ${ew.sqlSegment} </where>-->
|
||||
<!-- ${ew.customSqlSegment} -->
|
||||
|
||||
<select id="selectPageVo" resultType="com.yxt.goods.biz.baseproduct.BaseProductVo">
|
||||
SELECT
|
||||
p.sid,
|
||||
mg.goodsName AS materialName,
|
||||
mg.goodsCode AS materialCode,
|
||||
g.goodsName AS productName,
|
||||
g.goodsCode AS productCode,
|
||||
p.rateType,
|
||||
m.rate,
|
||||
m.sid AS cSid
|
||||
FROM
|
||||
base_product AS p
|
||||
LEFT JOIN base_product_material AS m ON p.sid = m.productSid
|
||||
LEFT JOIN goods_spu AS g ON p.goodsSid = g.sid
|
||||
LEFT JOIN goods_spu AS mg ON m.materialSid = mg.sid
|
||||
LEFT JOIN ss_user.sys_organization AS s ON p.useOrgSid = s.sid
|
||||
<where>
|
||||
${ew.sqlSegment}
|
||||
</where>
|
||||
GROUP BY
|
||||
p.sid
|
||||
ORDER BY
|
||||
p.id DESC
|
||||
</select>
|
||||
<select id="selChildrenList" resultType="com.yxt.goods.biz.baseproduct.BaseProductChildVo">
|
||||
SELECT
|
||||
p.sid,
|
||||
mg.goodsName AS materialName,
|
||||
mg.goodsCode AS materialCode,
|
||||
-- g.goodsName AS productName,
|
||||
-- g.goodsCode AS productCode,
|
||||
-- p.rateType,
|
||||
m.rate,
|
||||
m.sid AS cSid
|
||||
FROM
|
||||
base_product AS p
|
||||
LEFT JOIN base_product_material AS m ON p.sid = m.productSid
|
||||
LEFT JOIN goods_spu AS g ON p.goodsSid = g.sid
|
||||
LEFT JOIN goods_spu AS mg ON m.materialSid = mg.sid
|
||||
WHERE p.sid = #{sid} and m.sid != #{cSid}
|
||||
|
||||
</select>
|
||||
<select id="checkByGoodsSidAndUseOrgSid" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*) FROM base_product WHERE goodsSid = #{goodsSid} and useOrgSid = #{useOrgSid}
|
||||
</select>
|
||||
<select id="checkByGoodsSidAndUseOrgSidAndSid" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*) FROM base_product WHERE goodsSid = #{goodsSid} and useOrgSid = #{useOrgSid} and sid !=#{sid}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.yxt.goods.biz.baseproduct;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Fan
|
||||
* @description
|
||||
* @date 2024/8/13 10:40
|
||||
*/
|
||||
@Data
|
||||
public class BaseProductMaterialDetailsVo {
|
||||
|
||||
@ApiModelProperty("原料sid-对应商品sid")
|
||||
private String materialSid; // 原料sid-对应商品sid
|
||||
private String materialName; //原料名称
|
||||
private String materialCode;//原料编码
|
||||
private String rate;//产出比例
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.yxt.goods.biz.baseproduct;
|
||||
|
||||
import com.yxt.common.core.query.Query;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Fan
|
||||
* @description
|
||||
* @date 2024/8/13 9:30
|
||||
*/
|
||||
@Data
|
||||
public class BaseProductQuery implements Query {
|
||||
|
||||
/**
|
||||
* 产品名称
|
||||
*/
|
||||
private String productName;
|
||||
/**
|
||||
* 比例类别
|
||||
*/
|
||||
private String rateType;
|
||||
|
||||
|
||||
private String orgLevelKey;//权限等级
|
||||
@ApiModelProperty("菜单路由")
|
||||
private String menuUrl;
|
||||
@ApiModelProperty("组织全路径sid")
|
||||
private String orgPath;
|
||||
@ApiModelProperty("用户sid")
|
||||
private String userSid;
|
||||
private int index;
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
package com.yxt.goods.biz.baseproduct;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.yxt.common.base.service.MybatisBaseService;
|
||||
import com.yxt.common.base.utils.PagerUtil;
|
||||
import com.yxt.common.base.utils.StringUtils;
|
||||
import com.yxt.common.core.query.PagerQuery;
|
||||
import com.yxt.common.core.result.ResultBean;
|
||||
import com.yxt.common.core.vo.PagerVo;
|
||||
import com.yxt.goods.biz.baseproductmaterial.BaseProductMaterial;
|
||||
import com.yxt.goods.biz.baseproductmaterial.BaseProductMaterialService;
|
||||
import com.yxt.goods.biz.goodsspu.GoodsSpu;
|
||||
import com.yxt.goods.biz.goodsspu.GoodsSpuService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author wangpengfei
|
||||
* @date 2024/2/26 13:40
|
||||
*/
|
||||
@Service
|
||||
public class BaseProductService extends MybatisBaseService<BaseProductMapper, BaseProduct> {
|
||||
|
||||
@Autowired
|
||||
private BaseProductMaterialService baseProductMaterialService;
|
||||
@Autowired
|
||||
private GoodsSpuService goodsSpuService;
|
||||
public PagerVo<BaseProductVo> listPageVo(PagerQuery<BaseProductQuery> pq) {
|
||||
BaseProductQuery query = pq.getParams();
|
||||
QueryWrapper<BaseProduct> qw = new QueryWrapper<>();
|
||||
if (com.yxt.common.base.utils.StringUtils.isNotBlank(query.getOrgLevelKey())) {
|
||||
//数据权限ID(1全部、2本部门及子部门、3本部门、4个人)
|
||||
String orgLevelKey = query.getOrgLevelKey();
|
||||
String orgSidPath = query.getOrgPath();
|
||||
int index = query.getIndex();
|
||||
if ("1".equals(orgLevelKey)) {
|
||||
orgSidPath = orgSidPath.substring(0, index);
|
||||
qw.like("s.orgSidPath", orgSidPath);
|
||||
} else if ("2".equals(orgLevelKey)) {
|
||||
orgSidPath = orgSidPath.substring(0, index);
|
||||
qw.like("s.orgSidPath", orgSidPath);
|
||||
} else if ("3".equals(orgLevelKey)) {
|
||||
orgSidPath = orgSidPath.substring(0, index);
|
||||
qw.apply("s.orgSidPath like('" + orgSidPath + "')");
|
||||
} else if ("4".equals(orgLevelKey)) {
|
||||
qw.eq("p.createBySid", query.getUserSid());
|
||||
} else {
|
||||
PagerVo<BaseProductVo> p = new PagerVo<>();
|
||||
return p;
|
||||
}
|
||||
} else {
|
||||
PagerVo<BaseProductVo> p = new PagerVo<>();
|
||||
return p;
|
||||
}
|
||||
if (StringUtils.isNotBlank(query.getProductName())) {
|
||||
qw.like("g.goodsName", query.getProductName());
|
||||
}
|
||||
if (StringUtils.isNotBlank(query.getRateType())) {
|
||||
qw.eq("p.rateType", query.getRateType());
|
||||
}
|
||||
IPage<BaseProduct> page = PagerUtil.queryToPage(pq);
|
||||
IPage<BaseProductVo> pagging = baseMapper.selectPageVo(page, qw);
|
||||
List<BaseProductVo> records = pagging.getRecords();
|
||||
if (!records.isEmpty()) {
|
||||
for (BaseProductVo record : records) {
|
||||
String childSid = record.getCSid();
|
||||
String sid = record.getSid();
|
||||
List<BaseProductChildVo> children = baseMapper.selChildrenList(sid, childSid);
|
||||
if (!children.isEmpty()) {
|
||||
record.setChildren(children);
|
||||
}
|
||||
}
|
||||
}
|
||||
PagerVo<BaseProductVo> p = PagerUtil.pageToVo(pagging, null);
|
||||
return p;
|
||||
}
|
||||
|
||||
public ResultBean saveProduct(BaseProductDto dto) {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
String sid = "";
|
||||
if (StringUtils.isNotBlank(dto.getSid())) {
|
||||
sid = dto.getSid();
|
||||
int count = baseMapper.checkByGoodsSidAndUseOrgSidAndSid(dto.getGoodsSid(),dto.getUseOrgSid(),sid);
|
||||
if (count > 0) {
|
||||
return rb.setMsg("产品名称已存在,请勿重复选择");
|
||||
}
|
||||
BaseProduct baseProduct = fetchBySid(sid);
|
||||
BeanUtil.copyProperties(dto,baseProduct,"id","sid");
|
||||
baseMapper.updateById(baseProduct);
|
||||
baseProductMaterialService.delByProductSid(sid);
|
||||
} else {
|
||||
int count = baseMapper.checkByGoodsSidAndUseOrgSid(dto.getGoodsSid(),dto.getUseOrgSid());
|
||||
if (count > 0) {
|
||||
return rb.setMsg("产品名称已存在,请勿重复选择");
|
||||
}
|
||||
BaseProduct baseProduct = new BaseProduct();
|
||||
BeanUtil.copyProperties(dto,baseProduct,"id","sid");
|
||||
baseMapper.insert(baseProduct);
|
||||
sid = baseProduct.getSid();
|
||||
}
|
||||
List<BaseProductMaterialDetailsVo> list = dto.getList();
|
||||
if (!list.isEmpty()) {
|
||||
for (BaseProductMaterialDetailsVo detailsVo : list) {
|
||||
BaseProductMaterial material = new BaseProductMaterial();
|
||||
BeanUtil.copyProperties(detailsVo,material,"id","sid");
|
||||
material.setProductSid(sid);
|
||||
baseProductMaterialService.insert(material);
|
||||
}
|
||||
}
|
||||
return rb.success();
|
||||
}
|
||||
|
||||
public ResultBean<BaseProductDetailsVo> fetchDetailsBySid(String sid) {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
BaseProductDetailsVo vo = new BaseProductDetailsVo();
|
||||
BaseProduct baseProduct = fetchBySid(sid);
|
||||
if (null != baseProduct) {
|
||||
BeanUtil.copyProperties(baseProduct,vo);
|
||||
String goodsSid = baseProduct.getGoodsSid();
|
||||
GoodsSpu goodsSpu = goodsSpuService.fetchBySid(goodsSid);
|
||||
if (null != goodsSpu) {
|
||||
vo.setProductName(goodsSpu.getGoodsName());
|
||||
}
|
||||
List<BaseProductMaterialDetailsVo> list = new ArrayList<>(); //原料列表
|
||||
List<BaseProductMaterial> ms = baseProductMaterialService.selByProductSid(sid);
|
||||
if (!ms.isEmpty()) {
|
||||
for (BaseProductMaterial m : ms) {
|
||||
BaseProductMaterialDetailsVo md = new BaseProductMaterialDetailsVo();
|
||||
BeanUtil.copyProperties(m,md);
|
||||
String materialSid = m.getMaterialSid();
|
||||
GoodsSpu mGoodsSpu = goodsSpuService.fetchBySid(materialSid);
|
||||
if (null != mGoodsSpu) {
|
||||
md.setMaterialName(mGoodsSpu.getGoodsName());
|
||||
md.setMaterialCode(mGoodsSpu.getGoodsCode());
|
||||
}
|
||||
list.add(md);
|
||||
}
|
||||
vo.setList(list);
|
||||
}
|
||||
}
|
||||
return rb.success().setData(vo);
|
||||
}
|
||||
|
||||
public void deleteBySids(String[] sids) {
|
||||
delBySids(sids);
|
||||
for (String sid : sids) {
|
||||
baseProductMaterialService.delByProductSid(sid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.yxt.goods.biz.baseproduct;
|
||||
|
||||
import com.yxt.common.core.vo.Vo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Fan
|
||||
* @description
|
||||
* @date 2024/8/13 9:30
|
||||
*/
|
||||
@Data
|
||||
public class BaseProductVo implements Vo {
|
||||
|
||||
/**
|
||||
* 原料编码
|
||||
*/
|
||||
private String materialCode;
|
||||
/**
|
||||
* 原料名称
|
||||
*/
|
||||
private String materialName;
|
||||
/**
|
||||
* 产品编码
|
||||
*/
|
||||
private String productCode;
|
||||
/**
|
||||
* 产品名称
|
||||
*/
|
||||
private String productName;
|
||||
/**
|
||||
* 比例
|
||||
*/
|
||||
private String rate;
|
||||
/**
|
||||
* 比例类别
|
||||
*/
|
||||
private String rateType;
|
||||
private String sid;
|
||||
private String cSid;
|
||||
private List<BaseProductChildVo> children = new ArrayList<>();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.yxt.goods.biz.baseproductmaterial;
|
||||
|
||||
import com.yxt.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author wangpengfei
|
||||
* @date 2024/2/26 13:36
|
||||
*/
|
||||
@Data
|
||||
public class BaseProductMaterial extends BaseEntity {
|
||||
|
||||
@ApiModelProperty("产品sid")
|
||||
private String productSid; // 产品sid
|
||||
@ApiModelProperty("原料sid-对应商品sid")
|
||||
private String materialSid; // 原料sid-对应商品sid
|
||||
@ApiModelProperty("比例(%产品比例/配比)")
|
||||
private Double rate; // 比例(%产品比例/配比)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.yxt.goods.biz.baseproductmaterial;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.yxt.goods.biz.goodsbrandinfo.GoodsBrandInfo;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wangpengfei
|
||||
* @date 2024/2/26 13:40
|
||||
*/
|
||||
@Mapper
|
||||
public interface BaseProductMaterialMapper extends BaseMapper<BaseProductMaterial> {
|
||||
|
||||
@Delete("delete from base_product_material where productSid =#{sid}")
|
||||
void delByProductSid(String sid);
|
||||
|
||||
@Select("select * from base_product_material where productSid =#{sid}")
|
||||
List<BaseProductMaterial> selByProductSid(String sid);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.yxt.goods.biz.baseproductmaterial.BaseProductMaterialMapper">
|
||||
<!-- <where> ${ew.sqlSegment} </where>-->
|
||||
<!-- ${ew.customSqlSegment} -->
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.yxt.goods.biz.baseproductmaterial;
|
||||
|
||||
|
||||
import com.yxt.common.base.service.MybatisBaseService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author wangpengfei
|
||||
* @date 2024/2/26 13:40
|
||||
*/
|
||||
@Service
|
||||
public class BaseProductMaterialService extends MybatisBaseService<BaseProductMaterialMapper, BaseProductMaterial> {
|
||||
|
||||
public void delByProductSid(String sid) {
|
||||
baseMapper.delByProductSid(sid);
|
||||
}
|
||||
|
||||
public List<BaseProductMaterial> selByProductSid(String sid) {
|
||||
return baseMapper.selByProductSid(sid);
|
||||
}
|
||||
}
|
||||
@@ -23,4 +23,6 @@ public interface GoodsSpuMapper extends BaseMapper<GoodsSpu> {
|
||||
List<GoodsSpuVo> listAll(@Param("orgPath")String orgPath);
|
||||
|
||||
IPage<SalesGoodsVo> getGoodsForSales(IPage<GoodsSpu> page, @Param(Constants.WRAPPER) QueryWrapper<GoodsSpu> qw);
|
||||
|
||||
List<ProductGoodsVo> getGoodsForProduct(@Param(Constants.WRAPPER) QueryWrapper<GoodsSpu> qw);
|
||||
}
|
||||
|
||||
@@ -55,6 +55,14 @@
|
||||
${ew.sqlSegment}
|
||||
</where>
|
||||
</select>
|
||||
<select id="getGoodsForProduct" resultType="com.yxt.goods.biz.goodsspu.ProductGoodsVo">
|
||||
select
|
||||
*
|
||||
from goods_spu
|
||||
<where>
|
||||
${ew.sqlSegment}
|
||||
</where>
|
||||
</select>
|
||||
<update id="updateBySidIsDelete">
|
||||
UPDATE goods_spu
|
||||
SET isDelete=1
|
||||
|
||||
@@ -529,4 +529,19 @@ public class GoodsSpuService extends MybatisBaseService<GoodsSpuMapper, GoodsSpu
|
||||
PagerVo<SalesGoodsVo> p = PagerUtil.pageToVo(pagging, null);
|
||||
return rb.success().setData(p);
|
||||
}
|
||||
|
||||
public ResultBean<List<ProductGoodsVo>> getGoodsForProduct(ProductGoodsQuery query) {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
QueryWrapper<GoodsSpu> qw = new QueryWrapper<>();
|
||||
if (StringUtils.isNotBlank(query.getQueryName())) {
|
||||
qw.like("goodsName", query.getQueryName());
|
||||
}
|
||||
if (StringUtils.isNotBlank(query.getUseOrgSid())) {
|
||||
qw.like("useOrgSid", query.getUseOrgSid());
|
||||
}
|
||||
qw.eq("isEnable" , 1);
|
||||
qw.eq("isDelete" ,0);
|
||||
List<ProductGoodsVo> list = baseMapper.getGoodsForProduct(qw);
|
||||
return rb.success().setData(list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.yxt.goods.biz.goodsspu;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Fan
|
||||
* @description
|
||||
* @date 2024/8/13 10:22
|
||||
*/
|
||||
@Data
|
||||
public class ProductGoodsQuery {
|
||||
|
||||
private String queryName;
|
||||
private String useOrgSid;
|
||||
|
||||
}
|
||||
17
src/main/java/com/yxt/goods/biz/goodsspu/ProductGoodsVo.java
Normal file
17
src/main/java/com/yxt/goods/biz/goodsspu/ProductGoodsVo.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.yxt.goods.biz.goodsspu;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Fan
|
||||
* @description
|
||||
* @date 2024/8/13 10:20
|
||||
*/
|
||||
@Data
|
||||
public class ProductGoodsVo {
|
||||
|
||||
private String sid;
|
||||
private String goodsName;
|
||||
private String goodsCode;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user