This commit is contained in:
sxu 2025-04-29 20:07:09 +08:00
parent 114e26f840
commit 94085f8868
6 changed files with 341 additions and 54 deletions

View File

@ -0,0 +1,39 @@
package com.bonus.canteen.core.drp.controller;
import com.bonus.canteen.core.drp.dto.AndroidSearchMaterialDTO;
import com.bonus.canteen.core.drp.service.AndroidInventoryService;
import com.bonus.canteen.core.drp.vo.AndroidSearchMaterialVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javax.validation.Valid;
import lombok.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping({"/api/v1/android/inventory"})
@Api(
value = "gyp-电子秤设备接口",
tags = {"gyp-电子秤设备接口"}
)
public class AndroidInventoryController {
@Generated
private static final Logger log = LoggerFactory.getLogger(AndroidInventoryController.class);
@Autowired
@Lazy
private AndroidInventoryService androidInventoryService;
@PostMapping({"/search/material"})
@ApiOperation("电子秤/手持机-根据原料名称模糊查询原料配置信息")
public List<AndroidSearchMaterialVO> searchMaterial(@RequestBody @Valid AndroidSearchMaterialDTO dto) {
return this.androidInventoryService.searchMaterial(dto);
}
}

View File

@ -0,0 +1,58 @@
package com.bonus.canteen.core.drp.dto;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.List;
import lombok.Generated;
public class AndroidSearchMaterialDTO implements Serializable {
@ApiModelProperty("原料名称")
private String materialName;
@ApiModelProperty("原料编码")
private String materialCode;
@ApiModelProperty("原料类别id集合")
private List<Long> categoryIdList;
@ApiModelProperty("条码")
private String barCode;
@Generated
public String getMaterialName() {
return this.materialName;
}
@Generated
public String getMaterialCode() {
return this.materialCode;
}
@Generated
public List<Long> getCategoryIdList() {
return this.categoryIdList;
}
@Generated
public String getBarCode() {
return this.barCode;
}
@Generated
public void setMaterialName(final String materialName) {
this.materialName = materialName;
}
@Generated
public void setMaterialCode(final String materialCode) {
this.materialCode = materialCode;
}
@Generated
public void setCategoryIdList(final List<Long> categoryIdList) {
this.categoryIdList = categoryIdList;
}
@Generated
public void setBarCode(final String barCode) {
this.barCode = barCode;
}
}

View File

@ -2,7 +2,9 @@ package com.bonus.canteen.core.drp.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bonus.canteen.core.drp.dto.AndroidSearchMaterialDTO;
import com.bonus.canteen.core.drp.model.DrpInventory;
import com.bonus.canteen.core.drp.vo.AndroidSearchMaterialVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
@ -21,9 +23,9 @@ public interface DrpInventoryMapper extends BaseMapper<DrpInventory> {
//
// @Select({"select category_id id, parent_id, category_name from menu_material_category where del_flag = #{delFlag}"})
// List<MenuCategoryTreeVO> selectCategoryTree(Integer delFlag);
//
// List<AndroidSearchMaterialVO> selectAndroidMaterialList(@Param("content") AndroidSearchMaterialDTO content, @Param("pinyinInitials") String pinyinInitials, @Param("pinyinFull") String pinyinFull, @Param("delFlag") Integer delFlag);
//
List<AndroidSearchMaterialVO> selectAndroidMaterialList(@Param("content") AndroidSearchMaterialDTO content, @Param("pinyinInitials") String pinyinInitials, @Param("pinyinFull") String pinyinFull, @Param("delFlag") Integer delFlag);
// List<AndroidSearchInventoryMaterialVO> searchInventoryMaterial(@Param("content") AndroidSearchInventoryMaterialDTO content, @Param("pinyinInitials") String pinyinInitials, @Param("pinyinFull") String pinyinFull, @Param("delFlag") Integer delFlag);
//
// InventoryModel getInventoryNumByMaterialId(@Param("materialId") Long materialId, @Param("warehouseId") Long warehouseId, @Param("unitId") Long unitId);

View File

@ -0,0 +1,31 @@
package com.bonus.canteen.core.drp.service;
import cn.hutool.core.util.ObjectUtil;
import com.bonus.canteen.core.drp.dto.AndroidSearchMaterialDTO;
import com.bonus.canteen.core.drp.mapper.DrpInventoryMapper;
import com.bonus.canteen.core.drp.vo.AndroidSearchMaterialVO;
import com.bonus.common.houqin.constant.DelFlagEnum;
import lombok.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class AndroidInventoryService {
@Generated
private static final Logger log = LoggerFactory.getLogger(AndroidInventoryService.class);
@Autowired
@Lazy
private DrpInventoryMapper drpInventoryMapper;
public List<AndroidSearchMaterialVO> searchMaterial(AndroidSearchMaterialDTO content) {
String materialName = ObjectUtil.isNull(content.getMaterialName()) ? "" : content.getMaterialName();
return this.drpInventoryMapper.selectAndroidMaterialList(content, materialName.toUpperCase(), materialName.toLowerCase(), DelFlagEnum.DEL_FALSE.key());
}
}

View File

@ -0,0 +1,157 @@
package com.bonus.canteen.core.drp.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import lombok.Generated;
@ApiModel("根据原料名称模糊查询原料配置信息")
public class AndroidSearchMaterialVO implements Serializable {
@ApiModelProperty("原料id")
private Long materialId;
@ApiModelProperty("原料名称")
private String materialName;
@ApiModelProperty("原料编码")
private String materialCode;
@ApiModelProperty("类别名称")
private String categoryName;
@ApiModelProperty("供应商id")
private Long supplierId;
@ApiModelProperty("供应商名称")
private String supplierName;
@ApiModelProperty("计量单位id")
private Long unitId;
@ApiModelProperty("计量单位名称")
private String unitName;
@ApiModelProperty("单位类型(1-按份,2-称重)")
private Integer weighType;
@ApiModelProperty("换算比率(换算成?g)")
private BigDecimal rate;
@ApiModelProperty("参考价格")
private Integer unitPrice;
@ApiModelProperty("到期时间(保质期)")
private LocalDate expireTime;
@Generated
public Long getMaterialId() {
return this.materialId;
}
@Generated
public String getMaterialName() {
return this.materialName;
}
@Generated
public String getMaterialCode() {
return this.materialCode;
}
@Generated
public String getCategoryName() {
return this.categoryName;
}
@Generated
public Long getSupplierId() {
return this.supplierId;
}
@Generated
public String getSupplierName() {
return this.supplierName;
}
@Generated
public Long getUnitId() {
return this.unitId;
}
@Generated
public String getUnitName() {
return this.unitName;
}
@Generated
public Integer getWeighType() {
return this.weighType;
}
@Generated
public BigDecimal getRate() {
return this.rate;
}
@Generated
public Integer getUnitPrice() {
return this.unitPrice;
}
@Generated
public LocalDate getExpireTime() {
return this.expireTime;
}
@Generated
public void setMaterialId(final Long materialId) {
this.materialId = materialId;
}
@Generated
public void setMaterialName(final String materialName) {
this.materialName = materialName;
}
@Generated
public void setMaterialCode(final String materialCode) {
this.materialCode = materialCode;
}
@Generated
public void setCategoryName(final String categoryName) {
this.categoryName = categoryName;
}
@Generated
public void setSupplierId(final Long supplierId) {
this.supplierId = supplierId;
}
@Generated
public void setSupplierName(final String supplierName) {
this.supplierName = supplierName;
}
@Generated
public void setUnitId(final Long unitId) {
this.unitId = unitId;
}
@Generated
public void setUnitName(final String unitName) {
this.unitName = unitName;
}
@Generated
public void setWeighType(final Integer weighType) {
this.weighType = weighType;
}
@Generated
public void setRate(final BigDecimal rate) {
this.rate = rate;
}
@Generated
public void setUnitPrice(final Integer unitPrice) {
this.unitPrice = unitPrice;
}
@Generated
public void setExpireTime(final LocalDate expireTime) {
this.expireTime = expireTime;
}
}

View File

@ -67,57 +67,57 @@
<!-- </select>-->
<!-- &lt;!&ndash; AI电子秤原料搜索 &ndash;&gt;-->
<!-- <select id="selectAndroidMaterialList"-->
<!-- resultType="net.xnzn.core.drp.vo.AndroidSearchMaterialVO">-->
<!-- select-->
<!-- mm.material_id,-->
<!-- mm.material_name,-->
<!-- mm.material_code,-->
<!-- mmc.category_name,-->
<!-- ds.supplier_id,-->
<!-- ds.supplier_name,-->
<!-- mm.unit_id,-->
<!-- du.unit_name,-->
<!-- du.weigh_type,-->
<!-- du.rate,-->
<!-- did.unit_price-->
<!-- from-->
<!-- menu_material mm-->
<!-- left join (-->
<!-- select-->
<!-- a.*-->
<!-- from-->
<!-- drp_into_detail as a,-->
<!-- ( select b.material_id, max( b.id ) as id from drp_into_detail as b group by b.material_id ) as c-->
<!-- where-->
<!-- a.material_id = c.material_id-->
<!-- and a.id = c.id-->
<!-- ) did on mm.material_id = did.material_id-->
<!-- left join menu_material_category mmc on mm.category_id = mmc.category_id-->
<!-- left join drp_supplier ds on did.supplier_id = ds.supplier_id-->
<!-- left join drp_unit du on mm.unit_id = du.unit_id-->
<!-- where-->
<!-- mm.del_flag = #{delFlag}-->
<!-- <if test="content.materialCode != null and content.materialCode != ''">-->
<!-- and mm.material_code = #{content.materialCode}-->
<!-- </if>-->
<!-- <if test="content.materialName != null and content.materialName != ''">-->
<!-- and (-->
<!-- mm.material_name like concat(concat('%', #{content.materialName}), '%')-->
<!-- or mm.pinyin_initials like concat(concat('%', #{pinyinInitials}), '%')-->
<!-- or mm.pinyin_full like concat(concat('%', #{pinyinFull}), '%')-->
<!-- )-->
<!-- </if>-->
<!-- <if test="content.categoryIdList != null and content.categoryIdList.size() > 0">-->
<!-- and mm.category_id in-->
<!-- <foreach collection="content.categoryIdList" item="categoryId" separator="," open="(" close=")">-->
<!-- #{categoryId}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="content.barCode != null and content.barCode != ''">-->
<!-- and mm.bar_code = #{content.barCode}-->
<!-- </if>-->
<!-- </select>-->
<select id="selectAndroidMaterialList"
resultType="com.bonus.canteen.core.drp.vo.AndroidSearchMaterialVO">
select
mm.material_id,
mm.material_name,
mm.material_code,
mmc.category_name,
ds.supplier_id,
ds.supplier_name,
mm.unit_id,
du.unit_name,
du.weigh_type,
du.rate,
did.unit_price
from
menu_material mm
left join (
select
a.*
from
drp_into_detail as a,
( select b.material_id, max( b.id ) as id from drp_into_detail as b group by b.material_id ) as c
where
a.material_id = c.material_id
and a.id = c.id
) did on mm.material_id = did.material_id
left join menu_material_category mmc on mm.category_id = mmc.category_id
left join drp_supplier ds on did.supplier_id = ds.supplier_id
left join drp_unit du on mm.unit_id = du.unit_id
where
mm.del_flag = #{delFlag}
<if test="content.materialCode != null and content.materialCode != ''">
and mm.material_code = #{content.materialCode}
</if>
<if test="content.materialName != null and content.materialName != ''">
and (
mm.material_name like concat(concat('%', #{content.materialName}), '%')
or mm.pinyin_initials like concat(concat('%', #{pinyinInitials}), '%')
or mm.pinyin_full like concat(concat('%', #{pinyinFull}), '%')
)
</if>
<if test="content.categoryIdList != null and content.categoryIdList.size() > 0">
and mm.category_id in
<foreach collection="content.categoryIdList" item="categoryId" separator="," open="(" close=")">
#{categoryId}
</foreach>
</if>
<if test="content.barCode != null and content.barCode != ''">
and mm.bar_code = #{content.barCode}
</if>
</select>
<!-- <select id="searchInventoryMaterial"-->
<!-- resultType="net.xnzn.core.drp.vo.AndroidSearchInventoryMaterialVO">-->