Merge remote-tracking branch 'origin/master'

This commit is contained in:
刘名喜 2024-11-28 14:14:07 +08:00
commit a988e974d6
13 changed files with 276 additions and 20 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;
/**
* 开放 查询出库任务列表
@ -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));
}

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

@ -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<WmsZdTask> wmsZdTaskList = wmsZdTaskMapper.selectWmsZdTaskList(wmsZdTaskWrapper);
if (!wmsZdTaskList.isEmpty()){
// 获取组装任务
WmsZdTask wmsZdTask = wmsZdTaskList.get(0);
// 检测是否完成
WmsOutTask wmsOutTaskWrapper = new WmsOutTask();
wmsOutTaskWrapper.setWmsOutPlanCode(wmsZdTask.getCode());
List<WmsOutTask> 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<WmsZdTask> 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) {

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,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();
}