industrial_measurement/src/main/java/com/xkrs/service/impl/DataSourceServiceImpl.java

60 lines
2.2 KiB
Java
Raw Normal View History

2022-02-12 08:48:57 +08:00
package com.xkrs.service.impl;
import com.xkrs.dao.DataDictDao;
import com.xkrs.dao.DataSourceDao;
import com.xkrs.encapsulation.PromptMessageEnum;
import com.xkrs.model.entity.DataDict;
import com.xkrs.model.entity.DataSource;
import com.xkrs.model.qo.DataSourceQo;
import com.xkrs.service.DataSourceService;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Locale;
import static com.xkrs.encapsulation.OutputEncapsulation.outputEncapsulationObject;
/**
* @Author: XinYi Song
* @Date: 2022/1/19 16:43
*/
@Service
public class DataSourceServiceImpl implements DataSourceService {
@Resource
private DataSourceDao dataSourceDao;
@Resource
private DataDictDao dataDictDao;
/**
* 添加测量数据
* @param dataSourceQo
* @return
*/
@Override
public String insertDataSource(DataSourceQo dataSourceQo) {
Locale locale = LocaleContextHolder.getLocale();
DataDict byDictEnglishName = dataDictDao.findByDictEnglishName(dataSourceQo.getDataName());
if(byDictEnglishName == null){
2022-02-25 08:40:50 +08:00
2022-02-12 08:48:57 +08:00
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"不存在该字典类型!",locale);
}
/*DataSource byDataName = dataSourceDao.findByDataName(dataSourceQo.getDataName());
if(byDataName != null){
return outputEncapsulationObject(PromptMessageEnum.DATA_EXIT,"该字典类型数据已添加,请勿重复添加!",locale);
}*/
DataSource dataSource = new DataSource();
dataSource.setDataModelNumber(dataSourceQo.getDataModelNumber());
dataSource.setDataBatchNumber(dataSourceQo.getDataBatchNumber());
dataSource.setDataMachineCode(dataSourceQo.getDataMachineCode());
dataSource.setProductNumber(dataSourceQo.getProductNumber());
2022-02-25 08:40:50 +08:00
dataSource.setMaterial(dataSourceQo.getMaterial());
2022-02-12 08:48:57 +08:00
dataSource.setDataName(dataSourceQo.getDataName());
dataSource.setNumericalValue(dataSourceQo.getNumericalValue());
dataSourceDao.save(dataSource);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"添加成功!",locale);
}
}