Min il y a 1 an
Parent
commit
e75a672425

+ 83 - 15
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -4778,7 +4778,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             //凑整件数
             Integer rounding=0;
             //拆算件数
-            BigDecimal converted=new BigDecimal(0);
+            BigDecimal convertedTime=new BigDecimal(0);
+            BigDecimal convertedCost=new BigDecimal(0);
             //找到产品下的工序
             List<ProdProcedure> targetProdProcedures = prodProcedureList.stream().filter(p -> p.getProductId().equals(product.getId())).collect(Collectors.toList());
             //过滤工序id 作为完整件数 需要路过的全部工序
@@ -4903,19 +4904,28 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 //过滤日报所填了哪些工序
                 List<Integer> hasReportProdProduceIds = hasReportList.stream().map(Report::getProdProcedureId).collect(Collectors.toList());
                 //计算当前产品的总预算工时
-                BigDecimal reduce = targetProdProcedures.stream().map(i -> new BigDecimal(i.getWorkingTime())).reduce(BigDecimal.ZERO, BigDecimal::add);
+                BigDecimal reduceTime = targetProdProcedures.stream().map(i -> new BigDecimal(i.getWorkingTime())).reduce(BigDecimal.ZERO, BigDecimal::add);
+                BigDecimal reduceCost = targetProdProcedures.stream().map(i -> new BigDecimal(String.valueOf(i.getUnitPrice()))).reduce(BigDecimal.ZERO, BigDecimal::add);
                 //利用上面找到的所填了哪些工序 按照所在工序占比计算
                 List<ProdProcedure> hasReportProcedures = targetProdProcedures.stream().filter(ts -> hasReportProdProduceIds.contains(ts.getId())).collect(Collectors.toList());
-                BigDecimal bigDecimal=new BigDecimal(0);
+                BigDecimal bigDecimalTime=new BigDecimal(0);
+                BigDecimal bigDecimalCost=new BigDecimal(0);
                 for (ProdProcedure hasReportProcedure : hasReportProcedures) {
                     //找到当前工序所在产品总预算工时
-                    BigDecimal decimal = new BigDecimal(hasReportProcedure.getWorkingTime());
-                    BigDecimal divide = decimal.divide(reduce, 2,BigDecimal.ROUND_HALF_UP);
-                    BigDecimal check = new BigDecimal(1);
-                    check=check.multiply(divide).setScale(2,BigDecimal.ROUND_HALF_UP);
-                    bigDecimal=bigDecimal.add(check).setScale(2,BigDecimal.ROUND_HALF_UP);
+                    BigDecimal decimalTime = new BigDecimal(hasReportProcedure.getWorkingTime());
+                    BigDecimal divideTime = decimalTime.divide(reduceTime, 3,BigDecimal.ROUND_HALF_UP);
+                    BigDecimal checkTime = new BigDecimal(1);
+                    checkTime=checkTime.multiply(divideTime).setScale(3,BigDecimal.ROUND_HALF_UP);
+                    bigDecimalTime=bigDecimalTime.add(checkTime).setScale(3,BigDecimal.ROUND_HALF_UP);
+                    //找到当前工序所在产品总预算工时
+                    BigDecimal decimalCost = new BigDecimal(String.valueOf(hasReportProcedure.getUnitPrice()));
+                    BigDecimal divideCost = decimalCost.divide(reduceCost, 3,BigDecimal.ROUND_HALF_UP);
+                    BigDecimal checkCost = new BigDecimal(1);
+                    checkCost=checkCost.multiply(divideCost).setScale(3,BigDecimal.ROUND_HALF_UP);
+                    bigDecimalCost=bigDecimalCost.add(checkCost).setScale(3,BigDecimal.ROUND_HALF_UP);
                 }
-                converted=converted.add(bigDecimal);
+                convertedTime=convertedTime.add(bigDecimalTime);
+                convertedCost=convertedCost.add(bigDecimalCost);
             }
 
             //计算凑整件数
@@ -5008,13 +5018,17 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
 //            }
             resultMap.put("integratedSteelNums",integratedSteelNums);
             resultMap.put("roundingSteelNums",roundingSteelNums);
-            converted = converted.setScale(2, BigDecimal.ROUND_HALF_UP);
+            convertedTime = convertedTime.setScale(3, BigDecimal.ROUND_HALF_UP);
+            convertedCost = convertedCost.setScale(3, BigDecimal.ROUND_HALF_UP);
             resultMap.put("integrated",integrated);
             resultMap.put("rounding",rounding);
-            resultMap.put("converted",converted);
+            resultMap.put("convertedTime",convertedTime);
+            resultMap.put("convertedCost",convertedCost);
             BigDecimal bigDecimal=new BigDecimal(integrated);
-            bigDecimal=bigDecimal.add(new BigDecimal(rounding)).add(converted);
-            resultMap.put("total",bigDecimal.doubleValue());
+            BigDecimal bigDecimalTime=bigDecimal.add(new BigDecimal(rounding)).add(convertedTime);
+            BigDecimal bigDecimalCost=bigDecimal.add(new BigDecimal(rounding)).add(convertedCost);
+            resultMap.put("totalTime",bigDecimalTime.doubleValue());
+            resultMap.put("totalCost",bigDecimalCost.doubleValue());
             resultMapList.add(resultMap);
         }
         Map<String,Object> result=new HashMap<>();
@@ -5185,6 +5199,10 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 }
             }
             if(isViewUser){
+                BigDecimal arrangeTotalPlanCost=new BigDecimal(0);
+                BigDecimal arrangeTotalNowCost=new BigDecimal(0);
+                BigDecimal arrangeTotalPlanHour=new BigDecimal(0);
+                BigDecimal arrangeTotalNowHour=new BigDecimal(0);
                 for (String userId : userIdList) {
                     Map<String,Object> item=new HashMap<>();
                     item.put("startDate",date.replaceAll("-",""));
@@ -5204,13 +5222,32 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                     nowCost=nowCost.setScale(2,BigDecimal.ROUND_HALF_UP);
                     planHour=planHour.setScale(2,BigDecimal.ROUND_HALF_UP);
                     nowHour=nowHour.setScale(2,BigDecimal.ROUND_HALF_UP);
+                    arrangeTotalPlanCost=arrangeTotalPlanCost.add(planCost).setScale(2,BigDecimal.ROUND_HALF_UP);
+                    arrangeTotalNowCost=arrangeTotalNowCost.add(nowCost).setScale(2,BigDecimal.ROUND_HALF_UP);
+                    arrangeTotalPlanHour=arrangeTotalPlanHour.add(planHour).setScale(2,BigDecimal.ROUND_HALF_UP);
+                    arrangeTotalNowHour=arrangeTotalNowHour.add(nowHour).setScale(2,BigDecimal.ROUND_HALF_UP);
                     item.put("planCost",planCost.doubleValue());
                     item.put("nowCost",nowCost.doubleValue());
                     item.put("planHour",planHour.doubleValue());
                     item.put("nowHour",nowHour.doubleValue());
                     resultList.add(item);
                 }
+                //手动增加合计列 用于计算列合计数据
+                Map<String,Object> item=new HashMap<>();
+                item.put("startDate",date.replaceAll("-",""));
+                item.put("userId","0");
+                item.put("planCost",arrangeTotalPlanCost.doubleValue());
+                item.put("nowCost",arrangeTotalNowCost.doubleValue());
+                item.put("planHour",arrangeTotalPlanHour.doubleValue());
+                item.put("nowHour",arrangeTotalNowHour.doubleValue());
+                resultList.add(item);
             }else {
+                BigDecimal arrangeTotalPlanNum=new BigDecimal(0);
+                BigDecimal arrangeTotalNowNum=new BigDecimal(0);
+                BigDecimal arrangeTotalPlanCost=new BigDecimal(0);
+                BigDecimal arrangeTotalNowCost=new BigDecimal(0);
+                BigDecimal arrangeTotalPlanHour=new BigDecimal(0);
+                BigDecimal arrangeTotalNowHour=new BigDecimal(0);
                 for (Integer dept : deptIdList) {
                     Map<String,Object> item=new HashMap<>();
                     item.put("startDate",date.replaceAll("-",""));
@@ -5237,6 +5274,12 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                     nowCost=nowCost.setScale(2,BigDecimal.ROUND_HALF_UP);
                     planHour=planHour.setScale(2,BigDecimal.ROUND_HALF_UP);
                     nowHour=nowHour.setScale(2,BigDecimal.ROUND_HALF_UP);
+                    arrangeTotalPlanNum=arrangeTotalPlanNum.add(planNum).setScale(2,BigDecimal.ROUND_HALF_UP);
+                    arrangeTotalNowNum=arrangeTotalNowNum.add(nowNum).setScale(2,BigDecimal.ROUND_HALF_UP);
+                    arrangeTotalPlanCost=arrangeTotalPlanCost.add(planCost).setScale(2,BigDecimal.ROUND_HALF_UP);
+                    arrangeTotalNowCost=arrangeTotalNowCost.add(nowCost).setScale(2,BigDecimal.ROUND_HALF_UP);
+                    arrangeTotalPlanHour=arrangeTotalPlanHour.add(planHour).setScale(2,BigDecimal.ROUND_HALF_UP);
+                    arrangeTotalNowHour=arrangeTotalNowHour.add(nowHour).setScale(2,BigDecimal.ROUND_HALF_UP);
                     item.put("planNum",planNum.doubleValue());
                     item.put("nowNum",nowNum.doubleValue());
                     item.put("planCost",planCost.doubleValue());
@@ -5247,6 +5290,17 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                     item.put("progress",format.format(progress.doubleValue()));
                     resultList.add(item);
                 }
+                //手动增加合计列 用于计算列合计数据
+                Map<String,Object> item=new HashMap<>();
+                item.put("startDate",date.replaceAll("-",""));
+                item.put("deptId","0");
+                item.put("planNum",arrangeTotalPlanNum.doubleValue());
+                item.put("nowNum",arrangeTotalNowNum.doubleValue());
+                item.put("planCost",arrangeTotalPlanCost.doubleValue());
+                item.put("nowCost",arrangeTotalNowCost.doubleValue());
+                item.put("planHour",arrangeTotalPlanHour.doubleValue());
+                item.put("nowHour",arrangeTotalNowHour.doubleValue());
+                resultList.add(item);
             }
         }
         List<Map<String,Object>> lastList=new ArrayList<>();
@@ -5258,7 +5312,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 map.put("userList",maps);
                 map.put("userId",userId);
                 Optional<User> first = userList.stream().filter(u -> u.getId().equals(userId)).findFirst();
-                map.put("userName",first.isPresent()?first.get().getName():"");
+                map.put("userName",userId.equals("0")?"合计":first.isPresent()?first.get().getName():"");
                 BigDecimal totalPlanHour = new BigDecimal(0);
                 BigDecimal totalNowHour = new BigDecimal(0);
                 BigDecimal totalPlanCost = new BigDecimal(0);
@@ -5283,7 +5337,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             List<String> deptIdList = resultList.stream().map(r -> String.valueOf(r.get("deptId"))).distinct().collect(Collectors.toList());
             for (String dept : deptIdList) {
                 Map<String,Object> map=new HashMap<>();
-                map.put("departmentCascade",convertDepartmentIdToCascade(Integer.valueOf(dept),departmentList));
+                map.put("departmentCascade",dept.equals("0")?"合计":convertDepartmentIdToCascade(Integer.valueOf(dept),departmentList));
                 List<Map<String, Object>> maps = resultList.stream().filter(r -> String.valueOf(r.get("deptId")).equals(dept)).collect(Collectors.toList());
                 map.put("deptList",maps);
                 map.put("deptId",dept);
@@ -5318,6 +5372,20 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 lastList.add(map);
             }
         }
+        List<Map<String, Object>> list;
+        List<Map<String, Object>> list1;
+        if(isViewUser){
+            list = lastList.stream().filter(l -> !String.valueOf(l.get("userId")).equals("0")).collect(Collectors.toList());
+            list1 = lastList.stream().filter(l -> String.valueOf(l.get("userId")).equals("0")).collect(Collectors.toList());
+
+        }else {
+            list = lastList.stream().filter(l -> !String.valueOf(l.get("deptId")).equals("0")).collect(Collectors.toList());
+            list1 = lastList.stream().filter(l -> String.valueOf(l.get("deptId")).equals("0")).collect(Collectors.toList());
+        }
+        if(list1.size()>0){
+            list.add(list1.get(0));
+        }
+        lastList=list;
 
         if(stationId!=null){
             lastList=lastList.stream().filter(l->Integer.valueOf(String.valueOf(l.get("deptId"))).equals(stationId)).collect(Collectors.toList());

+ 5 - 5
fhKeeper/formulahousekeeper/management-workshop/src/main/resources/mapper/ReportMapper.xml

@@ -155,10 +155,11 @@
     <select id="getPersonWorkHoursWagesDetail" resultType="java.util.Map">
         select r.cost,r.working_time,r.finish_num, r.creator_id,ppt.total_progress as progress,DATE_FORMAT(r.create_date,'%Y%m%d') as createDate,pp.name as procedureName,(case  when pp.check_type=0 then '自检' when pp.check_type=1 then '互检' else '专检' end) as checkType,
         p.name as productName,DATE_FORMAT(plan.start_date,'%Y%m%d') as planStartDate,DATE_FORMAT(plan.end_date,'%Y%m%d') as planEndDate ,
-        plan.task_change_notice_num as taskName,plan.plan_type as planType,u.name as checkerName,u2.name as creatorName,plan.product_scheduling_num
+        plan.task_change_notice_num as taskName,plan.plan_type as planType,u.name as checkerName,u2.name as creatorName,plan.product_scheduling_num,r.finish_num as finishNum
         from report r
+        left join prod_procedure_team ppt2 on r.user_procedure_team_id=ppt2.id
         left join prod_procedure pp on r.prod_procedure_id=pp.id
-        left join plan_procedure_total ppt on ppt.prod_procedure_id=pp.id
+        left join plan_procedure_total ppt on ppt.id=ppt2.plan_procedure_id
         left join product p on p.id=r.product_id
         left join plan on plan.id=r.plan_id
         left join user u on r.checker_id=u.id
@@ -180,7 +181,6 @@
         <if test="startDate!=null and endDate!=null">
             and r.create_date between #{startDate} and #{endDate}
         </if>
-        group by r.id
     </select>
 
     <select id="getProcedureRealTimeProgressList" resultType="java.util.Map">
@@ -321,7 +321,7 @@
         left join user u on u.id=b.station_id
         where b.company_id=#{companyId}
         <if test="userId!=null and userId!=''">
-            and d.user_id=#{userId}
+            and b.foreman_id=#{userId}
         </if>
         <if test="deptId!=null and deptId!=''">
             and b.station_id=#{deptId}
@@ -356,7 +356,7 @@
         left join user u on u.id=b.station_id
         where b.company_id=#{companyId}
         <if test="userId!=null and userId!=''">
-            and d.user_id=#{userId}
+            and b.foreman_id=#{userId}
         </if>
         <if test="deptId!=null and deptId!=''">
             and b.station_id=#{deptId}

+ 16 - 9
fhKeeper/formulahousekeeper/timesheet-workshop/src/views/statistic/index.vue

@@ -145,7 +145,7 @@
                 <el-table-column align="center" prop="taskName" label="排产工单号" min-width="150">
                   <template slot-scope="scope">{{scope.row.taskName}}</template>
                 </el-table-column>
-                <el-table-column align="center" prop="statinoName" label="工位" min-width="250"></el-table-column>
+                <el-table-column align="center" prop="userName" label="工长" min-width="250"></el-table-column>
                 <el-table-column align="center" prop="planNum" label="计划件数" min-width="150">
                   <template slot-scope="scope">{{scope.row.planNum}}</template>
                 </el-table-column>
@@ -192,11 +192,17 @@
                 <el-table-column align="center" prop="rounding" label="凑整件数" min-width="150">
                   <template slot-scope="scope">{{scope.row.rounding}}</template>
                 </el-table-column>
-                <el-table-column align="center" prop="converted" label="折算件数" min-width="150">
-                  <template slot-scope="scope">{{scope.row.converted}}</template>
+                <el-table-column align="center" prop="convertedTime" label="工时折算件数" min-width="150">
+                  <template slot-scope="scope">{{scope.row.convertedTime}}</template>
+                </el-table-column>
+                <el-table-column align="center" prop="convertedCost" label="工价折算件数" min-width="150">
+                  <template slot-scope="scope">{{scope.row.convertedCost}}</template>
+                </el-table-column>
+                <el-table-column align="center" prop="totalTime" label="工时总件数" min-width="150">
+                  <template slot-scope="scope">{{scope.row.totalTime}}</template>
                 </el-table-column>
-                <el-table-column align="center" prop="total" label="总件数" min-width="150">
-                  <template slot-scope="scope">{{scope.row.total}}</template>
+                <el-table-column align="center" prop="totalCost" label="工价总件数" min-width="150">
+                  <template slot-scope="scope">{{scope.row.totalCost}}</template>
                 </el-table-column>
             </el-table>
 
@@ -204,7 +210,8 @@
             <el-table v-if="ins == 6"  key="7" border :data="planDataWithStationDatas" highlight-current-row v-loading="listLoading" :height="+tableHeight - 1" style="width: 100%;">
                 <el-table-column v-if="!isViewUser" align="center" prop="departmentCascade" label="部门名称"   min-width="150"  fixed="left">
                   <template slot-scope="scope">
-                    <span class="colorText" @click="getPlanDataWithStation(scope.row.deptId)" >{{scope.row.departmentCascade}}</span>
+                    <span v-if="scope.row.deptId!='0'" class="colorText" @click="getPlanDataWithStation(scope.row.deptId)" >{{scope.row.departmentCascade}}</span>
+                    <span v-else class="colorText" >{{scope.row.departmentCascade}}</span>
                     <!-- <span class="colorText" >{{scope.row.departmentCascade}}</span> -->
                   </template>
                 </el-table-column>
@@ -237,7 +244,7 @@
             </el-table>
 
         <!--工具条-->
-        <el-col :span="24" class="toolbar" v-if="ins != 7">
+        <el-col :span="24" class="toolbar" v-if="ins != 6">
           <el-pagination
                 v-if="ins == 12"
                 @size-change="groupSizeChange"
@@ -322,9 +329,9 @@
               <el-table-column prop="productName" label="产品名称" width="180"></el-table-column>
               <el-table-column prop="product_scheduling_num" label="排产工单号" width="180"></el-table-column>
               <el-table-column prop="procedureName" label="工序名称" width="180"></el-table-column>
-              <el-table-column prop="progress" label="进度" width="80">
+              <el-table-column prop="finishNum" label="完成件数" width="80">
                 <template slot-scope="scope">
-                  {{scope.row.progress?scope.row.progress:0}}%
+                  {{scope.row.finishNum?scope.row.finishNum:0}}
                 </template>
               </el-table-column>
               <el-table-column prop="cost" label="工钱" width="80"></el-table-column>