|
@@ -4,17 +4,16 @@ import com.welampiot.common.BaseResult;
|
|
|
import com.welampiot.common.InterfaceResultEnum;
|
|
|
import com.welampiot.dto.*;
|
|
|
import com.welampiot.service.*;
|
|
|
+import com.welampiot.utils.ExcelUtil;
|
|
|
import com.welampiot.utils.ToolUtils;
|
|
|
import com.welampiot.vo.*;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.CrossOrigin;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* ClassName: CityAdminCaseController
|
|
@@ -296,4 +295,121 @@ public class CityAdminCaseController {
|
|
|
cityAdminCaseImageVO.setList(list);
|
|
|
return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,cityAdminCaseImageVO);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量导入案件
|
|
|
+ * @param vo 案件信息
|
|
|
+ * @return 批量导入案件
|
|
|
+ */
|
|
|
+ @PostMapping("/batchInput")
|
|
|
+ private BaseResult<?> batchInput(CityAdminCaseInfoVO vo) {
|
|
|
+ int version = vo.getVersion() == null ? 0 : vo.getVersion();
|
|
|
+ Integer streetId = vo.getStreetId();
|
|
|
+ Integer areaId = vo.getAreaId();
|
|
|
+ Integer type = vo.getType();
|
|
|
+ if (streetId == null || streetId == 0 || areaId == null || areaId == 0)
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+ MultipartFile file = vo.getFile();
|
|
|
+ if (type == 1) { // 验证
|
|
|
+ if (file.isEmpty()) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+ List<Map> maps = ExcelUtil.inExcel(file);
|
|
|
+ List<Object> msg = new ArrayList<>();
|
|
|
+ List<CityAdminCaseInfoDTO> caseData = new ArrayList<>();
|
|
|
+ int index = 1;
|
|
|
+ if (maps.size() > 0) {
|
|
|
+ for (Map m : maps) {
|
|
|
+ CityAdminCaseInfoDTO cityAdminCaseInfoDTO = new CityAdminCaseInfoDTO();
|
|
|
+ String startDate = m.get(0).toString();
|
|
|
+ String problemSourceStr = m.get(1).toString();
|
|
|
+ Set<String> sourceSet = new HashSet<>(Arrays.asList("采集上报","公众举报","视频上报","微信上报","领导交办"));
|
|
|
+ if (!sourceSet.contains(problemSourceStr)) msg.add("表格第" + index + "行问题来源类型错误");
|
|
|
+ Integer problemSource = CityAdminCaseInfoDTO.getProblemSourceByStr(problemSourceStr);
|
|
|
+ String problemLevelStr = m.get(2).toString();
|
|
|
+ Set<String> levelSet = new HashSet<>(Arrays.asList("日常","一般","严重","重大"));
|
|
|
+ if (!levelSet.contains(problemLevelStr)) msg.add("表格第" + index + "行问题级别错误");
|
|
|
+ Integer problemLevel = CityAdminCaseInfoDTO.getProblemLevelByStr(problemLevelStr);
|
|
|
+ String bigCase = m.get(3).toString();
|
|
|
+ String smallCase = m.get(4).toString();
|
|
|
+ String area = m.get(5).toString();
|
|
|
+ String street = m.get(6).toString();
|
|
|
+ String community = m.get(7).toString();
|
|
|
+ String grid = m.get(8).toString();
|
|
|
+ String remark = m.get(9).toString();
|
|
|
+ String location = m.get(10).toString();
|
|
|
+ String phone = m.get(12).toString();
|
|
|
+ String name = m.get(11).toString();
|
|
|
+ String isBack = m.get(13).toString();
|
|
|
+ if (isBack.equals("是")) {
|
|
|
+ cityAdminCaseInfoDTO.setIsBack(1);
|
|
|
+ } else {
|
|
|
+ cityAdminCaseInfoDTO.setIsBack(0);
|
|
|
+ }
|
|
|
+ String backPhone = m.get(14).toString();
|
|
|
+ String sax = m.get(15).toString();
|
|
|
+ if (sax.equals("男")) {
|
|
|
+ cityAdminCaseInfoDTO.setSax(1);
|
|
|
+ } else {
|
|
|
+ cityAdminCaseInfoDTO.setSax(0);
|
|
|
+ }
|
|
|
+ cityAdminCaseInfoDTO.setStartDate(startDate);
|
|
|
+ cityAdminCaseInfoDTO.setProblemSource(problemSource);
|
|
|
+ cityAdminCaseInfoDTO.setProblemLevel(problemLevel);
|
|
|
+ cityAdminCaseInfoDTO.setCaseBigName(bigCase);
|
|
|
+ cityAdminCaseInfoDTO.setCaseSmallName(smallCase);
|
|
|
+ cityAdminCaseInfoDTO.setArea(area);
|
|
|
+ cityAdminCaseInfoDTO.setStreet(street);
|
|
|
+ cityAdminCaseInfoDTO.setCommunity(community);
|
|
|
+ cityAdminCaseInfoDTO.setGrid(grid);
|
|
|
+ cityAdminCaseInfoDTO.setPhone(phone);
|
|
|
+ cityAdminCaseInfoDTO.setName(name);
|
|
|
+ cityAdminCaseInfoDTO.setBackPhone(backPhone);
|
|
|
+ cityAdminCaseInfoDTO.setRemark(remark);
|
|
|
+ cityAdminCaseInfoDTO.setLocation(location);
|
|
|
+
|
|
|
+ CityAdminAreaDTO cityStreet = cityAdminAreaService.getAreaOrStreetByName(street);
|
|
|
+ if (cityStreet != null) {
|
|
|
+ cityAdminCaseInfoDTO.setStreetId(cityStreet.getId());
|
|
|
+ } else {
|
|
|
+ msg.add("表格第" + index + "行街道(镇)错误");
|
|
|
+ }
|
|
|
+ CityAdminAreaDTO cityArea = cityAdminAreaService.getAreaOrStreetByName(area);
|
|
|
+ if (cityArea != null) {
|
|
|
+ cityAdminCaseInfoDTO.setAreaId(cityArea.getId());
|
|
|
+ } else {
|
|
|
+ msg.add("表格第" + index + "行区域错误");
|
|
|
+ }
|
|
|
+ CityAdminCaseItemDTO bigCaseItem = cityAdminCaseItemService.getCaseByName(bigCase);
|
|
|
+ if (bigCaseItem != null) {
|
|
|
+ cityAdminCaseInfoDTO.setCaseBigId(bigCaseItem.getId());
|
|
|
+ } else {
|
|
|
+ msg.add("表格第" + index + "行大案件错误");
|
|
|
+ }
|
|
|
+ CityAdminCaseItemDTO smallCaseItem = cityAdminCaseItemService.getCaseByName(smallCase);
|
|
|
+ if (smallCaseItem != null) {
|
|
|
+ cityAdminCaseInfoDTO.setCaseSmallId(smallCaseItem.getId());
|
|
|
+ } else {
|
|
|
+ msg.add("表格第" + index + "行小案件错误");
|
|
|
+ }
|
|
|
+ caseData.add(cityAdminCaseInfoDTO);
|
|
|
+
|
|
|
+ index ++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ CityAdminCaseInfoVO cityAdminCaseInfoVO = new CityAdminCaseInfoVO();
|
|
|
+ cityAdminCaseInfoVO.setMsg(msg);
|
|
|
+ cityAdminCaseInfoVO.setCaseData(caseData);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,cityAdminCaseInfoVO);
|
|
|
+ } else { // 创建
|
|
|
+ List<CityAdminCaseInfoDTO> caseData = vo.getCaseData();
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ for (CityAdminCaseInfoDTO dto : caseData) {
|
|
|
+ long l = System.currentTimeMillis();
|
|
|
+ String createTime = format.format(l);
|
|
|
+ dto.setCreateTime(createTime);
|
|
|
+ cityAdminCaseInfoService.addCityAdminCaseInfoData(dto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
+ }
|
|
|
}
|