ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpSupplierWarehousingController.java
@@ -26,6 +26,7 @@ import javax.validation.Valid; import java.util.List; import java.util.stream.Collectors; /** * <p> @@ -158,6 +159,16 @@ SysUser user = tokenService.getLoginUser().getUser(); return R.ok(erpGoodsService.pageInventoryGoodsPageList(query,user)); } @ApiOperation(value = "有效期预警商品选择") @GetMapping(value = "/pageInventoryGoodsList") public R<List<TErpGoodsInventoryVO>> pageInventoryGoodsList(@RequestParam String warehouseId,@RequestParam(required = false)String batchNumber) { SysUser user = tokenService.getLoginUser().getUser(); List<TErpGoodsInventoryVO> tErpGoodsInventoryVOS = erpGoodsService.pageInventoryGoodsList(warehouseId, user); if(batchNumber!=null && !"".equals(batchNumber)){ tErpGoodsInventoryVOS = tErpGoodsInventoryVOS.stream().filter(e->e.getBatchNumber().equals(batchNumber)).collect(Collectors.toList()); } return R.ok(tErpGoodsInventoryVOS); } @ApiOperation(value = "供应商 确认盘点") @PostMapping(value = "/inventoryGoods") ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysOrderController.java
@@ -125,6 +125,8 @@ String outTradeNo = time + nonce; String amount = String.valueOf(erpProcurement.getPayMoney().multiply(new BigDecimal("100")).intValue()); TCrmSupplier supplier = crmSupplierService.getById(erpProcurement.getSupplierId()); String apiPath = "sit/api/v3/labs/trans/preorder"; String body = "{\n" + @@ -132,8 +134,8 @@ "\t\"version\": \"3.0\",\n" + "\t\"req_data\": {\n" + "\t\t\"out_trade_no\": \"" + outTradeNo + "\",\n" + "\t\t\"merchant_no\": \"822290059430BF9\",\n" + "\t\t\"term_no\": \"A9358698\",\n" + "\t\t\"merchant_no\": \""+supplier.getRecvMerchantNo()+"\",\n" + "\t\t\"term_no\": \""+supplier.getTermNo()+"\",\n" + "\t\t\"notify_url\": \"http://221.182.45.100:8089/t-sys-order/messageHandle\",\n" + "\t\t\"location_info\": {\n" + "\t\t\t\"request_ip\": \"" + ipAddr + "\"\n" + @@ -160,7 +162,7 @@ String code = jsonObject1.getString("log_no"); erpProcurement.setPayTransactionId(code); erpProcurement.setStatus(2); erpProcurement.setTermNo("A9358698"); erpProcurement.setTermNo(supplier.getTermNo()); erpProcurement.setAccountType(type); erpProcurement.setTransType("41"); erpProcurementService.updateById(erpProcurement); @@ -219,7 +221,7 @@ HashMap<String, Object> map = new HashMap<>(); map.put("merchant_no", "822290059430BF9"); map.put("merchant_no", erpProcurement.getMerchantNo()); map.put("log_no", erpProcurement.getPayTransactionId()); map.put("log_date", DateUtils.dateTime()); map.put("notify_url", "http://221.182.45.100:8089/t-sys-order/messageSeparateHandle"); @@ -233,8 +235,11 @@ String outTradeNo = time + str; map.put("out_separate_no", outTradeNo); map.put("total_amt", erpProcurement.getPayMoney().multiply(BigDecimal.valueOf(100)).intValue() + ""); // 平台应得分账 BigDecimal allMoney = erpProcurement.getPayMoney(); // 平台应得分账 BigDecimal payMoney = erpProcurement.getPayMoney(); ArrayList<HashMap<String, Object>> objects = new ArrayList<>(); // 根据供应商id分组 @@ -248,10 +253,11 @@ payMoney = payMoney.subtract(reduce); map1.put("recv_no", supplier.getRecvMerchantNo()); map1.put("separate_value", reduce.multiply(BigDecimal.valueOf(100)).intValue() + ""); objects.add(map1); // objects.add(map1); } HashMap<String, Object> map1 = new HashMap<>(); map1.put("recv_merchant_no", "822641048160MMJ"); //TODO hzt map1.put("recv_no", "822641048160MMJ"); // 手续费 BigDecimal bigDecimal = allMoney.multiply(new BigDecimal("0.038")).setScale(2, RoundingMode.HALF_UP); payMoney = payMoney.subtract(bigDecimal); @@ -345,7 +351,7 @@ "\t\"req_time\": \"" + time + "\",\n" + "\t\"version\": \"3.0\",\n" + "\t\"req_data\": {\n" + "\t\t\"merchant_no\": \"822290059430BF9\",\n" + "\t\t\"merchant_no\": \""+erpProcurement.getMerchantNo()+"\",\n" + "\t\t\"term_no\": \""+erpProcurement.getTermNo()+"\",\n" + "\t\t\"refund_amount\": " + refund_amount + ",\n" + "\t\t\"out_trade_no\": \"" + outTradeNo + "\",\n" + @@ -444,30 +450,28 @@ HashMap<String, Object> map = new HashMap<>(); map.put("merchant_no", "822290059430BF9"); map.put("merchant_no", erpProcurement.getMerchantNo()); map.put("origin_separate_no", erpProcurement.getSeparateNo()); map.put("out_separate_no",outTradeNo); erpProcurement.setRefundOutSeparateNo(outTradeNo); erpProcurementService.updateById(erpProcurement); List<TErpProcurementGoods> list = erpProcurementGoodsService.list(new LambdaQueryWrapper<TErpProcurementGoods>().eq(TErpProcurementGoods::getProcurementId, erpProcurement.getId())); // List<TErpProcurementGoods> list = erpProcurementGoodsService.list(new LambdaQueryWrapper<TErpProcurementGoods>().eq(TErpProcurementGoods::getProcurementId, erpProcurement.getId())); // 根据供应商id分组 Map<String, List<TErpProcurementGoods>> collect = list.stream().collect(Collectors.groupingBy(TErpProcurementGoods::getSupplierId)); // Map<String, List<TErpProcurementGoods>> collect = list.stream().collect(Collectors.groupingBy(TErpProcurementGoods::getSupplierId)); ArrayList<HashMap<String, Object>> objects = new ArrayList<>(); BigDecimal allMoney = list.stream().map(TErpProcurementGoods::getSupplierMoney).reduce(BigDecimal.ZERO, BigDecimal::add); for (Map.Entry<String, List<TErpProcurementGoods>> entry : collect.entrySet()) { // BigDecimal allMoney = list.stream().map(TErpProcurementGoods::getSupplierMoney).reduce(BigDecimal.ZERO, BigDecimal::add); // for (Map.Entry<String, List<TErpProcurementGoods>> entry : collect.entrySet()) { // // List<TErpProcurementGoods> value = entry.getValue(); // BigDecimal reduce = value.stream().map(TErpProcurementGoods::getSupplierMoney).reduce(BigDecimal.ZERO, BigDecimal::add); // String recv_no = value.stream().map(TErpProcurementGoods::getRecvNo).collect(Collectors.toList()).get(0); // } HashMap<String, Object> map1 = new HashMap<>(); List<TErpProcurementGoods> value = entry.getValue(); BigDecimal reduce = value.stream().map(TErpProcurementGoods::getSupplierMoney).reduce(BigDecimal.ZERO, BigDecimal::add); String recv_no = value.stream().map(TErpProcurementGoods::getRecvNo).collect(Collectors.toList()).get(0); map1.put("recv_no", recv_no); map1.put("amt", reduce.multiply(BigDecimal.valueOf(100)).intValue() + ""); // TODO hzt map1.put("recv_no", "dsadasda"); map1.put("amt", erpProcurement.getMoney().multiply(BigDecimal.valueOf(100)).intValue() + ""); objects.add(map1); } BigDecimal add = allMoney.add(erpProcurement.getMoney()).multiply(BigDecimal.valueOf(100)); map.put("total_amt",add); map.put("total_amt",erpProcurement.getMoney().multiply(BigDecimal.valueOf(100)).intValue() + ""); map.put("origin_recv_datas",objects); reqMap.put("req_data", map); ruoyi-system/src/main/java/com/ruoyi/system/mapper/TErpGoodsMapper.java
@@ -28,4 +28,7 @@ List<TErpGoodsVO> listExport(@Param("query") TErpGoodsQuery query, @Param("user") SysUser user); List<TErpGoodsInventoryVO> pageInventoryGoodsPageList(@Param("query") TErpGoodsInventoryQuery query, @Param("pageInfo") PageInfo<TErpGoodsInventoryVO> pageInfo, @Param("user") SysUser user, @Param("supplierClinicId") String supplierClinicId, @Param("time") Date time); List<TErpGoodsInventoryVO> pageInventoryGoodsList(@Param("warehouseId") String warehouseId, @Param("user") SysUser user, @Param("supplierClinicId") String supplierClinicId, @Param("endDate") Date endDate); } ruoyi-system/src/main/java/com/ruoyi/system/model/TCrmSupplier.java
@@ -72,5 +72,9 @@ @TableField("recv_merchant_no") private String recvMerchantNo; @ApiModelProperty(value = "终端号") @TableField("term_no") private String termNo; } ruoyi-system/src/main/java/com/ruoyi/system/model/TErpProcurement.java
@@ -113,4 +113,13 @@ @TableField("refund_status") private Integer refundStatus; @ApiModelProperty(value = "供应商id") @TableField("supplier_id") private String supplierId; @ApiModelProperty(value = "商户号") @TableField("merchant_no") private String merchantNo; } ruoyi-system/src/main/java/com/ruoyi/system/service/TErpGoodsService.java
@@ -49,4 +49,7 @@ void inventoryGoods(InventoryDto dto, SysUser user); List<TErpGoodsInventoryVO> pageInventoryGoodsList(@Valid String warehouseId, SysUser user); } ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java
@@ -174,6 +174,49 @@ pageInfo.setRecords(list); return pageInfo; } @Override public List<TErpGoodsInventoryVO> pageInventoryGoodsList(String warehouseId, SysUser user) { Integer roleType = user.getRoleType(); String supplierClinicId = null; if(roleType == 4){ // 供应商 TCrmSupplier crmSupplier = crmSupplierMapper.selectOne(Wrappers.lambdaQuery(TCrmSupplier.class) .eq(TCrmSupplier::getUserId, user.getUserId()) .last("LIMIT 1")); supplierClinicId =crmSupplier.getId(); } if(roleType == 5){ // 诊所 TCrmClinic crmClinic = crmClinicMapper.selectOne(Wrappers.lambdaQuery(TCrmClinic.class) .eq(TCrmClinic::getUserId, user.getUserId()) .last("LIMIT 1")); supplierClinicId =crmClinic.getId(); } // 当前时间一个月后 Date endDate = DateUtils.addMonths(DateUtils.getNowDate(), 1); List<TErpGoodsInventoryVO> list = this.baseMapper.pageInventoryGoodsList(warehouseId, user,supplierClinicId,endDate); if (list.isEmpty()) { return list; } List<String> typeIds = list.stream().map(TErpGoodsInventoryVO::getTypeId).collect(Collectors.toList()); if (!typeIds.isEmpty()) { List<TErpGoodsType> typeList = erpGoodsTypeMapper.selectBatchIds(typeIds); for (TErpGoodsInventoryVO tErpGoodsVO : list) { typeList.stream().filter(t -> t.getId().equals(tErpGoodsVO.getTypeId())).findFirst().ifPresent(t -> tErpGoodsVO.setTypeName(t.getTypeName())); tErpGoodsVO.setTypeName(tErpGoodsVO.getTypeName()); } } List<String> packingUnitId = list.stream().map(TErpGoodsInventoryVO::getPackingUnitId).collect(Collectors.toList()); if (!packingUnitId.isEmpty()) { List<TErpGoodsUnit> tErpGoodsUnits = erpGoodsUnitMapper.selectBatchIds(packingUnitId); for (TErpGoodsInventoryVO tErpGoodsVO : list) { tErpGoodsUnits.stream().filter(t -> t.getId().equals(tErpGoodsVO.getPackingUnitId())).findFirst().ifPresent(t -> tErpGoodsVO.setPackingUnitName(t.getUnitName())); } } return list; } @Override public void inventoryGoods(InventoryDto dto, SysUser user) { ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpSupplierWarehousingServiceImpl.java
@@ -89,6 +89,8 @@ 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); @@ -173,6 +175,7 @@ } tErpGoodsWarehouseLastVO.setAllNum(tErpGoodsWarehouseVOS.stream().mapToInt(TErpGoodsWarehouseVO::getNowNum).sum()); tErpGoodsWarehouseLastVO.setAllTotalPrice(tErpGoodsWarehouseVOS.stream().mapToDouble(TErpGoodsWarehouseVO::getUnitAmount).sum()); tErpGoodsWarehouseLastVO.setAllTotalPrice(BigDecimal.valueOf(tErpGoodsWarehouseLastVO.getAllTotalPrice()).setScale(2,RoundingMode.HALF_UP).doubleValue()); tErpGoodsWarehouseLastVO.setList(tErpGoodsWarehouseVOS); tErpGoodsWarehouseLastVO.setWarningInventory(goods.getWarningInventory()); tErpGoodsWarehouseLastVOS.add(tErpGoodsWarehouseLastVO); @@ -277,11 +280,14 @@ tErpSupplierWarehousing.setGoodsId(dto.getGoodsId()); TErpGoods goods = erpGoodsMapper.selectById(dto.getGoodsId()); tErpSupplierWarehousing.setGoodsName(goods.getGoodsName()); tErpSupplierWarehousing.setGoodsCount(tErpSupplierWarehousing.getGoodsCount()); tErpSupplierWarehousing.setUnitAmount(tErpSupplierWarehousing.getUnitAmount()); tErpSupplierWarehousing.setTotalPrice(tErpSupplierWarehousing.getTotalPrice()); erpSupplierWarehousingMapper.insert(tErpSupplierWarehousing); tErpSupplierWarehousing.setGoodsCount(dto.getWarehousingNum()); tErpSupplierWarehousing.setUnitAmount(dto.getPrice()); tErpSupplierWarehousing.setTotalPrice(dto.getTotalPrice()); List<WarehousingGoodsNextDto> warehousingGoodsNextDtos = dto.getWarehousingGoodsNextDtos(); int sum = warehousingGoodsNextDtos.stream().mapToInt(WarehousingGoodsNextDto::getWarehousingNum).sum(); tErpSupplierWarehousing.setGoodsCount( sum); erpSupplierWarehousingMapper.insert(tErpSupplierWarehousing); for (WarehousingGoodsNextDto warehousingGoodsNextDto : warehousingGoodsNextDtos) { TErpSupplierWarehousingBatch tErpSupplierWarehousingBatch = new TErpSupplierWarehousingBatch(); tErpSupplierWarehousingBatch.setWarehousingId(tErpSupplierWarehousing.getId()); @@ -503,11 +509,11 @@ throw new ServiceException("批次号:"+tErpSupplierWarehousingBatch.getBatchNumber()+"库存不足"); } TErpSupplierWarehousing tErpSupplierWarehousing = erpSupplierWarehousingMapper.selectById(tErpSupplierWarehousingBatch.getWarehousingId()); TErpGoods goods = erpGoodsMapper.selectById(tErpSupplierWarehousing.getGoodsId()); BigDecimal multiply = goods.getSalesAmount().multiply(BigDecimal.valueOf(outboundGoodsNextDto.getNum())); // TErpGoods goods = erpGoodsMapper.selectById(tErpSupplierWarehousing.getGoodsId()); BigDecimal multiply = tErpSupplierWarehousing.getUnitAmount().multiply(BigDecimal.valueOf(outboundGoodsNextDto.getNum())); TErpSupplierOutboundGoods tErpSupplierOutboundGoods1 = new TErpSupplierOutboundGoods(); tErpSupplierOutboundGoods1.setWarehousingId(dto.getWarehouseId()); tErpSupplierOutboundGoods1.setWarehousingId(tErpSupplierWarehousing.getId()); tErpSupplierOutboundGoods1.setWarehousingBatchId(outboundGoodsNextDto.getBatchId()); tErpSupplierOutboundGoods1.setOutboundCount(outboundGoodsNextDto.getNum()); tErpSupplierOutboundGoods1.setTotalPrice(multiply); ruoyi-system/src/main/java/com/ruoyi/system/vo/TErpGoodsWarehouseVO.java
@@ -1,5 +1,6 @@ package com.ruoyi.system.vo; import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.system.model.TErpGoods; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -22,9 +23,11 @@ private String batchNumber; @ApiModelProperty(value = "生产日期") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") private LocalDateTime productionDate; @ApiModelProperty(value = "失效日期") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") private LocalDateTime expiryDate; @ApiModelProperty(value = "单价") ruoyi-system/src/main/java/com/ruoyi/system/vo/ValidityPeriodWarningVo.java
@@ -13,6 +13,10 @@ @ApiModel(value = "有效期预警Vo") public class ValidityPeriodWarningVo { @ApiModelProperty(value = "仓库id") private String warehouseId; @ApiModelProperty(value = "入库单号") private String warehousingNo; ruoyi-system/src/main/resources/mapper/system/TErpGoodsMapper.xml
@@ -123,7 +123,7 @@ t1.warehousing_number, t2.create_time, t1.warehousing_number - coalesce(sum(t5.outbound_count),0) as num, t3.sales_amount, t2.unit_amount as sales_amount, t1.expiry_date from t_erp_supplier_warehousing_batch t1 LEFT JOIN t_erp_supplier_warehousing t2 on t1.warehousing_id = t2.id @@ -159,6 +159,42 @@ <if test="query.warehouseNo != null and query.warehouseNo != ''"> and t2.warehouse_no = #{query.warehouseNo} </if> GROUP BY t1.id ) as o where (o.warehousing_number -o.outbound_count) >0 order by o.create_time desc </select> <select id="pageInventoryGoodsList" resultType="com.ruoyi.system.vo.TErpGoodsInventoryVO"> select * from ( SELECT t1.id,t2.warehouse_no, t3.goods_name, t4.supplier_name, t3.type_id, t3.packing_unit_id, t3.quasi_number, t3.goods_id_code, t1.batch_number, coalesce(sum(t5.outbound_count),0) as outbound_count, t1.warehousing_number, t2.create_time, t1.warehousing_number - coalesce(sum(t5.outbound_count),0) as num, t2.unit_amount as sales_amount, t1.expiry_date from t_erp_supplier_warehousing_batch t1 LEFT JOIN t_erp_supplier_warehousing t2 on t1.warehousing_id = t2.id LEFT JOIN t_erp_goods t3 on t2.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 where t2.disabled = 0 and t2.warehouse_id = #{warehouseId} and #{time} > t1.expiry_date <if test="user.roleType !=null and user.roleType ==4"> and t3.supplier_clinic_id =#{supplierClinicId} and t3.goods_source=1 </if> <if test="user.roleType !=null and user.roleType ==5"> and t3.supplier_clinic_id =#{supplierClinicId} and t3.goods_source=2 </if> GROUP BY t1.id ) as o where (o.warehousing_number -o.outbound_count) >0 order by o.create_time desc ruoyi-system/src/main/resources/mapper/system/TErpMaintenanceReminderMapper.xml
@@ -38,10 +38,10 @@ left join t_erp_goods t4 on t3.goods_id = t4.id where t1.disabled = 0 and #{tomorrow} >= t1.maintenance_time <if test="user.roleType !=null and user.roleType==4"> and t1.clinic_supplier_id = #{user.supplierClinicId} and t1.maintenance_type=1 and t1.clinic_supplier_id = #{supplierClinicId} and t1.maintenance_type=1 </if> <if test="user.roleType !=null and user.roleType==5"> and t1.clinic_supplier_id = #{user.supplierClinicId} and t1.maintenance_type=2 and t1.clinic_supplier_id = #{supplierClinicId} and t1.maintenance_type=2 </if> <if test="query.warehouseNo != null and query.warehouseNo != ''"> and t3.warehouse_no =#{query.warehouseNo} ruoyi-system/src/main/resources/mapper/system/TErpSupplierWarehousingMapper.xml
@@ -31,11 +31,12 @@ 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, SUM(t2.unit_amount * (t2.goods_count - COALESCE(t3.outbound_count, 0))) as allTotalPrice, COALESCE(sum(t3.outbound_count), 0) as outNum from t_erp_supplier_warehousing t2 left join t_erp_goods t1 on t1.id = t2.goods_id 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 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},'%') </if> @@ -57,7 +58,7 @@ <if test="user.roleType != null and user.roleType == 5 "> and t1.goods_source =2 and t1.supplier_clinic_id =#{query.supplierClinicId} </if> GROUP BY t2.id GROUP BY t1.id ) o where 1=1 <if test="query.type != null and query.type ==1"> and o.warning_inventory > (o.allNum-o.outNum) @@ -107,7 +108,7 @@ <select id="validityPeriodWarning" resultType="com.ruoyi.system.vo.ValidityPeriodWarningVo"> select t2.warehouse_no, t4.goods_name, t4.quasi_number, t1.batch_number, t1.expiry_date, t4.id as goodsId,t5.type_name,t6.unit_name packingUnitName, select t2.warehouse_id,t2.warehouse_no warehousingNo, t4.goods_name, t4.quasi_number, t1.batch_number, 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