Просмотр исходного кода

Merge branch 'master' of https://gogs.superdesk.cn/super_service/superdesk_superservice

longmeizhen@avic-s.com 2 лет назад
Родитель
Сommit
0bf150bb13

+ 2 - 0
src/main/java/com/palmnest/dao/repair/RepairBillDao.java

@@ -106,4 +106,6 @@ public interface RepairBillDao extends GenericDao<RepairBill, Long> {
 
 	Page getPeoplecOrderList(Map<String, Object> conditions,int type,int pageNo,int pageSize);
 
+	List<Integer> getAutomaticHighPraiseRepairData();
+
 }

+ 11 - 0
src/main/java/com/palmnest/dao/repair/impl/RepairBillDaoImpl.java

@@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
 
 import org.apache.commons.lang.StringUtils;
 import org.springframework.stereotype.Repository;
+import scala.collection.generic.BitOperations;
 
 import java.math.BigDecimal;
 import java.math.BigInteger;
@@ -876,5 +877,15 @@ public class RepairBillDaoImpl extends GenericDaoHibernate<RepairBill, Long> imp
         return pagedQueryByJdbcTemplate(sql.toString(), pageNo, pageSize);
     }
 
+    @Override
+    public List<Integer> getAutomaticHighPraiseRepairData() {
+
+        StringBuilder sql=new StringBuilder("");
+        sql.append("  SELECT id FROM tb_repair_bills WHERE `STATUS` = 8 and has_comment = 1 and TIMESTAMPDIFF(HOUR,end_time,NOW()) >= 168 ");
+
+        log.info(sql.toString());
+        return getJdbcTemplate().queryForList(sql.toString(), Integer.class);
+    }
+
 
 }

+ 3 - 0
src/main/java/com/palmnest/service/repair/RepairBillManager.java

@@ -131,4 +131,7 @@ public interface RepairBillManager extends GenericManager<RepairBill, Long> {
 	List<Map<String,Object>> getExportWxAmountOrder(Map<String, Object> conditions, int isFree, int type);
 
 	Page getPeoplecOrderList(Map<String, Object> conditions,int type,int pageNo,int pageSize);
+
+	//获取自动好评工程维修数据
+	List<Integer> getAutomaticHighPraiseRepairData();
 }

+ 3 - 0
src/main/java/com/palmnest/service/repair/RepairBillService.java

@@ -39,6 +39,9 @@ public interface RepairBillService {
 
 	public String grabBillOvertimePush() throws Exception;
 
+	//自动好好评
+	public String automaticHighPraise() throws Exception;
+
 	public String managePendBillPush() throws Exception;
 
 	public RepairSumIndexDto findBy(String userName);

+ 5 - 0
src/main/java/com/palmnest/service/repair/impl/RepairBillManagerImpl.java

@@ -795,4 +795,9 @@ public class RepairBillManagerImpl extends GenericManagerImpl<RepairBill, Long>
         return repairBillDao.getPeoplecOrderList(conditions, type,pageNo, pageSize);
     }
 
+    @Override
+    public List<Integer> getAutomaticHighPraiseRepairData() {
+        return repairBillDao.getAutomaticHighPraiseRepairData();
+    }
+
 }

+ 27 - 0
src/main/java/com/palmnest/service/repair/impl/RepairBillServiceImpl.java

@@ -670,6 +670,33 @@ public class RepairBillServiceImpl implements RepairBillService {
 		return null;
 	}
 
+	@Override
+	public String automaticHighPraise() throws Exception {
+
+		List<Integer> list  = repairBillManager.getAutomaticHighPraiseRepairData();
+		for(Integer repairId : list){
+
+			//看是否有评论记录
+			RepairBillComment repairBillComment =  repairBillCommentManager.findBy(Long.parseLong(repairId.toString()));
+			if(null != repairBillComment){
+				repairBillComment.setStar(5); //工程维修工单完成状态24*7小时后自动五星好评
+				repairBillCommentManager.updateModel(repairBillComment);
+			}else{
+				RepairBillComment saveRepairBillComment = new RepairBillComment();
+
+				saveRepairBillComment.setBillId(Long.parseLong(repairId.toString()));
+				saveRepairBillComment.setStar(5);
+				saveRepairBillComment.setCreateTime(new Date());
+				repairBillCommentManager.saveModel(saveRepairBillComment);
+			}
+			RepairBill repairBill=	repairBillManager.get(Long.parseLong(repairId.toString()));
+			repairBill.setHasComment(2); //是否有评论
+			repairBillManager.updateModel(repairBill);
+		}
+
+		return null;
+	}
+
 
 	@Override
 	public String managePendBillPush() throws Exception {

+ 13 - 0
src/main/java/com/palmnest/webapp/controller/backstage/RepairBillController.java

@@ -636,7 +636,20 @@ public class RepairBillController extends BaseFormController {
         }
     }
 
+    /**
+     * test
+     *
+     * @param request
+     * @return
+     */
+    @RequestMapping("/automaticHighPraise")
+    @ResponseBody
+    public AppResultDto automaticHighPraise(HttpServletRequest request) throws Exception {
 
+        repairBillService.automaticHighPraise();
+
+        return AppResultUtil.createSuccesDto("查询成功");
+    }
 
 
 

+ 33 - 0
src/main/java/com/palmnest/webapp/quartz/RepairAutomaticHighPraiseTask.java

@@ -0,0 +1,33 @@
+package com.palmnest.webapp.quartz;
+
+import com.palmnest.service.repair.RepairBillService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * 工程维修工单完成状态24*7小时后自动五星好评
+ * @author wangxz
+ * <p>
+ * 2018年5月15日
+ */
+@Slf4j
+@Component("repairAutomaticHighPraiseTask")
+public class RepairAutomaticHighPraiseTask {
+
+	@Autowired
+	private RepairBillService repairBillService;
+
+	public void run() {
+		log.info("quartz into RepairAutomaticHighPraiseTask start ...");
+		try {
+			repairBillService.automaticHighPraise();
+		} catch (Exception e) {
+			e.printStackTrace();
+			log.error(e.getMessage());
+		}
+		log.info("quartz into RepairAutomaticHighPraiseTask end ...");
+
+
+	}
+}

+ 15 - 0
src/main/resources/quartz_job2.xml

@@ -109,6 +109,20 @@
         </property>
     </bean>
 
+    <!-- 工程维修通知定时任务开始 -->
+    <bean id="repairAutomaticHighPraiseTimer"
+          class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
+        <property name="targetObject" ref="repairAutomaticHighPraiseTask"/>
+        <property name="targetMethod" value="run"/>
+    </bean>
+    <bean id="repairAutomaticHighPraiseTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
+        <property name="jobDetail" ref="repairAutomaticHighPraiseTimer"/>
+        <property name="cronExpression">
+            <value>0 30 0 * * ? *</value>
+        </property>
+    </bean>
+
+
 
     <!--空调加时单 申请时间大于当前时间  把状态改为已完成-->
     <bean id="airConditionerAddTimeTimer"
@@ -396,6 +410,7 @@
                 <ref local="moduleUserCountExpireTrigger"/>
                 <ref local="orderDinnerGetOrderInfoTrigger"/>
                 <ref local="snycKoalaPassLogTaskTrigger"/>
+                <ref local="repairAutomaticHighPraiseTrigger"/>
                 <!-- <ref local="repairGrabBillPushTrigger" />
                 <ref local="repairManagePendBillPushTrigger" />
                 <ref local="repairPendBillPushTrigger" /> -->