Browse Source

专利提醒逻辑修改

anderx 4 years ago
parent
commit
bea141d4ac

+ 3 - 3
src/main/java/com/goafanti/common/mapper/PatentNewMapper.xml

@@ -555,10 +555,10 @@
 
 	<select id="AllselectStartPatentNew" resultType="com.goafanti.patent.bo.PatentNewBo">
 		select
-		a.id,a.patent_no patentNo,a.name ,a.aid ,a.email ,a.end_date endDate,a.status
-		,c.buyer_name userName,a.salesman_remind salesmanRemind
+			a.id,a.patent_no patentNo,a.name ,a.aid ,a.email ,a.end_date endDate,a.status
+			 ,c.buyer_name userName,a.salesman_remind salesmanRemind
 		from patent_new a left join t_order_task b on a.tid =b.id left join
-		t_order_mid c on b.order_no=c.order_no
+			 t_order_mid c on b.order_no=c.order_no where a.status &lt; 6
 	</select>
 	<select id="AllselectEndPatentNew" resultMap="BaseResultMap">
 		select

+ 21 - 16
src/main/java/com/goafanti/common/task/PatentTask.java

@@ -104,8 +104,27 @@ public class PatentTask {
 					flag=true;
 					status = 5;
 					s5.add(p.getId().toString());
-				}else if(count<0&&p.getSalesmanRemind()==1) {
+				}else if(count<0) {
 					s6.add(p.getId().toString());
+					if (p.getSalesmanRemind()==0){
+						Notice n = new Notice();
+						n.setId(UUID.randomUUID().toString());
+						n.setCreateTime(date);
+						n.setReaded(0);// 未读
+						n.setNoticeType(NoticeStatus.TASK_PATENT_ERROR.getCode());
+						PatentNewLog pl = new PatentNewLog();
+						StringBuffer str =new StringBuffer();
+						str.append("专利编号[").append(p.getPatentNo()).append("],名称[").append(p.getName()).append("],email[")
+								.append(p.getEmail().trim()).append("]").append("提醒结束时间已超过,但未做提醒!!!请悉知。");
+						pl.setContent(str.toString());
+						pl.setCreateTime(new Date());
+						pl.setPid(p.getId());
+						logList.add(pl);
+						n.setAid(p.getAid());
+						n.setNoticeType(NoticeStatus.TASK_PATENT_REMIND.getCode());
+						n.setContent(str.toString());
+						nlist.add(n);
+					}
 				}
 				if (flag) {
 					Notice n = new Notice();
@@ -160,7 +179,7 @@ public class PatentTask {
 			updatePatentNew(s3,3);
 			updatePatentNew(s4,4);
 			updatePatentNew(s5,5);
-			pushPatentNewStatus(s6);
+			patentNewService.pushResetPatentNew(s6);
 			
 		} catch (Exception e) {
 			LoggerUtils.debug(getClass(), "=====================专利提醒失败======================");
@@ -174,20 +193,6 @@ public class PatentTask {
 	}
 
 
-	private void pushPatentNewStatus(List<String> s6) throws InterruptedException {
-		List<PatentNewLog> logs = new ArrayList<>();
-		for (String string : s6) {
-			PatentNewLog log=new PatentNewLog();
-			log.setContent("超过时间重置状态并计算下一年");
-			log.setCreateTime(new Date());
-			log.setPid(Integer.valueOf(string));
-			logs.add(log);
-		}
-		pushPatentLog(logs);
-		patentNewService.pushResetPatentNew(s6);
-	}
-
-
 
 
 	private void pushNotice(List<Notice> nlist) throws InterruptedException {

+ 1 - 1
src/main/java/com/goafanti/patent/service/PatentNewService.java

@@ -43,7 +43,7 @@ public interface PatentNewService {
 
 	void updateBatchStatusByid(List<String> l2, Integer status);
 
-	void pushResetPatentNew(List<String> list);
+	void pushResetPatentNew(List<String> list) throws InterruptedException;
 
 	boolean checkTid(Integer tid);
 

+ 36 - 4
src/main/java/com/goafanti/patent/service/impl/PatentNewServiceImpl.java

@@ -663,24 +663,56 @@ public class PatentNewServiceImpl  extends BaseMybatisDao<PatentNewMapper> imple
 	 * 超过时间重置到第二年
 	 */
 	@Override
-	public void pushResetPatentNew(List<String> list) {
+	public void pushResetPatentNew(List<String> list) throws InterruptedException {
+		List<PatentNewLog> logs = new ArrayList<>();
+
+
 		for (String ids : list) {
 			PatentNew pn=patentNewMapper.selectByPrimaryKey(Integer.valueOf(ids));
 			int year=pn.getYears()+1;
 			PatentPaymentDetails ppd=patentPaymentDetailsMapper.selectByPidAndYear(pn.getId(),year);
+			//未找到下一年则计算看是否存在
 			if (ppd==null) {
 				sumYears(pn);
 				ppd=patentPaymentDetailsMapper.selectByPidAndYear(pn.getId(),year);
+
 			}
+
 			PatentNew n=new PatentNew();
 			n.setId(pn.getId());
 			n.setStatus(0);
 			n.setSalesmanRemind(0);
-			n.setYears(ppd.getYears());
-			n.setEndDate(ppd.getEndDate());
-			n.setPatentAmount(sumAmout(pn.getType(),pn.getTid(),pn.getYears()));
+			//还是未找到,判断为不存在一下年,判断提醒已完成
+			if(ppd==null){
+				n.setStatus(6);
+			}else{
+				n.setYears(ppd.getYears());
+				n.setEndDate(ppd.getEndDate());
+				n.setPatentAmount(sumAmout(pn.getType(),pn.getTid(),pn.getYears()));
+				PatentNewLog log=new PatentNewLog();
+				log.setContent("超过时间重置状态并计算下一年");
+				log.setCreateTime(new Date());
+				log.setPid(Integer.valueOf(ids));
+				logs.add(log);
+			}
 			patentNewMapper.updateByPrimaryKeySelective(n);
 		}
+		pushPatentLog(logs);
+	}
+
+	private void pushPatentLog(List<PatentNewLog> logList) throws InterruptedException {
+		if (!logList.isEmpty()) {
+			List<PatentNewLog> logList2 = new ArrayList<>();
+			for (int i = 0; i < logList.size(); i++) {
+				logList2.add(logList.get(i));
+				if (50 == logList2.size() || i == logList.size() - 1) {
+					if (logList2.size() > 0) insertLogBatch(logList2);
+					Thread.sleep(2000);
+					logList2.clear();
+				}
+			}
+
+		}
 	}
 
 	@Override