包头bug修改
This commit is contained in:
parent
7f2f708fe7
commit
d5eee499ed
@ -321,13 +321,13 @@ public class WorkerAdmissionController {
|
||||
if (jo.getString("field5960144013031") == null || JSON.parseArray(jo.getString("field5960144013031")).size() == 0) {
|
||||
errs.add(workerName + "需要上传" + type.getPostWorkTypeName() + "资质证");
|
||||
}
|
||||
if (jo.getString("field5342644024091") == null || FlowUtil.isBlank(jo.getString("field5342644024091"))) {
|
||||
if (jo.getString("field5342644024091") == null || FlowUtil.isEmpty(jo.getString("field5342644024091"))) {
|
||||
errs.add(workerName + "需要上传" + type.getPostWorkTypeName() + "资质验证");
|
||||
}
|
||||
if (StrUtil.isBlank(jo.getString("field9354421203736"))) {
|
||||
errs.add(workerName + "需要填写资格证号");
|
||||
}
|
||||
if (FlowUtil.isBlank(jo.getString("field1492921345638"))) {
|
||||
if (FlowUtil.isEmpty(jo.getString("field1492921345638"))) {
|
||||
errs.add(workerName + "需要选择发证机关");
|
||||
}
|
||||
if (StrUtil.isBlank(jo.getString("field2436120887995"))) {
|
||||
|
||||
@ -5,7 +5,6 @@ import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@ -13,7 +12,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||
import com.zhgd.xmgl.constant.Cts;
|
||||
@ -39,7 +37,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
@ -237,7 +234,7 @@ public class WorkerAdmissionServiceImpl extends ServiceImpl<WorkerAdmissionMappe
|
||||
Long epcCbs = FlowUtil.getPullDownLong(m, "field4614421102325");
|
||||
Long enterpriseId = FlowUtil.getPullDownLong(m, "field9875821081899");
|
||||
Map<String, String> idCardMap = IdCardUtils.getBirthdayAgeSex(idCard);
|
||||
Integer sex = Integer.valueOf(idCardMap.get("sex"));
|
||||
Integer sex = Convert.toInt(idCardMap.get("sex"));
|
||||
Integer isCertificateQualified = FlowUtil.getPullDownInteger(m, "field1062926653275");
|
||||
String random = IdUtil.simpleUUID();
|
||||
WorkerAdmissionDetail detail = new WorkerAdmissionDetail();
|
||||
@ -312,7 +309,9 @@ public class WorkerAdmissionServiceImpl extends ServiceImpl<WorkerAdmissionMappe
|
||||
String issueTime = FlowUtil.getString(m, "field2436120887995");
|
||||
String effectTime = FlowUtil.getString(m, "field7888920890828");
|
||||
Integer issueCompany = FlowUtil.getPullDownInteger(m, "field1492921345638");
|
||||
if (needCertTypeMap.get(detail.getPostWorkType()) != null) {
|
||||
String photoUrl = FlowUtil.getFileWithStar(m, "field5960144013031");
|
||||
String veri = FlowUtil.getFileWithStar(m, "field5342644024091");
|
||||
if (FlowUtil.anyIsNotEmpty(certificateNumber, issueCompany, issueTime, effectTime, veri, photoUrl)) {
|
||||
//需要添加证书
|
||||
WorkerAdmissionCertificateDetail certificateDetail = new WorkerAdmissionCertificateDetail();
|
||||
certificateDetail.setCertificateNumber(certificateNumber);
|
||||
@ -339,8 +338,8 @@ public class WorkerAdmissionServiceImpl extends ServiceImpl<WorkerAdmissionMappe
|
||||
certificateDetail.setIssueCompany(issueCompany);
|
||||
certificateDetail.setIssueTime(issueTime);
|
||||
certificateDetail.setEffectTime(effectTime);
|
||||
certificateDetail.setPhotoUrl(FlowUtil.getFileWithStar(m, "field5960144013031"));
|
||||
certificateDetail.setQualificationVerification(FlowUtil.getFileWithStar(m, "field5342644024091"));
|
||||
certificateDetail.setPhotoUrl(photoUrl);
|
||||
certificateDetail.setQualificationVerification(veri);
|
||||
certificateDetail.setProjectSn(projectSn);
|
||||
certificateDetail.setRandom(random);
|
||||
certificateDetails.add(certificateDetail);
|
||||
|
||||
@ -242,17 +242,248 @@ public class FlowUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为空
|
||||
* 综合空值检查方法
|
||||
*
|
||||
* @param obj 要检查的对象
|
||||
* @return true如果对象为空,false否则
|
||||
*/
|
||||
public static boolean isEmpty(Object obj) {
|
||||
if (obj == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 检查字符串
|
||||
if (obj instanceof String) {
|
||||
String str = ((String) obj).trim();
|
||||
if (str.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 检查JSON字符串
|
||||
if (isPotentialJson(str)) {
|
||||
try {
|
||||
if (str.startsWith("[")) {
|
||||
JSONArray jsonArray = JSON.parseArray(str);
|
||||
return isJsonArrayEmpty(jsonArray);
|
||||
} else if (str.startsWith("{")) {
|
||||
JSONObject jsonObject = JSON.parseObject(str);
|
||||
return isJsonObjectEmpty(jsonObject);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 如果不是有效的JSON,按普通字符串处理
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查集合
|
||||
if (obj instanceof Collection) {
|
||||
return ((Collection<?>) obj).isEmpty() || isCollectionWithAllEmptyElements((Collection<?>) obj);
|
||||
}
|
||||
|
||||
// 检查数组
|
||||
if (obj.getClass().isArray()) {
|
||||
return java.lang.reflect.Array.getLength(obj) == 0 || isArrayWithAllEmptyElements(obj);
|
||||
}
|
||||
|
||||
// 检查Map
|
||||
if (obj instanceof Map) {
|
||||
return ((Map<?, ?>) obj).isEmpty() || isMapWithAllEmptyValues((Map<?, ?>) obj);
|
||||
}
|
||||
|
||||
// 检查JSONObject (如果直接传入)
|
||||
if (obj instanceof JSONObject) {
|
||||
return isJsonObjectEmpty((JSONObject) obj);
|
||||
}
|
||||
|
||||
// 检查JSONArray (如果直接传入)
|
||||
if (obj instanceof JSONArray) {
|
||||
return isJsonArrayEmpty((JSONArray) obj);
|
||||
}
|
||||
|
||||
// 其他类型默认认为非空
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 任意一个参数不为空即返回true
|
||||
*
|
||||
* @param objects
|
||||
* @return
|
||||
*/
|
||||
public static boolean anyIsNotEmpty(Object... objects) {
|
||||
if (objects == null) return false;
|
||||
|
||||
for (Object obj : objects) {
|
||||
if (isNotEmpty(obj)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 所有参数都不为空才返回true
|
||||
*
|
||||
* @param objects
|
||||
* @return
|
||||
*/
|
||||
public static boolean allAreNotEmpty(Object... objects) {
|
||||
if (objects == null) return false;
|
||||
|
||||
for (Object obj : objects) {
|
||||
if (isEmpty(obj)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 综合非空值检查方法
|
||||
*
|
||||
* @param obj
|
||||
* @return
|
||||
*/
|
||||
public static boolean isBlank(String obj) {
|
||||
Object parse = JSON.parse(obj);
|
||||
if (parse instanceof List) {
|
||||
return Optional.ofNullable((List) parse).map(m -> m.size() == 0 || m.get(0) == null || StrUtil.isBlank(m.get(0) + "")).orElse(null);
|
||||
} else {
|
||||
public static boolean isNotEmpty(Object obj) {
|
||||
return !isEmpty(obj);
|
||||
}
|
||||
|
||||
private static boolean isPotentialJson(String str) {
|
||||
str = str.trim();
|
||||
return (str.startsWith("{") && str.endsWith("}")) ||
|
||||
(str.startsWith("[") && str.endsWith("]"));
|
||||
}
|
||||
|
||||
private static boolean isJsonArrayEmpty(JSONArray jsonArray) {
|
||||
if (jsonArray.size() == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
Object element = jsonArray.get(i);
|
||||
if (!isJsonElementEmpty(element)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean isJsonObjectEmpty(JSONObject jsonObject) {
|
||||
if (jsonObject.size() == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (String key : jsonObject.keySet()) {
|
||||
Object value = jsonObject.get(key);
|
||||
if (!isJsonElementEmpty(value)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean isJsonElementEmpty(Object element) {
|
||||
if (element == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (element instanceof String) {
|
||||
return ((String) element).isEmpty();
|
||||
}
|
||||
|
||||
if (element instanceof JSONArray) {
|
||||
return isJsonArrayEmpty((JSONArray) element);
|
||||
}
|
||||
|
||||
if (element instanceof JSONObject) {
|
||||
return isJsonObjectEmpty((JSONObject) element);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isCollectionWithAllEmptyElements(Collection<?> collection) {
|
||||
for (Object element : collection) {
|
||||
if (!isEmpty(element)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean isArrayWithAllEmptyElements(Object array) {
|
||||
int length = java.lang.reflect.Array.getLength(array);
|
||||
for (int i = 0; i < length; i++) {
|
||||
Object element = java.lang.reflect.Array.get(array, i);
|
||||
if (!isEmpty(element)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean isMapWithAllEmptyValues(Map<?, ?> map) {
|
||||
for (Object value : map.values()) {
|
||||
if (!isEmpty(value)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// ========== 测试用例 ==========
|
||||
public static void main(String[] args) {
|
||||
// 基本类型测试
|
||||
System.out.println("=== 基本类型测试 ===");
|
||||
System.out.println(isEmpty(null)); // true
|
||||
System.out.println(isEmpty("")); // true
|
||||
System.out.println(isEmpty(" ")); // true (trim后为空)
|
||||
|
||||
// 集合/数组测试
|
||||
System.out.println("\n=== 集合/数组测试 ===");
|
||||
System.out.println(isEmpty(new ArrayList<>())); // true
|
||||
System.out.println(isEmpty(new String[]{})); // true
|
||||
System.out.println(isEmpty(new String[]{""})); // true
|
||||
System.out.println(isEmpty(new String[]{"", ""})); // true
|
||||
System.out.println(isEmpty(new Object[]{null, null})); // true
|
||||
System.out.println(isEmpty(Arrays.asList("", ""))); // true
|
||||
System.out.println(isEmpty(Arrays.asList(new HashMap<>()))); // true [{}]
|
||||
|
||||
// Map测试
|
||||
System.out.println("\n=== Map测试 ===");
|
||||
System.out.println(isEmpty(new HashMap<>())); // true
|
||||
System.out.println(isEmpty(new MapBuilder<String, Object>()
|
||||
.put("a", "")
|
||||
.build())); // true (值为空字符串)
|
||||
System.out.println(isEmpty(new MapBuilder<String, Object>()
|
||||
.put("a", null)
|
||||
.build())); // true (值为null)
|
||||
System.out.println(isEmpty(new MapBuilder<String, Object>()
|
||||
.put("a", new ArrayList<>())
|
||||
.build())); // true (值为空集合)
|
||||
|
||||
// JSON字符串测试
|
||||
System.out.println("\n=== JSON字符串测试 ===");
|
||||
System.out.println(isEmpty("[]")); // true
|
||||
System.out.println(isEmpty("[\"\"]")); // true
|
||||
System.out.println(isEmpty("[\"\", \"\"]")); // true
|
||||
System.out.println(isEmpty("[null, null]")); // true
|
||||
System.out.println(isEmpty("{}")); // true
|
||||
System.out.println(isEmpty("{\"key\": \"\"}")); // true
|
||||
System.out.println(isEmpty("{\"key\": null}")); // true
|
||||
System.out.println(isEmpty("[{}]")); // true
|
||||
System.out.println(isEmpty("[{\"key\": \"\"}]")); // true
|
||||
|
||||
// 非空案例
|
||||
System.out.println("\n=== 非空案例 ===");
|
||||
System.out.println(isEmpty("hello")); // false
|
||||
System.out.println(isEmpty(new String[]{"a"})); // false
|
||||
System.out.println(isEmpty(Arrays.asList("a"))); // false
|
||||
System.out.println(isEmpty(new MapBuilder<String, Object>()
|
||||
.put("a", "b")
|
||||
.build())); // false
|
||||
System.out.println(isEmpty("{\"key\": \"value\"}")); // false
|
||||
System.out.println(isEmpty("[\"a\"]")); // false
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user