From 9ac0574f20f01415d63d095dd32d5b4c6155d1df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=A4=E9=94=A6=E7=A7=91?= <32996823@qq.com> Date: Thu, 28 Nov 2024 09:08:31 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BB=E5=8F=96=E5=AF=B9=E5=88=80xml?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ktg/web/core/config/SwaggerConfig.java | 2 +- .../md/controller/BaseKnifeController.java | 1 + .../controller/InventoryBatchController.java | 2 - .../md/controller/WmsOutTaskController.java | 43 ++++++++++++++++++- .../com/ktg/mes/md/domain/InventoryBatch.java | 2 +- .../java/com/ktg/mes/md/domain/MyConfig.java | 19 ++++++++ .../java/com/ktg/mes/md/domain/ParamXml.java | 39 +++++++++++++++++ .../main/java/com/ktg/mes/md/domain/Tool.java | 40 +++++++++++++++++ .../java/com/ktg/mes/md/domain/Tools.java | 20 +++++++++ .../mes/md/service/IWmsOutTaskService.java | 3 +- .../md/service/impl/BaseKnifeServiceImpl.java | 39 ++++++++++++++--- .../service/impl/WmsOutTaskServiceImpl.java | 32 +++++++++++--- .../wm/service/impl/WmsZdTaskServiceImpl.java | 3 ++ 13 files changed, 228 insertions(+), 17 deletions(-) create mode 100644 ktg-mes/src/main/java/com/ktg/mes/md/domain/MyConfig.java create mode 100644 ktg-mes/src/main/java/com/ktg/mes/md/domain/ParamXml.java create mode 100644 ktg-mes/src/main/java/com/ktg/mes/md/domain/Tool.java create mode 100644 ktg-mes/src/main/java/com/ktg/mes/md/domain/Tools.java diff --git a/ktg-admin/src/main/java/com/ktg/web/core/config/SwaggerConfig.java b/ktg-admin/src/main/java/com/ktg/web/core/config/SwaggerConfig.java index 43cd7a6..1a0f4bf 100644 --- a/ktg-admin/src/main/java/com/ktg/web/core/config/SwaggerConfig.java +++ b/ktg-admin/src/main/java/com/ktg/web/core/config/SwaggerConfig.java @@ -59,7 +59,7 @@ public class SwaggerConfig // 扫描所有有注解的api,用这种方式更灵活 .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) // 扫描指定包中的swagger注解 - // .apis(RequestHandlerSelectors.basePackage("com.ktg.project.tool.swagger")) + // .apis(RequestHandlerSelectors.basePackage("com.ktg.project.Tool.swagger")) // 扫描所有 .apis(RequestHandlerSelectors.any()) .paths(PathSelectors.any()) .build() diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/controller/BaseKnifeController.java b/ktg-mes/src/main/java/com/ktg/mes/md/controller/BaseKnifeController.java index 8fb0307..0eb8eb8 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/md/controller/BaseKnifeController.java +++ b/ktg-mes/src/main/java/com/ktg/mes/md/controller/BaseKnifeController.java @@ -816,6 +816,7 @@ public class BaseKnifeController extends BaseController { outPlanDetail.setWmStorageAreaCode(wmStorageArea.getAreaCode()); outPlanDetail.setWmStorageAreaName(wmStorageArea.getAreaName()); outPlanDetail.setDetailState("1"); + outPlanDetail.setCreateTime(DateUtils.getNowDate()); wmsOutPlanDetailList.add(outPlanDetail); } diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/controller/InventoryBatchController.java b/ktg-mes/src/main/java/com/ktg/mes/md/controller/InventoryBatchController.java index 43e0c3a..44a3797 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/md/controller/InventoryBatchController.java +++ b/ktg-mes/src/main/java/com/ktg/mes/md/controller/InventoryBatchController.java @@ -77,9 +77,7 @@ public class InventoryBatchController extends BaseController @GetMapping("/list") public TableDataInfo list(InventoryBatch inventoryBatch) { startPage(); - List result = inventoryBatchService.selectInventoryBatchList(inventoryBatch); - return getDataTable(result); } diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/controller/WmsOutTaskController.java b/ktg-mes/src/main/java/com/ktg/mes/md/controller/WmsOutTaskController.java index 47f7c74..3291d3d 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/md/controller/WmsOutTaskController.java +++ b/ktg-mes/src/main/java/com/ktg/mes/md/controller/WmsOutTaskController.java @@ -6,15 +6,34 @@ import com.ktg.common.core.domain.AjaxResult; import com.ktg.common.core.page.TableDataInfo; import com.ktg.common.enums.BusinessType; import com.ktg.common.utils.poi.ExcelUtil; +import com.ktg.mes.md.domain.MyConfig; +import com.ktg.mes.md.domain.ParamXml; import com.ktg.mes.md.domain.WmsOutPlan; import com.ktg.mes.md.domain.WmsOutTask; import com.ktg.mes.md.service.IWmsOutTaskService; import com.ktg.mes.wm.domain.WmsInPlan; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; + import javax.servlet.http.HttpServletResponse; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; +import org.xml.sax.SAXException; + +import java.io.File; +import java.io.IOException; import java.util.List; /** @@ -29,6 +48,9 @@ public class WmsOutTaskController extends BaseController { @Autowired private IWmsOutTaskService wmsOutTaskService; + @Autowired + private MyConfig myConfig; + /** * 开放 查询出库任务列表 @@ -51,7 +73,7 @@ public class WmsOutTaskController extends BaseController { return getDataTable(list); } - /** + /** * 查询出库任务列表 */ @PreAuthorize("@ss.hasPermi('md:TASK:list')") @@ -62,6 +84,23 @@ public class WmsOutTaskController extends BaseController { return getDataTable(list); } + /** + * 查询出库任务列表 + */ + @PreAuthorize("@ss.hasPermi('md:TASK:query')") + @GetMapping("/xmlParam") + public void list() throws IOException, SAXException, ParserConfigurationException, JAXBException { + // 读取xml配置文件 + File xmlFile = new File(myConfig.getToolSettingXmlPath()); + JAXBContext jaxbContext = JAXBContext.newInstance(ParamXml.class); + Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); + ParamXml paramXml = (ParamXml) unmarshaller.unmarshal(xmlFile); + + System.out.println(paramXml.getRfid()); + System.out.println(paramXml.getName()); + System.out.println(paramXml.getParam()); + } + /** * 导出出库任务列表 */ @@ -106,7 +145,7 @@ public class WmsOutTaskController extends BaseController { @PreAuthorize("@ss.hasPermi('md:TASK:edit')") @Log(title = "手动出库", businessType = BusinessType.UPDATE) @PutMapping("/run/{wmsOutTaskIds}") - public AjaxResult run(@PathVariable Long[] wmsOutTaskIds) { + public AjaxResult run(@PathVariable Long[] wmsOutTaskIds) throws JAXBException { return toAjax(wmsOutTaskService.runWmsOutTask(wmsOutTaskIds)); } diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/domain/InventoryBatch.java b/ktg-mes/src/main/java/com/ktg/mes/md/domain/InventoryBatch.java index e7dd776..b64ed29 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/md/domain/InventoryBatch.java +++ b/ktg-mes/src/main/java/com/ktg/mes/md/domain/InventoryBatch.java @@ -14,7 +14,7 @@ import java.util.List; * @author yinjinlu * @date 2024-11-02 */ -public class InventoryBatch { +public class InventoryBatch extends BaseEntity { private static final long serialVersionUID = 1L; /** diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/domain/MyConfig.java b/ktg-mes/src/main/java/com/ktg/mes/md/domain/MyConfig.java new file mode 100644 index 0000000..e8f2b64 --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/md/domain/MyConfig.java @@ -0,0 +1,19 @@ +package com.ktg.mes.md.domain; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class MyConfig { + + @Value("${toolSettingXml.path}") + private String toolSettingXmlPath; + + public String getToolSettingXmlPath() { + return toolSettingXmlPath; + } + + public void setToolSettingXmlPath(String toolSettingXmlPath) { + this.toolSettingXmlPath = toolSettingXmlPath; + } +} diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/domain/ParamXml.java b/ktg-mes/src/main/java/com/ktg/mes/md/domain/ParamXml.java new file mode 100644 index 0000000..cc409bd --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/md/domain/ParamXml.java @@ -0,0 +1,39 @@ +package com.ktg.mes.md.domain; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class ParamXml { + private String rfid; + private String name; + private String param; + + public String getRfid() { + return rfid; + } + + @XmlElement + public void setRfid(String rfid) { + this.rfid = rfid; + } + + public String getName() { + return name; + } + + @XmlElement + public void setName(String name) { + this.name = name; + } + + public String getParam() { + return param; + } + + @XmlElement + public void setParam(String param) { + this.param = param; + } + +} diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/domain/Tool.java b/ktg-mes/src/main/java/com/ktg/mes/md/domain/Tool.java new file mode 100644 index 0000000..5d26382 --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/md/domain/Tool.java @@ -0,0 +1,40 @@ +package com.ktg.mes.md.domain; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class Tool { + + private String name; + private String diameter; + private String length; + + public String getName() { + return name; + } + + + @XmlElement + public void setName(String name) { + this.name = name; + } + + public String getDiameter() { + return diameter; + } + + @XmlElement + public void setDiameter(String diameter) { + this.diameter = diameter; + } + + public String getLength() { + return length; + } + + @XmlElement + public void setLength(String length) { + this.length = length; + } +} diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/domain/Tools.java b/ktg-mes/src/main/java/com/ktg/mes/md/domain/Tools.java new file mode 100644 index 0000000..c710345 --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/md/domain/Tools.java @@ -0,0 +1,20 @@ +package com.ktg.mes.md.domain; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class Tools { + + private Tool tool; + + + public Tool getTool() { + return tool; + } + + @XmlElement + public void setTool(Tool tool) { + this.tool = tool; + } +} diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/service/IWmsOutTaskService.java b/ktg-mes/src/main/java/com/ktg/mes/md/service/IWmsOutTaskService.java index 5567b0c..f2023e1 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/md/service/IWmsOutTaskService.java +++ b/ktg-mes/src/main/java/com/ktg/mes/md/service/IWmsOutTaskService.java @@ -2,6 +2,7 @@ package com.ktg.mes.md.service; import com.ktg.mes.md.domain.WmsOutTask; +import javax.xml.bind.JAXBException; import java.util.List; /** @@ -59,7 +60,7 @@ public interface IWmsOutTaskService { */ int deleteWmsOutTaskByWmsOutTaskId(Long wmsOutTaskId); - boolean runWmsOutTask(Long[] wmsOutTaskIds); + boolean runWmsOutTask(Long[] wmsOutTaskIds) throws JAXBException; boolean autoRunWmsOutTask(Long[] wmsOutTaskIds); diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/BaseKnifeServiceImpl.java b/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/BaseKnifeServiceImpl.java index b424e90..a034a49 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/BaseKnifeServiceImpl.java +++ b/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/BaseKnifeServiceImpl.java @@ -1,5 +1,6 @@ package com.ktg.mes.md.service.impl; +import com.alibaba.fastjson.JSON; import com.ktg.common.utils.DateUtils; import com.ktg.mes.md.domain.*; import com.ktg.mes.md.mapper.*; @@ -10,11 +11,19 @@ import com.ktg.mes.wm.service.impl.WmsInPlanDetailEntityServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.w3c.dom.Document; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import java.io.File; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; +import java.util.*; import static org.apache.commons.lang3.SystemUtils.getUserName; @@ -47,6 +56,9 @@ public class BaseKnifeServiceImpl implements IBaseKnifeService { @Autowired private WmsInPlanDetailEntityServiceImpl wmsInPlanDetailEntityService; + @Autowired + private MyConfig myConfig; + /** * 查询工具台账 * @@ -110,8 +122,25 @@ public class BaseKnifeServiceImpl implements IBaseKnifeService { hashMap.put("wmStorageAreaCode", wmsOutPlanDetail.getWmStorageAreaCode()); // 库位编码 hashMap.put("wmStorageAreaName", wmsOutPlanDetail.getWmStorageAreaName()); // 库位名称 hashMap.put("detailStatus", wmsOutPlanDetail.getDetailState()); // 明细状态 - hashMap.put("isToolSetting", nowWmsOutPlanDetailEntity.getIsToolSetting()); // 是否对刀 - hashMap.put("toolSettingParam", nowWmsOutPlanDetailEntity.getToolSettingParam()); // 对刀参数 + hashMap.put("isToolSetting", 0); // 是否对刀 + + // 读取xml配置文件 + if ("PRODUCT".equals(nowWmsOutPlanDetailEntity.getItemOrProduct())) { + try { +// File xmlFile = new File(myConfig.getToolSettingXmlPath() + nowBaseKnife.getRfid() + ".xml"); + File xmlFile = new File(myConfig.getToolSettingXmlPath() + "DDYDATA0" + (new Random().nextInt(5) + 1) + ".xml"); + JAXBContext jaxbContext = JAXBContext.newInstance(Tools.class); + Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); + Tools paramXml = (Tools) unmarshaller.unmarshal(xmlFile); + + hashMap.put("isToolSetting", 1); // 是否对刀 + hashMap.put("toolSettingParam", JSON.toJSONString(paramXml)); // 对刀参数 + + } catch (JAXBException e) { +// throw new RuntimeException(e); + } + } + /* 实体 */ String outTime = null; if (nowWmsOutPlanDetailEntity.getCreateTime() != null) diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/WmsOutTaskServiceImpl.java b/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/WmsOutTaskServiceImpl.java index 5225050..f7a8323 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/WmsOutTaskServiceImpl.java +++ b/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/WmsOutTaskServiceImpl.java @@ -11,11 +11,12 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; +import java.io.File; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; +import java.util.*; /** * 出库任务Service业务层处理 @@ -46,6 +47,9 @@ public class WmsOutTaskServiceImpl implements IWmsOutTaskService { @Autowired private WmStorageAreaMapper wmStorageAreaMapper; + @Autowired + private MyConfig myConfig; + /** * 查询出库任务 * @@ -194,7 +198,7 @@ public class WmsOutTaskServiceImpl implements IWmsOutTaskService { @Transactional @Override - public boolean runWmsOutTask(Long[] wmsOutTaskIds) { + public boolean runWmsOutTask(Long[] wmsOutTaskIds) throws JAXBException { for (Long wmsOutTaskId : wmsOutTaskIds) { // 获得当前出库任务 WmsOutTask wmsOutTask = wmsOutTaskMapper.selectWmsOutTaskByWmsOutTaskId(wmsOutTaskId); @@ -212,6 +216,8 @@ public class WmsOutTaskServiceImpl implements IWmsOutTaskService { 2, 1 ); + + this.toolSetting(wmsOutPlanDetailEntity); } // 更新出库任务状态 @@ -221,6 +227,22 @@ public class WmsOutTaskServiceImpl implements IWmsOutTaskService { return true; } + public void toolSetting(WmsOutPlanDetailEntity wmsOutPlanDetailEntity) throws JAXBException { + // 读取xml配置文件 + File xmlFile = new File(myConfig.getToolSettingXmlPath()); + JAXBContext jaxbContext = JAXBContext.newInstance(ParamXml.class); + Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); + ParamXml paramXml = (ParamXml) unmarshaller.unmarshal(xmlFile); + + // 获取当前实体台账 + BaseKnife baseKnife = baseKnifeMapper.selectBaseKnifeByBaseKnifeId(wmsOutPlanDetailEntity.getBaseKnifeId()); + if (Objects.equals(baseKnife.getRfid(), paramXml.getRfid())){ + wmsOutPlanDetailEntity.setIsToolSetting(1); + wmsOutPlanDetailEntity.setToolSettingParam("rfid: " + paramXml.getRfid() + " name: " + paramXml.getName() + " param: " + paramXml.getParam()); + wmsOutPlanDetailEntityMapper.updateWmsOutPlanDetailEntity(wmsOutPlanDetailEntity); + } + } + @Transactional @Override public boolean autoRunWmsOutTask(Long[] wmsOutTaskIds) { diff --git a/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmsZdTaskServiceImpl.java b/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmsZdTaskServiceImpl.java index 151b1c4..e7d58e7 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmsZdTaskServiceImpl.java +++ b/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmsZdTaskServiceImpl.java @@ -240,6 +240,7 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService // 锁定物料 int resetCount = 0; + String rfid = ""; for (MbbProduBom mbbProduBom : bomRoute.getMbbProduBomList()) { // 查询未锁定的物料 baseKnifeWrapper.setMbbBdMrlId(mbbProduBom.getMdItemId()); @@ -250,6 +251,7 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService int bomCount = mbbProduBom.getStandardDosage(); for (BaseKnife wmsBaseKnife : baseKnifeList) { if (bomCount > 0) { + if ("ITEM".equals(wmsBaseKnife.getItemOrProduct())) rfid = wmsBaseKnife.getRfid(); wmsBaseKnife.setZdTaskId(zdTask.getWmsZdTaskId()); wmsBaseKnife.setIsLocked(1); wmsBaseKnife.setKnifeFineState(2); @@ -269,6 +271,7 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService // 更新重置次数 baseKnife.setResetCount(resetCount - 1); + baseKnife.setRfid(rfid); baseKnifeMapper.updateBaseKnife(baseKnife); }