package com.gs.xky.service.Impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.gs.xky.dto.BarcodeDeliveryNo; import com.gs.xky.dto.DynamicData; import com.gs.xky.entity.TblBarcodeInformation; import com.gs.xky.mapper.TblBarcodeInformationMapper; import com.gs.xky.service.TblBarcodeInformationService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.time.Instant; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; /** * @author 28567 * @description 针对表【TBL_BARCODE_INFORMATION(条码信息表)】的数据库操作Service实现 * @createDate 2025-02-12 12:52:06 */ @Service @Transactional(rollbackFor = Exception.class) @RequiredArgsConstructor public class TblBarcodeInformationServiceImpl extends ServiceImpl implements TblBarcodeInformationService { @Override public boolean SaveBarcodeInformation(List barcodeList, String deliveryNo) { if (CollUtil.isEmpty(barcodeList)) { return false; } List tbBarcodeInformationList = new ArrayList(); LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); for (BarcodeDeliveryNo barcodeDeliveryNo : barcodeList) { DynamicData detail = barcodeDeliveryNo.getDynamicData(); updateWrapper.clear(); updateWrapper.eq(TblBarcodeInformation::getSmallBarcode, barcodeDeliveryNo.getSmallBarcode()); remove(updateWrapper); TblBarcodeInformation barcodeInformation = new TblBarcodeInformation(); BeanUtil.copyProperties(barcodeDeliveryNo, barcodeInformation); barcodeInformation.setDeliveryNo(deliveryNo); // String[] split = detail.getPoLineNo().split("-"); // barcodeInformation.setPoLineNo(split[0]); barcodeInformation.setExtendN01(detail.getExtendN01()); barcodeInformation.setPoErpNo(detail.getPoErpNo()); barcodeInformation.setInnerVendorCode(detail.getInnerVendorCode()); long timestamp = Long.parseLong(detail.getCustomize1()); // 将时间戳转换为Instant对象 Instant instant = Instant.ofEpochMilli(timestamp); // 创建DateTimeFormatter实例,指定格式 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss") .withZone(ZoneId.systemDefault()); // 格式化为字符串 String formattedDate = formatter.format(instant); barcodeInformation.setCustomize1(formattedDate); tbBarcodeInformationList.add(barcodeInformation); } return saveBatch(tbBarcodeInformationList); } }