shenhao 1 tahun lalu
induk
melakukan
c81805656d

+ 2 - 2
src/main/java/com/ssj/dao/conch/curator/dao/IVacationLimitDao.java

@@ -34,10 +34,10 @@ public interface IVacationLimitDao extends JpaRepository<TbVacationLimit, String
 
     @Query(nativeQuery = true, value = "select t.* from tb_vacation_limit t \n" +
             " join fx_merchant t11 on t.lib_id = t11.lib_id\n" +
-            "where t.lib_id=?1\n" +
+            "where t.lib_id=?1 and t.set_state=2 \n" +
             "and  (to_days(t.start_date) <= to_days(now()) \n" +
             "AND to_days(t.end_date) >= to_days(now())) \n" +
-            "and t.limit_year=?2 and TO_DAYS(t11.sign_time)<=TO_DAYS(NOW()) AND TO_DAYS(t11.end_sign_time)>TO_DAYS(NOW())\n" +
+            "and t.limit_year=?2 and TO_DAYS(t11.active_time)<=TO_DAYS(NOW()) AND TO_DAYS(t11.end_active_time)>TO_DAYS(NOW())\n" +
             "order by t.type asc")
     List<TbVacationLimit> findValidVocationList(String libId, String year);
 }

+ 12 - 0
src/main/java/com/ssj/dao/weixin/zuoyb/dao/ZuoybCourseDao.java

@@ -7,6 +7,7 @@ import org.springframework.data.jpa.repository.Query;
 import org.springframework.stereotype.Repository;
 
 import java.util.List;
+import java.util.Map;
 
 
 /** 
@@ -94,4 +95,15 @@ public interface ZuoybCourseDao extends JpaRepository<ZuoybCourse, String>{
 	 public List<String> getCourseAndLibId(String libId);
 	@Query(nativeQuery = true, value = "select SUBSTR(file_key,2) as file_key  from scon_homework_picture  where  create_time like  CONCAT(?1,'%')")
 	List<String> findFileKeyList(String format);
+
+	@Query(nativeQuery = true, value = "SELECT back_cover_url from q_workbook where back_cover_url is not null and isbn is null order by book_year desc")
+	List<Map<String,String>> findOrcImgList();
+
+	@Query(nativeQuery = true, value = "update q_workbook set isbn = ?2   where id = ?1 ")
+	@Modifying
+	void updateBookIsbn(String bookId, String isbn);
+
+	@Query(nativeQuery = true, value = "update kmt_exercise_book set isbn = ?2   where parent_book_id = ?1 ")
+	@Modifying
+	void updateExerciseIsbn(String bookId, String isbn);
 }

+ 2 - 0
src/main/java/com/ssj/dao/weixin/zuoyb/dao/ZuoybQueryDao.java

@@ -341,4 +341,6 @@ public interface ZuoybQueryDao {
 	 * @return
 	 */
 	Map<String, Object> findFirstMonth();
+
+    List<Map<String, Object>> findOrcImgList();
 }

+ 8 - 0
src/main/java/com/ssj/dao/weixin/zuoyb/dao/impl/ZuoybQueryDaoImpl.java

@@ -1729,4 +1729,12 @@ public class ZuoybQueryDaoImpl  implements ZuoybQueryDao{
 		selSQL.append(" SELECT  DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%s') as create_time from scon_homework_picture  order by create_time asc limit 1");
 		return dao.findMap(selSQL.toString(), queryParams.toArray()).get(0);
 	}
+
+	@Override
+	public List<Map<String, Object>> findOrcImgList() {
+		StringBuilder selSQL = new StringBuilder();
+		List<Object> queryParams = new ArrayList<Object>();
+		selSQL.append("SELECT back_cover_url,id from q_workbook where back_cover_url is not null and isbn is null order by book_year desc");
+		return dao.findMap(selSQL.toString(), queryParams.toArray());
+	}
 }

+ 15 - 0
src/main/java/com/ssj/service/isbn/dao/IOcrDataDao.java

@@ -0,0 +1,15 @@
+package com.ssj.service.isbn.dao;
+
+import com.ssj.service.isbn.entity.TbBookOcrData;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+/**
+ * @author sh
+ * @className IOcrDataDao
+ * @description
+ * @date 2023/3/1
+ */
+@Repository
+public interface IOcrDataDao extends JpaRepository<TbBookOcrData,String> {
+}

+ 44 - 0
src/main/java/com/ssj/service/isbn/entity/TbBookOcrData.java

@@ -0,0 +1,44 @@
+package com.ssj.service.isbn.entity;
+
+import com.ssj.bean.common.framework.core.domain.BaseEntity;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import java.io.Serializable;
+
+/**
+ * @author sh
+ * @className TbBookOcrData
+ * @description 记录调用ocr返回信息
+ * @date 2023/3/1
+ */
+@Entity
+@Table(name="tb_book_ocr_data")
+public class TbBookOcrData  extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 练习册id
+     */
+    private String bookId;
+
+    /**
+     * 练习册返回的json
+     */
+    private String orcJson;
+
+    public String getBookId() {
+        return bookId;
+    }
+
+    public void setBookId(String bookId) {
+        this.bookId = bookId;
+    }
+
+    public String getOrcJson() {
+        return orcJson;
+    }
+
+    public void setOrcJson(String orcJson) {
+        this.orcJson = orcJson;
+    }
+}

+ 14 - 0
src/main/java/com/ssj/service/isbn/service/IOcrDataService.java

@@ -0,0 +1,14 @@
+package com.ssj.service.isbn.service;
+
+import com.ssj.framework.core.common.service.BaseService;
+import com.ssj.service.isbn.entity.TbBookOcrData;
+
+/**
+ * @author sh
+ * @className IOcrDataService
+ * @description TODO
+ * @date 2023/3/1
+ */
+public interface IOcrDataService extends BaseService<TbBookOcrData, String> {
+    void saveOrcData(String bookId, String reJson);
+}

+ 34 - 0
src/main/java/com/ssj/service/isbn/service/impl/OcrDataServiceImpl.java

@@ -0,0 +1,34 @@
+package com.ssj.service.isbn.service.impl;
+
+import com.ssj.framework.core.common.service.BaseServiceImpl;
+import com.ssj.service.isbn.dao.IOcrDataDao;
+import com.ssj.service.isbn.entity.TbBookOcrData;
+import com.ssj.service.isbn.service.IOcrDataService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.repository.PagingAndSortingRepository;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author sh
+ * @className OcrDataServiceImpl
+ * @description TODO
+ * @date 2023/3/1
+ */
+@Service
+public class OcrDataServiceImpl extends BaseServiceImpl<TbBookOcrData,String> implements IOcrDataService {
+
+    @Autowired
+    private IOcrDataDao dao;
+    @Override
+    public PagingAndSortingRepository<TbBookOcrData, String> getDao() {
+        return dao;
+    }
+
+    @Override
+    public void saveOrcData(String bookId, String reJson) {
+        TbBookOcrData data = new TbBookOcrData();
+        data.setBookId(bookId);
+        data.setOrcJson(reJson);
+        this.save(data);
+    }
+}

+ 6 - 0
src/main/java/com/ssj/service/weixin/zuoyb/service/ZuoybCourseService.java

@@ -205,4 +205,10 @@ public interface ZuoybCourseService  extends BaseService<ZuoybCourse, String> {
 	public	String findFirstMonth();
 
 	List<String> findFileKeyList(String format);
+
+	List<Map<String,Object>> findOrcImgList();
+
+	void updateBookIsbn(String bookId, String isbn);
+
+	void updateExerciseIsbn(String bookId, String isbn);
 }

+ 15 - 0
src/main/java/com/ssj/service/weixin/zuoyb/service/impl/ZuoybCourseServiceImpl.java

@@ -201,4 +201,19 @@ public class ZuoybCourseServiceImpl  extends BaseServiceImpl<ZuoybCourse, String
 		return zuoybCourseDao.findFileKeyList(format);
 	}
 
+	@Override
+	public List<Map<String,Object>> findOrcImgList() {
+		return zuoybQueryDao.findOrcImgList();
+	}
+
+	@Override
+	public void updateBookIsbn(String bookId, String isbn) {
+		zuoybCourseDao.updateBookIsbn(bookId,isbn);
+	}
+
+	@Override
+	public void updateExerciseIsbn(String bookId, String isbn) {
+		zuoybCourseDao.updateExerciseIsbn(bookId,isbn);
+	}
+
 }

+ 231 - 149
src/main/java/com/ssj/sys/controller/SysLibController.java

@@ -10,6 +10,7 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.CompletableFuture;
 
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletRequest;
@@ -17,14 +18,18 @@ import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 
 import cn.hutool.core.thread.ThreadUtil;
+import com.aliyun.ocr_api20210707.models.RecognizeGeneralResponse;
 import com.aliyun.oss.ClientException;
 import com.aliyun.oss.OSS;
 import com.aliyun.oss.OSSClientBuilder;
 import com.aliyun.oss.OSSException;
 import com.aliyun.oss.model.DeleteObjectsRequest;
 import com.aliyun.oss.model.DeleteObjectsResult;
+import com.aliyun.tea.TeaException;
+import com.google.gson.Gson;
 import com.ssj.bean.sys.fx.domain.Merchant;
 import com.ssj.bean.weixin.libmy.domain.*;
+import com.ssj.service.isbn.service.IOcrDataService;
 import com.ssj.service.sys.fx.service.MerchantService;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.lang3.StringUtils;
@@ -142,6 +147,9 @@ public class SysLibController extends BaseController {
 
 	@Autowired
 	private MerchantService merchantService;
+
+	@Autowired
+	private IOcrDataService ocrDataService;
     
 
     
@@ -1497,8 +1505,127 @@ public class SysLibController extends BaseController {
 		response.setCharacterEncoding("utf-8");
 	}
 
+//	/**
+//	 * 请求删除2021年前的文件,这个2021年写死。
+//	 * @param
+//	 * @return
+//	 */
+//	@RequestMapping(value = "/admin/delFile", method = RequestMethod.POST)
+//	@ResponseBody
+//	public Response delFile() {
+//		Response response = new  Response();
+//		try{
+//			//进来写入到redis
+//			String delState = tokenManager.getString("del_oss_file");
+//			if(delState == null){
+//				tokenManager.set("del_oss_file","1");
+//				//另起线程去处理删除
+//				ThreadUtil.execAsync(() -> {
+//					/**
+//					 * 查询2021年前的作业,数据量大
+//					 * 先查询最早一个月的数据,然后每次加一个月份查询数据做处理,知道2021年1月。
+//					 */
+//					// Endpoint以华东1(杭州)为例,其它Region请按实际情况填写。
+//					String endpoint = "https://oss-cn-shenzhen-internal.aliyuncs.com";
+//					// 阿里云账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维,请登录RAM控制台创建RAM用户。
+//					String accessKeyId = tokenManager.getString("sts_accessKeyId");
+//					String accessKeySecret = tokenManager.getString("sts_accessKeySecret");
+//					// 填写Bucket名称,例如examplebucket。
+//					String bucketName = tokenManager.getString("bucketName");
+//					String fileSavePath = PropertiesUtil.getValue("file_save_path");
+//					// 创建OSSClient实例。
+//					OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
+//					try {
+//						String startMonth = zuoybCourseService.findFirstMonth();
+//						LocalDateTime localDate=LocalDateTime.parse(startMonth, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+//						LocalDate localDate2 = localDate.toLocalDate();
+//						//截止年月日,取固定值20210101 删除2021年前学生作业图片
+//						LocalDate localDate1 = LocalDate.parse("20210101", DateTimeFormatter.BASIC_ISO_DATE);
+//						System.out.println("日期比较"+localDate1.compareTo(localDate2));
+//						while (localDate1.compareTo(localDate2)>0){
+//							String format = localDate2.format(DateTimeFormatter.ofPattern("yyyy-MM"));
+//							//查询该月份的作业
+//							List<String> fileKeyList = zuoybCourseService.findFileKeyList(format);
+//							if(fileKeyList==null || fileKeyList.size()==0){
+//								localDate2 =  localDate2.plusMonths(1);
+//								continue;
+//							}
+//							int fileSize = fileKeyList.size();
+//							// 删除文件。批量删除最多一次1000个。这里一次删除500
+//							int pageSize = 500;
+//							int pageCount = fileSize/pageSize;
+//							int leftNum = fileSize%pageSize;
+//							for(int i = 0;i<pageCount;i++){
+//								List<String> list2 = new ArrayList<>();
+//								list2.addAll(fileKeyList.subList(i*pageSize,(i+1)*pageSize));
+//								// 填写需要删除的多个文件完整路径。文件完整路径中不能包含Bucket名称。
+//								DeleteObjectsResult deleteObjectsResult = ossClient.deleteObjects(new DeleteObjectsRequest(bucketName).withKeys(list2).withEncodingType("url"));
+//								//这里没有查看删除返回的结果集了。List<String> deletedObjects = deleteObjectsResult.getDeletedObjects();
+//								//删除本地文件
+//								for(String str :list2){
+//									File file = new File(fileSavePath+"/"+str);
+//									if(file.exists()){
+//										file.delete();
+//									}
+//
+//								}
+//
+//								list2.clear();
+//							}
+//							if(leftNum>0){
+//								List<String> list3 = new ArrayList<>();
+//								list3.addAll(fileKeyList.subList(pageCount*pageSize,fileSize));
+//								// 填写需要删除的多个文件完整路径。文件完整路径中不能包含Bucket名称。
+//								DeleteObjectsResult deleteObjectsResult = ossClient.deleteObjects(new DeleteObjectsRequest(bucketName).withKeys(list3).withEncodingType("url"));
+//								//删除本地文件
+//								for(String str :list3){
+//									File file = new File(fileSavePath+"/"+str);
+//									if(file.exists()){
+//										file.delete();
+//									}
+//								}
+//								list3.clear();
+//							}
+//							fileKeyList.clear();
+//
+//							localDate2 =  localDate2.plusMonths(1);
+//						}
+//					}catch (OSSException oe) {
+//						System.out.println("Caught an OSSException, which means your request made it to OSS, "
+//								+ "but was rejected with an error response for some reason.");
+//						System.out.println("Error Message:" + oe.getErrorMessage());
+//						System.out.println("Error Code:" + oe.getErrorCode());
+//						System.out.println("Request ID:" + oe.getRequestId());
+//						System.out.println("Host ID:" + oe.getHostId());
+//					} catch (ClientException ce) {
+//						System.out.println("Caught an ClientException, which means the client encountered "
+//								+ "a serious internal problem while trying to communicate with OSS, "
+//								+ "such as not being able to access the network.");
+//						System.out.println("Error Message:" + ce.getMessage());
+//					}catch (Exception e){
+//						logger.error(e.getMessage());
+//						e.printStackTrace();
+//						response.failure("请求失败");
+//					} finally {
+//						if (ossClient != null) {
+//							ossClient.shutdown();
+//							System.out.println("----删除成功----");
+//						}
+//					}
+//
+//				});
+//			}
+//			response.success();
+//		}catch (Exception e){
+//			logger.error(e.getMessage());
+//			response.failure("请求失败");
+//		}
+//		return response;
+//	}
+
+
 	/**
-	 * 请求删除2021年前的文件,这个2021年写死。
+	 * 请求更新练习册isbn字段
 	 * @param
 	 * @return
 	 */
@@ -1506,166 +1633,121 @@ public class SysLibController extends BaseController {
 	@ResponseBody
 	public Response delFile() {
 		Response response = new  Response();
-		try{
-			//进来写入到redis
-			String delState = tokenManager.getString("del_oss_file");
-			if(delState == null){
-				tokenManager.set("del_oss_file","1");
-				//另起线程去处理删除
-				ThreadUtil.execAsync(() -> {
-					/**
-					 * 查询2021年前的作业,数据量大
-					 * 先查询最早一个月的数据,然后每次加一个月份查询数据做处理,知道2021年1月。
-					 */
-					// Endpoint以华东1(杭州)为例,其它Region请按实际情况填写。
-					String endpoint = "https://oss-cn-shenzhen-internal.aliyuncs.com";
-					// 阿里云账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维,请登录RAM控制台创建RAM用户。
-					String accessKeyId = tokenManager.getString("sts_accessKeyId");
-					String accessKeySecret = tokenManager.getString("sts_accessKeySecret");
-					// 填写Bucket名称,例如examplebucket。
-					String bucketName = tokenManager.getString("bucketName");
-					String fileSavePath = PropertiesUtil.getValue("file_save_path");
-					// 创建OSSClient实例。
-					OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
-					try {
-						String startMonth = zuoybCourseService.findFirstMonth();
-						LocalDateTime localDate=LocalDateTime.parse(startMonth, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
-						LocalDate localDate2 = localDate.toLocalDate();
-						//截止年月日,取固定值20210101 删除2021年前学生作业图片
-						LocalDate localDate1 = LocalDate.parse("20210101", DateTimeFormatter.BASIC_ISO_DATE);
-						System.out.println("日期比较"+localDate1.compareTo(localDate2));
-						while (localDate1.compareTo(localDate2)>0){
-							String format = localDate2.format(DateTimeFormatter.ofPattern("yyyy-MM"));
-							//查询该月份的作业
-							List<String> fileKeyList = zuoybCourseService.findFileKeyList(format);
-							if(fileKeyList==null || fileKeyList.size()==0){
-								localDate2 =  localDate2.plusMonths(1);
-								continue;
-							}
-							int fileSize = fileKeyList.size();
-							// 删除文件。批量删除最多一次1000个。这里一次删除500
-							int pageSize = 500;
-							int pageCount = fileSize/pageSize;
-							int leftNum = fileSize%pageSize;
-							for(int i = 0;i<pageCount;i++){
-								List<String> list2 = new ArrayList<>();
-								list2.addAll(fileKeyList.subList(i*pageSize,(i+1)*pageSize));
-								// 填写需要删除的多个文件完整路径。文件完整路径中不能包含Bucket名称。
-								DeleteObjectsResult deleteObjectsResult = ossClient.deleteObjects(new DeleteObjectsRequest(bucketName).withKeys(list2).withEncodingType("url"));
-								//这里没有查看删除返回的结果集了。List<String> deletedObjects = deleteObjectsResult.getDeletedObjects();
-								//删除本地文件
-								for(String str :list2){
-									File file = new File(fileSavePath+"/"+str);
-									if(file.exists()){
-										file.delete();
-									}
-
+		try {
+			com.aliyun.ocr_api20210707.Client client = createClient(tokenManager.getString("sts_accessKeyId"), tokenManager.getString("sts_accessKeySecret"));
+			String  imgUrl = tokenManager.getString("OSS_PATH");
+			/**
+			 * 查询q_workbook 中 back_url不为null的数据 根据年份排序 数据大概是1W(8982)左右。一次查出来了。
+			 */
+			ThreadUtil.execAsync(() -> {
+				try {
+					List<Map<String,Object>> backList = zuoybCourseService.findOrcImgList();
+					for(Map map:backList){
+						String reJson = "";
+						try {
+							com.aliyun.ocr_api20210707.models.RecognizeGeneralRequest recognizeGeneralRequest = new com.aliyun.ocr_api20210707.models.RecognizeGeneralRequest()
+									.setUrl(imgUrl+map.get("back_cover_url"));
+							com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
+							RecognizeGeneralResponse results = client.recognizeGeneralWithOptions(recognizeGeneralRequest, runtime);
+							reJson = new Gson().toJson(results);
+						}catch (Exception e){
+							e.printStackTrace();
+							continue;
+						}
+						String bookId = map.get("id").toString();
+						/**
+						 * 将book_id 以及返回json存入数据库,如果处理出错就不需要再次调用接口。
+						 */
+						ocrDataService.saveOrcData(bookId,reJson);
+						int i =  reJson.indexOf("ISBN");
+						if(i== -1){
+							//笨办法,旋转图片依次识别,如果都失败则放弃
+							for(int j=1;j<4;j++){
+								try {
+									com.aliyun.ocr_api20210707.models.RecognizeGeneralRequest req = new com.aliyun.ocr_api20210707.models.RecognizeGeneralRequest()
+											.setUrl(imgUrl+map.get("back_cover_url")+"?x-oss-process=image/auto-orient,0/resize,m_lfit,h_2000,w_2000,limit_1/rotate,"+90*j);
+									com.aliyun.teautil.models.RuntimeOptions runtime1 = new com.aliyun.teautil.models.RuntimeOptions();
+									RecognizeGeneralResponse resultsTemp = client.recognizeGeneralWithOptions(req, runtime1);
+									reJson = new Gson().toJson(resultsTemp);
+								}catch (Exception e){
+									e.printStackTrace();
+									continue;
 								}
-
-								list2.clear();
-							}
-							if(leftNum>0){
-								List<String> list3 = new ArrayList<>();
-								list3.addAll(fileKeyList.subList(pageCount*pageSize,fileSize));
-								// 填写需要删除的多个文件完整路径。文件完整路径中不能包含Bucket名称。
-								DeleteObjectsResult deleteObjectsResult = ossClient.deleteObjects(new DeleteObjectsRequest(bucketName).withKeys(list3).withEncodingType("url"));
-								//删除本地文件
-								for(String str :list3){
-									File file = new File(fileSavePath+"/"+str);
-									if(file.exists()){
-										file.delete();
-									}
+								ocrDataService.saveOrcData(bookId,reJson);
+								if(reJson.indexOf("ISBN")==-1){
+									continue;
+								}else{
+									i= reJson.indexOf("ISBN");
+									break;
 								}
-								list3.clear();
 							}
-							fileKeyList.clear();
-
-							localDate2 =  localDate2.plusMonths(1);
-						}
-					}catch (OSSException oe) {
-						System.out.println("Caught an OSSException, which means your request made it to OSS, "
-								+ "but was rejected with an error response for some reason.");
-						System.out.println("Error Message:" + oe.getErrorMessage());
-						System.out.println("Error Code:" + oe.getErrorCode());
-						System.out.println("Request ID:" + oe.getRequestId());
-						System.out.println("Host ID:" + oe.getHostId());
-					} catch (ClientException ce) {
-						System.out.println("Caught an ClientException, which means the client encountered "
-								+ "a serious internal problem while trying to communicate with OSS, "
-								+ "such as not being able to access the network.");
-						System.out.println("Error Message:" + ce.getMessage());
-					}catch (Exception e){
-						logger.error(e.getMessage());
-						e.printStackTrace();
-						response.failure("请求失败");
-					} finally {
-						if (ossClient != null) {
-							ossClient.shutdown();
-							System.out.println("----删除成功----");
+							if(i==-1){
+								continue;
+							}
 						}
+						String isbn = reJson.substring(i+4,i+22);
+						isbn = isbn.replace(" ","").replace("-","");
+
+						/**
+						 * 根据id更新表q_work_book 中的isbn字段
+						 */
+						zuoybCourseService.updateBookIsbn(bookId,isbn);
+						/**
+						 * 根据parent_book_id更新表kmt_exercise_book 中的isbn字段
+						 */
+						zuoybCourseService.updateExerciseIsbn(bookId,isbn);
+						;
 					}
+					backList.clear();
+				}catch (Exception e){
+					e.printStackTrace();
+				}
+					});
 
-				});
-			}
-			response.success();
-		}catch (Exception e){
-			logger.error(e.getMessage());
-			response.failure("请求失败");
+		} catch (TeaException error) {
+
+			com.aliyun.teautil.Common.assertAsString(error.message);
+		} catch (Exception _error) {
+			TeaException error = new TeaException(_error.getMessage(), _error);
+			com.aliyun.teautil.Common.assertAsString(error.message);
 		}
 		return response;
 	}
 
-	public static void main(String[] args) {
-		LocalDateTime localDate=LocalDateTime.parse("2018-06-13 16:05:26", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+	/**
+	 * 使用AK&SK初始化账号Client
+	 * @param accessKeyId
+	 * @param accessKeySecret
+	 * @return Client
+	 * @throws Exception
+	 */
+	public static   com.aliyun.ocr_api20210707.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
+		com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
+				// 必填,您的 AccessKey ID
+				.setAccessKeyId(accessKeyId)
+				// 必填,您的 AccessKey Secret
+				.setAccessKeySecret(accessKeySecret);
+		// 访问的域名
+		config.endpoint = "ocr-api.cn-hangzhou.aliyuncs.com";
+		return new com.aliyun.ocr_api20210707.Client(config);
+	}
 
-//		System.out.println(localDate);
-		LocalDate localDate2 = localDate.toLocalDate();
-		LocalDate localDate1 = LocalDate.parse("20210101", DateTimeFormatter.BASIC_ISO_DATE);
+	public static void main(String[] args_) throws Exception {
 
-		while (localDate1.compareTo(localDate2)>0){
-//			System.out.println(localDate1.compareTo(localDate2));
-			String format = localDate2.format(DateTimeFormatter.ofPattern("yyyy-MM"));
-			System.out.println(format);
-			localDate2 =  localDate2.plusMonths(1);
-		}
-//		int j =980;
-//		System.out.println(980/50);
-//		System.out.println(980%50);
-//		for(int i=1;i<=19;i++){
-//			System.out.println(19*50);
-//		}
-//		List<String> list = new ArrayList<>();
-//		list.add("1");
-//		list.add("2");
-//		list.add("3");
-//		list.add("4");
-//		list.add("5");
-//		list.add("6");
-//		list.add("7");
-//		list.add("8");
-//		list.add("9");
-//		list.add("10");
-//		list.add("11");
-//		list.add("12");
-//		list.add("13");
-//		list.add("14");
-//		int pageSize = 3;
-//		int pageCount = list.size()/pageSize;
-//		int leftNum = list.size()%pageSize;
-//		for(int i = 0;i<pageCount;i++){
-//			List<String> list2 = new ArrayList<>();
-//			list2.addAll(list.subList(i*pageSize,(i+1)*pageSize));
-//			for (String str:list2){
-//				System.out.println(str);
-//			}
-//		}
-//		if(leftNum>0){
-//			List<String> list3 = new ArrayList<>();
-//			list3.addAll(list.subList(pageCount*pageSize,list.size()));
-//			for (String str:list3){
-//				System.out.println(str);
-//			}
-//		}
 
 	}
+//	public static void main(String[] args) {
+//		LocalDateTime localDate=LocalDateTime.parse("2018-06-13 16:05:26", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+//
+////		System.out.println(localDate);
+//		LocalDate localDate2 = localDate.toLocalDate();
+//		LocalDate localDate1 = LocalDate.parse("20210101", DateTimeFormatter.BASIC_ISO_DATE);
+//
+//		while (localDate1.compareTo(localDate2)>0){
+////			System.out.println(localDate1.compareTo(localDate2));
+//			String format = localDate2.format(DateTimeFormatter.ofPattern("yyyy-MM"));
+//			System.out.println(format);
+//			localDate2 =  localDate2.plusMonths(1);
+//		}
+//	}
 }