| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation(value = "删除采购") |
| | | @DeleteMapping(value = "/delProcurement/{id}") |
| | | public R<String> delProcurement(@PathVariable String id) { |
| | | SysUser user = tokenService.getLoginUser().getUser(); |
| | | Integer roleType = user.getRoleType(); |
| | | String clinicSupplierId=null; |
| | | if(roleType == 5){ |
| | | // 诊所 |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | clinicSupplierId = crmClinic.getId(); |
| | | } |
| | | TErpProcurement tErpProcurement = erpProcurementService.getById(id); |
| | | if(tErpProcurement.getClinicId().equals(clinicSupplierId)){ |
| | | erpProcurementService.removeById( id); |
| | | return R.ok(); |
| | | }else { |
| | | return R.fail("无权限"); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | |
| | | @Resource |
| | | private TCrmClinicMapper crmClinicMapper; |
| | | |
| | | |
| | | @Resource |
| | | private TErpClinicInventoryGoodsMapper erpClinicInventoryGoodsMapper; |
| | | |
| | |
| | | tErpGoodsVO.setTypeName(tErpGoodsVO.getTypeName()); |
| | | } |
| | | } |
| | | List<String> unitIds = list.stream().map(TErpGoods::getPackingUnitId).collect(Collectors.toList()); |
| | | if (!unitIds.isEmpty()) { |
| | | List<TErpGoodsUnit> unitList = erpGoodsUnitMapper.selectBatchIds(unitIds); |
| | | for (TErpGoodsVO tErpGoodsVO : list) { |
| | | unitList.stream().filter(t -> t.getId().equals(tErpGoodsVO.getPackingUnitId())).findFirst().ifPresent(t -> tErpGoodsVO.setPackingUnitName(t.getUnitName())); |
| | | } |
| | | } |
| | | List<String> supplierIds = list.stream().map(TErpGoods::getSupplierClinicId).collect(Collectors.toList()); |
| | | if (!supplierIds.isEmpty()) { |
| | | List<TCrmSupplier> supplierClinicList = crmSupplierMapper.selectBatchIds(supplierIds); |
| | | for (TErpGoodsVO tErpGoodsVO : list) { |
| | | supplierClinicList.stream().filter(t -> tErpGoodsVO.getGoodsSource()==1 && t.getId().equals(tErpGoodsVO.getSupplierClinicId())).findFirst().ifPresent(t -> tErpGoodsVO.setSupplierName(t.getSupplierName())); |
| | | } |
| | | } |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | |
| | | List<TErpClinicOutboundGoods> tErpClinicOutboundGoods2 = erpClinicOutboundGoodsMapper.selectList(new LambdaQueryWrapper<TErpClinicOutboundGoods>().eq(TErpClinicOutboundGoods::getWarehousingBatchId, outboundGoods.getWarehousingBatchId())); |
| | | int sum = tErpClinicOutboundGoods2.stream().mapToInt(TErpClinicOutboundGoods::getOutboundCount).sum(); |
| | | |
| | | int count = tErpClinicWarehousingBatch.getPurchaseCount() - sum; |
| | | int count = tErpClinicWarehousingBatch.getWarehousingNumber() - sum; |
| | | outboundGoodsDetailNextVo.setSurplusCount(count); |
| | | |
| | | outboundGoodsDetailNextVo.setUnitAmount(tErpClinicWarehousingBatch.getUnitAmount()); |
| | | if(outboundGoodsDetailNextVo.getUnitAmount()==null){ |
| | | outboundGoodsDetailNextVo.setUnitAmount(tErpClinicWarehousingBatch.getSalesAmount()); |
| | | } |
| | | outboundGoodsDetailNextVo.setOutboundCount(outboundGoods.getOutboundCount()); |
| | | outboundGoodsDetailNextVo.setExpiryDate(tErpClinicWarehousingBatch.getExpiryDate()); |
| | | outboundGoodsDetailNextVo.setTotalAmount(outboundGoodsDetailNextVo.getUnitAmount().multiply(new BigDecimal(outboundGoods.getOutboundCount()))); |
| | |
| | | </select> |
| | | |
| | | <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, |
| | | 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,t1.supplier_name, |
| | | </sql> |
| | | <select id="pageList" resultType="com.ruoyi.system.vo.TErpGoodsVO"> |
| | | select * from ( |
| | | select <include refid="Base_Column_List1"/> |
| | | 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, |
| | | SUM(t2.sales_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_crm_supplier t4 on t3.supplier_clinic_id = t4.id |
| | | left join ( |
| | | select warehousing_batch_id, sum(outbound_count) as outbound_count |
| | | from t_erp_supplier_outbound_goods |
| | | from t_erp_clinic_outbound_goods |
| | | group by warehousing_batch_id |
| | | ) t5 on t5.warehousing_batch_id =t1.id |
| | | where t2.disabled = 0 and t2.clinic_id =#{supplierClinicId} |