📄 dbservice.java
字号:
package com.onet.autobill.db;
import java.sql.SQLException;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import com.onet.autobill.dao.DataBaseToolsDao;
import com.onet.autobill.dao.MachineConfigDao;
import com.onet.autobill.dao.MobileSectionDao;
import com.onet.autobill.dao.ProductDao;
import com.onet.autobill.dao.ProvNameDao;
import com.onet.autobill.dao.RouterInfoDao;
import com.onet.autobill.dao.SettleProjectCmdInfoDao;
import com.onet.autobill.model.LineObject;
import com.onet.autobill.model.MachineConfig;
import com.onet.autobill.model.RouterObject;
import com.onet.autobill.model.SettleProjectCmdInfo;
/**
* 数据库操作服务
*
* @author mengwei
*
*/
public class DbService {
private static Logger logger = Logger.getLogger(DbService.class);
private MobileSectionDao mobileSectionDao;
private ProvNameDao provNameDao;
private RouterInfoDao routerInfoDao;
private ProductDao productDao;
private MachineConfigDao machineConfigDao;
private DataBaseToolsDao dataBaseToolsDao;
private SettleProjectCmdInfoDao settleProjectCmdInfoDao;
public List<SettleProjectCmdInfo> getSettleProjectCmdInfoList() {
if (settleProjectCmdInfoDao == null) {
logger.warn("settleProjectCmdInfoDao is null");
return null;
} else {
// synchronized (this) {
return settleProjectCmdInfoDao.getSettleProjectCmdInfo();
// }
}
}
/**
* 服务器配置
*
* @return
*/
public List<MachineConfig> getAllMachineConfigs() {
if (machineConfigDao != null) {
// synchronized (this) {
return machineConfigDao.getAllMachineConfig();
// }
}
logger.warn("machineConfigDao is null");
return null;
}
/**
* 去路由信息
*
* @return
*/
public List<RouterObject> getRouterInfo() {
if (routerInfoDao != null) {
// synchronized (this) {
return routerInfoDao.getRouterInfo();
// }
}
logger.warn("routerInfoDao is null");
return null;
}
/**
* 取号段信息
*
* @return
*/
public Map<String, String> getMobileSection() {
if (mobileSectionDao != null) {
// synchronized (this) {
return mobileSectionDao.getMobileSection();
// }
}
logger.warn("mobileSectionDao is null");
return null;
}
/**
* 取省份信息
*
* @return
*/
public Map<String, String> getProvNameMap() {
if (provNameDao != null) {
// synchronized (this) {
return provNameDao.getProvNameMap();
// }
}
logger.warn("provNameDao is null");
return null;
}
public boolean updateMachineConfigNodeAndTime(int linePoint,
MachineConfig machineConfig) {
if (machineConfigDao != null) {
{
// synchronized (this) {
return machineConfigDao.updateNodeAndTime(linePoint,
machineConfig);
// }
}
}
logger.warn("machineConfigDao is null");
return false;
}
public int importDB(String fileName, String tableName) {
if (dataBaseToolsDao != null) {
// synchronized (this) {
return dataBaseToolsDao.importBillFileToDB(fileName, tableName);
// }
}
logger.warn("dataBaseToolsDao is null");
return 1;
}
public String getTableName(int type, int logcode, int isReply,
String dateStr) throws SQLException {
if (dataBaseToolsDao != null) {
// synchronized (this) {
return dataBaseToolsDao.getTableName(type, logcode, isReply,
dateStr);
// }
}
logger.warn("dataBaseToolsDao is null");
return "";
}
public boolean doAutoTestStat(Date date) {
if (dataBaseToolsDao != null) {
// synchronized (this) {
return dataBaseToolsDao.autoTestStat(date);
// }
}
logger.warn("dataBaseToolsDao is null");
return false;
}
public boolean updateMachineConfigTime(MachineConfig machineConfig) {
if (machineConfigDao != null) {
// synchronized (this) {
return machineConfigDao.updateTime(machineConfig);
// }
}
logger.warn("machineConfigDao is null");
return false;
}
/**
* 倒库出现问题更新,交由自动巡检处理
*
* @param node
* 当为0时转换出现错误,非0:倒库出现错误
* @param machineConfigId
*/
public void errNotify(int node, MachineConfig machineConfig) {
if (machineConfigDao == null) {
logger.warn("machineConfigDao is null");
return;
}
if (node != 0) {
// synchronized (this) {
machineConfigDao.updateTwoNodeByImportToDBErr(node,
machineConfig);
// }
} else {
// synchronized (this) {
machineConfigDao.updateLastNodeToNodeByFileErr(machineConfig);
// }
}
}
public List<LineObject> getProduct() {
if (productDao != null) {
// synchronized (this) {
return productDao.getProduct();
// }
}
logger.warn("productDao is null");
return null;
}
public boolean updateSubmitStatusAndProductId(Date date) {
if (dataBaseToolsDao != null) {
// synchronized (this) {
return dataBaseToolsDao.updateSubmitStatusAndProductId(date);
// }
}
logger.warn("dataBaseToolsDao is null");
return false;
}
public boolean updateDeliverInfo(Date date) {
if (dataBaseToolsDao != null) {
// synchronized (this) {
return dataBaseToolsDao.updateDeliverInfo(date);
// }
}
logger.warn("dataBaseToolsDao is null");
return false;
}
public void setMobileSectionDao(MobileSectionDao mobileSectionDao) {
this.mobileSectionDao = mobileSectionDao;
}
public void setProvNameDao(ProvNameDao provNameDao) {
this.provNameDao = provNameDao;
}
public void setRouterInfoDao(RouterInfoDao routerInfoDao) {
this.routerInfoDao = routerInfoDao;
}
public void setProductDao(ProductDao productDao) {
this.productDao = productDao;
}
public void setSettleProjectCmdInfoDao(
SettleProjectCmdInfoDao settleProjectCmdInfoDao) {
this.settleProjectCmdInfoDao = settleProjectCmdInfoDao;
}
public void setMachineConfigDao(MachineConfigDao machineConfigDao) {
this.machineConfigDao = machineConfigDao;
}
public void setDataBaseToolsDao(DataBaseToolsDao dataBaseToolsDao) {
this.dataBaseToolsDao = dataBaseToolsDao;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -