|
@@ -1,15 +1,15 @@
|
|
package com.bootdo.datas.controller;
|
|
package com.bootdo.datas.controller;
|
|
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
import com.bootdo.common.annotation.Log;
|
|
import com.bootdo.common.annotation.Log;
|
|
-import com.bootdo.common.utils.PageUtils;
|
|
|
|
-import com.bootdo.common.utils.Query;
|
|
|
|
-import com.bootdo.common.utils.R;
|
|
|
|
|
|
+import com.bootdo.common.utils.*;
|
|
|
|
|
|
-import com.bootdo.common.utils.StringUtils;
|
|
|
|
|
|
+import com.bootdo.datas.domain.GyDataExcelDO;
|
|
import com.bootdo.datas.dto.GyDataImportDTO;
|
|
import com.bootdo.datas.dto.GyDataImportDTO;
|
|
import com.bootdo.datas.service.GyDataService;
|
|
import com.bootdo.datas.service.GyDataService;
|
|
|
|
|
|
|
|
+import com.bootdo.datas.tools.ExcelUtils;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
@@ -17,8 +17,12 @@ import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.ui.Model;
|
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -32,7 +36,7 @@ public class DataSendProvinceController {
|
|
private GyDataService gyDataService;
|
|
private GyDataService gyDataService;
|
|
|
|
|
|
@GetMapping()
|
|
@GetMapping()
|
|
- @Log("访问送审省级")
|
|
|
|
|
|
+ @Log("访问上报到省级")
|
|
@RequiresPermissions("datas:dataSendProvince:data")
|
|
@RequiresPermissions("datas:dataSendProvince:data")
|
|
String Data() {
|
|
String Data() {
|
|
return "datas/dataSendProvince/data";
|
|
return "datas/dataSendProvince/data";
|
|
@@ -65,15 +69,15 @@ public class DataSendProvinceController {
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
- * @Description: 送审
|
|
|
|
|
|
+ * @Description: 上报到省级
|
|
*/
|
|
*/
|
|
- @PostMapping("/sendVerify")
|
|
|
|
|
|
+ @PostMapping("/sendProvince")
|
|
@ResponseBody
|
|
@ResponseBody
|
|
- @RequiresPermissions("datas:dataSendProvince:sendVerify")
|
|
|
|
- public R sendVerify(@RequestParam("ids[]") Long[] ids) {
|
|
|
|
- log.info("送审 ids:" + ids.toString());
|
|
|
|
|
|
+ @RequiresPermissions("datas:dataSendProvince:sendProvince")
|
|
|
|
+ public R sendProvince(@RequestParam("ids[]") Long[] ids) {
|
|
|
|
+ log.info("上报到省级 ids:" + ids.toString());
|
|
for (Long id : ids) {
|
|
for (Long id : ids) {
|
|
- log.info("送审 id:" + id);
|
|
|
|
|
|
+ log.info("上报到省级 id:" + id);
|
|
GyDataImportDTO data = new GyDataImportDTO();
|
|
GyDataImportDTO data = new GyDataImportDTO();
|
|
// 判断是否已审核过
|
|
// 判断是否已审核过
|
|
data = gyDataService.get(id);
|
|
data = gyDataService.get(id);
|
|
@@ -93,6 +97,140 @@ public class DataSendProvinceController {
|
|
return R.ok();
|
|
return R.ok();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * @Description: 加密导出
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/encryptExports")
|
|
|
|
+ @RequiresPermissions("datas:dataSendProvince:encryptExports")
|
|
|
|
+ public void encryptExports(HttpServletResponse responses, String idValue) throws Exception {
|
|
|
|
+ log.info("批量导出 备案主键 idvalue:" + idValue);
|
|
|
|
+ // 导出xlsx操作
|
|
|
|
+ try {
|
|
|
|
+ gyDataService.encryptExports(responses,idValue);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("export error", e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @Description: 批量导出
|
|
|
|
+ * @Author: wangp
|
|
|
|
+ * @Date: 2022/3/16 10:46
|
|
|
|
+ * @param idValue
|
|
|
|
+ * @Return: R
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/batchExports")
|
|
|
|
+ @RequiresPermissions("datas:dataSendProvince:export")
|
|
|
|
+ public void batchExports(HttpServletResponse responses, String idValue) {
|
|
|
|
+ log.info("批量导出 备案主键 idvalue:" + idValue);
|
|
|
|
+ List<GyDataExcelDO> list = new ArrayList<>();
|
|
|
|
+ JSONArray json = (JSONArray)JSONArray.parse(idValue);
|
|
|
|
+ for (int i = 0; i < json.size(); i++) {
|
|
|
|
+ String id = String.valueOf(json.get(i));
|
|
|
|
+ log.info("批量导出 id:" + json.get(i));
|
|
|
|
+ GyDataExcelDO data = new GyDataExcelDO();
|
|
|
|
+ data = gyDataService.getDataExcel(Long.parseLong(id));
|
|
|
|
+ data.setNo(i + 1); //序号
|
|
|
|
+ list.add(data);
|
|
|
|
+ }
|
|
|
|
+ log.info("list size:" + list.size());
|
|
|
|
+ // 导出xlsx操作
|
|
|
|
+ try {
|
|
|
|
+ ExcelUtils.export(responses, GyDataExcelDO.class, list, "上报到省级备案导出信息");
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("export error", e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @Description: 跳转批量导入页面
|
|
|
|
+ * @Author: wangp
|
|
|
|
+ * @Date: 2022/3/21 10:06
|
|
|
|
+ * @param
|
|
|
|
+ * @Return: String
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/dataImport")
|
|
|
|
+ @RequiresPermissions("datas:dataSendProvince:plainTextImport")
|
|
|
|
+ String dataImport() {
|
|
|
|
+ return "datas/dataSendProvince/dataImport";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @Description: 明文导入
|
|
|
|
+ * @Author: wangp
|
|
|
|
+ * @Date: 2022/6/10 15:01
|
|
|
|
+ * @param file
|
|
|
|
+ * @Return: R
|
|
|
|
+ */
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @PostMapping("/plainTextImport")
|
|
|
|
+ @RequiresPermissions("datas:dataSendProvince:plainTextImport")
|
|
|
|
+ public R plainTextImport(@RequestParam("data_file") MultipartFile file) {
|
|
|
|
+ try {
|
|
|
|
+ String fileName = file.getOriginalFilename();
|
|
|
|
+ log.info("fileName:" + fileName);
|
|
|
|
+ String type = fileName.substring(fileName.lastIndexOf(".") + 1);
|
|
|
|
+ // 根据excel类型取数据
|
|
|
|
+ if ("xlsx".equals(type) || "xlsx".equals(type)) {
|
|
|
|
+ String reault = gyDataService.plainTextImport(file, 3);
|
|
|
|
+ if (!ObjectUtils.isEmpty(reault)) {
|
|
|
|
+ return R.ok(fileName + ":" + reault);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ return R.error("请使用excel导入!");
|
|
|
|
+ }
|
|
|
|
+ return R.ok();
|
|
|
|
+ } catch (BDException e){
|
|
|
|
+ return R.error(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @Description: 跳转批量导入页面
|
|
|
|
+ * @Author: wangp
|
|
|
|
+ * @Date: 2022/3/21 10:06
|
|
|
|
+ * @param
|
|
|
|
+ * @Return: String
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/batchAdd")
|
|
|
|
+ @RequiresPermissions("datas:dataSendProvince:add")
|
|
|
|
+ String batchAdd() {
|
|
|
|
+ return "datas/dataSendProvince/batchAdd";
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 密文导入
|
|
|
|
+ */
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @PostMapping("/save")
|
|
|
|
+ @RequiresPermissions("datas:dataSendProvince:add")
|
|
|
|
+ public R save(@RequestParam("data_file") MultipartFile file) {
|
|
|
|
+ try {
|
|
|
|
+ String fileName = file.getOriginalFilename();
|
|
|
|
+ log.info("fileName:" + fileName);
|
|
|
|
+ String type = fileName.substring(fileName.lastIndexOf(".") + 1);
|
|
|
|
+ // 根据excel类型取数据
|
|
|
|
+ if ("xlsx".equals(type) || "xlsx".equals(type)) {
|
|
|
|
+ // dataService.save(file);
|
|
|
|
+ // 文件解密
|
|
|
|
+ String decFlg = gyDataService.dec(file);
|
|
|
|
+ log.info("decFlg:" + decFlg);
|
|
|
|
+ if (StringUtils.isNotBlank(decFlg)) {
|
|
|
|
+ String reault = gyDataService.cipherTextImport(decFlg, 3);
|
|
|
|
+ if (!ObjectUtils.isEmpty(reault)) {
|
|
|
|
+ return R.ok(fileName + ":" + reault);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ return R.error("文件解密异常!");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ return R.error("请使用excel导入!");
|
|
|
|
+ }
|
|
|
|
+ return R.ok();
|
|
|
|
+ } catch (BDException e){
|
|
|
|
+ return R.error(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|