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;
|
}
|
}
|