Browse Source

添加删除功能接口

DESKTOP-2K9OVK9\siwei 4 months ago
parent
commit
abfbe2014b

+ 25 - 26
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/controller/supervise/TSupervisePcsjController.java

@@ -19,37 +19,35 @@ import java.util.List;
 
 /**
  * 监管批次数据Controller
- * 
+ *
  * @author zhx
  * @date 2024-09-26
  */
 @RestController
 @RequestMapping("/supervise/pcsj")
-public class TSupervisePcsjController extends BaseController
-{
+public class TSupervisePcsjController extends BaseController {
     @Autowired
     private ITSupervisePcsjService tSupervisePcsjService;
 
     /**
      * 查询监管批次数据列表
      */
-      //@RequiresPermissions("supervise:pcsj:list")
+    //@RequiresPermissions("supervise:pcsj:list")
     @GetMapping("/list")
-    public TableDataInfo list(TSupervisePcsj tSupervisePcsj)
-    {
+    public TableDataInfo list(TSupervisePcsj tSupervisePcsj) {
         startPage();
 //        tSupervisePcsj.setUploaduser(SecurityUtils.getUsername());
         String xzqdm_query = tSupervisePcsj.getXzqdm();
         String xzq = SecurityUtils.getLoginUserXzq();
-        if (StringUtils.isNotEmpty(xzqdm_query)&&StringUtils.isNotEmpty(xzq)&&!"0".equals(xzq)){
-            if(xzqdm_query.indexOf(xzq)!=0){
+        if (StringUtils.isNotEmpty(xzqdm_query) && StringUtils.isNotEmpty(xzq) && !"0".equals(xzq)) {
+            if (xzqdm_query.indexOf(xzq) != 0) {
                 TableDataInfo rspData = new TableDataInfo();
                 rspData.setCode(HttpStatus.BAD_REQUEST);
                 rspData.setMsg("参数有问题");
                 return rspData;
             }
         }
-        if (StringUtils.isEmpty(xzqdm_query)){
+        if (StringUtils.isEmpty(xzqdm_query)) {
             tSupervisePcsj.setXzqdm(xzq);
         }
         List<TSupervisePcsj> list = tSupervisePcsjService.selectTSupervisePcsjList(tSupervisePcsj);
@@ -59,11 +57,10 @@ public class TSupervisePcsjController extends BaseController
     /**
      * 导出监管批次数据列表
      */
-      //@RequiresPermissions("supervise:pcsj:export")
+    //@RequiresPermissions("supervise:pcsj:export")
     @Log(title = "监管批次数据", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, TSupervisePcsj tSupervisePcsj)
-    {
+    public void export(HttpServletResponse response, TSupervisePcsj tSupervisePcsj) {
         List<TSupervisePcsj> list = tSupervisePcsjService.selectTSupervisePcsjList(tSupervisePcsj);
         ExcelUtil<TSupervisePcsj> util = new ExcelUtil<TSupervisePcsj>(TSupervisePcsj.class);
         util.exportExcel(response, list, "监管批次数据数据");
@@ -72,43 +69,45 @@ public class TSupervisePcsjController extends BaseController
     /**
      * 获取监管批次数据详细信息
      */
-      //@RequiresPermissions("supervise:pcsj:query")
+    //@RequiresPermissions("supervise:pcsj:query")
     @GetMapping(value = "/{id}")
-    public AjaxResult getInfo(@PathVariable("id") String id)
-    {
+    public AjaxResult getInfo(@PathVariable("id") String id) {
         return success(tSupervisePcsjService.selectTSupervisePcsjById(id));
     }
 
     /**
      * 新增监管批次数据
      */
-      //@RequiresPermissions("supervise:pcsj:add")
+    //@RequiresPermissions("supervise:pcsj:add")
     @Log(title = "监管批次数据", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody TSupervisePcsj tSupervisePcsj)
-    {
+    public AjaxResult add(@RequestBody TSupervisePcsj tSupervisePcsj) {
         return toAjax(tSupervisePcsjService.insertTSupervisePcsj(tSupervisePcsj));
     }
 
     /**
      * 修改监管批次数据
      */
-      //@RequiresPermissions("supervise:pcsj:edit")
+    //@RequiresPermissions("supervise:pcsj:edit")
     @Log(title = "监管批次数据", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody TSupervisePcsj tSupervisePcsj)
-    {
+    public AjaxResult edit(@RequestBody TSupervisePcsj tSupervisePcsj) {
         return toAjax(tSupervisePcsjService.updateTSupervisePcsj(tSupervisePcsj));
     }
 
     /**
      * 删除监管批次数据
      */
-      //@RequiresPermissions("supervise:pcsj:remove")
+    //@RequiresPermissions("supervise:pcsj:remove")
+//    @Log(title = "监管批次数据", businessType = BusinessType.DELETE)
+//	@DeleteMapping("/{ids}")
+//    public AjaxResult remove(@PathVariable String[] ids)
+//    {
+//        return toAjax(tSupervisePcsjService.deleteTSupervisePcsjByIds(ids));
+//    }
     @Log(title = "监管批次数据", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{ids}")
-    public AjaxResult remove(@PathVariable String[] ids)
-    {
-        return toAjax(tSupervisePcsjService.deleteTSupervisePcsjByIds(ids));
+    @DeleteMapping("/{id}")
+    public AjaxResult removeId(@PathVariable("id") String id) {
+        return toAjax(tSupervisePcsjService.removeTSupervisePcsjById(id));
     }
 }

+ 14 - 9
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/mapper/supervise/TSupervisePcsjMapper.java

@@ -1,20 +1,20 @@
 package com.onemap.apply.mapper.supervise;
 
 import com.onemap.apply.domain.supervise.TSupervisePcsj;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
 /**
  * 监管批次数据Mapper接口
- * 
+ *
  * @author zhx
  * @date 2024-09-26
  */
-public interface TSupervisePcsjMapper 
-{
+public interface TSupervisePcsjMapper {
     /**
      * 查询监管批次数据
-     * 
+     *
      * @param id 监管批次数据主键
      * @return 监管批次数据
      */
@@ -22,7 +22,7 @@ public interface TSupervisePcsjMapper
 
     /**
      * 查询监管批次数据列表
-     * 
+     *
      * @param tSupervisePcsj 监管批次数据
      * @return 监管批次数据集合
      */
@@ -30,7 +30,7 @@ public interface TSupervisePcsjMapper
 
     /**
      * 新增监管批次数据
-     * 
+     *
      * @param tSupervisePcsj 监管批次数据
      * @return 结果
      */
@@ -38,16 +38,17 @@ public interface TSupervisePcsjMapper
 
     /**
      * 修改监管批次数据
-     * 
+     *
      * @param tSupervisePcsj 监管批次数据
      * @return 结果
      */
     public int updateTSupervisePcsj(TSupervisePcsj tSupervisePcsj);
+
     public int updateTSupervisePcsjByRead(TSupervisePcsj tSupervisePcsj);
 
     /**
      * 删除监管批次数据
-     * 
+     *
      * @param id 监管批次数据主键
      * @return 结果
      */
@@ -55,9 +56,13 @@ public interface TSupervisePcsjMapper
 
     /**
      * 批量删除监管批次数据
-     * 
+     *
      * @param ids 需要删除的数据主键集合
      * @return 结果
      */
     public int deleteTSupervisePcsjByIds(String[] ids);
+
+    public int removePcsjById(@Param("id") String id, @Param("removeuser") String removeuser, @Param("unzippath") String unzippath, @Param("filepath") String filepath);
+
+    public int deletPcsjXqById(@Param("id") String id, @Param("sjy") String sjy);
 }

+ 3 - 0
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/service/supervise/ITSupervisePcsjService.java

@@ -60,4 +60,7 @@ public interface ITSupervisePcsjService
      * @return 结果
      */
     public int deleteTSupervisePcsjById(String id);
+
+
+    public int removeTSupervisePcsjById(String id);
 }

+ 65 - 25
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/service/supervise/impl/TSupervisePcsjServiceImpl.java

@@ -1,104 +1,144 @@
 package com.onemap.apply.service.supervise.impl;
 
 import com.onemap.apply.domain.supervise.TSupervisePcsj;
+import com.onemap.apply.domain.supervise.TSuperviseYwlxDo;
 import com.onemap.apply.mapper.supervise.TSupervisePcsjMapper;
+import com.onemap.apply.mapper.supervise.TSuperviseYwlxMapper;
 import com.onemap.apply.service.supervise.ITSupervisePcsjService;
+import com.onemap.common.core.utils.StringUtils;
+import com.onemap.common.security.utils.SecurityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
 import java.util.List;
 
 /**
  * 监管批次数据Service业务层处理
- * 
+ *
  * @author zhx
  * @date 2024-09-26
  */
 @Service
-public class TSupervisePcsjServiceImpl implements ITSupervisePcsjService 
-{
+public class TSupervisePcsjServiceImpl implements ITSupervisePcsjService {
     @Autowired
     private TSupervisePcsjMapper tSupervisePcsjMapper;
+    @Autowired
+    private TSuperviseYwlxMapper tSuperviseYwlxMapper;
 
     /**
      * 查询监管批次数据
-     * 
+     *
      * @param id 监管批次数据主键
      * @return 监管批次数据
      */
     @Override
-    public TSupervisePcsj selectTSupervisePcsjById(String id)
-    {
+    public TSupervisePcsj selectTSupervisePcsjById(String id) {
         return tSupervisePcsjMapper.selectTSupervisePcsjById(id);
     }
 
     /**
      * 查询监管批次数据列表
-     * 
+     *
      * @param tSupervisePcsj 监管批次数据
      * @return 监管批次数据
      */
     @Override
-    public List<TSupervisePcsj> selectTSupervisePcsjList(TSupervisePcsj tSupervisePcsj)
-    {
+    public List<TSupervisePcsj> selectTSupervisePcsjList(TSupervisePcsj tSupervisePcsj) {
         return tSupervisePcsjMapper.selectTSupervisePcsjList(tSupervisePcsj);
     }
 
 
-
     /**
      * 新增监管批次数据
-     * 
+     *
      * @param tSupervisePcsj 监管批次数据
      * @return 结果
      */
     @Override
-    public int insertTSupervisePcsj(TSupervisePcsj tSupervisePcsj)
-    {
+    public int insertTSupervisePcsj(TSupervisePcsj tSupervisePcsj) {
         return tSupervisePcsjMapper.insertTSupervisePcsj(tSupervisePcsj);
     }
 
     /**
      * 修改监管批次数据
-     * 
+     *
      * @param tSupervisePcsj 监管批次数据
      * @return 结果
      */
     @Override
-    public int updateTSupervisePcsj(TSupervisePcsj tSupervisePcsj)
-    {
+    public int updateTSupervisePcsj(TSupervisePcsj tSupervisePcsj) {
         return tSupervisePcsjMapper.updateTSupervisePcsj(tSupervisePcsj);
     }
 
     @Override
-    public int updateTSupervisePcsjByRead(TSupervisePcsj tSupervisePcsj)
-    {
+    public int updateTSupervisePcsjByRead(TSupervisePcsj tSupervisePcsj) {
         return tSupervisePcsjMapper.updateTSupervisePcsjByRead(tSupervisePcsj);
     }
 
 
-
     /**
      * 批量删除监管批次数据
-     * 
+     *
      * @param ids 需要删除的监管批次数据主键
      * @return 结果
      */
     @Override
-    public int deleteTSupervisePcsjByIds(String[] ids)
-    {
+    public int deleteTSupervisePcsjByIds(String[] ids) {
         return tSupervisePcsjMapper.deleteTSupervisePcsjByIds(ids);
     }
 
     /**
      * 删除监管批次数据信息
-     * 
+     *
      * @param id 监管批次数据主键
      * @return 结果
      */
     @Override
-    public int deleteTSupervisePcsjById(String id)
-    {
+    public int deleteTSupervisePcsjById(String id) {
         return tSupervisePcsjMapper.deleteTSupervisePcsjById(id);
     }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int removeTSupervisePcsjById(String id) {
+        TSupervisePcsj d0 = tSupervisePcsjMapper.selectTSupervisePcsjById(id);
+        if (d0 == null) {
+            return 0;
+        }
+        String d0_unzippath = d0.getUnzippath();
+        String d0_filepath = d0.getFilepath();
+        int d1_unzip_len = d0_unzippath.lastIndexOf("/");
+        int d1_filepath = d0_filepath.lastIndexOf("/");
+        String d2_unzippath = d0_unzippath.substring(0, d1_unzip_len) + "/REMOVE" + d0_unzippath.substring(d1_unzip_len);
+        String d2_filepath = d0_filepath.substring(0, d1_filepath) + "/REMOVE" + d0_filepath.substring(d1_filepath);
+
+        try {
+            if (new File(d0_unzippath).exists()) {
+                Files.move(Paths.get(d0_unzippath), Paths.get(d2_unzippath));
+            }
+            if (new File(d0_filepath).exists()) {
+                Files.move(Paths.get(d0_filepath), Paths.get(d2_filepath));
+            }
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+        String ywlxCode = d0.getName().substring(0, 2);
+        TSuperviseYwlxDo d1 = tSuperviseYwlxMapper.selectTSuperviseYwlxByYwlx(ywlxCode);
+        if (d1 != null) {
+            String d2_sjy = d1.getSjy();
+            tSupervisePcsjMapper.deletPcsjXqById(id, d2_sjy);
+        }
+        String username = SecurityUtils.getUsername();
+        if (StringUtils.isEmpty(username)) {
+            username = "admin";
+        }
+        tSupervisePcsjMapper.removePcsjById(id, username, d2_unzippath, d2_filepath);
+        tSupervisePcsjMapper.deleteTSupervisePcsjById(id);
+        return 1;
+    }
 }

+ 16 - 2
onemap-modules/onemap-apply/src/main/resources/mapper/postgresql/supervise/TSupervisePcsjMapper.xml

@@ -60,8 +60,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="readsign != null"> and readsign = #{readsign}</if>
             <if test="readstatus != null"> and readstatus = #{readstatus}</if>
             <if test="filetime != null"> and filetime = #{filetime}</if>
-            <if test="beginTime != null"> and filetime &gt;= #{beginTime}</if>
-            <if test="endTime != null"> and filetime &lt;= #{endTime}</if>
+            <if test="beginTime != null"> and to_date(filetime,'yyyymmdd') &gt;= to_date(#{beginTime},'yyyy-mm-dd')</if>
+            <if test="endTime != null"> and to_date(filetime,'yyyymmdd') &lt;= to_date(#{endTime},'yyyy-mm-dd')</if>
         </where>
         order by uploadtime desc
         )t0 left join sys_dept t1 on t1.district = t0.xzqdm
@@ -157,4 +157,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{id}
         </foreach>
     </delete>
+
+    <delete id="removePcsjById" parameterType="String">
+        insert into t_spotfile_remove(
+        id,name,uploaduser,uploadtime,filepath,shppath,proxypath,unzippath,filetype,storage,status,xzqdm,readstatus,readmessage,readsign,filetime,readtime,envelopegeom,spotsnumber,spotsarea,
+        spotssize,removeuser,removetime
+        )
+        select id,name,uploaduser,uploadtime,#{filepath} filepath,shppath,proxypath,#{unzippath} unzippath,filetype,storage,status,xzqdm,readstatus,readmessage,readsign,filetime,readtime,envelopegeom,spotsnumber,spotsarea,
+        spotssize,#{removeuser} removeuser,now()
+        from t_spotfile where id = #{id}
+    </delete>
+
+    <delete id="deletPcsjXqById" parameterType="String">
+        delete from "${sjy}" where pcsjid = #{id}
+    </delete>
 </mapper>