|
@@ -114,6 +114,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
@Resource
|
|
|
private ReportLogDetailMapper reportLogDetailMapper;
|
|
|
@Resource
|
|
|
+ private FinanceFixedcolnameService financeFixedcolnameService;
|
|
|
+ @Resource
|
|
|
private CompanyDingdingService companyDingdingService;
|
|
|
@Resource
|
|
|
private ReportBatchMapper reportBatchMapper;
|
|
@@ -134,6 +136,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
@Resource
|
|
|
private ReportLogService reportLogService;
|
|
|
@Resource
|
|
|
+ private FinanceTblcuscolMapper financeTblcuscolMapper;
|
|
|
+ @Resource
|
|
|
ReportExtraDegreeMapper reportExtraDegreeMapper;
|
|
|
@Resource
|
|
|
WxCorpInfoService wxCorpInfoService;
|
|
@@ -241,14 +245,13 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
@Value(value = "${upload.path}")
|
|
|
private String path;
|
|
|
@Autowired
|
|
|
- private BusinessTripMapper businessTripMapper;
|
|
|
- @Autowired
|
|
|
private BustripProjectMapper bustripProjectMapper;
|
|
|
@Resource
|
|
|
private CompanyDingdingMapper companyDingdingMapper;
|
|
|
@Resource
|
|
|
private SysRoleFunctionService sysRoleFunctionService;
|
|
|
- private DingDingService dingDingService;
|
|
|
+ @Resource
|
|
|
+ private FinanceMapper financeMapper;
|
|
|
|
|
|
|
|
|
//获取报告列表
|
|
@@ -12127,15 +12130,17 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HttpRespMsg getProduceTimeReport(Integer companyId, Integer projectId, String startDate, String endDate) {
|
|
|
+ public HttpRespMsg getProduceTimeReport(Integer companyId, Integer projectId, String ymonth) {
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
- msg.setData(getProduceTime(companyId, projectId, startDate, endDate));
|
|
|
+ msg.setData(getProduceTime(companyId, projectId, ymonth));
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
- private List<ProduceTime> getProduceTime(Integer companyId, Integer projectId, String startDate, String endDate) {
|
|
|
+ private List<ProduceTime> getProduceTime(Integer companyId, Integer projectId, String ymonth) {
|
|
|
Integer leaveProjectId = 80333;//请假项目,排除在外
|
|
|
Integer publicProjectId = 77651;//公共项目
|
|
|
+ String startDate = ymonth + "-01";
|
|
|
+ String endDate = ymonth + "-31";
|
|
|
QueryWrapper<Report> wrapper = new QueryWrapper<Report>().select("id, create_date, creator_id, project_id,dept_id, working_time, group_id, extra_field4").eq("company_id", companyId).ne("project_id", leaveProjectId)
|
|
|
.eq("state", 1).between("create_date", startDate, endDate);
|
|
|
if (projectId != null) {
|
|
@@ -12150,6 +12155,21 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
Integer rdDeptId = departmentList.stream().filter(dept->dept.getDepartmentName().equals("研发中心")).findFirst().get().getDepartmentId();
|
|
|
Integer cuServiceDeptId = departmentList.stream().filter(dept->dept.getDepartmentName().equals("售后部")).findFirst().get().getDepartmentId();
|
|
|
List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
|
|
|
+ //获取薪资数据
|
|
|
+ List<Finance> finances = financeMapper.selectList(new QueryWrapper<Finance>().eq("company_id", companyId).eq("ymonth",ymonth));
|
|
|
+ //按人员分组,获取工时数
|
|
|
+ Map<String, Double> userTime = reportList.stream().collect(Collectors.groupingBy(Report::getCreatorId, Collectors.summingDouble(Report::getWorkingTime)));
|
|
|
+ finances.forEach(f->{
|
|
|
+ String uid = f.getUserId();
|
|
|
+ Double b = userTime.get(uid);
|
|
|
+ if (b != null) {
|
|
|
+ BigDecimal avgHourCost = f.getTotalCost().divide(new BigDecimal(b),6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ f.setHourCost(avgHourCost);
|
|
|
+ //同步设置人员的时薪
|
|
|
+ userList.stream().filter(u->u.getId().equals(f.getUserId())).findFirst().ifPresent(u->u.setCost(avgHourCost));
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
List<ProduceTime> result = new ArrayList<>();
|
|
|
if (reportList.size() > 0) {
|
|
|
//按照项目和人员进行分组统计
|
|
@@ -12170,8 +12190,15 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
Map<String, List<Report>> membReportList = reports.stream().collect(Collectors.groupingBy(Report::getCreatorId));
|
|
|
|
|
|
membReportList.forEach((membId, oneMembList )-> {
|
|
|
- User user = userList.stream().filter(u->u.getId().equals(membId)).findFirst().get();
|
|
|
ProduceTime produceTimeItem = new ProduceTime();
|
|
|
+ produceTimeItem.setUserTotalTime(userTime.get(membId));
|
|
|
+ User user = userList.stream().filter(u->u.getId().equals(membId)).findFirst().get();
|
|
|
+ Optional<Finance> f = finances.stream().filter(finance -> finance.getUserId().equals(membId)).findFirst();
|
|
|
+ if (f.isPresent()) {
|
|
|
+ Finance userFinance = f.get();
|
|
|
+ produceTimeItem.setUserFinance(userFinance);
|
|
|
+ }
|
|
|
+
|
|
|
produceTimeItem.setProjectId(p.getId());
|
|
|
produceTimeItem.setProjectCode(p.getProjectCode());
|
|
|
produceTimeItem.setProjectName(projectName);
|
|
@@ -12220,7 +12247,6 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
produceTimeItem.setManufactureCost(user.getCost().multiply(new BigDecimal(manufactureTime)).setScale(2, RoundingMode.HALF_UP));
|
|
|
produceTimeItem.setRdCost(user.getCost().multiply(new BigDecimal(rdTime)).setScale(2, RoundingMode.HALF_UP));
|
|
|
produceTimeItem.setSalesCost(user.getCost().multiply(new BigDecimal(cusTime)).setScale(2, RoundingMode.HALF_UP));
|
|
|
-
|
|
|
result.add(produceTimeItem);
|
|
|
});
|
|
|
});
|
|
@@ -12230,8 +12256,42 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HttpRespMsg exportProduceTimeReport(Integer companyId, Integer projectId, String startDate, String endDate) {
|
|
|
+ public HttpRespMsg exportProduceTimeReport(Integer companyId, Integer projectId, String ymonth) {
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ //准备多张sheet
|
|
|
+ final List<FinanceTblcuscol> cusColList = financeTblcuscolMapper.selectList(new QueryWrapper<FinanceTblcuscol>().eq("company_id", companyId));
|
|
|
+ List<String> sheetNameList = new ArrayList<String>();
|
|
|
+ sheetNameList.add("财务数据分摊总表");
|
|
|
+ FinanceFixedcolname fixedItem = financeFixedcolnameService.getFixed(companyId);
|
|
|
+ if(!StringUtils.isEmpty(fixedItem.getMonthCost())){
|
|
|
+ sheetNameList.add(fixedItem.getMonthCost()+"分摊表");
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(fixedItem.getBonus())){
|
|
|
+ sheetNameList.add(fixedItem.getBonus()+"分摊表");
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(fixedItem.getAllowance())){
|
|
|
+ sheetNameList.add(fixedItem.getAllowance()+"分摊表");
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(fixedItem.getInsuranceOld())){
|
|
|
+ sheetNameList.add(fixedItem.getInsuranceOld()+"分摊表");
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(fixedItem.getInsuranceMedical())){
|
|
|
+ sheetNameList.add(fixedItem.getInsuranceMedical()+"分摊表");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!StringUtils.isEmpty(fixedItem.getInsuranceLosejob())){
|
|
|
+ sheetNameList.add(fixedItem.getInsuranceLosejob()+"分摊表");
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(fixedItem.getInsuranceInjury())){
|
|
|
+ sheetNameList.add(fixedItem.getInsuranceInjury()+"分摊表");
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(fixedItem.getHouseFund())){
|
|
|
+ sheetNameList.add(fixedItem.getHouseFund()+"分摊表");
|
|
|
+ }
|
|
|
+ for (FinanceTblcuscol col : cusColList) {
|
|
|
+ sheetNameList.add(col.getFieldName()+"分摊表");
|
|
|
+ }
|
|
|
+
|
|
|
List<List<String>> dataList = new ArrayList<>();
|
|
|
List<String> headList = new ArrayList<>();
|
|
|
headList.add("项目编号");
|
|
@@ -12247,7 +12307,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
headList.add("研发支出-工资");
|
|
|
headList.add("销售费用-工资");
|
|
|
dataList.add(headList);
|
|
|
- List<ProduceTime> produceTimeList = getProduceTime(companyId, projectId, startDate, endDate);
|
|
|
+ List<ProduceTime> produceTimeList = getProduceTime(companyId, projectId, ymonth);
|
|
|
for (ProduceTime produceTime : produceTimeList) {
|
|
|
List<String> list = new ArrayList<>();
|
|
|
list.add(produceTime.getProjectCode());
|
|
@@ -12266,9 +12326,60 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
}
|
|
|
//生成excel文件导出
|
|
|
//String fileName = "人员每日工时统计_"+startDate+"至"+endDate+"_"+System.currentTimeMillis();
|
|
|
- String fileName = "生产制造工时费用统计_"+ startDate+"至"+endDate+"_"+System.currentTimeMillis();
|
|
|
+ String fileName = "生产制造工时费用统计_"+ ymonth+"_"+System.currentTimeMillis();
|
|
|
try {
|
|
|
- return excelExportService.exportGeneralExcelByTitleAndList(null,null, fileName, dataList, path);
|
|
|
+ List[] multiSheetDataList = new ArrayList[sheetNameList.size()];
|
|
|
+ multiSheetDataList[0] = dataList;
|
|
|
+ for (int i = 1; i < sheetNameList.size(); i++) {
|
|
|
+ String sheetName = sheetNameList.get(i);
|
|
|
+ multiSheetDataList[i] = new ArrayList();
|
|
|
+ multiSheetDataList[i].add(headList);//每个表单的头都一样,数据不一样而已
|
|
|
+ for (ProduceTime produceTime : produceTimeList) {
|
|
|
+ List<String> list = new ArrayList<String>();
|
|
|
+ list.add(produceTime.getProjectCode());
|
|
|
+ list.add(produceTime.getProjectName());
|
|
|
+ list.add(produceTime.getUserName());
|
|
|
+ list.add(produceTime.getDepartmentName());
|
|
|
+ list.add(""+produceTime.getTotalTime());
|
|
|
+ list.add(produceTime.getProduceTime()+"");
|
|
|
+ list.add(produceTime.getWorksheetDeptName());
|
|
|
+ //取费用成本项的值,按比例计算
|
|
|
+ Finance userFinance = produceTime.getUserFinance();
|
|
|
+ BigDecimal cost = new BigDecimal(0);
|
|
|
+ if (userFinance != null) {
|
|
|
+ if (sheetName.equals(fixedItem.getMonthCost()+"分摊表")){
|
|
|
+ cost = userFinance.getMonthCost();
|
|
|
+ } else if (sheetName.equals(fixedItem.getAllowance()+"分摊表")) {
|
|
|
+ cost = userFinance.getAllowance();
|
|
|
+ } else if (sheetName.equals(fixedItem.getInsuranceOld()+"分摊表")) {
|
|
|
+ cost = userFinance.getInsuranceOld();
|
|
|
+ } else if (sheetName.equals(fixedItem.getInsuranceMedical()+"分摊表")) {
|
|
|
+ cost = userFinance.getInsuranceMedical();
|
|
|
+ } else if (sheetName.equals(fixedItem.getInsuranceLosejob()+"分摊表")) {
|
|
|
+ cost = userFinance.getInsuranceLosejob();
|
|
|
+ } else if (sheetName.equals(fixedItem.getInsuranceInjury()+"分摊表")) {
|
|
|
+ cost = userFinance.getInsuranceInjury();
|
|
|
+ } else if (sheetName.equals(fixedItem.getHouseFund()+"分摊表")) {
|
|
|
+ cost = userFinance.getHouseFund();
|
|
|
+ } else if (sheetName.equals(fixedItem.getBonus()+"分摊表")) {
|
|
|
+ cost = userFinance.getBonus();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ BigDecimal produceCost = new BigDecimal(produceTime.getProduceTime()/produceTime.getUserTotalTime()).multiply(cost).setScale(2,BigDecimal.ROUND_HALF_UP);
|
|
|
+ list.add(produceCost.toString());
|
|
|
+ list.add(produceTime.getProjectTime()+"");
|
|
|
+ BigDecimal manufactureCost = new BigDecimal(produceTime.getManufactureTime()/produceTime.getUserTotalTime()).multiply(cost).setScale(2,BigDecimal.ROUND_HALF_UP);
|
|
|
+ list.add(manufactureCost.toString());
|
|
|
+ BigDecimal rdCost = new BigDecimal(produceTime.getRdTime()/produceTime.getUserTotalTime()).multiply(cost).setScale(2,BigDecimal.ROUND_HALF_UP);
|
|
|
+ list.add(rdCost.toString());
|
|
|
+ BigDecimal salesCost = new BigDecimal(produceTime.getSalesTime()/produceTime.getUserTotalTime()).multiply(cost).setScale(2,BigDecimal.ROUND_HALF_UP);
|
|
|
+ list.add(salesCost.toString());
|
|
|
+ multiSheetDataList[i].add(list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return excelExportService.exportMultiSheetGeneralExcelByTitleAndList(null,null,fileName , multiSheetDataList, path, sheetNameList.toArray(new String[0]));
|
|
|
+// return excelExportService.exportGeneralExcelByTitleAndList(null,null, fileName, dataList, path);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|