|
|
@@ -9,6 +9,7 @@ import org.sky.core.log.exception.ServiceException;
|
|
|
import org.sky.core.mp.base.BaseServiceImpl;
|
|
|
import org.sky.core.tool.utils.BeanUtil;
|
|
|
import org.sky.core.tool.utils.CollectionUtil;
|
|
|
+import org.sky.core.tool.utils.StringUtil;
|
|
|
import org.sky.scientific.excel.CgZlExcel;
|
|
|
import org.sky.scientific.mapper.CgZlMapper;
|
|
|
import org.sky.scientific.mapper.XmMapper;
|
|
|
@@ -48,7 +49,7 @@ public class CgZlServiceImpl extends BaseServiceImpl<CgZlMapper, CgZlEntity> imp
|
|
|
@Override
|
|
|
public void importZl(MultipartFile file) {
|
|
|
List<CgZlExcel> data = ExcelUtil.read(file, 0, 2, CgZlExcel.class);
|
|
|
- if(CollectionUtil.isEmpty(data)){
|
|
|
+ if (CollectionUtil.isEmpty(data)) {
|
|
|
throw new ServiceException("未能从模板中读取数据,请检查模板格式是否正确");
|
|
|
}
|
|
|
for (CgZlExcel excel : data) {
|
|
|
@@ -59,13 +60,12 @@ public class CgZlServiceImpl extends BaseServiceImpl<CgZlMapper, CgZlEntity> imp
|
|
|
|
|
|
@Override
|
|
|
public boolean save(CgZlEntity cgZl) {
|
|
|
- if (cgZl.getXmbh() != null) {
|
|
|
- XmEntity dbXm = xmMapper.selectOne(Wrappers.<XmEntity>lambdaQuery().eq(XmEntity::getXmbh, cgZl.getXmbh()));
|
|
|
- if(dbXm==null){
|
|
|
- throw new ServiceException("项目编号["+cgZl.getXmbh()+"]不存在,导入失败,请检查数据");
|
|
|
+ if (!StringUtil.isAllBlank(cgZl.getXmbh(), cgZl.getXmmc())) {
|
|
|
+ Long xmId = xmMapper.getXmIdByXmmcOrXmbh(null, cgZl.getXmmc(), cgZl.getXmbh());
|
|
|
+ if (xmId == null) {
|
|
|
+ throw new ServiceException("项目不存在,导入失败,请检查数据");
|
|
|
}
|
|
|
- cgZl.setXmId(dbXm != null ? dbXm.getId() : null);
|
|
|
- cgZl.setXmmc(dbXm != null ? dbXm.getXmmc() : null);
|
|
|
+ cgZl.setXmId(xmId);
|
|
|
}
|
|
|
return super.save(cgZl);
|
|
|
}
|