|
|
@ -1,12 +1,8 @@ |
|
|
package com.spring.modules.part.task; |
|
|
package com.spring.modules.part.task; |
|
|
|
|
|
|
|
|
import com.spring.common.utils.DateUtils; |
|
|
|
|
|
import com.spring.modules.base.vo.PersonnelLevelVo; |
|
|
import com.spring.modules.base.vo.PersonnelLevelVo; |
|
|
import com.spring.modules.base.vo.WorkCenterCostVo; |
|
|
import com.spring.modules.base.vo.WorkCenterCostVo; |
|
|
import com.spring.modules.part.service.PartInformationService; |
|
|
|
|
|
import com.spring.modules.part.service.PartService; |
|
|
|
|
|
import com.spring.modules.part.service.RoutingManagementService; |
|
|
import com.spring.modules.part.service.RoutingManagementService; |
|
|
import com.spring.modules.part.vo.InventoryPartUnitCostSumVo; |
|
|
|
|
|
import com.spring.modules.part.vo.LocationInformationVo; |
|
|
import com.spring.modules.part.vo.LocationInformationVo; |
|
|
import com.spring.modules.part.vo.WorkCenterVo; |
|
|
import com.spring.modules.part.vo.WorkCenterVo; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
@ -19,6 +15,11 @@ import org.springframework.scheduling.annotation.EnableScheduling; |
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
import org.springframework.stereotype.Component; |
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
|
|
import java.util.Collections; |
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
@Component |
|
|
@Component |
|
|
@Configuration |
|
|
@Configuration |
|
|
@EnableScheduling |
|
|
@EnableScheduling |
|
|
@ -34,51 +35,80 @@ public class PartRelatedTask { |
|
|
|
|
|
|
|
|
@Scheduled(cron = "${task.data.syncDataToPLM}") |
|
|
@Scheduled(cron = "${task.data.syncDataToPLM}") |
|
|
public void executeDeviceCollect() { |
|
|
public void executeDeviceCollect() { |
|
|
String siteCon = convertToSQLString(useSite); |
|
|
|
|
|
|
|
|
String siteCon = buildSiteCon(); |
|
|
|
|
|
if ("()".equals(siteCon)) { |
|
|
|
|
|
logger.warn("未配置可用站点,跳过同步。use-site={}", useSite); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 同步人员等级 |
|
|
// 同步人员等级 |
|
|
try { |
|
|
try { |
|
|
logger.info("开始同步人员等级..."); |
|
|
|
|
|
|
|
|
logger.info("开始同步人员等级,siteCon={}", siteCon); |
|
|
PersonnelLevelVo laborClassVo = new PersonnelLevelVo(); |
|
|
PersonnelLevelVo laborClassVo = new PersonnelLevelVo(); |
|
|
laborClassVo.setSiteCon(siteCon); |
|
|
laborClassVo.setSiteCon(siteCon); |
|
|
routingManagementService.syncLaborClassToPLM(laborClassVo); |
|
|
routingManagementService.syncLaborClassToPLM(laborClassVo); |
|
|
logger.info("同步人员等级完成"); |
|
|
|
|
|
|
|
|
logger.info("同步人员等级完成,siteCon={}", siteCon); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
logger.error("同步人员等级失败: " + e.getMessage(), e); |
|
|
|
|
|
|
|
|
logger.error("同步人员等级失败,siteCon={},error={}", siteCon, e.getMessage(), e); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 同步加工中心 |
|
|
// 同步加工中心 |
|
|
try { |
|
|
try { |
|
|
logger.info("开始同步加工中心..."); |
|
|
|
|
|
|
|
|
logger.info("开始同步加工中心,siteCon={}", siteCon); |
|
|
WorkCenterVo workCenterVo = new WorkCenterVo(); |
|
|
WorkCenterVo workCenterVo = new WorkCenterVo(); |
|
|
workCenterVo.setSiteCon(siteCon); |
|
|
workCenterVo.setSiteCon(siteCon); |
|
|
routingManagementService.syncWorkCenterToPLM(workCenterVo); |
|
|
routingManagementService.syncWorkCenterToPLM(workCenterVo); |
|
|
logger.info("同步加工中心完成"); |
|
|
|
|
|
|
|
|
logger.info("同步加工中心完成,siteCon={}", siteCon); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
logger.error("同步加工中心失败: " + e.getMessage(), e); |
|
|
|
|
|
|
|
|
logger.error("同步加工中心失败,siteCon={},error={}", siteCon, e.getMessage(), e); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 同步加工中心成本 |
|
|
// 同步加工中心成本 |
|
|
try { |
|
|
try { |
|
|
logger.info("开始同步加工中心成本..."); |
|
|
|
|
|
|
|
|
logger.info("开始同步加工中心成本,siteCon={}", siteCon); |
|
|
WorkCenterCostVo workCenterCostVo = new WorkCenterCostVo(); |
|
|
WorkCenterCostVo workCenterCostVo = new WorkCenterCostVo(); |
|
|
workCenterCostVo.setSiteCon(siteCon); |
|
|
workCenterCostVo.setSiteCon(siteCon); |
|
|
routingManagementService.syncWorkCenterCostToPLM(workCenterCostVo); |
|
|
routingManagementService.syncWorkCenterCostToPLM(workCenterCostVo); |
|
|
logger.info("同步加工中心成本完成"); |
|
|
|
|
|
|
|
|
logger.info("同步加工中心成本完成,siteCon={}", siteCon); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
logger.error("同步加工中心成本失败: " + e.getMessage(), e); |
|
|
|
|
|
|
|
|
logger.error("同步加工中心成本失败,siteCon={},error={}", siteCon, e.getMessage(), e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Scheduled(cron = "${task.data.syncLocationToPLM}") |
|
|
@Scheduled(cron = "${task.data.syncLocationToPLM}") |
|
|
public void executeDeviceCollect2() { |
|
|
public void executeDeviceCollect2() { |
|
|
String siteCon = convertToSQLString(useSite); |
|
|
|
|
|
|
|
|
String siteCon = buildSiteCon(); |
|
|
|
|
|
if ("()".equals(siteCon)) { |
|
|
|
|
|
logger.warn("未配置可用站点,跳过库位同步。use-site={}", useSite); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 同步库位 |
|
|
// 同步库位 |
|
|
LocationInformationVo locationVo = new LocationInformationVo(); |
|
|
LocationInformationVo locationVo = new LocationInformationVo(); |
|
|
locationVo.setSiteCon(siteCon); |
|
|
locationVo.setSiteCon(siteCon); |
|
|
routingManagementService.syncLocationToPLM(locationVo); |
|
|
routingManagementService.syncLocationToPLM(locationVo); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private List<String> parseSites(String siteConfig) { |
|
|
|
|
|
if (siteConfig == null || siteConfig.trim().isEmpty()) { |
|
|
|
|
|
return Collections.emptyList(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return Arrays.stream(siteConfig.split(",")) |
|
|
|
|
|
.map(String::trim) |
|
|
|
|
|
.filter(site -> !site.isEmpty()) |
|
|
|
|
|
.distinct() |
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private String buildSiteCon() { |
|
|
|
|
|
List<String> sites = parseSites(useSite); |
|
|
|
|
|
if (sites.isEmpty()) { |
|
|
|
|
|
return "()"; |
|
|
|
|
|
} |
|
|
|
|
|
return convertToSQLString(String.join(",", sites)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public static String convertToSQLString(String input) { |
|
|
public static String convertToSQLString(String input) { |
|
|
if (input == null || input.isEmpty()) { |
|
|
if (input == null || input.isEmpty()) { |
|
|
return "()"; |
|
|
return "()"; |
|
|
|