|
@@ -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;
|
|
|
+ }
|
|
|
}
|