李永德
1 year ago
14 changed files with 312 additions and 21 deletions
@ -0,0 +1,72 @@ |
|||
package org.nl.wms.ext.acs.autotask; |
|||
|
|||
import cn.hutool.http.HttpStatus; |
|||
import lombok.SneakyThrows; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.system.service.notice.ISysNoticeService; |
|||
import org.nl.wms.ext.acs.service.WmsToAcsService; |
|||
import org.nl.wms.ext.acs.service.dto.to.wms.AcsResponse; |
|||
import org.nl.wms.pdm.workorder.service.IPdmBdWorkorderService; |
|||
import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder; |
|||
import org.nl.wms.pdm.workorder.service.dao.vo.AcsWorkOrderVo; |
|||
import org.nl.wms.sch.task_manage.enums.NoticeTypeEnum; |
|||
import org.nl.wms.sch.task_manage.enums.WorkOrderStatusEnum; |
|||
import org.nl.wms.util.TaskUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.core.annotation.Order; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.List; |
|||
import java.util.concurrent.CopyOnWriteArrayList; |
|||
|
|||
/** |
|||
* @Author: lyd |
|||
* @Description: 自动下发工单给acs |
|||
* @Date: 2023/10/30 |
|||
*/ |
|||
@Slf4j |
|||
@Component |
|||
@Order(value = 1) |
|||
public class AutoIssueWorkOrder { |
|||
@Autowired |
|||
private IPdmBdWorkorderService workorderService; |
|||
@Autowired |
|||
private WmsToAcsService wmsToAcsService; |
|||
@Autowired |
|||
private ISysNoticeService noticeService; |
|||
@SneakyThrows |
|||
public void run() { |
|||
// 获取未有生产中的设备号
|
|||
List<String> deviceCodes = workorderService.getTheDayUnProducedDevice(); |
|||
// 查找该设备未生产的工单去下发
|
|||
deviceCodes.forEach(s -> { |
|||
List<AcsWorkOrderVo> acsWorkOrderVoList = workorderService.getAcsWorkOrderVos(s); |
|||
if (acsWorkOrderVoList.size() == 0) return; |
|||
AcsWorkOrderVo acsWorkOrderVo = acsWorkOrderVoList.get(0); |
|||
// 获取一个下发
|
|||
List<AcsWorkOrderVo> list = new CopyOnWriteArrayList<>(); |
|||
list.add(acsWorkOrderVo); |
|||
AcsResponse resultForAcs; |
|||
try { |
|||
resultForAcs = wmsToAcsService.order(list); |
|||
} catch (Exception e) { |
|||
log.error("工单下发异常:" + e.getMessage()); |
|||
// 通知
|
|||
noticeService.createNotice("工单下发失败: " + e.getMessage(), "工单下发失败: " |
|||
+ acsWorkOrderVo.getWorkorder_code(), NoticeTypeEnum.EXCEPTION.getCode()); |
|||
return; |
|||
} |
|||
if (resultForAcs.getCode() != HttpStatus.HTTP_OK) { |
|||
// 不成功
|
|||
noticeService.createNotice(resultForAcs.getMessage(), "工单下发失败: " + acsWorkOrderVo.getWorkorder_code(), |
|||
NoticeTypeEnum.EXCEPTION.getCode()); |
|||
return; |
|||
} |
|||
// 修改工单数据
|
|||
PdmBdWorkorder pdmBdWorkorder = workorderService.getByCode(acsWorkOrderVo.getWorkorder_code()); |
|||
pdmBdWorkorder.setWorkorder_status(WorkOrderStatusEnum.ISSUED.getCode()); |
|||
TaskUtils.setWorkOrderUpdateByAcs(pdmBdWorkorder); |
|||
workorderService.updateById(pdmBdWorkorder); |
|||
}); |
|||
} |
|||
} |
@ -0,0 +1,25 @@ |
|||
package org.nl.wms.ext.mes.autotask; |
|||
|
|||
import lombok.SneakyThrows; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.wms.ext.mes.service.WmsToMesService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.core.annotation.Order; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* @Author: lyd |
|||
* @Description: 自动同步工单 |
|||
* @Date: 2023/10/30 |
|||
*/ |
|||
@Slf4j |
|||
@Component |
|||
@Order(value = 1) |
|||
public class AutoSynWorkOrderInfo { |
|||
@Autowired |
|||
private WmsToMesService wmsToMesService; |
|||
@SneakyThrows |
|||
public void run() { |
|||
wmsToMesService.synchronizeWorkOrderInfo(); |
|||
} |
|||
} |
Loading…
Reference in new issue