From 0f51415b641e5b9ca1299ecb6458835cfe5862d9 Mon Sep 17 00:00:00 2001 From: wenshijun Date: Wed, 4 Jun 2025 11:34:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A5=E5=BA=93=E7=9B=B8=E5=85=B3=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=BC=80=E5=8F=912.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PcdeDetailController.java | 4 +- .../service/IPcdeDetailService.java | 7 + .../service/impl/PcdeDetailServiceImpl.java | 20 ++ .../wisdom/controller/RkInfoController.java | 7 +- .../controller/app/AppRkInfoController.java | 97 +++++++ .../com/zg/project/wisdom/domain/RkInfo.java | 13 + .../wisdom/domain/dto/PcRkInfoBatchDTO.java | 64 +++++ .../wisdom/domain/dto/PcRkInfoItemDTO.java | 242 ++++++++++++++++++ .../wisdom/domain/dto/RkInfoBatchDTO.java | 1 - .../wisdom/domain/dto/RkInfoItemDTO.java | 141 +++++++++- .../wisdom/domain/dto/RkInfoScanDTO.java | 16 +- .../zg/project/wisdom/mapper/GysJhMapper.java | 6 + .../project/wisdom/mapper/RkInfoMapper.java | 7 + .../wisdom/service/IRkInfoService.java | 12 +- .../service/impl/RkInfoServiceImpl.java | 139 +++++++++- .../project/wisdom/util/CodeConvertUtil.java | 42 +++ .../resources/mybatis/wisdom/GysJhMapper.xml | 7 + .../resources/mybatis/wisdom/RkInfoMapper.xml | 20 +- 18 files changed, 812 insertions(+), 33 deletions(-) create mode 100644 src/main/java/com/zg/project/wisdom/controller/app/AppRkInfoController.java create mode 100644 src/main/java/com/zg/project/wisdom/domain/dto/PcRkInfoBatchDTO.java create mode 100644 src/main/java/com/zg/project/wisdom/domain/dto/PcRkInfoItemDTO.java create mode 100644 src/main/java/com/zg/project/wisdom/util/CodeConvertUtil.java diff --git a/src/main/java/com/zg/project/information/controller/PcdeDetailController.java b/src/main/java/com/zg/project/information/controller/PcdeDetailController.java index 3cebb53..4db4863 100644 --- a/src/main/java/com/zg/project/information/controller/PcdeDetailController.java +++ b/src/main/java/com/zg/project/information/controller/PcdeDetailController.java @@ -43,13 +43,13 @@ public class PcdeDetailController extends BaseController } /** - * 查询全部库位明细列表 + * 获取未被入库单据使用的库位列表 */ @PreAuthorize("@ss.hasPermi('information:pcdedetail:list')") @GetMapping("/getAll") public AjaxResult getAll() { - List list = pcdeDetailService.selectPcdeDetailList(new PcdeDetail()); + List list = pcdeDetailService.getAllPcde(); return success(list); } diff --git a/src/main/java/com/zg/project/information/service/IPcdeDetailService.java b/src/main/java/com/zg/project/information/service/IPcdeDetailService.java index 88256e3..2d51e6f 100644 --- a/src/main/java/com/zg/project/information/service/IPcdeDetailService.java +++ b/src/main/java/com/zg/project/information/service/IPcdeDetailService.java @@ -66,4 +66,11 @@ public interface IPcdeDetailService * @return */ String importPcdeDetail(List list, String operName); + + /** + * 获取未被入库单据使用的库位列表 + * @return + */ + List getAllPcde(); + } diff --git a/src/main/java/com/zg/project/information/service/impl/PcdeDetailServiceImpl.java b/src/main/java/com/zg/project/information/service/impl/PcdeDetailServiceImpl.java index b1dbb56..82a9f58 100644 --- a/src/main/java/com/zg/project/information/service/impl/PcdeDetailServiceImpl.java +++ b/src/main/java/com/zg/project/information/service/impl/PcdeDetailServiceImpl.java @@ -1,6 +1,7 @@ package com.zg.project.information.service.impl; import java.util.List; +import java.util.stream.Collectors; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.zg.common.exception.ServiceException; @@ -183,4 +184,23 @@ public class PcdeDetailServiceImpl implements IPcdeDetailService return "恭喜您,数据已全部导入成功!共 " + successNum + " 条。"; } } + + /** + * 获取未被入库单据使用的库位列表 + */ + @Override + public List getAllPcde() { + // 查询所有库位 + List pcdeList = pcdeDetailMapper.selectPcdeDetailList(new PcdeDetail()); + + // 查询已被使用过的库位码(pcode) + List usedPcodeList = rkInfoMapper.selectUsedPcodes(); + + // 过滤掉已使用的 + List availableList = pcdeList.stream() + .filter(p -> !usedPcodeList.contains(p.getLocationCode())) + .collect(Collectors.toList()); + + return availableList; + } } diff --git a/src/main/java/com/zg/project/wisdom/controller/RkInfoController.java b/src/main/java/com/zg/project/wisdom/controller/RkInfoController.java index 2485264..8de6071 100644 --- a/src/main/java/com/zg/project/wisdom/controller/RkInfoController.java +++ b/src/main/java/com/zg/project/wisdom/controller/RkInfoController.java @@ -3,6 +3,7 @@ package com.zg.project.wisdom.controller; import java.util.List; import javax.servlet.http.HttpServletResponse; +import com.zg.project.wisdom.domain.dto.PcRkInfoBatchDTO; import com.zg.project.wisdom.domain.dto.RkInfoBatchDTO; import com.zg.project.wisdom.service.IGysJhService; import org.springframework.security.access.prepost.PreAuthorize; @@ -31,7 +32,7 @@ import com.zg.framework.web.page.TableDataInfo; * @date 2025-05-28 */ @RestController -@RequestMapping("/wisdom/stock") +@RequestMapping("/pc/wisdom/stock") public class RkInfoController extends BaseController { @Autowired @@ -75,10 +76,10 @@ public class RkInfoController extends BaseController /** * 新增库存单据主 */ + @PostMapping("/add") @PreAuthorize("@ss.hasPermi('wisdom:stock:add')") @Log(title = "库存单据主", businessType = BusinessType.INSERT) - @PostMapping("/add") - public AjaxResult batchAdd(@RequestBody RkInfoBatchDTO dto) { + public AjaxResult batchAdd(@RequestBody PcRkInfoBatchDTO dto) { return toAjax(rkInfoService.batchInsert(dto)); } diff --git a/src/main/java/com/zg/project/wisdom/controller/app/AppRkInfoController.java b/src/main/java/com/zg/project/wisdom/controller/app/AppRkInfoController.java new file mode 100644 index 0000000..426f60b --- /dev/null +++ b/src/main/java/com/zg/project/wisdom/controller/app/AppRkInfoController.java @@ -0,0 +1,97 @@ +package com.zg.project.wisdom.controller.app; + +import com.zg.common.utils.poi.ExcelUtil; +import com.zg.framework.aspectj.lang.annotation.Log; +import com.zg.framework.aspectj.lang.enums.BusinessType; +import com.zg.framework.web.controller.BaseController; +import com.zg.framework.web.domain.AjaxResult; +import com.zg.framework.web.page.TableDataInfo; +import com.zg.project.wisdom.domain.RkInfo; +import com.zg.project.wisdom.domain.dto.RkInfoBatchDTO; +import com.zg.project.wisdom.service.IRkInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +/** + * 库存单据主Controller + * + * @author zg + * @date 2025-05-28 + */ +@RestController +@RequestMapping("/wisdom/stock") +public class AppRkInfoController extends BaseController { + @Autowired + private IRkInfoService rkInfoService; + + /** + * 查询库存单据主列表 + */ + @PreAuthorize("@ss.hasPermi('wisdom:stock:list')") + @GetMapping("/list") + public TableDataInfo list(RkInfo rkInfo) + { + startPage(); + List list = rkInfoService.selectRkInfoList(rkInfo); + return getDataTable(list); + } + + /** + * 导出库存单据主列表 + */ + @PreAuthorize("@ss.hasPermi('wisdom:stock:export')") + @Log(title = "库存单据主", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, RkInfo rkInfo) + { + List list = rkInfoService.selectRkInfoList(rkInfo); + ExcelUtil util = new ExcelUtil(RkInfo.class); + util.exportExcel(response, list, "库存单据主数据"); + } + + /** + * 获取库存单据主详细信息 + */ + @PreAuthorize("@ss.hasPermi('wisdom:stock:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(rkInfoService.selectRkInfoById(id)); + } + + /** + * 新增库存单据主 + */ + @PreAuthorize("@ss.hasPermi('wisdom:stock:add')") + @Log(title = "库存单据主", businessType = BusinessType.INSERT) + @PostMapping("/add") + public AjaxResult batchAdd(@RequestBody RkInfoBatchDTO dto) { + return toAjax(rkInfoService.batchInsertApp(dto)); + } + + /** + * 修改库存单据主 + */ + @PreAuthorize("@ss.hasPermi('wisdom:stock:edit')") + @Log(title = "库存单据主", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody RkInfo rkInfo) + { + return toAjax(rkInfoService.updateRkInfo(rkInfo)); + } + + /** + * 删除库存单据主 + */ + @PreAuthorize("@ss.hasPermi('wisdom:stock:remove')") + @Log(title = "库存单据主", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(rkInfoService.deleteRkInfoByIds(ids)); + } +} diff --git a/src/main/java/com/zg/project/wisdom/domain/RkInfo.java b/src/main/java/com/zg/project/wisdom/domain/RkInfo.java index 2d73a09..3d640d2 100644 --- a/src/main/java/com/zg/project/wisdom/domain/RkInfo.java +++ b/src/main/java/com/zg/project/wisdom/domain/RkInfo.java @@ -121,6 +121,10 @@ public class RkInfo extends BaseEntity @Excel(name = "库位码") private String pcode; + /** 库位主键ID */ + @Excel(name = "库位主键ID") + private String pcodeId; + /** 托盘码 */ @Excel(name = "托盘码") private String trayCode; @@ -384,6 +388,14 @@ public class RkInfo extends BaseEntity return pcode; } + public void setPcodeId(String pcodeId) { + this.pcodeId = pcodeId; + } + + public String getPcodeId() { + return pcodeId; + } + public void setTrayCode(String trayCode) { this.trayCode = trayCode; @@ -441,6 +453,7 @@ public class RkInfo extends BaseEntity .append("dw", getDw()) .append("realQty", getRealQty()) .append("pcode", getPcode()) + .append("pcodeId", getPcodeId()) .append("trayCode", getTrayCode()) .append("entityId", getEntityId()) .append("createBy", getCreateBy()) diff --git a/src/main/java/com/zg/project/wisdom/domain/dto/PcRkInfoBatchDTO.java b/src/main/java/com/zg/project/wisdom/domain/dto/PcRkInfoBatchDTO.java new file mode 100644 index 0000000..74b680c --- /dev/null +++ b/src/main/java/com/zg/project/wisdom/domain/dto/PcRkInfoBatchDTO.java @@ -0,0 +1,64 @@ +package com.zg.project.wisdom.domain.dto; + +import java.util.List; + +/** + * PC端 - 入库请求 DTO + */ +public class PcRkInfoBatchDTO { + + /** 入库类型 */ + private String rkType; + + /** 物资类型 */ + private String wlType; + + /** 理货员 */ + private String lihuoY; + + /** 所属仓库 */ + private String cangku; + + /** 入库记录列表(每条为完整入库项) */ + private List rkList; + + public String getRkType() { + return rkType; + } + + public void setRkType(String rkType) { + this.rkType = rkType; + } + + public String getWlType() { + return wlType; + } + + public void setWlType(String wlType) { + this.wlType = wlType; + } + + public String getLihuoY() { + return lihuoY; + } + + public void setLihuoY(String lihuoY) { + this.lihuoY = lihuoY; + } + + public String getCangku() { + return cangku; + } + + public void setCangku(String cangku) { + this.cangku = cangku; + } + + public List getRkList() { + return rkList; + } + + public void setRkList(List rkList) { + this.rkList = rkList; + } +} diff --git a/src/main/java/com/zg/project/wisdom/domain/dto/PcRkInfoItemDTO.java b/src/main/java/com/zg/project/wisdom/domain/dto/PcRkInfoItemDTO.java new file mode 100644 index 0000000..18f5f4b --- /dev/null +++ b/src/main/java/com/zg/project/wisdom/domain/dto/PcRkInfoItemDTO.java @@ -0,0 +1,242 @@ +package com.zg.project.wisdom.domain.dto; + +import java.math.BigDecimal; + +/** + * PC端 - 入库明细 DTO(字段驼峰命名规范) + */ +public class PcRkInfoItemDTO { + + /** 县局 */ + private String xj; + + /** 供应计划主键ID */ + private Long gysJhId; + + /** 本地物料号 */ + private String wlNo; + + /** 项目描述 */ + private String xmMs; + + /** 项目号 */ + private String xmNo; + + /** SAP物料号 */ + private String sapWlNo; + + /** SAP物料描述 */ + private String sapWlMs; + + /** 供应商编码 */ + private String gysNo; + + /** 供应商名称 */ + private String gysMc; + + /** SAP订单编号 */ + private String sapNo; + + /** 计划交货数量 */ + private Long jhQty; + + /** 合同数量 */ + private Long htQty; + + /** 计量单位 */ + private String dw; + + /** 计划交货金额 */ + private BigDecimal jhAmt; + + /** 合同单价 */ + private BigDecimal htDj; + + /** 实际入库数量 */ + private Long realQty; + + /** 库位码 */ + private String pcode; + + /** 库位主键ID */ + private String pcodeId; + + /** 托盘码 */ + private String trayCode; + + /** 实物 ID */ + private String entityId; + + /** 备注 */ + private String remark; + + // ======= Getter / Setter ======= + + public String getXj() { + return xj; + } + + public void setXj(String xj) { + this.xj = xj; + } + + public Long getGysJhId() { + return gysJhId; + } + + public void setGysJhId(Long gysJhId) { + this.gysJhId = gysJhId; + } + + public String getWlNo() { + return wlNo; + } + + public void setWlNo(String wlNo) { + this.wlNo = wlNo; + } + + public String getXmMs() { + return xmMs; + } + + public void setXmMs(String xmMs) { + this.xmMs = xmMs; + } + + public String getXmNo() { + return xmNo; + } + + public void setXmNo(String xmNo) { + this.xmNo = xmNo; + } + + public String getSapWlNo() { + return sapWlNo; + } + + public void setSapWlNo(String sapWlNo) { + this.sapWlNo = sapWlNo; + } + + public String getSapWlMs() { + return sapWlMs; + } + + public void setSapWlMs(String sapWlMs) { + this.sapWlMs = sapWlMs; + } + + public String getGysNo() { + return gysNo; + } + + public void setGysNo(String gysNo) { + this.gysNo = gysNo; + } + + public String getGysMc() { + return gysMc; + } + + public void setGysMc(String gysMc) { + this.gysMc = gysMc; + } + + public String getSapNo() { + return sapNo; + } + + public void setSapNo(String sapNo) { + this.sapNo = sapNo; + } + + public Long getJhQty() { + return jhQty; + } + + public void setJhQty(Long jhQty) { + this.jhQty = jhQty; + } + + public Long getHtQty() { + return htQty; + } + + public void setHtQty(Long htQty) { + this.htQty = htQty; + } + + public String getDw() { + return dw; + } + + public void setDw(String dw) { + this.dw = dw; + } + + public BigDecimal getJhAmt() { + return jhAmt; + } + + public void setJhAmt(BigDecimal jhAmt) { + this.jhAmt = jhAmt; + } + + public BigDecimal getHtDj() { + return htDj; + } + + public void setHtDj(BigDecimal htDj) { + this.htDj = htDj; + } + + public Long getRealQty() { + return realQty; + } + + public void setRealQty(Long realQty) { + this.realQty = realQty; + } + + public String getPcode() { + return pcode; + } + + public void setPcode(String pcode) { + this.pcode = pcode; + } + + public String getPcodeId() { + return pcodeId; + } + + public void setPcodeId(String pcodeId) { + this.pcodeId = pcodeId; + } + + public String getTrayCode() { + return trayCode; + } + + public void setTrayCode(String trayCode) { + this.trayCode = trayCode; + } + + public String getEntityId() { + return entityId; + } + + public void setEntityId(String entityId) { + this.entityId = entityId; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } +} diff --git a/src/main/java/com/zg/project/wisdom/domain/dto/RkInfoBatchDTO.java b/src/main/java/com/zg/project/wisdom/domain/dto/RkInfoBatchDTO.java index 6342b70..a86114e 100644 --- a/src/main/java/com/zg/project/wisdom/domain/dto/RkInfoBatchDTO.java +++ b/src/main/java/com/zg/project/wisdom/domain/dto/RkInfoBatchDTO.java @@ -19,7 +19,6 @@ public class RkInfoBatchDTO { /** 入库物料列表 */ private List rkList; - // Getters and Setters public String getRkType() { return rkType; } diff --git a/src/main/java/com/zg/project/wisdom/domain/dto/RkInfoItemDTO.java b/src/main/java/com/zg/project/wisdom/domain/dto/RkInfoItemDTO.java index 58f0367..68167a6 100644 --- a/src/main/java/com/zg/project/wisdom/domain/dto/RkInfoItemDTO.java +++ b/src/main/java/com/zg/project/wisdom/domain/dto/RkInfoItemDTO.java @@ -1,19 +1,66 @@ package com.zg.project.wisdom.domain.dto; +import java.math.BigDecimal; import java.util.List; +/** + * APP端 - 入库明细 DTO + */ public class RkInfoItemDTO { - /** 物料号 */ + /** 供应计划主键ID */ + private Long gysJhId; + + /** SAP物料号(数据库字段 wl_no) */ private String wlNo; + /** SAP物料描述(数据库字段 wl_ms) */ + private String wlMs; + + /** 项目号(数据库字段 xm_no) */ + private String xmNo; + /** 项目描述 */ private String xmMs; - /** 扫码记录列表 */ + /** 县局 */ + private String xj; + + /** 供应商编码 */ + private String gysNo; + + /** 供应商名称 */ + private String gysMc; + + /** SAP订单编号 */ + private String sapNo; + + /** 计划交货数量 */ + private Long jhQty; + + /** 合同数量 */ + private Long htQty; + + /** 计量单位 */ + private String dw; + + /** 计划交货金额 */ + private BigDecimal jhAmt; + + /** 合同单价 */ + private BigDecimal htDj; + + /** 实物扫码记录列表 */ private List scanList; - // Getters and Setters + public Long getGysJhId() { + return gysJhId; + } + + public void setGysJhId(Long gysJhId) { + this.gysJhId = gysJhId; + } + public String getWlNo() { return wlNo; } @@ -22,6 +69,22 @@ public class RkInfoItemDTO { this.wlNo = wlNo; } + public String getWlMs() { + return wlMs; + } + + public void setWlMs(String wlMs) { + this.wlMs = wlMs; + } + + public String getXmNo() { + return xmNo; + } + + public void setXmNo(String xmNo) { + this.xmNo = xmNo; + } + public String getXmMs() { return xmMs; } @@ -30,6 +93,78 @@ public class RkInfoItemDTO { this.xmMs = xmMs; } + public String getXj() { + return xj; + } + + public void setXj(String xj) { + this.xj = xj; + } + + public String getGysNo() { + return gysNo; + } + + public void setGysNo(String gysNo) { + this.gysNo = gysNo; + } + + public String getGysMc() { + return gysMc; + } + + public void setGysMc(String gysMc) { + this.gysMc = gysMc; + } + + public String getSapNo() { + return sapNo; + } + + public void setSapNo(String sapNo) { + this.sapNo = sapNo; + } + + public Long getJhQty() { + return jhQty; + } + + public void setJhQty(Long jhQty) { + this.jhQty = jhQty; + } + + public Long getHtQty() { + return htQty; + } + + public void setHtQty(Long htQty) { + this.htQty = htQty; + } + + public String getDw() { + return dw; + } + + public void setDw(String dw) { + this.dw = dw; + } + + public BigDecimal getJhAmt() { + return jhAmt; + } + + public void setJhAmt(BigDecimal jhAmt) { + this.jhAmt = jhAmt; + } + + public BigDecimal getHtDj() { + return htDj; + } + + public void setHtDj(BigDecimal htDj) { + this.htDj = htDj; + } + public List getScanList() { return scanList; } diff --git a/src/main/java/com/zg/project/wisdom/domain/dto/RkInfoScanDTO.java b/src/main/java/com/zg/project/wisdom/domain/dto/RkInfoScanDTO.java index 6dcd4cf..dfcb77d 100644 --- a/src/main/java/com/zg/project/wisdom/domain/dto/RkInfoScanDTO.java +++ b/src/main/java/com/zg/project/wisdom/domain/dto/RkInfoScanDTO.java @@ -5,19 +5,21 @@ public class RkInfoScanDTO { /** 库位码 */ private String pcode; + /** 库位主键ID */ + private String pcodeId; + /** 托盘码 */ private String trayCode; - /** 实际入库数量 */ + /** 实际数量 */ private Long realQty; - /** 实物ID */ + /** 实物 ID */ private String entityId; /** 备注 */ private String remark; - // Getters and Setters public String getPcode() { return pcode; } @@ -26,6 +28,14 @@ public class RkInfoScanDTO { this.pcode = pcode; } + public String getPcodeId() { + return pcodeId; + } + + public void setPcodeId(String pcodeId) { + this.pcodeId = pcodeId; + } + public String getTrayCode() { return trayCode; } diff --git a/src/main/java/com/zg/project/wisdom/mapper/GysJhMapper.java b/src/main/java/com/zg/project/wisdom/mapper/GysJhMapper.java index c7c0314..db16e54 100644 --- a/src/main/java/com/zg/project/wisdom/mapper/GysJhMapper.java +++ b/src/main/java/com/zg/project/wisdom/mapper/GysJhMapper.java @@ -65,4 +65,10 @@ public interface GysJhMapper * @return */ List getBySapNo(String sapNo); + + /** + * 修改状态 + * @param gysJhId + */ + void updateStatusById(Long gysJhId); } diff --git a/src/main/java/com/zg/project/wisdom/mapper/RkInfoMapper.java b/src/main/java/com/zg/project/wisdom/mapper/RkInfoMapper.java index fe39ed6..158da6f 100644 --- a/src/main/java/com/zg/project/wisdom/mapper/RkInfoMapper.java +++ b/src/main/java/com/zg/project/wisdom/mapper/RkInfoMapper.java @@ -66,4 +66,11 @@ public interface RkInfoMapper * @return */ int countRkInfoByLocationCode(@Param("locationCode") String locationCode); + + /** + * 查询已使用库位 + * @return + */ + List selectUsedPcodes(); + } diff --git a/src/main/java/com/zg/project/wisdom/service/IRkInfoService.java b/src/main/java/com/zg/project/wisdom/service/IRkInfoService.java index 09cbc6b..a415b60 100644 --- a/src/main/java/com/zg/project/wisdom/service/IRkInfoService.java +++ b/src/main/java/com/zg/project/wisdom/service/IRkInfoService.java @@ -2,6 +2,7 @@ package com.zg.project.wisdom.service; import java.util.List; import com.zg.project.wisdom.domain.RkInfo; +import com.zg.project.wisdom.domain.dto.PcRkInfoBatchDTO; import com.zg.project.wisdom.domain.dto.RkInfoBatchDTO; /** @@ -54,9 +55,16 @@ public interface IRkInfoService public int deleteRkInfoById(Long id); /** - * 新增入库单据 + * PC新增入库单据 * @param dto * @return */ - int batchInsert(RkInfoBatchDTO dto); + int batchInsert(PcRkInfoBatchDTO dto); + + /** + * APP新增入库单据 + * @param dto + * @return + */ + int batchInsertApp(RkInfoBatchDTO dto); } diff --git a/src/main/java/com/zg/project/wisdom/service/impl/RkInfoServiceImpl.java b/src/main/java/com/zg/project/wisdom/service/impl/RkInfoServiceImpl.java index 506a406..a35e09c 100644 --- a/src/main/java/com/zg/project/wisdom/service/impl/RkInfoServiceImpl.java +++ b/src/main/java/com/zg/project/wisdom/service/impl/RkInfoServiceImpl.java @@ -3,19 +3,23 @@ package com.zg.project.wisdom.service.impl; import java.util.ArrayList; import java.util.Date; import java.util.List; + +import com.zg.common.exception.ServiceException; import com.zg.common.utils.DateUtils; import com.zg.common.utils.SecurityUtils; import com.zg.project.wisdom.domain.GysJh; -import com.zg.project.wisdom.domain.dto.RkInfoBatchDTO; -import com.zg.project.wisdom.domain.dto.RkInfoItemDTO; -import com.zg.project.wisdom.domain.dto.RkInfoScanDTO; +import com.zg.project.wisdom.domain.dto.*; +import com.zg.project.wisdom.mapper.GysJhMapper; import com.zg.project.wisdom.service.IGysJhService; +import com.zg.project.wisdom.util.CodeConvertUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.zg.project.wisdom.mapper.RkInfoMapper; import com.zg.project.wisdom.domain.RkInfo; import com.zg.project.wisdom.service.IRkInfoService; +import static com.zg.common.utils.SecurityUtils.getUsername; + /** * 库存单据主Service业务层处理 * @@ -29,6 +33,9 @@ public class RkInfoServiceImpl implements IRkInfoService @Autowired private RkInfoMapper rkInfoMapper; + @Autowired + private GysJhMapper gysJhMapper; + /** * 查询库存单据主 * @@ -97,44 +104,148 @@ public class RkInfoServiceImpl implements IRkInfoService * @return */ @Override - public int batchInsert(RkInfoBatchDTO dto) { + public int batchInsert(PcRkInfoBatchDTO dto) { List saveList = new ArrayList<>(); - String username = SecurityUtils.getUsername(); // 获取当前登录用户 - Date now = DateUtils.getNowDate(); // 当前时间 + String username = SecurityUtils.getUsername(); + Date now = DateUtils.getNowDate(); + + if (dto.getRkList() == null || dto.getRkList().isEmpty()) { + throw new ServiceException("rkList 入库明细列表不能为空"); + } + + for (PcRkInfoItemDTO item : dto.getRkList()) { + RkInfo entity = new RkInfo(); + + // 顶层字段 + entity.setRkType(dto.getRkType()); + entity.setWlType(dto.getWlType()); + entity.setCangku(dto.getCangku()); + entity.setLihuoY(dto.getLihuoY()); + + // 明细字段(item) + entity.setXj(item.getXj()); + entity.setXmNo(item.getXmNo()); + entity.setXmMs(item.getXmMs()); + entity.setSapNo(item.getSapNo()); + entity.setJhQty(item.getJhQty()); + entity.setHtQty(item.getHtQty()); + entity.setJhAmt(item.getJhAmt()); + entity.setHtDj(item.getHtDj()); + entity.setDw(item.getDw()); + entity.setWlNo(item.getWlNo()); +// entity.setWlMs(item.getWlMs()); + entity.setGysNo(item.getGysNo()); + entity.setGysMc(item.getGysMc()); + + // 库存字段 + entity.setRealQty(item.getRealQty()); + entity.setPcode(item.getPcode()); + if (item.getPcode() != null) { + entity.setPcodeId(CodeConvertUtil.stringToHex(item.getPcode())); + } + entity.setTrayCode(item.getTrayCode()); + entity.setEntityId(item.getEntityId()); + entity.setRemark(item.getRemark()); + + // 系统字段 + entity.setIsChuku("0"); + entity.setIsDelete("0"); + entity.setRkTime(now); + entity.setCreateBy(username); + entity.setCreateTime(now); + + saveList.add(entity); + + // 更新供应计划状态 + if (item.getGysJhId() != null) { + gysJhMapper.updateStatusById(item.getGysJhId()); + } + } + + if (saveList.isEmpty()) { + throw new ServiceException("未提取到任何可保存的数据"); + } + + return rkInfoMapper.batchInsertRkInfo(saveList); + } + + /** + * 新增入库单据(APP) + * @param dto + * @return + */ + @Override + public int batchInsertApp(RkInfoBatchDTO dto) { + List saveList = new ArrayList<>(); + String username = SecurityUtils.getUsername(); + Date now = DateUtils.getNowDate(); + + if (dto.getRkList() == null || dto.getRkList().isEmpty()) { + throw new ServiceException("rkList 入库明细列表不能为空"); + } for (RkInfoItemDTO item : dto.getRkList()) { - for (RkInfoScanDTO scan : item.getScanList()) { + List scanList = item.getScanList(); + if (scanList == null || scanList.isEmpty()) { + continue; + } + + for (RkInfoScanDTO scan : scanList) { + RkInfo entity = new RkInfo(); - // ======= 来自最外层 DTO ======= + // 批次字段 entity.setRkType(dto.getRkType()); entity.setWlType(dto.getWlType()); entity.setCangku(dto.getCangku()); entity.setLihuoY(dto.getLihuoY()); - // ======= 中层 DTO ======= - entity.setWlNo(item.getWlNo()); + // 明细字段(RkInfoItemDTO) + entity.setXj(item.getXj()); entity.setXmMs(item.getXmMs()); + entity.setXmNo(item.getXmNo()); + entity.setSapNo(item.getSapNo()); + entity.setJhQty(item.getJhQty()); + entity.setHtQty(item.getHtQty()); + entity.setJhAmt(item.getJhAmt()); + entity.setHtDj(item.getHtDj()); + entity.setDw(item.getDw()); + entity.setWlNo(item.getWlNo()); + entity.setWlMs(item.getWlMs()); + entity.setGysNo(item.getGysNo()); + entity.setGysMc(item.getGysMc()); - // ======= 最内层 DTO ======= + // 扫码记录(RkInfoScanDTO) entity.setPcode(scan.getPcode()); + if (scan.getPcode() != null) { + entity.setPcodeId(CodeConvertUtil.stringToHex(scan.getPcode())); + } entity.setTrayCode(scan.getTrayCode()); entity.setRealQty(scan.getRealQty()); entity.setEntityId(scan.getEntityId()); entity.setRemark(scan.getRemark()); - // ======= 系统默认字段 ======= - entity.setIsChuku("0"); + // 系统字段 entity.setIsDelete("0"); + entity.setIsChuku("0"); entity.setRkTime(now); entity.setCreateBy(username); entity.setCreateTime(now); saveList.add(entity); } + + // 每个 item 的 供应计划主键ID 更新一次供应计划状态 + if (item.getGysJhId() != null) { + gysJhMapper.updateStatusById(item.getGysJhId()); + } + + } + + if (saveList.isEmpty()) { + throw new ServiceException("未提取到任何可保存的数据"); } - // 批量插入到数据库 return rkInfoMapper.batchInsertRkInfo(saveList); } diff --git a/src/main/java/com/zg/project/wisdom/util/CodeConvertUtil.java b/src/main/java/com/zg/project/wisdom/util/CodeConvertUtil.java new file mode 100644 index 0000000..8f73dee --- /dev/null +++ b/src/main/java/com/zg/project/wisdom/util/CodeConvertUtil.java @@ -0,0 +1,42 @@ +package com.zg.project.wisdom.util; + +/** + * 编码转换工具类 - 处理如库位码转十六进制字符串等逻辑 + */ +public class CodeConvertUtil { + + /** + * 将字符串转为十六进制字符串(如用于生成库位ID) + * @param input 原始字符串,例如 "A01-013004" + * @return 十六进制字符串,例如 "4130312D303133303034" + */ + public static String stringToHex(String input) { + if (input == null) { + return null; + } + + StringBuilder hex = new StringBuilder(); + for (char ch : input.toCharArray()) { + hex.append(String.format("%02X", (int) ch)); + } + return hex.toString(); + } + + /** + * 可选:将十六进制字符串转换回原始字符串 + * @param hex 十六进制字符串 + * @return 原始字符串 + */ + public static String hexToString(String hex) { + if (hex == null || hex.length() % 2 != 0) { + return null; + } + + StringBuilder output = new StringBuilder(); + for (int i = 0; i < hex.length(); i += 2) { + String str = hex.substring(i, i + 2); + output.append((char) Integer.parseInt(str, 16)); + } + return output.toString(); + } +} diff --git a/src/main/resources/mybatis/wisdom/GysJhMapper.xml b/src/main/resources/mybatis/wisdom/GysJhMapper.xml index de9283a..a80d709 100644 --- a/src/main/resources/mybatis/wisdom/GysJhMapper.xml +++ b/src/main/resources/mybatis/wisdom/GysJhMapper.xml @@ -54,6 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -137,6 +138,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} + + update gys_jh + set status = '1' + where id = #{id} + + delete from gys_jh where id = #{id} diff --git a/src/main/resources/mybatis/wisdom/RkInfoMapper.xml b/src/main/resources/mybatis/wisdom/RkInfoMapper.xml index 7bea50a..84785f7 100644 --- a/src/main/resources/mybatis/wisdom/RkInfoMapper.xml +++ b/src/main/resources/mybatis/wisdom/RkInfoMapper.xml @@ -62,20 +62,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" insert into rk_info ( rk_type, wl_type, cangku, lihuo_y, rk_time, - wl_no, xm_ms, pcode, tray_code, real_qty, entity_id, + wl_no, wl_ms, xm_no, xm_ms, xj, sap_no, gys_no, gys_mc, + jh_qty, ht_qty, jh_amt, ht_dj, dw, + pcode, pcode_id, tray_code, real_qty, entity_id, remark, is_chuku, is_delete, create_by, create_time ) values ( #{item.rkType}, #{item.wlType}, #{item.cangku}, #{item.lihuoY}, #{item.rkTime}, - #{item.wlNo}, #{item.xmMs}, #{item.pcode}, #{item.trayCode}, #{item.realQty}, #{item.entityId}, + #{item.wlNo}, #{item.wlMs}, #{item.xmNo}, #{item.xmMs}, #{item.xj}, #{item.sapNo}, #{item.gysNo}, #{item.gysMc}, + #{item.jhQty}, #{item.htQty}, #{item.jhAmt}, #{item.htDj}, #{item.dw}, + #{item.pcode}, #{item.pcodeId}, #{item.trayCode}, #{item.realQty}, #{item.entityId}, #{item.remark}, #{item.isChuku}, #{item.isDelete}, #{item.createBy}, #{item.createTime} ) - - + + + + update rk_info