update 物料定时任务、存储数据

master
yinq 2 days ago
parent 8019b3ed77
commit be476567ed

@ -1,6 +1,6 @@
package org.dromara.mes.api; package org.dromara.mes.api;
import org.dromara.mes.api.domain.bo.BaseMaterialInfoBo; import org.dromara.mes.api.model.bo.BaseMaterialInfoBo;
import java.util.List; import java.util.List;

@ -1,17 +1,19 @@
package org.dromara.mes.api.domain; package org.dromara.mes.api.model;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial; import java.io.Serial;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
/** /**
* base_material_info * base_material_info
* *
* @author zangch
* @date 2025-01-07
*/ */
@Data @Data
public class BaseMaterialInfo implements Serializable { public class BaseMaterialInfo {
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

@ -103,14 +103,17 @@
<groupId>org.dromara</groupId> <groupId>org.dromara</groupId>
<artifactId>ruoyi-api-resource</artifactId> <artifactId>ruoyi-api-resource</artifactId>
</dependency> </dependency>
<!-- <dependency>--> <!-- <dependency>-->
<!-- <groupId>com.mysql</groupId>--> <!-- <groupId>com.mysql</groupId>-->
<!-- <artifactId>mysql-connector-j</artifactId>--> <!-- <artifactId>mysql-connector-j</artifactId>-->
<!-- </dependency>--> <!-- </dependency>-->
<dependency> <dependency>
<groupId>com.microsoft.sqlserver</groupId> <groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId> <artifactId>mssql-jdbc</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.dromara</groupId> <groupId>org.dromara</groupId>
<artifactId>hwmom-api-mes</artifactId> <artifactId>hwmom-api-mes</artifactId>
@ -118,6 +121,11 @@
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>org.dromara</groupId>
<artifactId>ruoyi-common-job</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>

@ -0,0 +1,56 @@
package org.dromara.api.domain;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* @Author YinQ
* @create 2023-09-26 14:46
*/
public class SAPPortDto {
private static final long serialVersionUID = 1L;
/**
*
*/
@JsonProperty(value = "NDATE")
private String startDate;
/**
*
*/
@JsonProperty(value = "EDATE")
private String endDate;
/**
*
*/
@JsonProperty(value = "WERKS")
private WERKSDto factoryCodes;
public String getStartDate() {
return startDate;
}
public void setStartDate(String startDate) {
this.startDate = startDate;
}
public String getEndDate() {
return endDate;
}
public void setEndDate(String endDate) {
this.endDate = endDate;
}
public WERKSDto getFactoryCodes() {
return factoryCodes;
}
public void setFactoryCodes(WERKSDto factoryCodes) {
this.factoryCodes = factoryCodes;
}
}

@ -0,0 +1,33 @@
package org.dromara.api.domain;
import java.util.HashMap;
import java.util.List;
/**
* @Author YinQ
* @create 2023-09-26 15:13
*/
public class WERKSDto {
/**
* Map
*/
List<HashMap<String, String>> item;
public List<HashMap<String, String>> getItem() {
return item;
}
public void setItem(List<HashMap<String, String>> item) {
this.item = item;
}
@Override
public String toString() {
return "WERKSDto{" +
"item=" + item +
'}';
}
}

@ -0,0 +1,61 @@
package org.dromara.api.domain.vo;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.dromara.api.domain.WERKSDto;
import java.util.HashMap;
import java.util.List;
/**
*
*
* @Author YinQ
* @create 2023-09-27 13:37
*/
public class SAPResultVo {
@JsonProperty(value = "O_TAB")
private HashMap<String, List<HashMap<String, String>>> O_TAB;
@JsonProperty(value = "WERKS")
private WERKSDto WERKS;
@JsonProperty(value = "O_RETURN")
private WERKSDto O_RETURN;
public HashMap<String, List<HashMap<String, String>>> getO_TAB() {
return O_TAB;
}
public void setO_TAB(HashMap<String, List<HashMap<String, String>>> o_TAB) {
O_TAB = o_TAB;
}
public WERKSDto getWERKS() {
return WERKS;
}
public void setWERKS(WERKSDto WERKS) {
this.WERKS = WERKS;
}
public WERKSDto getO_RETURN() {
return O_RETURN;
}
public void setO_RETURN(WERKSDto o_RETURN) {
O_RETURN = o_RETURN;
}
public SAPResultVo() {
}
@Override
public String toString() {
return "SAPResultVo{" +
"O_TAB=" + O_TAB +
", WERKS='" + WERKS + '\'' +
", O_RETURN=" + O_RETURN +
'}';
}
}

@ -2,7 +2,7 @@ package org.dromara.api.service;
/** /**
* Service * APIService
* *
* @author Yinq * @author Yinq
* @date 2025-01-02 * @date 2025-01-02

@ -1,18 +1,22 @@
package org.dromara.api.service.impl; package org.dromara.api.service.impl;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.dubbo.config.annotation.DubboReference; import org.apache.dubbo.config.annotation.DubboReference;
import org.dromara.api.domain.SAPPortDto;
import org.dromara.api.domain.vo.SAPResultVo;
import org.dromara.api.service.IBaseMaterialInfoApiService; import org.dromara.api.service.IBaseMaterialInfoApiService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.dromara.mes.api.RemoteMaterialInfoService; import org.dromara.mes.api.RemoteMaterialInfoService;
import org.dromara.mes.api.domain.bo.BaseMaterialInfoBo; import org.dromara.mes.api.model.bo.BaseMaterialInfoBo;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
* Service * APIService
* *
* @author Yinq * @author Yinq
* @date 2025-01-02 * @date 2025-01-02
@ -26,8 +30,36 @@ public class BaseMaterialInfoApiServiceImpl implements IBaseMaterialInfoApiServi
@Override @Override
public String insertApi(String requestBody) { public String insertApi(String requestBody) {
List<BaseMaterialInfoBo> list = new ArrayList<>(); SAPPortDto sapPortDto = new SAPPortDto();
Boolean aBoolean = remoteMaterialInfoService.remoteInsertBaseMaterialInfo(list); //请求API接口获取数据
return null; List<BaseMaterialInfoBo> list = getMaterialData(sapPortDto);
//解析数据,存储实体类
remoteMaterialInfoService.remoteInsertBaseMaterialInfo(list);
return "success";
}
public List<BaseMaterialInfoBo> getMaterialData(SAPPortDto sapPortDto) {
List<BaseMaterialInfoBo> materialVos = new ArrayList<>();
String requestParam = null;
String result = null;
// 创建ObjectMapper实例 对象转JSON字符串
ObjectMapper objectMapper = new ObjectMapper();
// 格式化输出
// objectMapper.configure(SerializationFeature.INDENT_OUTPUT, true);
// requestParam = objectMapper.writeValueAsString(sapPortDto);
// result = ApiUtils.sendSAPHttpPost(SAPConstants.SAP_PREFIX_URL + SAPConstants.MATERIAL_URL, requestParam);
try {
// 处理接口返回消息
ObjectMapper resultMapper = new ObjectMapper();
// 将 JSON 字符串 转换为 Java 对象
SAPResultVo resultVo = resultMapper.readValue(result, SAPResultVo.class);
//转物料实体类 保存数据
// materialVos = storageService.insertSAPMaterialInfo(resultVo);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
return materialVos;
} }
} }

@ -0,0 +1,30 @@
package org.dromara.api.snailjob;
import com.aizuda.snailjob.client.job.core.annotation.JobExecutor;
import com.aizuda.snailjob.client.job.core.dto.JobArgs;
import com.aizuda.snailjob.client.model.ExecuteResult;
import com.aizuda.snailjob.common.core.util.JsonUtil;
import com.aizuda.snailjob.common.log.SnailJobLog;
import org.dromara.api.service.IBaseMaterialInfoApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author opensnail
* @date 2024-05-17
*/
@Component
@JobExecutor(name = "materialInfoJobExecutor")
public class MaterialInfoJobExecutor {
@Autowired
IBaseMaterialInfoApiService baseMaterialInfoApiService;
public ExecuteResult jobExecute(JobArgs jobArgs) {
String jobParams = String.valueOf(jobArgs.getJobParams());
String result = baseMaterialInfoApiService.insertApi(jobParams);
SnailJobLog.LOCAL.info("materialInfoJobExecutor.jobArgs:{}", JsonUtil.toJsonString(jobArgs));
return ExecuteResult.success(result);
}
}

@ -4,7 +4,7 @@ import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboService; import org.apache.dubbo.config.annotation.DubboService;
import org.dromara.common.core.utils.MapstructUtils; import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.mes.api.RemoteMaterialInfoService; import org.dromara.mes.api.RemoteMaterialInfoService;
import org.dromara.mes.api.domain.bo.BaseMaterialInfoBo; import org.dromara.mes.api.model.bo.BaseMaterialInfoBo;
import org.dromara.mes.domain.BaseMaterialInfo; import org.dromara.mes.domain.BaseMaterialInfo;
import org.dromara.mes.mapper.BaseMaterialInfoMapper; import org.dromara.mes.mapper.BaseMaterialInfoMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;

@ -40,6 +40,12 @@
<artifactId>spring-boot-admin-starter-client</artifactId> <artifactId>spring-boot-admin-starter-client</artifactId>
<version>${spring-boot-admin.version}</version> <version>${spring-boot-admin.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>

Loading…
Cancel
Save