Browse Source

更新防止空字段导致审批失效

baihe 3 years ago
parent
commit
2adfba9836

+ 1 - 1
application-facade/pom.xml

@@ -10,7 +10,7 @@
     <modelVersion>4.0.0</modelVersion>
     <artifactId>application-facade</artifactId>
     <packaging>jar</packaging>
-    <name>application-wx</name>
+    <name>application-web</name>
 
     <dependencies>
         <dependency>

+ 1 - 1
application-facade/src/main/java/com/factory/controller/web/FirstArticleController.java

@@ -100,7 +100,7 @@ public class FirstArticleController {
 	@ApiOperation(value = "修改首件计划")
 	@PostMapping("/editFaPlan")
 	@ApiOperationSupport(order = 3)
-	public ResponseBean<Void> editFaPlan(@RequestBody EditFaPlanReq req) {
+	public ResponseBean<Void> editFaPlan(@Valid @RequestBody EditFaPlanReq req) {
 		return firstArticleService.editFaPlan(req);
 	}
 

+ 3 - 1
application-facade/src/main/java/com/factory/controller/web/PreventMistakeController.java

@@ -2,6 +2,8 @@ package com.factory.controller.web;
 
 import java.util.List;
 
+import javax.validation.Valid;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -114,7 +116,7 @@ public class PreventMistakeController {
 	@ApiOperation(value = "修改防错计划")
 	@PostMapping("/editPmPlan")
 	@ApiOperationSupport(order = 7)
-	public ResponseBean<Void> editPmPlan(@RequestBody EditPmPlanReq req) {
+	public ResponseBean<Void> editPmPlan(@Valid @RequestBody EditPmPlanReq req) {
 		return preventMistakeService.editPmPlan(req);
 	}
 

+ 0 - 127
application-facade/src/main/java/com/factory/scheduled/CreateIniBase.java

@@ -1,127 +0,0 @@
-package com.factory.scheduled;
-
-import cn.hutool.core.convert.Convert;
-import cn.hutool.json.JSONUtil;
-import com.factory.base.entity.enumPo.CheckTypeSubmit;
-import com.factory.base.entity.po.benteler.*;
-import com.factory.web.entity.vo.res.web.ini.PagePlanRes;
-import com.factory.web.mapper.ini.BentelerIniVersionMapper;
-import com.factory.web.service.BentelerPlanService;
-import com.factory.web.service.ini.*;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.EnableScheduling;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Component;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.time.LocalDate;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
-
-@Slf4j
-@Component
-@EnableScheduling
-@Transactional(rollbackFor = Exception.class)
-public class CreateIniBase {
-    @Autowired
-    private BentelerIniVersionMapper versionMapper;
-    @Autowired
-    private BentelerPlanService planService;
-    @Autowired
-    private BentelerIniVersionService versionService;
-    @Autowired
-    private BentelerIniCheckResultService checkResultService;
-    @Autowired
-    private BentelerIniCheckTypeService checkTypeService;
-    @Autowired
-    private BentelerIniCheckItemService checkItemService;
-    @Autowired
-    private BentelerIniVersionItemService versionItemService;
-
-    /**
-     * 每天0点执行
-     * 创建
-     * 结果单     Result
-     * 点检分类表 checkType
-     * 点检结果表 CheckItem
-     */
-    @Scheduled(cron = "0 0 0 * * ?")
-    public void creat() {
-        List<PagePlanRes> planlist = versionMapper.Planlist(null, null, null, null);
-        Map<Long, List<PagePlanRes>> versionId_res_Map = planlist.stream()
-                //过滤
-                .filter(plan -> {
-
-                    Long versionId = plan.getVersionId();
-                    BentelerIniVersion version = versionService.getById(versionId);
-                    return version.getBeginDate().compareTo(LocalDate.now()) < 1;
-                })
-                //版本id分组
-                .collect(Collectors.groupingBy(PagePlanRes::getVersionId));
-
-        ArrayList<BentelerIniCheckType> checkTypeList = new ArrayList<>();
-        ArrayList<BentelerIniCheckItem> checkItems = new ArrayList<>();
-
-        versionId_res_Map.entrySet().forEach(map -> {
-            BentelerIniVersion version = versionService.getById(map.getKey());
-            BentelerPlan plan = planService.getById(version.getPlanId());
-            //创建结果单
-            BentelerIniCheckResult result = BentelerIniCheckResult.builder()
-                    .planId(plan.getId())
-                    .versionId(version.getId())
-                    .checkStatus(0)
-                    .abnormalFlag(false)
-                    .build();
-            checkResultService.save(result);
-
-            String allChecktype = version.getAllChecktype();
-            List<Integer> integers = Convert.toList(Integer.class, allChecktype);
-            //分类循环
-            integers.forEach(inte -> {
-                //创建分类结果提交记录表
-                BentelerIniCheckType checkType = BentelerIniCheckType.builder()
-                        .checkResultId(result.getId())
-                        .checkType(inte)
-                        .status(CheckTypeSubmit.未保存.value)
-                        .build();
-
-                checkTypeList.add(checkType);
-                //每一个点检项创建一个 点检项结果表
-                map.getValue().forEach(item -> {
-                    BentelerIniVersionItem versionItem = versionItemService.getById(item.getVersionItemId());
-
-                    BentelerIniCheckItem checkItem = BentelerIniCheckItem.builder()
-                            .versionItemId(item.getVersionItemId())
-                            .checkResultId(result.getId())
-                            .checkType(inte)
-                            .dataType(versionItem.getDataType())
-                            .build();
-                    //填充空的得分json
-                    Integer begin = versionItem.getWorkStationBegin();
-                    Integer end = versionItem.getWorkStationEnd();
-                    List<IniGread> greads = IntStream.rangeClosed(begin, end)//
-                            .boxed()
-                            .map(workNum -> IniGread.builder()
-                                    .GreadFlag(versionItem.getDataType().equals(0))
-                                    .build())
-                            .collect(Collectors.toList());
-                    String greadJson = JSONUtil.toJsonStr(greads);
-                    checkItem.setGread(greadJson);
-                    checkItems.add(checkItem);
-                });
-
-            });
-        });
-        checkTypeService.saveBatch(checkTypeList);
-        checkItemService.saveBatch(checkItems);
-
-        log.info("创建" + LocalDate.now().toString() + "日 基础表单成功");
-
-    }
-
-
-}

+ 3 - 2
application-facade/src/main/java/com/factory/web/entity/fa/req/AddFaPlanReq.java

@@ -30,11 +30,12 @@ import java.util.List;
 @ApiModel("")
 public class AddFaPlanReq {
 
-    @Size(max = 128, message = "名字长度过长")
+    @Size(max = 128, message = "名字长度不要超过128个字符")
     @NotEmpty(message = "计划名称不能为空")
     @ApiModelProperty(value = "计划名称", example = "计划A")
     private String bentelerPlanName;
-
+    
+    @NotNull(message = "生效日期必填")
     @ApiModelProperty(value = "生效日期", example = "2021-06-06")
     private LocalDate effectiveDate;
 

+ 4 - 2
application-facade/src/main/java/com/factory/web/entity/fa/req/EditFaPlanReq.java

@@ -10,6 +10,7 @@ import lombok.Data;
 import lombok.NoArgsConstructor;
 
 import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
 import javax.validation.constraints.Size;
 import java.time.LocalDate;
 import java.util.List;
@@ -31,11 +32,12 @@ public class EditFaPlanReq {
     @ApiModelProperty(value = "计划ID")
     private Long bentelerPlanId;
 
-    @Size(max = 128, message = "名字长度过长")
+    @Size(max = 128, message = "名字长度不要超过128个字符")
     @NotEmpty(message = "计划名称不能为空")
     @ApiModelProperty(value = "计划名称", example = "计划A")
     private String bentelerPlanName;
-
+    
+    @NotNull(message = "生效日期必填")
     @ApiModelProperty(value = "生效日期", example = "2021-06-06")
     private LocalDate effectiveDate;
 

+ 3 - 1
application-facade/src/main/java/com/factory/web/entity/pm/req/EditPmPlanReq.java

@@ -10,6 +10,7 @@ import lombok.Data;
 import lombok.NoArgsConstructor;
 
 import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
 import javax.validation.constraints.Size;
 import java.time.LocalDate;
 import java.util.List;
@@ -31,11 +32,12 @@ public class EditPmPlanReq {
     @ApiModelProperty(value = "计划ID")
     private Long bentelerPlanId;
 
-    @Size(max = 128, message = "名字长度过长")
+    @Size(max = 128, message = "名字长度不要超过128个字符")
     @NotEmpty(message = "计划名称不能为空")
     @ApiModelProperty(value = "计划名称", example = "计划A")
     private String bentelerPlanName;
 
+    @NotNull(message = "生效日期必填")
     @ApiModelProperty(value = "生效日期", example = "2021-06-06")
     private LocalDate effectiveDate;
 

+ 5 - 1
application-facade/src/main/java/com/factory/wx/service/impl/PlanApprovalServiceImpl.java

@@ -269,7 +269,11 @@ public class PlanApprovalServiceImpl implements PlanApprovalService {
                 			.id(planApprovalReq.getPlanId())
                 			.status(PlanStatus.APPROVAL_PASS.value)
                 			.build();
-                	if(!LocalDate.now().isBefore(plan.getEffectiveDate())) {//有效期已经过了当前日期了,那么立刻生效
+                	if(plan.getEffectiveDate()==null) {//
+                		plan.setEffectiveDate(LocalDate.now());
+                		planUpdate.setEffectiveDate(plan.getEffectiveDate());
+                	}
+                	if(!LocalDate.now().isBefore(plan.getEffectiveDate())||plan.getPrevId()==null) {//有效期已经过了当前日期了,或者这是一个新计划,那么立刻生效
                 		if(plan.getPrevId()!=null) {
                 			planService.lambdaUpdate().eq(BentelerPlan::getOriginalId,plan.getOriginalId())
             				.in(BentelerPlan::getStatus, PlanStatus.APPROVAL_FORMAL.value,PlanStatus.APPROVAL_PASS.value)

File diff suppressed because it is too large
+ 481 - 0
crocodile.sql


+ 29 - 0
清空数据.sql

@@ -0,0 +1,29 @@
+SET foreign_key_checks = 0;
+truncate table benteler_plan;
+truncate table benteler_plan_bak;
+truncate table first_article_approval_task;
+truncate table first_article_calendar;
+truncate table first_article_item;
+truncate table first_article_item_result;
+truncate table first_article_task;
+truncate table first_article_task_his_blob;
+truncate table first_article_task_key;
+truncate table first_article_title_blob;
+truncate table first_article_workshop;
+truncate table onsite_approval_plan;
+truncate table onsite_approval_task;
+truncate table onsite_calendar;
+truncate table onsite_item;
+truncate table onsite_item_result;
+truncate table onsite_plan_his_blob;
+truncate table onsite_task;
+truncate table onsite_task_his_blob;
+truncate table onsite_title_blob;
+truncate table plan_bind;
+truncate table onsite_workshop;
+truncate table remind_approval_task;
+truncate table us_user_wechat;
+SET foreign_key_checks = 1;
+delete from upload_file_blob where id > 1;
+delete from us_user_role where user_id > 1;
+delete from us_user where id > 1;

Some files were not shown because too many files changed in this diff