|
@@ -6,11 +6,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.qdport.annotation.WebLog;
|
|
import com.qdport.annotation.WebLog;
|
|
|
import com.qdport.core.tool.api.R;
|
|
import com.qdport.core.tool.api.R;
|
|
|
import com.qdport.core.tool.utils.DateUtil;
|
|
import com.qdport.core.tool.utils.DateUtil;
|
|
|
|
|
+import com.qdport.entity.PolicyShare;
|
|
|
import com.qdport.entity.PolicyStrive;
|
|
import com.qdport.entity.PolicyStrive;
|
|
|
import com.qdport.enums.QDPortEnum;
|
|
import com.qdport.enums.QDPortEnum;
|
|
|
import com.qdport.modules.system.entity.SysUser;
|
|
import com.qdport.modules.system.entity.SysUser;
|
|
|
import com.qdport.modules.system.service.TSysUserService;
|
|
import com.qdport.modules.system.service.TSysUserService;
|
|
|
-import com.qdport.service.PolicyLogService;
|
|
|
|
|
import com.qdport.service.PolicyShareService;
|
|
import com.qdport.service.PolicyShareService;
|
|
|
import com.qdport.service.PolicyStriveService;
|
|
import com.qdport.service.PolicyStriveService;
|
|
|
import com.qdport.service.impl.PolicySystemService;
|
|
import com.qdport.service.impl.PolicySystemService;
|
|
@@ -27,7 +27,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -46,6 +45,14 @@ public class ImportDataController {
|
|
|
private TSysUserService sysUserService;
|
|
private TSysUserService sysUserService;
|
|
|
@Resource
|
|
@Resource
|
|
|
private PolicySystemService policySystemService;
|
|
private PolicySystemService policySystemService;
|
|
|
|
|
+ private final static String errorMsg_null = "excel中缺失有效数据";
|
|
|
|
|
+ private final static String errorMsg_hang = "该行数据存在必填字段未输入";
|
|
|
|
|
+ private final static String errorMsg_docNo = "政策文号已经存在,请勿重复填写";
|
|
|
|
|
+ private final static String errorMsg_docNo_2 = "政策文号填写错误,查不到对应的政策分享数据";
|
|
|
|
|
+ private final static String errorMsg_createName = "填报人或者填报人联系方式填写错误";
|
|
|
|
|
+ private final static String errorMsg_yjTime = "预计完成时间格式填写错误";
|
|
|
|
|
+ private final static String errorMsg_sjTime = "实际完成时间格式填写错误";
|
|
|
|
|
+ private final static String errorMsg_businessNo = "项目编号填写错误,查不到对应的政策争取";
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/policyShare")
|
|
@PostMapping("/policyShare")
|
|
@@ -56,21 +63,34 @@ public class ImportDataController {
|
|
|
List<PolicyShareExcelVO> list = ExcelUtil.readPolicyShareFromXls(byteFromUrl);
|
|
List<PolicyShareExcelVO> list = ExcelUtil.readPolicyShareFromXls(byteFromUrl);
|
|
|
|
|
|
|
|
if (list.isEmpty()) {
|
|
if (list.isEmpty()) {
|
|
|
- throw new Exception("excel中缺失有效数据");
|
|
|
|
|
|
|
+ throw new Exception(errorMsg_null);
|
|
|
}
|
|
}
|
|
|
list = list.stream().filter(model -> StringUtil.isNotEmpty(model.getIndex())).collect(Collectors.toList());
|
|
list = list.stream().filter(model -> StringUtil.isNotEmpty(model.getIndex())).collect(Collectors.toList());
|
|
|
List<PolicyShareExcelVO> excelVOList = new ArrayList<>();
|
|
List<PolicyShareExcelVO> excelVOList = new ArrayList<>();
|
|
|
for (PolicyShareExcelVO model : list) {
|
|
for (PolicyShareExcelVO model : list) {
|
|
|
try {
|
|
try {
|
|
|
|
|
+ if (!StringUtil.checkFieldsNotEmpty(model)) {
|
|
|
|
|
+ throw new Exception(errorMsg_hang);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
PolicyShareVO shareVO = new PolicyShareVO();
|
|
PolicyShareVO shareVO = new PolicyShareVO();
|
|
|
BeanUtils.copyProperties(model, shareVO);
|
|
BeanUtils.copyProperties(model, shareVO);
|
|
|
|
|
|
|
|
shareVO.setStatus(QDPortEnum.POLICY_SHARE_STATUS_ACTIVE.getValue());
|
|
shareVO.setStatus(QDPortEnum.POLICY_SHARE_STATUS_ACTIVE.getValue());
|
|
|
|
|
|
|
|
|
|
+ QueryWrapper<PolicyShare> wrapper = new QueryWrapper<>();
|
|
|
|
|
+ wrapper.eq("DOC_NO", model.getDocNo());
|
|
|
|
|
+ long count = policyShareService.count(wrapper);
|
|
|
|
|
+ if (count > 0) {
|
|
|
|
|
+ throw new Exception(errorMsg_docNo);
|
|
|
|
|
+ }
|
|
|
QueryWrapper<SysUser> userWrapper = new QueryWrapper<>();
|
|
QueryWrapper<SysUser> userWrapper = new QueryWrapper<>();
|
|
|
userWrapper.eq("MOBILE", model.getContactPhone());
|
|
userWrapper.eq("MOBILE", model.getContactPhone());
|
|
|
userWrapper.eq("NAME", model.getCreateName());
|
|
userWrapper.eq("NAME", model.getCreateName());
|
|
|
SysUser createUser = sysUserService.getOne(userWrapper);
|
|
SysUser createUser = sysUserService.getOne(userWrapper);
|
|
|
|
|
+ if (StringUtil.isEmpty(createUser.getId())) {
|
|
|
|
|
+ throw new Exception(errorMsg_createName);
|
|
|
|
|
+ }
|
|
|
shareVO.setCreateId(Long.valueOf(createUser.getId()));
|
|
shareVO.setCreateId(Long.valueOf(createUser.getId()));
|
|
|
shareVO.setUpdateId(Long.valueOf(createUser.getId()));
|
|
shareVO.setUpdateId(Long.valueOf(createUser.getId()));
|
|
|
shareVO.setCreateName(createUser.getName());
|
|
shareVO.setCreateName(createUser.getName());
|
|
@@ -80,7 +100,12 @@ public class ImportDataController {
|
|
|
shareVO.setCompanyId(Long.valueOf(map.get("companyId")));
|
|
shareVO.setCompanyId(Long.valueOf(map.get("companyId")));
|
|
|
|
|
|
|
|
policyShareService.save(shareVO);
|
|
policyShareService.save(shareVO);
|
|
|
|
|
+
|
|
|
|
|
+ model.setIsSuccess(true);
|
|
|
|
|
+ excelVOList.add(model);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
|
|
+ model.setIsSuccess(false);
|
|
|
|
|
+ model.setErrorMsg(e.getMessage());
|
|
|
excelVOList.add(model);
|
|
excelVOList.add(model);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -95,24 +120,43 @@ public class ImportDataController {
|
|
|
List<PolicyStriveExcelVO> list = ExcelUtil.readPolicyStriveFromXls(byteFromUrl);
|
|
List<PolicyStriveExcelVO> list = ExcelUtil.readPolicyStriveFromXls(byteFromUrl);
|
|
|
|
|
|
|
|
if (list.isEmpty()) {
|
|
if (list.isEmpty()) {
|
|
|
- throw new Exception("excel中缺失有效数据");
|
|
|
|
|
|
|
+ throw new Exception(errorMsg_null);
|
|
|
}
|
|
}
|
|
|
list = list.stream().filter(model -> StringUtil.isNotEmpty(model.getIndex())).collect(Collectors.toList());
|
|
list = list.stream().filter(model -> StringUtil.isNotEmpty(model.getIndex())).collect(Collectors.toList());
|
|
|
List<PolicyStriveExcelVO> excelVOList = new ArrayList<>();
|
|
List<PolicyStriveExcelVO> excelVOList = new ArrayList<>();
|
|
|
for (PolicyStriveExcelVO model : list) {
|
|
for (PolicyStriveExcelVO model : list) {
|
|
|
try {
|
|
try {
|
|
|
|
|
+ if(!StringUtil.checkFieldsNotEmpty(model)){
|
|
|
|
|
+ throw new Exception(errorMsg_hang);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
PolicyStriveVO striveVO = new PolicyStriveVO();
|
|
PolicyStriveVO striveVO = new PolicyStriveVO();
|
|
|
BeanUtils.copyProperties(model, striveVO);
|
|
BeanUtils.copyProperties(model, striveVO);
|
|
|
|
|
|
|
|
- Date yjFinishTime = DateUtil.parse(model.getYjFinishTime(), DateUtil.PATTERN_DATE);
|
|
|
|
|
- striveVO.setYjFinishTime(yjFinishTime);
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ Date yjFinishTime = DateUtil.parse(model.getYjFinishTime(), DateUtil.PATTERN_DATE);
|
|
|
|
|
+ striveVO.setYjFinishTime(yjFinishTime);
|
|
|
|
|
+ } catch (RuntimeException re) {
|
|
|
|
|
+ throw new Exception(errorMsg_yjTime);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
striveVO.setStatus(QDPortEnum.POLICY_SHARE_STATUS_ACTIVE.getValue());
|
|
striveVO.setStatus(QDPortEnum.POLICY_SHARE_STATUS_ACTIVE.getValue());
|
|
|
|
|
|
|
|
|
|
+ QueryWrapper<PolicyShare> wrapper = new QueryWrapper<>();
|
|
|
|
|
+ wrapper.eq("DOC_NO", model.getDocNo());
|
|
|
|
|
+ long count = policyShareService.count(wrapper);
|
|
|
|
|
+ if (count == 0) {
|
|
|
|
|
+ throw new Exception(errorMsg_docNo_2);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
QueryWrapper<SysUser> userWrapper = new QueryWrapper<>();
|
|
QueryWrapper<SysUser> userWrapper = new QueryWrapper<>();
|
|
|
userWrapper.eq("MOBILE", model.getContactPhone());
|
|
userWrapper.eq("MOBILE", model.getContactPhone());
|
|
|
userWrapper.eq("NAME", model.getCreateName());
|
|
userWrapper.eq("NAME", model.getCreateName());
|
|
|
SysUser createUser = sysUserService.getOne(userWrapper);
|
|
SysUser createUser = sysUserService.getOne(userWrapper);
|
|
|
|
|
+ if (StringUtil.isEmpty(createUser.getId())) {
|
|
|
|
|
+ throw new Exception(errorMsg_createName);
|
|
|
|
|
+ }
|
|
|
striveVO.setCreateId(Long.valueOf(createUser.getId()));
|
|
striveVO.setCreateId(Long.valueOf(createUser.getId()));
|
|
|
striveVO.setUpdateId(Long.valueOf(createUser.getId()));
|
|
striveVO.setUpdateId(Long.valueOf(createUser.getId()));
|
|
|
striveVO.setCreateName(createUser.getName());
|
|
striveVO.setCreateName(createUser.getName());
|
|
@@ -122,7 +166,12 @@ public class ImportDataController {
|
|
|
striveVO.setCompanyId(Long.valueOf(map.get("companyId")));
|
|
striveVO.setCompanyId(Long.valueOf(map.get("companyId")));
|
|
|
|
|
|
|
|
policyStriveService.save(striveVO);
|
|
policyStriveService.save(striveVO);
|
|
|
|
|
+
|
|
|
|
|
+ model.setIsSuccess(true);
|
|
|
|
|
+ excelVOList.add(model);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
|
|
+ model.setIsSuccess(false);
|
|
|
|
|
+ model.setErrorMsg(e.getMessage());
|
|
|
excelVOList.add(model);
|
|
excelVOList.add(model);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -134,29 +183,48 @@ public class ImportDataController {
|
|
|
@WebLog(operateName = "导入政策争取月度excel", operateType = "policy_strive")
|
|
@WebLog(operateName = "导入政策争取月度excel", operateType = "policy_strive")
|
|
|
public R policyStriveMonth(@RequestBody PolicyStriveVO vo) throws Exception {
|
|
public R policyStriveMonth(@RequestBody PolicyStriveVO vo) throws Exception {
|
|
|
byte[] byteFromUrl = HttpsUtil.getByteFromUrl(vo.getExcelUrl());
|
|
byte[] byteFromUrl = HttpsUtil.getByteFromUrl(vo.getExcelUrl());
|
|
|
- List<PolicyStriveExcelVO> list = ExcelUtil.readPolicyStriveMonthFromXls(byteFromUrl);
|
|
|
|
|
|
|
+ List<PolicyStriveMonthExcelVO> list = ExcelUtil.readPolicyStriveMonthFromXls(byteFromUrl);
|
|
|
|
|
|
|
|
if (list.isEmpty()) {
|
|
if (list.isEmpty()) {
|
|
|
- throw new Exception("excel中缺失有效数据");
|
|
|
|
|
|
|
+ throw new Exception(errorMsg_null);
|
|
|
}
|
|
}
|
|
|
list = list.stream().filter(model -> StringUtil.isNotEmpty(model.getIndex())).collect(Collectors.toList());
|
|
list = list.stream().filter(model -> StringUtil.isNotEmpty(model.getIndex())).collect(Collectors.toList());
|
|
|
- List<PolicyStriveExcelVO> excelVOList = new ArrayList<>();
|
|
|
|
|
- for (PolicyStriveExcelVO model : list) {
|
|
|
|
|
|
|
+ List<PolicyStriveMonthExcelVO> excelVOList = new ArrayList<>();
|
|
|
|
|
+ for (PolicyStriveMonthExcelVO model : list) {
|
|
|
try {
|
|
try {
|
|
|
|
|
+ if (!StringUtil.checkFieldsNotEmpty(model)) {
|
|
|
|
|
+ throw new Exception(errorMsg_hang);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
PolicyStriveVO striveVO = new PolicyStriveVO();
|
|
PolicyStriveVO striveVO = new PolicyStriveVO();
|
|
|
BeanUtils.copyProperties(model, striveVO);
|
|
BeanUtils.copyProperties(model, striveVO);
|
|
|
|
|
|
|
|
QueryWrapper<PolicyStrive> striveWrapper = new QueryWrapper<>();
|
|
QueryWrapper<PolicyStrive> striveWrapper = new QueryWrapper<>();
|
|
|
striveWrapper.eq("BUSINESS_NO", model.getBusinessNo());
|
|
striveWrapper.eq("BUSINESS_NO", model.getBusinessNo());
|
|
|
PolicyStrive existStrive = policyStriveService.getOne(striveWrapper);
|
|
PolicyStrive existStrive = policyStriveService.getOne(striveWrapper);
|
|
|
|
|
+ if(StringUtil.isEmpty(existStrive.getId())){
|
|
|
|
|
+ throw new Exception(errorMsg_businessNo);
|
|
|
|
|
+ }
|
|
|
striveVO.setId(existStrive.getId());
|
|
striveVO.setId(existStrive.getId());
|
|
|
|
|
|
|
|
if ("是".equals(model.getIsLand())) {
|
|
if ("是".equals(model.getIsLand())) {
|
|
|
striveVO.setIsLand(1);
|
|
striveVO.setIsLand(1);
|
|
|
|
|
+ try {
|
|
|
|
|
+ Date sjFinishTime = DateUtil.parse(model.getSjFinishTime(), DateUtil.PATTERN_DATE);
|
|
|
|
|
+ striveVO.setSjFinishTime(sjFinishTime);
|
|
|
|
|
+ } catch (RuntimeException re) {
|
|
|
|
|
+ throw new Exception(errorMsg_sjTime);
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
striveVO.setIsLand(0);
|
|
striveVO.setIsLand(0);
|
|
|
}
|
|
}
|
|
|
- String[] partSplit = model.getPartPersonArr().split(",");
|
|
|
|
|
|
|
+ String[] partSplit = new String[]{};
|
|
|
|
|
+ String partPersonArr = model.getPartPersonArr();
|
|
|
|
|
+ if (partPersonArr.contains(",")) {
|
|
|
|
|
+ partSplit = model.getPartPersonArr().split(",");
|
|
|
|
|
+ } else if (partPersonArr.contains(",")) {
|
|
|
|
|
+ partSplit = model.getPartPersonArr().split(",");
|
|
|
|
|
+ }
|
|
|
JSONArray array = new JSONArray();
|
|
JSONArray array = new JSONArray();
|
|
|
for (String partName : partSplit) {
|
|
for (String partName : partSplit) {
|
|
|
JSONObject partObj = new JSONObject();
|
|
JSONObject partObj = new JSONObject();
|
|
@@ -169,11 +237,19 @@ public class ImportDataController {
|
|
|
userWrapper.eq("MOBILE", model.getContactPhone());
|
|
userWrapper.eq("MOBILE", model.getContactPhone());
|
|
|
userWrapper.eq("NAME", model.getCreateName());
|
|
userWrapper.eq("NAME", model.getCreateName());
|
|
|
SysUser createUser = sysUserService.getOne(userWrapper);
|
|
SysUser createUser = sysUserService.getOne(userWrapper);
|
|
|
|
|
+ if (StringUtil.isEmpty(createUser.getId())) {
|
|
|
|
|
+ throw new Exception(errorMsg_createName);
|
|
|
|
|
+ }
|
|
|
striveVO.setUpdateId(Long.valueOf(createUser.getId()));
|
|
striveVO.setUpdateId(Long.valueOf(createUser.getId()));
|
|
|
striveVO.setUpdateTime(new Date());
|
|
striveVO.setUpdateTime(new Date());
|
|
|
|
|
|
|
|
policyStriveService.updateById(striveVO);
|
|
policyStriveService.updateById(striveVO);
|
|
|
|
|
+
|
|
|
|
|
+ model.setIsSuccess(true);
|
|
|
|
|
+ excelVOList.add(model);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
|
|
+ model.setIsSuccess(false);
|
|
|
|
|
+ model.setErrorMsg(e.getMessage());
|
|
|
excelVOList.add(model);
|
|
excelVOList.add(model);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|