diff --git a/ruoyi-api/hwmom-api-mes/src/main/java/org/dromara/mes/api/RemoteMaterialInfoService.java b/ruoyi-api/hwmom-api-mes/src/main/java/org/dromara/mes/api/RemoteMaterialInfoService.java index fda0e6cf..9b4b205d 100644 --- a/ruoyi-api/hwmom-api-mes/src/main/java/org/dromara/mes/api/RemoteMaterialInfoService.java +++ b/ruoyi-api/hwmom-api-mes/src/main/java/org/dromara/mes/api/RemoteMaterialInfoService.java @@ -1,6 +1,6 @@ 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; diff --git a/ruoyi-api/hwmom-api-mes/src/main/java/org/dromara/mes/api/domain/BaseMaterialInfo.java b/ruoyi-api/hwmom-api-mes/src/main/java/org/dromara/mes/api/model/BaseMaterialInfo.java similarity index 96% rename from ruoyi-api/hwmom-api-mes/src/main/java/org/dromara/mes/api/domain/BaseMaterialInfo.java rename to ruoyi-api/hwmom-api-mes/src/main/java/org/dromara/mes/api/model/BaseMaterialInfo.java index 537fb1f9..5c074f70 100644 --- a/ruoyi-api/hwmom-api-mes/src/main/java/org/dromara/mes/api/domain/BaseMaterialInfo.java +++ b/ruoyi-api/hwmom-api-mes/src/main/java/org/dromara/mes/api/model/BaseMaterialInfo.java @@ -1,17 +1,19 @@ -package org.dromara.mes.api.domain; +package org.dromara.mes.api.model; import lombok.Data; +import lombok.EqualsAndHashCode; import java.io.Serial; -import java.io.Serializable; import java.util.Date; /** * 物料信息对象 base_material_info * + * @author zangch + * @date 2025-01-07 */ @Data -public class BaseMaterialInfo implements Serializable { +public class BaseMaterialInfo { @Serial private static final long serialVersionUID = 1L; diff --git a/ruoyi-api/hwmom-api-mes/src/main/java/org/dromara/mes/api/domain/bo/BaseMaterialInfoBo.java b/ruoyi-api/hwmom-api-mes/src/main/java/org/dromara/mes/api/model/bo/BaseMaterialInfoBo.java similarity index 98% rename from ruoyi-api/hwmom-api-mes/src/main/java/org/dromara/mes/api/domain/bo/BaseMaterialInfoBo.java rename to ruoyi-api/hwmom-api-mes/src/main/java/org/dromara/mes/api/model/bo/BaseMaterialInfoBo.java index 8522435c..0cf3dc3a 100644 --- a/ruoyi-api/hwmom-api-mes/src/main/java/org/dromara/mes/api/domain/bo/BaseMaterialInfoBo.java +++ b/ruoyi-api/hwmom-api-mes/src/main/java/org/dromara/mes/api/model/bo/BaseMaterialInfoBo.java @@ -1,4 +1,4 @@ -package org.dromara.mes.api.domain.bo; +package org.dromara.mes.api.model.bo; import lombok.Data; diff --git a/ruoyi-modules/hwmom-api/pom.xml b/ruoyi-modules/hwmom-api/pom.xml index 205abd76..2cd6c777 100644 --- a/ruoyi-modules/hwmom-api/pom.xml +++ b/ruoyi-modules/hwmom-api/pom.xml @@ -103,14 +103,17 @@ org.dromara ruoyi-api-resource + + com.microsoft.sqlserver mssql-jdbc + org.dromara hwmom-api-mes @@ -118,6 +121,11 @@ compile + + org.dromara + ruoyi-common-job + + diff --git a/ruoyi-modules/hwmom-api/src/main/java/org/dromara/api/domain/SAPPortDto.java b/ruoyi-modules/hwmom-api/src/main/java/org/dromara/api/domain/SAPPortDto.java new file mode 100644 index 00000000..dfe51e12 --- /dev/null +++ b/ruoyi-modules/hwmom-api/src/main/java/org/dromara/api/domain/SAPPortDto.java @@ -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; + } +} diff --git a/ruoyi-modules/hwmom-api/src/main/java/org/dromara/api/domain/WERKSDto.java b/ruoyi-modules/hwmom-api/src/main/java/org/dromara/api/domain/WERKSDto.java new file mode 100644 index 00000000..5e064695 --- /dev/null +++ b/ruoyi-modules/hwmom-api/src/main/java/org/dromara/api/domain/WERKSDto.java @@ -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> item; + + + public List> getItem() { + return item; + } + + public void setItem(List> item) { + this.item = item; + } + + @Override + public String toString() { + return "WERKSDto{" + + "item=" + item + + '}'; + } +} diff --git a/ruoyi-modules/hwmom-api/src/main/java/org/dromara/api/domain/vo/SAPResultVo.java b/ruoyi-modules/hwmom-api/src/main/java/org/dromara/api/domain/vo/SAPResultVo.java new file mode 100644 index 00000000..11bea006 --- /dev/null +++ b/ruoyi-modules/hwmom-api/src/main/java/org/dromara/api/domain/vo/SAPResultVo.java @@ -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>> O_TAB; + + @JsonProperty(value = "WERKS") + private WERKSDto WERKS; + + @JsonProperty(value = "O_RETURN") + private WERKSDto O_RETURN; + + public HashMap>> getO_TAB() { + return O_TAB; + } + + public void setO_TAB(HashMap>> 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 + + '}'; + } +} diff --git a/ruoyi-modules/hwmom-api/src/main/java/org/dromara/api/service/IBaseMaterialInfoApiService.java b/ruoyi-modules/hwmom-api/src/main/java/org/dromara/api/service/IBaseMaterialInfoApiService.java index 6356824e..22b3e5a7 100644 --- a/ruoyi-modules/hwmom-api/src/main/java/org/dromara/api/service/IBaseMaterialInfoApiService.java +++ b/ruoyi-modules/hwmom-api/src/main/java/org/dromara/api/service/IBaseMaterialInfoApiService.java @@ -2,7 +2,7 @@ package org.dromara.api.service; /** - * 车间信息Service接口 + * API物料Service接口 * * @author Yinq * @date 2025-01-02 diff --git a/ruoyi-modules/hwmom-api/src/main/java/org/dromara/api/service/impl/BaseMaterialInfoApiServiceImpl.java b/ruoyi-modules/hwmom-api/src/main/java/org/dromara/api/service/impl/BaseMaterialInfoApiServiceImpl.java index 17c91118..d46c9f45 100644 --- a/ruoyi-modules/hwmom-api/src/main/java/org/dromara/api/service/impl/BaseMaterialInfoApiServiceImpl.java +++ b/ruoyi-modules/hwmom-api/src/main/java/org/dromara/api/service/impl/BaseMaterialInfoApiServiceImpl.java @@ -1,18 +1,22 @@ 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.dromara.api.domain.SAPPortDto; +import org.dromara.api.domain.vo.SAPResultVo; import org.dromara.api.service.IBaseMaterialInfoApiService; import lombok.RequiredArgsConstructor; 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 java.util.ArrayList; import java.util.List; /** - * Service业务层处理 + * API物料Service业务层处理 * * @author Yinq * @date 2025-01-02 @@ -26,8 +30,36 @@ public class BaseMaterialInfoApiServiceImpl implements IBaseMaterialInfoApiServi @Override public String insertApi(String requestBody) { - List list = new ArrayList<>(); - Boolean aBoolean = remoteMaterialInfoService.remoteInsertBaseMaterialInfo(list); - return null; + SAPPortDto sapPortDto = new SAPPortDto(); + //请求API接口,获取数据 + List list = getMaterialData(sapPortDto); + //解析数据,存储实体类 + + remoteMaterialInfoService.remoteInsertBaseMaterialInfo(list); + return "success"; + } + + public List getMaterialData(SAPPortDto sapPortDto) { + List 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; } + } diff --git a/ruoyi-modules/hwmom-api/src/main/java/org/dromara/api/snailjob/MaterialInfoJobExecutor.java b/ruoyi-modules/hwmom-api/src/main/java/org/dromara/api/snailjob/MaterialInfoJobExecutor.java new file mode 100644 index 00000000..b82c8773 --- /dev/null +++ b/ruoyi-modules/hwmom-api/src/main/java/org/dromara/api/snailjob/MaterialInfoJobExecutor.java @@ -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); + } + +} diff --git a/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/dubbo/RemoteMaterialInfoServiceImpl.java b/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/dubbo/RemoteMaterialInfoServiceImpl.java index 14e0c9b7..811b818b 100644 --- a/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/dubbo/RemoteMaterialInfoServiceImpl.java +++ b/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/dubbo/RemoteMaterialInfoServiceImpl.java @@ -4,7 +4,7 @@ import lombok.RequiredArgsConstructor; import org.apache.dubbo.config.annotation.DubboService; import org.dromara.common.core.utils.MapstructUtils; 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.mapper.BaseMaterialInfoMapper; import org.springframework.stereotype.Service; diff --git a/ruoyi-visual/ruoyi-snailjob-server/pom.xml b/ruoyi-visual/ruoyi-snailjob-server/pom.xml index 0cdaa547..36a9f57d 100644 --- a/ruoyi-visual/ruoyi-snailjob-server/pom.xml +++ b/ruoyi-visual/ruoyi-snailjob-server/pom.xml @@ -40,6 +40,12 @@ spring-boot-admin-starter-client ${spring-boot-admin.version} + + + com.microsoft.sqlserver + mssql-jdbc + +