Преглед на файлове

Merge branch 'master' of http://47.100.37.243:10191/wutt/manHourHousekeeper

Min преди 1 година
родител
ревизия
e4b1202eb3

+ 13 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ExcelExportServiceImpl.java

@@ -20,6 +20,7 @@ import org.springframework.transaction.annotation.Transactional;
 import javax.annotation.Resource;
 import java.io.File;
 import java.io.FileOutputStream;
+import java.time.LocalDateTime;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -81,14 +82,22 @@ public class ExcelExportServiceImpl implements ExcelExportService {
              * 异步上传转译文件的任务完成时会触发回调,在WeiXinCorpController中的commonDevCallbackPost实现了对回调的处理,存储到corpwxJobResult表中
              * 此处轮询查询本地数据库,检测到有任务的回调数据时继续执行查询操作
              */
-            while (i < 10) {
-                Thread.sleep(300);
+            long t = System.currentTimeMillis();
+            while (i < 30) {
+                if (i < 10) {
+                    Thread.sleep(300);
+                } else {
+                    Thread.sleep(1000);
+                }
+                System.out.println("i=="+i+", "+LocalDateTime.now());
                 CorpwxJobResult corpwxJobResult = corpwxJobCenter.get(jobId);
                 if (corpwxJobResult != null) {
                     if (corpwxJobResult.getErrCode() == 0) {
                         syncTranslationResult = wxCorpInfoService.getSyncTranslationResult(jobId);
                         corpwxJobCenter.remove(jobId);
                     } else {
+                        long t2 = System.currentTimeMillis();
+                        System.out.println("222企业微信转译报错:"+corpwxJobResult.getErrMsg()+",耗时:" + (t2 - t) + "ms");
                         httpRespMsg.setError(corpwxJobResult.getErrMsg());
                         return httpRespMsg;
                     }
@@ -97,6 +106,8 @@ public class ExcelExportServiceImpl implements ExcelExportService {
                 i++;
             }
             if (syncTranslationResult != null) {
+                long t2 = System.currentTimeMillis();
+                System.out.println("企业微信转译文件后地址是:"+syncTranslationResult+",耗时:" + (t2 - t) + "ms");
                 httpRespMsg.data = syncTranslationResult;
             } else {
                 //httpRespMsg.setError("处理超时...");

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

@@ -5062,6 +5062,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
     public HttpRespMsg exportReport(@RequestParam String startDate, @RequestParam String endDate, Integer projectId,Integer stateKey,Integer departmentId, HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         DateFormat timeDf = new SimpleDateFormat("yyyy-MM-dd");
+        long t0 = System.currentTimeMillis();
+        long fetchDataTime = 0;
         try {
             String userId = request.getHeader("Token");
             User user = userMapper.selectById(userId);
@@ -5071,6 +5073,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             Integer companyId = company.getId();
             List<UserCustom> userCustomList = userCustomMapper.selectList(new QueryWrapper<UserCustom>().eq("company_id", companyId));
             WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", companyId));
+            boolean needCorpWxTranslate = (wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1);
             SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
             List<List<String>> dataList=new ArrayList<>();
             List<String> titles = new ArrayList<String>();
@@ -5172,6 +5175,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             List<SysRichFunction> functionList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看全公司工时");
             //获取部门的所有子部门
             List<Department> departments = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id",companyId));
+            Department[] deptArray = departments.toArray(new Department[0]);
             List<Integer> branchDepartment = null;
             if(departmentId != null){
                 branchDepartment = departmentService.getBranchDepartment(departmentId,departments);
@@ -5223,11 +5227,15 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             }
             else {
                 //看公司所有人的
+                long t1 = System.currentTimeMillis();
                 if (timeType.getShowFillauditTime() == 1) {
                     allReportByDate = reportMapper.getAllReportByDateWithReportLog(startDate, user.getCompanyId(), null, endDate, projectId,stateKey,branchDepartment);
                 } else {
                     allReportByDate = reportMapper.getAllReportByDate(startDate, user.getCompanyId(), null, endDate, projectId,stateKey,branchDepartment);
                 }
+                long t2 = System.currentTimeMillis();
+                fetchDataTime = (t2-t1);
+                System.out.println("查数据库耗时:"+(t2-t1)/1000+"s");
             }
             //获取企业微信考勤数据
             List<UserCorpwxTime> userCorpwxTimeList = new ArrayList<>();
@@ -5309,9 +5317,9 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 }
             }
             List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
-            long t1 = System.currentTimeMillis();
             DateTimeFormatter dft = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
             for (Map<String, Object> map : allReportByDate) {
+                long p1 = System.currentTimeMillis();
                 List<String> item=new ArrayList<>();
                 item.add(String.valueOf(rowNum));
                 item.add((String) map.get("jobNumber"));
@@ -5332,20 +5340,22 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                     item.add(value);
                 }
                 Department dept = null;
-                for (Department department : departments) {
-                    if (map.containsKey("departmentId") && department.getDepartmentId().toString().equals(map.get("departmentId").toString())){
-                        dept = department;
-                        break;
+                Department targetDept = new Department();
+                if (map.get("departmentId") != null) {
+                    targetDept.setDepartmentId(Integer.valueOf(map.get("departmentId").toString()));
+                    int index = Arrays.binarySearch(deptArray, targetDept, Comparator.comparing(Department::getDepartmentId));
+                    if (index >= 0) {
+                        dept = deptArray[index];
                     }
                 }
-                if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+
+                if(needCorpWxTranslate){
                     item.add("$userName="+(map.get("corpwxUserId")==null?"":map.get("corpwxUserId"))+"$");
                     item.add(departmentService.exportWxDepartment(dept,departments));
                 }else {
                     item.add((String) map.get("name"));
                     item.add(departmentService.getSupDepartment(dept,departments));
                 }
-
                 item.add((String) map.get("projectCode"));
                 item.add((String) map.get("project"));
                 if(companyId==936){
@@ -5408,13 +5418,13 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 }
                 if (timeType.getShowFillauditTime() == 1) {
                     item.add(sdf.format((Date)map.get("time")));
-                    if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                    if(needCorpWxTranslate){
                         String projectAuditorName ="$userName="+String.valueOf(map.get("projectAuditorCorpwxUserId"))+"$";
                         item.add(projectAuditorName);
                     }else {
                         item.add((String)map.get("projectAuditorName"));
                     }
-                    if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                    if(needCorpWxTranslate){
                         String projectManagerName ="$userName="+String.valueOf(map.get("projectManagerCorpwxUserId"))+"$";
                         item.add(projectManagerName);
                     }else {
@@ -5446,7 +5456,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                             }
                             String time = dtf.format(operateDate);
                             String msg= "";
-                            if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                            if(needCorpWxTranslate){
                                 Optional<User> first = userList.stream().filter(ul -> ul.getId().equals(audit.getOperatorId())).findFirst();
                                 if(first.isPresent()){
                                     if(audit.getMsg().contains("提交了")){
@@ -5476,7 +5486,6 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                     }
                     item.add(sb.toString());
                 }
-                item.add((String) map.get("content"));
                 if(stateKey==1){
                     Integer state = (Integer) map.get("state");
                     switch (state){
@@ -5517,7 +5526,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                             String departmentName = map.get("departmentName") + "";
                             for (User userItem : userList) {
                                 if (userItem.getId().equals(deptAuditorId)){
-                                    if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                                    if(needCorpWxTranslate){
                                         String deptAuditorName ="$userName="+ userItem.getCorpwxRealUserid() +"$";
                                         departmentName = "$departmentName=" + departmentName + "$";
                                         if(timeType.getReportAuditType()==4){
@@ -5534,18 +5543,16 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                                         }else {
                                             item.add("待" + departmentName + "(" + userItem.getName() + ")审核");
                                         }
-
                                     }
                                     break;
                                 }
-
                             }
                         }else {
                             //项目审核或分组审核
                             if (String.valueOf(map.get("projectAuditState")).equals("0") || String.valueOf(map.get("groupAuditState")).equals("0")){
                                 String projectAuditorName = map.get("projectAuditorName")+"";
                                 String projectAuditorId = map.get("projectAuditorId")+"";
-                                if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                                if(needCorpWxTranslate){
                                     for (User userItem : userList) {
                                         if (userItem.getId().equals(projectAuditorId)){
                                             projectAuditorName ="$userName="+ userItem.getCorpwxUserid() +"$";

+ 1 - 0
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/service/impl/PlanProcedureTotalServiceImpl.java

@@ -191,6 +191,7 @@ public class PlanProcedureTotalServiceImpl extends ServiceImpl<PlanProcedureTota
             List<String> filledSteelNumList=new ArrayList<>();
 
             for (Report report : reportList) {
+                System.out.println("report.getCreateDate() = " + report.getCreateDate()+", "+report.getSteelNumArray());
                 //自己当天填的不算
                 if(dtf.format(report.getCreateDate()).equals(createDate)&&report.getCreatorId().equals(token)){
                     continue;

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

@@ -139,16 +139,19 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
         User user = userMapper.selectById(token);
         Integer companyId = user.getCompanyId();
         report.setCreatorId(token);
-        LocalDate today = LocalDate.now();
-        LocalDate targetDate = null;
-        if (report.getId() == null) {
-            report.setCreateDate(today);
-            targetDate = today;
-        } else {
-            Report report1 = reportMapper.selectById(report.getId());
-            targetDate = report1.getCreateDate();
-            report.setCreateDate(report1.getCreateDate());
+        if (report.getFinishNum() == null) {
+            report.setFinishNum(0.0);
         }
+//        LocalDate today = LocalDate.now();
+        LocalDate targetDate = report.getCreateDate();
+//        if (report.getId() == null) {
+//            report.setCreateDate(today);
+//            targetDate = today;
+//        } else {
+//            Report report1 = reportMapper.selectById(report.getId());
+//            targetDate = report1.getCreateDate();
+//            report.setCreateDate(report1.getCreateDate());
+//        }
         report.setCompanyId(companyId);
 
         Plan plan = planMapper.selectById(report.getPlanId());
@@ -255,6 +258,20 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
         planProcedureTotal.setTotalFillTime(workingTime);
         planProcedureTotal.setTotalProgress((int)(workingTime / planProcedureTotal.getTotalWorkingHours()) * 100);
         planProcedureTotalMapper.updateById(planProcedureTotal);
+        //检查该计划下的所有工序是否都已经完成
+        List<PlanProcedureTotal> planProcedureTotalList = planProcedureTotalMapper.selectList(new QueryWrapper<PlanProcedureTotal>().eq("plan_id", planProcedureTotal.getPlanId()));
+        boolean isAllFinish = true;
+        for (PlanProcedureTotal p : planProcedureTotalList) {
+            if (p.getTotalProgress() == null || p.getTotalProgress() < 100) {
+                isAllFinish = false;
+                break;
+            }
+        }
+        if (isAllFinish) {
+            //该计划下的所有工序都已经完成了,那么该计划就是完成状态
+            plan.setRealEndDate(LocalDate.now());
+            planMapper.updateById(plan);
+        }
         return httpRespMsg;
     }
 

+ 40 - 12
fhKeeper/formulahousekeeper/timesheet-workshop-h5/src/views/workView/fillReport.vue

@@ -1,11 +1,17 @@
 <template>
   <div class="distribution">
     <van-nav-bar title="报工" left-text="返回" @click-left="back" fixed left-arrow />
-    <div class="distribution_header">
+    <van-cell title="报工日期" :value="reportDate" @click="reportDateShow = true" is-link>
+    </van-cell>
+    <van-cell title="产品名称" :value="reportForm.product_name"></van-cell>
+    <van-cell :title="reportForm.plan_type == 0?'排产工单号':'任务变更通知号'" :value="reportForm.plan_type == 0 ? reportForm.product_scheduling_num : reportForm.task_change_notice_num"></van-cell>
+    <van-cell title="计划工期" :value="reportForm.start_date+'至'+(reportForm.end_date==null?' ':reportForm.end_date)"></van-cell>
+    <!-- <div class="distribution_header">
+      
       <div>{{ reportForm.product_name }}<span style="float:right;color:#20a0ff;">{{reportDate  }}</span> </div>
       <div>{{ reportForm.plan_type == 0 ? reportForm.product_scheduling_num : reportForm.task_change_notice_num }}</div>
       <div>{{ reportForm.start_date }}至{{ reportForm.end_date }}</div>
-    </div>
+    </div> -->
     <div class="distribution_con">
       <van-form @submit="onSubmit">
         <van-cell-group inset>
@@ -48,8 +54,7 @@
           </van-cell>
         </van-cell-group>
         <div style="margin: 16px;">
-          <van-button round block type="primary" native-type="submit" :loading="saving"
-            :disabled="reportForm.finishNum == 0">
+          <van-button round block type="primary" native-type="submit" :loading="saving">
             提交
           </van-button>
           <p v-if="reportForm.canBeDeleted" @click="deleteReport" style="margin:16px;text-align:center;color:#666;">删除</p>
@@ -68,6 +73,8 @@
         </template>
       </van-picker>
     </van-popup>
+    <!-- 日期 -->
+    <van-calendar v-model="reportDateShow" :min-date="minDate" @confirm="reportDateOnConfirm" />
   </div>
 </template>
 
@@ -78,6 +85,8 @@ export default {
   },
   data() {
     return {
+      minDate: new Date(2023, 0, 1),
+      reportDateShow: false,
       reportId: null,
       reportDate: null,
       checkerOptionList: [],
@@ -97,10 +106,27 @@ export default {
   created() { },
   mounted() {
     this.reportDate = this.$route.query.date;
-    this.reportId = this.$route.query.ohterId;
+    if (this.reportDate == null) {
+      //初始化为当天
+      this.reportDate = this.formatDate(new Date());
+    }
+    this.reportId = this.$route.query.otherId;
+
     this.getMyPlanProcedureList();
   },
   methods: {
+    formatDate(date) {
+      // 中国标准时间转成 YYYY-MM-DD
+      const year = date.getFullYear();
+      const month = date.getMonth() + 1;
+      const day = date.getDate();
+      return `${year}-${month < 10 ? '0' + month : month}-${day < 10 ? '0' + day : day}`;
+    },
+    reportDateOnConfirm(date) {
+      this.reportDateShow = false;
+      this.reportDate = this.formatDate(date);
+      this.getMyPlanProcedureList();
+    },
     deleteReport() {
       this.$dialog.confirm({
           title: '删除报工',
@@ -160,11 +186,12 @@ export default {
         isTerminated: this.reportForm.isTerminated,
         steelNumArray: JSON.stringify(this.reportForm.checkedSteelNum),
         finishNum: this.reportForm.finishNum,
-        isFinish: this.reportForm.isFinish
+        isFinish: this.reportForm.isFinish,
+        createDate: this.reportDate
       };
-      const { id, reportBoolean, ohterId } = this.$route.query;
-      if(reportBoolean == 'true') {
-        postData.id = ohterId;
+      const { id, reportBoolean, otherId } = this.$route.query;
+      if(this.reportId) {
+        postData.id = this.reportId;
       }
       if (this.reportForm.isFinish) {
         if (this.reportForm.check_type != 0) {
@@ -197,9 +224,6 @@ export default {
         id: id,
         inputSteelNum:this.inputSteelNum
       }
-      if(reportBoolean == 'true') {
-        params.createDate = date
-      }
       if (this.reportDate) {
         params.createDate = this.reportDate;
       }
@@ -208,6 +232,10 @@ export default {
         .then(res => {
           if (res.code == "ok") {
             this.reportForm = res.data;
+            if (this.reportForm.oldReport != null) {
+              //日报已存在,赋予id
+              this.reportId = this.reportForm.oldReport.id;
+            }
             this.oldPlanSteelStampNumberList=this.reportForm.planSteelStampNumberList
             //当日选中的钢印号,默认勾选上
             this.reportForm.checkedSteelNum = this.reportForm.steelNumArray==null?[]:this.reportForm.steelNumArray;

+ 1 - 1
fhKeeper/formulahousekeeper/timesheet-workshop-h5/src/views/workView/workView.vue

@@ -286,7 +286,7 @@ export default {
         query: {
           id: this.reportBoolean ? item.userProcedureTeamId : item.id,
           reportBoolean: this.reportBoolean,
-          ohterId: item.id,
+          otherId: item.id,
           date: item.createDate,
         }
       })