tjx
3 天以前 10d86aa74f50336a469385be2b2d14410438a234
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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<TblBarcodeInformationMapper, TblBarcodeInformation>
        implements TblBarcodeInformationService {
 
 
    @Override
    public boolean SaveBarcodeInformation(List<BarcodeDeliveryNo> barcodeList, String deliveryNo) {
 
        if (CollUtil.isEmpty(barcodeList)) {
            return false;
        }
 
        List<TblBarcodeInformation> tbBarcodeInformationList = new ArrayList<TblBarcodeInformation>();
 
        LambdaUpdateWrapper<TblBarcodeInformation> 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);
    }
}