|
@@ -91,6 +91,10 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
@Resource
|
|
|
StagesMapper stagesMapper;
|
|
|
@Resource
|
|
|
+ ProjectBasecostSettingMapper projectBasecostSettingMapper;
|
|
|
+ @Resource
|
|
|
+ ProjectCurrentcostMapper projectCurrentcostMapper;
|
|
|
+ @Resource
|
|
|
FinanceMapper financeMapper;
|
|
|
@Resource
|
|
|
TaskGroupMapper taskGroupMapper;
|
|
@@ -1882,7 +1886,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
//处理子项目
|
|
|
if (subNameCell != null) {
|
|
|
//兼容中英文逗号
|
|
|
- String[] subNames = subNameCell.getStringCellValue().trim().split(",|,");
|
|
|
+ String[] subNames = subNameCell.getStringCellValue().trim().split(",|\\,");
|
|
|
if (subNames != null) {
|
|
|
for (String s : subNames) {
|
|
|
if (!StringUtils.isEmpty(s)) {
|
|
@@ -2236,6 +2240,158 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg addBatchAccoDegrees(String ids, String associateDegrees, String associateDegreeNames, HttpServletRequest request) {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ if (!StringUtils.isEmpty(ids)) {
|
|
|
+ List<Integer> array = JSONArray.parseArray(ids, Integer.class);
|
|
|
+ if (array.size() > 0) {
|
|
|
+ List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().in("id", array));
|
|
|
+ List<Project> proUpdateList = new ArrayList<>();
|
|
|
+ for (Project project : projectList) {
|
|
|
+ String degreeIds = project.getAssociateDegrees();
|
|
|
+ String degreeNames = project.getAssociateDegreeNames();
|
|
|
+ List<String> newIdDataList = new ArrayList<>();
|
|
|
+ List<String> newNameDataList = new ArrayList<>();
|
|
|
+ String[] newIdsArr = associateDegrees.split("\\,");
|
|
|
+ String[] newNamesArr = associateDegreeNames.split("\\,");
|
|
|
+ for (int i=0;i<newIdsArr.length; i++) {
|
|
|
+ String newId = newIdsArr[i];
|
|
|
+ String newName = newNamesArr[i];
|
|
|
+ boolean find = false;
|
|
|
+ if (newId.length() > 0) {
|
|
|
+ if (!StringUtils.isEmpty(degreeIds)) {
|
|
|
+ String[] idArr = degreeIds.split("\\,");
|
|
|
+ for (String oldId : idArr) {
|
|
|
+ if (oldId.equals(newId)) {
|
|
|
+ find = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!find) {
|
|
|
+ //原来没有的,需要加上去
|
|
|
+ newIdDataList.add(newId);
|
|
|
+ newNameDataList.add(newName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (newIdDataList.size() > 0) {
|
|
|
+ degreeIds = degreeIds + "," + newIdDataList.stream().collect(Collectors.joining(","));
|
|
|
+ degreeNames = degreeNames + "," +newNameDataList.stream().collect(Collectors.joining(","));
|
|
|
+ Project updateP = new Project();
|
|
|
+ updateP.setId(project.getId());
|
|
|
+ updateP.setAssociateDegrees(degreeIds);
|
|
|
+ updateP.setAssociateDegreeNames(degreeNames);
|
|
|
+ proUpdateList.add(updateP);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (proUpdateList.size() > 0) {
|
|
|
+ updateBatchById(proUpdateList);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ msg.setError("项目不能为空");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ msg.setError("项目不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg getBaseCostAndRealCost(Integer pageIndex, Integer pageSize, HttpServletRequest request) {
|
|
|
+ User user = userMapper.selectById(request.getHeader("Token"));
|
|
|
+ Integer companyId = user.getCompanyId();
|
|
|
+ //撤销的项目不算
|
|
|
+ QueryWrapper<Project> queryWrapper = new QueryWrapper<Project>().eq("company_id", companyId);
|
|
|
+ queryWrapper.and(wrapper->wrapper.isNull("status").or().ne("status", 3));
|
|
|
+ int total = projectMapper.selectCount(queryWrapper);
|
|
|
+ int pageStart = (pageIndex -1) * pageSize;
|
|
|
+ List projectList = projectMapper.getBaseCostAndRealCost(companyId, pageStart, pageSize);
|
|
|
+ //查询项目的各个成本项实际的成本
|
|
|
+ List<Integer> pids = new ArrayList<>();
|
|
|
+ for (int i=0;i<projectList.size(); i++) {
|
|
|
+ HashMap map = (HashMap)projectList.get(i);
|
|
|
+ pids.add((Integer)map.get("id"));
|
|
|
+ }
|
|
|
+ //列
|
|
|
+ List<ProjectBasecostSetting> settingList = projectBasecostSettingMapper.selectList(new QueryWrapper<ProjectBasecostSetting>().eq("company_id", companyId).eq("alarm_type", 1));
|
|
|
+
|
|
|
+ HashMap map = new HashMap();
|
|
|
+ map.put("columns", settingList);
|
|
|
+ if (pids.size() > 0) {
|
|
|
+ List<ProjectCurrentcost> currentcostList = projectCurrentcostMapper.selectList(new QueryWrapper<ProjectCurrentcost>().in("project_id", pids));
|
|
|
+ List realCostData = reportMapper.getProjectCost(companyId, pids);
|
|
|
+ for (int i=0;i<projectList.size(); i++) {
|
|
|
+ HashMap item = (HashMap)projectList.get(i);
|
|
|
+ int pid = (Integer)item.get("id");
|
|
|
+ item.put("curcostList", currentcostList.stream().filter(cur->cur.getProjectId() == pid));
|
|
|
+ List proRealCost = new ArrayList();
|
|
|
+ for (int m=0;m<realCostData.size(); m++) {
|
|
|
+ HashMap realCostItem = (HashMap)realCostData.get(m);
|
|
|
+ if ((int)realCostItem.get("projectId") == pid) {
|
|
|
+ proRealCost.add(realCostItem);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ item.put("realcostList", proRealCost);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
+ map.put("records", projectList);
|
|
|
+ map.put("total", total);
|
|
|
+ httpRespMsg.data = map;
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg exportBaseCostAndRealCost(HttpServletRequest request) {
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
+ //通过公司id获取该公司所有的项目列表
|
|
|
+ User user = userMapper.selectById(request.getHeader("Token"));
|
|
|
+ Integer companyId = user.getCompanyId();
|
|
|
+
|
|
|
+ List<HashMap> projectList = projectMapper.getBaseCostAndRealCost(companyId, null, null);
|
|
|
+ List<List<String>> exportList = new ArrayList<>();
|
|
|
+ String[] titles = {"项目编号", "项目名称", "当前总预算", "已发生总工时成本"};
|
|
|
+ ArrayList<String> headList = Lists.list(titles);
|
|
|
+ //列,根据定义的工时预警类型的成本项来
|
|
|
+ List<ProjectBasecostSetting> settingList = projectBasecostSettingMapper.selectList(new QueryWrapper<ProjectBasecostSetting>().eq("company_id", companyId).eq("alarm_type", 1));
|
|
|
+ for (ProjectBasecostSetting setting : settingList) {
|
|
|
+ headList.add(setting.getName()+"成本预算");
|
|
|
+ headList.add(setting.getName()+"已发生成本");
|
|
|
+ headList.add(setting.getName()+"已发生占比");
|
|
|
+ }
|
|
|
+ exportList.add(headList);
|
|
|
+ for (HashMap project : projectList) {
|
|
|
+ List<String> data = new ArrayList<>();
|
|
|
+ data.add((String)project.get("projectCode"));
|
|
|
+ data.add((String)project.get("projectName"));
|
|
|
+ data.add(project.get("baseCurcost") != null?project.get("baseCurcost").toString():"");
|
|
|
+ data.add(""+project.get("freeMan"));
|
|
|
+// data.add(project.getFeeNormal().toString());
|
|
|
+// data.add(project.getFeeTravel().toString());
|
|
|
+// data.add(project.getFeeOutsourcing().toString());
|
|
|
+// double totalFee = project.getFeeMan() + project.getFeeNormal()+ project.getFeeTravel()+ project.getFeeOutsourcing();
|
|
|
+// data.add(totalFee+"");
|
|
|
+// if (project.getContractAmount() != null && project.getContractAmount() > 0) {
|
|
|
+// double profitAmt = project.getContractAmount() - totalFee;
|
|
|
+// data.add(profitAmt+"");
|
|
|
+// data.add(new java.text.DecimalFormat("#.0").format((100*profitAmt/project.getContractAmount()))+"%");
|
|
|
+// } else {
|
|
|
+// double profitAmt = -totalFee;
|
|
|
+// data.add(profitAmt+"");
|
|
|
+// data.add("");
|
|
|
+// }
|
|
|
+ exportList.add(data);
|
|
|
+ }
|
|
|
+ String fileName = "工时成本预警表_"+System.currentTimeMillis();
|
|
|
+ ExcelUtil.exportGeneralExcelByTitleAndList(fileName, exportList, path);
|
|
|
+ httpRespMsg.data = pathPrefix + fileName+".xls";
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private List<Department> getSubDepts(Department dp, List<Department> list) {
|
|
|
List<Department> collect = list.stream().filter(l -> dp.getDepartmentId().equals(l.getSuperiorId())).collect(Collectors.toList());;
|