liutao il y a 1 jour
Parent
commit
8be136ff46

+ 0 - 1
YHYZT/server/src/main/java/com/zjugis/yzt/controller/PewgController.java

@@ -1,6 +1,5 @@
 package com.zjugis.yzt.controller;
 
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.zjugis.yzt.service.PewgService;

+ 60 - 4
YHYZT/server/src/main/java/com/zjugis/yzt/controller/StNzydkController.java

@@ -3,9 +3,11 @@ package com.zjugis.yzt.controller;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.zjugis.yzt.beans.convert.StNzydkConvert;
+import com.zjugis.yzt.beans.entity.Pewg;
 import com.zjugis.yzt.beans.entity.StNzydk;
 import com.zjugis.yzt.beans.vo.StNzydkVO;
 import com.zjugis.yzt.service.StNzydkService;
+import com.zjugis.yzt.service.PewgService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.web.bind.annotation.*;
@@ -29,6 +31,8 @@ public class StNzydkController extends BaseRestController {
     @Autowired
     private StNzydkService stNzydkService;
 
+    @Autowired
+    private PewgService pewgService;
 
     /**
      * 获取农转用批次列表(分页)
@@ -97,7 +101,7 @@ public class StNzydkController extends BaseRestController {
                 .stream()
                 .filter(Optional::isPresent)
                 .map(Optional::get)
-                .sorted(Comparator.comparing(StNzydkVO::getObjectid).reversed())
+                .sorted(Comparator.comparing(StNzydkVO::getObjectid))
                 .collect(Collectors.toList());
 
         // 计算总记录数
@@ -182,7 +186,31 @@ public class StNzydkController extends BaseRestController {
      */
     @PostMapping("/update")
     public Object updateNzydk(@RequestBody StNzydk stNzydk) {
-        return result(stNzydkService.updateById(stNzydk));
+        boolean nzyUpdate = stNzydkService.updateById(stNzydk);
+
+        // 同步更新pewg表
+        if (stNzydk.getPcbh() != null && !stNzydk.getPcbh().isEmpty()
+                && stNzydk.getDkBh() != null && !stNzydk.getDkBh().isEmpty()) {
+            Pewg pewgUpdate = new Pewg();
+            if (stNzydk.getPch() != null) pewgUpdate.setPch(stNzydk.getPch());
+            if (stNzydk.getDkMc() != null) pewgUpdate.setDkMc(stNzydk.getDkMc());
+            if (stNzydk.getXzz() != null) pewgUpdate.setXzz(stNzydk.getXzz());
+            if (stNzydk.getDkYt() != null) pewgUpdate.setDkYt(stNzydk.getDkYt());
+            if (stNzydk.getTdZl() != null) pewgUpdate.setTdZl(stNzydk.getTdZl());
+            if (stNzydk.getDkMj() != null) pewgUpdate.setDkMj(stNzydk.getDkMj());
+            if (stNzydk.getDkQs() != null) pewgUpdate.setDkQs(stNzydk.getDkQs());
+            if (stNzydk.getLx() != null) pewgUpdate.setLx(stNzydk.getLx());
+            if (stNzydk.getPwh() != null) pewgUpdate.setPwh(stNzydk.getPwh());
+            if (stNzydk.getPzrq() != null) pewgUpdate.setPzrq(stNzydk.getPzrq());
+            if (stNzydk.getPzMj() != null) pewgUpdate.setPzMj(stNzydk.getPzMj());
+            if (stNzydk.getNmjf() != null) pewgUpdate.setNmjf(stNzydk.getNmjf());
+            if (stNzydk.getBz() != null) pewgUpdate.setBz(stNzydk.getBz());
+            QueryWrapper<Pewg> pewgWrapper = new QueryWrapper<>();
+            pewgWrapper.eq("pcbh", stNzydk.getPcbh());
+            pewgWrapper.eq("dk_bh", stNzydk.getDkBh());
+            pewgService.update(pewgUpdate, pewgWrapper);
+        }
+        return result(nzyUpdate);
     }
 
     /**
@@ -204,6 +232,9 @@ public class StNzydkController extends BaseRestController {
                                @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date pzrq,
                                @RequestParam(required = false) BigDecimal pzmj,
                                @RequestParam(required = false) String nmjf) {
+        if (pcbh == null || pcbh.trim().isEmpty()) {
+            return result(false);
+        }
         // 构建更新条件
         QueryWrapper<StNzydk> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("pcbh", pcbh);
@@ -228,8 +259,33 @@ public class StNzydkController extends BaseRestController {
         if (nmjf != null && !nmjf.isEmpty()) {
             updateEntity.setNmjf(nmjf);
         }
-        return result(stNzydkService.update(updateEntity, queryWrapper));
-    }
+        boolean nzyUpdate = stNzydkService.update(updateEntity, queryWrapper);
 
+        // 同步更新pewg表
+        Pewg pewgUpdate = new Pewg();
+        if (pch != null && !pch.isEmpty()) {
+            pewgUpdate.setPch(pch);
+        }
+        if (lx != null && !lx.isEmpty()) {
+            pewgUpdate.setLx(lx);
+        }
+        if (pwh != null && !pwh.isEmpty()) {
+            pewgUpdate.setPwh(pwh);
+        }
+        if (pzrq != null) {
+            pewgUpdate.setPzrq(pzrq);
+        }
+        if (pzmj != null) {
+            pewgUpdate.setPzMj(pzmj);
+        }
+        if (nmjf != null && !nmjf.isEmpty()) {
+            pewgUpdate.setNmjf(nmjf);
+        }
+        QueryWrapper<Pewg> pewgWrapper = new QueryWrapper<>();
+        pewgWrapper.eq("pcbh", pcbh);
+        boolean pewgUpdateResult = pewgService.update(pewgUpdate, pewgWrapper);
+
+        return result(nzyUpdate && pewgUpdateResult);
+    }
 
 }