|
@@ -6,13 +6,17 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.jeecg.common.util.DateUtils;
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
+import org.jeecg.modules.actualControl.billetActual.billetActual.vo.BilletPushResponse;
|
|
|
+import org.jeecg.modules.actualControl.billetActual.billetActual.vo.ShippingOrderVO;
|
|
|
import org.jeecg.modules.billet.billetHotsend.entity.BilletHotsend;
|
|
|
import org.jeecg.modules.billet.billetHotsend.mapper.BilletHotsendBaseMapper;
|
|
|
import org.jeecg.modules.billet.billetHotsendChangeShift.entity.BilletHotsendChangeShift;
|
|
|
import org.jeecg.modules.billet.billetHotsendChangeShift.service.IBilletHotsendChangeShiftService;
|
|
|
+import org.jeecg.modules.billet.billetOriginalProductRecord.dto.HandleBilletPushDTO;
|
|
|
import org.jeecg.modules.billet.billetOriginalProductRecord.dto.QualityInspectionQueryDTO;
|
|
|
import org.jeecg.modules.billet.billetOriginalProductRecord.entity.BilletOriginalProductRecord;
|
|
|
import org.jeecg.modules.billet.billetOriginalProductRecord.mapper.BilletOriginalProductRecordMapper;
|
|
@@ -25,8 +29,10 @@ import org.jeecg.modules.billet.sampleCardDeliveryRecord.entity.SampleCardDelive
|
|
|
import org.jeecg.modules.billet.sampleCardDeliveryRecord.mapper.SampleCardDeliveryRecordMapper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
@@ -43,6 +49,7 @@ import java.util.stream.Collectors;
|
|
|
* @Date: 2025-06-23
|
|
|
* @Version: V1.0
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
public class BilletOriginalProductRecordServiceImpl extends ServiceImpl<BilletOriginalProductRecordMapper, BilletOriginalProductRecord> implements IBilletOriginalProductRecordService {
|
|
|
|
|
@@ -62,6 +69,9 @@ public class BilletOriginalProductRecordServiceImpl extends ServiceImpl<BilletOr
|
|
|
@Autowired
|
|
|
private SampleCardDeliveryRecordMapper sampleCardDeliveryRecordMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RestTemplate restTemplate;
|
|
|
+
|
|
|
@Override
|
|
|
public Map<String, Object> getQualityInspectionMenu(QualityInspectionQueryDTO queryDTO) {
|
|
|
if (queryDTO == null || StringUtils.isBlank(queryDTO.getCcmNo())) {
|
|
@@ -348,6 +358,17 @@ public class BilletOriginalProductRecordServiceImpl extends ServiceImpl<BilletOr
|
|
|
|
|
|
@Override
|
|
|
public void initMonthlyStatisticsIfMissing(String ccmNo,String changeShiftId) {
|
|
|
+
|
|
|
+ // 参数校验
|
|
|
+ if (ccmNo == null || ccmNo.trim().isEmpty()) {
|
|
|
+ log.warn("initMonthlyStatisticsIfMissing 失败:ccmNo 不能为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (changeShiftId == null || changeShiftId.trim().isEmpty()) {
|
|
|
+ log.warn("initMonthlyStatisticsIfMissing 失败:changeShiftId 不能为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
Date monthStart = DateUtils.getMonthStart(new Date());
|
|
|
Date searchStart = new Date(monthStart.getTime() - 10 * 60 * 1000); // 向前推10分钟
|
|
|
Date now = new Date();
|
|
@@ -493,6 +514,56 @@ public class BilletOriginalProductRecordServiceImpl extends ServiceImpl<BilletOr
|
|
|
initMonthlyStatisticsIfMissing(ccmNo, changeShiftId);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Async("asyncExecutor") // 使用定义好的异步线程池
|
|
|
+ public void handleBilletPush(HandleBilletPushDTO pushDTO) {
|
|
|
+
|
|
|
+ // 远程调用
|
|
|
+ BilletPushResponse response = sendRequestAndLog(pushDTO);
|
|
|
+ if (response != null) {
|
|
|
+ // 远程调用成功后,保存或更新推送日志
|
|
|
+ log.info("远程推送装运单接收接口成功!");
|
|
|
+ } else {
|
|
|
+ log.error("远程调用装运单接收接口失败!");
|
|
|
+ throw new RuntimeException("远程调用装运单接收接口失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private BilletPushResponse sendRequestAndLog(HandleBilletPushDTO request) {
|
|
|
+ final int maxRetries = 3;
|
|
|
+ final long baseDelayMillis = 3000;
|
|
|
+
|
|
|
+ int attempt = 0;
|
|
|
+ while (attempt < maxRetries) {
|
|
|
+ try {
|
|
|
+ String url = "http://192.168.12.201:8850/scheduling/api/billet-quantities/handleBillet";
|
|
|
+ ResponseEntity<BilletPushResponse> response = restTemplate.postForEntity(url, request, BilletPushResponse.class);
|
|
|
+
|
|
|
+ BilletPushResponse body = response.getBody();
|
|
|
+// log.info("推送成功,响应信息: {}", body);
|
|
|
+
|
|
|
+ return body;
|
|
|
+ } catch (Exception e) {
|
|
|
+ attempt++;
|
|
|
+ log.error("推送失败,重试第 {} 次,错误信息:{}", attempt, e.getMessage());
|
|
|
+
|
|
|
+ if (attempt >= maxRetries) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ Thread.sleep(baseDelayMillis * attempt);
|
|
|
+ } catch (InterruptedException ie) {
|
|
|
+ Thread.currentThread().interrupt();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
public QualityInspectionStatisticsVO getStatisticsByShift(BilletHotsendChangeShift shiftRecord, List<BilletHotsendChangeShift> allShiftsOfTheDay,Map<LocalDate, List<BilletHotsendChangeShift>> shiftByDate) {
|
|
|
Date classStartTime = shiftRecord.getCreateTime();
|
|
|
Date classEndTime = Optional.ofNullable(shiftRecord.getChangeShiftTime()).orElse(new Date());
|