ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysGoodsController.java
@@ -196,7 +196,10 @@ @PostMapping(value = "/getExchangeRecord") public R<PageInfo<TSysGoodsExchange>> getExchangeRecord(@RequestBody @Valid TSysGoodsExchangeQuery query) { PageInfo<TSysGoodsExchange> page = new PageInfo<>(query.getPageNum(), query.getPageSize()); LambdaQueryWrapper<TSysGoodsExchange> wrapper = new LambdaQueryWrapper<TSysGoodsExchange>().eq(TSysGoodsExchange::getGoodsId, query.getId()); LambdaQueryWrapper<TSysGoodsExchange> wrapper = new LambdaQueryWrapper<TSysGoodsExchange>(); if(query.getId()!=null && !query.getId().isEmpty()){ wrapper.eq(TSysGoodsExchange::getGoodsId, query.getId()); } if (query.getClinicName() != null && !query.getClinicName().isEmpty()) { wrapper.like(TSysGoodsExchange::getClinicName, query.getClinicName()); } ruoyi-system/src/main/java/com/ruoyi/system/query/TSysGoodsExchangeQuery.java
@@ -12,7 +12,6 @@ public class TSysGoodsExchangeQuery extends BasePage { @ApiModelProperty("商品id") @NotBlank(message = "商品id不能为空") private String id; @ApiModelProperty("诊所名称") private String clinicName; ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java
@@ -570,6 +570,28 @@ String warehousingId1 = tErpSupplierWarehousingBatch1.getWarehousingId(); TErpSupplierWarehousing tErpSupplierWarehousing2 = erpSupplierWarehousingMapper.selectById(warehousingId1); if(inventoryGoodsDto.getDamagedCount()!=null && inventoryGoodsDto.getDamagedCount()>0){ TErpSupplierOutbound tErpSupplierOutbound = new TErpSupplierOutbound(); tErpSupplierOutbound.setWarehouseId(dto.getWarehouseId()); tErpSupplierOutbound.setSupplierId(supplierClinicId); tErpSupplierOutbound.setOutboundType(1); tErpSupplierOutbound.setOutboundNumber("G" + s); int count = inventoryGoodsDto.getDamagedCount(); tErpSupplierOutbound.setTotalMoney(tErpSupplierWarehousing1.getUnitAmount().multiply(new BigDecimal(count))); tErpSupplierOutbound.setGoodsId(tErpSupplierWarehousing2.getGoodsId()); erpSupplierOutboundMapper.insert(tErpSupplierOutbound); TErpSupplierOutboundGoods tErpSupplierOutboundGoods = new TErpSupplierOutboundGoods(); tErpSupplierOutboundGoods.setOutboundId(tErpSupplierOutbound.getId()); tErpSupplierOutboundGoods.setWarehousingId(tErpSupplierWarehousing1.getId()); tErpSupplierOutboundGoods.setWarehousingBatchId(tErpSupplierWarehousingBatch.getId()); tErpSupplierOutboundGoods.setOutboundCount(count); tErpSupplierOutboundGoods.setTotalPrice(tErpSupplierWarehousing1.getUnitAmount().multiply(new BigDecimal(count))); erpSupplierOutboundGoodsMapper.insert(tErpSupplierOutboundGoods); } TErpSupplierOutbound tErpSupplierOutbound = new TErpSupplierOutbound(); tErpSupplierOutbound.setWarehouseId(dto.getWarehouseId()); tErpSupplierOutbound.setSupplierId(supplierClinicId); @@ -638,6 +660,8 @@ TErpClinicWarehousing tErpSupplierWarehousing1 = erpClinicWarehousingMapper.selectById(warehousingId); TErpGoods erpGoods = this.getById(tErpSupplierWarehousingBatch.getGoodsId()); // 盘点是盘亏盘盈 赢 if (inventoryGoodsDto.getNum() < inventoryGoodsDto.getInventoryCount()) { // 添加入库信息 @@ -683,6 +707,26 @@ } else { if(inventoryGoodsDto.getDamagedCount()!=null && inventoryGoodsDto.getDamagedCount()>0){ TErpClinicOutbound tErpSupplierOutbound = new TErpClinicOutbound(); // tErpSupplierOutbound.setWarehouseId(dto.getWarehouseId()); // tErpSupplierOutbound.setSupplierId(supplierClinicId); tErpSupplierOutbound.setOutboundType(1); tErpSupplierOutbound.setOutboundNumber("G" + s); int count = inventoryGoodsDto.getDamagedCount(); tErpSupplierOutbound.setTotalMoney(erpGoods.getSalesAmount().multiply(new BigDecimal(count))); tErpSupplierOutbound.setInventoryId(tErpSupplierInventory.getId()); erpClinicOutboundMapper.insert(tErpSupplierOutbound); TErpClinicOutboundGoods tErpSupplierOutboundGoods = new TErpClinicOutboundGoods(); tErpSupplierOutboundGoods.setOutboundId(tErpSupplierOutbound.getId()); tErpSupplierOutboundGoods.setWarehousingId(tErpSupplierWarehousing1.getId()); tErpSupplierOutboundGoods.setWarehousingBatchId(tErpSupplierWarehousingBatch.getId()); tErpSupplierOutboundGoods.setOutboundCount(count); tErpSupplierOutboundGoods.setTotalPrice(erpGoods.getSalesAmount().multiply(new BigDecimal(count))); erpClinicOutboundGoodsMapper.insert(tErpSupplierOutboundGoods); } TErpClinicOutbound tErpSupplierOutbound = new TErpClinicOutbound(); // tErpSupplierOutbound.setWarehouseId(dto.getWarehouseId()); // tErpSupplierOutbound.setSupplierId(supplierClinicId); ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpMaintenanceReminderServiceImpl.java
@@ -46,10 +46,18 @@ private TErpSupplierWarehousingBatchMapper erpSupplierWarehousingBatchMapper; @Resource private TErpClinicWarehousingBatchMapper erpClinicWarehousingBatchMapper; @Resource private TErpSupplierWarehousingMapper erpSupplierWarehousingMapper; @Resource private TErpClinicOutboundGoodsMapper erpClinicOutboundGoodsMapper; @Resource private TErpSupplierOutboundGoodsMapper erpSupplierOutboundGoodsMapper; @Resource private TCrmClinicMapper crmClinicMapper; @@ -125,26 +133,47 @@ String warehousingBatchId = tErpMaintenanceReminder.getWarehousingBatchId(); if(warehousingBatchId != null){ TErpSupplierWarehousingBatch tErpSupplierWarehousingBatch = erpSupplierWarehousingBatchMapper.selectById(warehousingBatchId); tErpMaintenanceReminderDetailVo.setBatchNumber(tErpSupplierWarehousingBatch.getBatchNumber()); TErpSupplierWarehousing tErpSupplierWarehousing = erpSupplierWarehousingMapper.selectById(tErpSupplierWarehousingBatch.getWarehousingId()); if(tErpSupplierWarehousing!=null){ String goodsId = tErpSupplierWarehousing.getGoodsId(); if(goodsId != null){ TErpGoods goods = erpGoodsMapper.selectById(goodsId); tErpMaintenanceReminderDetailVo.setGoodsName(goods.getGoodsName()); tErpMaintenanceReminderDetailVo.setQuasiNumber(goods.getQuasiNumber()); tErpMaintenanceReminderDetailVo.setGoodsIdCode(goods.getGoodsIdCode()); String packingUnitId = goods.getPackingUnitId(); if(packingUnitId != null){ TErpGoodsUnit tErpGoodsUnit = erpGoodsUnitMapper.selectById(packingUnitId); tErpMaintenanceReminderDetailVo.setUnitName(tErpGoodsUnit.getUnitName()); if(tErpMaintenanceReminder.getMaintenanceType()==2){ TErpClinicWarehousingBatch tErpSupplierWarehousingBatch = erpClinicWarehousingBatchMapper.selectById(warehousingBatchId); tErpMaintenanceReminderDetailVo.setBatchNumber(tErpSupplierWarehousingBatch.getBatchNumber()); String goodsId = tErpSupplierWarehousingBatch.getGoodsId(); if(goodsId != null){ TErpGoods goods = erpGoodsMapper.selectById(goodsId); tErpMaintenanceReminderDetailVo.setGoodsName(goods.getGoodsName()); tErpMaintenanceReminderDetailVo.setQuasiNumber(goods.getQuasiNumber()); tErpMaintenanceReminderDetailVo.setGoodsIdCode(goods.getGoodsIdCode()); String packingUnitId = goods.getPackingUnitId(); if(packingUnitId != null){ TErpGoodsUnit tErpGoodsUnit = erpGoodsUnitMapper.selectById(packingUnitId); tErpMaintenanceReminderDetailVo.setUnitName(tErpGoodsUnit.getUnitName()); } } List<TErpClinicOutboundGoods> tErpSupplierOutboundGoods = erpClinicOutboundGoodsMapper.selectList(new LambdaQueryWrapper<TErpClinicOutboundGoods>().eq(TErpClinicOutboundGoods::getWarehousingBatchId, warehousingBatchId)); int sum = tErpSupplierOutboundGoods.stream().mapToInt(TErpClinicOutboundGoods::getOutboundCount).sum(); tErpMaintenanceReminderDetailVo.setNumber(tErpSupplierWarehousingBatch.getWarehousingNumber()-sum); }else { TErpSupplierWarehousingBatch tErpSupplierWarehousingBatch = erpSupplierWarehousingBatchMapper.selectById(warehousingBatchId); tErpMaintenanceReminderDetailVo.setBatchNumber(tErpSupplierWarehousingBatch.getBatchNumber()); TErpSupplierWarehousing tErpSupplierWarehousing = erpSupplierWarehousingMapper.selectById(tErpSupplierWarehousingBatch.getWarehousingId()); if(tErpSupplierWarehousing!=null){ String goodsId = tErpSupplierWarehousing.getGoodsId(); if(goodsId != null){ TErpGoods goods = erpGoodsMapper.selectById(goodsId); tErpMaintenanceReminderDetailVo.setGoodsName(goods.getGoodsName()); tErpMaintenanceReminderDetailVo.setQuasiNumber(goods.getQuasiNumber()); tErpMaintenanceReminderDetailVo.setGoodsIdCode(goods.getGoodsIdCode()); String packingUnitId = goods.getPackingUnitId(); if(packingUnitId != null){ TErpGoodsUnit tErpGoodsUnit = erpGoodsUnitMapper.selectById(packingUnitId); tErpMaintenanceReminderDetailVo.setUnitName(tErpGoodsUnit.getUnitName()); } } } List<TErpSupplierOutboundGoods> tErpSupplierOutboundGoods = erpSupplierOutboundGoodsMapper.selectList(new LambdaQueryWrapper<TErpSupplierOutboundGoods>().eq(TErpSupplierOutboundGoods::getWarehousingBatchId, warehousingBatchId)); int sum = tErpSupplierOutboundGoods.stream().mapToInt(TErpSupplierOutboundGoods::getOutboundCount).sum(); tErpMaintenanceReminderDetailVo.setNumber(tErpSupplierWarehousingBatch.getWarehousingNumber()-sum); } List<TErpSupplierOutboundGoods> tErpSupplierOutboundGoods = erpSupplierOutboundGoodsMapper.selectList(new LambdaQueryWrapper<TErpSupplierOutboundGoods>().eq(TErpSupplierOutboundGoods::getWarehousingBatchId, warehousingBatchId)); int sum = tErpSupplierOutboundGoods.stream().mapToInt(TErpSupplierOutboundGoods::getOutboundCount).sum(); tErpMaintenanceReminderDetailVo.setNumber(tErpSupplierWarehousingBatch.getWarehousingNumber()-sum); } return tErpMaintenanceReminderDetailVo; ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TSysGoodsServiceImpl.java
@@ -54,7 +54,7 @@ if(sum+dto.getCount()>tSysGoods.getConvertibleQuantity()){ throw new RuntimeException("可兑换数量不足"); } List<TCrmClinicPoints> points = crmClinicPointsMapper.selectList(new LambdaQueryWrapper<TCrmClinicPoints>().eq(TCrmClinicPoints::getClinicId, crmClinic.getId()).ge(TCrmClinicPoints::getExpireTime, new Date()).last(" and points > use_points").orderByAsc(TCrmClinicPoints::getCreateTime)); List<TCrmClinicPoints> points = crmClinicPointsMapper.selectList(new LambdaQueryWrapper<TCrmClinicPoints>().eq(TCrmClinicPoints::getClinicId, crmClinic.getId()).ge(TCrmClinicPoints::getExpireTime, new Date()).last(" and points > use_points ORDER BY create_time ASC")); // 可用积分 int userPoints = points.stream().mapToInt(item -> item.getPoints() - item.getUsePoints()).sum(); if(userPoints<needPoints){ ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TSysOrderServiceImpl.java
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.basic.PageInfo; import com.ruoyi.common.core.domain.BaseModel; import com.ruoyi.system.dto.TSysOrderDto; import com.ruoyi.system.dto.TSysOrderNextDto; import com.ruoyi.system.mapper.*; ruoyi-system/src/main/resources/mapper/system/TErpClinicWarehousingMapper.xml
@@ -47,10 +47,11 @@ <select id="validityPeriodWarning" resultType="com.ruoyi.system.vo.ValidityPeriodWarningVo"> select t2.warehouse_no warehousingNo, t4.goods_name, t4.quasi_number, t1.batch_number, t1.id as batchId,t1.expiry_date, t4.id as goodsId,t5.type_name,t6.unit_name packingUnitName, select * from (select t2.warehouse_no warehousingNo, t4.goods_name, t4.quasi_number, t1.batch_number, t1.id as batchId,t1.expiry_date, t4.id as goodsId,t5.type_name,t6.unit_name packingUnitName, case when t3.id is null then t1.warehousing_number else t1.warehousing_number -t3.outbound_count else t1.warehousing_number -coalesce(sum(t3.outbound_count),0) end as num from t_erp_clinic_warehousing_batch t1 left join t_erp_clinic_warehousing t2 on t1.warehousing_id = t2.id @@ -59,7 +60,6 @@ left join t_erp_goods_type t5 on t4.type_id = t5.id left join t_erp_goods_unit t6 on t4.packing_unit_id = t6.id where #{time} > t1.expiry_date and (t1.warehousing_number - t3.outbound_count > 0 or t3.id is null) <if test="user.roleType !=null and user.roleType ==5"> and t2.clinic_id =#{supplierClinicId} </if> @@ -75,7 +75,10 @@ <if test="query.typeId != null and query.typeId != ''"> and t4.type_id = #{query.typeId} </if> order by t1.expiry_date group by t1.id ) as o where o.num >0 order by o.expiry_date </select> @@ -85,13 +88,17 @@ <select id="pageList" resultType="com.ruoyi.system.vo.TErpGoodsVO"> select * from ( select <include refid="Base_Column_List1"/> COALESCE(sum(t2.purchase_count), 0) - COALESCE(sum(t3.outbound_count), 0) as allNum, SUM(t2.unit_amount * (t2.purchase_count - COALESCE(t3.outbound_count, 0))) as allTotalPrice, COALESCE(sum(t2.warehousing_number), 0) - COALESCE(sum(t3.outbound_count), 0) as allNum, SUM(t2.unit_amount * (t2.warehousing_number - COALESCE(t3.outbound_count, 0))) as allTotalPrice, t3.outbound_count, COALESCE(sum(t3.outbound_count), 0) as outNum,t4.create_time as createTime1 from t_erp_goods t1 left join t_erp_clinic_warehousing_batch t2 on t1.id = t2.goods_id left join t_erp_clinic_warehousing t4 on t2.warehousing_id = t4.id left join t_erp_clinic_outbound_goods t3 on t2.id = t3.warehousing_id left join t_erp_clinic_warehousing t4 on t2.warehousing_id = t4.id left join ( select warehousing_batch_id, sum(outbound_count) as outbound_count from t_erp_clinic_outbound_goods group by warehousing_batch_id ) t3 on t2.id = t3.warehousing_batch_id where t1.disabled = 0 and t2.id is not null <if test="query.goodsName != null and query.goodsName != ''"> and t1.goods_name like concat('%',#{query.goodsName},'%') ruoyi-system/src/main/resources/mapper/system/TErpGoodsMapper.xml
@@ -278,7 +278,7 @@ select * from ( SELECT t1.id,t2.warehouse_no, t3.goods_name, t4.supplier_name, case t3.goods_source when 1 then t4.supplier_name when 2 then t3.supplier_name end as supplierName, t3.type_id, t3.packing_unit_id, t3.quasi_number, @@ -294,19 +294,19 @@ LEFT JOIN t_erp_clinic_warehousing t2 on t1.warehousing_id = t2.id LEFT JOIN t_erp_goods t3 on t1.goods_id = t3.id LEFT JOIN t_crm_supplier t4 on t3.supplier_clinic_id = t4.id LEFT JOIN t_erp_supplier_outbound_goods t5 on t5.warehousing_batch_id =t1.id LEFT JOIN t_erp_clinic_outbound_goods t5 on t5.warehousing_batch_id =t1.id where t2.disabled = 0 and #{endDate} > t1.expiry_date <if test="user.roleType !=null and user.roleType ==4"> and t3.supplier_clinic_id =#{supplierClinicId} and t3.goods_source=1 and t3.supplier_clinic_id =#{supplierClinicId} </if> <if test="user.roleType !=null and user.roleType ==5"> and t3.supplier_clinic_id =#{supplierClinicId} and t3.goods_source=2 and t3.supplier_clinic_id =#{supplierClinicId} </if> GROUP BY t1.id ) as o where (o.warehousing_number -o.outbound_count) >0 where o.num >0 order by o.create_time desc </select> <select id="getGoodsById" resultType="com.ruoyi.system.model.TErpGoods"> ruoyi-system/src/main/resources/mapper/system/TSysOrderMapper.xml
@@ -26,6 +26,7 @@ <include refid="Base_Column_List"/> from t_sys_order where app_user_id = #{appUserId} and disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} order by create_time desc </select>