Commit 701a4d4d authored by wanghao's avatar wanghao

1 通过 验证 从 MES 获取 标检单功能实现

parent 9d7953d8
......@@ -77,3 +77,5 @@ WHERE
ALTER TABLE `t_storey_info`
ADD COLUMN `f_estimated_end_time` datetime DEFAULT NULL COMMENT '预计老化结束时间';
-- src/assets/styles/variables.scss $sideBarWidth 修改左边栏宽度
package com.zehong.web.controller.equipment;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.core.page.TableDataInfo;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.system.domain.ProductStandardInspection;
import com.zehong.system.service.IProductStandardInspectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 产品主体标检单Controller
*
* @author zehong
* @date 2026-01-17
*/
@RestController
@RequestMapping("/system/inspection")
public class ProductStandardInspectionController extends BaseController
{
@Autowired
private IProductStandardInspectionService productStandardInspectionService;
/**
* 查询产品主体标检单列表
*/
@GetMapping("/list")
public TableDataInfo list(ProductStandardInspection productStandardInspection)
{
startPage();
List<ProductStandardInspection> list = productStandardInspectionService.selectProductStandardInspectionList(productStandardInspection);
return getDataTable(list);
}
/**
* 导出产品主体标检单列表
*/
@GetMapping("/export")
public AjaxResult export(ProductStandardInspection productStandardInspection)
{
List<ProductStandardInspection> list = productStandardInspectionService.selectProductStandardInspectionList(productStandardInspection);
ExcelUtil<ProductStandardInspection> util = new ExcelUtil<ProductStandardInspection>(ProductStandardInspection.class);
return util.exportExcel(list, "产品主体标检单数据");
}
/**
* 同步MES数据
*/
@GetMapping("/syncMESData")
public void syncMESData() {
productStandardInspectionService.syncMESData();
}
/**
* 获取产品主体标检单详细信息
*/
@GetMapping(value = "/{productStandardInspectionId}")
public AjaxResult getInfo(@PathVariable("productStandardInspectionId") Long productStandardInspectionId)
{
return AjaxResult.success(productStandardInspectionService.selectProductStandardInspectionById(productStandardInspectionId));
}
/**
* 新增产品主体标检单
*/
@PostMapping
public AjaxResult add(@RequestBody ProductStandardInspection productStandardInspection)
{
return toAjax(productStandardInspectionService.insertProductStandardInspection(productStandardInspection));
}
/**
* 修改产品主体标检单
*/
@PutMapping
public AjaxResult edit(@RequestBody ProductStandardInspection productStandardInspection)
{
return toAjax(productStandardInspectionService.updateProductStandardInspection(productStandardInspection));
}
/**
* 删除产品主体标检单
*/
@DeleteMapping("/{productStandardInspectionIds}")
public AjaxResult remove(@PathVariable Long[] productStandardInspectionIds)
{
return toAjax(productStandardInspectionService.deleteProductStandardInspectionByIds(productStandardInspectionIds));
}
}
......@@ -9,6 +9,18 @@ public class RoboticArmConstans {
// 上传MES地址的key
public static final String UPLOAD_MES_ADDRESS = "uploadMesAddress";
// 标检单地址的key
public static final String STANDARD_INSPECTION_ADDRESS = "standardInspectionAddress";
public static final String MES_TOKEN = "mes:token";
public static final String MES_LOGIN_URL = "mes.login.url";
public static final String MES_USERNAME = "mes.username";
public static final String MES_PASSWORD = "mes.password";
/**
* 老化流程第一阶段执行时间(单位:分钟)
*/
......
......@@ -49,6 +49,16 @@ public class RedisCache
redisTemplate.opsForValue().set(key, value, timeout, timeUnit);
}
/**
* 获取键的剩余过期时间
* @param key Redis键
* @param timeUnit 时间单位
* @return 剩余时间,单位由timeUnit指定
*/
public Long getExpire(final String key, final TimeUnit timeUnit) {
return redisTemplate.getExpire(key, timeUnit);
}
/**
* 设置有效时间
*
......
......@@ -4,12 +4,15 @@ import java.io.*;
import java.net.*;
import java.nio.charset.StandardCharsets;
import java.security.cert.X509Certificate;
import java.util.Map;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import com.alibaba.fastjson.JSON;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.zehong.common.constant.Constants;
......@@ -23,6 +26,8 @@ public class HttpUtils
{
private static final Logger log = LoggerFactory.getLogger(HttpUtils.class);
private static final int CONNECT_TIMEOUT = 5000; // 5秒
private static final int READ_TIMEOUT = 30000; // 30秒
/**
* 向指定 URL 发送GET方法的请求
*
......@@ -250,4 +255,229 @@ public class HttpUtils
return true;
}
}
/**
* 发送GET请求(带请求头和查询参数)
*/
public static String get(String url, Map<String, String> headers, Map<String, Object> params) {
HttpURLConnection connection = null;
BufferedReader reader = null;
try {
// 构建带参数的URL
String fullUrl = buildUrlWithParams(url, params);
log.debug("GET请求URL: {}", fullUrl);
if (headers != null) {
log.debug("GET请求头: {}", JSON.toJSONString(headers));
}
URL requestUrl = new URL(fullUrl);
connection = (HttpURLConnection) requestUrl.openConnection();
// 设置连接参数
connection.setRequestMethod("GET");
connection.setConnectTimeout(CONNECT_TIMEOUT);
connection.setReadTimeout(READ_TIMEOUT);
connection.setDoInput(true);
// 设置通用请求头
connection.setRequestProperty("Accept", "application/json, text/plain, */*");
connection.setRequestProperty("Connection", "keep-alive");
// 设置自定义请求头
if (headers != null) {
for (Map.Entry<String, String> entry : headers.entrySet()) {
connection.setRequestProperty(entry.getKey(), entry.getValue());
}
}
// 发起请求
connection.connect();
// 获取响应码
int responseCode = connection.getResponseCode();
// 读取响应
InputStream inputStream;
if (responseCode >= 200 && responseCode < 300) {
inputStream = connection.getInputStream();
} else {
inputStream = connection.getErrorStream();
}
reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
StringBuilder response = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
response.append(line);
}
String responseBody = response.toString();
log.debug("GET响应码: {}, 响应体: {}", responseCode, responseBody);
if (responseCode >= 200 && responseCode < 300) {
return responseBody;
} else {
throw new IOException("HTTP GET请求失败,状态码: " + responseCode + ",响应: " + responseBody);
}
} catch (Exception e) {
log.error("GET请求异常, URL: {}", url, e);
throw new RuntimeException("GET请求失败", e);
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
log.warn("关闭读取流异常", e);
}
}
if (connection != null) {
connection.disconnect();
}
}
}
/**
* 发送POST请求(JSON格式)
*/
public static String postJson(String url, Map<String, String> headers, Object body) {
return requestWithBody("POST", url, headers, JSON.toJSONString(body), "application/json");
}
/**
* 发送带请求体的请求
*/
private static String requestWithBody(String method, String url, Map<String, String> headers,
String body, String contentType) {
HttpURLConnection connection = null;
BufferedReader reader = null;
OutputStreamWriter writer = null;
try {
log.debug("{}请求URL: {}", method, url);
log.debug("{}请求头: {}", method, JSON.toJSONString(headers));
log.debug("{}请求体: {}", method, body);
URL requestUrl = new URL(url);
connection = (HttpURLConnection) requestUrl.openConnection();
// 设置连接参数
connection.setRequestMethod(method);
connection.setConnectTimeout(CONNECT_TIMEOUT);
connection.setReadTimeout(READ_TIMEOUT);
connection.setDoInput(true);
connection.setDoOutput(true);
// 设置通用请求头
connection.setRequestProperty("Accept", "application/json, text/plain, */*");
connection.setRequestProperty("Connection", "keep-alive");
// 设置内容类型
if (contentType != null) {
connection.setRequestProperty("Content-Type", contentType);
}
// 设置自定义请求头
if (headers != null) {
for (Map.Entry<String, String> entry : headers.entrySet()) {
connection.setRequestProperty(entry.getKey(), entry.getValue());
}
}
// 发送请求体
if (body != null) {
writer = new OutputStreamWriter(connection.getOutputStream(), StandardCharsets.UTF_8);
writer.write(body);
writer.flush();
}
// 获取响应码
int responseCode = connection.getResponseCode();
// 读取响应
InputStream inputStream;
if (responseCode >= 200 && responseCode < 300) {
inputStream = connection.getInputStream();
} else {
inputStream = connection.getErrorStream();
}
reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
StringBuilder response = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
response.append(line);
}
String responseBody = response.toString();
log.debug("{}响应码: {}, 响应体: {}", method, responseCode, responseBody);
if (responseCode >= 200 && responseCode < 300) {
return responseBody;
} else {
throw new IOException("HTTP " + method + "请求失败,状态码: " + responseCode + ",响应: " + responseBody);
}
} catch (Exception e) {
log.error("{}请求异常, URL: {}", method, url, e);
throw new RuntimeException(method + "请求失败", e);
} finally {
if (writer != null) {
try {
writer.close();
} catch (IOException e) {
log.warn("关闭写入流异常", e);
}
}
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
log.warn("关闭读取流异常", e);
}
}
if (connection != null) {
connection.disconnect();
}
}
}
/**
* 构建带参数的URL
*/
private static String buildUrlWithParams(String url, Map<String, Object> params) {
if (params == null || params.isEmpty()) {
return url;
}
StringBuilder urlBuilder = new StringBuilder(url);
// 检查URL是否已包含参数
boolean hasQuery = url.contains("?");
for (Map.Entry<String, Object> entry : params.entrySet()) {
if (!hasQuery) {
urlBuilder.append("?");
hasQuery = true;
} else {
urlBuilder.append("&");
}
try {
urlBuilder.append(URLEncoder.encode(entry.getKey(), "UTF-8"))
.append("=")
.append(URLEncoder.encode(String.valueOf(entry.getValue()), "UTF-8"));
} catch (UnsupportedEncodingException e) {
// 使用默认编码
urlBuilder.append(entry.getKey())
.append("=")
.append(entry.getValue());
}
}
return urlBuilder.toString();
}
}
package com.zehong.system.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.zehong.common.annotation.Excel;
import com.zehong.common.core.domain.BaseEntity;
/**
* 产品主体标检单对象 t_product_standard_inspection
*
* @author zehong
* @date 2026-01-17
*/
public class ProductStandardInspection extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** id */
private Long productStandardInspectionId;
/** 出库单号 */
@Excel(name = "出库单号")
private String outStoreOrderNumber;
/** 主体标检单号 */
@Excel(name = "主体标检单号")
private String productStandardInspectionNumber;
/** 确认标检人 */
@Excel(name = "确认标检人")
private String confirmQualityInspector;
/** 备注 */
@Excel(name = "备注")
private String remarks;
/** 状态 (PENDING_STANDARD_INSPECTION-待标检;DURING_STANDARD_INSPECTION-标检中;STANDARD_INSPECTION_COMPLETED-标检完成) */
@Excel(name = "状态 (PENDING_STANDARD_INSPECTION-待标检;DURING_STANDARD_INSPECTION-标检中;STANDARD_INSPECTION_COMPLETED-标检完成) ")
private String status;
/** 报检部门 */
@Excel(name = "报检部门")
private String inspectionDep;
/** 删除标志,默认0,删除1 */
@Excel(name = "删除标志,默认0,删除1")
private Integer deleteFlag;
/** 物料名称 */
@Excel(name = "物料名称")
private String materialName;
/** 物料代码 */
@Excel(name = "物料代码")
private String materialCode;
/** 规格型号 */
@Excel(name = "规格型号")
private String specification;
/** 领料数量 */
@Excel(name = "领料数量")
private Long issuedNum;
/** 申请数量 */
@Excel(name = "申请数量")
private Long quantity;
/** 合格数量 */
@Excel(name = "合格数量")
private Long qualifiedNum;
/** 不合格数量 */
@Excel(name = "不合格数量")
private Long unQualifiedNum;
/** 老化时长 */
@Excel(name = "老化时长")
private String agingDuration;
/** 标定气体 */
@Excel(name = "标定气体")
private String calibrationGas;
/** 报警值 */
@Excel(name = "报警值")
private String alarmValue;
/** 量程 */
@Excel(name = "量程")
private String range;
public void setProductStandardInspectionId(Long productStandardInspectionId)
{
this.productStandardInspectionId = productStandardInspectionId;
}
public Long getProductStandardInspectionId()
{
return productStandardInspectionId;
}
public void setOutStoreOrderNumber(String outStoreOrderNumber)
{
this.outStoreOrderNumber = outStoreOrderNumber;
}
public String getOutStoreOrderNumber()
{
return outStoreOrderNumber;
}
public void setProductStandardInspectionNumber(String productStandardInspectionNumber)
{
this.productStandardInspectionNumber = productStandardInspectionNumber;
}
public String getProductStandardInspectionNumber()
{
return productStandardInspectionNumber;
}
public void setConfirmQualityInspector(String confirmQualityInspector)
{
this.confirmQualityInspector = confirmQualityInspector;
}
public String getConfirmQualityInspector()
{
return confirmQualityInspector;
}
public void setRemarks(String remarks)
{
this.remarks = remarks;
}
public String getRemarks()
{
return remarks;
}
public void setStatus(String status)
{
this.status = status;
}
public String getStatus()
{
return status;
}
public void setInspectionDep(String inspectionDep)
{
this.inspectionDep = inspectionDep;
}
public String getInspectionDep()
{
return inspectionDep;
}
public void setDeleteFlag(Integer deleteFlag)
{
this.deleteFlag = deleteFlag;
}
public Integer getDeleteFlag()
{
return deleteFlag;
}
public void setMaterialName(String materialName)
{
this.materialName = materialName;
}
public String getMaterialName()
{
return materialName;
}
public void setMaterialCode(String materialCode)
{
this.materialCode = materialCode;
}
public String getMaterialCode()
{
return materialCode;
}
public void setSpecification(String specification)
{
this.specification = specification;
}
public String getSpecification()
{
return specification;
}
public void setIssuedNum(Long issuedNum)
{
this.issuedNum = issuedNum;
}
public Long getIssuedNum()
{
return issuedNum;
}
public void setQuantity(Long quantity)
{
this.quantity = quantity;
}
public Long getQuantity()
{
return quantity;
}
public void setQualifiedNum(Long qualifiedNum)
{
this.qualifiedNum = qualifiedNum;
}
public Long getQualifiedNum()
{
return qualifiedNum;
}
public void setUnQualifiedNum(Long unQualifiedNum)
{
this.unQualifiedNum = unQualifiedNum;
}
public Long getUnQualifiedNum()
{
return unQualifiedNum;
}
public void setAgingDuration(String agingDuration)
{
this.agingDuration = agingDuration;
}
public String getAgingDuration()
{
return agingDuration;
}
public void setCalibrationGas(String calibrationGas)
{
this.calibrationGas = calibrationGas;
}
public String getCalibrationGas()
{
return calibrationGas;
}
public void setAlarmValue(String alarmValue)
{
this.alarmValue = alarmValue;
}
public String getAlarmValue()
{
return alarmValue;
}
public void setRange(String range)
{
this.range = range;
}
public String getRange()
{
return range;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("productStandardInspectionId", getProductStandardInspectionId())
.append("outStoreOrderNumber", getOutStoreOrderNumber())
.append("productStandardInspectionNumber", getProductStandardInspectionNumber())
.append("confirmQualityInspector", getConfirmQualityInspector())
.append("remarks", getRemarks())
.append("status", getStatus())
.append("createBy", getCreateBy())
.append("inspectionDep", getInspectionDep())
.append("createTime", getCreateTime())
.append("deleteFlag", getDeleteFlag())
.append("materialName", getMaterialName())
.append("materialCode", getMaterialCode())
.append("specification", getSpecification())
.append("issuedNum", getIssuedNum())
.append("quantity", getQuantity())
.append("qualifiedNum", getQualifiedNum())
.append("unQualifiedNum", getUnQualifiedNum())
.append("agingDuration", getAgingDuration())
.append("calibrationGas", getCalibrationGas())
.append("alarmValue", getAlarmValue())
.append("range", getRange())
.toString();
}
}
package com.zehong.system.mapper;
import java.util.List;
import com.zehong.system.domain.ProductStandardInspection;
/**
* 产品主体标检单Mapper接口
*
* @author zehong
* @date 2026-01-17
*/
public interface ProductStandardInspectionMapper
{
/**
* 查询产品主体标检单
*
* @param productStandardInspectionId 产品主体标检单ID
* @return 产品主体标检单
*/
public ProductStandardInspection selectProductStandardInspectionById(Long productStandardInspectionId);
/**
* 查询产品主体标检单列表
*
* @param productStandardInspection 产品主体标检单
* @return 产品主体标检单集合
*/
public List<ProductStandardInspection> selectProductStandardInspectionList(ProductStandardInspection productStandardInspection);
/**
* 新增产品主体标检单
*
* @param productStandardInspection 产品主体标检单
* @return 结果
*/
public int insertProductStandardInspection(ProductStandardInspection productStandardInspection);
/**
* 修改产品主体标检单
*
* @param productStandardInspection 产品主体标检单
* @return 结果
*/
public int updateProductStandardInspection(ProductStandardInspection productStandardInspection);
/**
* 删除产品主体标检单
*
* @param productStandardInspectionId 产品主体标检单ID
* @return 结果
*/
public int deleteProductStandardInspectionById(Long productStandardInspectionId);
/**
* 批量删除产品主体标检单
*
* @param productStandardInspectionIds 需要删除的数据ID
* @return 结果
*/
public int deleteProductStandardInspectionByIds(Long[] productStandardInspectionIds);
}
package com.zehong.system.service;
import java.util.List;
import com.zehong.system.domain.ProductStandardInspection;
/**
* 产品主体标检单Service接口
*
* @author zehong
* @date 2026-01-17
*/
public interface IProductStandardInspectionService
{
/**
* 查询产品主体标检单
*
* @param productStandardInspectionId 产品主体标检单ID
* @return 产品主体标检单
*/
public ProductStandardInspection selectProductStandardInspectionById(Long productStandardInspectionId);
/**
* 查询产品主体标检单列表
*
* @param productStandardInspection 产品主体标检单
* @return 产品主体标检单集合
*/
public List<ProductStandardInspection> selectProductStandardInspectionList(ProductStandardInspection productStandardInspection);
/**
* 同步MES数据
*/
public void syncMESData();
/**
* 新增产品主体标检单
*
* @param productStandardInspection 产品主体标检单
* @return 结果
*/
public int insertProductStandardInspection(ProductStandardInspection productStandardInspection);
/**
* 修改产品主体标检单
*
* @param productStandardInspection 产品主体标检单
* @return 结果
*/
public int updateProductStandardInspection(ProductStandardInspection productStandardInspection);
/**
* 批量删除产品主体标检单
*
* @param productStandardInspectionIds 需要删除的产品主体标检单ID
* @return 结果
*/
public int deleteProductStandardInspectionByIds(Long[] productStandardInspectionIds);
/**
* 删除产品主体标检单信息
*
* @param productStandardInspectionId 产品主体标检单ID
* @return 结果
*/
public int deleteProductStandardInspectionById(Long productStandardInspectionId);
}
package com.zehong.system.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.zehong.common.constant.RoboticArmConstans;
import com.zehong.common.core.redis.RedisCache;
import com.zehong.common.utils.DateUtils;
import com.zehong.common.utils.http.HttpUtils;
import com.zehong.system.domain.ProductStandardInspection;
import com.zehong.system.mapper.ProductStandardInspectionMapper;
import com.zehong.system.service.IProductStandardInspectionService;
import com.zehong.system.service.ISysConfigService;
import io.netty.handler.codec.http.HttpUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* 产品主体标检单Service业务层处理
*
* @author zehong
* @date 2026-01-17
*/
@Service
public class ProductStandardInspectionServiceImpl implements IProductStandardInspectionService
{
public static final Logger logger = LoggerFactory.getLogger(ProductStandardInspectionServiceImpl.class);
@Resource
private ProductStandardInspectionMapper productStandardInspectionMapper;
@Resource
private ISysConfigService sysConfigService;
@Resource
private RedisCache redisCache;
/**
* 查询产品主体标检单
*
* @param productStandardInspectionId 产品主体标检单ID
* @return 产品主体标检单
*/
@Override
public ProductStandardInspection selectProductStandardInspectionById(Long productStandardInspectionId)
{
return productStandardInspectionMapper.selectProductStandardInspectionById(productStandardInspectionId);
}
/**
* 查询产品主体标检单列表
*
* @param productStandardInspection 产品主体标检单
* @return 产品主体标检单
*/
@Override
public List<ProductStandardInspection> selectProductStandardInspectionList(ProductStandardInspection productStandardInspection)
{
return productStandardInspectionMapper.selectProductStandardInspectionList(productStandardInspection);
}
/**
* 同步MES数据
*/
@Override
public void syncMESData() {
String standardInspectionAddress = sysConfigService.directSelectConfigByKey(RoboticArmConstans.STANDARD_INSPECTION_ADDRESS);
if (StringUtils.isBlank(standardInspectionAddress)) {
throw new RuntimeException("MES地址未配置");
}
// 2. 获取token
String token = getMESToken();
if (StringUtils.isBlank(token)) {
throw new RuntimeException("MES token未获取");
}
// 3. 构造请求头
Map<String, String> headers = new HashMap<>();
headers.put("Authorization", "Bearer " + token);
headers.put("Content-Type", "application/json");
// 4. 调用MES接口
String result = HttpUtils.get(standardInspectionAddress, headers, null);
if (StringUtils.isNotBlank(result)) {
// 5. 处理返回的数据
processMESData(result);
logger.info("MES数据同步成功");
} else {
throw new RuntimeException("MES接口调用失败");
}
}
/**
* 获取MES token
*/
private String getMESToken() {
// 1. 先从Redis中获取token
Object tokenObj = redisCache.getCacheObject(RoboticArmConstans.MES_TOKEN);
if (tokenObj != null) {
String token = tokenObj.toString();
// 检查token是否即将过期(提前5分钟刷新)
long expireTime = redisCache.getExpire(RoboticArmConstans.MES_TOKEN, TimeUnit.MINUTES);
if (expireTime > 1) { // 大于1分钟,直接返回
return token;
}
}
// 2. 如果Redis中没有或即将过期,重新获取token
return refreshMESToken();
}
/**
* 刷新MES token
*/
private String refreshMESToken() {
try {
// 1. 获取登录配置信息
String loginUrl = sysConfigService.directSelectConfigByKey(RoboticArmConstans.MES_LOGIN_URL);
String username = sysConfigService.directSelectConfigByKey(RoboticArmConstans.MES_USERNAME);
String password = sysConfigService.directSelectConfigByKey(RoboticArmConstans.MES_PASSWORD);
if (StringUtils.isAnyBlank(loginUrl, username, password)) {
throw new RuntimeException("MES登录配置信息不完整");
}
// 2. 构造登录参数
Map<String, String> loginParams = new HashMap<>();
loginParams.put("username", username);
loginParams.put("password", password);
// 3. 调用登录接口
String response = HttpUtils.sendPost(loginUrl, JSON.toJSONString(loginParams));
if (StringUtils.isNotBlank(response)) {
// 4. 解析返回的token(根据实际接口返回格式调整)
String token = parseTokenFromResponse(response);
if (StringUtils.isNotBlank(token)) {
// 5. 将token存储到Redis,设置过期时间
redisCache.setCacheObject(RoboticArmConstans.MES_TOKEN, token, 300, TimeUnit.MINUTES); // 5分钟
return token;
}
}
throw new RuntimeException("获取MES token失败");
} catch (Exception e) {
throw new RuntimeException("刷新MES token异常", e);
}
}
/**
* 从响应中解析token(根据实际接口返回格式调整)
*/
private String parseTokenFromResponse(String response) {
try {
// 假设返回格式为:{"code": 200, "data": "abacadfsasd", "msg": "success"}
JSONObject jsonObject = JSON.parseObject(response);
if (jsonObject != null && jsonObject.getInteger("code") == 200) {
String token = jsonObject.getString("data");
if(StringUtils.isNotBlank(token)) {
return token;
} else {
throw new RuntimeException("获取MES token失败");
}
}
} catch (Exception e) {
logger.error("解析token失败,响应内容:{}", response, e);
}
return null;
}
/**
* 处理MES返回的数据
*/
private void processMESData(String data) {
// 根据实际业务需求处理数据
// 这里只是示例,具体实现根据您的业务逻辑
try {
JSONObject jsonData = JSON.parseObject(data);
// 处理数据逻辑...
logger.debug("接收到MES数据:{}", jsonData);
} catch (Exception e) {
logger.error("处理MES数据异常:", e);
}
}
/**
* 新增产品主体标检单
*
* @param productStandardInspection 产品主体标检单
* @return 结果
*/
@Override
public int insertProductStandardInspection(ProductStandardInspection productStandardInspection)
{
productStandardInspection.setCreateTime(DateUtils.getNowDate());
return productStandardInspectionMapper.insertProductStandardInspection(productStandardInspection);
}
/**
* 修改产品主体标检单
*
* @param productStandardInspection 产品主体标检单
* @return 结果
*/
@Override
public int updateProductStandardInspection(ProductStandardInspection productStandardInspection)
{
return productStandardInspectionMapper.updateProductStandardInspection(productStandardInspection);
}
/**
* 批量删除产品主体标检单
*
* @param productStandardInspectionIds 需要删除的产品主体标检单ID
* @return 结果
*/
@Override
public int deleteProductStandardInspectionByIds(Long[] productStandardInspectionIds)
{
return productStandardInspectionMapper.deleteProductStandardInspectionByIds(productStandardInspectionIds);
}
/**
* 删除产品主体标检单信息
*
* @param productStandardInspectionId 产品主体标检单ID
* @return 结果
*/
@Override
public int deleteProductStandardInspectionById(Long productStandardInspectionId)
{
return productStandardInspectionMapper.deleteProductStandardInspectionById(productStandardInspectionId);
}
}
{
"name": "zehong",
"version": "3.5.0",
"description": "泽宏管理系统",
"description": "泽宏老化监控平台",
"author": "泽宏",
"license": "MIT",
"scripts": {
......
import request from '@/utils/request'
// 查询产品主体标检单列表
export function listInspection(query) {
return request({
url: '/system/inspection/list',
method: 'get',
params: query
})
}
// 查询产品主体标检单详细
export function getInspection(productStandardInspectionId) {
return request({
url: '/system/inspection/' + productStandardInspectionId,
method: 'get'
})
}
// 新增产品主体标检单
export function addInspection(data) {
return request({
url: '/system/inspection',
method: 'post',
data: data
})
}
// 修改产品主体标检单
export function updateInspection(data) {
return request({
url: '/system/inspection',
method: 'put',
data: data
})
}
// 删除产品主体标检单
export function delInspection(productStandardInspectionId) {
return request({
url: '/system/inspection/' + productStandardInspectionId,
method: 'delete'
})
}
// 导出产品主体标检单
export function exportInspection(query) {
return request({
url: '/system/inspection/export',
method: 'get',
params: query
})
}
export function syncMESData() {
return request({
url: '/system/inspection/syncMESData',
method: 'get'
})
}
......@@ -24,7 +24,7 @@ $sidebarLightTitle: #001529;
$subMenuBg:#1f2d3d;
$subMenuHover:#001528;
$sideBarWidth: 200px;
$sideBarWidth: 250px;
// the :export directive is the magic sauce for webpack
// https://www.bluematador.com/blog/how-to-share-variables-between-js-and-sass
......
......@@ -35,7 +35,7 @@ export default {
},
data() {
return {
title: '泽宏管理系统',
title: '泽宏老化监控平台',
logo: logoImg
}
}
......
module.exports = {
title: '泽宏管理系统',
title: '泽宏老化监控平台',
/**
* 侧边栏主题 深色主题theme-dark,浅色主题theme-light
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment