parent
bc71ee7830
commit
dada568893
10 changed files with 1201 additions and 0 deletions
@ -0,0 +1,26 @@ |
||||
package org.springblade.wms.pojo.dto; |
||||
|
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.wms.pojo.entity.StGraphiteMoldOut; |
||||
|
||||
import java.io.Serial; |
||||
|
||||
/** |
||||
* @version 1.0 |
||||
* @program: jonhon-mes-svr |
||||
* @ClassName StGraphiteMoldOutDTO |
||||
* @description: 石墨模出库 数据传输对象实体类 |
||||
* @autor: WuSiYu |
||||
* @create 2025-xx-xx xx:xx |
||||
**/ |
||||
|
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class StGraphiteMoldOutDTO extends StGraphiteMoldOut { |
||||
@Serial |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,151 @@ |
||||
package org.springblade.wms.pojo.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.core.tenant.mp.TenantEntity; |
||||
|
||||
import java.io.Serial; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* @version 1.0 |
||||
* @program: jonhon-mes-svr |
||||
* @ClassName StGraphiteMoldOut |
||||
* @description: 石墨模出库 实体类 |
||||
* @autor: WuSiYu |
||||
* @create 2025-xx-xx xx:xx |
||||
**/ |
||||
|
||||
@Data |
||||
@TableName("ST_GRAPHITE_MOLD_OUT") |
||||
@Schema(description = "StGraphiteMoldOut对象") |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class StGraphiteMoldOut extends TenantEntity { |
||||
|
||||
@Serial |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 出库凭证信息 |
||||
*/ |
||||
@Schema(description = "出库凭证信息") |
||||
private Long sirId; |
||||
|
||||
/** |
||||
* 生产单号 |
||||
*/ |
||||
@TableField(value = "YO_CODE") |
||||
private String yoCode; |
||||
|
||||
/** |
||||
* 批次号 |
||||
*/ |
||||
@Schema(description = "批次号") |
||||
private String piNo; |
||||
|
||||
/** |
||||
* 流程卡号 |
||||
*/ |
||||
@Schema(description = "流程卡号") |
||||
private String cardNo; |
||||
|
||||
/** |
||||
* 物料ID |
||||
*/ |
||||
@Schema(description = "物料ID") |
||||
private Long goodsId; |
||||
|
||||
/** |
||||
* 物料编号 |
||||
*/ |
||||
@Schema(description = "物料编号") |
||||
private String goodsCode; |
||||
|
||||
/** |
||||
* 物料名称 |
||||
*/ |
||||
@Schema(description = "物料名称") |
||||
private String goodsName; |
||||
|
||||
/** |
||||
* 物料需求量 |
||||
*/ |
||||
@Schema(description = "物料需求量") |
||||
private Double needQuantity; |
||||
|
||||
/** |
||||
* 库房ID |
||||
*/ |
||||
@Schema(description = "库房ID") |
||||
private Long shId; |
||||
|
||||
/** |
||||
* 库房名称 |
||||
*/ |
||||
@Schema(description = "库房名称") |
||||
private String shName; |
||||
|
||||
/** |
||||
* 库位ID |
||||
*/ |
||||
@Schema(description = "库位ID") |
||||
private Long slId; |
||||
|
||||
/** |
||||
* 库位号 |
||||
*/ |
||||
@Schema(description = "库位号") |
||||
private String location; |
||||
|
||||
/** |
||||
* 已出库数量 |
||||
*/ |
||||
@Schema(description = "已出库数量") |
||||
private Double outedQuantity; |
||||
|
||||
/** |
||||
* 出库时间 |
||||
*/ |
||||
@Schema(description = "出库时间") |
||||
private Date outTime; |
||||
|
||||
/** |
||||
* 出库人 |
||||
*/ |
||||
@Schema(description = "出库人") |
||||
private Long outUser; |
||||
|
||||
/** |
||||
* 出库单号 |
||||
*/ |
||||
@Schema(description = "出库单号") |
||||
private String outCode; |
||||
|
||||
/** |
||||
* 库存ID |
||||
*/ |
||||
@Schema(description = "库存ID") |
||||
private Long rlsId; |
||||
|
||||
/** |
||||
* 状态 |
||||
*/ |
||||
@Schema(description = "状态") |
||||
private Long curStatus; |
||||
|
||||
/** |
||||
* 可用库存数量 |
||||
*/ |
||||
@TableField(exist = false) |
||||
private Double stockQty; |
||||
|
||||
/** |
||||
* 领料人ID |
||||
*/ |
||||
@Schema(description = "领料人ID") |
||||
private Long picker; |
||||
|
||||
} |
||||
@ -0,0 +1,24 @@ |
||||
package org.springblade.wms.pojo.vo; |
||||
|
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.wms.pojo.entity.StGraphiteMoldOut; |
||||
|
||||
import java.io.Serial; |
||||
|
||||
/** |
||||
* @version 1.0 |
||||
* @program: jonhon-mes-svr |
||||
* @ClassName StGraphiteMoldOutVO |
||||
* @description: 石墨模出库 视图实体类 |
||||
* @autor: WuSiYu |
||||
* @create 2025-xx-xx xx:xx |
||||
**/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class StGraphiteMoldOutVO extends StGraphiteMoldOut { |
||||
@Serial |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,234 @@ |
||||
package org.springblade.wms.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import io.swagger.v3.oas.annotations.Operation; |
||||
import io.swagger.v3.oas.annotations.Parameter; |
||||
import io.swagger.v3.oas.annotations.tags.Tag; |
||||
import jakarta.servlet.http.HttpServletResponse; |
||||
import jakarta.validation.Valid; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.boot.ctrl.BladeController; |
||||
import org.springblade.core.excel.util.ExcelUtil; |
||||
import org.springblade.core.log.annotation.ApiLog; |
||||
import org.springblade.core.mp.support.Condition; |
||||
import org.springblade.core.mp.support.Query; |
||||
import org.springblade.core.secure.BladeUser; |
||||
import org.springblade.core.secure.annotation.IsAdmin; |
||||
import org.springblade.core.secure.utils.AuthUtil; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.DateUtil; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.wms.excel.StGraphiteMoldOutExcel; |
||||
import org.springblade.wms.pojo.dto.StGraphiteMoldOutDTO; |
||||
import org.springblade.wms.pojo.entity.StGraphiteMoldOut; |
||||
import org.springblade.wms.pojo.vo.StGraphiteMoldOutVO; |
||||
import org.springblade.wms.pojo.vo.StStockInoutRecordVO; |
||||
import org.springblade.wms.service.IStGraphiteMoldOutService; |
||||
import org.springblade.wms.service.IStStockInoutRecordService; |
||||
import org.springblade.wms.wrapper.StGraphiteMoldOutWrapper; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @version 1.0 |
||||
* @program: jonhon-mes-svr |
||||
* @ClassName StGraphiteMoldOutController |
||||
* @description: 石墨模出库 控制器 |
||||
* @autor: WuSiYu |
||||
* @create 2025-xx-xx xx:xx |
||||
**/ |
||||
|
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping("/stGraphiteMoldOut") |
||||
@Tag(name = "石墨模出库", description = "石墨模出库接口") |
||||
public class StGraphiteMoldOutController extends BladeController { |
||||
|
||||
private final IStGraphiteMoldOutService stGraphiteMoldOutService; |
||||
private final IStStockInoutRecordService stStockInoutRecordService; |
||||
|
||||
/** |
||||
* 石墨模出库 详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
@ApiOperationSupport(order = 1) |
||||
@ApiLog("石墨模出库 详情") |
||||
@Operation(summary = "详情", description = "传入stGraphiteMoldOut") |
||||
public R<StGraphiteMoldOutVO> detail(StGraphiteMoldOut stGraphiteMoldOut) { |
||||
StGraphiteMoldOut detail = stGraphiteMoldOutService.getOne(Condition.getQueryWrapper(stGraphiteMoldOut)); |
||||
return R.data(StGraphiteMoldOutWrapper.build().entityVO(detail)); |
||||
} |
||||
|
||||
/** |
||||
* 石墨模出库 分页 |
||||
*/ |
||||
@GetMapping("/list") |
||||
@ApiOperationSupport(order = 2) |
||||
@ApiLog("石墨模出库 分页") |
||||
@Operation(summary = "分页", description = "传入stGraphiteMoldOut") |
||||
public R<IPage<StGraphiteMoldOutVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> stGraphiteMoldOut, Query query) { |
||||
IPage<StGraphiteMoldOut> pages = stGraphiteMoldOutService.page(Condition.getPage(query), Condition.getQueryWrapper(stGraphiteMoldOut, StGraphiteMoldOut.class)); |
||||
return R.data(StGraphiteMoldOutWrapper.build().pageVO(pages)); |
||||
} |
||||
|
||||
/** |
||||
* 石墨模出库 自定义分页 |
||||
*/ |
||||
@GetMapping("/page") |
||||
@ApiOperationSupport(order = 3) |
||||
@ApiLog("石墨模出库 自定义分页") |
||||
@Operation(summary = "分页", description = "传入stGraphiteMoldOut") |
||||
public R<IPage<StGraphiteMoldOutVO>> page(StGraphiteMoldOutVO stGraphiteMoldOut, Query query) { |
||||
IPage<StGraphiteMoldOutVO> pages = stGraphiteMoldOutService.selectStGraphiteMoldOutPage(Condition.getPage(query), stGraphiteMoldOut); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 石墨模出库 新增 |
||||
*/ |
||||
@PostMapping("/save") |
||||
@ApiOperationSupport(order = 4) |
||||
@ApiLog("石墨模出库 新增") |
||||
@Operation(summary = "新增", description = "传入stGraphiteMoldOut") |
||||
public R save(@Valid @RequestBody StGraphiteMoldOut stGraphiteMoldOut) { |
||||
return R.status(stGraphiteMoldOutService.save(stGraphiteMoldOut)); |
||||
} |
||||
|
||||
/** |
||||
* 石墨模出库 修改 |
||||
*/ |
||||
@PostMapping("/update") |
||||
@ApiOperationSupport(order = 5) |
||||
@ApiLog("石墨模出库 修改") |
||||
@Operation(summary = "修改", description = "传入stGraphiteMoldOut") |
||||
public R update(@Valid @RequestBody StGraphiteMoldOut stGraphiteMoldOut) { |
||||
return R.status(stGraphiteMoldOutService.updateById(stGraphiteMoldOut)); |
||||
} |
||||
|
||||
/** |
||||
* 石墨模出库 新增或修改 |
||||
*/ |
||||
@PostMapping("/submit") |
||||
@ApiOperationSupport(order = 6) |
||||
@ApiLog("石墨模出库 新增或修改") |
||||
@Operation(summary = "新增或修改", description = "传入stGraphiteMoldOut") |
||||
public R submit(@Valid @RequestBody StGraphiteMoldOut stGraphiteMoldOut) { |
||||
return R.status(stGraphiteMoldOutService.saveOrUpdate(stGraphiteMoldOut)); |
||||
} |
||||
|
||||
/** |
||||
* 石墨模出库 删除 |
||||
*/ |
||||
@PostMapping("/remove") |
||||
@ApiOperationSupport(order = 7) |
||||
@ApiLog("石墨模出库 删除") |
||||
@Operation(summary = "逻辑删除", description = "传入ids") |
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) { |
||||
return R.status(stGraphiteMoldOutService.deleteLogic(Func.toLongList(ids))); |
||||
} |
||||
|
||||
/** |
||||
* 石墨模出库 生成出库单号 |
||||
*/ |
||||
@GetMapping("/generateCode") |
||||
@ApiOperationSupport(order = 8) |
||||
@ApiLog("石墨模出库 生成出库单号") |
||||
@Operation(summary = "生成石墨模出库单号", description = "获取新单据号并返回空账单对象") |
||||
public R<StStockInoutRecordVO> generateCode() { |
||||
// 1. 生成单号
|
||||
String sirCode = stStockInoutRecordService.generateCode(); |
||||
|
||||
// 2. 封装合表 VO
|
||||
StStockInoutRecordVO vo = new StStockInoutRecordVO(); |
||||
vo.setSirCode(sirCode); |
||||
vo.setCreateUser(AuthUtil.getUserId()); |
||||
|
||||
return R.data(vo); |
||||
} |
||||
|
||||
/** |
||||
* 生成石墨模预出库单 |
||||
*/ |
||||
@PostMapping("/generateOrder") |
||||
@ApiOperationSupport(order = 9) |
||||
@ApiLog("生成石墨模预出库单") |
||||
@Operation(summary = "生成石墨模预出库单", description = "按物料编号+规格等条件查库存,库存充足生成预出库单,不足返回指定提示") |
||||
public R<List<StGraphiteMoldOut>> generatePreOutOrder( |
||||
@Parameter(description = "石墨模预出库信息", required = true) |
||||
@RequestBody StGraphiteMoldOutDTO dto |
||||
) { |
||||
return R.data(stGraphiteMoldOutService.generatePreOutOrder(dto)); |
||||
} |
||||
|
||||
/** |
||||
* 批量生成石墨模预出库单 |
||||
*/ |
||||
@PostMapping("/batchGenerateOrder") |
||||
@ApiOperationSupport(order = 10) |
||||
@ApiLog("批量生成石墨模预出库单") |
||||
@Operation(summary = "批量生成石墨模预出库单", description = "批量传入石墨模信息,逐条校验库存,成功生成预出库单,失败收集提示信息(一条失败不影响其他)") |
||||
public R<Map<String, Object>> batchGeneratePreOutOrder( |
||||
@Parameter(description = "石墨模预出库信息集合", required = true) |
||||
@RequestBody List<StGraphiteMoldOutDTO> dtoList |
||||
) { |
||||
Map<String, Object> result = stGraphiteMoldOutService.batchGeneratePreOutOrder(dtoList); |
||||
return R.data(result); |
||||
} |
||||
|
||||
/** |
||||
* 扫码查询/新增待出库数据 |
||||
*/ |
||||
@GetMapping("/scanCard") |
||||
@ApiOperationSupport(order = 11) |
||||
@ApiLog("扫码查询/新增待出库数据") |
||||
@Operation(summary = "扫码处理石墨模出库", description = "传入流程卡号,查询/新增待出库数据") |
||||
public R<List<StGraphiteMoldOut>> scanCard( |
||||
@Parameter(description = "流程卡号(扫码内容)", required = true) @RequestParam String cardNo) { |
||||
return R.data(stGraphiteMoldOutService.scanCardProcess(cardNo, AuthUtil.getUser())); |
||||
} |
||||
|
||||
/** |
||||
* 编辑出库数量后 提交确认出库 |
||||
*/ |
||||
@PostMapping("/submitOutStock") |
||||
@ApiOperationSupport(order = 12) |
||||
@ApiLog("编辑出库数量后 提交确认出库") |
||||
@Operation(summary = "石墨模出库-提交确认出库", description = "填写出库数量后提交,写入出入库记录并扣减库存,变更为已出库状态") |
||||
public R<StGraphiteMoldOut> submitOutStock(@RequestBody StGraphiteMoldOut stGraphiteMoldOut) { |
||||
BladeUser user = AuthUtil.getUser(); |
||||
StGraphiteMoldOut result = stGraphiteMoldOutService.submitOutStock(stGraphiteMoldOut, user); |
||||
return R.data(result); |
||||
} |
||||
|
||||
/** |
||||
* 编辑出库数量后 批量出库 |
||||
*/ |
||||
@PostMapping("/batchSubmitOutStock") |
||||
@ApiOperationSupport(order = 13) |
||||
@ApiLog("编辑出库数量后 批量出库") |
||||
@Operation(summary = "石墨模出库-提交确认出库", description = "填写出库数量后提交,写入出入库记录并扣减库存,变更为已出库状态") |
||||
public R<List<StGraphiteMoldOut>> batchSubmitOutStock(@RequestBody List<StGraphiteMoldOut> paramList) { |
||||
BladeUser user = AuthUtil.getUser(); |
||||
List<StGraphiteMoldOut> result = stGraphiteMoldOutService.batchSubmitOutStock(paramList, user); |
||||
return R.data(result); |
||||
} |
||||
|
||||
/** |
||||
* 导出数据 |
||||
*/ |
||||
@IsAdmin |
||||
@GetMapping("/export-stGraphiteMoldOut") |
||||
@ApiOperationSupport(order = 14) |
||||
@ApiLog("导出数据") |
||||
@Operation(summary = "导出数据", description = "传入stGraphiteMoldOut") |
||||
public void exportStGraphiteMoldOut(@Parameter(hidden = true) @RequestParam Map<String, Object> stGraphiteMoldOut, BladeUser bladeUser, HttpServletResponse response) { |
||||
QueryWrapper<StGraphiteMoldOut> queryWrapper = Condition.getQueryWrapper(stGraphiteMoldOut, StGraphiteMoldOut.class); |
||||
List<StGraphiteMoldOutExcel> list = stGraphiteMoldOutService.exportStGraphiteMoldOut(queryWrapper); |
||||
ExcelUtil.export(response, "石墨模出库数据" + DateUtil.time(), "石墨模出库数据表", list, StGraphiteMoldOutExcel.class); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,164 @@ |
||||
package org.springblade.wms.excel; |
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty; |
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth; |
||||
import com.alibaba.excel.annotation.write.style.ContentRowHeight; |
||||
import com.alibaba.excel.annotation.write.style.HeadRowHeight; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serial; |
||||
import java.io.Serializable; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* @version 1.0 |
||||
* @program: jonhon-mes-svr |
||||
* @ClassName StGraphiteMoldOutExcel |
||||
* @description: 石墨模出库 Excel实体类 |
||||
* @autor: WuSiYu |
||||
* @create 2025-xx-xx xx:xx |
||||
**/ |
||||
|
||||
@Data |
||||
@ColumnWidth(25) |
||||
@HeadRowHeight(20) |
||||
@ContentRowHeight(18) |
||||
public class StGraphiteMoldOutExcel implements Serializable { |
||||
|
||||
@Serial |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 主键 |
||||
*/ |
||||
@ColumnWidth(20) |
||||
@ExcelProperty("主键") |
||||
private Long id; |
||||
/** |
||||
* 租户ID |
||||
*/ |
||||
@ColumnWidth(20) |
||||
@ExcelProperty("租户ID") |
||||
private String tenantId; |
||||
/** |
||||
* 是否已删除 |
||||
*/ |
||||
@ColumnWidth(20) |
||||
@ExcelProperty("是否已删除") |
||||
private Long isDeleted; |
||||
/** |
||||
* 出库凭证信息 |
||||
*/ |
||||
@ColumnWidth(20) |
||||
@ExcelProperty("出库凭证信息") |
||||
private Long sirId; |
||||
/** |
||||
* 车间订单号 |
||||
*/ |
||||
@ColumnWidth(20) |
||||
@ExcelProperty("车间订单号") |
||||
private String woCode; |
||||
/** |
||||
* 生产单号 |
||||
*/ |
||||
@ColumnWidth(20) |
||||
@ExcelProperty("生产单号") |
||||
private String yoCode; |
||||
/** |
||||
* 零件号 |
||||
*/ |
||||
@ColumnWidth(20) |
||||
@ExcelProperty("零件号") |
||||
private String partCode; |
||||
/** |
||||
* 零件名称 |
||||
*/ |
||||
@ColumnWidth(20) |
||||
@ExcelProperty("零件名称") |
||||
private String partName; |
||||
/** |
||||
* 批次号 |
||||
*/ |
||||
@ColumnWidth(20) |
||||
@ExcelProperty("批次号") |
||||
private String piNo; |
||||
/** |
||||
* 流程卡号 |
||||
*/ |
||||
@ColumnWidth(20) |
||||
@ExcelProperty("流程卡号") |
||||
private String cardNo; |
||||
/** |
||||
* 物料需求量 |
||||
*/ |
||||
@ColumnWidth(20) |
||||
@ExcelProperty("物料需求量") |
||||
private Double needQuantity; |
||||
/** |
||||
* 已出库数量 |
||||
*/ |
||||
@ColumnWidth(20) |
||||
@ExcelProperty("已出库数量") |
||||
private Double outedQuantity; |
||||
/** |
||||
* 状态 |
||||
*/ |
||||
@ColumnWidth(20) |
||||
@ExcelProperty("状态") |
||||
private Long curStatus; |
||||
/** |
||||
* 出库时间 |
||||
*/ |
||||
@ColumnWidth(20) |
||||
@ExcelProperty("出库时间") |
||||
private Date outTime; |
||||
/** |
||||
* 出库人 |
||||
*/ |
||||
@ColumnWidth(20) |
||||
@ExcelProperty("出库人") |
||||
private Long outUser; |
||||
/** |
||||
* 物料ID |
||||
*/ |
||||
@ColumnWidth(20) |
||||
@ExcelProperty("物料ID") |
||||
private Long goodsId; |
||||
/** |
||||
* 库位ID |
||||
*/ |
||||
@ColumnWidth(20) |
||||
@ExcelProperty("库位ID") |
||||
private Long slId; |
||||
/** |
||||
* 库房ID |
||||
*/ |
||||
@ColumnWidth(20) |
||||
@ExcelProperty("库房ID") |
||||
private Long shId; |
||||
/** |
||||
* 库存ID |
||||
*/ |
||||
@ColumnWidth(20) |
||||
@ExcelProperty("库存ID") |
||||
private Long rlsId; |
||||
/** |
||||
* 出库单号 |
||||
*/ |
||||
@ColumnWidth(20) |
||||
@ExcelProperty("出库单号") |
||||
private String outCode; |
||||
/** |
||||
* 备注 |
||||
*/ |
||||
@ColumnWidth(20) |
||||
@ExcelProperty("备注") |
||||
private String memo; |
||||
/** |
||||
* 领料人ID |
||||
*/ |
||||
@ColumnWidth(20) |
||||
@ExcelProperty("领料人ID") |
||||
private Long picker; |
||||
|
||||
} |
||||
@ -0,0 +1,52 @@ |
||||
package org.springblade.wms.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.springblade.desk.order.pojo.entity.YieldOrder; |
||||
import org.springblade.desk.produce.pojo.entity.WorkOrder; |
||||
import org.springblade.wms.excel.StGraphiteMoldOutExcel; |
||||
import org.springblade.wms.pojo.entity.StGraphiteMoldOut; |
||||
import org.springblade.wms.pojo.vo.StGraphiteMoldOutVO; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @version 1.0 |
||||
* @program: jonhon-mes-svr |
||||
* @ClassName StGraphiteMoldOutMapper |
||||
* @description: 石墨模出库 Mapper 接口 |
||||
* @autor: WuSiYu |
||||
* @create 2025-xx-xx xx:xx |
||||
**/ |
||||
|
||||
public interface StGraphiteMoldOutMapper extends BaseMapper<StGraphiteMoldOut> { |
||||
|
||||
/** |
||||
* 自定义分页 |
||||
* |
||||
* @param page 分页参数 |
||||
* @param stGraphiteMoldOut 查询参数 |
||||
* @return List<StGraphiteMoldOutVO> |
||||
*/ |
||||
List<StGraphiteMoldOutVO> selectStGraphiteMoldOutPage(IPage page, StGraphiteMoldOutVO stGraphiteMoldOut); |
||||
|
||||
/** |
||||
* 获取导出数据 |
||||
* |
||||
* @param queryWrapper 查询条件 |
||||
* @return List<StGraphiteMoldOutExcel> |
||||
*/ |
||||
List<StGraphiteMoldOutExcel> exportStGraphiteMoldOut(@Param("ew") Wrapper<StGraphiteMoldOut> queryWrapper); |
||||
|
||||
StGraphiteMoldOut getBySirId(Long sirId); |
||||
|
||||
WorkOrder getByWoCode(String cardNo); |
||||
|
||||
YieldOrder getByYoCode(String cardNo); |
||||
|
||||
YieldOrder getByYieldOrder(String yoCode); |
||||
|
||||
List<YieldOrder> getYieldOrderList(Long id, String yieldType); |
||||
} |
||||
@ -0,0 +1,118 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="org.springblade.wms.mapper.StGraphiteMoldOutMapper"> |
||||
|
||||
<!-- 通用查询映射结果 --> |
||||
<resultMap id="stGraphiteMoldOutResultMap" type="org.springblade.wms.pojo.entity.StGraphiteMoldOut"> |
||||
<result column="ID" property="id"/> |
||||
<result column="TENANT_ID" property="tenantId"/> |
||||
<result column="CREATE_USER" property="createUser"/> |
||||
<result column="CREATE_DEPT" property="createDept"/> |
||||
<result column="CREATE_TIME" property="createTime"/> |
||||
<result column="UPDATE_USER" property="updateUser"/> |
||||
<result column="UPDATE_TIME" property="updateTime"/> |
||||
<result column="STATUS" property="status"/> |
||||
<result column="IS_DELETED" property="isDeleted"/> |
||||
<result column="SIR_ID" property="sirId"/> |
||||
<result column="YO_CODE" property="yoCode"/> |
||||
<result column="PI_NO" property="piNo"/> |
||||
<result column="CARD_NO" property="cardNo"/> |
||||
<result column="NEED_QUANTITY" property="needQuantity"/> |
||||
<result column="OUTED_QUANTITY" property="outedQuantity"/> |
||||
<result column="CUR_STATUS" property="curStatus"/> |
||||
<result column="OUT_TIME" property="outTime"/> |
||||
<result column="OUT_USER" property="outUser"/> |
||||
<result column="GOODS_ID" property="goodsId"/> |
||||
<result column="SL_ID" property="slId"/> |
||||
<result column="SH_ID" property="shId"/> |
||||
<result column="RLS_ID" property="rlsId"/> |
||||
<result column="OUT_CODE" property="outCode"/> |
||||
</resultMap> |
||||
|
||||
<select id="selectStGraphiteMoldOutPage" resultType="org.springblade.wms.pojo.vo.StGraphiteMoldOutVO"> |
||||
SELECT |
||||
gmo.id, gmo.create_user, gmo.create_time, |
||||
gmo.sir_id, gmo.wo_code, gmo.yo_code, gmo.pi_no, gmo.card_no, gmo.need_quantity, gmo.outed_quantity, |
||||
gmo.cur_status, gmo.out_time, gmo.out_user, gmo.out_code, |
||||
gmo.memo, gmo.picker, |
||||
-- 物料表字段 |
||||
g.goods_code, |
||||
g.id AS goodsId, |
||||
g.goods_name, |
||||
-- 库房名称 |
||||
w.id AS shId, |
||||
w.sh_name, |
||||
w.sh_code, |
||||
-- 库位名称 |
||||
lc.id AS slId, |
||||
lc.location, |
||||
-- 库存表字段 |
||||
r.id AS rlsId, |
||||
r.pi_no, |
||||
COALESCE(r.quantity, 0) - COALESCE(r.occupy_quantity, 0) AS stockQty, |
||||
-- 用户名称 |
||||
cu.name AS create_user_name, |
||||
ou.name AS out_user_name, |
||||
pk.name AS picker_name |
||||
FROM ST_GRAPHITE_MOLD_OUT gmo |
||||
LEFT JOIN ST_GOODS g ON gmo.goods_id = g.id AND g.is_deleted = 0 |
||||
LEFT JOIN ST_STOREHOUSE w ON gmo.sh_id = w.id AND w.is_deleted = 0 |
||||
LEFT JOIN ST_STORAGE_LOCATION lc ON gmo.sl_id = lc.id AND lc.is_deleted = 0 |
||||
LEFT JOIN ST_REALTIME_STOCK r ON gmo.rls_id = r.id AND r.is_deleted = 0 |
||||
LEFT JOIN BLADE_USER cu ON gmo.create_user = cu.id AND cu.is_deleted = 0 |
||||
LEFT JOIN BLADE_USER ou ON gmo.out_user = ou.id AND ou.is_deleted = 0 |
||||
LEFT JOIN BLADE_USER pk ON gmo.picker = pk.id AND pk.is_deleted = 0 |
||||
WHERE gmo.is_deleted = 0 |
||||
<if test="stGraphiteMoldOut.yoCode != null and stGraphiteMoldOut.yoCode != ''"> |
||||
AND gmo.yo_code LIKE '%' || #{stGraphiteMoldOut.yoCode} || '%' |
||||
</if> |
||||
|
||||
<if test="stGraphiteMoldOut.cardNo != null and stGraphiteMoldOut.cardNo != ''"> |
||||
AND gmo.card_no LIKE '%' || #{stGraphiteMoldOut.cardNo} || '%' |
||||
</if> |
||||
<if test="stGraphiteMoldOut.goodsCode != null and stGraphiteMoldOut.goodsCode != ''"> |
||||
AND g.goods_code LIKE '%' || #{stGraphiteMoldOut.goodsCode} || '%' |
||||
</if> |
||||
<if test="stGraphiteMoldOut.curStatus != null"> |
||||
AND gmo.cur_status = #{stGraphiteMoldOut.curStatus} |
||||
</if> |
||||
ORDER BY gmo.create_time DESC |
||||
</select> |
||||
|
||||
<select id="getBySirId" resultMap="stGraphiteMoldOutResultMap"> |
||||
SELECT * |
||||
FROM ST_GRAPHITE_MOLD_OUT |
||||
WHERE SIR_ID = #{sirId} |
||||
AND ROWNUM = 1 |
||||
</select> |
||||
|
||||
<select id="exportStGraphiteMoldOut" resultType="org.springblade.wms.excel.StGraphiteMoldOutExcel"> |
||||
SELECT * FROM ST_GRAPHITE_MOLD_OUT ${ew.customSqlSegment} |
||||
</select> |
||||
|
||||
<select id="getByWoCode" resultType="org.springblade.desk.produce.pojo.entity.WorkOrder"> |
||||
SELECT * |
||||
FROM MES_WORK_ORDER |
||||
WHERE card_no = #{cardNo} |
||||
</select> |
||||
|
||||
<select id="getByYoCode" resultType="org.springblade.desk.order.pojo.entity.YieldOrder"> |
||||
SELECT * |
||||
FROM MES_YIELD_ORDER |
||||
WHERE card_no = #{cardNo} |
||||
</select> |
||||
|
||||
<select id="getByYieldOrder" resultType="org.springblade.desk.order.pojo.entity.YieldOrder"> |
||||
SELECT * |
||||
FROM MES_YIELD_ORDER |
||||
WHERE YO_CODE = #{yoCode} |
||||
</select> |
||||
|
||||
<select id="getYieldOrderList" resultType="org.springblade.desk.order.pojo.entity.YieldOrder"> |
||||
SELECT * |
||||
FROM MES_YIELD_ORDER |
||||
WHERE FATHER_YO_ID = #{id} |
||||
AND YIELD_TYPE = #{yieldType} |
||||
</select> |
||||
|
||||
</mapper> |
||||
@ -0,0 +1,51 @@ |
||||
package org.springblade.wms.service; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import org.springblade.core.mp.base.BaseService; |
||||
import org.springblade.core.secure.BladeUser; |
||||
import org.springblade.wms.excel.StGraphiteMoldOutExcel; |
||||
import org.springblade.wms.pojo.dto.StGraphiteMoldOutDTO; |
||||
import org.springblade.wms.pojo.entity.StGraphiteMoldOut; |
||||
import org.springblade.wms.pojo.vo.StGraphiteMoldOutVO; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @version 1.0 |
||||
* @program: jonhon-mes-svr |
||||
* @ClassName IStGraphiteMoldOutService |
||||
* @description: 石墨模出库 服务类 |
||||
* @autor: WuSiYu |
||||
* @create 2025-xx-xx xx:xx |
||||
**/ |
||||
public interface IStGraphiteMoldOutService extends BaseService<StGraphiteMoldOut> { |
||||
/** |
||||
* 自定义分页 |
||||
* |
||||
* @param page 分页参数 |
||||
* @param stGraphiteMoldOut 查询参数 |
||||
* @return IPage<StGraphiteMoldOutVO> |
||||
*/ |
||||
IPage<StGraphiteMoldOutVO> selectStGraphiteMoldOutPage(IPage<StGraphiteMoldOutVO> page, StGraphiteMoldOutVO stGraphiteMoldOut); |
||||
|
||||
|
||||
/** |
||||
* 导出数据 |
||||
* |
||||
* @param queryWrapper 查询条件 |
||||
* @return List<StGraphiteMoldOutExcel> |
||||
*/ |
||||
List<StGraphiteMoldOutExcel> exportStGraphiteMoldOut(Wrapper<StGraphiteMoldOut> queryWrapper); |
||||
|
||||
List<StGraphiteMoldOut> scanCardProcess(String cardNo, BladeUser user); |
||||
|
||||
StGraphiteMoldOut submitOutStock(StGraphiteMoldOut stGraphiteMoldOut, BladeUser user); |
||||
|
||||
List<StGraphiteMoldOut> generatePreOutOrder(StGraphiteMoldOutDTO dto); |
||||
|
||||
Map<String, Object> batchGeneratePreOutOrder(List<StGraphiteMoldOutDTO> dtoList); |
||||
|
||||
List<StGraphiteMoldOut> batchSubmitOutStock(List<StGraphiteMoldOut> paramList, BladeUser user); |
||||
} |
||||
@ -0,0 +1,345 @@ |
||||
package org.springblade.wms.service.impl; |
||||
|
||||
import cn.hutool.core.util.IdUtil; |
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import jakarta.annotation.Resource; |
||||
import org.springblade.core.log.exception.ServiceException; |
||||
import org.springblade.core.mp.base.BaseServiceImpl; |
||||
import org.springblade.core.secure.BladeUser; |
||||
import org.springblade.desk.order.pojo.entity.YieldOrder; |
||||
import org.springblade.wms.excel.StGraphiteMoldOutExcel; |
||||
import org.springblade.wms.mapper.StGraphiteMoldOutMapper; |
||||
import org.springblade.wms.mapper.StRealtimeStockMapper; |
||||
import org.springblade.wms.pojo.dto.StGraphiteMoldOutDTO; |
||||
import org.springblade.wms.pojo.entity.*; |
||||
import org.springblade.wms.pojo.vo.StGraphiteMoldOutVO; |
||||
import org.springblade.wms.service.*; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
import org.springframework.util.CollectionUtils; |
||||
|
||||
import java.util.*; |
||||
|
||||
/** |
||||
* @version 1.0 |
||||
* @program: jonhon-mes-svr |
||||
* @ClassName StGraphiteMoldOutServiceImpl |
||||
* @description: 石墨模出库 服务实现类 |
||||
* @autor: WuSiYu |
||||
* @create 2025-xx-xx xx:xx |
||||
**/ |
||||
|
||||
@Service |
||||
public class StGraphiteMoldOutServiceImpl extends BaseServiceImpl<StGraphiteMoldOutMapper, StGraphiteMoldOut> implements IStGraphiteMoldOutService { |
||||
@Resource |
||||
StRealtimeStockMapper stRealtimeStockMapper; |
||||
@Resource |
||||
IStStockInoutRecordService stStockInoutRecordService; |
||||
@Resource |
||||
IStRealtimeStockService stRealtimeStockService; |
||||
@Resource |
||||
IStGoodsService stGoodsService; |
||||
@Resource |
||||
IStStorehouseService stStorehouseService; |
||||
@Resource |
||||
IStStorageLocationService stStorageLocationService; |
||||
|
||||
@Override |
||||
public IPage<StGraphiteMoldOutVO> selectStGraphiteMoldOutPage(IPage<StGraphiteMoldOutVO> page, StGraphiteMoldOutVO stGraphiteMoldOut) { |
||||
return page.setRecords(baseMapper.selectStGraphiteMoldOutPage(page, stGraphiteMoldOut)); |
||||
} |
||||
|
||||
@Override |
||||
@Transactional(rollbackFor = Exception.class) |
||||
public List<StGraphiteMoldOut> generatePreOutOrder(StGraphiteMoldOutDTO dto) { |
||||
if (dto == null) { |
||||
throw new ServiceException("石墨模信息不能为空,无法生成预出库单"); |
||||
} |
||||
Date now = new Date(); |
||||
|
||||
YieldOrder faYieldOrder = baseMapper.getByYoCode(dto.getCardNo()); |
||||
if (faYieldOrder == null) { |
||||
throw new RuntimeException("根据生产订单ID【" + dto.getCardNo() + "】未查询到生产订单信息"); |
||||
} |
||||
|
||||
List<StGraphiteMoldOut> preOutStockList = new ArrayList<>(); |
||||
|
||||
String goodsCode = faYieldOrder.getPartCode(); |
||||
Double requireQty = faYieldOrder.getYpQty(); |
||||
System.out.println("石墨模编码:" + goodsCode + ",总需求:" + requireQty); |
||||
|
||||
List<StRealtimeStock> candidateStockList = new ArrayList<>(); |
||||
double totalUsable = 0.0; |
||||
while (true) { |
||||
StRealtimeStock maxStock = stRealtimeStockMapper.selectMaxUsableStockByMoldAttr(goodsCode); |
||||
|
||||
if (maxStock == null) { |
||||
break; |
||||
} |
||||
|
||||
double occupyQty = Optional.ofNullable(maxStock.getOccupyQuantity()).orElse(0D); |
||||
double usableQty = maxStock.getQuantity() - occupyQty; |
||||
|
||||
if (usableQty <= 0) { |
||||
break; |
||||
} |
||||
|
||||
candidateStockList.add(maxStock); |
||||
totalUsable += usableQty; |
||||
|
||||
if (totalUsable >= requireQty) { |
||||
break; |
||||
} |
||||
} |
||||
|
||||
if (totalUsable < requireQty - 0.001) { |
||||
throw new ServiceException("石墨模【" + goodsCode + "】库存不足,无法生成!需求数量:" + requireQty + ",可用库存:" + totalUsable); |
||||
} |
||||
|
||||
double remainingQty = requireQty; |
||||
for (StRealtimeStock maxStock : candidateStockList) { |
||||
if (remainingQty <= 0.001) { |
||||
break; |
||||
} |
||||
|
||||
double occupyQty = Optional.ofNullable(maxStock.getOccupyQuantity()).orElse(0D); |
||||
double usableQty = maxStock.getQuantity() - occupyQty; |
||||
double actualTake = Math.min(usableQty, remainingQty); |
||||
|
||||
StGraphiteMoldOut preOutStock = new StGraphiteMoldOut(); |
||||
preOutStock.setYoCode(faYieldOrder.getYoCode()); |
||||
preOutStock.setCardNo(dto.getCardNo()); |
||||
|
||||
preOutStock.setOutCode(stStockInoutRecordService.generateCode()); |
||||
preOutStock.setNeedQuantity(requireQty); |
||||
preOutStock.setGoodsId(maxStock.getGoodsId()); |
||||
StGoods stGoods = stGoodsService.getById(maxStock.getGoodsId()); |
||||
preOutStock.setGoodsName(stGoods.getGoodsName()); |
||||
preOutStock.setGoodsCode(stGoods.getGoodsCode()); |
||||
preOutStock.setSlId(maxStock.getSlId()); |
||||
StStorageLocation location = stStorageLocationService.getById(maxStock.getSlId()); |
||||
preOutStock.setLocation(location.getLocation()); |
||||
preOutStock.setShId(maxStock.getShId()); |
||||
StStorehouse storehouse = stStorehouseService.getById(maxStock.getShId()); |
||||
preOutStock.setShName(storehouse.getShName()); |
||||
preOutStock.setRlsId(maxStock.getId()); |
||||
preOutStock.setPiNo(maxStock.getPiNo()); |
||||
|
||||
preOutStock.setCurStatus(0L); |
||||
preOutStock.setCreateTime(now); |
||||
preOutStock.setUpdateTime(now); |
||||
|
||||
preOutStockList.add(preOutStock); |
||||
System.out.println("石墨模[编码:" + goodsCode + "]库存充足,已构建预出库信息,库存ID:" + maxStock.getId()); |
||||
|
||||
double newOccupy = occupyQty + actualTake; |
||||
maxStock.setOccupyQuantity(newOccupy); |
||||
stRealtimeStockService.updateById(maxStock); |
||||
|
||||
StRealtimeStockLock lock = new StRealtimeStockLock(); |
||||
lock.setId(IdUtil.getSnowflake().nextId()); |
||||
lock.setRlsId(maxStock.getId()); |
||||
lock.setWoNo(preOutStock.getCardNo()); |
||||
lock.setOccupyQuantity(actualTake); |
||||
lock.setStatus(0); |
||||
stRealtimeStockMapper.insertStockLock(lock); |
||||
remainingQty -= actualTake; |
||||
} |
||||
System.out.println("石墨模[编码:" + goodsCode + "] 预出库全部完成!"); |
||||
|
||||
this.saveBatch(preOutStockList); |
||||
return preOutStockList; |
||||
} |
||||
|
||||
@Override |
||||
public Map<String, Object> batchGeneratePreOutOrder(List<StGraphiteMoldOutDTO> dtoList) { |
||||
Map<String, Object> resultMap = new HashMap<>(2); |
||||
List<StGraphiteMoldOut> successList = new ArrayList<>(); |
||||
List<String> failMsgList = new ArrayList<>(); |
||||
|
||||
if (CollectionUtils.isEmpty(dtoList)) { |
||||
failMsgList.add("批量生成失败:石墨模信息集合不能为空"); |
||||
resultMap.put("successList", successList); |
||||
resultMap.put("failMsgList", failMsgList); |
||||
return resultMap; |
||||
} |
||||
|
||||
for (int i = 0; i < dtoList.size(); i++) { |
||||
StGraphiteMoldOutDTO dto = dtoList.get(i); |
||||
try { |
||||
List<StGraphiteMoldOut> preOutOrderList = this.generatePreOutOrder(dto); |
||||
for (StGraphiteMoldOut item : preOutOrderList) { |
||||
if (item != null) { |
||||
successList.add(item); |
||||
} |
||||
} |
||||
} catch (ServiceException e) { |
||||
failMsgList.add(String.format("第%s条:%s", i + 1, e.getMessage())); |
||||
} catch (Exception e) { |
||||
failMsgList.add(String.format("第%s条:生成失败,未知异常:%s", i + 1, e.getMessage())); |
||||
} |
||||
} |
||||
|
||||
resultMap.put("successList", successList); |
||||
resultMap.put("failMsgList", failMsgList); |
||||
return resultMap; |
||||
} |
||||
|
||||
@Override |
||||
@Transactional(rollbackFor = Exception.class) |
||||
public List<StGraphiteMoldOut> scanCardProcess(String cardNo, BladeUser user) { |
||||
QueryWrapper<StGraphiteMoldOut> queryWrapper = new QueryWrapper<>(); |
||||
queryWrapper.eq("card_no", cardNo); |
||||
queryWrapper.eq("cur_status", 0L); |
||||
|
||||
List<StGraphiteMoldOut> waitOutList = baseMapper.selectList(queryWrapper); |
||||
|
||||
if (!CollectionUtils.isEmpty(waitOutList)) { |
||||
for (StGraphiteMoldOut waitOut : waitOutList) { |
||||
StRealtimeStock stock = stRealtimeStockService.getById(waitOut.getRlsId()); |
||||
|
||||
if (stock != null) { |
||||
waitOut.setStockQty(stock.getQuantity() - stock.getOccupyQuantity()); |
||||
waitOut.setPiNo(stock.getPiNo()); |
||||
} |
||||
StGoods stGoods = stGoodsService.getById(waitOut.getGoodsId()); |
||||
waitOut.setGoodsCode(stGoods.getGoodsCode()); |
||||
waitOut.setGoodsName(stGoods.getGoodsName()); |
||||
StStorehouse storehouse = stStorehouseService.getById(waitOut.getShId()); |
||||
waitOut.setShName(storehouse.getShName()); |
||||
StStorageLocation location = stStorageLocationService.getById(waitOut.getSlId()); |
||||
waitOut.setLocation(location.getLocation()); |
||||
} |
||||
return waitOutList; |
||||
}else { |
||||
StGraphiteMoldOutDTO dto = new StGraphiteMoldOutDTO(); |
||||
dto.setCardNo(cardNo); |
||||
|
||||
List<StGraphiteMoldOut> stGraphiteMoldOutList = this.generatePreOutOrder(dto); |
||||
if (!CollectionUtils.isEmpty(stGraphiteMoldOutList)) { |
||||
for (StGraphiteMoldOut waitOut : stGraphiteMoldOutList) { |
||||
StRealtimeStock stock = stRealtimeStockService.getById(waitOut.getRlsId()); |
||||
|
||||
if (stock != null) { |
||||
waitOut.setStockQty(stock.getQuantity() - stock.getOccupyQuantity()); |
||||
waitOut.setPiNo(stock.getPiNo()); |
||||
} |
||||
StGoods stGoods = stGoodsService.getById(waitOut.getGoodsId()); |
||||
waitOut.setGoodsCode(stGoods.getGoodsCode()); |
||||
waitOut.setGoodsName(stGoods.getGoodsName()); |
||||
StStorehouse storehouse = stStorehouseService.getById(waitOut.getShId()); |
||||
waitOut.setShName(storehouse.getShName()); |
||||
StStorageLocation location = stStorageLocationService.getById(waitOut.getSlId()); |
||||
waitOut.setLocation(location.getLocation()); |
||||
} |
||||
return stGraphiteMoldOutList; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
@Transactional(rollbackFor = Exception.class) |
||||
public StGraphiteMoldOut submitOutStock(StGraphiteMoldOut param, BladeUser user) { |
||||
List<StGraphiteMoldOut> outList = new ArrayList<>(); |
||||
outList.add(param); |
||||
List<StGraphiteMoldOut> resultList = this.batchSubmitOutStock(outList, user); |
||||
return resultList.isEmpty() ? null : resultList.get(0); |
||||
} |
||||
|
||||
@Transactional(rollbackFor = Exception.class) |
||||
public List<StGraphiteMoldOut> batchSubmitOutStock(List<StGraphiteMoldOut> paramList, BladeUser user) { |
||||
if (paramList == null || paramList.isEmpty()) { |
||||
throw new ServiceException("出库数据不能为空"); |
||||
} |
||||
Long userId = Long.valueOf(user.getUserId()); |
||||
Date nowDate = new Date(); |
||||
|
||||
List<StStockInoutRecord> allInoutList = new ArrayList<>(); |
||||
List<StRealtimeStock> stockList = new ArrayList<>(); |
||||
List<StGraphiteMoldOut> resultList = new ArrayList<>(); |
||||
|
||||
for (StGraphiteMoldOut param : paramList) { |
||||
if (param.getId() == null) { |
||||
throw new ServiceException("出库数据ID不能为空"); |
||||
} |
||||
if (param.getOutedQuantity() == null || param.getOutedQuantity() <= 0) { |
||||
throw new ServiceException("流程卡号【"+param.getCardNo()+"】请填写正确的出库数量,数量必须大于0"); |
||||
} |
||||
|
||||
StGraphiteMoldOut outEntity = this.getById(param.getId()); |
||||
if (outEntity == null) { |
||||
throw new ServiceException("主键ID【"+param.getId()+"】未查询到该待出库数据"); |
||||
} |
||||
if (outEntity.getCurStatus() != 0L) { |
||||
throw new ServiceException("流程卡号【"+outEntity.getCardNo()+"】非待出库状态,无法提交出库"); |
||||
} |
||||
|
||||
StRealtimeStock realtimeStock = stRealtimeStockService.getById(outEntity.getRlsId()); |
||||
if (realtimeStock != null) { |
||||
stockList.add(realtimeStock); |
||||
} |
||||
|
||||
if (param.getOutedQuantity() > realtimeStock.getQuantity()) { |
||||
throw new ServiceException("流程卡号【"+outEntity.getCardNo()+"】出库数量不能大于库存总数量,库存数量为:" + realtimeStock.getQuantity()); |
||||
} |
||||
|
||||
outEntity.setRlsId(param.getRlsId()); |
||||
outEntity.setGoodsId(param.getGoodsId()); |
||||
outEntity.setShId(param.getShId()); |
||||
outEntity.setSlId(param.getSlId()); |
||||
outEntity.setOutedQuantity(param.getOutedQuantity()); |
||||
outEntity.setOutUser(userId); |
||||
outEntity.setOutTime(nowDate); |
||||
outEntity.setCurStatus(1L); |
||||
outEntity.setUpdateUser(userId); |
||||
outEntity.setUpdateTime(nowDate); |
||||
outEntity.setPicker(param.getPicker()); |
||||
this.updateById(outEntity); |
||||
|
||||
StStockInoutRecord inoutRecord = new StStockInoutRecord(); |
||||
inoutRecord.setCheckNo(outEntity.getCardNo()); |
||||
inoutRecord.setSirCode(outEntity.getOutCode()); |
||||
inoutRecord.setSlId(outEntity.getSlId()); |
||||
inoutRecord.setRlsId(outEntity.getRlsId()); |
||||
inoutRecord.setShId(outEntity.getShId()); |
||||
inoutRecord.setGoodsId(outEntity.getGoodsId()); |
||||
inoutRecord.setPiNo(realtimeStock.getPiNo()); |
||||
inoutRecord.setStovePiNo(realtimeStock.getStovePiNo()); |
||||
inoutRecord.setQuantity(param.getOutedQuantity()); |
||||
inoutRecord.setUnitPrice(realtimeStock.getBalanceMoney()); |
||||
inoutRecord.setSirMoney(param.getOutedQuantity() * realtimeStock.getBalanceMoney()); |
||||
inoutRecord.setInOutType(StStockInoutRecord.OUT_TYPE); |
||||
|
||||
inoutRecord.setInOutSource(StStockInoutRecord.INOUT_SOURCE_GRAPHITE_MOLD_OUT); |
||||
inoutRecord.setInOutDate(nowDate); |
||||
|
||||
inoutRecord.setUserId(param.getPicker()); |
||||
inoutRecord.setCreateUser(userId); |
||||
inoutRecord.setCreateTime(nowDate); |
||||
inoutRecord.setUpdateUser(userId); |
||||
inoutRecord.setUpdateTime(nowDate); |
||||
|
||||
stStockInoutRecordService.save(inoutRecord); |
||||
allInoutList.add(inoutRecord); |
||||
|
||||
outEntity.setSirId(inoutRecord.getId()); |
||||
this.updateById(outEntity); |
||||
resultList.add(outEntity); |
||||
} |
||||
|
||||
if (!allInoutList.isEmpty() && !stockList.isEmpty()) { |
||||
stRealtimeStockService.reviseRealTimeStock(allInoutList, stockList, null); |
||||
} |
||||
|
||||
return resultList; |
||||
} |
||||
|
||||
@Override |
||||
public List<StGraphiteMoldOutExcel> exportStGraphiteMoldOut(Wrapper<StGraphiteMoldOut> queryWrapper) { |
||||
List<StGraphiteMoldOutExcel> list = baseMapper.exportStGraphiteMoldOut(queryWrapper); |
||||
return list; |
||||
} |
||||
} |
||||
@ -0,0 +1,36 @@ |
||||
package org.springblade.wms.wrapper; |
||||
|
||||
import org.springblade.core.mp.support.BaseEntityWrapper; |
||||
import org.springblade.core.tool.utils.BeanUtil; |
||||
import org.springblade.wms.pojo.entity.StGraphiteMoldOut; |
||||
import org.springblade.wms.pojo.vo.StGraphiteMoldOutVO; |
||||
|
||||
import java.util.Objects; |
||||
|
||||
/** |
||||
* @version 1.0 |
||||
* @program: jonhon-mes-svr |
||||
* @ClassName StGraphiteMoldOutWrapper |
||||
* @description: 石墨模出库 包装类,返回视图层所需的字段 |
||||
* @autor: WuSiYu |
||||
* @create 2025-xx-xx xx:xx |
||||
**/ |
||||
public class StGraphiteMoldOutWrapper extends BaseEntityWrapper<StGraphiteMoldOut, StGraphiteMoldOutVO> { |
||||
|
||||
public static StGraphiteMoldOutWrapper build() { |
||||
return new StGraphiteMoldOutWrapper(); |
||||
} |
||||
|
||||
@Override |
||||
public StGraphiteMoldOutVO entityVO(StGraphiteMoldOut stGraphiteMoldOut) { |
||||
StGraphiteMoldOutVO stGraphiteMoldOutVO = Objects.requireNonNull(BeanUtil.copyProperties(stGraphiteMoldOut, StGraphiteMoldOutVO.class)); |
||||
|
||||
//User createUser = UserCache.getUser(stGraphiteMoldOut.getCreateUser());
|
||||
//User updateUser = UserCache.getUser(stGraphiteMoldOut.getUpdateUser());
|
||||
//stGraphiteMoldOutVO.setCreateUserName(createUser.getName());
|
||||
//stGraphiteMoldOutVO.setUpdateUserName(updateUser.getName());
|
||||
|
||||
return stGraphiteMoldOutVO; |
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue