| | |
| | | package com.gs.xky.service; |
| | | |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.gs.xky.config.ApiResponse; |
| | | import com.gs.xky.config.BodyParam; |
| | |
| | | import com.gs.xky.dto.BarcodeDeliveryNo; |
| | | import com.gs.xky.dto.XkyDetail; |
| | | import com.gs.xky.dto.XkyEntity; |
| | | import com.gs.xky.entity.DeliveryNotice; |
| | | import com.gs.xky.entity.DeliveryNoticeDetail; |
| | | import com.gs.xky.entity.TblBarcodeInformation; |
| | | import com.gs.xky.entity.*; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | private final TblBarcodeInformationService barcodeInformationService; |
| | | private final DeliveryNoticeDetailService deliveryNoticeDetailService; |
| | | |
| | | private final MesInvItemArnService mesInvItemArnService; |
| | | private final MesInvItemArnDetailService mesInvItemArnDetailService; |
| | | private final MesInvItemBarcodesService mesInvItemBarcodesService; |
| | | |
| | | private final MesQaItemsDetect01Service mesQaItemsDetect01Service; |
| | | |
| | | public void GetSaveDetail() throws IOException { |
| | | long currentTimeMillis = System.currentTimeMillis(); |
| | | |
| | | XkyCommonParam param = XkyCommonParam.GetInit(); |
| | | |
| | | // 计算五分钟前的时间戳 |
| | | long startDate = currentTimeMillis - (65 * 60 * 1000); // 5 分钟 = 5 * 60 * 1000 毫秒 |
| | | long startDate = currentTimeMillis - (20 * 60 * 1000); // 1 分钟 = 1 * 60 * 1000 毫秒 |
| | | |
| | | // 创建 BodyParam 对象并赋值 |
| | | BodyParam bodyParam = new BodyParam(); |
| | | bodyParam.setStartDate(startDate); |
| | | bodyParam.setEndDate(currentTimeMillis); |
| | | bodyParam.setErpCode(DataAcquisitionConfiguration.TEST_ERP_CODE); |
| | | bodyParam.setStatus(new int[]{1}); |
| | | bodyParam.setLogisticsStatus(2); |
| | | bodyParam.setStatus(new int[]{1, 6}); |
| | | // bodyParam.setLogisticsStatus(2); |
| | | |
| | | param.setBody(bodyParam); |
| | | |
| | |
| | | |
| | | List<XkyEntity> deliveryNoList = noList.getDataList(); |
| | | |
| | | LambdaUpdateWrapper<DeliveryNotice> deliveryNoticeWrapper = new LambdaUpdateWrapper<>(); |
| | | |
| | | LambdaUpdateWrapper<DeliveryNoticeDetail> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | |
| | | LambdaUpdateWrapper<TblBarcodeInformation> updateWrapper1 = new LambdaUpdateWrapper<>(); |
| | | if (CollUtil.isEmpty(deliveryNoList)) { |
| | | return; |
| | | } |
| | | |
| | | deliveryNoList.forEach(deliveryNo -> { |
| | | try { |
| | | |
| | | if ("4".equals(deliveryNo.getStatus()) || "8".equals(deliveryNo.getStatus())) { |
| | | deliveryNoticeWrapper.clear(); |
| | | updateWrapper.clear(); |
| | | updateWrapper1.clear(); |
| | | deliveryNoticeWrapper.eq(DeliveryNotice::getDeliveryNo, deliveryNo.getDeliveryNo()); |
| | | if ("6".equals(deliveryNo.getStatus()) || "0".equals(deliveryNo.getLogisticsStatus())) { |
| | | |
| | | DeliveryNotice one = deliveryNoticeService.getOne(deliveryNoticeWrapper, false); |
| | | remove(deliveryNo); |
| | | |
| | | if (deliveryNoticeService.remove(deliveryNoticeWrapper)) { |
| | | } else if ("1".equals(deliveryNo.getStatus()) && "2".equals(deliveryNo.getLogisticsStatus())) { |
| | | XkyDetail detail = getDetail(deliveryNo.getDeliveryNo()); |
| | | deliveryNoticeService.saveDeliveryNotice(detail); |
| | | List<BarcodeDeliveryNo> barcodeDeliveryNos = GetBarcodeInformation(deliveryNo.getDeliveryNo()); |
| | | barcodeInformationService.SaveBarcodeInformation(barcodeDeliveryNos, deliveryNo.getDeliveryNo()); |
| | | |
| | | updateWrapper.eq(DeliveryNoticeDetail::getPid, one.getId()); |
| | | deliveryNoticeDetailService.remove(updateWrapper); |
| | | |
| | | updateWrapper1.eq(TblBarcodeInformation::getDeliveryNo, deliveryNo.getDeliveryNo()); |
| | | barcodeInformationService.remove(updateWrapper1); |
| | | } |
| | | |
| | | |
| | | deliveryNoticeService.callPdaReceiptBtn("送货单签收[BTNOK[PL017[" + deliveryNo.getDeliveryNo(), ""); |
| | | } |
| | | |
| | | XkyDetail detail = getDetail(deliveryNo.getDeliveryNo()); |
| | | deliveryNoticeService.saveDeliveryNotice(detail); |
| | | List<BarcodeDeliveryNo> barcodeDeliveryNos = GetBarcodeInformation(deliveryNo.getDeliveryNo()); |
| | | barcodeInformationService.SaveBarcodeInformation(barcodeDeliveryNos, deliveryNo.getDeliveryNo()); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private void remove(XkyEntity deliveryNo) { |
| | | LambdaUpdateWrapper<DeliveryNotice> deliveryNoticeWrapper = new LambdaUpdateWrapper<>(); |
| | | |
| | | deliveryNoticeWrapper.eq(DeliveryNotice::getDeliveryNo, deliveryNo.getDeliveryNo()); |
| | | |
| | | DeliveryNotice one = deliveryNoticeService.getOne(deliveryNoticeWrapper, false); |
| | | |
| | | if (deliveryNoticeService.remove(deliveryNoticeWrapper)) { |
| | | |
| | | LambdaUpdateWrapper<DeliveryNoticeDetail> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | |
| | | updateWrapper.eq(DeliveryNoticeDetail::getPid, one.getId()); |
| | | |
| | | deliveryNoticeDetailService.remove(updateWrapper); |
| | | |
| | | LambdaUpdateWrapper<TblBarcodeInformation> updateWrapper1 = new LambdaUpdateWrapper<>(); |
| | | |
| | | updateWrapper1.eq(TblBarcodeInformation::getDeliveryNo, deliveryNo.getDeliveryNo()); |
| | | |
| | | barcodeInformationService.remove(updateWrapper1); |
| | | |
| | | LambdaQueryWrapper<MesInvItemArn> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(MesInvItemArn::getPaperBillNo, deliveryNo.getDeliveryNo()); |
| | | |
| | | MesInvItemArn mesInvItemArn = mesInvItemArnService.getOne(wrapper, false); |
| | | |
| | | mesInvItemArnService.remove(wrapper); |
| | | |
| | | if (mesInvItemArn != null) { |
| | | LambdaUpdateWrapper<MesInvItemArnDetail> updateWrapper2 = new LambdaUpdateWrapper<>(); |
| | | |
| | | updateWrapper2.eq(MesInvItemArnDetail::getMid, mesInvItemArn.getId()); |
| | | mesInvItemArnDetailService.remove(updateWrapper2); |
| | | |
| | | LambdaUpdateWrapper<MesInvItemBarcodes> updateWrapper3 = new LambdaUpdateWrapper<>(); |
| | | |
| | | updateWrapper3.eq(MesInvItemBarcodes::getBillNo, mesInvItemArn.getBillNo()); |
| | | mesInvItemBarcodesService.remove(updateWrapper3); |
| | | |
| | | mesQaItemsDetect01Service.removeQa(mesInvItemArn.getBillNo()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private XkyDetail getDetail(String deliveryNo) throws IOException { |
| | | XkyCommonParam param = XkyCommonParam.GetInit(); |
| | | |