|
|
@@ -25,6 +25,7 @@ import org.sky.scientific.e.XmStatusEnum;
|
|
|
import org.sky.scientific.excel.XmExcel;
|
|
|
import org.sky.scientific.mapper.DepartmentMapper;
|
|
|
import org.sky.scientific.mapper.TechnicianMapper;
|
|
|
+import org.sky.scientific.mapper.XmCostDetailsMapper;
|
|
|
import org.sky.scientific.mapper.XmMapper;
|
|
|
import org.sky.scientific.pojo.dto.XmDTO;
|
|
|
import org.sky.scientific.pojo.dto.XmUpdateDto;
|
|
|
@@ -37,6 +38,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.InputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
@@ -53,6 +55,7 @@ public class XmServiceImpl extends BaseServiceImpl<XmMapper, XmEntity> implement
|
|
|
|
|
|
private final TechnicianMapper technicianMapper;
|
|
|
private final DepartmentMapper departmentMapper;
|
|
|
+ private final XmCostDetailsMapper xmCostDetailsMapper;
|
|
|
|
|
|
@Override
|
|
|
public IPage<XmEntity> selectXmList(IPage<XmEntity> page, XmDTO xm) {
|
|
|
@@ -128,6 +131,12 @@ public class XmServiceImpl extends BaseServiceImpl<XmMapper, XmEntity> implement
|
|
|
List<XmSummary> xmList = baseMapper.summaryPage(page, xm);
|
|
|
|
|
|
int year = Integer.parseInt(xm.getYearAndMonth().substring(0, 4));
|
|
|
+
|
|
|
+ //本年度已归集研发费用(万元)
|
|
|
+ List<JSONObject> costByDateList = xmCostDetailsMapper.statisticsCost(xm.getYearAndMonth(), SecureUtil.getTenantId());
|
|
|
+ //全周期已归集(万元)
|
|
|
+ List<JSONObject> costAllList = xmCostDetailsMapper.statisticsCost(null, SecureUtil.getTenantId());
|
|
|
+
|
|
|
for (XmSummary xmVO : xmList) {
|
|
|
|
|
|
//立项报告数量
|
|
|
@@ -145,6 +154,27 @@ public class XmServiceImpl extends BaseServiceImpl<XmMapper, XmEntity> implement
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //全周期已归集(万元)
|
|
|
+ double qzqygj = costAllList.stream().filter(item -> Func.equals(item.getLong("xmId"), xmVO.getId())).mapToDouble(item -> item.getDouble("amountTotal")).sum();
|
|
|
+ //元->万元
|
|
|
+ xmVO.setQzqygj(BigDecimal.valueOf(qzqygj).multiply(BigDecimal.valueOf(0.0001)).setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //总预算完成率(%)
|
|
|
+ if (xmVO.getQzqygj() == null || xmVO.getQzqygj().compareTo(BigDecimal.ZERO) <= 0 || xmVO.getXmysze() == null || xmVO.getXmysze().compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
+ xmVO.setZyswcl(BigDecimal.ZERO);
|
|
|
+ } else {
|
|
|
+ xmVO.setZyswcl(xmVO.getQzqygj().divide(xmVO.getXmysze(), 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)));
|
|
|
+ }
|
|
|
+
|
|
|
+ //本年度已归集研发费用(万元)
|
|
|
+ double ndygjyffy = costByDateList.stream().filter(item -> Func.equals(item.getLong("xmId"), xmVO.getId())).mapToDouble(item -> item.getDouble("amountTotal")).sum();
|
|
|
+ //元->万元
|
|
|
+ xmVO.setNdygjyffy(BigDecimal.valueOf(ndygjyffy).multiply(BigDecimal.valueOf(0.0001)).setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //年度已归集金额/年度预算(%)xmyszeCurrentYear
|
|
|
+ if (xmVO.getNdygjyffy() == null || xmVO.getNdygjyffy().compareTo(BigDecimal.ZERO) <= 0 || xmVO.getXmyszeCurrentYear() == null || xmVO.getXmyszeCurrentYear() <= 0) {
|
|
|
+ xmVO.setNdygjjel(BigDecimal.ZERO);
|
|
|
+ } else {
|
|
|
+ xmVO.setNdygjjel(xmVO.getNdygjyffy().divide(BigDecimal.valueOf(xmVO.getXmyszeCurrentYear()),4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)));
|
|
|
+ }
|
|
|
xmVO.setXmsqdw(departmentMapper.getFullNameById(xmVO.getXmsqdwid()));
|
|
|
}
|
|
|
return page.setRecords(xmList);
|
|
|
@@ -154,44 +184,44 @@ public class XmServiceImpl extends BaseServiceImpl<XmMapper, XmEntity> implement
|
|
|
@Override
|
|
|
public void exportSummary(HttpServletResponse response, XmDTO dto) {
|
|
|
// try {
|
|
|
- InputStream templateFileName = this.getClass().getClassLoader().getResourceAsStream("export-template/研发项目汇总表.xls");
|
|
|
- response.setContentType("application/vnd.ms-excel");
|
|
|
- response.setCharacterEncoding("utf-8");
|
|
|
- response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("研发项目汇总表.xls", Charsets.UTF_8));
|
|
|
-
|
|
|
- Query query = new Query().setCurrent(1).setSize(Integer.MAX_VALUE);
|
|
|
-
|
|
|
- List<XmSummary> list = this.summaryPage(Condition.getPage(query), dto).getRecords();
|
|
|
- AtomicInteger index = new AtomicInteger();
|
|
|
- for (XmSummary summary : list) {
|
|
|
- summary.setXh(index.incrementAndGet());
|
|
|
- Optional<XmStatusEnum> first = Arrays.stream(XmStatusEnum.values()).filter(status -> status.getCode() == summary.getStatus()).findFirst();
|
|
|
- summary.setStatusName(first.isPresent()?first.get().getName():"");
|
|
|
-
|
|
|
- summary.setXmkssjStr(Func.notNull(summary.getXmkssj())?DateUtil.format(summary.getXmkssj(), DateUtil.PATTERN_DATE):null);
|
|
|
- summary.setXmjssjStr(Func.notNull(summary.getXmjssj())?DateUtil.format(summary.getXmjssj(), DateUtil.PATTERN_DATE):null);
|
|
|
-
|
|
|
- summary.setLxbgStatus((summary.getLxbgCount()>0)?"已提交":"未提交");
|
|
|
- summary.setJdxbgStatus((summary.getJdxbgCount()>0)?"已提交":"未提交");
|
|
|
- summary.setYsbgStatus((summary.getYsbgCount()>0)?"已提交":"未提交");
|
|
|
- }
|
|
|
+ InputStream templateFileName = this.getClass().getClassLoader().getResourceAsStream("export-template/研发项目管理/研发项目汇总表.xls");
|
|
|
+ response.setContentType("application/vnd.ms-excel");
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
+ response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("研发项目汇总表.xls", Charsets.UTF_8));
|
|
|
|
|
|
- ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream())
|
|
|
- .withTemplate((templateFileName))
|
|
|
- .excelType(ExcelTypeEnum.XLS)
|
|
|
- .build();
|
|
|
-
|
|
|
- WriteSheet writeSheet = EasyExcel.writerSheet().build();
|
|
|
- //设置list集合数据
|
|
|
- excelWriter.fill(list, writeSheet);
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("year", dto.getYearAndMonth().substring(0, 4));
|
|
|
- map.put("month", dto.getYearAndMonth().substring(4));
|
|
|
- excelWriter.fill(map, writeSheet);
|
|
|
- excelWriter.finish();
|
|
|
- if (templateFileName != null) {
|
|
|
- templateFileName.close();
|
|
|
- }
|
|
|
+ Query query = new Query().setCurrent(1).setSize(Integer.MAX_VALUE);
|
|
|
+
|
|
|
+ List<XmSummary> list = this.summaryPage(Condition.getPage(query), dto).getRecords();
|
|
|
+ AtomicInteger index = new AtomicInteger();
|
|
|
+ for (XmSummary summary : list) {
|
|
|
+ summary.setXh(index.incrementAndGet());
|
|
|
+ Optional<XmStatusEnum> first = Arrays.stream(XmStatusEnum.values()).filter(status -> status.getCode() == summary.getStatus()).findFirst();
|
|
|
+ summary.setStatusName(first.isPresent() ? first.get().getName() : "");
|
|
|
+
|
|
|
+ summary.setXmkssjStr(Func.notNull(summary.getXmkssj()) ? DateUtil.format(summary.getXmkssj(), DateUtil.PATTERN_DATE) : null);
|
|
|
+ summary.setXmjssjStr(Func.notNull(summary.getXmjssj()) ? DateUtil.format(summary.getXmjssj(), DateUtil.PATTERN_DATE) : null);
|
|
|
+
|
|
|
+ summary.setLxbgStatus((summary.getLxbgCount() > 0) ? "已提交" : "未提交");
|
|
|
+ summary.setJdxbgStatus((summary.getJdxbgCount() > 0) ? "已提交" : "未提交");
|
|
|
+ summary.setYsbgStatus((summary.getYsbgCount() > 0) ? "已提交" : "未提交");
|
|
|
+ }
|
|
|
+
|
|
|
+ ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream())
|
|
|
+ .withTemplate((templateFileName))
|
|
|
+ .excelType(ExcelTypeEnum.XLS)
|
|
|
+ .build();
|
|
|
+
|
|
|
+ WriteSheet writeSheet = EasyExcel.writerSheet().build();
|
|
|
+ //设置list集合数据
|
|
|
+ excelWriter.fill(list, writeSheet);
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("year", dto.getYearAndMonth().substring(0, 4));
|
|
|
+ map.put("month", dto.getYearAndMonth().substring(4));
|
|
|
+ excelWriter.fill(map, writeSheet);
|
|
|
+ excelWriter.finish();
|
|
|
+ if (templateFileName != null) {
|
|
|
+ templateFileName.close();
|
|
|
+ }
|
|
|
// }catch (Exception e) {
|
|
|
// throw new ServiceException("导出失败," + e.getLocalizedMessage());
|
|
|
// try {
|
|
|
@@ -209,7 +239,7 @@ public class XmServiceImpl extends BaseServiceImpl<XmMapper, XmEntity> implement
|
|
|
throw new ServiceException("参数xmId不能为空");
|
|
|
}
|
|
|
XmYszbVO vo = baseMapper.selectYszb(xmId);
|
|
|
- List<JSONObject> mxList = JSON.parseArray(vo.getXmyszemx(), JSONObject.class);
|
|
|
+ List<JSONObject> mxList = JSON.parseArray(vo.getXmyszemx(), JSONObject.class);
|
|
|
vo.setXmysze(mxList.stream().mapToDouble(t -> t.getDouble("amount")).sum());
|
|
|
|
|
|
vo.setXmsqdw(departmentMapper.getFullNameById(vo.getXmsqdwid()));
|
|
|
@@ -239,7 +269,7 @@ public class XmServiceImpl extends BaseServiceImpl<XmMapper, XmEntity> implement
|
|
|
List<JSONObject> list = this.selectAssistList(Condition.getPage(new Query().setCurrent(1).setSize(Integer.MAX_VALUE)), dto).getRecords();
|
|
|
AtomicInteger index = new AtomicInteger(1);
|
|
|
|
|
|
- list.forEach(temp -> {
|
|
|
+ list.forEach(temp -> {
|
|
|
temp.put("xh", index.getAndIncrement() + "");
|
|
|
});
|
|
|
|