ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpClinicWarehousingController.java
@@ -1,8 +1,26 @@ package com.ruoyi.web.controller.api; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.basic.PageInfo; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.framework.web.service.TokenService; import com.ruoyi.system.query.TErpGoodsQuery; import com.ruoyi.system.query.TErpGoodsWarehouseQuery; import com.ruoyi.system.service.TErpClinicWarehousingService; import com.ruoyi.system.service.TErpGoodsService; import com.ruoyi.system.service.TErpSupplierWarehousingService; import com.ruoyi.system.vo.TErpGoodsVO; import com.ruoyi.system.vo.TErpGoodsWarehouseLastVO; import com.ruoyi.system.vo.TErpGoodsWarehouseRecordLastVO; import com.ruoyi.system.vo.TErpGoodsWarehouseVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import java.util.List; /** * <p> @@ -14,7 +32,54 @@ */ @RestController @RequestMapping("/t-erp-clinic-warehousing") @Api(tags = "供应商库存管理") public class TErpClinicWarehousingController { private final TErpSupplierWarehousingService erpSupplierWarehousingService; private final TokenService tokenService; @Autowired public TErpClinicWarehousingController(TErpSupplierWarehousingService erpSupplierWarehousingService, TokenService tokenService) { this.erpSupplierWarehousingService = erpSupplierWarehousingService; this.tokenService = tokenService; } /** * 获取erp问题上报管理列表 */ @ApiOperation(value = "供应商获取库存分页列表") @PostMapping(value = "/pageList") public R<PageInfo<TErpGoodsVO>> pageList(@RequestBody TErpGoodsQuery query) { SysUser user = tokenService.getLoginUser().getUser(); return R.ok(erpSupplierWarehousingService.pageList(query,user)); } @ApiOperation(value = "供应商库存详情") @GetMapping(value = "/detail") public R<List<TErpGoodsWarehouseLastVO>> detail(String id, String warehouseName) { SysUser user = tokenService.getLoginUser().getUser(); return R.ok(erpSupplierWarehousingService.detail(id,warehouseName,user)); } /** * 获取erp问题上报管理列表 */ @ApiOperation(value = "供应商获取库存记录列表") @PostMapping(value = "/pageWarehouseList") public R<PageInfo<TErpGoodsWarehouseRecordLastVO>> pageWarehouseList(@RequestBody TErpGoodsWarehouseQuery query) { SysUser user = tokenService.getLoginUser().getUser(); return R.ok(erpSupplierWarehousingService.pageWarehouseList(query,user)); } } ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsController.java
@@ -67,6 +67,7 @@ } TErpGoods goods = new TErpGoods(); goods.setSupplierClinicId(user.getUserId().toString()); goods.setCreateId(user.getUserId().toString()); goods.setGoodsIdCode(dto.getGoodsIdCode()); goods.setQuasiNumber(dto.getQuasiNumber()); goods.setManufacturer(dto.getManufacturer()); ruoyi-system/src/main/java/com/ruoyi/system/mapper/TErpSupplierWarehousingMapper.java
@@ -1,7 +1,16 @@ package com.ruoyi.system.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.common.basic.PageInfo; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.system.model.TErpSupplierWarehousing; import com.ruoyi.system.query.TErpGoodsQuery; import com.ruoyi.system.query.TErpGoodsWarehouseQuery; import com.ruoyi.system.vo.TErpGoodsVO; import com.ruoyi.system.vo.TErpGoodsWarehouseRecordLastVO; import org.apache.ibatis.annotations.Param; import java.util.List; /** * <p> @@ -13,4 +22,7 @@ */ public interface TErpSupplierWarehousingMapper extends BaseMapper<TErpSupplierWarehousing> { List<TErpGoodsVO> pageList(@Param("query") TErpGoodsQuery query, @Param("pageInfo") PageInfo<TErpGoodsVO> pageInfo, @Param("user") SysUser user); List<TErpGoodsWarehouseRecordLastVO> pageWarehouseList(@Param("query") TErpGoodsWarehouseQuery query, @Param("pageInfo") PageInfo<TErpGoodsWarehouseRecordLastVO> pageInfo, @Param("user") SysUser user); } ruoyi-system/src/main/java/com/ruoyi/system/query/TErpGoodsQuery.java
@@ -25,4 +25,7 @@ @ApiModelProperty(value = "1启用 2禁用") private Integer state; @ApiModelProperty(value = "库存管理条件 不足传1") private Integer type; } ruoyi-system/src/main/java/com/ruoyi/system/query/TErpGoodsWarehouseQuery.java
New file @@ -0,0 +1,22 @@ package com.ruoyi.system.query; import com.ruoyi.common.core.domain.BasePage; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data @ApiModel(value = "erp商品库存记录查询参数query") public class TErpGoodsWarehouseQuery extends BasePage { @ApiModelProperty(value = "仓库名称") private String warehouseName; @ApiModelProperty(value = "1入库 2出库") private Integer type; @ApiModelProperty(value = "操作时间 2022-02-02 - 2023-03-03") private String time; } ruoyi-system/src/main/java/com/ruoyi/system/service/TErpSupplierWarehousingService.java
@@ -1,7 +1,17 @@ package com.ruoyi.system.service; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.common.basic.PageInfo; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.system.model.TErpSupplierWarehousing; import com.ruoyi.system.query.TErpGoodsQuery; import com.ruoyi.system.query.TErpGoodsWarehouseQuery; import com.ruoyi.system.vo.TErpGoodsVO; import com.ruoyi.system.vo.TErpGoodsWarehouseLastVO; import com.ruoyi.system.vo.TErpGoodsWarehouseRecordLastVO; import com.ruoyi.system.vo.TErpGoodsWarehouseVO; import java.util.List; /** * <p> @@ -13,4 +23,9 @@ */ public interface TErpSupplierWarehousingService extends IService<TErpSupplierWarehousing> { PageInfo<TErpGoodsVO> pageList(TErpGoodsQuery query, SysUser user); List<TErpGoodsWarehouseLastVO> detail(String id, String warehouseName, SysUser user); PageInfo<TErpGoodsWarehouseRecordLastVO> pageWarehouseList(TErpGoodsWarehouseQuery query, SysUser user); } ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java
@@ -6,6 +6,8 @@ import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.system.mapper.TErpGoodsMapper; import com.ruoyi.system.mapper.TErpGoodsTypeMapper; import com.ruoyi.system.mapper.TErpSupplierInventoryMapper; import com.ruoyi.system.mapper.TErpSupplierWarehousingMapper; import com.ruoyi.system.model.TErpGoods; import com.ruoyi.system.model.TErpGoodsType; import com.ruoyi.system.model.TSysBanner; @@ -32,6 +34,7 @@ @Resource private TErpGoodsTypeMapper erpGoodsTypeMapper; @Override public PageInfo<TErpGoodsVO> pageList(TErpGoodsQuery query, SysUser user) { PageInfo<TErpGoodsVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpSupplierWarehousingServiceImpl.java
@@ -1,10 +1,28 @@ package com.ruoyi.system.service.impl; import com.ruoyi.system.model.TErpSupplierWarehousing; import com.ruoyi.system.mapper.TErpSupplierWarehousingMapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.common.basic.PageInfo; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.system.mapper.*; import com.ruoyi.system.model.*; import com.ruoyi.system.query.TErpGoodsQuery; import com.ruoyi.system.query.TErpGoodsWarehouseQuery; import com.ruoyi.system.service.TErpSupplierWarehousingService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.system.vo.TErpGoodsVO; import com.ruoyi.system.vo.TErpGoodsWarehouseLastVO; import com.ruoyi.system.vo.TErpGoodsWarehouseRecordLastVO; import com.ruoyi.system.vo.TErpGoodsWarehouseVO; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.stream.Collectors; /** * <p> @@ -17,4 +35,113 @@ @Service public class TErpSupplierWarehousingServiceImpl extends ServiceImpl<TErpSupplierWarehousingMapper, TErpSupplierWarehousing> implements TErpSupplierWarehousingService { @Resource private TErpGoodsTypeMapper erpGoodsTypeMapper; @Resource private TErpSupplierWarehousingMapper erpSupplierWarehousingMapper; @Resource private TErpGoodsMapper erpGoodsMapper; @Resource private TErpSupplierOutboundGoodsMapper erpSupplierOutboundGoodsMapper; @Resource private TErpSupplierWarehousingBatchMapper erpSupplierWarehousingBatchMapper; @Resource private TCrmWarehouseMapper crmWarehouseMapper; @Override public PageInfo<TErpGoodsVO> pageList(TErpGoodsQuery query, SysUser user) { PageInfo<TErpGoodsVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); List<TErpGoodsVO> list = this.baseMapper.pageList(query,pageInfo,user); if(list.isEmpty()){ return pageInfo; } List<String> typeIds = list.stream().map(TErpGoods::getTypeId).collect(Collectors.toList()); if(!typeIds.isEmpty()){ List<TErpGoodsType> typeList = erpGoodsTypeMapper.selectBatchIds(typeIds); for (TErpGoodsVO tErpGoodsVO : list) { typeList.stream().filter(t -> t.getId().equals(tErpGoodsVO.getTypeId())).findFirst().ifPresent(t -> tErpGoodsVO.setTypeName(t.getTypeName())); tErpGoodsVO.setTypeName(tErpGoodsVO.getTypeName()); } } pageInfo.setRecords(list); return pageInfo; } @Override public List<TErpGoodsWarehouseLastVO> detail(String id, String warehouseName, SysUser user) { TErpGoods goods = erpGoodsMapper.selectById(id); List<TCrmWarehouse> tCrmWarehouses = crmWarehouseMapper.selectList(new LambdaQueryWrapper<TCrmWarehouse>().eq(warehouseName != null && !warehouseName.isEmpty(), TCrmWarehouse::getWarehouseName, warehouseName)); if(tCrmWarehouses.isEmpty()){ return Collections.emptyList(); } List<TErpSupplierWarehousing> tErpSupplierWarehousings = erpSupplierWarehousingMapper.selectList(new LambdaQueryWrapper<TErpSupplierWarehousing>().in(TErpSupplierWarehousing::getWarehouseId, tCrmWarehouses.stream().map(TCrmWarehouse::getId).collect(Collectors.toList())).eq(TErpSupplierWarehousing::getSupplierId, user.getUserId()).eq(TErpSupplierWarehousing::getGoodsId, id)); if(tErpSupplierWarehousings.isEmpty()){ return Collections.emptyList(); } // 出库详情 List<TErpSupplierOutboundGoods> tErpSupplierOutboundGoods = erpSupplierOutboundGoodsMapper.selectList(new LambdaQueryWrapper<TErpSupplierOutboundGoods>().in(TErpSupplierOutboundGoods::getWarehousingId, tErpSupplierWarehousings.stream().map(TErpSupplierWarehousing::getId).collect(Collectors.toList()))); // 入库批次 List<TErpSupplierWarehousingBatch> tErpSupplierWarehousingBatches = erpSupplierWarehousingBatchMapper.selectList(new LambdaQueryWrapper<TErpSupplierWarehousingBatch>().in(!tErpSupplierWarehousings.isEmpty(), TErpSupplierWarehousingBatch::getWarehousingId, tErpSupplierWarehousings.stream().map(TErpSupplierWarehousing::getId).collect(Collectors.toList()))); ArrayList<TErpGoodsWarehouseLastVO> tErpGoodsWarehouseLastVOS = new ArrayList<>(); // 通过WarehouseId分组 Map<String, List<TErpSupplierWarehousing>> collect = tErpSupplierWarehousings.stream().collect(Collectors.groupingBy(TErpSupplierWarehousing::getWarehouseId)); for (Map.Entry<String, List<TErpSupplierWarehousing>> entry : collect.entrySet()) { TErpGoodsWarehouseLastVO tErpGoodsWarehouseLastVO = new TErpGoodsWarehouseLastVO(); // 获取key String houseId = entry.getKey(); List<TErpSupplierWarehousing> list = entry.getValue(); tErpGoodsWarehouseLastVO.setHouseId( houseId); tCrmWarehouses.stream().filter(t -> t.getId().equals(houseId)).findFirst().ifPresent(t -> tErpGoodsWarehouseLastVO.setHouseName(t.getWarehouseName())); List<String> warehousingIds = list.stream().map(TErpSupplierWarehousing::getId).collect(Collectors.toList()); // 当前仓库的入库批次信息 List<TErpSupplierWarehousingBatch> warehousingBatchesList = tErpSupplierWarehousingBatches.stream().filter(t -> warehousingIds.contains(t.getWarehousingId())).collect(Collectors.toList()); ArrayList<TErpGoodsWarehouseVO> tErpGoodsWarehouseVOS = new ArrayList<>(); for (TErpSupplierWarehousingBatch tErpSupplierWarehousingBatch : warehousingBatchesList) { TErpSupplierWarehousing tErpSupplierWarehousing = list.stream().filter(e -> e.getId().equals(tErpSupplierWarehousingBatch.getWarehousingId())).findFirst().get(); TErpGoodsWarehouseVO tErpGoodsWarehouseVO = new TErpGoodsWarehouseVO(); tErpGoodsWarehouseVO.setBatchNumber(tErpSupplierWarehousingBatch.getBatchNumber()); tErpGoodsWarehouseVO.setProductionDate(tErpSupplierWarehousingBatch.getProductionDate()); tErpGoodsWarehouseVO.setExpiryDate(tErpSupplierWarehousingBatch.getExpiryDate()); TErpSupplierOutboundGoods tErpSupplierOutboundGoods1 = tErpSupplierOutboundGoods.stream().filter(t -> t.getWarehousingBatchId().equals(tErpSupplierWarehousingBatch.getId())).findFirst().orElse(null); if(tErpSupplierOutboundGoods1!=null){ tErpGoodsWarehouseVO.setNowNum(tErpSupplierWarehousingBatch.getWarehousingNumber()-tErpSupplierOutboundGoods1.getOutboundCount()); }else { tErpGoodsWarehouseVO.setNowNum(tErpSupplierWarehousingBatch.getWarehousingNumber()); } tErpGoodsWarehouseVO.setUnitAmount(new BigDecimal(tErpSupplierWarehousing.getUnitAmount()*tErpGoodsWarehouseVO.getNowNum()).setScale(2, RoundingMode.HALF_UP).doubleValue()); tErpGoodsWarehouseVOS.add(tErpGoodsWarehouseVO); } tErpGoodsWarehouseLastVO.setAllNum(tErpGoodsWarehouseVOS.stream().mapToInt(TErpGoodsWarehouseVO::getNowNum).sum()); tErpGoodsWarehouseLastVO.setAllTotalPrice(tErpGoodsWarehouseVOS.stream().mapToDouble(TErpGoodsWarehouseVO::getUnitAmount).sum()); tErpGoodsWarehouseLastVO.setList(tErpGoodsWarehouseVOS); tErpGoodsWarehouseLastVO.setWarningInventory(goods.getWarningInventory()); tErpGoodsWarehouseLastVOS.add(tErpGoodsWarehouseLastVO); } return tErpGoodsWarehouseLastVOS; } @Override public PageInfo<TErpGoodsWarehouseRecordLastVO> pageWarehouseList(TErpGoodsWarehouseQuery query, SysUser user) { PageInfo<TErpGoodsWarehouseRecordLastVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); List<TErpGoodsWarehouseRecordLastVO> list = this.baseMapper.pageWarehouseList(query,pageInfo,user); return null; } } ruoyi-system/src/main/java/com/ruoyi/system/vo/TErpGoodsVO.java
@@ -6,8 +6,16 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; @Data @ApiModel(value = "供应商erp商品VO") public class TErpGoodsVO extends TErpGoods { @ApiModelProperty(value = "总库存数量") private Integer allNum; @ApiModelProperty(value = "总价") private BigDecimal allTotalPrice; } ruoyi-system/src/main/java/com/ruoyi/system/vo/TErpGoodsWarehouseLastVO.java
New file @@ -0,0 +1,34 @@ package com.ruoyi.system.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; import java.util.Date; import java.util.List; @Data @ApiModel(value = "供应商erp库存详情一级商品VO") public class TErpGoodsWarehouseLastVO { @ApiModelProperty(value = "仓库id") private String houseId; @ApiModelProperty(value = "仓库名称") private String houseName; @ApiModelProperty(value = "总库存") private Integer allNum; @ApiModelProperty(value = "总价") private Double allTotalPrice; @ApiModelProperty(value = "预警库存") private Integer warningInventory; @ApiModelProperty("二级信息") private List<TErpGoodsWarehouseVO> list; } ruoyi-system/src/main/java/com/ruoyi/system/vo/TErpGoodsWarehouseRecordLastVO.java
New file @@ -0,0 +1,48 @@ package com.ruoyi.system.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.time.LocalDateTime; import java.util.List; @Data @ApiModel(value = "供应商erp库存详情一级商品VO") public class TErpGoodsWarehouseRecordLastVO { @ApiModelProperty(value = "仓库id") private String houseId; @ApiModelProperty(value = "仓库名称") private String houseName; @ApiModelProperty(value = "总库存") private Integer allNum; @ApiModelProperty(value = "总价") private Double allTotalPrice; @ApiModelProperty(value = "预警库存") private Integer warningInventory; @ApiModelProperty(value = "1入库 2出库") private Integer type; @ApiModelProperty(value = "操作时间") private LocalDateTime operationTime; @ApiModelProperty(value = "出库原因") private String outboundReason; @ApiModelProperty(value = "出库类型1=报损 2=到期 3=失效 4=召回 5=其他 6=盘点出库 7=购买出库") private Integer outboundType; @ApiModelProperty("二级信息") private List<TErpGoodsWarehouseVO> list; } ruoyi-system/src/main/java/com/ruoyi/system/vo/TErpGoodsWarehouseVO.java
New file @@ -0,0 +1,34 @@ package com.ruoyi.system.vo; import com.ruoyi.system.model.TErpGoods; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.Date; @Data @ApiModel(value = "供应商erp库存详情二级商品VO") public class TErpGoodsWarehouseVO { @ApiModelProperty(value = "数量") private Integer nowNum; @ApiModelProperty(value = "批次号") private String batchNumber; @ApiModelProperty(value = "生产日期") private LocalDateTime productionDate; @ApiModelProperty(value = "失效日期") private LocalDateTime expiryDate; @ApiModelProperty(value = "单价") private Double unitAmount; } ruoyi-system/src/main/resources/mapper/system/TErpGoodsMapper.xml
@@ -57,8 +57,11 @@ <if test="query.state != null "> and state = #{query.state} </if> <if test="user.roleType == null or user.roleType != 1 "> and create_id =#{user.userId} <if test="user.roleType != null and user.roleType == 4 "> and goods_source =1 and supplier_clinic_id =#{user.userId} </if> <if test="user.roleType != null and user.roleType == 5 "> and goods_source =2 and supplier_clinic_id =#{user.userId} </if> order by create_time desc </select> ruoyi-system/src/main/resources/mapper/system/TErpSupplierWarehousingMapper.xml
@@ -24,4 +24,50 @@ id, warehouse_id, supplier_id, goods_id, goods_name, goods_count, unit_amount, total_price, create_time, update_time, create_by, update_by, disabled </sql> <sql id="Base_Column_List1"> t1.id, t1.supplier_clinic_id, t1.goods_source, t1.goods_name, t1.goods_id_code, t1.quasi_number, t1.manufacturer, t1.formulation_spec, t1.packing_spec, t1.type_id, t1.goods_yards, t1.maintenance_interval, t1.low_purchase_quantity, t1.low_unit_id, t1.is_prescription_drug, t1.goods_spec, t1.warning_inventory, t1.sales_amount, t1.packing_unit_id, t1.instructions_use, t1.side_effect, t1.clinic_purchase_price, t1.platform_commission_price, t1.create_time, t1.update_time, t1.create_by,t1.`state`, t1.update_by, t1.disabled, </sql> <select id="pageList" resultType="com.ruoyi.system.vo.TErpGoodsVO"> select * from ( select <include refid="Base_Column_List1"/> COALESCE(sum(t2.goods_count), 0) - COALESCE(sum(t3.outbound_count), 0) as allNum, COALESCE(sum(t2.total_price), 0) * ( COALESCE(sum(t2.goods_count), 0) - COALESCE(sum(t3.outbound_count), 0)) as allTotalPrice, COALESCE(sum(t3.outbound_count), 0) as outNum from t_erp_goods t1 left join t_erp_supplier_warehousing t2 on t1.id = t2.goods_id left join t_erp_supplier_outbound_goods t3 on t2.id = t3.warehousing_id where t1.disabled = 0 <if test="query.goodsName != null and query.goodsName != ''"> and t1.goods_name like concat('%',#{query.goodsName},'%') </if> <if test="query.goodsIdCode != null and query.goodsIdCode != ''"> and t1.goods_id_code like concat('%',#{query.goodsIdCode},'%') </if> <if test="query.typeId != null and query.typeId != ''"> and t1.type_id = #{query.typeId} </if> <if test="query.quasiNumber != null and query.quasiNumber != ''"> and t1.quasi_number like concat('%',#{query.quasiNumber},'%') </if> <if test="query.state != null "> and t1.state = #{query.state} </if> <if test="user.roleType != null and user.roleType == 4 "> and t1.goods_source =1 and t1.supplier_clinic_id =#{user.userId} </if> <if test="user.roleType != null and user.roleType == 5 "> and t1.goods_source =2 and t1.supplier_clinic_id =#{user.userId} </if> ) o where 1=1 <if test="query.type != null and query.type ==1"> and o.warning_inventory > (o.allNum-o.outNum) </if> order by o.create_time desc </select> <select id="pageWarehouseList" resultType="com.ruoyi.system.vo.TErpGoodsWarehouseRecordLastVO"> select t1.warehouse_id houseId,t2.warehouse_name houseName,t1.total_money allTotalPrice,t1.outbound_type </select> </mapper>