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 d2933dc..f222c04 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; + /** * 开放 查询出库任务列表 @@ -55,7 +77,7 @@ public class WmsOutTaskController extends BaseController { return getDataTable(list); } - /** + /** * 查询出库任务列表 */ @PreAuthorize("@ss.hasPermi('md:TASK:list')") @@ -66,6 +88,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()); + } + /** * 导出出库任务列表 */ @@ -110,7 +149,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..246d159 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 @@ -5,17 +5,20 @@ import com.ktg.mes.md.domain.*; import com.ktg.mes.md.mapper.*; import com.ktg.mes.md.service.IWmsOutTaskService; import com.ktg.mes.wm.domain.WmStorageArea; +import com.ktg.mes.wm.domain.WmsZdTask; import com.ktg.mes.wm.mapper.WmStorageAreaMapper; +import com.ktg.mes.wm.mapper.WmsZdTaskMapper; import com.ktg.mes.wm.service.IWmStorageAreaService; 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 +49,12 @@ public class WmsOutTaskServiceImpl implements IWmsOutTaskService { @Autowired private WmStorageAreaMapper wmStorageAreaMapper; + @Autowired + private WmsZdTaskMapper wmsZdTaskMapper; + + @Autowired + private MyConfig myConfig; + /** * 查询出库任务 * @@ -194,7 +203,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,15 +221,74 @@ public class WmsOutTaskServiceImpl implements IWmsOutTaskService { 2, 1 ); + +// this.toolSetting(wmsOutPlanDetailEntity); } // 更新出库任务状态 wmsOutTask.setTaskState("1"); wmsOutTaskMapper.updateWmsOutTask(wmsOutTask); + + // 完成标识 + boolean flag = true; + + // 判断是否来自组装任务 + WmsZdTask wmsZdTaskWrapper = new WmsZdTask(); + wmsZdTaskWrapper.setCode(wmsOutTask.getWmsOutPlanCode()); + List wmsZdTaskList = wmsZdTaskMapper.selectWmsZdTaskList(wmsZdTaskWrapper); + if (!wmsZdTaskList.isEmpty()){ + // 获取组装任务 + WmsZdTask wmsZdTask = wmsZdTaskList.get(0); + + // 检测是否完成 + WmsOutTask wmsOutTaskWrapper = new WmsOutTask(); + wmsOutTaskWrapper.setWmsOutPlanCode(wmsZdTask.getCode()); + List wmsOutTaskList = wmsOutTaskMapper.selectWmsOutTaskList(wmsOutTaskWrapper); + + // 遍历状态 + for (WmsOutTask item: wmsOutTaskList){ + if (Objects.equals("0", item.getTaskState())) { + flag = false; + break; + } + } + } + + if (flag) { this.wmsZdTaskFinish(wmsOutTask.getWmsOutPlanCode()); } } + return true; } + public void wmsZdTaskFinish(String planCode){ + WmsZdTask wmsZdTaskWrapper = new WmsZdTask(); + wmsZdTaskWrapper.setCode(planCode); + List wmsZdTaskList = wmsZdTaskMapper.selectWmsZdTaskList(wmsZdTaskWrapper); + + if (!wmsZdTaskList.isEmpty()) { + // 获取组装任务 更新状态 + WmsZdTask wmsZdTask = wmsZdTaskList.get(0); + wmsZdTask.setStatus("1"); + wmsZdTaskMapper.updateWmsZdTask(wmsZdTask); + } + } + + 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..4d25949 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,9 +251,9 @@ 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); wmsBaseKnife.setLockedStartTime(technologyBom.getLockedStartTime()); wmsBaseKnife.setLockedEndTime(technologyBom.getLockedEndTime()); wmsBaseKnife.setParentId(baseKnife.getBaseKnifeId()); @@ -269,6 +270,7 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService // 更新重置次数 baseKnife.setResetCount(resetCount - 1); + baseKnife.setRfid(rfid); baseKnifeMapper.updateBaseKnife(baseKnife); } @@ -350,7 +352,7 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService wmsOutTask.setMdItemCode(outPlanDetail.getMdItemCode()); wmsOutTask.setMdItemName(outPlanDetail.getMdItemName()); wmsOutTask.setMdItemUnit(outPlanDetail.getMdItemUnit()); - wmsOutTask.setTaskState("1"); + wmsOutTask.setTaskState("0"); wmsOutTask.setRecipientUsername(""); wmsOutTask.setCreateBy(getUsername()); wmsOutTask.setCreateTime(DateUtils.getNowDate()); @@ -359,7 +361,7 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService }); // 更新组装任务 - zdTask.setStatus("1"); + zdTask.setStatus("3"); wmsZdTaskMapper.updateWmsZdTask(zdTask); return AjaxResult.success(); }