From 37bc38615b2abbc8ebfa616eaa9104013440b088 Mon Sep 17 00:00:00 2001 From: xins Date: Mon, 15 Apr 2024 14:40:41 +0800 Subject: [PATCH] =?UTF-8?q?2.1.3=20=E7=94=9F=E4=BA=A7=EF=BC=9APDA=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E6=89=98=E7=9B=98=E4=B8=8E=E7=89=A9=E6=96=99=E7=BB=91?= =?UTF-8?q?=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mes/controller/MesMobileController.java | 36 ++++++ .../com/hw/mes/domain/MesBasePalletInfo.java | 103 +++++++++++++++--- .../hw/mes/domain/vo/MesPalletInfoBindVo.java | 25 +++++ .../mes/mapper/MesBasePalletInfoMapper.java | 26 +++-- .../service/IMesBasePalletInfoService.java | 26 +++-- .../impl/MesBasePalletInfoServiceImpl.java | 84 ++++++++++---- .../mapper/mes/MesBasePalletInfoMapper.xml | 51 +++++++-- 7 files changed, 286 insertions(+), 65 deletions(-) create mode 100644 hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesMobileController.java create mode 100644 hw-modules/hw-mes/src/main/java/com/hw/mes/domain/vo/MesPalletInfoBindVo.java diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesMobileController.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesMobileController.java new file mode 100644 index 0000000..2d503ec --- /dev/null +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesMobileController.java @@ -0,0 +1,36 @@ +package com.hw.mes.controller; + +import com.hw.common.core.web.controller.BaseController; +import com.hw.common.core.web.domain.AjaxResult; +import com.hw.common.log.annotation.Log; +import com.hw.common.log.enums.BusinessType; +import com.hw.mes.domain.vo.*; +import com.hw.mes.service.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +/** + * MES手持端接口Controller + * + * @author xins + * @date 2024-04-15 + */ +@RestController +@RequestMapping("/mobile") +public class MesMobileController extends BaseController { + @Autowired + private IMesBasePalletInfoService mesBasePalletInfoService; + + + /** + * 物料条码和托盘码绑定 + */ + @Log(title = "托盘信息", businessType = BusinessType.BIND) + @PostMapping(("/bindPalletInfo")) + public AjaxResult bindPalletInfo(@Validated @RequestBody MesPalletInfoBindVo mesPalletInfoBindVo) { + return success(mesBasePalletInfoService.bindPalletInfo(mesPalletInfoBindVo)); + } + + +} diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesBasePalletInfo.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesBasePalletInfo.java index 4e8976b..c8bfb09 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesBasePalletInfo.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesBasePalletInfo.java @@ -1,5 +1,6 @@ package com.hw.mes.domain; +import java.math.BigDecimal; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.hw.common.core.annotation.Excel; @@ -7,9 +8,9 @@ import com.hw.common.core.web.domain.BaseEntity; /** * 托盘信息对象 mes_base_pallet_info - * + * * @author Yinq - * @date 2024-01-26 + * @date 2024-04-15 */ public class MesBasePalletInfo extends BaseEntity { @@ -18,39 +19,109 @@ public class MesBasePalletInfo extends BaseEntity /** 托盘ID */ private Long palletInfoId; - /** RFID编码 */ - @Excel(name = "RFID编码") + /** 托盘信息RFID编码,不能修改 */ + @Excel(name = "托盘信息RFID编码,不能修改") private String palletInfoCode; - public void setPalletInfoId(Long palletInfoId) + /** 物料ID,关联物料信息主键 */ + @Excel(name = "物料ID,关联物料信息主键") + private Long materialId; + + /** 物料编号 */ + @Excel(name = "物料编号") + private String materialCode; + + /** 物料名称 */ + @Excel(name = "物料名称") + private String materialName; + + /** 物料条码 */ + @Excel(name = "物料条码") + private String materialBarcode; + + /** 绑定数量 */ + @Excel(name = "绑定数量") + private BigDecimal bindAmount; + + public void setPalletInfoId(Long palletInfoId) { this.palletInfoId = palletInfoId; } - public Long getPalletInfoId() + public Long getPalletInfoId() { return palletInfoId; } - public void setPalletInfoCode(String palletInfoCode) + public void setPalletInfoCode(String palletInfoCode) { this.palletInfoCode = palletInfoCode; } - public String getPalletInfoCode() + public String getPalletInfoCode() { return palletInfoCode; } + public void setMaterialId(Long materialId) + { + this.materialId = materialId; + } + + public Long getMaterialId() + { + return materialId; + } + public void setMaterialCode(String materialCode) + { + this.materialCode = materialCode; + } + + public String getMaterialCode() + { + return materialCode; + } + public void setMaterialName(String materialName) + { + this.materialName = materialName; + } + + public String getMaterialName() + { + return materialName; + } + public void setMaterialBarcode(String materialBarcode) + { + this.materialBarcode = materialBarcode; + } + + public String getMaterialBarcode() + { + return materialBarcode; + } + public void setBindAmount(BigDecimal bindAmount) + { + this.bindAmount = bindAmount; + } + + public BigDecimal getBindAmount() + { + return bindAmount; + } @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("palletInfoId", getPalletInfoId()) - .append("palletInfoCode", getPalletInfoCode()) - .append("remark", getRemark()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .toString(); + .append("palletInfoId", getPalletInfoId()) + .append("palletInfoCode", getPalletInfoCode()) + .append("materialId", getMaterialId()) + .append("materialCode", getMaterialCode()) + .append("materialName", getMaterialName()) + .append("materialBarcode", getMaterialBarcode()) + .append("remark", getRemark()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("bindAmount", getBindAmount()) + .toString(); } } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/vo/MesPalletInfoBindVo.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/vo/MesPalletInfoBindVo.java new file mode 100644 index 0000000..94e2e04 --- /dev/null +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/vo/MesPalletInfoBindVo.java @@ -0,0 +1,25 @@ +package com.hw.mes.domain.vo; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + * @Description: 托盘与物料绑定VO对象 + * @ClassName: MesPalletInfoBindVo + * @Author : xins + * @Date :2024-04-15 13:42 + * @Version :1.0 + */ +@Data +public class MesPalletInfoBindVo { + //物料条码 + @NotBlank(message = "物料条码必须输入") + private String materialBarcode; + + //托盘码 + @NotBlank(message = "托盘码必须输入") + private String palletInfoCode; + +} diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesBasePalletInfoMapper.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesBasePalletInfoMapper.java index 4c9606c..a98e3d0 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesBasePalletInfoMapper.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesBasePalletInfoMapper.java @@ -5,15 +5,15 @@ import com.hw.mes.domain.MesBasePalletInfo; /** * 托盘信息Mapper接口 - * + * * @author Yinq * @date 2024-01-26 */ -public interface MesBasePalletInfoMapper +public interface MesBasePalletInfoMapper { /** * 查询托盘信息 - * + * * @param palletInfoId 托盘信息主键 * @return 托盘信息 */ @@ -21,7 +21,7 @@ public interface MesBasePalletInfoMapper /** * 查询托盘信息列表 - * + * * @param mesBasePalletInfo 托盘信息 * @return 托盘信息集合 */ @@ -29,7 +29,7 @@ public interface MesBasePalletInfoMapper /** * 新增托盘信息 - * + * * @param mesBasePalletInfo 托盘信息 * @return 结果 */ @@ -37,7 +37,7 @@ public interface MesBasePalletInfoMapper /** * 修改托盘信息 - * + * * @param mesBasePalletInfo 托盘信息 * @return 结果 */ @@ -45,7 +45,7 @@ public interface MesBasePalletInfoMapper /** * 删除托盘信息 - * + * * @param palletInfoId 托盘信息主键 * @return 结果 */ @@ -53,9 +53,19 @@ public interface MesBasePalletInfoMapper /** * 批量删除托盘信息 - * + * * @param palletInfoIds 需要删除的数据主键集合 * @return 结果 */ public int deleteMesBasePalletInfoByPalletInfoIds(Long[] palletInfoIds); + + + + /** + * 查询托盘信息 + * + * @param palletInfoCode 托盘信息编码 + * @return 托盘信息 + */ + public MesBasePalletInfo selectMesBasePalletInfoByPalletInfoCode(String palletInfoCode); } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesBasePalletInfoService.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesBasePalletInfoService.java index dc3c48f..da31945 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesBasePalletInfoService.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesBasePalletInfoService.java @@ -2,18 +2,20 @@ package com.hw.mes.service; import java.util.List; import com.hw.mes.domain.MesBasePalletInfo; +import com.hw.mes.domain.vo.MesPalletInfoBindVo; +import org.springframework.transaction.annotation.Transactional; /** * 托盘信息Service接口 - * + * * @author Yinq * @date 2024-01-26 */ -public interface IMesBasePalletInfoService +public interface IMesBasePalletInfoService { /** * 查询托盘信息 - * + * * @param palletInfoId 托盘信息主键 * @return 托盘信息 */ @@ -21,7 +23,7 @@ public interface IMesBasePalletInfoService /** * 查询托盘信息列表 - * + * * @param mesBasePalletInfo 托盘信息 * @return 托盘信息集合 */ @@ -29,7 +31,7 @@ public interface IMesBasePalletInfoService /** * 新增托盘信息 - * + * * @param mesBasePalletInfo 托盘信息 * @return 结果 */ @@ -37,7 +39,7 @@ public interface IMesBasePalletInfoService /** * 修改托盘信息 - * + * * @param mesBasePalletInfo 托盘信息 * @return 结果 */ @@ -45,7 +47,7 @@ public interface IMesBasePalletInfoService /** * 批量删除托盘信息 - * + * * @param palletInfoIds 需要删除的托盘信息主键集合 * @return 结果 */ @@ -53,9 +55,17 @@ public interface IMesBasePalletInfoService /** * 删除托盘信息信息 - * + * * @param palletInfoId 托盘信息主键 * @return 结果 */ public int deleteMesBasePalletInfoByPalletInfoId(Long palletInfoId); + + + /** + * 绑定托盘信息 + * @param mesPalletInfoBindVo + * @return + */ + public int bindPalletInfo(MesPalletInfoBindVo mesPalletInfoBindVo); } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBasePalletInfoServiceImpl.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBasePalletInfoServiceImpl.java index 5064ff6..4615f82 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBasePalletInfoServiceImpl.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBasePalletInfoServiceImpl.java @@ -1,59 +1,65 @@ package com.hw.mes.service.impl; +import java.util.Date; import java.util.List; + +import com.hw.common.core.exception.ServiceException; import com.hw.common.core.utils.DateUtils; import com.hw.common.security.utils.SecurityUtils; +import com.hw.mes.api.domain.MesBaseBarcodeInfo; +import com.hw.mes.domain.vo.MesPalletInfoBindVo; +import com.hw.mes.mapper.MesBaseBarcodeInfoMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.hw.mes.mapper.MesBasePalletInfoMapper; import com.hw.mes.domain.MesBasePalletInfo; import com.hw.mes.service.IMesBasePalletInfoService; +import org.springframework.transaction.annotation.Transactional; /** * 托盘信息Service业务层处理 - * + * * @author Yinq * @date 2024-01-26 */ @Service -public class MesBasePalletInfoServiceImpl implements IMesBasePalletInfoService -{ +public class MesBasePalletInfoServiceImpl implements IMesBasePalletInfoService { @Autowired private MesBasePalletInfoMapper mesBasePalletInfoMapper; + @Autowired + private MesBaseBarcodeInfoMapper mesBaseBarcodeInfoMapper; + /** * 查询托盘信息 - * + * * @param palletInfoId 托盘信息主键 * @return 托盘信息 */ @Override - public MesBasePalletInfo selectMesBasePalletInfoByPalletInfoId(Long palletInfoId) - { + public MesBasePalletInfo selectMesBasePalletInfoByPalletInfoId(Long palletInfoId) { return mesBasePalletInfoMapper.selectMesBasePalletInfoByPalletInfoId(palletInfoId); } /** * 查询托盘信息列表 - * + * * @param mesBasePalletInfo 托盘信息 * @return 托盘信息 */ @Override - public List selectMesBasePalletInfoList(MesBasePalletInfo mesBasePalletInfo) - { + public List selectMesBasePalletInfoList(MesBasePalletInfo mesBasePalletInfo) { return mesBasePalletInfoMapper.selectMesBasePalletInfoList(mesBasePalletInfo); } /** * 新增托盘信息 - * + * * @param mesBasePalletInfo 托盘信息 * @return 结果 */ @Override - public int insertMesBasePalletInfo(MesBasePalletInfo mesBasePalletInfo) - { + public int insertMesBasePalletInfo(MesBasePalletInfo mesBasePalletInfo) { mesBasePalletInfo.setCreateTime(DateUtils.getNowDate()); mesBasePalletInfo.setCreateBy(SecurityUtils.getUsername()); return mesBasePalletInfoMapper.insertMesBasePalletInfo(mesBasePalletInfo); @@ -61,13 +67,12 @@ public class MesBasePalletInfoServiceImpl implements IMesBasePalletInfoService /** * 修改托盘信息 - * + * * @param mesBasePalletInfo 托盘信息 * @return 结果 */ @Override - public int updateMesBasePalletInfo(MesBasePalletInfo mesBasePalletInfo) - { + public int updateMesBasePalletInfo(MesBasePalletInfo mesBasePalletInfo) { mesBasePalletInfo.setUpdateTime(DateUtils.getNowDate()); mesBasePalletInfo.setUpdateBy(SecurityUtils.getUsername()); return mesBasePalletInfoMapper.updateMesBasePalletInfo(mesBasePalletInfo); @@ -75,25 +80,62 @@ public class MesBasePalletInfoServiceImpl implements IMesBasePalletInfoService /** * 批量删除托盘信息 - * + * * @param palletInfoIds 需要删除的托盘信息主键 * @return 结果 */ @Override - public int deleteMesBasePalletInfoByPalletInfoIds(Long[] palletInfoIds) - { + public int deleteMesBasePalletInfoByPalletInfoIds(Long[] palletInfoIds) { return mesBasePalletInfoMapper.deleteMesBasePalletInfoByPalletInfoIds(palletInfoIds); } /** * 删除托盘信息信息 - * + * * @param palletInfoId 托盘信息主键 * @return 结果 */ @Override - public int deleteMesBasePalletInfoByPalletInfoId(Long palletInfoId) - { + public int deleteMesBasePalletInfoByPalletInfoId(Long palletInfoId) { return mesBasePalletInfoMapper.deleteMesBasePalletInfoByPalletInfoId(palletInfoId); } + + + /** + * 绑定托盘信息 + * @param mesPalletInfoBindVo + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int bindPalletInfo(MesPalletInfoBindVo mesPalletInfoBindVo) { + String palletInfoCode = mesPalletInfoBindVo.getPalletInfoCode(); + String materialBarcode = mesPalletInfoBindVo.getMaterialBarcode(); + + MesBaseBarcodeInfo mesBaseBarcodeInfo = mesBaseBarcodeInfoMapper.selectMesBaseBarcodeInfoByBarcodeInfo(materialBarcode); + if (mesBaseBarcodeInfo == null) { + throw new ServiceException("物料条码有误"); + } + + MesBasePalletInfo mesBasePalletInfo = mesBasePalletInfoMapper.selectMesBasePalletInfoByPalletInfoCode(palletInfoCode); + if (mesBasePalletInfo == null) { + throw new ServiceException("托盘码有误"); + } + + String userName = SecurityUtils.getUsername(); + Date currentDate = new Date(); + mesBaseBarcodeInfo.setPalletInfoCode(palletInfoCode); + mesBaseBarcodeInfo.setUpdateBy(userName); + mesBaseBarcodeInfo.setUpdateTime(currentDate); + mesBaseBarcodeInfoMapper.updateMesBaseBarcodeInfo(mesBaseBarcodeInfo); + + mesBasePalletInfo.setMaterialBarcode(materialBarcode); + mesBasePalletInfo.setMaterialId(mesBaseBarcodeInfo.getMaterialId()); + mesBasePalletInfo.setMaterialName(mesBaseBarcodeInfo.getMaterialName()); + mesBasePalletInfo.setUpdateBy(userName); + mesBasePalletInfo.setUpdateTime(currentDate); + + return mesBasePalletInfoMapper.updateMesBasePalletInfo(mesBasePalletInfo); + + } } diff --git a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesBasePalletInfoMapper.xml b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesBasePalletInfoMapper.xml index a4a8e5b..6c31e07 100644 --- a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesBasePalletInfoMapper.xml +++ b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesBasePalletInfoMapper.xml @@ -5,18 +5,22 @@ - - - - - - - + + + + + + + + + + + + - select pallet_info_id, pallet_info_code, remark, create_by, create_time, update_by, update_time - from mes_base_pallet_info + select pallet_info_id, pallet_info_code, material_id, material_code, material_name, material_barcode, remark, create_by, create_time, update_by, update_time, bind_amount from mes_base_pallet_info - + insert into mes_base_pallet_info pallet_info_code, + material_id, + material_code, + material_name, + material_barcode, remark, create_by, create_time, update_by, update_time, + bind_amount, #{palletInfoCode}, + #{materialId}, + #{materialCode}, + #{materialName}, + #{materialBarcode}, #{remark}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime}, + #{bindAmount}, @@ -56,11 +69,16 @@ update mes_base_pallet_info pallet_info_code = #{palletInfoCode}, + material_id = #{materialId}, + material_code = #{materialCode}, + material_name = #{materialName}, + material_barcode = #{materialBarcode}, remark = #{remark}, create_by = #{createBy}, create_time = #{createTime}, update_by = #{updateBy}, update_time = #{updateTime}, + bind_amount = #{bindAmount}, where pallet_info_id = #{palletInfoId} @@ -77,4 +95,13 @@ #{palletInfoId} - \ No newline at end of file + + + + + + +