YYC
2024-12-30 5d2ddd92e970f02f42a4014cc65eb74e33feb776
数据同步
已修改7个文件
295 ■■■■■ 文件已修改
src/main/java/com/fzzy/api/utils/FileUtils.java 254 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/async/fzzy40/entity/Fz40DrugLogPeople.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/async/fzzy40/entity/Fz40InoutStockChange.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1023.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1202.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1207.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1310.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/api/utils/FileUtils.java
@@ -1,9 +1,16 @@
package com.fzzy.api.utils;
import com.fzzy.data.ConfigData;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ws.schild.jave.Encoder;
import ws.schild.jave.EncoderException;
import ws.schild.jave.MultimediaObject;
import ws.schild.jave.encode.AudioAttributes;
import ws.schild.jave.encode.EncodingAttributes;
import ws.schild.jave.encode.VideoAttributes;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -14,114 +21,177 @@
/**
 * 将文件转为二进制流工具类
 * @author czt
 *
 * @author czt
 */
@Slf4j
@Service(FileUtils.BEAN_ID)
public class FileUtils {
    public static final String BEAN_ID = "base.fileUtil";
    public static final String BEAN_ID = "base.fileUtil";
    @Autowired
    private ConfigData configData;
    @Autowired
    private ConfigData configData;
    /**
     * 根据文件路径将文件转为二进制文件流字符串
     * @param filePath:文件路径
     * @return
     */
    public static String fileToByteString(String filePath) {
        byte[] bytes = file2byte(filePath);
        return toHexString(bytes);
    }
    /**
     * 根据文件路径将文件转为二进制文件流字符串
     *
     * @param filePath:文件路径
     * @return
     */
    public static String fileToByteString(String filePath) {
        byte[] bytes = file2byte(filePath);
        return toHexString(bytes);
    }
    /**
     * 根据文件路径将文件转为二进制数组
     * @param filePath:文件路径
     * @return
     */
    public static byte[] file2byte(String filePath) {
        byte[] buffer = null;
        try {
            File file = new File(filePath);
            FileInputStream fis = new FileInputStream(file);
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            byte[] b = new byte[1024];
            int n;
            while ((n = fis.read(b)) != -1) {
                bos.write(b, 0, n);
            }
            fis.close();
            bos.close();
            buffer = bos.toByteArray();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return buffer;
    }
    /**
     * 将二进制数组转为字符串
     * @param byteArray
     * @return
     */
    private static String toHexString(byte[] byteArray) {
        if (byteArray == null || byteArray.length < 1)
            throw new IllegalArgumentException(
                    "this byteArray must not be null or empty");
    /**
     * 根据文件路径将文件转为二进制数组
     *
     * @param filePath:文件路径
     * @return
     */
    public static byte[] file2byte(String filePath) {
        byte[] buffer = null;
        try {
            File file = new File(filePath);
            FileInputStream fis = new FileInputStream(file);
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            byte[] b = new byte[1024];
            int n;
            while ((n = fis.read(b)) != -1) {
                bos.write(b, 0, n);
            }
            fis.close();
            bos.close();
            buffer = bos.toByteArray();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return buffer;
    }
        final StringBuilder hexString = new StringBuilder();
        for (int i = 0; i < byteArray.length; i++) {
            if ((byteArray[i] & 0xff) < 0x10)// 0~F前面不零
                hexString.append("0");
            hexString.append(Integer.toHexString(0xFF & byteArray[i]));
        }
        return hexString.toString().toLowerCase();
    }
    /**
     * 将二进制数组转为字符串
     *
     * @param byteArray
     * @return
     */
    private static String toHexString(byte[] byteArray) {
        if (byteArray == null || byteArray.length < 1)
            throw new IllegalArgumentException(
                    "this byteArray must not be null or empty");
    public String getInoutFilePath(Date date) {
        if (null == date) {
            date = new Date();
        }
        final StringBuilder hexString = new StringBuilder();
        for (int i = 0; i < byteArray.length; i++) {
            if ((byteArray[i] & 0xff) < 0x10)// 0~F前面不零
                hexString.append("0");
            hexString.append(Integer.toHexString(0xFF & byteArray[i]));
        }
        return hexString.toString().toLowerCase();
    }
        String basePath = configData.getImgPath() + "INOUT/"
                + DateFormatUtils.format(date, "yyyyMM") + "/";
    public String getInoutFilePath(Date date) {
        if (null == date) {
            date = new Date();
        }
        File file = new File(basePath);
        if (!file.exists()) {
            file.mkdirs();
        }
        String basePath = configData.getImgPath() + "INOUT/"
                + DateFormatUtils.format(date, "yyyyMM") + "/";
        return basePath;
    }
        File file = new File(basePath);
        if (!file.exists()) {
            file.mkdirs();
        }
    public String getSnapFilePath(Date date) {
        if (null == date) {
            date = new Date();
        }
        return basePath;
    }
        String basePath = configData.getImgPath() + "SNAP/"
                + DateFormatUtils.format(date, "yyyyMM") + "/";
        File file = new File(basePath);
        if (!file.exists()) {
            file.mkdirs();
        }
        return basePath;
    }
    public String getSnapFilePath(Date date) {
        if (null == date) {
            date = new Date();
        }
    public String getCommonFilePath(Date date) {
        if (null == date)
            date = new Date();
        String basePath = configData.getImgPath() + "SNAP/"
                + DateFormatUtils.format(date, "yyyyMM") + "/";
        File file = new File(basePath);
        if (!file.exists()) {
            file.mkdirs();
        }
        return basePath;
    }
        String basePath = configData.getImgPath() + "COMMON/"
                + DateFormatUtils.format(date, "yyyyMM") + "/";
    public String getCommonFilePath(Date date) {
        if (null == date)
            date = new Date();
        File file = new File(basePath);
        if (!file.exists()) {
            file.mkdirs();
        }
        return basePath;
    }
        String basePath = configData.getImgPath() + "COMMON/"
                + DateFormatUtils.format(date, "yyyyMM") + "/";
        File file = new File(basePath);
        if (!file.exists()) {
            file.mkdirs();
        }
        return basePath;
    }
    /**
     * 视频压缩
     *
     * @param source 源文件
     * @param target 目标文件
     * @param rate   压缩比
     */
    public static void compre(File source, File target, Integer rate) throws EncoderException {
        try {
            log.info("---------------开始压缩---------------");
            long start = System.currentTimeMillis();
            // 音频编码属性配置
            AudioAttributes audio = new AudioAttributes();
            audio.setCodec("libmp3lame");
            // 设置音频比特率,单位:b (比特率越高,清晰度/音质越好,当然文件也就越大 56000 = 56kb)
            // audio.setBitRate(new Integer(56_000));
            audio.setBitRate(new Integer(10));
            // 设置重新编码的音频流中使用的声道数(1 =单声道,2 = 双声道(立体声))
            audio.setChannels(1);
            // 采样率越高声音的还原度越好,文件越大
            // audio.setSamplingRate(new Integer(44100));
            audio.setSamplingRate(new Integer(22050));
            // 视频编码属性配置
            VideoAttributes video = new VideoAttributes();
            // 设置编码
            video.setCodec("h254");
            //设置音频比特率,单位:b (比特率越高,清晰度/音质越好,当然文件也就越大 5600000 = 5600kb)
            // video.setBitRate(new Integer(5_600_000 / rate));
            video.setBitRate(10 / rate);
            // 设置视频帧率(帧率越低,视频会出现断层,越高让人感觉越连续),这里 除1000是为了单位转换
            video.setFrameRate(15);
            // 编码设置
            EncodingAttributes attr = new EncodingAttributes();
            attr.setOutputFormat("mp4");
            attr.setAudioAttributes(audio);
            attr.setVideoAttributes(video);
            // 设置值编码
            Encoder ec = new Encoder();
            ec.encode(new MultimediaObject(source), target, attr);
            log.info("---------------结束压缩---------------");
            long end = System.currentTimeMillis();
            log.info("压缩前大小:" + source.length() + " 压缩后大小:" + target.length());
            log.info("压缩耗时:" + (end - start));
        } catch (EncoderException e) {
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        }
    }
}
src/main/java/com/fzzy/async/fzzy40/entity/Fz40DrugLogPeople.java
@@ -24,8 +24,8 @@
    @Id
    @Column(name = "PEOPLE_ID_", length = 40)
    @PropertyDef(label = "propleId")
    private String propleId;
    @PropertyDef(label = "peopleId")
    private String peopleId;
    @Column(name = "DRUG_LOG_ID_", length = 12)
src/main/java/com/fzzy/async/fzzy40/entity/Fz40InoutStockChange.java
@@ -60,6 +60,14 @@
    @PropertyDef(label = "倒出仓库")
    private String depotIdOut;
    @Column(name = "CHANGE_START_DATE_")
    @PropertyDef(label = "倒仓开始日期", description = "yyyy-MM-dd")
    private Date changeStartDate;
    @Column(name = "CHANGE_END_DATE_")
    @PropertyDef(label = "倒仓结束日期", description = "yyyy-MM-dd")
    private Date changeEndDate;
    @Column(name = "CHANGE_DATE_")
    @PropertyDef(label = "倒仓日期", description = "yyyy-MM-dd")
    private Date changeDate;
src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1023.java
@@ -197,11 +197,11 @@
                infoData.setKqdm(kqdm);
                infoData.setInteType(Constant.API_CATEGORY_13);
                infoData.setInteId(ApiCodeConstant.API_1023);
                infoData.setBizType(PushProtocol.SB_GD_2022.getCode());
                infoData.setInteId(ApiCodeConstant.API_9201);
                infoData.setBizType(PushProtocol.SB_GD_2023.getCode());
                infoData.setUpdateTime(new Date());
                infoData.setDataId(data.getXzbm());
                apiInfoList = apiInfoDataRep.getDataByInteAndData(ApiCodeConstant.API_1023, data.getXzbm(), kqdm);
                apiInfoList = apiInfoDataRep.getDataByInteAndData(ApiCodeConstant.API_9201, data.getXzbm(), kqdm);
                if (null == apiInfoList || apiInfoList.isEmpty()) {
                    GD2022Api1023.setCzbz(Constant.CZBZ_I);
src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1202.java
@@ -148,9 +148,14 @@
                //粮权单位归属代码
                List<Api1208> dataByHwdm = api1208Rep.findDataByHwdm(apiData.getHwdm());
                if(null != dataByHwdm && dataByHwdm.size() > 0){
                    apiData.setLqgsdwdm(StringUtils.isEmpty(dataByHwdm.get(0).getLqgsdwdm()) ? apiData.getHwdm().substring(0, 18) : dataByHwdm.get(0).getLqgsdwdm());
                if (null != dataByHwdm && dataByHwdm.size() > 0) {
                    apiData.setLqgsdwdm(StringUtils.isEmpty(dataByHwdm.get(0).getLqgsdwdm()) ? apiData.getKqdm() : dataByHwdm.get(0).getLqgsdwdm());
                }else {
                    apiData.setLqgsdwdm(apiData.getKqdm());
                }
                apiData.setSlr("售粮人");
                apiData.setSlrdz("售粮人地址");
                apiData.setBz(StringUtils.isEmpty(sysData.getRemarks()) ? "备注" : sysData.getRemarks());
                apiData.setXxdz(StringUtils.isEmpty(sysData.getUserAddress()) ? "详细地址" : sysData.getUserAddress());
@@ -164,7 +169,7 @@
                //生成方式
                apiData.setScfs(1);
                if(StringUtils.isNotEmpty(sysData.getRecordStatus()) && sysData.getRecordStatus().equals("ADD")){
                if (StringUtils.isNotEmpty(sysData.getRecordStatus()) && sysData.getRecordStatus().equals("ADD")) {
                    apiData.setScfs(2);
                    apiData.setSdblyy("库区停电导致无法按流程进行出库");
                }
@@ -254,7 +259,6 @@
                apiData.setBizId(sysData.getId());
                apiData.setKqdm(kqdm);
                apiData.setSyncTime(new Date());
                apiData.setBz(null == sysData.getRemarks() ? "备注" : sysData.getRemarks());
                apiData.setKlyy("扣量原因");
                apiData.setCmqrmgryxm(StringUtils.isEmpty(sysData.getRegisterUser()) ? "登记人" : sysData.getRegisterUser());
@@ -263,6 +267,8 @@
                //04:表示农用车车牌号,绿底白字; LS:表示临时虚拟号牌,仅限于售 粮车无固定号牌时使用
                apiData.setCchlx("01");
                apiData.setLdd("装粮地点");
                apiData.setZkj(0.0);
                apiData.setZlfyzkl(0.0);
                apiData.setQzsfzkl(0.0);
                apiData.setQzzzzkl(0.0);
                apiData.setQzgwcmkl(0.0);
src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1207.java
@@ -96,6 +96,8 @@
                apiData.setDchwdm(api1105Out.getHwdm());
                apiData.setDrhwdm(api1105In.getHwdm());
                apiData.setDcrq(sysData.getChangeDate());
                apiData.setDcksrq(sysData.getChangeStartDate());
                apiData.setDcjsrq(sysData.getChangeEndDate());
                apiData.setDcsl(sysData.getNumber());
                apiData.setBzw(sysData.getBzw());
                apiData.setBzbjs(sysData.getBzbjs());
src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1310.java
@@ -106,8 +106,8 @@
                api1310.setRkrq(fz40Quality.getStoreDate());
                api1310.setJylb(fz40Quality.getType());
                api1310.setJysj(fz40Quality.getTime());
                api1310.setJydw(fz40Quality.getUser());
                api1310.setJyr(fz40Quality.getUser());
                api1310.setJydw(StringUtils.isEmpty(fz40Quality.getUnit()) ? "检验单位" : fz40Quality.getUnit());
                api1310.setJyr(StringUtils.isEmpty(fz40Quality.getUser()) ? "检验人" : fz40Quality.getUser());
                api1310.setJyyj(fz40Quality.getStandard());
                if (StringUtils.isEmpty(fz40Quality.getZblb())) {
                    api1310.setZblb("2");
@@ -139,9 +139,6 @@
                api1310.setZbjgpd(fz40Quality.getResult());
                api1310.setQfrq(fz40Quality.getTime());
                api1310.setBgcjsj(fz40Quality.getTime());
                if (fz40Quality.getUser().isEmpty()){
                    fz40Quality.setUser(fz40Quality.getCheckUser());
                }
                api1310.setShrxm(fz40Quality.getShrxm().contains("、")?fz40Quality.getShrxm().replace('、','|'):fz40Quality.getShrxm());
                if (null == fz40Quality.getCheckTime()) {
                    fz40Quality.setCheckTime(DateUtils.addDays(fz40Quality.getTime(), -1));