读取对刀xml文件

This commit is contained in:
汤锦科 2024-11-28 09:08:31 +08:00
parent e21e66b291
commit 9ac0574f20
13 changed files with 228 additions and 17 deletions

View File

@ -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()

View File

@ -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);
}

View File

@ -77,9 +77,7 @@ public class InventoryBatchController extends BaseController
@GetMapping("/list")
public TableDataInfo list(InventoryBatch inventoryBatch) {
startPage();
List<InventoryBatch> result = inventoryBatchService.selectInventoryBatchList(inventoryBatch);
return getDataTable(result);
}

View File

@ -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));
}

View File

@ -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;
/**

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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)

View File

@ -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) {

View File

@ -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);
}