|
|
@@ -9,7 +9,6 @@ import com.alibaba.excel.write.metadata.WriteSheet;
|
|
|
import com.alibaba.excel.write.metadata.fill.FillConfig;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.SneakyThrows;
|
|
|
import org.sky.core.log.exception.ServiceException;
|
|
|
@@ -60,10 +59,13 @@ public class YsZjtrfyServiceImpl extends BaseServiceImpl<YsZjtrfyMapper, YsZjtrf
|
|
|
if (isDuplicate(ysZjtrfy)) {
|
|
|
throw new ServiceException("物资名称已存在");
|
|
|
}
|
|
|
- if(ysZjtrfy.getYsje() != null){
|
|
|
+ if (ysZjtrfy.getDanJia() != null) {
|
|
|
+ ysZjtrfy.setDanJia(ysZjtrfy.getDanJia() * 10000);
|
|
|
+ }
|
|
|
+ if (ysZjtrfy.getYsje() != null) {
|
|
|
ysZjtrfy.setYsje(ysZjtrfy.getYsje() * 10000);
|
|
|
}
|
|
|
- if(ysZjtrfy.getZlfyys() != null){
|
|
|
+ if (ysZjtrfy.getZlfyys() != null) {
|
|
|
ysZjtrfy.setZlfyys(ysZjtrfy.getZlfyys() * 10000);
|
|
|
}
|
|
|
|
|
|
@@ -71,7 +73,11 @@ public class YsZjtrfyServiceImpl extends BaseServiceImpl<YsZjtrfyMapper, YsZjtrf
|
|
|
}
|
|
|
|
|
|
private boolean isDuplicate(YsZjtrfyEntity entity) {
|
|
|
- List<YsZjtrfyEntity> list = baseMapper.selectList(Wrappers.<YsZjtrfyEntity>lambdaQuery().eq(YsZjtrfyEntity::getXmId, entity.getXmId()));
|
|
|
+// LambdaQueryWrapper<YsZjtrfyEntity> ew = Wrappers.<YsZjtrfyEntity>lambdaQuery()
|
|
|
+// .eq(YsZjtrfyEntity::getXmId, entity.getXmId())
|
|
|
+// .eq(YsZjtrfyEntity::getWzmc, entity.getWzmc());
|
|
|
+// List<YsZjtrfyEntity> list = baseMapper.selectList(ew);
|
|
|
+
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
@@ -85,10 +91,13 @@ public class YsZjtrfyServiceImpl extends BaseServiceImpl<YsZjtrfyMapper, YsZjtrf
|
|
|
if (ysZjtrfy.getXmId() == null) {
|
|
|
throw new ServiceException("请选择科研项目");
|
|
|
}
|
|
|
- if(ysZjtrfy.getYsje() != null){
|
|
|
+ if (ysZjtrfy.getDanJia() != null) {
|
|
|
+ ysZjtrfy.setDanJia(ysZjtrfy.getDanJia() * 10000);
|
|
|
+ }
|
|
|
+ if (ysZjtrfy.getYsje() != null) {
|
|
|
ysZjtrfy.setYsje(ysZjtrfy.getYsje() * 10000);
|
|
|
}
|
|
|
- if(ysZjtrfy.getZlfyys() != null){
|
|
|
+ if (ysZjtrfy.getZlfyys() != null) {
|
|
|
ysZjtrfy.setZlfyys(ysZjtrfy.getZlfyys() * 10000);
|
|
|
}
|
|
|
return this.updateById(ysZjtrfy);
|
|
|
@@ -106,7 +115,7 @@ public class YsZjtrfyServiceImpl extends BaseServiceImpl<YsZjtrfyMapper, YsZjtrf
|
|
|
throw new ServiceException("研发项目不存在");
|
|
|
}
|
|
|
YsZjtrfyImportListener listener = new YsZjtrfyImportListener();
|
|
|
- EasyExcel.read(new BufferedInputStream(file.getInputStream()))
|
|
|
+ EasyExcel.read(new BufferedInputStream(file.getInputStream()))
|
|
|
.registerReadListener(listener)
|
|
|
.sheet(0)
|
|
|
.headRowNumber(3) // 重要:设置表头行数(0-based)
|
|
|
@@ -119,12 +128,7 @@ public class YsZjtrfyServiceImpl extends BaseServiceImpl<YsZjtrfyMapper, YsZjtrf
|
|
|
YsZjtrfyEntity entity = new YsZjtrfyEntity();
|
|
|
entity.setXmId(xmId);
|
|
|
BeanUtil.copyProperties(excel, entity);
|
|
|
-// if(entity.getYsje() != null){
|
|
|
-// entity.setYsje(entity.getYsje() / 10000);
|
|
|
-// }
|
|
|
-// if(entity.getZlfyys() != null){
|
|
|
-// entity.setZlfyys(entity.getZlfyys() / 10000);
|
|
|
-// }
|
|
|
+
|
|
|
insertList.add(entity);
|
|
|
if (insertList.size() % batchCount == 0 && this.saveBatch(insertList)) {
|
|
|
insertList.clear();
|
|
|
@@ -143,8 +147,22 @@ public class YsZjtrfyServiceImpl extends BaseServiceImpl<YsZjtrfyMapper, YsZjtrf
|
|
|
AtomicInteger index = new AtomicInteger(1);
|
|
|
for (YsZjtrfyVO temp : list) {
|
|
|
temp.setXh(index.getAndIncrement() + "");
|
|
|
+ if (temp.getDanJia() == null) {
|
|
|
+ temp.setDanJia(0.00);
|
|
|
+ }
|
|
|
+ temp.setDanJia(temp.getDanJia() / 10000);
|
|
|
+ if (temp.getYongLiang() == null) {
|
|
|
+ temp.setYongLiang(0);
|
|
|
+ }
|
|
|
temp.setWuziTotal(BigDecimal.valueOf(temp.getYongLiang() * temp.getDanJia()));
|
|
|
- temp.setYsje(temp.getYsje()/10000);
|
|
|
+ if(temp.getYsje()!=null){
|
|
|
+ temp.setYsje(temp.getYsje() / 10000);
|
|
|
+ }
|
|
|
+ if(temp.getZlfyys()!=null){
|
|
|
+ temp.setZlfyys(temp.getZlfyys() / 10000);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
InputStream templateFileName = this.getClass().getClassLoader().getResourceAsStream("export-template/研发项目管理/预算编制/直接投入费用.xls");
|
|
|
ExcelWriter excelWriter = EasyExcel.write(os)
|