|
@@ -31,6 +31,7 @@ import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import java.io.*;
|
|
import java.io.*;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
+import java.math.RoundingMode;
|
|
import java.sql.Wrapper;
|
|
import java.sql.Wrapper;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.time.Instant;
|
|
import java.time.Instant;
|
|
@@ -83,6 +84,8 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
private PlanProcedureTotalService planProcedureTotalService;
|
|
private PlanProcedureTotalService planProcedureTotalService;
|
|
@Resource
|
|
@Resource
|
|
private TaskTypeService taskTypeService;
|
|
private TaskTypeService taskTypeService;
|
|
|
|
+ @Resource
|
|
|
|
+ private ReportMapper reportMapper;
|
|
|
|
|
|
@Value(value = "${upload.path}")
|
|
@Value(value = "${upload.path}")
|
|
private String path;
|
|
private String path;
|
|
@@ -122,8 +125,8 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
List<ProdProcedureTeam> prodProcedureTeams = prodProcedureTeamService.list(new QueryWrapper<ProdProcedureTeam>().eq("company_id", companyId).eq("user_id", user.getId()));
|
|
List<ProdProcedureTeam> prodProcedureTeams = prodProcedureTeamService.list(new QueryWrapper<ProdProcedureTeam>().eq("company_id", companyId).eq("user_id", user.getId()));
|
|
List<Integer> collect=new ArrayList<>();
|
|
List<Integer> collect=new ArrayList<>();
|
|
if(prodProcedureTeams!=null&&prodProcedureTeams.size()>0){
|
|
if(prodProcedureTeams!=null&&prodProcedureTeams.size()>0){
|
|
- List<Integer> ids = prodProcedureTeams.stream().map(ProdProcedureTeam::getProdProcedureId).collect(Collectors.toList());
|
|
|
|
- List<PlanProcedureTotal> list = planProcedureTotalService.list(new QueryWrapper<PlanProcedureTotal>().in("prod_procedure_id", ids));
|
|
|
|
|
|
+ List<Integer> ids = prodProcedureTeams.stream().map(ProdProcedureTeam::getPlanProcedureId).collect(Collectors.toList());
|
|
|
|
+ List<PlanProcedureTotal> list = planProcedureTotalService.list(new QueryWrapper<PlanProcedureTotal>().in("id", ids));
|
|
collect = list.stream().map(PlanProcedureTotal::getPlanId).distinct().collect(Collectors.toList());
|
|
collect = list.stream().map(PlanProcedureTotal::getPlanId).distinct().collect(Collectors.toList());
|
|
}
|
|
}
|
|
collect.add(-1);
|
|
collect.add(-1);
|
|
@@ -639,23 +642,44 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
|
|
Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
|
|
BigDecimal totalWages=new BigDecimal(planProcedureTotal.getTotalWages());
|
|
BigDecimal totalWages=new BigDecimal(planProcedureTotal.getTotalWages());
|
|
BigDecimal totalWorkingHours=new BigDecimal(planProcedureTotal.getTotalWorkingHours());
|
|
BigDecimal totalWorkingHours=new BigDecimal(planProcedureTotal.getTotalWorkingHours());
|
|
|
|
+ BigDecimal overCountWages = new BigDecimal(0);
|
|
|
|
+ BigDecimal overWorkingHours = new BigDecimal(0);
|
|
List<ProdProcedureTeam> list=new ArrayList<>();
|
|
List<ProdProcedureTeam> list=new ArrayList<>();
|
|
- if(StringUtils.isEmpty(teamIds)){
|
|
|
|
|
|
+ if(!StringUtils.isEmpty(teamIds)){
|
|
String[] team = teamIds.split(",");
|
|
String[] team = teamIds.split(",");
|
|
- totalWages=totalWages.divide(new BigDecimal(team.length));
|
|
|
|
- totalWorkingHours=totalWorkingHours.divide(new BigDecimal(team.length));
|
|
|
|
- for (String s : team) {
|
|
|
|
|
|
+ totalWages=totalWages.divide(new BigDecimal(team.length),1, RoundingMode.HALF_UP);
|
|
|
|
+ totalWorkingHours=totalWorkingHours.divide(new BigDecimal(team.length),1, RoundingMode.HALF_UP);
|
|
|
|
+ overCountWages=totalWages.multiply(new BigDecimal(team.length));
|
|
|
|
+ overWorkingHours=totalWorkingHours.multiply(new BigDecimal(team.length));
|
|
|
|
+ List<ProdProcedureTeam> procedureTeamList = prodProcedureTeamService.list(new QueryWrapper<ProdProcedureTeam>().eq("plan_procedure_id",planProcedureTotal.getId()));
|
|
|
|
+ for (int i = 0; i < team.length; i++) {
|
|
ProdProcedureTeam prodProcedureTeam=new ProdProcedureTeam();
|
|
ProdProcedureTeam prodProcedureTeam=new ProdProcedureTeam();
|
|
prodProcedureTeam.setCompanyId(companyId);
|
|
prodProcedureTeam.setCompanyId(companyId);
|
|
- prodProcedureTeam.setProdProcedureId(planProcedureTotal.getProdProcedureId());
|
|
|
|
- prodProcedureTeam.setUserId(s);
|
|
|
|
- prodProcedureTeam.setPlanId(planProcedureTotal.getPlanId());
|
|
|
|
- prodProcedureTeam.setWorkTime(totalWorkingHours.doubleValue());
|
|
|
|
- prodProcedureTeam.setJobOfMoney(totalWages);
|
|
|
|
|
|
+ prodProcedureTeam.setPlanProcedureId(planProcedureTotal.getId());
|
|
|
|
+ prodProcedureTeam.setUserId(team[i]);
|
|
|
|
+ int finalI = i;
|
|
|
|
+ Optional<ProdProcedureTeam> first = procedureTeamList.stream().filter(pl -> pl.getUserId().equals(team[finalI])).findFirst();
|
|
|
|
+ if(first.isPresent()){
|
|
|
|
+ Integer cut = reportMapper.selectCount(new QueryWrapper<Report>().eq("user_procedure_team_id", first.get().getId()));
|
|
|
|
+ if(cut>0){
|
|
|
|
+ prodProcedureTeam.setId(first.get().getId());
|
|
|
|
+ }else {
|
|
|
|
+ prodProcedureTeamService.remove(new QueryWrapper<ProdProcedureTeam>().eq("plan_procedure_id",planProcedureTotal.getId()).eq("user_id",team[i]));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(i==team.length-1){
|
|
|
|
+ double wagesAbs =new BigDecimal(planProcedureTotal.getTotalWages()).subtract(overCountWages).doubleValue();
|
|
|
|
+ double workTimesAbs =new BigDecimal(planProcedureTotal.getTotalWorkingHours()).subtract(overWorkingHours).doubleValue();
|
|
|
|
+ prodProcedureTeam.setWorkTime(totalWorkingHours.add(new BigDecimal(workTimesAbs)).doubleValue());
|
|
|
|
+ prodProcedureTeam.setJobOfMoney(totalWages.add(new BigDecimal(wagesAbs)));
|
|
|
|
+ }else {
|
|
|
|
+ prodProcedureTeam.setWorkTime(totalWorkingHours.doubleValue());
|
|
|
|
+ prodProcedureTeam.setJobOfMoney(totalWages);
|
|
|
|
+ }
|
|
list.add(prodProcedureTeam);
|
|
list.add(prodProcedureTeam);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if(!prodProcedureTeamService.saveBatch(list)){
|
|
|
|
|
|
+ if(!prodProcedureTeamService.saveOrUpdateBatch(list)){
|
|
msg.setError("验证失败");
|
|
msg.setError("验证失败");
|
|
}
|
|
}
|
|
return msg;
|
|
return msg;
|
|
@@ -670,11 +694,17 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
|
|
case 0:
|
|
case 0:
|
|
List<PlanProcedureTotal> procedureTotals = planProcedureTotalService.list(new QueryWrapper<PlanProcedureTotal>().eq("plan_id", plan.getId()));
|
|
List<PlanProcedureTotal> procedureTotals = planProcedureTotalService.list(new QueryWrapper<PlanProcedureTotal>().eq("plan_id", plan.getId()));
|
|
List<ProdProcedure> prodProcedureList = prodProcedureMapper.selectList(new QueryWrapper<ProdProcedure>().eq("product_id", plan.getProductId()).eq("version_number",plan.getVersionNumber()));
|
|
List<ProdProcedure> prodProcedureList = prodProcedureMapper.selectList(new QueryWrapper<ProdProcedure>().eq("product_id", plan.getProductId()).eq("version_number",plan.getVersionNumber()));
|
|
|
|
+ List<Integer> ids = procedureTotals.stream().map(PlanProcedureTotal::getId).collect(Collectors.toList());
|
|
|
|
+ ids.add(-1);
|
|
|
|
+ List<ProdProcedureTeam> procedureTeams = prodProcedureTeamService.list(new QueryWrapper<ProdProcedureTeam>().in("plan_procedure_id", ids));
|
|
procedureTotals.forEach(ps->{
|
|
procedureTotals.forEach(ps->{
|
|
Optional<ProdProcedure> first = prodProcedureList.stream().filter(pl -> pl.getId().equals(ps.getProdProcedureId())).findFirst();
|
|
Optional<ProdProcedure> first = prodProcedureList.stream().filter(pl -> pl.getId().equals(ps.getProdProcedureId())).findFirst();
|
|
if(first.isPresent()){
|
|
if(first.isPresent()){
|
|
ps.setProdProcedure(first.get());
|
|
ps.setProdProcedure(first.get());
|
|
}
|
|
}
|
|
|
|
+ if(procedureTeams.size()>0){
|
|
|
|
+ ps.setTeamIds(procedureTeams.stream().filter(pt->pt.getPlanProcedureId().equals(ps.getId())).map(ProdProcedureTeam::getUserId).distinct().collect(Collectors.joining(",")));
|
|
|
|
+ }
|
|
});
|
|
});
|
|
msg.setData(procedureTotals);
|
|
msg.setData(procedureTotals);
|
|
break;
|
|
break;
|