Min před 1 rokem
rodič
revize
127bf699aa

+ 1 - 1
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/controller/PlanController.java

@@ -94,7 +94,7 @@ public class PlanController {
     }
 
     @RequestMapping("/importData")
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     public HttpRespMsg importData(MultipartFile file,Integer planType){
         return planService.importData(file,planType);
     }

+ 30 - 39
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/service/impl/PlanServiceImpl.java

@@ -28,6 +28,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
 import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.multipart.MultipartFile;
@@ -308,9 +309,11 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
             plan.setTaskTypeName(taskType.getTaskTypeName());
         }
         List<ProdProcedure> procedureList = prodProcedureMapper.selectList(new QueryWrapper<ProdProcedure>().eq("company_id", companyId).eq("product_id",plan.getProductId()).orderByDesc("id"));
-        if(procedureList.size()<=0){
-            msg.setError("当前产品工序配置未完成,请先完成工序配置");
-            return msg;
+        if(plan.getPlanType()==0){
+            if(procedureList.size()<=0){
+                msg.setError("当前产品工序配置未完成,请先完成工序配置");
+                return msg;
+            }
         }
         List<PlanProcedureTotal> planProcedureTotals=new ArrayList<>();
         List<PlanProcedureTotal> oldPlanProcedureTotals=new ArrayList<>();
@@ -511,7 +514,7 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
     }
 
     @Override
-    public HttpRespMsg importData(MultipartFile multipartFile, Integer planType) {
+    public HttpRespMsg importData(MultipartFile multipartFile, Integer planType){
         HttpRespMsg msg=new HttpRespMsg();
         DateTimeFormatter df=DateTimeFormatter.ofPattern("yyyy-MM-dd");
         SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
@@ -560,8 +563,7 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
                 if(planType!=2){
                     if(!StringUtils.isEmpty(cell0.getStringCellValue())){
                         if(cell0.getStringCellValue().equals("任务变更通知号")){
-                            msg.setError("导入模板为插单计划模板,请重新下载模板");
-                            return  msg;
+                            throw new Exception("导入模板为插单计划模板,请重新下载模板");
                         }
                     }
                     plan.setPlanType(0);
@@ -587,14 +589,13 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
                     if (describtionCell != null) describtionCell.setCellType(CellType.STRING);
                     plan.setStartDate(planType==0?LocalDate.now():LocalDate.now().plusDays(1));
                     if(productSchedulingNumCell!=null){
-                        if(count(new QueryWrapper<Plan>().eq("product_scheduling_num",productSchedulingNumCell.getStringCellValue()))>0){
-                            msg.setError("已存在的排产工单号"+productSchedulingNumCell.getStringCellValue());
-                            return msg;
+                        Plan one = getOne(new QueryWrapper<Plan>().eq("product_scheduling_num", productSchedulingNumCell.getStringCellValue()));
+                        if(one!=null){
+                            plan.setId(one.getId());
                         }
                         Optional<Plan> first = needInsertList.stream().filter(nl -> nl.getProductSchedulingNum().equals(productSchedulingNumCell.getStringCellValue())).findFirst();
                         if(first.isPresent()){
-                            msg.setError("重复的排产工单号"+productSchedulingNumCell.getStringCellValue());
-                            return msg;
+                            throw new Exception("重复的排产工单号"+productSchedulingNumCell.getStringCellValue());
                         }
                         plan.setProductSchedulingNum(productSchedulingNumCell.getStringCellValue());
                     }
@@ -604,8 +605,7 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
                         for (String s : split) {
                             String[] targetSplit = s.split(",");
                             if(targetSplit.length!=2){
-                                msg.setError("数据["+s+"]钢印号数组及下标错误");
-                                return msg;
+                                throw new Exception("数据["+s+"]钢印号数组及下标错误");
                             }
                             String steelStampNum=targetSplit[0];
                             String indexNum=targetSplit[1];
@@ -621,8 +621,7 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
                             if(indexNum.contains("-")){
                                 String[] split2 = indexNum.split("-");
                                 if(Integer.valueOf(split2[0])>Integer.valueOf(split2[1])){
-                                    msg.setError("钢印号数组["+s+"]下标异常,第一下标不能大于第二下标");
-                                    return msg;
+                                    throw new Exception("钢印号数组["+s+"]下标异常,第一下标不能大于第二下标");
                                 }
                                 p.setRuleIndexStart(Integer.valueOf(split2[0]));
                                 p.setRuleIndexEnd(Integer.valueOf(split2[1]));
@@ -640,12 +639,10 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
                             plan.setProductName(first.get().getName());
                             plan.setProjectCode(first.get().getCode());
                         }else {
-                            msg.setError("产品["+productNameCell.getStringCellValue()+"]不存在");
-                            return msg;
+                            throw new Exception("产品["+productNameCell.getStringCellValue()+"]不存在");
                         }
                     }else {
-                        msg.setError("产品名称不能为空");
-                        return msg;
+                        throw new Exception("产品名称不能为空");
                     }
                     plan.setNum(numCell==null?0:Double.valueOf(numCell.getNumericCellValue()).intValue());
                     plan.setMainProcess(mainProcessCell==null?"":mainProcessCell.getStringCellValue());
@@ -660,19 +657,16 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
                                 plan.setForemanName(user.get().getName());
                             }
                         }else {
-                            msg.setError("工位["+stationNameCell.getStringCellValue()+"]不存在");
-                            return msg;
+                            throw new Exception("工位["+stationNameCell.getStringCellValue()+"]不存在");
                         }
                     }else {
-                        msg.setError("工位不能为空");
-                        return msg;
+                        throw new Exception("工位不能为空");
                     }
                     if(startDateCell!=null&&!StringUtils.isEmpty(startDateCell.getDateCellValue())&&endDateCell!=null&&!StringUtils.isEmpty(endDateCell.getDateCellValue())){
                         LocalDate startDate = LocalDate.parse(sdf.format(startDateCell.getDateCellValue()), df);
                         LocalDate endDate = LocalDate.parse(sdf.format(endDateCell.getDateCellValue()), df);
                         if(endDate.isBefore(startDate)){
-                            msg.setError("第"+rowIndex+"行数据结束日期大于开始日期");
-                            return msg;
+                           throw new Exception("第"+rowIndex+"行数据结束日期大于开始日期");
                         }
                     }
                     if(startDateCell!=null&&!StringUtils.isEmpty(startDateCell.getDateCellValue())){
@@ -687,8 +681,7 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
                 }else {
                     if(!StringUtils.isEmpty(cell0.getStringCellValue())){
                         if(cell0.getStringCellValue().equals("排产工单号")){
-                            msg.setError("导入模板为排产计划模板,请重新下载模板");
-                            return  msg;
+                            throw new Exception("导入模板为排产计划模板,请重新下载模板");
                         }
                     }
                     plan.setPlanType(1);
@@ -723,14 +716,13 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
                     List<TaskType> taskTypeList = taskTypeMapper.selectList(new QueryWrapper<TaskType>().eq("company_id", companyId));
 
                     if(taskChangeNoticeNumCell!=null){
-                        if(count(new QueryWrapper<Plan>().eq("task_change_notice_num",taskChangeNoticeNumCell.getStringCellValue()))>0){
-                            msg.setError("已存在的任务变更通知号"+taskChangeNoticeNumCell.getStringCellValue());
-                            return msg;
+                        Plan one = getOne(new QueryWrapper<Plan>().eq("task_change_notice_num", taskChangeNoticeNumCell.getStringCellValue()));
+                        if(one!=null){
+                            plan.setId(one.getId());
                         }
                         Optional<Plan> first = needInsertList.stream().filter(nl -> nl.getTaskChangeNoticeNum().equals(taskChangeNoticeNumCell.getStringCellValue())).findFirst();
                         if(first.isPresent()){
-                            msg.setError("重复的任务变更通知号"+taskChangeNoticeNumCell.getStringCellValue());
-                            return msg;
+                            throw new Exception("重复的任务变更通知号"+taskChangeNoticeNumCell.getStringCellValue());
                         }
                         plan.setTaskChangeNoticeNum(taskChangeNoticeNumCell.getStringCellValue());
                     }
@@ -775,19 +767,16 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
                                 plan.setForemanName(user.get().getName());
                             }
                         }else {
-                            msg.setError("工位["+stationNameCell.getStringCellValue()+"]不存在");
-                            return msg;
+                           throw new Exception("工位["+stationNameCell.getStringCellValue()+"]不存在");
                         }
                     }else {
-                        msg.setError("工位不能为空");
-                        return msg;
+                        throw new Exception("工位不能为空");
                     }
                     if(startDateCell!=null&&!StringUtils.isEmpty(startDateCell.getDateCellValue())&&endDateCell!=null&&!StringUtils.isEmpty(endDateCell.getDateCellValue())){
                         LocalDate startDate = LocalDate.parse(sdf.format(startDateCell.getDateCellValue()), df);
                         LocalDate endDate = LocalDate.parse(sdf.format(endDateCell.getDateCellValue()), df);
                         if(endDate.isBefore(startDate)){
-                            msg.setError("第"+rowIndex+"行数据结束日期大于开始日期");
-                            return msg;
+                           throw new Exception("第"+rowIndex+"行数据结束日期大于开始日期");
                         }
                     }
                     if(startDateCell!=null&&!StringUtils.isEmpty(startDateCell.getDateCellValue())){
@@ -876,7 +865,7 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
                 if(lastPlanList.size()>0){
                     saveOrUpdateBatch(lastPlanList);
                 };
-                msg.setData("导入成功,其中产品["+sb.toString()+"]产品工序未完成,请完成工序配置");
+                msg.setData("导入成功,其中产品["+sb.toString()+"]产品工序未完成,请完成工序配置后重新导入");
             }
         } catch (IOException e) {
             e.printStackTrace();
@@ -896,6 +885,8 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
             return msg;
         } catch (Exception e) {
             e.printStackTrace();
+            //针对try-catch 捕捉异常导致事务回滚失效的情况 手动设置回滚
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
             //msg.setError("上传失败:" + e.getMessage());
             msg.setError(MessageUtils.message("file.uploadError",e.getMessage()));
             return msg;

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

@@ -4051,6 +4051,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             targetUserIds.add("-1");
             queryWrapper.in("id",targetUserIds);
         }
+        queryWrapper.eq("is_active",1);
+        queryWrapper.orderByAsc("department_id");
         IPage<User> userIPage = userMapper.selectPage(new Page<>(pageIndex, pageSize), queryWrapper);
         List<User> userList = userIPage.getRecords();
         if(userList.size()>0){

+ 68 - 2
fhKeeper/formulahousekeeper/timesheet-workshop/src/views/plan/orderInsert.vue

@@ -86,9 +86,14 @@
           </el-table-column>
           <el-table-column prop="startDate" label="开工时间" width="180"></el-table-column>
           <el-table-column prop="endDate" label="完工时间" width="180"></el-table-column>
-          <el-table-column label="操作" :fixed="'right'">
+          <el-table-column label="操作" :fixed="'right'" width="140">
             <template slot-scope="scope">
-              <div @click="editPlan(scope.row)" class="colorText">编辑</div>
+              <div class="controls_btn">
+                <div @click="editPlan(scope.row)" class="colorText">编辑</div>
+                <div @click="deletePlan(scope.row.id)" class="colorText">删除</div>
+                <div v-if="jisuanDate(scope.row.startDate) > 30" @click="hidePlan(scope.row.id, scope.row.hideState)"
+                  class="colorText">{{ scope.row.hideState == 0 ? '隐藏' : '取消隐藏' }}</div>
+              </div>
             </template>
           </el-table-column>
         </el-table>
@@ -677,6 +682,55 @@ export default {
         }
       });
     },
+    jisuanDate(startDate) {
+      let date1 = new Date(startDate);
+      let date2 = new Date();
+      date1 = new Date(date1.getFullYear(), date1.getMonth(), date1.getDate());
+      date2 = new Date(date2.getFullYear(), date2.getMonth(), date2.getDate());
+      const diff = date2.getTime() - date1.getTime(); //目标时间减去当前时间
+      const diffDate = diff / (24 * 60 * 60 * 1000);
+      return diffDate;
+    },
+    //删除计划
+    deletePlan(id) {
+      this.$confirm('该计划将被删除, 是否继续?', '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+          this.http.post(
+            "/plan/deletePlan",
+            {
+              id: id,
+            },
+            (res) => {
+              if (res.code == "ok") {
+                this.$message({
+                  message: '删除成功',
+                  type: "success",
+                });
+              } else {
+                this.$message({
+                  message: res.msg,
+                  type: "error",
+                });
+              }
+              this.getTableData()
+            },
+            (error) => {
+              this.$message({
+                message: error,
+                type: "error",
+              });
+            }
+          );
+        }).catch(() => {
+          this.$message({
+            type: 'info',
+            message: '已取消删除'
+          });          
+        });
+    },
     editPlan(item) {
       (this.titleName = `编辑${this.titleText}`), (this.editPlanDiaLog = true);
       this.todayPlanForm = item;
@@ -1015,6 +1069,18 @@ export default {
     box-sizing: border-box;
   }
 
+  .controls_btn {
+    display: flex;
+
+    div {
+      margin-right: 10px;
+
+      &:last-child {
+        margin-right: 0;
+      }
+    }
+  }
+
   .layout-container-header {
     padding: 10px 10px 0 10px;
     background: #F2F2F2;

+ 11 - 5
fhKeeper/formulahousekeeper/timesheet-workshop/src/views/plan/planComponent.vue

@@ -1111,9 +1111,11 @@ export default {
     },
     //删除计划
     deletePlan(id) {
-      this.$alert('该计划将被删除', '是否删除该计划', {
-        confirmButtonText: '确定',
-        callback: action => {
+      this.$confirm('该计划将被删除, 是否继续?', '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
           this.http.post(
             "/plan/deletePlan",
             {
@@ -1140,8 +1142,12 @@ export default {
               });
             }
           );
-        }
-      });
+        }).catch(() => {
+          this.$message({
+            type: 'info',
+            message: '已取消删除'
+          });          
+        });
     },
   },
   created() {