liupeng 4 years ago
parent
commit
12fe7382a7

+ 31 - 0
code/sapparent/sapcms/src/main/java/org/fouram/controller/TestController.java

@@ -0,0 +1,31 @@
+package org.fouram.controller;
+
+import org.fouram.core.base.controller.BaseController;
+import org.fouram.core.util.AppUtil;
+import org.fouram.service.TestService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+@Controller
+@RequestMapping(value = "/test")
+public class TestController extends BaseController {
+
+	@Autowired
+	private TestService testService;
+
+	/**
+	 * http://localhost:8080/sapcms/test/saveTestAnon
+	 * 
+	 * @return
+	 * @throws Exception
+	 */
+	@PostMapping(value = "/saveTestAnon", produces = "application/json;charset=utf-8")
+	@ResponseBody
+	public Object saveTestAnon() throws Exception {
+		testService.saveTest();
+		return AppUtil.success();
+	}
+}

+ 14 - 0
code/sapparent/sapservice/src/main/java/org/fouram/core/util/EmojiUtils.java

@@ -0,0 +1,14 @@
+package org.fouram.core.util;
+
+import org.apache.commons.lang.StringUtils;
+
+public class EmojiUtils {
+
+	public static String filterEmoji(String source) {
+		if (StringUtils.isNotBlank(source)) {
+			return source.replaceAll("[\\ud800\\udc00-\\udbff\\udfff\\ud800-\\udfff]", "");
+		} else {
+			return source;
+		}
+	}
+}

+ 3 - 3
code/sapparent/sapservice/src/main/java/org/fouram/core/util/JsonNodeUtil.java

@@ -15,7 +15,7 @@ public class JsonNodeUtil {
 			Date date = new Date(Long.valueOf(value.replace("/Date(", "").replace(")/", "").replace("+0000", "")));
 			return DateUtil.getDay(date);
 		}
-		return value;
+		return EmojiUtils.filterEmoji(value);
 	}
 	
 	public static String getTime(JsonNode userNode, String key) {
@@ -27,7 +27,7 @@ public class JsonNodeUtil {
 			Date date = new Date(Long.valueOf(value.replace("/Date(", "").replace(")/", "").replace("+0000", "")));
 			return DateUtil.getTime(date);
 		}
-		return value;
+		return EmojiUtils.filterEmoji(value);
 	}
 
 	public static String getValue(JsonNode userNode, String key1, String key2) {
@@ -38,7 +38,7 @@ public class JsonNodeUtil {
 		if (Tools.isEmpty(value)) {
 			return "";
 		}
-		return value;
+		return EmojiUtils.filterEmoji(value);
 	}
 
 	public static void main(String[] args) {

+ 1 - 1
code/sapparent/sapservice/src/main/java/org/fouram/entity/SapEmployeeTime.java

@@ -55,6 +55,6 @@ public class SapEmployeeTime implements Serializable {
 
 	public String getKeyString() {
 		return new StringBuffer().append(externalCode).append(startDate).append(endDate).append(approvalStatus)
-				.toString();
+				.append(comment).toString();
 	}
 }

+ 1 - 3
code/sapparent/sapservice/src/main/java/org/fouram/service/SapEmployeeTimeService.java

@@ -79,12 +79,10 @@ public class SapEmployeeTimeService extends BaseService {
 					String recurrenceGroup = JsonNodeUtil.getValue(userNode, "recurrenceGroup");
 					String createdBy = JsonNodeUtil.getValue(userNode, "createdBy");
 					String workflowInitiatedByAdmin = JsonNodeUtil.getValue(userNode, "workflowInitiatedByAdmin");
-					/* String comment = JsonNodeUtil.getValue(userNode, "comment"); */
-					String comment = "";
+					String comment = JsonNodeUtil.getValue(userNode, "comment");
 					String fractionQuantity = JsonNodeUtil.getValue(userNode, "fractionQuantity");
 					String endTime = JsonNodeUtil.getValue(userNode, "endTime");
 					String originalQuantityInDays = JsonNodeUtil.getValue(userNode, "originalQuantityInDays");
-
 					employeeTime = SapEmployeeTime.builder().externalCode(externalCode)
 							.lastModifiedDateTime(lastModifiedDateTime).loaActualReturnDate(loaActualReturnDate)
 							.createdDateTime(createdDateTime).timeType(timeType)

+ 18 - 0
code/sapparent/sapservice/src/main/java/org/fouram/service/TestService.java

@@ -0,0 +1,18 @@
+package org.fouram.service;
+
+import org.fouram.core.base.service.BaseService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+@Service
+public class TestService extends BaseService {
+
+	@Autowired
+	private SapEmployeeTimeService employeeTimeService;
+
+	@Transactional
+	public void saveTest() throws Exception {
+		employeeTimeService.saveEmployeeTimes();
+	}
+}