This commit is contained in:
skjia 2025-06-09 13:26:56 +08:00
parent a82e3df139
commit c8b0e17366
6 changed files with 105 additions and 9 deletions

View File

@ -45,6 +45,7 @@ public class SupermarketProductController extends BaseController {
@GetMapping("/list")
public TableDataInfo list(SupermarketProduct supermarketProduct) {
startPage();
System.out.println(supermarketProduct.getMaterialName());
List<SupermarketProduct> list = supermarketProductService.selectSupermarketProductList(supermarketProduct);
return getDataTable(list);
}
@ -78,9 +79,9 @@ public class SupermarketProductController extends BaseController {
*/
@ApiOperation(value = "获取超市商城商品详细信息")
//@RequiresPermissions("supermarket:product:query")
@GetMapping(value = "/{productId}")
public AjaxResult getInfo(@PathVariable("productId") Long productId) {
return success(supermarketProductService.selectSupermarketProductByProductId(productId));
@PostMapping(value = "/getInfo")
public AjaxResult getInfo(@RequestBody SupermarketProduct supermarketProduct) {
return success(supermarketProductService.selectSupermarketProductByProductId(supermarketProduct.getProductId()));
}
/**
@ -89,7 +90,7 @@ public class SupermarketProductController extends BaseController {
@ApiOperation(value = "新增超市商城商品")
//@PreventRepeatSubmit
//@RequiresPermissions("supermarket:product:add")
@SysLog(title = "超市商城商品", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增超市商城商品")
@SysLog(title = "超市商城商品", businessType = OperaType.INSERT, logType = 1,module = "超市管理->新增超市商城商品")
@PostMapping
public AjaxResult add(@RequestBody SupermarketProduct supermarketProduct) {
try {
@ -98,7 +99,50 @@ public class SupermarketProductController extends BaseController {
return error(e.getMessage());
}
}
/**
* 新增超市商城商品
*/
@ApiOperation(value = "新增超市商城商品")
//@PreventRepeatSubmit
//@RequiresPermissions("supermarket:product:add")
@SysLog(title = "超市商城商品", businessType = OperaType.INSERT, logType = 1,module = "超市管理->新增超市商城商品")
@PostMapping("/addProducts")
public AjaxResult adds(@RequestBody SupermarketProduct supermarketProduct) {
try {
return toAjax(supermarketProductService.insertSupermarketProducts(supermarketProduct));
} catch (Exception e) {
return error(e.getMessage());
}
}
/**
* 新增超市商城商品
*/
@ApiOperation(value = "删除超市商城商品")
//@PreventRepeatSubmit
//@RequiresPermissions("supermarket:product:add")
@SysLog(title = "超市商城商品", businessType = OperaType.INSERT, logType = 1,module = "超市管理->删除超市商城商品")
@PostMapping("/delProduct")
public AjaxResult delProduct(@RequestBody SupermarketProduct supermarketProduct) {
try {
String[] productIds=supermarketProduct.getProductIds().split(",");
return toAjax(supermarketProductService.deleteSupermarketProductByProductIdss(productIds));
} catch (Exception e) {
return error(e.getMessage());
}
}
@ApiOperation(value = "超市商城商品批量上线")
//@PreventRepeatSubmit
//@RequiresPermissions("supermarket:product:add")
@SysLog(title = "超市商城商品批量上线", businessType = OperaType.INSERT, logType = 1,module = "超市管理->超市商城商品批量上线")
@PostMapping("/onlines")
public AjaxResult online(@RequestBody SupermarketProduct supermarketProduct) {
try {
String[] productIds=supermarketProduct.getProductIds().split(",");
return toAjax(supermarketProductService.onlineSupermarketProductByProductIdss(productIds));
} catch (Exception e) {
return error(e.getMessage());
}
}
/**
* 修改超市商城商品
*/
@ -109,6 +153,8 @@ public class SupermarketProductController extends BaseController {
@PostMapping("/edit")
public AjaxResult edit(@RequestBody SupermarketProduct supermarketProduct) {
try {
System.out.println(supermarketProduct.getPutawayState());
System.out.println(supermarketProduct.getIfOnline());
return toAjax(supermarketProductService.updateSupermarketProduct(supermarketProduct));
} catch (Exception e) {
return error(e.getMessage());

View File

@ -74,6 +74,8 @@ public class SupermarketProduct extends BaseEntity {
@ApiModelProperty(value = "库存数")
private BigDecimal inventoryNum;
private String materialIds;
private String materialName;
private String materialType;
@ -85,7 +87,8 @@ public class SupermarketProduct extends BaseEntity {
private String areaName;
private String unitName;
private String productIds;
private String barCode;
public String getImgUrl() {
return FileUrlUtil.getFileUrl(this.imgUrl);
}

View File

@ -60,4 +60,6 @@ public interface SupermarketProductMapper {
* @return 结果
*/
public int deleteSupermarketProductByProductIds(Long[] productIds);
public int deleteSupermarketProductByProductIdss(String[] productIds);
public int onlineSupermarketProductByProductIdss(String[] productIds);
}

View File

@ -36,6 +36,7 @@ public interface ISupermarketProductService {
*/
public int insertSupermarketProduct(SupermarketProduct supermarketProduct);
public int insertSupermarketProducts(SupermarketProduct supermarketProduct);
/**
* 修改超市商城商品
*
@ -51,7 +52,8 @@ public interface ISupermarketProductService {
* @return 结果
*/
public int deleteSupermarketProductByProductIds(Long[] productIds);
public int deleteSupermarketProductByProductIdss(String[] productIds);
public int onlineSupermarketProductByProductIdss(String[] productIds);
/**
* 删除超市商城商品信息
*

View File

@ -1,5 +1,6 @@
package com.bonus.canteen.core.supermarket.service.impl;
import java.util.ArrayList;
import java.util.List;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
@ -64,6 +65,22 @@ public class SupermarketProductServiceImpl implements ISupermarketProductService
}
}
@Override
public int insertSupermarketProducts(SupermarketProduct supermarketProduct) {
supermarketProduct.setCreateTime(DateUtils.getNowDate());
supermarketProduct.setCreateBy(SecurityUtils.getUsername());
try {
List<SupermarketProduct> sps=new ArrayList<>();
sps=supermarketProductMapper.selectSupermarketAddProductList(supermarketProduct);
for(SupermarketProduct vo:sps){
vo.setSupermarketId(supermarketProduct.getSupermarketId());
supermarketProductMapper.insertSupermarketProduct(vo);
}
return 1;
} catch (Exception e) {
throw new ServiceException(e.getMessage());
}
}
/**
* 修改超市商城商品
*
@ -91,7 +108,14 @@ public class SupermarketProductServiceImpl implements ISupermarketProductService
public int deleteSupermarketProductByProductIds(Long[] productIds) {
return supermarketProductMapper.deleteSupermarketProductByProductIds(productIds);
}
@Override
public int deleteSupermarketProductByProductIdss(String[] productIds) {
return supermarketProductMapper.deleteSupermarketProductByProductIdss(productIds);
}
@Override
public int onlineSupermarketProductByProductIdss(String[] productIds) {
return supermarketProductMapper.onlineSupermarketProductByProductIdss(productIds);
}
/**
* 删除超市商城商品信息
*

View File

@ -26,16 +26,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectSupermarketProductVo">
select sp.product_id, sp.supermarket_id, sp.material_id, sp.putaway_state, sp.if_online, sp.sale_price,
sp.pref_price, sp.person_limit, sp.one_day_limit, sp.img_url, sp.inventory_num, sp.create_by,
sp.create_time, sp.update_by, sp.update_time, sm.material_name, spu.unit_name
sp.create_time, sp.update_by, sp.update_time, sm.material_name,smt.material_type_name, spu.unit_name
from supermarket_product sp
left join supermarket_material sm on sm.material_id = sp.material_id
left join supply_product_unit spu on spu.unit_id = sm.unit_id
left join supermarket_material_type smt on smt.material_type_id = sm.material_type_id
</sql>
<select id="selectSupermarketProductList" parameterType="com.bonus.canteen.core.supermarket.domain.SupermarketProduct" resultMap="SupermarketProductResult">
<include refid="selectSupermarketProductVo"/>
<where>
<if test="barCode != null"> and sm.bar_code like concat('%', #{barCode}, '%')</if>
<if test="materialName != null"> and sm.material_name like concat('%', #{materialName}, '%')</if>
<if test="supermarketId != null "> and sp.supermarket_id = #{supermarketId}</if>
<if test="materialType != null "> and sm.material_type_id = #{materialType}</if>
<if test="materialId != null "> and sp.material_id = #{materialId}</if>
<if test="putawayState != null "> and sp.putaway_state = #{putawayState}</if>
<if test="ifOnline != null "> and sp.if_online = #{ifOnline}</if>
@ -62,6 +66,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join supermarket_product sp on sm.material_id=sp.material_id
where sp.material_id is null
<if test="areaId != null and areaId != ''"> and sm.area_id = #{areaId}</if>
<if test="materialName != null and materialName != ''"> and sm.material_name like concat('%', #{materialName}, '%')</if>
<if test="barCode != null and barCode != ''"> and sm.bar_code = #{barCode}</if>
<if test="materialIds != null and materialIds != ''"> and sm.material_id in (${materialIds}) </if>
</select>
<select id="selectSupermarketProductByProductId" parameterType="Long" resultMap="SupermarketProductResult">
@ -144,4 +151,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{productId}
</foreach>
</delete>
<delete id="deleteSupermarketProductByProductIdss" parameterType="String">
delete from supermarket_product where product_id in
<foreach item="productId" collection="array" open="(" separator="," close=")">
#{productId}
</foreach>
</delete>
<delete id="onlineSupermarketProductByProductIdss" parameterType="String">
update supermarket_product set if_online="1" where product_id in
<foreach item="productId" collection="array" open="(" separator="," close=")">
#{productId}
</foreach>
</delete>
</mapper>