You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
104 lines
3.1 KiB
104 lines
3.1 KiB
package com.spring.modules.part.task;
|
|
|
|
import com.spring.common.utils.DateUtils;
|
|
import com.spring.modules.base.vo.PersonnelLevelVo;
|
|
import com.spring.modules.part.service.PartService;
|
|
import com.spring.modules.part.service.RoutingManagementService;
|
|
import com.spring.modules.part.service.impl.RoutingManagementServiceImpl;
|
|
import com.spring.modules.part.vo.LocationInformationVo;
|
|
import com.spring.modules.part.vo.WorkCenterVo;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
@Component
|
|
@Configuration
|
|
@EnableScheduling
|
|
@Slf4j
|
|
public class PartRelatedTask {
|
|
|
|
@Value("${use-site}")
|
|
private String useSite;
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
@Autowired
|
|
private RoutingManagementService routingManagementService;
|
|
@Autowired
|
|
private PartService partService;
|
|
|
|
@Scheduled(cron = "${task.data.syncDataToPLM}")
|
|
public void executeDeviceCollect() {
|
|
String siteCon = convertToSQLString(useSite);
|
|
// 同步库位
|
|
LocationInformationVo locationVo = new LocationInformationVo();
|
|
locationVo.setSiteCon(siteCon);
|
|
routingManagementService.syncLocationToPLM(locationVo);
|
|
// 同步人员等级
|
|
PersonnelLevelVo laborClassVo = new PersonnelLevelVo();
|
|
laborClassVo.setSiteCon(siteCon);
|
|
routingManagementService.syncLaborClassToPLM(laborClassVo);
|
|
// 同步加工中心
|
|
WorkCenterVo workCenterVo = new WorkCenterVo();
|
|
workCenterVo.setSiteCon(siteCon);
|
|
routingManagementService.syncWorkCenterToPLM(workCenterVo);
|
|
}
|
|
|
|
|
|
/**
|
|
* @description: 刷新物料件的方法
|
|
* @author LR
|
|
* @date 2024/9/23 10:15
|
|
* @version 1.0
|
|
*/
|
|
@Scheduled(cron = "${task.data.sync_part_catalog_to_plm}")
|
|
public void syncPartCatalogToPlm(){
|
|
try {
|
|
//获取处理的文件数
|
|
logger.info("同步物料件的操作 的开始时间:"+ DateUtils.getStringNow());
|
|
partService.syncPartCatalogToPlm();
|
|
logger.info("同步物料件的操作 的结束时间:"+DateUtils.getStringNow());
|
|
} catch (Exception e) {
|
|
logger.error("异常时间:"+DateUtils.getStringNow()+",同步物料件的操作 ,错误信息为:"+e.getMessage());
|
|
}
|
|
}
|
|
|
|
private static String convertToSQLString(String input) {
|
|
if (input == null || input.isEmpty()) {
|
|
return "()";
|
|
}
|
|
|
|
String[] parts = input.split(",");
|
|
StringBuilder sb = new StringBuilder("(");
|
|
|
|
for (int i = 0; i < parts.length; i++) {
|
|
sb.append("'").append(parts[i]).append("'");
|
|
if (i < parts.length - 1) {
|
|
sb.append(",");
|
|
}
|
|
}
|
|
|
|
sb.append(")");
|
|
return sb.toString();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|