deason 5 سال پیش
والد
کامیت
5c9a5e5893

+ 3 - 2
examcloud-core-print-provider/src/main/java/cn/com/qmth/examcloud/core/print/api/controller/ProjectBackupSettingController.java

@@ -7,10 +7,11 @@
 
 package cn.com.qmth.examcloud.core.print.api.controller;
 
-import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import cn.com.qmth.examcloud.core.print.common.Result;
 import cn.com.qmth.examcloud.core.print.entity.ProjectBackupSetting;
 import cn.com.qmth.examcloud.core.print.service.ProjectBackupSettingService;
+import cn.com.qmth.examcloud.core.print.service.bean.printingproject.ProjectBackupSettingInfo;
+import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -39,7 +40,7 @@ public class ProjectBackupSettingController extends ControllerSupport {
 
     @PostMapping("/save")
     @ApiOperation(value = "保存或更新某个项目的备份设置信息")
-    public Result save(@RequestBody ProjectBackupSetting info) {
+    public Result save(@RequestBody ProjectBackupSettingInfo info) {
         projectBackupSettingService.saveProjectBackupSetting(info);
         return success();
     }

+ 3 - 2
examcloud-core-print-provider/src/main/java/cn/com/qmth/examcloud/core/print/api/controller/ProjectOtherSettingController.java

@@ -7,10 +7,11 @@
 
 package cn.com.qmth.examcloud.core.print.api.controller;
 
-import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import cn.com.qmth.examcloud.core.print.common.Result;
 import cn.com.qmth.examcloud.core.print.entity.ProjectOtherSetting;
 import cn.com.qmth.examcloud.core.print.service.ProjectOtherSettingService;
+import cn.com.qmth.examcloud.core.print.service.bean.printingproject.ProjectOtherSettingInfo;
+import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -47,7 +48,7 @@ public class ProjectOtherSettingController extends ControllerSupport {
 
     @PostMapping("/save")
     @ApiOperation(value = "保存或更新某个其它事项设置信息")
-    public Result save(@RequestBody ProjectOtherSetting info) {
+    public Result save(@RequestBody ProjectOtherSettingInfo info) {
         projectOtherSettingService.saveProjectOtherSetting(info);
         return success();
     }

+ 2 - 1
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/ProjectBackupSettingService.java

@@ -8,6 +8,7 @@
 package cn.com.qmth.examcloud.core.print.service;
 
 import cn.com.qmth.examcloud.core.print.entity.ProjectBackupSetting;
+import cn.com.qmth.examcloud.core.print.service.bean.printingproject.ProjectBackupSettingInfo;
 
 /**
  * @author: fengdesheng
@@ -23,7 +24,7 @@ public interface ProjectBackupSettingService {
     /**
      * 保存或更新某个项目的备份设置信息
      */
-    void saveProjectBackupSetting(ProjectBackupSetting info);
+    void saveProjectBackupSetting(ProjectBackupSettingInfo info);
 
     /**
      * 清除某个项目的备份设置信息

+ 2 - 1
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/ProjectOtherSettingService.java

@@ -8,6 +8,7 @@
 package cn.com.qmth.examcloud.core.print.service;
 
 import cn.com.qmth.examcloud.core.print.entity.ProjectOtherSetting;
+import cn.com.qmth.examcloud.core.print.service.bean.printingproject.ProjectOtherSettingInfo;
 
 import java.util.List;
 
@@ -30,7 +31,7 @@ public interface ProjectOtherSettingService {
     /**
      * 保存或更新某个其它事项设置信息
      */
-    void saveProjectOtherSetting(ProjectOtherSetting info);
+    void saveProjectOtherSetting(ProjectOtherSettingInfo info);
 
     /**
      * 删除某个其它事项设置信息

+ 25 - 0
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/bean/printingproject/ProjectBackupSettingConvert.java

@@ -0,0 +1,25 @@
+package cn.com.qmth.examcloud.core.print.service.bean.printingproject;
+
+import cn.com.qmth.examcloud.core.print.entity.ProjectBackupSetting;
+
+public class ProjectBackupSettingConvert {
+
+    public static ProjectBackupSetting of(ProjectBackupSettingInfo info) {
+        ProjectBackupSetting entity = new ProjectBackupSetting();
+        entity.setId(info.getId());
+        entity.setProjectId(info.getProjectId());
+
+        entity.setNeedEachPkg(info.getNeedEachPkg());
+        entity.setEachPkgPercent(info.getEachPkgPercent());
+        entity.setEachPkgMax(info.getEachPkgMax());
+        entity.setEachPkgMin(info.getEachPkgMin());
+
+        entity.setNeedAlonePkg(info.getNeedAlonePkg());
+        entity.setGroupType(info.getGroupType());
+        entity.setAlonePkgMax(info.getAlonePkgMax());
+        entity.setAlonePkgMin(info.getAlonePkgMin());
+        entity.setAlonePkgPercent(info.getAlonePkgPercent());
+        return entity;
+    }
+
+}

+ 158 - 0
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/bean/printingproject/ProjectBackupSettingInfo.java

@@ -0,0 +1,158 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-10-17 16:28:20.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.core.print.service.bean.printingproject;
+
+import cn.com.qmth.examcloud.api.commons.exchange.JsonSerializable;
+import cn.com.qmth.examcloud.core.print.enums.BackupGroupType;
+
+/**
+ * 印刷项目-备份设置信息
+ */
+public class ProjectBackupSettingInfo implements JsonSerializable {
+    private static final long serialVersionUID = 1L;
+    private Long id;
+
+    /**
+     * 项目ID
+     */
+    private Long projectId;
+
+    /* 1、每袋冗余设置 */
+
+    /**
+     * 是否需要每袋备份
+     */
+    private Boolean needEachPkg;
+    /**
+     * 每袋备份比例
+     */
+    private Double eachPkgPercent;
+    /**
+     * 每袋备份最大值
+     */
+    private Double eachPkgMax;
+    /**
+     * 每袋备份最小值
+     */
+    private Double eachPkgMin;
+
+
+    /* 2、单独备份袋 */
+
+    /**
+     * 是否需要单独备份袋
+     */
+    private Boolean needAlonePkg;
+    /**
+     * 归集类型
+     */
+    private BackupGroupType groupType;
+    /**
+     * 单独备份比例
+     */
+    private Double alonePkgPercent;
+    /**
+     * 单独备份最大值
+     */
+    private Double alonePkgMax;
+    /**
+     * 单独备份最小值
+     */
+    private Double alonePkgMin;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getProjectId() {
+        return projectId;
+    }
+
+    public void setProjectId(Long projectId) {
+        this.projectId = projectId;
+    }
+
+    public Boolean getNeedEachPkg() {
+        //为空时,默认值
+        return needEachPkg != null ? needEachPkg : false;
+    }
+
+    public void setNeedEachPkg(Boolean needEachPkg) {
+        this.needEachPkg = needEachPkg;
+    }
+
+    public Boolean getNeedAlonePkg() {
+        //为空时,默认值
+        return needAlonePkg != null ? needAlonePkg : false;
+    }
+
+    public void setNeedAlonePkg(Boolean needAlonePkg) {
+        this.needAlonePkg = needAlonePkg;
+    }
+
+    public Double getEachPkgPercent() {
+        return eachPkgPercent;
+    }
+
+    public void setEachPkgPercent(Double eachPkgPercent) {
+        this.eachPkgPercent = eachPkgPercent;
+    }
+
+    public Double getEachPkgMax() {
+        return eachPkgMax;
+    }
+
+    public void setEachPkgMax(Double eachPkgMax) {
+        this.eachPkgMax = eachPkgMax;
+    }
+
+    public Double getEachPkgMin() {
+        return eachPkgMin;
+    }
+
+    public void setEachPkgMin(Double eachPkgMin) {
+        this.eachPkgMin = eachPkgMin;
+    }
+
+    public BackupGroupType getGroupType() {
+        return groupType;
+    }
+
+    public void setGroupType(BackupGroupType groupType) {
+        this.groupType = groupType;
+    }
+
+    public Double getAlonePkgPercent() {
+        return alonePkgPercent;
+    }
+
+    public void setAlonePkgPercent(Double alonePkgPercent) {
+        this.alonePkgPercent = alonePkgPercent;
+    }
+
+    public Double getAlonePkgMax() {
+        return alonePkgMax;
+    }
+
+    public void setAlonePkgMax(Double alonePkgMax) {
+        this.alonePkgMax = alonePkgMax;
+    }
+
+    public Double getAlonePkgMin() {
+        return alonePkgMin;
+    }
+
+    public void setAlonePkgMin(Double alonePkgMin) {
+        this.alonePkgMin = alonePkgMin;
+    }
+
+}

+ 52 - 0
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/bean/printingproject/ProjectOtherSettingInfo.java

@@ -0,0 +1,52 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-10-17 16:28:20.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.core.print.service.bean.printingproject;
+
+import cn.com.qmth.examcloud.api.commons.exchange.JsonSerializable;
+
+/**
+ * 印刷项目-其它设置信息
+ */
+public class ProjectOtherSettingInfo implements JsonSerializable {
+    private static final long serialVersionUID = 1L;
+    private Long id;
+
+    /**
+     * 项目ID
+     */
+    private Long projectId;
+    /**
+     * 备注
+     */
+    private String remark;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getProjectId() {
+        return projectId;
+    }
+
+    public void setProjectId(Long projectId) {
+        this.projectId = projectId;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+}

+ 10 - 6
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/impl/ProjectBackupSettingServiceImpl.java

@@ -13,6 +13,8 @@ import cn.com.qmth.examcloud.core.print.common.utils.Check;
 import cn.com.qmth.examcloud.core.print.entity.ProjectBackupSetting;
 import cn.com.qmth.examcloud.core.print.repository.ProjectBackupSettingRepository;
 import cn.com.qmth.examcloud.core.print.service.ProjectBackupSettingService;
+import cn.com.qmth.examcloud.core.print.service.bean.printingproject.ProjectBackupSettingConvert;
+import cn.com.qmth.examcloud.core.print.service.bean.printingproject.ProjectBackupSettingInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -45,7 +47,7 @@ public class ProjectBackupSettingServiceImpl implements ProjectBackupSettingServ
     }
 
     @Override
-    public void saveProjectBackupSetting(ProjectBackupSetting info) {
+    public void saveProjectBackupSetting(ProjectBackupSettingInfo info) {
         Check.isNull(info, "备份设置的信息不能为空!");
         Check.isNull(info.getProjectId(), "备份设置的项目ID不能为空!");
 
@@ -64,16 +66,18 @@ public class ProjectBackupSettingServiceImpl implements ProjectBackupSettingServ
 
         Specification<ProjectBackupSetting> spec = SearchBuilder.EQ("projectId", info.getProjectId());
         Optional<ProjectBackupSetting> optional = projectBackupSettingRepository.findOne(spec);
+
+        ProjectBackupSetting setting = ProjectBackupSettingConvert.of(info);
         if (optional.isPresent()) {
             //存在记录时,则修改
-            ProjectBackupSetting setting = optional.get();
-            info.setId(setting.getId());
-            info.setCreationTime(setting.getCreationTime());
-            info.setUpdateTime(new Date());
+            ProjectBackupSetting baseSetting = optional.get();
+            setting.setId(baseSetting.getId());
+            setting.setCreationTime(baseSetting.getCreationTime());
+            setting.setUpdateTime(new Date());
         }
 
         //否则,新增记录
-        projectBackupSettingRepository.save(info);
+        projectBackupSettingRepository.save(setting);
     }
 
     @Override

+ 13 - 2
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/impl/ProjectOtherSettingServiceImpl.java

@@ -13,6 +13,7 @@ import cn.com.qmth.examcloud.core.print.common.utils.Check;
 import cn.com.qmth.examcloud.core.print.entity.ProjectOtherSetting;
 import cn.com.qmth.examcloud.core.print.repository.ProjectOtherSettingRepository;
 import cn.com.qmth.examcloud.core.print.service.ProjectOtherSettingService;
+import cn.com.qmth.examcloud.core.print.service.bean.printingproject.ProjectOtherSettingInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -52,11 +53,21 @@ public class ProjectOtherSettingServiceImpl implements ProjectOtherSettingServic
     }
 
     @Override
-    public void saveProjectOtherSetting(ProjectOtherSetting info) {
+    public void saveProjectOtherSetting(ProjectOtherSettingInfo info) {
         Check.isNull(info, "事项设置信息不能为空!");
         Check.isNull(info.getProjectId(), "事项设置的项目ID不能为空!");
         Check.isBlank(info.getRemark(), "事项设置的内容不能为空!");
-        projectOtherSettingRepository.save(info);
+
+        ProjectOtherSetting setting;
+        if (info.getId() != null) {
+            setting = this.getProjectOtherSettingById(info.getId());
+        } else {
+            setting = new ProjectOtherSetting();
+            setting.setProjectId(info.getProjectId());
+        }
+
+        setting.setRemark(info.getRemark());
+        projectOtherSettingRepository.save(setting);
     }
 
     @Override