From 03a056f18d5e4444ae83a3ef492a87c3fbf77d02 Mon Sep 17 00:00:00 2001 From: philip <244793088@qq.com> Date: Fri, 13 Aug 2021 15:38:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=A5=E5=B7=A5=E6=8E=A5=E5=8F=A3=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AccessoryLogController.java | 26 ++++++ .../production/mapper/AccessoryLogMapper.java | 3 + .../mesnac/production/model/AccessoryLog.java | 17 +++- .../service/AccessoryLogService.java | 4 + .../service/impl/AccessoryLogServiceImpl.java | 93 ++++++++++++++++++- .../service/impl/PodTemplateServiceImpl.java | 13 +-- .../resources/mapper/AccessoryLogMapper.xml | 8 +- 7 files changed, 149 insertions(+), 15 deletions(-) diff --git a/production/src/main/java/com/foreverwin/mesnac/production/controller/AccessoryLogController.java b/production/src/main/java/com/foreverwin/mesnac/production/controller/AccessoryLogController.java index 6113085f..d7c44157 100644 --- a/production/src/main/java/com/foreverwin/mesnac/production/controller/AccessoryLogController.java +++ b/production/src/main/java/com/foreverwin/mesnac/production/controller/AccessoryLogController.java @@ -23,6 +23,32 @@ public class AccessoryLogController { @Autowired public AccessoryLogService accessoryLogService; + + /** + * 查询资源上料记录 + * + * @return + */ + @ResponseBody + @GetMapping("/loadList") + public R getLoadList(AccessoryLog accessoryLog){ + List result; + result = accessoryLogService.getLoadLabelList(accessoryLog); + return R.ok(result); + } + + /** + * 上料 + * + * @return + */ + @ResponseBody + @GetMapping("/loadConfirm") + public R loadInventory(AccessoryLog accessoryLog){ + accessoryLogService.loadConfirm(accessoryLog); + return R.ok("上料成功"); + } + /** * 根据id查询 * diff --git a/production/src/main/java/com/foreverwin/mesnac/production/mapper/AccessoryLogMapper.java b/production/src/main/java/com/foreverwin/mesnac/production/mapper/AccessoryLogMapper.java index 980b27ce..3b3c1bc9 100644 --- a/production/src/main/java/com/foreverwin/mesnac/production/mapper/AccessoryLogMapper.java +++ b/production/src/main/java/com/foreverwin/mesnac/production/mapper/AccessoryLogMapper.java @@ -4,6 +4,8 @@ import com.foreverwin.mesnac.production.model.AccessoryLog; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.springframework.stereotype.Repository; +import java.util.List; + /** *

* 辅料使用记录表 Mapper 接口 @@ -15,4 +17,5 @@ import org.springframework.stereotype.Repository; @Repository public interface AccessoryLogMapper extends BaseMapper { + List getLabelList(String site, String sfc, String stepId); } \ No newline at end of file diff --git a/production/src/main/java/com/foreverwin/mesnac/production/model/AccessoryLog.java b/production/src/main/java/com/foreverwin/mesnac/production/model/AccessoryLog.java index a6f19ad3..3adc2494 100644 --- a/production/src/main/java/com/foreverwin/mesnac/production/model/AccessoryLog.java +++ b/production/src/main/java/com/foreverwin/mesnac/production/model/AccessoryLog.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.extension.activerecord.Model; import java.io.Serializable; +import java.math.BigDecimal; import java.time.LocalDateTime; /** @@ -88,7 +89,7 @@ public class AccessoryLog extends Model { * 使用数量 */ @TableField("QTY") - private Double qty; + private BigDecimal qty; /** * 创建人 */ @@ -100,6 +101,16 @@ public class AccessoryLog extends Model { @TableField("CREATED_DATE_TIME") private LocalDateTime createdDateTime; + @TableField(exist = false) + private String description; + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } public String getHandle() { return handle; @@ -197,11 +208,11 @@ public class AccessoryLog extends Model { this.revision = revision; } - public Double getQty() { + public BigDecimal getQty() { return qty; } - public void setQty(Double qty) { + public void setQty(BigDecimal qty) { this.qty = qty; } diff --git a/production/src/main/java/com/foreverwin/mesnac/production/service/AccessoryLogService.java b/production/src/main/java/com/foreverwin/mesnac/production/service/AccessoryLogService.java index d2da0aaa..4d56b537 100644 --- a/production/src/main/java/com/foreverwin/mesnac/production/service/AccessoryLogService.java +++ b/production/src/main/java/com/foreverwin/mesnac/production/service/AccessoryLogService.java @@ -25,4 +25,8 @@ public interface AccessoryLogService extends IService { IPage selectPage(FrontPage frontPage, AccessoryLog accessoryLog); List selectList(AccessoryLog accessoryLog); + + void loadConfirm(AccessoryLog accessoryLog); + + List getLoadLabelList(AccessoryLog accessoryLog); } \ No newline at end of file diff --git a/production/src/main/java/com/foreverwin/mesnac/production/service/impl/AccessoryLogServiceImpl.java b/production/src/main/java/com/foreverwin/mesnac/production/service/impl/AccessoryLogServiceImpl.java index 4df573e1..db745c6d 100644 --- a/production/src/main/java/com/foreverwin/mesnac/production/service/impl/AccessoryLogServiceImpl.java +++ b/production/src/main/java/com/foreverwin/mesnac/production/service/impl/AccessoryLogServiceImpl.java @@ -1,17 +1,32 @@ package com.foreverwin.mesnac.production.service.impl; -import com.foreverwin.modular.core.util.FrontPage; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; -import com.foreverwin.mesnac.production.model.AccessoryLog; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.foreverwin.mesnac.common.enums.HandleEnum; +import com.foreverwin.mesnac.common.service.CommonService; +import com.foreverwin.mesnac.common.util.StringUtil; +import com.foreverwin.mesnac.dispatch.model.ItemBatch; +import com.foreverwin.mesnac.dispatch.service.ItemBatchService; +import com.foreverwin.mesnac.meapi.model.Item; +import com.foreverwin.mesnac.meapi.model.Operation; +import com.foreverwin.mesnac.meapi.service.ItemService; +import com.foreverwin.mesnac.meapi.service.SfcService; import com.foreverwin.mesnac.production.mapper.AccessoryLogMapper; +import com.foreverwin.mesnac.production.model.AccessoryLog; import com.foreverwin.mesnac.production.service.AccessoryLogService; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.stereotype.Service; +import com.foreverwin.modular.core.exception.BaseException; +import com.foreverwin.modular.core.util.CommonMethods; +import com.foreverwin.modular.core.util.FrontPage; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; +import java.time.LocalDateTime; import java.util.List; +import java.util.UUID; + /** *

* 辅料使用记录表 服务实现类 @@ -27,7 +42,14 @@ public class AccessoryLogServiceImpl extends ServiceImpl selectPage(FrontPage frontPage, AccessoryLog accessoryLog) { QueryWrapper queryWrapper = new QueryWrapper<>(); @@ -42,5 +64,66 @@ public class AccessoryLogServiceImpl extends ServiceImpl queryWrapper=new QueryWrapper<>(); + queryWrapper.eq(ItemBatch.SITE,site); + queryWrapper.eq(ItemBatch.LABEL,label); + List list = itemBatchService.list(queryWrapper); + if (qty.compareTo(BigDecimal.ZERO)<=0){ + throw new BaseException("数量不能小于零"); + } + if (list.isEmpty()){ + throw new BaseException("标签不存在"); + } + ItemBatch itemBatch = list.get(0); + String workShopBo = commonService.getWorkShopBo(HandleEnum.RESOURCE.getHandle(site,resrce)); + if (StringUtil.isBlank(workShopBo)) { + throw new BaseException("资源 " + resrce + " 未匹配到车间"); + } + String sfcBO = HandleEnum.SFC.getHandle(site, sfc); + Operation operationBySfcBo = commonService.getOperationBySfcBo(sfcBO); + if (operationBySfcBo==null){ + throw new BaseException("未找到产品条码信息"); + } + accessoryLog.setHandle(UUID.randomUUID().toString()); + accessoryLog.setSite(site); + accessoryLog.setWorkCenter(StringUtil.trimHandle(workShopBo)); + accessoryLog.setShopOrder(StringUtil.trimHandle(sfcService.getById(sfcBO).getShopOrderBo())); + accessoryLog.setOperation(operationBySfcBo.getOperation()); + accessoryLog.setStepId(operationBySfcBo.getStepId()); + accessoryLog.setBatch(itemBatch.getBatch()); + String item = itemBatch.getItem(); + Item selectCurrent = itemService.selectCurrent(site, item); + if (selectCurrent==null){ + throw new BaseException("标签物料不存在当前版本"); + } + accessoryLog.setItem(item); + accessoryLog.setRevision(selectCurrent.getRevision()); + accessoryLog.setCreateUser(CommonMethods.getUser()); + accessoryLog.setCreatedDateTime(LocalDateTime.now()); + save(accessoryLog); + } + + @Override + public List getLoadLabelList(AccessoryLog accessoryLog) { + String site = CommonMethods.getSite(); + String sfc = accessoryLog.getSfc(); + String sfcBO = HandleEnum.SFC.getHandle(site, sfc); + Operation operationBySfcBo = commonService.getOperationBySfcBo(sfcBO); + if (operationBySfcBo==null){ + throw new BaseException("未找到产品条码信息"); + } + if (operationBySfcBo==null){ + throw new BaseException("未找到产品条码信息"); + } + return accessoryLogMapper.getLabelList(site,sfc,operationBySfcBo.getStepId()); + } + } \ No newline at end of file diff --git a/production/src/main/java/com/foreverwin/mesnac/production/service/impl/PodTemplateServiceImpl.java b/production/src/main/java/com/foreverwin/mesnac/production/service/impl/PodTemplateServiceImpl.java index 1f9e1c00..9760fcc7 100644 --- a/production/src/main/java/com/foreverwin/mesnac/production/service/impl/PodTemplateServiceImpl.java +++ b/production/src/main/java/com/foreverwin/mesnac/production/service/impl/PodTemplateServiceImpl.java @@ -363,7 +363,7 @@ public class PodTemplateServiceImpl implements PodTemplateService { if (inventoryList.isEmpty()) { throw new BaseException("设备没有上" + StringUtil.trimHandle(componentGbo) + "/" + currentReversionItem.getDescription() + "料"); } - BigDecimal needQty = new BigDecimal(BomComponentDto.getQty()).multiply(new BigDecimal(sfcServiceById.getQty())); + BigDecimal needQty = new BigDecimal(String.valueOf(BomComponentDto.getQty())).multiply(new BigDecimal(sfcServiceById.getQty())); for (LoadInventory loadInventory : inventoryList) { BigDecimal qtyOnHand = loadInventory.getQtyOnHand(); BigDecimal costQty; @@ -465,10 +465,10 @@ public class PodTemplateServiceImpl implements PodTemplateService { ZprodordconfStruOut[] outs = new ZprodordconfStruOut[1]; ZprodordconfStruOut struOut = new ZprodordconfStruOut(); - struOut.setAufnr(""); - struOut.setVornr(""); + struOut.setAufnr(ins[0].getAufnr()); + struOut.setVornr(ins[0].getVornr()); struOut.setAueru("1"); - struOut.setLmnga(BigDecimal.ZERO); + struOut.setLmnga(ins[0].getLmnga()); struOut.setRet(""); struOut.setMsg(""); outs[0] = struOut; @@ -477,12 +477,13 @@ public class PodTemplateServiceImpl implements PodTemplateService { //调用WS try { ERPAPI.erpWebService().zmesProdordconf(inHolder, outHolder); - } catch (RemoteException e) { String status = outHolder.value[1].getRet(); String message = outHolder.value[1].getMsg(); if (status.equals("E")) { throw new BaseException("ERP接口返回:状态:" + status + ",消息:" + message); } + } catch (RemoteException e) { + ExceptionUtil.throwException(e); } finally { //记录接口日志 IntegrationLog log = new IntegrationLog(); @@ -492,7 +493,7 @@ public class PodTemplateServiceImpl implements PodTemplateService { log.setCategory("REQUEST"); log.setIntegrationWay("ERP"); log.setIntegrationMethod("erpWebService.zmesProdordconf"); - log.setParam(ins.toString()); + log.setParam(inHolder.toString()); log.setStatus(outHolder.value[1].getRet()); log.setResultMessage(outHolder.value[1].getMsg()); log.setTransactionId(""); diff --git a/production/src/main/resources/mapper/AccessoryLogMapper.xml b/production/src/main/resources/mapper/AccessoryLogMapper.xml index d1c7e4ab..1c6745bf 100644 --- a/production/src/main/resources/mapper/AccessoryLogMapper.xml +++ b/production/src/main/resources/mapper/AccessoryLogMapper.xml @@ -19,6 +19,8 @@ + + @@ -478,5 +480,9 @@ ) - +