diff --git a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/dto/erp/CanteenInventoryRecordEditDTO.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/dto/erp/CanteenInventoryRecordEditDTO.java new file mode 100644 index 000000000..dede1cc6a --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/dto/erp/CanteenInventoryRecordEditDTO.java @@ -0,0 +1,95 @@ +package com.bsd.pjcloud.canteen.dto.erp; + + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.List; + + +@Data +@Schema(description = "出入库记录修改对象") +public class CanteenInventoryRecordEditDTO { + + + /** + * 主键 + */ + @Schema(description="主键") + private Long id; + + /** + * 单据编号(规则生成,出入库编号) + */ + @Schema(description="单据编号(规则生成,出入库编号)") + private String inventoryCode; + + /** + * 单据日期 + */ + @Schema(description="单据日期") + private LocalDate inventoryDate; + + /** + * 单据类型(字典inventory_type)采购入库、采购退货、盘点入库等 + */ + @Schema(description="单据类型(字典inventory_type)采购入库、采购退货、盘点入库等") + private String inventoryType; + + + + /** + * 经办人id + */ + @Schema(description="经办人id") + private Long handlerUserId; + + + /** + * 商户编号 + */ + @Schema(description="商户编号") + private Long merchantId; + + + /** + * 货商 + */ + @Schema(description="货商") + private Long supplierId; + + /** + * 备注 + */ + @Schema(description="备注") + private String remark; + + /** + * 订单类型(1入库 2出库) + */ + @Schema(description="订单类型(1入库 2出库)") + private String orderType; + + /** + * 入库总金额 + */ + @Schema(description="入库总金额") + private Integer totalAmount; + + + @Schema(description="收货数量") + private Integer receiveAmount; + + + /** + * @Link SmCgPlanEditItemDTO + */ + @Schema(description="item") + private List items; + + + + +} diff --git a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/dto/erp/CanteenInventoryRecordEditItemDTO.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/dto/erp/CanteenInventoryRecordEditItemDTO.java new file mode 100644 index 000000000..bbbdb6087 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/dto/erp/CanteenInventoryRecordEditItemDTO.java @@ -0,0 +1,86 @@ +package com.bsd.pjcloud.canteen.dto.erp; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + + +@Data +@Schema(description = "出入库记录编辑-item") +public class CanteenInventoryRecordEditItemDTO { + + /** + * id + */ + + @Schema(description="id") + private Long id; + + /** + * 单据类型(字典inventory_type) + */ + @Schema(description="单据类型(字典inventory_type)") + private String inventoryType; + + /** + * 商品id + */ + @Schema(description="原料id") + private Long erpMaterialId; + + /** + * 部门id + */ + @Schema(description="部门id") + private Long deptId; + + /** + * 出入库数量 + */ + @Schema(description="出入库数量") + private Double quantity; + + /** + * 单价 + */ + @Schema(description="单价") + private Integer unitPrice; + + /** + * 总金额 + */ + @Schema(description="总金额") + private Integer totalAmount; + + /** + * 税率% + */ + @Schema(description="税率%") + private Integer taxRate; + + /** + * 税前金额 + */ + @Schema(description="税前金额") + private Integer taxAmount; + + /** + * 货商 + */ + @Schema(description="货商") + private Long supplierId; + + /** + * 备注 + */ + @Schema(description="备注") + private String remark; + + /** + * 订单类型(1入库 2出库) + */ + @Schema(description="订单类型(1入库 2出库)") + private String orderType; + + + +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/erp/CanteenProductionRecordPageVO.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/erp/CanteenProductionRecordPageVO.java index 1a5eeb2bf..8d468e52c 100644 --- a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/erp/CanteenProductionRecordPageVO.java +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/erp/CanteenProductionRecordPageVO.java @@ -67,4 +67,7 @@ public class CanteenProductionRecordPageVO { @TableField(fill = FieldFill.INSERT) @Schema(description="创建时间") private LocalDateTime createTime; + + @Schema(description="食材名称") + private String productName; } \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/pom.xml b/pjcloud-canteen/pjcloud-canteen-biz/pom.xml index afafa6356..d07884323 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/pom.xml +++ b/pjcloud-canteen/pjcloud-canteen-biz/pom.xml @@ -20,12 +20,6 @@ 1.3.4 - - - com.bsd - pjcloud-common-sequence - 5.7.0 - com.bsd @@ -82,6 +76,11 @@ com.bsd pjcloud-common-feign + + + com.bsd + pjcloud-common-sequence + com.bsd diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/config/PjcloudBizName.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/config/PjcloudBizName.java new file mode 100644 index 000000000..5792e04a7 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/config/PjcloudBizName.java @@ -0,0 +1,14 @@ +package com.bsd.pjcloud.canteen.config; + +import cn.hutool.core.date.DateUtil; +import com.bsd.pjcloud.common.sequence.range.BizName; + +public class PjcloudBizName implements BizName { + /** + * 生成名称 + */ + @Override + public String create() { + return DateUtil.today(); + } +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/config/SequenceConfig.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/config/SequenceConfig.java new file mode 100644 index 000000000..86d1aecff --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/config/SequenceConfig.java @@ -0,0 +1,29 @@ +package com.bsd.pjcloud.canteen.config; + +import com.bsd.pjcloud.common.sequence.builder.DbSeqBuilder; +import com.bsd.pjcloud.common.sequence.sequence.Sequence; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import javax.sql.DataSource; + +/** + *

+ * 设置发号器生成规则 + */ +@Configuration +public class SequenceConfig { + + @Bean + public Sequence sequence(DataSource dataSource) { + return DbSeqBuilder + .create() + .bizName(new PjcloudBizName())// 定义切片规则 + .dataSource(dataSource) // 注入数据源 + .step(1000) // 每次获取数据的个数 + .retryTimes(3) // 重试次数 + .tableName("pjcloud_sequence") // 存储表名信息 + .build(); + } +} + diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenInventoryRecordsController.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenInventoryRecordsController.java index d9711227c..0c20dc361 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenInventoryRecordsController.java +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenInventoryRecordsController.java @@ -6,6 +6,7 @@ import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.bsd.pjcloud.canteen.dto.erp.CanteenInventoryRecordEditDTO; import com.bsd.pjcloud.canteen.dto.erp.CanteenInventoryRecordsdDTO; import com.bsd.pjcloud.common.core.util.R; import com.bsd.pjcloud.common.log.annotation.SysLog; @@ -83,15 +84,15 @@ public class CanteenInventoryRecordsController { /** * 修改采购记录表 - * @param canteenInventoryRecords 采购记录表 + * @param canteenInventoryRecordEditDTO 采购记录表 * @return R */ @Operation(summary = "修改采购记录表" , description = "修改采购记录表" ) @SysLog("修改采购记录表" ) @PutMapping @PreAuthorize("@pms.hasPermission('canteen_canteenInventoryRecords_edit')" ) - public R updateById(@RequestBody CanteenInventoryRecordsEntity canteenInventoryRecords) { - return R.ok(canteenInventoryRecordsService.updateById(canteenInventoryRecords)); + public R updateById(@RequestBody CanteenInventoryRecordEditDTO canteenInventoryRecordEditDTO) { + return R.ok(canteenInventoryRecordsService.updateByCanteenInventoryRecordEditDTO(canteenInventoryRecordEditDTO)); } /** diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenSupplierController.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenSupplierController.java new file mode 100644 index 000000000..282a47e52 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenSupplierController.java @@ -0,0 +1,122 @@ +package com.bsd.pjcloud.canteen.controller; + +import cn.hutool.core.util.StrUtil; +import cn.hutool.core.util.ArrayUtil; +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.bsd.pjcloud.common.core.util.R; +import com.bsd.pjcloud.common.log.annotation.SysLog; +import com.bsd.pjcloud.canteen.entity.CanteenSupplierEntity; +import com.bsd.pjcloud.canteen.service.CanteenSupplierService; +import org.springframework.security.access.prepost.PreAuthorize; +import com.bsd.pjcloud.common.excel.annotation.ResponseExcel; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import org.springdoc.core.annotations.ParameterObject; +import org.springframework.http.HttpHeaders; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Operation; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Objects; + +/** + * 货商信息 + * + * @author zjf + * @date 2025-05-09 13:18:19 + */ +@RestController +@RequiredArgsConstructor +@RequestMapping("/canteenSupplier" ) +@Tag(description = "canteenSupplier" , name = "货商信息管理" ) +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) +public class CanteenSupplierController { + + private final CanteenSupplierService canteenSupplierService; + + /** + * 分页查询 + * @param page 分页对象 + * @param canteenSupplier 货商信息 + * @return + */ + @Operation(summary = "分页查询" , description = "分页查询" ) + @GetMapping("/page" ) + @PreAuthorize("@pms.hasPermission('canteen_canteenSupplier_view')" ) + public R getCanteenSupplierPage(@ParameterObject Page page, @ParameterObject CanteenSupplierEntity canteenSupplier) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.like(StrUtil.isNotBlank(canteenSupplier.getSupplierName()),CanteenSupplierEntity::getSupplierName,canteenSupplier.getSupplierName()); + wrapper.eq(StrUtil.isNotBlank(canteenSupplier.getPhone()),CanteenSupplierEntity::getPhone,canteenSupplier.getPhone()); + return R.ok(canteenSupplierService.page(page, wrapper)); + } + + + /** + * 通过id查询货商信息 + * @param supplierId id + * @return R + */ + @Operation(summary = "通过id查询" , description = "通过id查询" ) + @GetMapping("/{supplierId}" ) + @PreAuthorize("@pms.hasPermission('canteen_canteenSupplier_view')" ) + public R getById(@PathVariable("supplierId" ) Long supplierId) { + return R.ok(canteenSupplierService.getById(supplierId)); + } + + /** + * 新增货商信息 + * @param canteenSupplier 货商信息 + * @return R + */ + @Operation(summary = "新增货商信息" , description = "新增货商信息" ) + @SysLog("新增货商信息" ) + @PostMapping + @PreAuthorize("@pms.hasPermission('canteen_canteenSupplier_add')" ) + public R save(@RequestBody CanteenSupplierEntity canteenSupplier) { + return R.ok(canteenSupplierService.save(canteenSupplier)); + } + + /** + * 修改货商信息 + * @param canteenSupplier 货商信息 + * @return R + */ + @Operation(summary = "修改货商信息" , description = "修改货商信息" ) + @SysLog("修改货商信息" ) + @PutMapping + @PreAuthorize("@pms.hasPermission('canteen_canteenSupplier_edit')" ) + public R updateById(@RequestBody CanteenSupplierEntity canteenSupplier) { + return R.ok(canteenSupplierService.updateById(canteenSupplier)); + } + + /** + * 通过id删除货商信息 + * @param ids supplierId列表 + * @return R + */ + @Operation(summary = "通过id删除货商信息" , description = "通过id删除货商信息" ) + @SysLog("通过id删除货商信息" ) + @DeleteMapping + @PreAuthorize("@pms.hasPermission('canteen_canteenSupplier_del')" ) + public R removeById(@RequestBody Long[] ids) { + return R.ok(canteenSupplierService.removeBatchByIds(CollUtil.toList(ids))); + } + + + /** + * 导出excel 表格 + * @param canteenSupplier 查询条件 + * @param ids 导出指定ID + * @return excel 文件流 + */ + @ResponseExcel + @GetMapping("/export") + @PreAuthorize("@pms.hasPermission('canteen_canteenSupplier_export')" ) + public List export(CanteenSupplierEntity canteenSupplier,Long[] ids) { + return canteenSupplierService.list(Wrappers.lambdaQuery(canteenSupplier).in(ArrayUtil.isNotEmpty(ids), CanteenSupplierEntity::getSupplierId, ids)); + } +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenSupplierEntity.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenSupplierEntity.java new file mode 100644 index 000000000..0513484e2 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenSupplierEntity.java @@ -0,0 +1,163 @@ +package com.bsd.pjcloud.canteen.entity; + +import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import com.bsd.pjcloud.common.core.util.TenantTable; +import java.time.LocalDateTime; + +/** + * 货商信息 + * + * @author zjf + * @date 2025-05-09 13:18:19 + */ +@Data +@TenantTable +@TableName("canteen_supplier") +@EqualsAndHashCode(callSuper = true) +@Schema(description = "货商信息") +public class CanteenSupplierEntity extends Model { + + + /** + * 货商ID + */ + @TableId(type = IdType.ASSIGN_ID) + @Schema(description="货商ID") + private Long supplierId; + + /** + * 货商名称 + */ + @Schema(description="货商名称") + private String supplierName; + + /** + * 货商地址 + */ + @Schema(description="货商地址") + private String address; + + /** + * 电话号码 + */ + @Schema(description="电话号码") + private String phone; + + /** + * 税号 + */ + @Schema(description="税号") + private String tax; + + /** + * 联系人 + */ + @Schema(description="联系人") + private String linkName; + + /** + * 开户行账号 + */ + @Schema(description="开户行账号") + private String openAccount; + + /** + * 邮箱地址 + */ + @Schema(description="邮箱地址") + private String email; + + /** + * 所属部门ID + */ + @Schema(description="所属部门ID") + private Long deptId; + + /** + * 货商类别 + */ + @Schema(description="货商类别") + private Long supplierType; + + /** + * 货商地区 + */ + @Schema(description="货商地区") + private String supplierArea; + + /** + * 修改时间 + */ + @Schema(description="修改时间") + private LocalDateTime passwordModifyTime; + + /** + * 开户行 + */ + @Schema(description="开户行") + private String openName; + + /** + * 合同号 + */ + @Schema(description="合同号") + private String contractNumber; + + /** + * 状态 0使用 1禁用 + */ + @Schema(description="状态 0使用 1禁用") + private String status; + + /** + * 拼音简码 + */ + @Schema(description="拼音简码") + private String pinyinCod; + + /** + * 创建人 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description="创建人") + private String createBy; + + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description="创建时间") + private LocalDateTime createTime; + + /** + * 修改人 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + @Schema(description="修改人") + private String updateBy; + + /** + * 修改时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + @Schema(description="修改时间") + private LocalDateTime updateTime; + + /** + * 删除标记,0未删除,1已删除 + */ + @TableLogic + @TableField(fill = FieldFill.INSERT) + @Schema(description="删除标记,0未删除,1已删除") + private String delFlag; + + /** + * 所属租户ID + */ + @Schema(description="所属租户ID") + private Long tenantId; +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/CanteenSupplierMapper.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/CanteenSupplierMapper.java new file mode 100644 index 000000000..def616a2a --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/CanteenSupplierMapper.java @@ -0,0 +1,11 @@ +package com.bsd.pjcloud.canteen.mapper; + +import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper; +import com.bsd.pjcloud.canteen.entity.CanteenSupplierEntity; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface CanteenSupplierMapper extends PjcloudBaseMapper { + + +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenInventoryRecordsService.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenInventoryRecordsService.java index f97960f20..57a9057b8 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenInventoryRecordsService.java +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenInventoryRecordsService.java @@ -2,6 +2,7 @@ package com.bsd.pjcloud.canteen.service; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; +import com.bsd.pjcloud.canteen.dto.erp.CanteenInventoryRecordEditDTO; import com.bsd.pjcloud.canteen.dto.erp.CanteenInventoryRecordsdDTO; import com.bsd.pjcloud.canteen.entity.CanteenInventoryRecordsEntity; import com.bsd.pjcloud.canteen.vo.erp.CanteenProductionRecordPageVO; @@ -24,4 +25,12 @@ public interface CanteenInventoryRecordsService extends IService pageScope(Page page, CanteenInventoryRecordsEntity canteenInventoryRecords); + + + /** + * 修改 + * @param canteenInventoryRecordEditDTO + * @return + */ + Object updateByCanteenInventoryRecordEditDTO(CanteenInventoryRecordEditDTO canteenInventoryRecordEditDTO); } \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenSupplierService.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenSupplierService.java new file mode 100644 index 000000000..2d8ce0357 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenSupplierService.java @@ -0,0 +1,8 @@ +package com.bsd.pjcloud.canteen.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.bsd.pjcloud.canteen.entity.CanteenSupplierEntity; + +public interface CanteenSupplierService extends IService { + +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenInventoryRecordsServiceImpl.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenInventoryRecordsServiceImpl.java index 1e5483af8..86878d4b7 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenInventoryRecordsServiceImpl.java +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenInventoryRecordsServiceImpl.java @@ -1,11 +1,10 @@ package com.bsd.pjcloud.canteen.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.bsd.pjcloud.canteen.constant.OrderTypeEnum; -import com.bsd.pjcloud.canteen.dto.erp.CanteenInventoryRecordsItemDTO; -import com.bsd.pjcloud.canteen.dto.erp.CanteenInventoryRecordsdDTO; -import com.bsd.pjcloud.canteen.dto.erp.UpdateStockDTO; +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.mapper.CanteenInventoryRecordsItemMapper; @@ -26,6 +25,8 @@ import org.springframework.util.CollectionUtils; import java.util.ArrayList; import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; /** * 采购记录表 @@ -91,4 +92,84 @@ public class CanteenInventoryRecordsServiceImpl extends ServiceImpl items = canteenInventoryRecordEditDTO.getItems(); + List updateStockDTOS = new ArrayList<>(); + List CanteenInventoryRecordsItemEntityList = new ArrayList<>(); + + for (CanteenInventoryRecordEditItemDTO item : items){ + CanteenInventoryRecordsItemEntity CanteenInventoryRecordsItemEntity = new CanteenInventoryRecordsItemEntity(); + org.springframework.beans.BeanUtils.copyProperties(item,CanteenInventoryRecordsItemEntity); + //库存更新对象 + UpdateStockDTO updateStockDTO = new UpdateStockDTO(); + updateStockDTO.setId(item.getErpMaterialId()); + Double quantity = item.getQuantity(); + String orderType = item.getOrderType(); + CanteenInventoryRecordsItemEntity.setOrderType(orderType); + if (orderType.equals(OrderTypeEnum.RK.getType())){ + updateStockDTO.setIncrCount(quantity); + }else if (orderType.equals(OrderTypeEnum.CK.getType())){ + updateStockDTO.setIncrCount(-quantity); + }else { + throw new RuntimeException("订单类型错误"); + } + CanteenInventoryRecordsItemEntityList.add(CanteenInventoryRecordsItemEntity); + updateStockDTOS.add(updateStockDTO); + + } + + + List insertItems = CanteenInventoryRecordsItemEntityList.stream(). + filter(CanteenInventoryRecordsItemEntity -> CanteenInventoryRecordsItemEntity.getId() == null).collect(Collectors.toList()); + List updateItems = CanteenInventoryRecordsItemEntityList.stream(). + filter(CanteenInventoryRecordsItemEntity -> CanteenInventoryRecordsItemEntity.getId() != null).collect(Collectors.toList()); + + + //更新的话,查询之前保存了哪些item,然后去库存表删掉从新计算库存 + List dataBaseCanteenInventoryRecordsItemEntityList = canteenInventoryRecordsItemMapper + .selectList(new LambdaQueryWrapper().eq(CanteenInventoryRecordsItemEntity::getInventoryId, canteenInventoryRecordEditDTO.getId())); + + //这部分是数据库原本添加的库存数据,需要全部减掉,重新添加更新的库存数据进去 + dataBaseCanteenInventoryRecordsItemEntityList.forEach(item -> { + UpdateStockDTO updateStockDTO = new UpdateStockDTO(); + updateStockDTO.setId(item.getErpMaterialId()); + updateStockDTO.setIncrCount(-item.getQuantity()); + updateStockDTOS.add(updateStockDTO); + }); + + + canteenInventoryRecordsItemMapper.updateById(updateItems); + canteenInventoryRecordsItemMapper.insert(insertItems); + + List existingCodeIds = canteenInventoryRecordsItemMapper.selectList( + new LambdaQueryWrapper() + .eq(CanteenInventoryRecordsItemEntity::getInventoryId, smErpInventoryRecordsEntity.getId()) + ).stream().map(CanteenInventoryRecordsItemEntity::getId).collect(Collectors.toList()); + + // 收集本次提交的ID(排除新增的) + List submittedCodeIds = updateItems.stream() + .map(CanteenInventoryRecordsItemEntity::getId) + .filter(Objects::nonNull) + .collect(Collectors.toList()); + + // 计算需要删除的ID + List toDeleteCodeIds = existingCodeIds.stream() + .filter(id -> !submittedCodeIds.contains(id)) + .collect(Collectors.toList()); + + // 批量删除失效 + if (!toDeleteCodeIds.isEmpty()) { + canteenInventoryRecordsItemMapper.deleteByIds(toDeleteCodeIds); + } + //更新库存 + if (!CollectionUtils.isEmpty(updateStockDTOS)){ + canteenStockService.updateStock(updateStockDTOS); + } + + return i; + } } \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenSupplierServiceImpl.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenSupplierServiceImpl.java new file mode 100644 index 000000000..79e8d4bdb --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenSupplierServiceImpl.java @@ -0,0 +1,16 @@ +package com.bsd.pjcloud.canteen.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bsd.pjcloud.canteen.entity.CanteenSupplierEntity; +import com.bsd.pjcloud.canteen.mapper.CanteenSupplierMapper; +import com.bsd.pjcloud.canteen.service.CanteenSupplierService; +import org.springframework.stereotype.Service; +/** + * 货商信息 + * + * @author zjf + * @date 2025-05-09 13:18:19 + */ +@Service +public class CanteenSupplierServiceImpl extends ServiceImpl implements CanteenSupplierService { +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenInventoryRecordsMapper.xml b/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenInventoryRecordsMapper.xml index 0897302e8..19f38a044 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenInventoryRecordsMapper.xml +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenInventoryRecordsMapper.xml @@ -31,19 +31,22 @@ \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenSupplierMapper.xml b/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenSupplierMapper.xml new file mode 100644 index 000000000..4cb1bdfb7 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenSupplierMapper.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file