|
@@ -2,14 +2,13 @@ package cn.iocoder.yudao.module.order.service.impl;
|
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
|
+import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
|
|
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
|
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
|
|
import cn.iocoder.yudao.module.infra.api.config.ConfigApi;
|
|
import cn.iocoder.yudao.module.infra.api.config.ConfigApi;
|
|
|
import cn.iocoder.yudao.module.order.controller.admin.workorder.vo.*;
|
|
import cn.iocoder.yudao.module.order.controller.admin.workorder.vo.*;
|
|
|
import cn.iocoder.yudao.module.order.dal.dataobject.WorkOrdMasterDO;
|
|
import cn.iocoder.yudao.module.order.dal.dataobject.WorkOrdMasterDO;
|
|
|
import cn.iocoder.yudao.module.order.dal.mysql.WorkOrdMasterMapper;
|
|
import cn.iocoder.yudao.module.order.dal.mysql.WorkOrdMasterMapper;
|
|
|
import cn.iocoder.yudao.module.order.service.WorkOrderService;
|
|
import cn.iocoder.yudao.module.order.service.WorkOrderService;
|
|
|
-import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
|
|
|
|
-import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.mzt.logapi.context.LogRecordContext;
|
|
import com.mzt.logapi.context.LogRecordContext;
|
|
|
import com.mzt.logapi.starter.annotation.LogRecord;
|
|
import com.mzt.logapi.starter.annotation.LogRecord;
|
|
@@ -28,7 +27,6 @@ import java.time.format.DateTimeFormatter;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
-import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
|
|
|
|
import static cn.iocoder.yudao.module.order.enums.ErrorCodeConstants.WORK_ORDER_NOT_EXISTS;
|
|
import static cn.iocoder.yudao.module.order.enums.ErrorCodeConstants.WORK_ORDER_NOT_EXISTS;
|
|
|
import static cn.iocoder.yudao.module.system.enums.LogRecordConstants.*;
|
|
import static cn.iocoder.yudao.module.system.enums.LogRecordConstants.*;
|
|
|
|
|
|
|
@@ -47,15 +45,11 @@ public class WorkOrderServiceImpl implements WorkOrderService {
|
|
|
private ConfigApi configApi;
|
|
private ConfigApi configApi;
|
|
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
|
- private AdminUserApi adminUserApi;
|
|
|
|
|
-
|
|
|
|
|
- @Resource
|
|
|
|
|
private RestTemplate restTemplate;
|
|
private RestTemplate restTemplate;
|
|
|
|
|
|
|
|
// 外部接口地址
|
|
// 外部接口地址
|
|
|
- private static final String MATERIAL_CHECK_URL = "http://123.60.180.165:9898/api/business/resource-examine/producedayplankittingcheck";
|
|
|
|
|
- private static final String MATERIAL_REQUIREMENT_URL = "http://123.60.180.165:9898/api/business/resource-examine/AutomaticPrAdjustDate";
|
|
|
|
|
-
|
|
|
|
|
|
|
+ private static final String MATERIAL_CHECK_URL = "http://123.60.180.165:8087/api/business/resource-examine/producedayplankittingcheck";
|
|
|
|
|
+ private static final String MATERIAL_REQUIREMENT_URL = "http://123.60.180.165:8087/api/business/resource-examine/AutomaticPrAdjustDate";
|
|
|
@Override
|
|
@Override
|
|
|
@TenantIgnore
|
|
@TenantIgnore
|
|
|
public PageResult<WorkOrderPoolRespVO> getWorkOrderPoolPage(WorkOrderPoolPageReqVO pageReqVO) {
|
|
public PageResult<WorkOrderPoolRespVO> getWorkOrderPoolPage(WorkOrderPoolPageReqVO pageReqVO) {
|
|
@@ -139,7 +133,7 @@ public class WorkOrderServiceImpl implements WorkOrderService {
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@TenantIgnore
|
|
@TenantIgnore
|
|
|
- @LogRecord(type = WORK_ORDER_TYPE, subType = WORK_ORDER_RELEASE_SUB_TYPE, bizNo = "{{#releaseReqVO.workOrderNo}}",
|
|
|
|
|
|
|
+ @LogRecord(type = WORK_ORDER_TYPE, subType = WORK_ORDER_RELEASE_SUB_TYPE, bizNo = "{{#workOrder.recId}}",
|
|
|
success = WORK_ORDER_RELEASE_SUCCESS)
|
|
success = WORK_ORDER_RELEASE_SUCCESS)
|
|
|
public void releaseWorkOrder(WorkOrderReleaseReqVO releaseReqVO) {
|
|
public void releaseWorkOrder(WorkOrderReleaseReqVO releaseReqVO) {
|
|
|
String domain = getDefaultDomain();
|
|
String domain = getDefaultDomain();
|
|
@@ -155,10 +149,10 @@ public class WorkOrderServiceImpl implements WorkOrderService {
|
|
|
LocalDateTime newOrdDate = LocalDateTime.parse(releaseReqVO.getOrdDate() + " 00:00:00",
|
|
LocalDateTime newOrdDate = LocalDateTime.parse(releaseReqVO.getOrdDate() + " 00:00:00",
|
|
|
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
|
|
|
- // 2. 判断开工日期是否小于当前日期
|
|
|
|
|
|
|
+ // 2. 判断开工日期是否小于当前日期(允许等于当前日期)
|
|
|
LocalDateTime now = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0).withNano(0);
|
|
LocalDateTime now = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0).withNano(0);
|
|
|
if (newOrdDate.isBefore(now)) {
|
|
if (newOrdDate.isBefore(now)) {
|
|
|
- throw new RuntimeException("工单开工日期需调整至今日之后");
|
|
|
|
|
|
|
+ throw new RuntimeException("工单开工日期不能早于今天");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 3. 计算旧开工日期与新开工日期的天数差
|
|
// 3. 计算旧开工日期与新开工日期的天数差
|
|
@@ -197,20 +191,6 @@ public class WorkOrderServiceImpl implements WorkOrderService {
|
|
|
week
|
|
week
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
- // 8. 调用外部接口进行物料齐套检查
|
|
|
|
|
- String userAccount = getCurrentUserName();
|
|
|
|
|
- String url = "http://123.60.180.165:8087/api/business/resource-examine/ProduceWorkOrdKittingCheck" +
|
|
|
|
|
- "?workord=" + releaseReqVO.getWorkOrderNo() +
|
|
|
|
|
- "&domain=" + domain +
|
|
|
|
|
- "&userAccount=" + userAccount;
|
|
|
|
|
-
|
|
|
|
|
- String response = restTemplate.getForObject(url, String.class);
|
|
|
|
|
-
|
|
|
|
|
- // 检查返回结果
|
|
|
|
|
- if (!"ok".equalsIgnoreCase(response)) {
|
|
|
|
|
- throw new RuntimeException("工单下达失败:" + response);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
log.info("工单下达成功,工单号:{},生产批号:{},开工日期:{},完工日期:{},周次:{}",
|
|
log.info("工单下达成功,工单号:{},生产批号:{},开工日期:{},完工日期:{},周次:{}",
|
|
|
releaseReqVO.getWorkOrderNo(), releaseReqVO.getLotSerial(),
|
|
releaseReqVO.getWorkOrderNo(), releaseReqVO.getLotSerial(),
|
|
|
newOrdDate, newDueDate, week);
|
|
newOrdDate, newDueDate, week);
|
|
@@ -298,13 +278,17 @@ public class WorkOrderServiceImpl implements WorkOrderService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private String getCurrentUserName() {
|
|
private String getCurrentUserName() {
|
|
|
- Long loginUserId = getLoginUserId();
|
|
|
|
|
- if (loginUserId != null) {
|
|
|
|
|
- AdminUserRespDTO user = adminUserApi.getUser(loginUserId);
|
|
|
|
|
- if (user != null) {
|
|
|
|
|
- return user.getNickname();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 优先使用登录用户名(username),如果没有则使用昵称(nickname)
|
|
|
|
|
+ String username = SecurityFrameworkUtils.getLoginUsername();
|
|
|
|
|
+ if (StrUtil.isNotBlank(username)) {
|
|
|
|
|
+ return username;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ String nickname = SecurityFrameworkUtils.getLoginUserNickname();
|
|
|
|
|
+ if (StrUtil.isNotBlank(nickname)) {
|
|
|
|
|
+ return nickname;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return "system";
|
|
return "system";
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|