|
@@ -1,12 +1,19 @@
|
|
|
package com.rongwei.bscommon.sys.utils;
|
|
|
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONException;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.rongwei.bsentity.dto.luckysheet.AssembleCellParam;
|
|
|
import com.rongwei.bsentity.dto.project.ProjectSummaryParamExcelDto;
|
|
|
import com.rongwei.bsentity.dto.project.SheetInfoParam;
|
|
|
import com.rongwei.rwcommon.utils.StringUtils;
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -24,6 +31,88 @@ public class LuckySheet4SummaryHelp {
|
|
|
*/
|
|
|
public static final String[] MAIN_TITLE_SECOND = {"总状态","提出日期","整改期限","提出者","备注1","备注2"};
|
|
|
|
|
|
+ /**
|
|
|
+ * 字符串转日期格式 无法转换日期给null
|
|
|
+ *
|
|
|
+ * @param obj
|
|
|
+ * @param dateKey
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static Date getDateDefaultNull(JSONObject obj, String dateKey) {
|
|
|
+
|
|
|
+ if(ObjectUtil.isEmpty(obj) || ObjectUtil.isEmpty(dateKey)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ return obj.getDate(dateKey);
|
|
|
+ } catch (JSONException e) {
|
|
|
+ if(e.getMessage().startsWith("can not cast to Date")) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ String dateValue = obj.getString(dateKey);
|
|
|
+ try {
|
|
|
+ DateTime dateTime = DateUtil.parse(dateValue, getDateFormat(dateValue));
|
|
|
+ return dateTime;
|
|
|
+ } catch (Exception ex) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取匹配符
|
|
|
+ *
|
|
|
+ * @param strVal
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static String getDateFormat(String strVal) {
|
|
|
+ String delimiter = "-";
|
|
|
+ if(strVal.contains(".")) {
|
|
|
+ delimiter = ".";
|
|
|
+ } else if(strVal.contains("/")) {
|
|
|
+ delimiter = "/";
|
|
|
+ } else if(strVal.contains("年")) {
|
|
|
+ delimiter = "年";
|
|
|
+ }
|
|
|
+
|
|
|
+ StringBuilder ymdSb = new StringBuilder();
|
|
|
+ if("年".equals(delimiter)) {
|
|
|
+ ymdSb.append("yyyy");
|
|
|
+ ymdSb.append("年");
|
|
|
+ ymdSb.append("MM");
|
|
|
+ ymdSb.append("月");
|
|
|
+ ymdSb.append("dd");
|
|
|
+ ymdSb.append("日");
|
|
|
+ } else {
|
|
|
+ ymdSb.append("yyyy");
|
|
|
+ ymdSb.append(delimiter);
|
|
|
+ ymdSb.append("MM");
|
|
|
+ ymdSb.append(delimiter);
|
|
|
+ ymdSb.append("dd");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(strVal.length() == 10) {
|
|
|
+ return ymdSb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (strVal.length() == "yyyy-MM-dd HH:mm:ss".length()) {
|
|
|
+ ymdSb.append(" HH:mm:ss");
|
|
|
+ } else if (strVal.length() == 29 && strVal.charAt(26) == ':' && strVal.charAt(28) == '0') {
|
|
|
+ ymdSb.append("'T'HH:mm:ss.SSSXXX");
|
|
|
+ } else if (strVal.length() == 23 && strVal.charAt(19) == ',') {
|
|
|
+ ymdSb.append(" HH:mm:ss,SSS");
|
|
|
+ } else {
|
|
|
+ ymdSb.append(" HH:mm:ss.SSS");
|
|
|
+ }
|
|
|
+
|
|
|
+ return ymdSb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* {
|
|
|
* "c": 0,
|