ソースを参照

定时任务修改

Signed-off-by: anderx <312518615@qq.com>
anderx 5 年 前
コミット
f2a0a5488c

+ 13 - 2
src/main/java/com/goafanti/common/task/PatentTask.java

@@ -30,6 +30,7 @@ import com.goafanti.common.model.PatentNew;
 import com.goafanti.common.model.PatentNewLog;
 import com.goafanti.common.utils.LoggerUtils;
 import com.goafanti.common.utils.SendEmailUtil;
+import com.goafanti.customer.bo.LockingReleaseBo;
 import com.goafanti.patent.service.PatentNewService;
 
 
@@ -47,8 +48,10 @@ public class PatentTask {
 	
 	
 	
+	
+	
 
-    
+	int pointsDataLimit=50;
     
     private static final String regEx_script = "<script[^>]*?>[\\s\\S]*?<\\/script>"; // 定义script的正则表达式
     private static final String regEx_style = "<style[^>]*?>[\\s\\S]*?<\\/style>"; // 定义style的正则表达式
@@ -132,7 +135,15 @@ public class PatentTask {
 			 Thread.sleep(2000);
 		}
 		if (!nlist.isEmpty()) {
-			noticeMapper.insertBatch(nlist);	
+			List<Notice> newList=new  ArrayList<>();
+				  for(int i=0;i<nlist.size();i++){
+					  newList.add(nlist.get(i));
+					  if(pointsDataLimit == newList.size()||i == nlist.size()-1){
+						  if(newList.size()>0) noticeMapper.insertBatch(newList);	
+						  newList.clear();
+						  Thread.sleep(2000);
+					  }  
+			}
 		}
 		List<PatentNew> ls=patentNewService.AllselectEndPatentNew();
 		for (PatentNew p : ls) {

+ 6 - 3
src/main/java/com/goafanti/common/task/ReleaseUserTask.java

@@ -12,6 +12,9 @@ import javax.mail.MessagingException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
 
 import com.goafanti.common.bo.EmailBo;
 import com.goafanti.common.constant.AFTConstants;
@@ -26,7 +29,7 @@ import com.goafanti.customer.bo.LockingReleaseBo;
 import com.goafanti.customer.service.CustomerService;
 import com.goafanti.user.service.UserService;
 @Component
-//@Controller
+@Controller
 public class ReleaseUserTask {
 	@Resource
 	private CustomerService customerServiceImpl;
@@ -42,7 +45,7 @@ public class ReleaseUserTask {
 	 */
 	
 	@Scheduled(cron = "0 0 1  * * ?") 
-//	@RequestMapping(value = "/open/updateUser", method = RequestMethod.GET)
+	@RequestMapping(value = "/open/updateUser", method = RequestMethod.GET)
 	public void updateUser(){
 		LoggerUtils.debug(getClass(), "==============客户释放开始============");
 		Date releaseTime = new Date();
@@ -92,7 +95,7 @@ public class ReleaseUserTask {
 			if(lockBusinessList.size()>0) customerServiceImpl.updateReleaseLock(lockBusinessList,releaseTime);
 			if(lockUserList.size()>0) userServiceImpl.updateReleaseLock(lockUserList);*/
 
-		} catch (Exception e) {
+		} catch (InterruptedException e) {
 			Notice n =new Notice(UUID.randomUUID().toString(),new Date(),0,"1",NoticeStatus.TASK_PATENT_ERROR.getCode(),"==============客户释放失败================");
 			 noticeMapper.insert(n);
 			EmailBo emailBo = new EmailBo( "释放客户失败",  AFTConstants.ADMIN_EMAIL,  "超管", "平台",  "系统", "释放客户失败");

+ 1 - 1
src/main/resources/props/config_local.properties

@@ -5,7 +5,7 @@ jdbc.driverClassName=com.mysql.jdbc.Driver
 #jdbc.username=dev
 #jdbc.password=123456
 #测试
-jdbc.url=jdbc:mysql://101.37.32.31:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
+jdbc.url=jdbc:mysql://101.37.32.31:3306/aft20200511?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
 jdbc.username=root
 jdbc.password=aftdev
 #\u68c0\u6d4b\u6570\u636e\u5e93\u94fe\u63a5\u662f\u5426\u6709\u6548\uff0c\u5fc5\u987b\u914d\u7f6e