组装任务联调WCS优化,新增读取对刀仪代码,联调数据大屏接口
This commit is contained in:
parent
72dac19897
commit
8b451fe282
@ -53,6 +53,11 @@
|
||||
<artifactId>swagger-models</artifactId>
|
||||
<version>1.6.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jcifs</groupId>
|
||||
<artifactId>jcifs</artifactId>
|
||||
<version>1.3.17</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.ktg</groupId>
|
||||
<artifactId>ktg-generator</artifactId>
|
||||
|
@ -91,6 +91,15 @@ public class CalendarUtil {
|
||||
return format(new Date(), DATETIME_PATTERN);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前日期和时间字符串.
|
||||
*
|
||||
* @return String 日期时间字符串,例如 2015/08/11
|
||||
*/
|
||||
public static String getDateTimeStrForFile() {
|
||||
return format(new Date(), DATE_PATTERN_WITH_SLASH);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间戳转换为日期时间字符串
|
||||
*
|
||||
|
@ -544,6 +544,12 @@ public class BaseKnifeController extends BaseController {
|
||||
mdItem = mdItemService.selectMdItemByCode(techBom.getKnifeCode());
|
||||
count = techBom.getKnifeCount() - countMap.get(techBom.getKnifeCode());
|
||||
|
||||
// 更新countMap
|
||||
if (techBom.getKnifeCount() >= countMap.get(techBom.getKnifeCode()))
|
||||
countMap.put(techBom.getKnifeCode(), 0);
|
||||
else
|
||||
countMap.put(techBom.getKnifeCode(), countMap.get(techBom.getKnifeCode()) + techBom.getKnifeCount());
|
||||
|
||||
// 先从台账表找
|
||||
baseKnifeWrapper.setMbbBdMrlId(mdItem.getItemId());
|
||||
baseKnifeWrapper.setIsLocked(0);
|
||||
@ -568,17 +574,29 @@ public class BaseKnifeController extends BaseController {
|
||||
return AjaxResult.error("Bom头查询错误", techBom.getKnifeCode());
|
||||
}
|
||||
|
||||
// 生成组装任务
|
||||
WmsZdTask wmsZdTask = new WmsZdTask();
|
||||
wmsZdTask.setmProductId(mdItem.getItemId());
|
||||
wmsZdTask.setPlanSheet(productionArrangements.getPlanSheet());
|
||||
wmsZdTask.setCode(generateTaskCode(techBom.getProcessCode()));
|
||||
wmsZdTask.setName(techBom.getProcessName());
|
||||
wmsZdTask.setProductIdQty(count);
|
||||
wmsZdTask.setBomId(bomRouteList.get(0).getBomRouteId());
|
||||
wmsZdTask.setCreateTime(DateUtils.getNowDate());
|
||||
zdTaskService.insertWmsZdTask(wmsZdTask);
|
||||
msg = "生产准备验证成功!缺少物料已生成组装任务!";
|
||||
// 判断是否存在组装任务
|
||||
WmsZdTask wmsZdTaskWrapper = new WmsZdTask();
|
||||
wmsZdTaskWrapper.setPlanSheet(productionArrangements.getPlanSheet());
|
||||
wmsZdTaskWrapper.setmProductId(mdItem.getItemId());
|
||||
List<WmsZdTask> wmsZdTaskList = zdTaskService.selectWmsZdTaskList(wmsZdTaskWrapper);
|
||||
if (wmsZdTaskList.isEmpty()){
|
||||
// 生成组装任务
|
||||
WmsZdTask wmsZdTask = new WmsZdTask();
|
||||
wmsZdTask.setmProductId(mdItem.getItemId());
|
||||
wmsZdTask.setPlanSheet(productionArrangements.getPlanSheet());
|
||||
wmsZdTask.setCode(generateTaskCode(techBom.getProcessCode()));
|
||||
wmsZdTask.setName(techBom.getProcessName());
|
||||
wmsZdTask.setProductIdQty(count);
|
||||
wmsZdTask.setBomId(bomRouteList.get(0).getBomRouteId());
|
||||
wmsZdTask.setCreateTime(DateUtils.getNowDate());
|
||||
zdTaskService.insertWmsZdTask(wmsZdTask);
|
||||
msg = "生产准备验证成功!缺少物料已生成组装任务!";
|
||||
} else {
|
||||
WmsZdTask wmsZdTask = wmsZdTaskList.get(0);
|
||||
wmsZdTask.setProductIdQty(wmsZdTask.getProductIdQty() + count);
|
||||
wmsZdTask.setCreateTime(DateUtils.getNowDate());
|
||||
msg = "生产准备验证成功!缺少物料已生成组装任务!";
|
||||
}
|
||||
} else {
|
||||
baseKnifeOriginList.forEach(baseKnife -> baseKnifeService.updateBaseKnife(baseKnife));
|
||||
operLog.setJsonResult("缺少BOM项:" + techBom.getKnifeCode());
|
||||
|
@ -70,7 +70,7 @@ public class WmsOutTaskController extends BaseController {
|
||||
/**
|
||||
* 开放 查询出库任务列表
|
||||
*/
|
||||
@GetMapping("/open/incomplete/{planSheet}")
|
||||
@GetMapping("/open/incompleteList/{planSheet}")
|
||||
public TableDataInfo openList(@PathVariable String planSheet) {
|
||||
startPage();
|
||||
List<WmsOutTask> list = wmsOutTaskService.selectWmsOutTaskIncompleteList(planSheet);
|
||||
|
@ -6,9 +6,21 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RestController
|
||||
public class MyConfig {
|
||||
|
||||
@Value("${toolSettingXml.path}")
|
||||
@Value("${globalConfig.toolSettingXml.localPath}")
|
||||
private String toolSettingXmlPath;
|
||||
|
||||
@Value("${globalConfig.toolSettingXml.remoteUrl}")
|
||||
private String remoteUrl;
|
||||
|
||||
@Value("${globalConfig.toolSettingXml.remoteUser}")
|
||||
private String remoteUser;
|
||||
|
||||
@Value("${globalConfig.toolSettingXml.remotePass}")
|
||||
private String remotePass;
|
||||
|
||||
@Value("${globalConfig.productionControl.path}")
|
||||
private String productionControlPath;
|
||||
|
||||
public String getToolSettingXmlPath() {
|
||||
return toolSettingXmlPath;
|
||||
}
|
||||
@ -16,4 +28,36 @@ public class MyConfig {
|
||||
public void setToolSettingXmlPath(String toolSettingXmlPath) {
|
||||
this.toolSettingXmlPath = toolSettingXmlPath;
|
||||
}
|
||||
|
||||
public String getProductionControlPath() {
|
||||
return productionControlPath;
|
||||
}
|
||||
|
||||
public void setProductionControlPath(String productionControlPath) {
|
||||
this.productionControlPath = productionControlPath;
|
||||
}
|
||||
|
||||
public String getRemoteUrl() {
|
||||
return remoteUrl;
|
||||
}
|
||||
|
||||
public void setRemoteUrl(String remoteUrl) {
|
||||
this.remoteUrl = remoteUrl;
|
||||
}
|
||||
|
||||
public String getRemoteUser() {
|
||||
return remoteUser;
|
||||
}
|
||||
|
||||
public void setRemoteUser(String remoteUser) {
|
||||
this.remoteUser = remoteUser;
|
||||
}
|
||||
|
||||
public String getRemotePass() {
|
||||
return remotePass;
|
||||
}
|
||||
|
||||
public void setRemotePass(String remotePass) {
|
||||
this.remotePass = remotePass;
|
||||
}
|
||||
}
|
||||
|
@ -2,12 +2,16 @@ package com.ktg.mes.md.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ktg.common.utils.DateUtils;
|
||||
import com.ktg.mes.cal.utils.CalendarUtil;
|
||||
import com.ktg.mes.md.domain.*;
|
||||
import com.ktg.mes.md.mapper.*;
|
||||
import com.ktg.mes.md.service.IBaseKnifeService;
|
||||
import com.ktg.mes.wm.domain.WmsInPlanDetailEntity;
|
||||
import com.ktg.mes.wm.mapper.WmsInPlanDetailEntityMapper;
|
||||
import com.ktg.mes.wm.service.impl.WmsInPlanDetailEntityServiceImpl;
|
||||
import jcifs.smb.NtlmPasswordAuthentication;
|
||||
import jcifs.smb.SmbFile;
|
||||
import jcifs.smb.SmbFileInputStream;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -21,7 +25,7 @@ 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.io.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
@ -120,14 +124,16 @@ public class BaseKnifeServiceImpl implements IBaseKnifeService {
|
||||
hashMap.put("wmStorageAreaCode", wmsOutPlanDetail.getWmStorageAreaCode()); // 库位编码
|
||||
hashMap.put("wmStorageAreaName", wmsOutPlanDetail.getWmStorageAreaName()); // 库位名称
|
||||
hashMap.put("detailStatus", wmsOutPlanDetail.getDetailState()); // 明细状态
|
||||
hashMap.put("isToolSetting", 0); // 是否对刀
|
||||
hashMap.put("isToolSetting", 0); // 是否对刀
|
||||
|
||||
// 读取xml配置文件
|
||||
if ("PRODUCT".equals(nowWmsOutPlanDetailEntity.getItemOrProduct())) {
|
||||
try {
|
||||
// File xmlFile = new File(myConfig.getToolSettingXmlPath() + nowBaseKnife.getRfid() + ".xml");
|
||||
File xmlFile = new File("\\\\DBJGJG24\\ddy\\aaa.xml");
|
||||
// File xmlFile = new File(myConfig.getToolSettingXmlPath() + "DDYDATA0" + (new Random().nextInt(5) + 1) + ".xml");
|
||||
// 抓取远程文件
|
||||
this.getRemoteFile();
|
||||
|
||||
// 读取本地文件
|
||||
File xmlFile = new File(myConfig.getToolSettingXmlPath() + CalendarUtil.getDateTimeStrForFile() + "/TSP1203.xml");
|
||||
JAXBContext jaxbContext = JAXBContext.newInstance(Tools.class);
|
||||
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
|
||||
Tools paramXml = (Tools) unmarshaller.unmarshal(xmlFile);
|
||||
@ -135,7 +141,8 @@ public class BaseKnifeServiceImpl implements IBaseKnifeService {
|
||||
hashMap.put("isToolSetting", 1); // 是否对刀
|
||||
hashMap.put("toolSettingParam", JSON.toJSONString(paramXml)); // 对刀参数
|
||||
|
||||
} catch (JAXBException e) {
|
||||
} catch (Exception e) {
|
||||
System.out.println("系统找不到指定文件!");
|
||||
// throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
@ -168,6 +175,74 @@ public class BaseKnifeServiceImpl implements IBaseKnifeService {
|
||||
return baseKnifeList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取远程文件
|
||||
*/
|
||||
public void getRemoteFile() throws IOException {
|
||||
try {
|
||||
// 创建认证用户
|
||||
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("", myConfig.getRemoteUser(), myConfig.getRemotePass());
|
||||
|
||||
// 构建远程文件对象
|
||||
SmbFile remoteFile = new SmbFile(myConfig.getRemoteUrl(), auth);
|
||||
// 尝试链接
|
||||
remoteFile.connect();
|
||||
if(remoteFile.exists()){
|
||||
// 获取共享文件夹中文件列表
|
||||
SmbFile[] smbFiles = remoteFile.listFiles();
|
||||
for (SmbFile smbFile : smbFiles){
|
||||
createFile(smbFile);
|
||||
}
|
||||
} else {
|
||||
System.out.println("==============START=================");
|
||||
System.out.println("远程文件不存在");
|
||||
System.out.println("===============END==================");
|
||||
}
|
||||
} catch (Exception e){
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建本地文件
|
||||
*/
|
||||
public void createFile(SmbFile remoteFile) {
|
||||
InputStream in = null;
|
||||
OutputStream out = null;
|
||||
try {
|
||||
// 创建本地文件
|
||||
// File localFile = new File("E:/xml_wjj/" + CalendarUtil.getDateTimeStrForFile() + "/" + remoteFile.getName());
|
||||
File localFile = new File(myConfig.getToolSettingXmlPath() + CalendarUtil.getDateTimeStrForFile() + "/" + remoteFile.getName());
|
||||
if (!localFile.getParentFile().exists()) localFile.getParentFile().mkdirs();
|
||||
if (!localFile.exists()) localFile.createNewFile();
|
||||
else {
|
||||
localFile.delete();
|
||||
localFile.createNewFile();
|
||||
}
|
||||
in = new BufferedInputStream(new SmbFileInputStream(remoteFile));
|
||||
// 获取远程输出流
|
||||
out = new BufferedOutputStream(new FileOutputStream(localFile));
|
||||
byte[] buffer = new byte[4096];
|
||||
int len = 0;
|
||||
// 写入
|
||||
while ((len = in.read(buffer, 0, buffer.length)) != -1) {
|
||||
out.write(buffer, 0, len);
|
||||
}
|
||||
out.flush(); // 刷新缓冲
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
try {
|
||||
if (out != null) out.close();
|
||||
if (in != null) in.close();
|
||||
} catch (Exception e){
|
||||
System.out.println("==============START=================");
|
||||
System.out.println("关闭资源发生错误!");
|
||||
System.out.println("===============END==================");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增工具台账
|
||||
*
|
||||
|
@ -96,7 +96,7 @@ public class WmsInTaskController extends BaseController {
|
||||
@GetMapping("/open/list")
|
||||
public TableDataInfo openList(WmsInTask wmsInTask) {
|
||||
startPage();
|
||||
List<WmsInTask> list = wmsInTaskService.selectWmsInTaskList(wmsInTask);
|
||||
List<WmsInTask> list = wmsInTaskService.selectWmsInTaskListOpen(wmsInTask);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,14 @@ public interface IWmsInTaskService
|
||||
*/
|
||||
public List<WmsInTask> selectWmsInTaskList(WmsInTask wmsInTask);
|
||||
|
||||
/**
|
||||
* 查询入库任务列表 开放
|
||||
*
|
||||
* @param wmsInTask 入库任务
|
||||
* @return 入库任务集合
|
||||
*/
|
||||
public List<WmsInTask> selectWmsInTaskListOpen(WmsInTask wmsInTask);
|
||||
|
||||
/**
|
||||
* 新增入库任务
|
||||
*
|
||||
|
@ -75,6 +75,17 @@ public class WmsInTaskServiceImpl implements IWmsInTaskService {
|
||||
return wmsInTaskList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询入库任务列表 开放
|
||||
*
|
||||
* @param wmsInTask 入库任务
|
||||
* @return 入库任务
|
||||
*/
|
||||
@Override
|
||||
public List<WmsInTask> selectWmsInTaskListOpen(WmsInTask wmsInTask) {
|
||||
return wmsInTaskMapper.selectWmsInTaskList(wmsInTask);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增入库任务
|
||||
*
|
||||
|
@ -1,12 +1,15 @@
|
||||
package com.ktg.mes.wm.service.impl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ktg.common.constant.UserConstants;
|
||||
import com.ktg.common.core.domain.AjaxResult;
|
||||
import com.ktg.common.utils.DateUtils;
|
||||
import com.ktg.common.utils.StringUtils;
|
||||
import com.ktg.generator.util.MultiModuleCodeGenerator;
|
||||
import com.ktg.mes.cal.utils.CalendarUtil;
|
||||
import com.ktg.mes.md.domain.*;
|
||||
import com.ktg.mes.md.mapper.*;
|
||||
import com.ktg.mes.md.service.IBaseKnifeService;
|
||||
@ -20,6 +23,7 @@ import com.ktg.mes.wm.service.IWmsInPlanService;
|
||||
import com.ktg.mes.wm.service.IWmsInTaskService;
|
||||
import com.ktg.system.mapper.SysOperLogMapper;
|
||||
import com.ktg.system.service.ISysOperLogService;
|
||||
import okhttp3.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ktg.mes.wm.service.IWmsZdTaskService;
|
||||
@ -74,6 +78,9 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
|
||||
@Autowired
|
||||
private ProductionArrangementsMapper productionArrangementsMapper;
|
||||
|
||||
@Autowired
|
||||
private MyConfig myConfig;
|
||||
|
||||
/**
|
||||
* 查询组装任务
|
||||
*
|
||||
@ -388,7 +395,8 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
|
||||
wmsInPlanTemp.setCellCode(wmStorageArea.getAreaCode());
|
||||
wmsInPlanTemp.setPlanCode(zdTask.getPlanSheet() != null ? zdTask.getPlanSheet() : zdTask.getCode());
|
||||
wmsInPlanTemp.setRelBillCode("组装单据");
|
||||
wmsInPlanTemp.setPlanTypeId(13L);
|
||||
wmsInPlanTemp.setPlanTypeId(9L);
|
||||
wmsInPlanTemp.setPlanTypeCode("ZDHK");
|
||||
wmsInPlanTemp.setCreateBy(getUsername());
|
||||
wmsInPlanTemp.setCreateTime(DateUtils.getNowDate());
|
||||
|
||||
@ -487,12 +495,14 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
|
||||
List<BaseTechnologyBom> baseTechnologyBomList = baseTechnologyBomMapper.selectBaseTechnologyBomList(baseTechnologyBomWrapper);
|
||||
|
||||
// 判断订单锁定的物料是否足够
|
||||
Map<String, Integer> coutMap = new HashMap<>();
|
||||
for (BaseTechnologyBom technologyBom : baseTechnologyBomList) {
|
||||
coutMap.merge(technologyBom.getKnifeCode(), technologyBom.getKnifeCount(), Integer::sum);
|
||||
BaseKnife baseKnifeWrapper = new BaseKnife();
|
||||
baseKnifeWrapper.setPlanSheet(planSheet);
|
||||
baseKnifeWrapper.setKnifeCode(technologyBom.getKnifeCode());
|
||||
List<BaseKnife> baseKnifePlanSheetList = baseKnifeMapper.selectBaseKnifeList(baseKnifeWrapper);
|
||||
if (baseKnifePlanSheetList.size() < technologyBom.getKnifeCount()) return false;
|
||||
if (baseKnifePlanSheetList.size() < coutMap.get(technologyBom.getKnifeCode())) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -500,7 +510,7 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
|
||||
|
||||
// 检查订单完成状态
|
||||
@Transactional
|
||||
public void createOutTask(String planSheet){
|
||||
public void createOutTask(String planSheet) throws IOException {
|
||||
// 构建出库计划
|
||||
WmsOutPlan outPlan = new WmsOutPlan();
|
||||
outPlan.setPlanCode(planSheet);
|
||||
@ -521,12 +531,16 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
|
||||
List<BaseTechnologyBom> baseTechnologyBomList = baseTechnologyBomMapper.selectBaseTechnologyBomList(baseTechnologyBomWrapper);
|
||||
|
||||
// 判断订单锁定的物料是否足够
|
||||
for (BaseTechnologyBom technologyBom : baseTechnologyBomList) {
|
||||
BaseKnife baseKnifeWrapper = new BaseKnife();
|
||||
Map<String, Integer> coutMap = new HashMap<>();
|
||||
for (BaseTechnologyBom technologyBom : baseTechnologyBomList)
|
||||
coutMap.merge(technologyBom.getKnifeCode(), technologyBom.getKnifeCount(), Integer::sum);
|
||||
|
||||
for (Map.Entry<String, Integer> item : coutMap.entrySet()) {
|
||||
BaseKnife baseKnifeWrapper = new BaseKnife();
|
||||
baseKnifeWrapper.setPlanSheet(planSheet);
|
||||
baseKnifeWrapper.setKnifeCode(technologyBom.getKnifeCode());
|
||||
baseKnifeWrapper.setKnifeCode(item.getKey());
|
||||
List<BaseKnife> baseKnifeLockedList = baseKnifeMapper.selectBaseKnifeList(baseKnifeWrapper);
|
||||
if (baseKnifeLockedList.size() == technologyBom.getKnifeCount()) baseKnifeResultList.addAll(baseKnifeLockedList);
|
||||
if (baseKnifeLockedList.size() == item.getValue()) baseKnifeResultList.addAll(baseKnifeLockedList);
|
||||
}
|
||||
|
||||
String batchNum = "SCZBPC01";
|
||||
@ -619,5 +633,69 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService
|
||||
|
||||
productionArrangements.setStatus(1);
|
||||
productionArrangementsMapper.updateProductionArrangements(productionArrangements);
|
||||
|
||||
// 给产线控制系统发指令
|
||||
productionArrangementsIsOk(productionArrangements);
|
||||
}
|
||||
|
||||
// 调用生产准备完成接口
|
||||
public void productionArrangementsIsOk(ProductionArrangements productionArrangements) throws IOException {
|
||||
// 产线控制系统生产准备完成接口
|
||||
String url = myConfig.getProductionControlPath() + "/cutterapi/cutComplete";
|
||||
|
||||
// 请求客户端
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
|
||||
// 构建请求数据
|
||||
Map<String, Object> requestMap = new HashMap<>();
|
||||
requestMap.put("prodordercode", productionArrangements.getPlanSheet());
|
||||
requestMap.put("result", "0");
|
||||
requestMap.put("completetime", CalendarUtil.getDateTimeStr());
|
||||
|
||||
// 获取工艺信息
|
||||
BaseTechnologyBom technologyBomWrapper = new BaseTechnologyBom();
|
||||
technologyBomWrapper.setTechnologyCode(productionArrangements.getTechnologyCode());
|
||||
List<BaseTechnologyBom> technologyBomList = baseTechnologyBomMapper.selectBaseTechnologyBomList(technologyBomWrapper);
|
||||
|
||||
BaseKnife baseKnifeWrapper = new BaseKnife();
|
||||
baseKnifeWrapper.setPlanSheet(productionArrangements.getPlanSheet());
|
||||
|
||||
// 获取刀具信息
|
||||
List<Map<String, String>> cutterList = new ArrayList<>();
|
||||
technologyBomList.forEach(baseTechnologyBom -> {
|
||||
baseKnifeWrapper.setKnifeCode(baseTechnologyBom.getKnifeCode());
|
||||
List<BaseKnife> baseKnifeList = baseKnifeMapper.selectBaseKnifeList(baseKnifeWrapper);
|
||||
baseKnifeList.forEach(baseKnife -> {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("specno", baseTechnologyBom.getProcessCode());
|
||||
map.put("code", baseKnife.getKnifeCode());
|
||||
map.put("name", baseKnife.getKnifeName());
|
||||
map.put("life", baseKnife.getKnifeLife().toString());
|
||||
cutterList.add(map);
|
||||
});
|
||||
});
|
||||
requestMap.put("cutterinfo", cutterList);
|
||||
|
||||
// 构建请求数据
|
||||
MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
|
||||
RequestBody requestBody = RequestBody.create(mediaType, JSON.toJSONString(requestMap));
|
||||
|
||||
// 请求体
|
||||
Request request = new Request.Builder()
|
||||
.url(url)
|
||||
.post(requestBody)
|
||||
.build();
|
||||
|
||||
// 发送请求
|
||||
try(Response response = client.newCall(request).execute()) {
|
||||
if (!response.isSuccessful())
|
||||
throw new IOException("Unexpected code " + response);
|
||||
|
||||
// 请求响应
|
||||
String responseBody = response.body().string();
|
||||
System.out.println(responseBody);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user