|
@@ -18,11 +18,13 @@ import com.ruoyi.gas.domain.vo.GPressureRegulatingBoxVo;
|
|
|
import com.ruoyi.gas.mapper.GPressureRegulatingBoxMapper;
|
|
|
import com.ruoyi.gas.service.IGPressureRegulatingBoxDetailsService;
|
|
|
import com.ruoyi.gas.service.IGPressureRegulatingBoxService;
|
|
|
+import com.ruoyi.system.mapper.SysDictDataMapper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.util.Collection;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -39,6 +41,8 @@ public class GPressureRegulatingBoxServiceImpl extends ServicePlusImpl<GPressure
|
|
|
@Autowired
|
|
|
private IGPressureRegulatingBoxDetailsService igPressureRegulatingBoxDetailsService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private SysDictDataMapper sysDictDataMapper;
|
|
|
@Override
|
|
|
public Map<String, Object> importVo(List<GPressureRegulatingBoxExcelVo> list, Boolean isUpdateSupport, String operName, int n, int successNum) {
|
|
|
if (ObjectUtils.isEmpty(list) || list.size() == 0) {
|
|
@@ -51,7 +55,28 @@ public class GPressureRegulatingBoxServiceImpl extends ServicePlusImpl<GPressure
|
|
|
try {
|
|
|
n++;
|
|
|
if (StringUtils.isNotEmpty(vo.getNumber())) {
|
|
|
- GPressureRegulatingBox gPressureRegulatingBox = baseMapper.getByNumber(vo.getNumber());
|
|
|
+ successNum++;
|
|
|
+ GPressureRegulatingBox gPressureRegulatingBox = baseMapper.getByNumber(vo.getNumber(),vo.getName(),vo.getManagementOffice());
|
|
|
+ String type = sysDictDataMapper.queryValueTextByKey("tyx_type", vo.getType());
|
|
|
+ if (StringUtils.isBlank(type)) {
|
|
|
+ throw new ServiceException( "第" + (n + 1) + "行类型填写错误,导入失败!");
|
|
|
+ }
|
|
|
+ String getNature = sysDictDataMapper.queryValueTextByKey("tyx_nature", vo.getNature());
|
|
|
+ if (StringUtils.isBlank(getNature)) {
|
|
|
+ throw new ServiceException("第" + (n + 1) + "行性质填写错误,导入失败!");
|
|
|
+ }
|
|
|
+ String getNumberOfRoutes = sysDictDataMapper.queryValueTextByKey("tyx_numberOfRoutes", vo.getNumberOfRoutes());
|
|
|
+ if (StringUtils.isBlank(getNumberOfRoutes)) {
|
|
|
+ throw new ServiceException( "第" + (n + 1) + "行路数填写错误,导入失败!");
|
|
|
+ }
|
|
|
+ String getManagementOffice = sysDictDataMapper.queryValueTextByKey("administrative_office", vo.getManagementOffice());
|
|
|
+ if (StringUtils.isBlank(getManagementOffice)) {
|
|
|
+ throw new ServiceException( "第" + (n + 1) + "行管理所填写错误,导入失败!");
|
|
|
+ }
|
|
|
+ vo.setNature(getNature);
|
|
|
+ vo.setType(type);
|
|
|
+ vo.setNumberOfRoutes(getNumberOfRoutes);
|
|
|
+ vo.setManagementOffice(getManagementOffice);
|
|
|
if (ObjectUtils.isEmpty(gPressureRegulatingBox)) {
|
|
|
GPressureRegulatingBox bean = BeanUtil.toBean(vo, GPressureRegulatingBox.class);
|
|
|
bean.setId(null);
|
|
@@ -59,8 +84,12 @@ public class GPressureRegulatingBoxServiceImpl extends ServicePlusImpl<GPressure
|
|
|
Long id = bean.getId();
|
|
|
GPressureRegulatingBoxDetailsBo bean1 = BeanUtil.toBean(vo, GPressureRegulatingBoxDetailsBo.class);
|
|
|
bean1.setRegulatingBoxId(id.toString());
|
|
|
+ bean1.setId(null);
|
|
|
igPressureRegulatingBoxDetailsService.insertByBo(bean1);
|
|
|
} else {
|
|
|
+ GPressureRegulatingBox bean = BeanUtil.toBean(vo, GPressureRegulatingBox.class);
|
|
|
+ bean.setId(gPressureRegulatingBox.getId());
|
|
|
+ baseMapper.updateById(bean);
|
|
|
Long id = gPressureRegulatingBox.getId();
|
|
|
GPressureRegulatingBoxDetailsBo bean1 = BeanUtil.toBean(vo, GPressureRegulatingBoxDetailsBo.class);
|
|
|
bean1.setRegulatingBoxId(id.toString());
|
|
@@ -68,9 +97,10 @@ public class GPressureRegulatingBoxServiceImpl extends ServicePlusImpl<GPressure
|
|
|
igPressureRegulatingBoxDetailsService.insertByBo(bean1);
|
|
|
}
|
|
|
}else {
|
|
|
- throw new ServiceException("第" + (n + 1) + "行格式错误,导入失败!");
|
|
|
+ throw new ServiceException("第" + (n + 1) + "行编号错误,导入失败!");
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
throw new ServiceException("第" + (n + 1) + "行格式错误,导入失败!");
|
|
|
}
|
|
|
ret.put("bfb", String.format("%.2f", (Double.valueOf((n + 1)) / Double.valueOf(list.size())) * 100));
|
|
@@ -80,7 +110,7 @@ public class GPressureRegulatingBoxServiceImpl extends ServicePlusImpl<GPressure
|
|
|
ret.put("successNum", successNum);
|
|
|
return ret;
|
|
|
}
|
|
|
- successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + list.size() + " 条");
|
|
|
+ successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条");
|
|
|
ret.put("bfb", String.format("%.2f", (Double.valueOf((n + 1)) / Double.valueOf(list.size())) * 100));
|
|
|
ret.put("n", n);
|
|
|
ret.put("is_success", false);
|
|
@@ -138,6 +168,7 @@ public class GPressureRegulatingBoxServiceImpl extends ServicePlusImpl<GPressure
|
|
|
lqw.like(StringUtils.isNotBlank(bo.getName()), GPressureRegulatingBox::getName, bo.getName());
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getLongitude()), GPressureRegulatingBox::getLongitude, bo.getLongitude());
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getLatitude()), GPressureRegulatingBox::getLatitude, bo.getLatitude());
|
|
|
+ lqw.like(StringUtils.isNotBlank(bo.getInspector()), GPressureRegulatingBox::getInspector, bo.getInspector());
|
|
|
return lqw;
|
|
|
}
|
|
|
|