This commit is contained in:
dzc committed 2025-05-09 18:12:44 +08:00
commit 081dacce4e
5 files changed
+210 -3

No files matched your search

@@ -0,0 +1,66 @@
package com.bsd.pjcloud.canteen.vo.erp;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
/**
* 采购计划-item
*
* @author zjf
* @date 2025-02-11 17:11:41
*/
@Data
@Schema(description = "采购计划-item")
public class InventoryRecordItemVo {
@Schema(description = "id")
private Long id;
@Schema(description="食材id")
private Long erpMaterialId;
/**
* 主表id
*/
@Schema(description="主表id")
private Long inventoryId;
/**
* 数量
*/
@Schema(description="数量")
private Integer quantity;
/**
* 进价
*/
@Schema(description="进价")
private Integer unitPrice;
/**
* 累计总金额
*/
@Schema(description="累计总金额")
private Integer totalAmount;
/**
* 备注
*/
@Schema(description="备注")
private String remark;
@Schema(description="实际进价")
private Integer realPrice;
/**
* 进价(分为单位)
*/
@Schema(description="进价(分为单位)")
private Integer purchasePrice;
}
@@ -0,0 +1,72 @@
package com.bsd.pjcloud.canteen.vo.erp;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
@Schema(description = "采购根据id查询-编辑回显 vo")
@Data
public class InventoryRecordVo {
@Schema(description ="id")
private Long id;
/**
* 采购计划编号
*/
@Schema(description="编号")
private String inventoryCode;
/**
* 采购计划单据日期
*/
@Schema(description="单据日期")
private LocalDate inventoryDate;
@Schema(description="商品名称")
private String productName;
/**
* 经办人id
*/
@Schema(description="经办人id")
private Long handlerUserId;
@Schema(description="供应商id")
private Long supplierId;
/**
* 备注
*/
@Schema(description="备注")
private String remark;
/**
* 创建人
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建人")
private String createBy;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建时间")
private LocalDateTime createTime;
/**
* @link InventoryRecordItemVo
*/
@Schema(description="item")
private List<InventoryRecordItemVo> items;
}
@@ -66,7 +66,7 @@ public class CanteenInventoryRecordsController {
@GetMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('canteen_canteenInventoryRecords_view')" )
public R getById(@PathVariable("id" ) Long id) {
return R.ok(canteenInventoryRecordsService.getById(id));
return R.ok(canteenInventoryRecordsService.getInventoryDetailById(id));
}
/**
@@ -105,7 +105,7 @@ public class CanteenInventoryRecordsController {
@DeleteMapping
@PreAuthorize("@pms.hasPermission('canteen_canteenInventoryRecords_del')" )
public R removeById(@RequestBody Long[] ids) {
return R.ok(canteenInventoryRecordsService.removeBatchByIds(CollUtil.toList(ids)));
return R.ok(canteenInventoryRecordsService.removeBatch(CollUtil.toList(ids)));
}
@@ -7,6 +7,9 @@ import com.bsd.pjcloud.canteen.dto.erp.CanteenInventoryRecordsdDTO;
import com.bsd.pjcloud.canteen.entity.CanteenInventoryRecordsEntity;
import com.bsd.pjcloud.canteen.vo.erp.CanteenProductionRecordPageVO;
import java.util.ArrayList;
import java.util.List;
public interface CanteenInventoryRecordsService extends IService<CanteenInventoryRecordsEntity> {
@@ -33,4 +36,10 @@ public interface CanteenInventoryRecordsService extends IService<CanteenInventor
* @return
*/
Object updateByCanteenInventoryRecordEditDTO(CanteenInventoryRecordEditDTO canteenInventoryRecordEditDTO);
Object getInventoryDetailById(Long id);
Object removeBatch(List<Long> list);
}
@@ -7,6 +7,7 @@ import com.bsd.pjcloud.canteen.constant.OrderTypeEnum;
import com.bsd.pjcloud.canteen.dto.erp.*;
import com.bsd.pjcloud.canteen.entity.CanteenInventoryRecordsEntity;
import com.bsd.pjcloud.canteen.entity.CanteenInventoryRecordsItemEntity;
import com.bsd.pjcloud.canteen.entity.CanteenProductionRecordEntity;
import com.bsd.pjcloud.canteen.mapper.CanteenInventoryRecordsItemMapper;
import com.bsd.pjcloud.canteen.mapper.CanteenInventoryRecordsMapper;
import com.bsd.pjcloud.canteen.mapper.CanteenProductionRecordItemMapper;
@@ -14,7 +15,10 @@ import com.bsd.pjcloud.canteen.mapper.CanteenStockMapper;
import com.bsd.pjcloud.canteen.service.CanteenInventoryRecordsService;
import com.bsd.pjcloud.canteen.service.CanteenStockService;
import com.bsd.pjcloud.canteen.vo.erp.CanteenProductionRecordPageVO;
import com.bsd.pjcloud.canteen.vo.erp.InventoryRecordItemVo;
import com.bsd.pjcloud.canteen.vo.erp.InventoryRecordVo;
import com.bsd.pjcloud.common.core.util.BeanUtils;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.security.util.SecurityUtils;
import com.bsd.pjcloud.flow.task.constant.TaskCheckStatusEnum;
@@ -65,7 +69,7 @@ public class CanteenInventoryRecordsServiceImpl extends ServiceImpl<CanteenInven
String orderType = canteenInventoryRecordsEntity.getOrderType();
canteenInventoryRecordsItemEntity.setOrderType(orderType);
UpdateStockDTO updateStockDTO = new UpdateStockDTO();
updateStockDTO.setId(id);
updateStockDTO.setId(canteenInventoryRecordsItemEntity.getErpMaterialId());
Double quantity = canteenInventoryRecordsItemEntity.getQuantity();
if (orderType.equals(OrderTypeEnum.RK.getType())){
updateStockDTO.setIncrCount(quantity);
@@ -172,4 +176,60 @@ public class CanteenInventoryRecordsServiceImpl extends ServiceImpl<CanteenInven
return i;
}
@Override
public Object getInventoryDetailById(Long id) {
CanteenInventoryRecordsEntity smErpInventoryRecordsEntity = this.getById(id);
List<CanteenInventoryRecordsItemEntity> list =canteenInventoryRecordsItemMapper.selectList(new LambdaQueryWrapper<CanteenInventoryRecordsItemEntity>()
.eq(CanteenInventoryRecordsItemEntity::getInventoryId, id));
InventoryRecordVo bean = BeanUtils.toBean(smErpInventoryRecordsEntity, InventoryRecordVo.class, (source) -> {
List<InventoryRecordItemVo> smeErpCgPlanItemVos = BeanUtils.toBean(list, InventoryRecordItemVo.class);
source.setItems(smeErpCgPlanItemVos);
});
return bean;
}
@Override
public Object removeBatch(List<Long> list) {
//首先先查询是否有当前数据权限
LambdaQueryWrapper<CanteenInventoryRecordsEntity> eq = new LambdaQueryWrapper<CanteenInventoryRecordsEntity>()
.in(CanteenInventoryRecordsEntity::getId, list);
List<CanteenInventoryRecordsEntity> smErpCgDdEntities = baseMapper.selectListByScope(eq,DataScope.of());
List<Long> delIds= smErpCgDdEntities.stream().map(smErpCgDdEntity -> smErpCgDdEntity.getId()).collect(Collectors.toList());
LambdaQueryWrapper<CanteenInventoryRecordsItemEntity> itemEntityLambdaQueryWrapper = new LambdaQueryWrapper<CanteenInventoryRecordsItemEntity>()
.in(CanteenInventoryRecordsItemEntity::getInventoryId, delIds);
//要删除的item
List<CanteenInventoryRecordsItemEntity> items = canteenInventoryRecordsItemMapper.selectList(itemEntityLambdaQueryWrapper);
canteenInventoryRecordsItemMapper.delete(itemEntityLambdaQueryWrapper);
baseMapper.deleteByIds(delIds);
List<Long> toDeleteIds = delIds.stream()
.filter(id -> !list.contains(id))
.collect(Collectors.toList());
if (!CollectionUtils.isEmpty(toDeleteIds)){
return R.failed("越权删除!");
}
//删除之前入库的库存
List<UpdateStockDTO> updateStockDTOS = new ArrayList<>();
for (CanteenInventoryRecordsItemEntity item : items){
//库存更新对象
UpdateStockDTO updateStockDTO = new UpdateStockDTO();
updateStockDTO.setId(item.getErpMaterialId());
Double quantity = item.getQuantity();
String orderType = item.getOrderType();
//入库的删除就是减去入的库存,所以是负数
if (orderType.equals(OrderTypeEnum.RK.getType())){
updateStockDTO.setIncrCount(-quantity);
}else if (orderType.equals(OrderTypeEnum.CK.getType())){
updateStockDTO.setIncrCount(quantity);
}else {
throw new RuntimeException("订单类型错误");
}
updateStockDTOS.add(updateStockDTO);
}
canteenStockService.updateStock(updateStockDTOS);
return R.ok();
}
}