Prechádzať zdrojové kódy

-修改:月度检查判重

jiangbiao 2 rokov pred
rodič
commit
88e8b8a9d4

+ 20 - 15
master/src/main/java/com/ruoyi/project/production/controller/TFivesMonthlyInspectionController.java

@@ -3,11 +3,13 @@ package com.ruoyi.project.production.controller;
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.framework.aspectj.lang.annotation.Log;
 import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
+import com.ruoyi.framework.interceptor.annotation.RepeatSubmit;
 import com.ruoyi.framework.web.controller.BaseController;
 import com.ruoyi.framework.web.domain.AjaxResult;
 import com.ruoyi.framework.web.page.TableDataInfo;
 import com.ruoyi.project.production.domain.TFivesMonthlyInspection;
 import com.ruoyi.project.production.service.ITFivesMonthlyInspectionService;
+import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
@@ -23,8 +25,7 @@ import java.util.List;
  */
 @RestController
 @RequestMapping("/production/inspection")
-public class TFivesMonthlyInspectionController extends BaseController
-{
+public class TFivesMonthlyInspectionController extends BaseController {
     @Autowired
     private ITFivesMonthlyInspectionService tFivesMonthlyInspectionService;
 
@@ -33,8 +34,7 @@ public class TFivesMonthlyInspectionController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('production:inspection:list')")
     @GetMapping("/list")
-    public TableDataInfo list(TFivesMonthlyInspection tFivesMonthlyInspection)
-    {
+    public TableDataInfo list(TFivesMonthlyInspection tFivesMonthlyInspection) {
         startPage();
         List<TFivesMonthlyInspection> list = tFivesMonthlyInspectionService.selectTFivesMonthlyInspectionList(tFivesMonthlyInspection);
         return getDataTable(list);
@@ -46,8 +46,7 @@ public class TFivesMonthlyInspectionController extends BaseController
     @PreAuthorize("@ss.hasPermi('production:inspection:export')")
     @Log(title = "区域月度检查", businessType = BusinessType.EXPORT)
     @GetMapping("/export")
-    public AjaxResult export(TFivesMonthlyInspection tFivesMonthlyInspection)
-    {
+    public AjaxResult export(TFivesMonthlyInspection tFivesMonthlyInspection) {
         List<TFivesMonthlyInspection> list = tFivesMonthlyInspectionService.selectTFivesMonthlyInspectionList(tFivesMonthlyInspection);
         ExcelUtil<TFivesMonthlyInspection> util = new ExcelUtil<TFivesMonthlyInspection>(TFivesMonthlyInspection.class);
         return util.exportExcel(list, "inspection");
@@ -58,8 +57,7 @@ public class TFivesMonthlyInspectionController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('production:inspection:query')")
     @GetMapping(value = "/{id}")
-    public AjaxResult getInfo(@PathVariable("id") Long id)
-    {
+    public AjaxResult getInfo(@PathVariable("id") Long id) {
         return AjaxResult.success(tFivesMonthlyInspectionService.selectTFivesMonthlyInspectionById(id));
     }
 
@@ -68,9 +66,18 @@ public class TFivesMonthlyInspectionController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('production:inspection:add')")
     @Log(title = "区域月度检查", businessType = BusinessType.INSERT)
+    @RepeatSubmit
     @PostMapping
-    public AjaxResult add(@RequestBody TFivesMonthlyInspection tFivesMonthlyInspection)
-    {
+    public AjaxResult add(@RequestBody TFivesMonthlyInspection tFivesMonthlyInspection) {
+        TFivesMonthlyInspection tfmi = new TFivesMonthlyInspection();
+        tfmi.setPosition(tFivesMonthlyInspection.getPosition());
+        tfmi.setOwner(tFivesMonthlyInspection.getOwner());
+        tfmi.setRegionOrder(tFivesMonthlyInspection.getRegionOrder());
+        tfmi.setYear(tFivesMonthlyInspection.getYear());
+        List<TFivesMonthlyInspection> selected = tFivesMonthlyInspectionService.selectTFivesMonthlyInspectionList(tfmi);
+        if (CollectionUtils.isNotEmpty(selected)) {
+            return AjaxResult.error("当前数据已存在");
+        }
         tFivesMonthlyInspection.setCreatedate(new Date());
         tFivesMonthlyInspection.setCreaterCode(getUserId().toString());
         return toAjax(tFivesMonthlyInspectionService.insertTFivesMonthlyInspection(tFivesMonthlyInspection));
@@ -82,8 +89,7 @@ public class TFivesMonthlyInspectionController extends BaseController
     @PreAuthorize("@ss.hasPermi('production:inspection:edit')")
     @Log(title = "区域月度检查", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody TFivesMonthlyInspection tFivesMonthlyInspection)
-    {
+    public AjaxResult edit(@RequestBody TFivesMonthlyInspection tFivesMonthlyInspection) {
         return toAjax(tFivesMonthlyInspectionService.updateTFivesMonthlyInspection(tFivesMonthlyInspection));
     }
 
@@ -92,9 +98,8 @@ public class TFivesMonthlyInspectionController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('production:inspection:remove')")
     @Log(title = "区域月度检查", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{ids}")
-    public AjaxResult remove(@PathVariable Long[] ids)
-    {
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids) {
         return toAjax(tFivesMonthlyInspectionService.deleteTFivesMonthlyInspectionByIds(ids));
     }
 }