刘小明
2024-10-12 b76fd3fa68f6e64b40a101d7f688f748dd88d35c
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
package com.dy.pmsOther.adapter;
 
import com.dy.pmsGlobal.daoOth.OthFileMapper;
import com.dy.pmsGlobal.daoOth.OthNetSerialAdapterFileMapper;
import com.dy.pmsGlobal.dyFile.FileOperate;
import com.dy.pmsGlobal.dyFile.FileRestVo;
import com.dy.pmsGlobal.pojoOth.OthFile;
import com.dy.pmsGlobal.pojoOth.OthNetSerialAdapterFile;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
 
@Slf4j
@Service
public class AdapterSv {
    private OthNetSerialAdapterFileMapper dao;
    private FileOperate fileOperate;
    private OthFileMapper othFileMapper;
    @Value("${dy.webFile.fmUrl}")
    private String fmUrl ;
    @Autowired
    public void setDao(OthNetSerialAdapterFileMapper dao) {
        this.dao = dao;
    }
    @Autowired
    public void setFileOperate(FileOperate fileOperate) {
        this.fileOperate = fileOperate;
    }
    @Autowired
    public void setOthFileMapper(OthFileMapper othFileMapper) {
        this.othFileMapper = othFileMapper;
    }
 
 
    public OthNetSerialAdapterFile getAdapter() {
        OthNetSerialAdapterFile adapter =dao.getAdapter();
        if(adapter != null){
            OthFile file = othFileMapper.selectByPrimaryKey(adapter.fileId);
            if (file != null) {
                FileRestVo fileRestVo = fileOperate.parseHashcode(fmUrl, file.hash);
                adapter.webUrl = fileRestVo.fileWebDownloadPath + adapter.fileId;
                adapter.orgName = file.orgName;
                adapter.extName = file.extName;
            }
        }
        return adapter;
    }
 
    public int saveOrUpdateAdapter(OthNetSerialAdapterFile adapter) {
        int count=0;
        if(adapter.getId()==null){
            count = dao.insertSelective(adapter);
        }else{
            count = dao.updateByPrimaryKeySelective(adapter);
        }
        return count;
    }
}