|
@@ -1,5 +1,6 @@
|
|
package com.ruoyi.gas.controller;
|
|
package com.ruoyi.gas.controller;
|
|
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
import com.ruoyi.common.annotation.Log;
|
|
import com.ruoyi.common.annotation.Log;
|
|
import com.ruoyi.common.annotation.RepeatSubmit;
|
|
import com.ruoyi.common.annotation.RepeatSubmit;
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
@@ -12,6 +13,7 @@ import com.ruoyi.common.enums.BusinessType;
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
import com.ruoyi.gas.domain.bo.GValveWellPositionBo;
|
|
import com.ruoyi.gas.domain.bo.GValveWellPositionBo;
|
|
import com.ruoyi.gas.domain.vo.GValveWellPositionVo;
|
|
import com.ruoyi.gas.domain.vo.GValveWellPositionVo;
|
|
|
|
+import com.ruoyi.gas.domain.vo.GWellPositionImportVo;
|
|
import com.ruoyi.gas.service.IGValveWellPositionService;
|
|
import com.ruoyi.gas.service.IGValveWellPositionService;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -20,12 +22,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.validation.constraints.NotEmpty;
|
|
import javax.validation.constraints.NotEmpty;
|
|
import javax.validation.constraints.NotNull;
|
|
import javax.validation.constraints.NotNull;
|
|
-import java.util.Arrays;
|
|
|
|
-import java.util.List;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 阀井位置Controller
|
|
* 阀井位置Controller
|
|
@@ -110,4 +112,61 @@ public class GValveWellPositionController extends BaseController {
|
|
@PathVariable Long[] ids) {
|
|
@PathVariable Long[] ids) {
|
|
return toAjax(iGValveWellPositionService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
|
|
return toAjax(iGValveWellPositionService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private String bfb="0";
|
|
|
|
+ private String message;
|
|
|
|
+
|
|
|
|
+ @GetMapping("/importTemplate")
|
|
|
|
+ @Log(title = "下载导入模板", businessType = BusinessType.EXPORT)
|
|
|
|
+ public void importTemplate(HttpServletResponse response) {
|
|
|
|
+ ExcelUtil.exportExcel(new ArrayList<>(), "阀井位置", GWellPositionImportVo.class, response);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Log(title = "导入小区列表", businessType = BusinessType.EXPORT)
|
|
|
|
+ @PostMapping("/importData")
|
|
|
|
+ public synchronized AjaxResult<Void> importData(@RequestPart("file") MultipartFile file, boolean updateSupport) throws Exception {
|
|
|
|
+ List<GWellPositionImportVo> listVo = ExcelUtil.importExcel(file.getInputStream(), GWellPositionImportVo.class);
|
|
|
|
+ List<GWellPositionImportVo> list = BeanUtil.copyToList(listVo, GWellPositionImportVo.class);
|
|
|
|
+ String operName = getUsername();
|
|
|
|
+ if(Double.valueOf(bfb)<=0){
|
|
|
|
+ forImportData(list,true,operName,0,0);
|
|
|
|
+ }
|
|
|
|
+ return AjaxResult.success(message);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void forImportData(List<GWellPositionImportVo> list, Boolean isUpdateSupport, String operName,int n,int successNum) throws Exception
|
|
|
|
+ {
|
|
|
|
+ try{
|
|
|
|
+ Map<String,Object> ret = iGValveWellPositionService.forImportData(list, isUpdateSupport, operName,n,successNum);//list, updateSupport, operName,第几条
|
|
|
|
+ if(Boolean.valueOf(ret.get("is_success").toString())){
|
|
|
|
+ bfb = ret.get("bfb").toString();
|
|
|
|
+ forImportData(list,isUpdateSupport,operName,Integer.valueOf(ret.get("n").toString()),Integer.valueOf(ret.get("successNum").toString()));
|
|
|
|
+ }else{
|
|
|
|
+ message = ret.get("successMsg").toString();
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ message = e.getMessage();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 进度条刷新,
|
|
|
|
+ */
|
|
|
|
+ @GetMapping(value = "/flushProgress")
|
|
|
|
+ public AjaxResult<Map> flushProgress() throws Exception
|
|
|
|
+ {
|
|
|
|
+ Map<String,String> ret = new HashMap<>();
|
|
|
|
+ ret.put("bfb",bfb);
|
|
|
|
+ ret.put("message",message);
|
|
|
|
+ return AjaxResult.success(ret);
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 结束进度条刷新,
|
|
|
|
+ */
|
|
|
|
+ @GetMapping(value = "/clearFlushProgress")
|
|
|
|
+ public AjaxResult<Void> clearFlushProgress() throws Exception
|
|
|
|
+ {
|
|
|
|
+ bfb="0";
|
|
|
|
+ message="";
|
|
|
|
+ return AjaxResult.success();
|
|
|
|
+ }
|
|
}
|
|
}
|