ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpProcurementController.java
@@ -11,6 +11,7 @@ import com.ruoyi.common.utils.DateUtils; import com.ruoyi.framework.web.service.TokenService; import com.ruoyi.system.dto.AddProcurementDto; import com.ruoyi.system.dto.DetailProcurementSendDto; import com.ruoyi.system.dto.UpdateStatusProcurementDto; import com.ruoyi.system.dto.UpdateStatusProcurementLastDto; import com.ruoyi.system.model.*; @@ -63,13 +64,14 @@ private final TCrmBranchService crmBranchService; private final TCrmSalespersonService crmSalespersonService; private final TErpProcurementCommissionService erpProcurementCommissionService; private final TCrmWarehouseService crmWarehouseService; @Autowired public TErpProcurementController(TErpProcurementService erpProcurementService, TokenService tokenService, TCrmClinicService crmClinicService, TErpProcurementGoodsService erpProcurementGoodsService , TErpGoodsService erpGoodsService, TErpClinicWarehousingService erpClinicWarehousingService, TErpClinicWarehousingBatchService erpClinicWarehousingBatchService, TCrmSupplierService crmSupplierService, TErpMaintenanceReminderService erpMaintenanceReminderService, TSysOtherConfigService sysOtherConfigService, TCrmClinicPointsService crmClinicPointsService, TCrmChangePointsService crmChangePointsService, TCrmBranchService crmBranchService, TCrmSalespersonService crmSalespersonService, TErpProcurementCommissionService erpProcurementCommissionService) { TCrmSupplierService crmSupplierService, TErpMaintenanceReminderService erpMaintenanceReminderService, TSysOtherConfigService sysOtherConfigService, TCrmClinicPointsService crmClinicPointsService, TCrmChangePointsService crmChangePointsService, TCrmBranchService crmBranchService, TCrmSalespersonService crmSalespersonService, TErpProcurementCommissionService erpProcurementCommissionService, TCrmWarehouseService crmWarehouseService) { this.erpProcurementService = erpProcurementService; this.tokenService = tokenService; this.crmClinicService = crmClinicService; @@ -85,6 +87,8 @@ this.crmBranchService = crmBranchService; this.crmSalespersonService = crmSalespersonService; this.erpProcurementCommissionService = erpProcurementCommissionService; this.crmWarehouseService = crmWarehouseService; } @@ -184,19 +188,24 @@ @ApiOperation(value = "采购详情--发货(仓库角色)") @PostMapping(value = "/detailProcurementSend/{id}") public R<?> detailProcurementSend(@PathVariable String id) { @PostMapping(value = "/detailProcurementSend") public R<?> detailProcurementSend(@RequestBody DetailProcurementSendDto dto) { SysUser user = tokenService.getLoginUser().getUser(); Integer roleType = user.getRoleType(); String clinicSupplierId=null; if(roleType == 4){ if(roleType == 6){ TCrmWarehouse warehouse = crmWarehouseService.getOne(Wrappers.lambdaQuery(TCrmWarehouse.class) .eq(TCrmWarehouse::getUserId, user.getUserId()) .last("LIMIT 1")); // 供应商 TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class) .eq(TCrmSupplier::getUserId, user.getUserId()) .eq(TCrmSupplier::getWarehouseId, warehouse.getId()) .last("LIMIT 1")); clinicSupplierId=crmSupplier.getId(); } erpProcurementService.detailProcurementSend(clinicSupplierId, user, id); erpProcurementService.detailProcurementSend(clinicSupplierId, user, dto.getId(),dto.getLogisticsNumber()); return R.ok(); } ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TOrderController.java
@@ -447,6 +447,11 @@ // 先退分账 在退订单 // 查出采购单 算出价格 下单 算出应该分佣金额 应该分给谁 TErpProcurement erpProcurement = erpProcurementService.getById(id); if(erpProcurement.getStatus()==2){ erpProcurement.setStatus(6); erpProcurementService.updateById(erpProcurement); return R.ok("操作成功"); } // 还未分账成功不能退款 if(erpProcurement.getStatus()==null || erpProcurement.getStatus()!=1){ ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysGoodsController.java
@@ -6,17 +6,21 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.basic.PageInfo; import com.ruoyi.common.core.domain.BaseModel; import com.ruoyi.common.core.domain.BasePage; 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.dto.ExchangeGoodsDto; import com.ruoyi.system.dto.TErpGoodsUpdateStatusDto; import com.ruoyi.system.model.*; import com.ruoyi.system.query.ExchangeGoodsRecordQuery; import com.ruoyi.system.query.TSysGoodsExchangeQuery; import com.ruoyi.system.query.TSysGoodsQuery; import com.ruoyi.system.service.*; import com.ruoyi.system.vo.ExchangeGoodsRecordDetailVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -46,16 +50,19 @@ private final TSysGoodsExchangeService sysGoodsExchangeService; private final TCrmClinicService crmClinicService; private final TCrmClinicPointsService crmClinicPointsService; private final TCrmChangePointsService crmChangePointsService; @Autowired public TSysGoodsController(TokenService tokenService, TSysGoodsService sysGoodsService, TCrmSupplierService crmSupplierService, TSysGoodsExchangeService sysGoodsExchangeService, TCrmClinicService crmClinicService, TCrmClinicPointsService crmClinicPointsService) { public TSysGoodsController(TokenService tokenService, TSysGoodsService sysGoodsService, TCrmSupplierService crmSupplierService, TSysGoodsExchangeService sysGoodsExchangeService, TCrmClinicService crmClinicService, TCrmClinicPointsService crmClinicPointsService, TCrmChangePointsService crmChangePointsService) { this.sysGoodsService = sysGoodsService; this.tokenService = tokenService; this.crmSupplierService = crmSupplierService; this.sysGoodsExchangeService = sysGoodsExchangeService; this.crmClinicService = crmClinicService; this.crmClinicPointsService = crmClinicPointsService; this.crmChangePointsService = crmChangePointsService; } @@ -227,7 +234,7 @@ public R<HashMap<String, Object>> pageListClinic(@RequestBody TSysGoodsQuery query) { PageInfo<TSysGoods> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); LambdaQueryWrapper<TSysGoods> tSysGoodsLambdaQueryWrapper = new LambdaQueryWrapper<>(); tSysGoodsLambdaQueryWrapper.eq(TSysGoods::getStatus,1); tSysGoodsLambdaQueryWrapper.eq(TSysGoods::getStatus, 1); if (query.getGoodsName() != null && !query.getGoodsName().isEmpty()) { tSysGoodsLambdaQueryWrapper.like(TSysGoods::getGoodsName, query.getGoodsName()); } @@ -244,19 +251,19 @@ } pageInfo.setRecords(records); HashMap<String, Object> map = new HashMap<>(); map.put("data",pageInfo); map.put("data", pageInfo); // 获取我的可用积分 map.put("total",sysGoodsService.count(tSysGoodsLambdaQueryWrapper)); map.put("total", sysGoodsService.count(tSysGoodsLambdaQueryWrapper)); SysUser user = tokenService.getLoginUser().getUser(); Integer roleType = user.getRoleType(); if(roleType == 5){ if (roleType == 5) { // 诊所 TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) .eq(TCrmClinic::getUserId, user.getUserId()) .last("LIMIT 1")); List<TCrmClinicPoints> list = crmClinicPointsService.list(new LambdaQueryWrapper<TCrmClinicPoints>().eq(TCrmClinicPoints::getClinicId, crmClinic.getId()).ge(TCrmClinicPoints::getExpireTime, new Date()).last(" and points > use_points")); map.put("myPoints",list.stream().mapToInt(item -> item.getPoints() - item.getUsePoints()).sum()); map.put("myPoints", list.stream().mapToInt(item -> item.getPoints() - item.getUsePoints()).sum()); } return R.ok(map); } @@ -267,7 +274,7 @@ @ApiOperation(value = "获取积分商品列表--详情") @GetMapping(value = "/detail/{id}") public R<TSysGoods> detail(@PathVariable String id) { TSysGoods goods= sysGoodsService.getById(id); TSysGoods goods = sysGoodsService.getById(id); return R.ok(goods); } @@ -280,7 +287,7 @@ public R<?> exchangeGoods(@RequestBody @Valid ExchangeGoodsDto dto) { SysUser user = tokenService.getLoginUser().getUser(); Integer roleType = user.getRoleType(); if(roleType == 5){ if (roleType == 5) { // 诊所 TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) .eq(TCrmClinic::getUserId, user.getUserId()) @@ -291,5 +298,86 @@ return R.fail("请选择正确的角色"); } /** * 兑换商品记录 */ @ApiOperation(value = "兑换商品记录--诊所") @PostMapping(value = "/exchangeGoodsRecord") public R<?> exchangeGoodsRecord(@RequestBody ExchangeGoodsRecordQuery query) { SysUser user = tokenService.getLoginUser().getUser(); Integer roleType = user.getRoleType(); if (roleType == 5) { // 诊所 TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) .eq(TCrmClinic::getUserId, user.getUserId()) .last("LIMIT 1")); LambdaQueryWrapper<TSysGoodsExchange> eq = new LambdaQueryWrapper<TSysGoodsExchange>().eq(TSysGoodsExchange::getClinicId, crmClinic.getId()); if (query.getName() != null && !query.getName().isEmpty()) { eq.like(TSysGoodsExchange::getGoodsName, query.getName()); } eq.orderByDesc(BaseModel::getCreateTime); PageInfo<TSysGoodsExchange> page = sysGoodsExchangeService.page(new PageInfo<>(query.getPageNum(), query.getPageSize()), eq); return R.ok(page); } return R.fail("请选择正确的角色"); } /** * 兑换商品记录 */ @ApiOperation(value = "兑换商品记录详情--诊所") @GetMapping(value = "/exchangeGoodsRecordDetail/{id}") public R<ExchangeGoodsRecordDetailVo> exchangeGoodsRecord(@PathVariable String id) { SysUser user = tokenService.getLoginUser().getUser(); Integer roleType = user.getRoleType(); if (roleType == 5) { // 诊所 TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) .eq(TCrmClinic::getUserId, user.getUserId()) .last("LIMIT 1")); TSysGoodsExchange exchangeServiceById = sysGoodsExchangeService.getById(id); if (exchangeServiceById.getClinicId().equals(crmClinic.getId())) { ExchangeGoodsRecordDetailVo vo = new ExchangeGoodsRecordDetailVo(); BeanUtils.copyProperties(exchangeServiceById, vo); String goodsId = vo.getGoodsId(); TSysGoods sysGoods = sysGoodsService.getById(goodsId); vo.setGoodsDetail(sysGoods.getGoodsDetail()); vo.setGoodsCover(sysGoods.getGoodsCover()); return R.ok(vo); } } return R.fail("请选择正确的角色"); } /** * 兑换商品记录 */ @ApiOperation(value = "积分变更记录--诊所") @PostMapping(value = "/pointsRecordDetail") public R<PageInfo<TCrmChangePoints>> pointsRecordDetail(@RequestBody BasePage page) { SysUser user = tokenService.getLoginUser().getUser(); Integer roleType = user.getRoleType(); if (roleType == 5) { // 诊所 TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) .eq(TCrmClinic::getUserId, user.getUserId()) .last("LIMIT 1")); PageInfo<TCrmChangePoints> page1 = crmChangePointsService.page(new PageInfo<>(page.getPageNum(), page.getPageSize()), new LambdaQueryWrapper<TCrmChangePoints>().eq(TCrmChangePoints::getBranchSalespersonId, crmClinic.getId()).eq(TCrmChangePoints::getUserType, 3).orderByDesc(BaseModel::getCreateTime)); return R.ok(page1); } return R.fail("请选择正确的角色"); } } ruoyi-system/src/main/java/com/ruoyi/system/dto/DetailProcurementSendDto.java
New file @@ -0,0 +1,19 @@ package com.ruoyi.system.dto; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotBlank; @Data @ApiModel("仓库发货dto") public class DetailProcurementSendDto { @ApiModelProperty("id") @NotBlank(message = "id不能为空") private String id; @ApiModelProperty("物流单号") @NotBlank(message = "物流单号不能为空") private String logisticsNumber; } ruoyi-system/src/main/java/com/ruoyi/system/model/TErpSupplierOutboundGoods.java
@@ -51,5 +51,8 @@ @TableField("total_price") private BigDecimal totalPrice; @ApiModelProperty(value = "采购商品id") @TableField("procurement_goods_id") private String procurementGoodsId; } ruoyi-system/src/main/java/com/ruoyi/system/model/TSysGoodsExchange.java
@@ -63,4 +63,8 @@ @TableField("logistics_number") private String logisticsNumber; @ApiModelProperty(value = "诊所id") @TableField("clinic_id") private String clinicId; } ruoyi-system/src/main/java/com/ruoyi/system/query/ExchangeGoodsRecordQuery.java
New file @@ -0,0 +1,11 @@ package com.ruoyi.system.query; import com.ruoyi.common.core.domain.BasePage; import io.swagger.annotations.ApiModel; import lombok.Data; @Data @ApiModel("诊所兑换记录Query") public class ExchangeGoodsRecordQuery extends BasePage { private String name; } ruoyi-system/src/main/java/com/ruoyi/system/service/TErpProcurementService.java
@@ -43,5 +43,5 @@ DetailProcurementVO detailProcurement(String clinicSupplierId, SysUser user, String id); void detailProcurementSend(String clinicSupplierId, SysUser user, String id); void detailProcurementSend(String clinicSupplierId, SysUser user, String id,String logisticsNumber); } ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpClinicWarehousingServiceImpl.java
@@ -80,30 +80,29 @@ public PageInfo<PageInventoryListVo> pageInventoryList(TErpInventoryQuery query, SysUser user) { Integer roleType = user.getRoleType(); String supplierClinicId = null; if(roleType == 5){ if (roleType == 5) { // 诊所 TCrmClinic crmClinic = crmClinicMapper.selectOne(Wrappers.lambdaQuery(TCrmClinic.class) .eq(TCrmClinic::getUserId, user.getUserId()) .last("LIMIT 1")); supplierClinicId =crmClinic.getId(); supplierClinicId = crmClinic.getId(); } String sTime=null; String eTime =null; if(query.getTime()!=null && !query.getTime().isEmpty()){ String sTime = null; String eTime = null; if (query.getTime() != null && !query.getTime().isEmpty()) { String[] split = query.getTime().split(" - "); sTime = split[0] + " 00:00:00"; eTime = split[1] + " 23:59:59"; } PageInfo<PageInventoryListVo> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); List<PageInventoryListVo> list = this.baseMapper.pageInventoryList(pageInfo,query,user,sTime,eTime,supplierClinicId); if(list.isEmpty()){ List<PageInventoryListVo> list = this.baseMapper.pageInventoryList(pageInfo, query, user, sTime, eTime, supplierClinicId); if (list.isEmpty()) { return pageInfo; } List<String> collect = list.stream().map(PageInventoryListVo::getId).collect(Collectors.toList()); List<TErpClinicInventoryGoods> tErpSupplierInventoryGoods = erpClinicInventoryGoodsMapper.selectList(new LambdaQueryWrapper<TErpClinicInventoryGoods>().in(TErpClinicInventoryGoods::getInventoryId,collect)); List<TErpClinicInventoryGoods> tErpSupplierInventoryGoods = erpClinicInventoryGoodsMapper.selectList(new LambdaQueryWrapper<TErpClinicInventoryGoods>().in(TErpClinicInventoryGoods::getInventoryId, collect)); for (PageInventoryListVo pageInventoryListVo : list) { // 盘盈 BigDecimal add = BigDecimal.ZERO; @@ -114,9 +113,9 @@ for (TErpClinicInventoryGoods tErpSupplierInventoryGoods1 : tErpSupplierInventoryGoodsList) { if(tErpSupplierInventoryGoods1!=null){ if (tErpSupplierInventoryGoods1 != null) { // 盘盈 查入库 if(tErpSupplierInventoryGoods1.getInventoryType()==1){ if (tErpSupplierInventoryGoods1.getInventoryType() == 1) { TErpClinicWarehousingBatch tErpSupplierWarehousing = erpClinicWarehousingBatchMapper.selectById(tErpSupplierInventoryGoods1.getWarehousingBatchId()); // List<TErpSupplierWarehousingBatch> tErpSupplierWarehousingBatches = erpSupplierWarehousingBatchMapper.selectList(new LambdaQueryWrapper<TErpSupplierWarehousingBatch>().eq(TErpSupplierWarehousingBatch::getWarehousingId, tErpSupplierWarehousing.getId())); // int sum = tErpSupplierWarehousingBatches.stream().mapToInt(TErpSupplierWarehousingBatch::getWarehousingNumber).sum(); @@ -125,7 +124,7 @@ int count = tErpSupplierInventoryGoods1.getInventoryCount() - tErpSupplierInventoryGoods1.getDamagedCount(); BigDecimal multiply = tErpSupplierWarehousing.getSalesAmount().multiply(new BigDecimal(count)); add = add.add(multiply); }else { } else { // 盘亏 查出库 TErpClinicOutbound tErpSupplierOutbound = erpClinicOutboundMapper.selectById(tErpSupplierInventoryGoods1.getWarehousingId()); @@ -161,20 +160,20 @@ ArrayList<InventoryDetailVo> inventoryDetailVos = new ArrayList<>(); List<TErpClinicInventoryGoods> tErpSupplierInventoryGoods = erpClinicInventoryGoodsMapper.selectList(new LambdaQueryWrapper<TErpClinicInventoryGoods>().eq(TErpClinicInventoryGoods::getInventoryId, id)); if(tErpSupplierInventoryGoods!=null && !tErpSupplierInventoryGoods.isEmpty()){ if (tErpSupplierInventoryGoods != null && !tErpSupplierInventoryGoods.isEmpty()) { for (TErpClinicInventoryGoods tErpSupplierInventoryGood : tErpSupplierInventoryGoods) { InventoryDetailVo inventoryDetailVo = new InventoryDetailVo(); if(tErpSupplierInventoryGood.getInventoryType()==1){ if (tErpSupplierInventoryGood.getInventoryType() == 1) { TErpClinicWarehousing tErpSupplierWarehousing = erpClinicWarehousingMapper.selectById(tErpSupplierInventoryGood.getWarehousingId()); String goodsId = tErpSupplierInventoryGood.getGoodsId(); TErpGoods goods = erpGoodsMapper.selectById(goodsId); if(goods.getGoodsSource()==1){ if (goods.getGoodsSource() == 1) { TCrmSupplier supplier = crmSupplierMapper.selectById(goods.getSupplierClinicId()); if(supplier!=null){ if (supplier != null) { inventoryDetailVo.setSupplierName(supplier.getSupplierName()); } }else { } else { inventoryDetailVo.setSupplierName(goods.getSupplierName()); } @@ -188,10 +187,10 @@ List<TErpClinicWarehousingBatch> tErpSupplierWarehousingBatches = erpClinicWarehousingBatchMapper.selectList(new LambdaQueryWrapper<TErpClinicWarehousingBatch>().eq(TErpClinicWarehousingBatch::getBatchNumber, tErpSupplierWarehousingBatch.getBatchNumber())); int sum = tErpSupplierWarehousingBatches.stream().mapToInt(TErpClinicWarehousingBatch::getWarehousingNumber).sum(); List<String> collect = tErpSupplierWarehousingBatches.stream().map(TErpClinicWarehousingBatch::getId).collect(Collectors.toList()); if(!collect.isEmpty()){ if (!collect.isEmpty()) { List<TErpClinicOutboundGoods> tErpSupplierOutboundGoods = erpClinicOutboundGoodsMapper.selectList(new LambdaQueryWrapper<TErpClinicOutboundGoods>().eq(TErpClinicOutboundGoods::getWarehousingBatchId, collect)); int sum1 = tErpSupplierOutboundGoods.stream().mapToInt(TErpClinicOutboundGoods::getOutboundCount).sum(); sum = sum-sum1; sum = sum - sum1; } // sum = 剩余库存 @@ -199,7 +198,7 @@ inventoryDetailVo.setInventoryCount(tErpSupplierInventoryGood.getInventoryCount()); inventoryDetailVo.setInventoryType(tErpSupplierInventoryGood.getInventoryType()); inventoryDetailVo.setDamagedCount(tErpSupplierInventoryGood.getDamagedCount()); }else { } else { TErpClinicOutbound tErpSupplierOutbound = erpClinicOutboundMapper.selectById(tErpSupplierInventoryGood.getWarehousingId()); List<TErpClinicOutboundGoods> tErpSupplierOutboundGoods = erpClinicOutboundGoodsMapper.selectList(new LambdaQueryWrapper<TErpClinicOutboundGoods>().eq(TErpClinicOutboundGoods::getOutboundId, tErpSupplierOutbound.getId())); for (TErpClinicOutboundGoods tErpSupplierOutboundGood : tErpSupplierOutboundGoods) { @@ -207,12 +206,12 @@ TErpClinicWarehousing tErpSupplierWarehousing = erpClinicWarehousingMapper.selectById(warehousingId); String goodsId = tErpSupplierInventoryGood.getGoodsId(); TErpGoods goods = erpGoodsMapper.selectById(goodsId); if(goods.getGoodsSource()==1){ if (goods.getGoodsSource() == 1) { TCrmSupplier supplier = crmSupplierMapper.selectById(goods.getSupplierClinicId()); if(supplier!=null){ if (supplier != null) { inventoryDetailVo.setSupplierName(supplier.getSupplierName()); } }else { } else { inventoryDetailVo.setSupplierName(goods.getSupplierName()); } @@ -229,10 +228,10 @@ List<TErpClinicWarehousingBatch> tErpSupplierWarehousingBatches = erpClinicWarehousingBatchMapper.selectList(new LambdaQueryWrapper<TErpClinicWarehousingBatch>().eq(TErpClinicWarehousingBatch::getId, outboundGoods.getWarehousingBatchId())); int sum = tErpSupplierWarehousingBatches.stream().mapToInt(TErpClinicWarehousingBatch::getWarehousingNumber).sum(); List<String> collect = tErpSupplierWarehousingBatches.stream().map(TErpClinicWarehousingBatch::getId).collect(Collectors.toList()); if(!collect.isEmpty()){ if (!collect.isEmpty()) { List<TErpClinicOutboundGoods> tErpSupplierOutboundGoods1 = erpClinicOutboundGoodsMapper.selectList(new LambdaQueryWrapper<TErpClinicOutboundGoods>().in(TErpClinicOutboundGoods::getWarehousingBatchId, collect)); int sum1 = tErpSupplierOutboundGoods1.stream().mapToInt(TErpClinicOutboundGoods::getOutboundCount).sum(); sum = sum-sum1; sum = sum - sum1; } // sum = 剩余库存 @@ -256,17 +255,16 @@ } @Override public PageInfo<ValidityPeriodWarningVo> validityPeriodWarning(ValidityPeriodWarningQuery query, SysUser user) { Integer roleType = user.getRoleType(); String supplierClinicId = null; if(roleType == 5){ if (roleType == 5) { // 诊所 TCrmClinic crmClinic = crmClinicMapper.selectOne(Wrappers.lambdaQuery(TCrmClinic.class) .eq(TCrmClinic::getUserId, user.getUserId()) .last("LIMIT 1")); supplierClinicId =crmClinic.getId(); supplierClinicId = crmClinic.getId(); } // 获取当前时间后9个月的时间 LocalDateTime nineMonthLater = LocalDateTime.now().plusMonths(9); @@ -274,21 +272,20 @@ PageInfo<ValidityPeriodWarningVo> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); return this.baseMapper.validityPeriodWarning(pageInfo,query,user,nineMonthLater,supplierClinicId); return this.baseMapper.validityPeriodWarning(pageInfo, query, user, nineMonthLater, supplierClinicId); } @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()){ 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()){ 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())); @@ -298,16 +295,17 @@ pageInfo.setRecords(list); return pageInfo; } @Override public List<TErpGoodsVO> pageList1(TErpGoodsQuery query, SysUser user) { List<TErpGoodsVO> list = this.baseMapper.pageList1(query,user); if(list.isEmpty()){ List<TErpGoodsVO> list = this.baseMapper.pageList1(query, user); if (list.isEmpty()) { return list; } List<String> typeIds = list.stream().map(TErpGoods::getTypeId).collect(Collectors.toList()); if(!typeIds.isEmpty()){ 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())); @@ -320,16 +318,16 @@ @Override public PageInfo<TErpClinicWarehousePageListVO> warehousePageList(TClinicWarehouseQuery query, SysUser user, String supplierClinicId) { String time = query.getTime(); String sTime =null; String sTime = null; String eTime = null; if(time!=null && !time.isEmpty()){ if (time != null && !time.isEmpty()) { String[] split = time.split(" - "); sTime = split[0] + " 00:00:00"; eTime = split[1] + " 23:59:59"; } PageInfo<TErpClinicWarehousePageListVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); List<TErpClinicWarehousePageListVO> list = this.baseMapper.warehousePageList(query,pageInfo,user,supplierClinicId,sTime,eTime); if(list.isEmpty()){ List<TErpClinicWarehousePageListVO> list = this.baseMapper.warehousePageList(query, pageInfo, user, supplierClinicId, sTime, eTime); if (list.isEmpty()) { return pageInfo; } List<String> collect = list.stream().map(TErpClinicWarehousePageListVO::getId).collect(Collectors.toList()); @@ -346,15 +344,15 @@ @Override public PageInfo<TErpClinicOutboundPageListVO> outboundPageList(TClinicOutboundQuery query, SysUser user, String supplierClinicId) { String time = query.getTime(); String sTime =null; String sTime = null; String eTime = null; if(time!=null && !time.isEmpty()){ if (time != null && !time.isEmpty()) { String[] split = time.split(" - "); sTime = split[0] + " 00:00:00"; eTime = split[1] + " 23:59:59"; } PageInfo<TErpClinicOutboundPageListVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); List<TErpClinicOutboundPageListVO> list = this.baseMapper.outboundPageList(query,pageInfo,user,supplierClinicId,sTime,eTime); List<TErpClinicOutboundPageListVO> list = this.baseMapper.outboundPageList(query, pageInfo, user, supplierClinicId, sTime, eTime); pageInfo.setRecords(list); return pageInfo; } @@ -366,53 +364,58 @@ // Map<String, List<clinicWarehouseGoodsDto>> collect = dtos.stream().collect(Collectors.groupingBy(clinicWarehouseGoodsDto::getSupplierId)); // for (Map.Entry<String, List<clinicWarehouseGoodsDto>> stringListEntry : collect.entrySet()) { TErpClinicWarehousing tErpClinicWarehousing = new TErpClinicWarehousing(); tErpClinicWarehousing.setClinicId(supplierClinicId); tErpClinicWarehousing.setCreateId(user.getUserId().toString()); tErpClinicWarehousing.setWarehouseNo("G"+ DateUtils.dateTimeNow()); tErpClinicWarehousing.setCreateTime(LocalDateTime.now()); tErpClinicWarehousing.setType(3); tErpClinicWarehousing.setStatus(dtos.getStatus()); this.save(tErpClinicWarehousing); TErpClinicWarehousing tErpClinicWarehousing = new TErpClinicWarehousing(); tErpClinicWarehousing.setClinicId(supplierClinicId); tErpClinicWarehousing.setCreateId(user.getUserId().toString()); tErpClinicWarehousing.setWarehouseNo("G" + DateUtils.dateTimeNow()); tErpClinicWarehousing.setCreateTime(LocalDateTime.now()); tErpClinicWarehousing.setType(3); tErpClinicWarehousing.setStatus(dtos.getStatus()); this.save(tErpClinicWarehousing); BigDecimal totalPrice = new BigDecimal(0); for (clinicWarehouseGoodsDto dto : dtos.getDtos()) { TErpClinicWarehousingBatch tErpClinicWarehousingBatch = new TErpClinicWarehousingBatch(); tErpClinicWarehousingBatch.setWarehousingId(tErpClinicWarehousing.getId()); tErpClinicWarehousingBatch.setWarehousingNumber(dto.getPurchaseCount()); tErpClinicWarehousingBatch.setBatchNumber(dto.getBatchNumber()); tErpClinicWarehousingBatch.setProductionDate(dto.getProductionDate().atStartOfDay()); tErpClinicWarehousingBatch.setExpiryDate(dto.getExpiryDate().atStartOfDay()); tErpClinicWarehousingBatch.setGoodsId(dto.getId()); TErpGoods goods = erpGoodsMapper.selectById(dto.getId()); tErpClinicWarehousingBatch.setGoodsName(goods.getGoodsName()); tErpClinicWarehousingBatch.setQuasiNumber(goods.getQuasiNumber()); tErpClinicWarehousingBatch.setUnitAmount(dto.getUnitAmount()); tErpClinicWarehousingBatch.setSalesAmount(dto.getSalesAmount()); if(dto.getSalesAmount()==null){ tErpClinicWarehousingBatch.setSalesAmount(goods.getClinicPurchasePrice()); } tErpClinicWarehousingBatch.setPurchaseCount(dto.getPurchaseCount()); erpClinicWarehousingBatchMapper.insert(tErpClinicWarehousingBatch); if(goods.getMaintenanceInterval()!=null && !goods.getMaintenanceInterval().isEmpty()){ TErpMaintenanceReminder tErpMaintenanceReminder = new TErpMaintenanceReminder(); tErpMaintenanceReminder.setClinicSupplierId(supplierClinicId); tErpMaintenanceReminder.setMaintenanceType(2); tErpMaintenanceReminder.setWarehousingBatchId(tErpClinicWarehousingBatch.getId()); Integer day = Integer.valueOf(goods.getMaintenanceInterval()); // 当前时间+day天 LocalDateTime time1 = LocalDateTime.now().plusDays(day); tErpMaintenanceReminder.setMaintenanceTime(time1); erpMaintenanceReminderMapper.insert(tErpMaintenanceReminder); } totalPrice = totalPrice.add(dto.getSalesAmount().multiply(new BigDecimal(dto.getPurchaseCount()))); BigDecimal totalPrice = new BigDecimal(0); ArrayList<String> names = new ArrayList<>(); for (clinicWarehouseGoodsDto dto : dtos.getDtos()) { TErpClinicWarehousingBatch tErpClinicWarehousingBatch = new TErpClinicWarehousingBatch(); tErpClinicWarehousingBatch.setWarehousingId(tErpClinicWarehousing.getId()); tErpClinicWarehousingBatch.setWarehousingNumber(dto.getPurchaseCount()); tErpClinicWarehousingBatch.setBatchNumber(dto.getBatchNumber()); tErpClinicWarehousingBatch.setProductionDate(dto.getProductionDate().atStartOfDay()); tErpClinicWarehousingBatch.setExpiryDate(dto.getExpiryDate().atStartOfDay()); tErpClinicWarehousingBatch.setGoodsId(dto.getId()); TErpGoods goods = erpGoodsMapper.selectById(dto.getId()); String supplierName = goods.getSupplierName(); names.add(supplierName); tErpClinicWarehousingBatch.setGoodsName(goods.getGoodsName()); tErpClinicWarehousingBatch.setQuasiNumber(goods.getQuasiNumber()); tErpClinicWarehousingBatch.setUnitAmount(dto.getUnitAmount()); tErpClinicWarehousingBatch.setSalesAmount(dto.getSalesAmount()); if (dto.getSalesAmount() == null) { tErpClinicWarehousingBatch.setSalesAmount(goods.getClinicPurchasePrice()); } tErpClinicWarehousing.setTotalPrice(totalPrice); this.updateById(tErpClinicWarehousing); tErpClinicWarehousingBatch.setPurchaseCount(dto.getPurchaseCount()); erpClinicWarehousingBatchMapper.insert(tErpClinicWarehousingBatch); if (goods.getMaintenanceInterval() != null && !goods.getMaintenanceInterval().isEmpty()) { TErpMaintenanceReminder tErpMaintenanceReminder = new TErpMaintenanceReminder(); tErpMaintenanceReminder.setClinicSupplierId(supplierClinicId); tErpMaintenanceReminder.setMaintenanceType(2); tErpMaintenanceReminder.setWarehousingBatchId(tErpClinicWarehousingBatch.getId()); Integer day = Integer.valueOf(goods.getMaintenanceInterval()); // 当前时间+day天 LocalDateTime time1 = LocalDateTime.now().plusDays(day); tErpMaintenanceReminder.setMaintenanceTime(time1); erpMaintenanceReminderMapper.insert(tErpMaintenanceReminder); } totalPrice = totalPrice.add(dto.getSalesAmount().multiply(new BigDecimal(dto.getPurchaseCount()))); } tErpClinicWarehousing.setTotalPrice(totalPrice); String name = names.stream().collect(Collectors.joining(",")); tErpClinicWarehousing.setSupplierName(name); this.updateById(tErpClinicWarehousing); // } @@ -423,7 +426,7 @@ TErpClinicOutbound tErpClinicOutbound = new TErpClinicOutbound(); tErpClinicOutbound.setClinicId(supplierClinicId); tErpClinicOutbound.setCreateId(user.getUserId().toString()); tErpClinicOutbound.setOutboundNumber("G"+ DateUtils.dateTimeNow()); tErpClinicOutbound.setOutboundNumber("G" + DateUtils.dateTimeNow()); tErpClinicOutbound.setCreateTime(LocalDateTime.now()); tErpClinicOutbound.setOutboundType(dto.getOutboundType()); tErpClinicOutbound.setTotalMoney(dto.getTotalPrice()); ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpProcurementServiceImpl.java
@@ -44,6 +44,7 @@ import java.math.RoundingMode; import java.security.PrivateKey; import java.security.cert.X509Certificate; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -99,6 +100,8 @@ @Resource private TErpSupplierOutboundGoodsMapper erpSupplierOutboundGoodsMapper; @Resource private TCrmWarehouseMapper crmWarehouseMapper; @Override public PageInfo<TErpProcurementVo> pageList(TErpProcurementQuery query, SysUser user) { @@ -170,9 +173,13 @@ Integer roleType = user.getRoleType(); String supplierClinicId = null; if (roleType == 6) { TCrmWarehouse warehouse = crmWarehouseMapper.selectOne(Wrappers.lambdaQuery(TCrmWarehouse.class) .eq(TCrmWarehouse::getUserId, user.getUserId()) .last("LIMIT 1")); // 供应商 TCrmSupplier crmSupplier = crmSupplierMapper.selectOne(Wrappers.lambdaQuery(TCrmSupplier.class) .eq(TCrmSupplier::getUserId, user.getUserId()) .eq(TCrmSupplier::getWarehouseId, warehouse.getId()) .last("LIMIT 1")); supplierClinicId = crmSupplier.getId(); @@ -377,7 +384,7 @@ BigDecimal all = BigDecimal.ZERO; for (AddProcurementDto addProcurementDto : value) { BigDecimal multiply = addProcurementDto.getSalesAmount().multiply(BigDecimal.valueOf(addProcurementDto.getPurchaseCount())); BigDecimal multiply = addProcurementDto.getGoodsSalesAmount().multiply(BigDecimal.valueOf(addProcurementDto.getPurchaseCount())); all = all.add(multiply); } tErpProcurement.setPayMoney(all); @@ -404,7 +411,9 @@ tErpProcurementGoods.setQuasiNumber(goods.getQuasiNumber()); TErpGoodsUnit tErpGoodsUnit = erpGoodsUnitMapper.selectById(goods.getPackingUnitId()); tErpProcurementGoods.setUnitName(tErpGoodsUnit.getUnitName()); if(tErpGoodsUnit!=null){ tErpProcurementGoods.setUnitName(tErpGoodsUnit.getUnitName()); } tErpProcurementGoods.setPurchasePrice(dto.getGoodsSalesAmount()); tErpProcurementGoods.setSalesAmount(dto.getSalesAmount()); tErpProcurementGoods.setTotalPrice(dto.getGoodsSalesAmount().multiply(new BigDecimal(dto.getPurchaseCount()))); @@ -460,6 +469,25 @@ detailProcurementNextVO.setTotalPrice(tErpProcurement.getPayMoney()); detailProcurementNextVO.setId(tErpProcurementGoods.getId()); detailProcurementNextVO.setPurchasePrice(tErpProcurementGoods.getPurchasePrice()); List<TErpSupplierOutboundGoods> tErpSupplierOutboundGoods = erpSupplierOutboundGoodsMapper.selectList(new LambdaQueryWrapper<TErpSupplierOutboundGoods>().eq(TErpSupplierOutboundGoods::getProcurementGoodsId, tErpProcurementGoods.getId())); if(!tErpSupplierOutboundGoods.isEmpty()){ ArrayList<DetailProcurementNextThreeVO> detailProcurementNextThreeVOS = new ArrayList<>(); List<String> collect = tErpSupplierOutboundGoods.stream().map(TErpSupplierOutboundGoods::getWarehousingBatchId).collect(Collectors.toList()); List<TErpSupplierWarehousingBatch> tErpSupplierWarehousingBatches = erpSupplierWarehousingBatchMapper.selectBatchIds(collect); for (TErpSupplierOutboundGoods tErpSupplierOutboundGood : tErpSupplierOutboundGoods) { List<TErpSupplierWarehousingBatch> collect1 = tErpSupplierWarehousingBatches.stream().filter(e -> e.getId().equals(tErpSupplierOutboundGood.getWarehousingBatchId())).collect(Collectors.toList()); for (TErpSupplierWarehousingBatch tErpSupplierWarehousingBatch : collect1) { DetailProcurementNextThreeVO detailProcurementNextThreeVO = new DetailProcurementNextThreeVO(); detailProcurementNextThreeVO.setBatchNumber(tErpSupplierWarehousingBatch.getBatchNumber()); detailProcurementNextThreeVO.setProductionDate(tErpSupplierWarehousingBatch.getProductionDate()); detailProcurementNextThreeVO.setExpirationDate(tErpSupplierWarehousingBatch.getExpiryDate()); detailProcurementNextThreeVO.setNum(tErpSupplierOutboundGood.getOutboundCount()); detailProcurementNextThreeVOS.add(detailProcurementNextThreeVO); } } detailProcurementNextVO.setDetailProcurementNextThreeVOS(detailProcurementNextThreeVOS); } detailProcurementNextVOS.add(detailProcurementNextVO); } detailProcurementVO.setList(detailProcurementNextVOS); @@ -468,7 +496,7 @@ @Override @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED) public void detailProcurementSend(String clinicSupplierId, SysUser user, String id) { public void detailProcurementSend(String clinicSupplierId, SysUser user, String id,String logisticsNumber) { // 查出这个采购的下级商品 List<TErpProcurementGoods> list = erpProcurementGoodsService.list(new QueryWrapper<TErpProcurementGoods>().eq("procurement_id", id)); List<TErpSupplierWarehousing> tErpSupplierWarehousings = erpSupplierWarehousingMapper.selectList(new LambdaQueryWrapper<TErpSupplierWarehousing>() @@ -530,6 +558,7 @@ tErpSupplierOutboundGoods.setWarehousingBatchId(warehousingBatch.getId()); tErpSupplierOutboundGoods.setOutboundCount(purchaseCount); tErpSupplierOutboundGoods.setTotalPrice(tErpProcurementGoods.getPurchasePrice().multiply(new BigDecimal(purchaseCount))); tErpSupplierOutboundGoods.setProcurementGoodsId(tErpProcurementGoods.getId()); erpSupplierOutboundGoodsMapper.insert(tErpSupplierOutboundGoods); continue outer; } @@ -552,6 +581,7 @@ tErpSupplierOutboundGoods.setWarehousingBatchId(warehousingBatch.getId()); tErpSupplierOutboundGoods.setOutboundCount(purchaseCount); tErpSupplierOutboundGoods.setTotalPrice(tErpProcurementGoods.getPurchasePrice().multiply(new BigDecimal(purchaseCount))); tErpSupplierOutboundGoods.setProcurementGoodsId(tErpProcurementGoods.getId()); erpSupplierOutboundGoodsMapper.insert(tErpSupplierOutboundGoods); } @@ -564,6 +594,11 @@ } TErpProcurement byId = this.getById(id); byId.setStatus(4); byId.setSendTime(LocalDateTime.now()); byId.setLogisticsNumber(logisticsNumber); this.updateById(byId); } ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TSysGoodsServiceImpl.java
@@ -84,6 +84,7 @@ exchange.setGoodsCount(dto.getCount()); exchange.setUsePoints(tSysGoods.getRequiredPoints().intValue() * dto.getCount()); exchange.setExchangeTime(LocalDateTime.now()); exchange.setClinicId(crmClinic.getId()); sysGoodsExchangeMapper.insert(exchange); // 记录 ruoyi-system/src/main/java/com/ruoyi/system/vo/DetailProcurementNextThreeVO.java
New file @@ -0,0 +1,33 @@ package com.ruoyi.system.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; import java.time.LocalDateTime; @Data @ApiModel(value = "诊所采购详情三级Vo") public class DetailProcurementNextThreeVO { @ApiModelProperty(value = "批次号") private String batchNumber; @ApiModelProperty(value = "生产日期") private LocalDateTime productionDate; @ApiModelProperty(value = "有效期") private LocalDateTime expirationDate; @ApiModelProperty(value = "入库数量") private Integer num; } ruoyi-system/src/main/java/com/ruoyi/system/vo/DetailProcurementNextVO.java
@@ -8,6 +8,7 @@ import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.List; @Data @ApiModel(value = "诊所采购详情二级Vo") @@ -25,14 +26,14 @@ @ApiModelProperty(value = "国药准字号") private String quasiNumber; @ApiModelProperty(value = "数量") private Integer num; @ApiModelProperty(value = "单位") private String packingUnitName; @ApiModelProperty(value = "售价") private BigDecimal salesAmount; @ApiModelProperty(value = "数量") private Integer num; @ApiModelProperty(value = "状态") private BigDecimal totalPrice=BigDecimal.ZERO; @@ -47,6 +48,10 @@ private BigDecimal purchasePrice; @ApiModelProperty(value = "采购三级") private List<DetailProcurementNextThreeVO> detailProcurementNextThreeVOS; ruoyi-system/src/main/java/com/ruoyi/system/vo/ExchangeGoodsRecordDetailVo.java
New file @@ -0,0 +1,54 @@ package com.ruoyi.system.vo; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.time.LocalDateTime; @Data @ApiModel("兑换记录详情") public class ExchangeGoodsRecordDetailVo { @TableId(value = "id", type = IdType.ASSIGN_ID) private String id; @ApiModelProperty(value = "诊所名称") private String clinicName; @ApiModelProperty(value = "商品名称") private String goodsName; @ApiModelProperty(value = "商品id") private String goodsId; @ApiModelProperty(value = "商品数量") private Integer goodsCount; @ApiModelProperty(value = "使用积分") private Integer usePoints; @ApiModelProperty(value = "兑换时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private LocalDateTime exchangeTime; @ApiModelProperty(value = "状态 1=未发货 2=已发货") private Integer status; @ApiModelProperty(value = "物流单号") private String logisticsNumber; @ApiModelProperty(value = "诊所id") private String clinicId; @ApiModelProperty(value = "封面") private String goodsCover; @ApiModelProperty(value = "商品详情") private String goodsDetail; } ruoyi-system/src/main/resources/mapper/system/TErpClinicWarehousingMapper.xml
@@ -123,19 +123,20 @@ <select id="warehousePageList" resultType="com.ruoyi.system.vo.TErpClinicWarehousePageListVO"> select t1.id,t1.warehouse_no, case when t1.type =1 then t2.supplier_name else t4.supplier_name end as supplierName, case when t1.type =1 then t2.supplier_name else t1.supplier_name end as supplierName, t3.procurement_code, case when t1.type =1 then t3.pay_money else t1.total_price end as allTotalPrice, t1.create_time warehouseTime,t1.type from t_erp_clinic_warehousing t1 left join t_erp_procurement t3 on t1.procurement_id = t3.id from t_erp_clinic_warehousing t1 left join t_erp_procurement t3 on t1.procurement_id = t3.id left join t_crm_supplier t2 on t3.supplier_id = t2.id and t1.type =1 left join t_crm_supplier t4 on t1.supplier_id = t4.id and t1.type !=1 where t1.disabled = 0 and t1.clinic_id = #{supplierClinicId} where t1.disabled = 0 and t1.clinic_id = #{supplierClinicId} and t1.status =2 <if test="query.warehouseNo != null and query.warehouseNo != ''"> and t1.warehouse_no like concat('%',#{query.warehouseNo},'%') </if> <if test="query.supplierName != null and query.supplierName != ''"> and (t2.supplier_name like concat('%',#{query.supplierName},'%') or t4.supplier_name like concat('%',#{query.supplierName},'%')) and (t2.supplier_name like concat('%',#{query.supplierName},'%') or t1.supplier_name like concat('%',#{query.supplierName},'%')) </if> <if test="sTime != null"> and t1.create_time between #{sTime} and #{eTime} ruoyi-system/src/main/resources/mapper/system/TErpProcurementMapper.xml
@@ -61,6 +61,7 @@ and t1.create_time between #{sTime} and #{eTime} </if> group by t1.id order by t1.create_time desc </select> <select id="inventoryNotEnoughList" resultType="com.ruoyi.system.vo.TErpGoodsVO">