自动评价及判断订单表是否已经写入
来源:互联网 发布:手写识别软件 编辑:程序博客网 时间:2024/05/18 03:06
在一般情况下,评价低的需要回访。如果为评价的也要回访(即全部要回访)。下面的dao里的sql语句是非常妙,不需要判断订单表是否已经写入回访表了
package com.tianjian.property.management.scheduled;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled; 定时器
import org.springframework.stereotype.Component;
import com.tianjian.property.service.ReturningService;
/**
* 自动把未评价的单添加到回访表里
*/
@Component
public class AutoReturn {
@Autowired
private ReturningService returningService;
@Scheduled(cron = "0 02/38 * * * ?") //定时器
public void importData() {
returningService.autoReturnIng();
}
}
package com.tianjian.property.service;
import java.beans.IntrospectionException;
import java.lang.reflect.InvocationTargetException;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.tianjian.property.constant.Constant;
import com.tianjian.property.dao.ReturningDao;
import com.tianjian.property.dao.WorkOrderDao;
import com.tianjian.property.dao.system.EUsersDao;
import com.tianjian.property.entity.Returning;
import com.tianjian.property.entity.WorkOrder;
import com.tianjian.property.entity.common.Pagination;
import com.tianjian.property.entity.system.Admin;
import com.tianjian.property.entity.system.EUsers;
import com.tianjian.property.util.CommonUtil;
@Service
@Transactional
public class ReturningService {
@Autowired
private ReturningDao returningDao;
@Autowired
private EUsersDao eUsersDao;
@Autowired
private WorkOrderDao workOrderDao;
private Log log = LogFactory.getLog(ReturningService.class);
public void addReturning(Returning returning){
try {
this.returningDao.addReturing(returning);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
| IntrospectionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public Pagination<Returning> getAll(Integer cityId, Integer countyId, Integer propertyId, Integer page,
Integer limit, String workOrderType, String startTime, String endTime) {
Admin admin = CommonUtil.currentAdminDetails();
EUsers euser = eUsersDao.getByEUserId(admin.geteUserId());
if (null == euser)
return null;
return returningDao.getAll(cityId, countyId, propertyId, page, limit, workOrderType, startTime, endTime, euser);
}
/**
* 自动评价
*auth lxl
*/
public void autoReturnIng(){
log.warn("自动评价 定时器启动 ");
List<WorkOrder> workOrderArray =workOrderDao.getNotComment();
log.warn("未评论数据 " + workOrderArray.size());
Timestamp nowTime = new Timestamp(new Date().getTime()); // 当前时间
for(WorkOrder w:workOrderArray){
log.warn("开始自动 添加回访单 订单号 " + w.getWorkOrderNo());
Long dd = nowTime.getTime() - w.getAddtime().getTime();
int dd2=(int) Math.floor(dd);
int ddValue = dd2/(1000*60*60);//小时
int ddIntValue = ddValue;//计算相差多少小时
String kk3="3";
if(w.getWorkOrderType().toString().equals(kk3)){//投诉实时
log.warn(w.getWorkOrderType()+"---Returning:"+buildReturning(w));
addReturning(buildReturning(w));
}
String kk4="4";String kk5="5";String kk6="6";String kk7="7";
String kk1="1";String kk2="2";int s4=4;
if(w.getStatus().toString().equals(kk4)||w.getStatus().toString().equals(kk5)||w.getStatus().toString().equals(kk6)||w.getStatus().toString().equals(kk7)){
if(ddIntValue>=s4){//居家和公共4小时后未评价进入回访表
if(w.getWorkOrderType().toString().equals(kk1)||w.getWorkOrderType().toString().equals(kk2)){
log.warn(w.getWorkOrderType()+"---Returning:"+buildReturning(w));
addReturning(buildReturning(w));
}}
}
}
log.warn("自动评价 定时器结束 ");
}
private Returning buildReturning(WorkOrder order){
Returning returning=new Returning();
returning.setWorkOrderNo(order.getWorkOrderNo());
returning.setWorkOrderId(order.getId());
returning.setType(order.getWorkOrderType());
returning.setContPhone(order.getPhone());
returning.setStatus(Constant.WAITING_VISIT);
returning.setReasonType(Constant.NOT_COMMENT);
returning.setAddTime(new Timestamp(new Date().getTime()));
returning.setExtension(0); //延期时间
returning.setAskName(order.getUserName());
returning.setAskId(String.valueOf(order.getUserId()));
return returning;
}
}
//Dao
public List<WorkOrder> getNotComment() {
String sql = "select R.* from t_WorkOrder R "
+ "left join t_Returning t on t.WorkOrderId = R.Id "
+ "where "
+ "t.Id is null "
+ "and (R.IsComment = 0 or R.IsComment is null) "
+ "and R.status = :Status ";
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("Status", 4);
List<WorkOrder> workOrderArray = this.namedJdbcTemplate.query(sql, paramMap , table.getRowMapper());
return workOrderArray;
}
public void addReturing(Returning returning) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, IntrospectionException{
Map<String,Object> map=BeanUtils.transBean2Map(returning);
String sql="INSERT INTO t_Returning(Type,WorkOrderId,WorkOrderNo,Status,ContPhone,ReasonType,Extension,AddTime) "
+ " VALUES(:type,:workOrderId,:workOrderNo,:status,:contPhone,:reasonType,:extension,:addTime)";
if (!StringUtils.isEmpty(returning.getType())) {
map.put("type",returning.getType());
}
if (!StringUtils.isEmpty(String.valueOf(returning.getWorkOrderId()))) {
map.put("workOrderId",returning.getWorkOrderId());
}
if (!StringUtils.isEmpty(returning.getWorkOrderNo())) {
map.put("workOrderNo",returning.getWorkOrderNo());
}
if (!StringUtils.isEmpty(returning.getContPhone())) {
map.put("status",returning.getStatus());
}
if (!StringUtils.isEmpty(returning.getContPhone())) {
map.put("contPhone",returning.getContPhone());
}
if (!StringUtils.isEmpty(String.valueOf(returning.getReasonType()))) {
map.put("reasonType",returning.getReasonType());
}
if (!StringUtils.isEmpty(returning.getExtension().toString())) {
map.put("extension",returning.getExtension());
}
if (!StringUtils.isEmpty(returning.getAddTime().toString())) {
map.put("addTime",returning.getAddTime());
}
this.namedJdbcTemplate.update(sql, map);
}
public static Map<String, Object> transBean2Map(Object obj) {
if(obj == null){
return null;
}
Map<String, Object> map = new HashMap<>();
try {
BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
for (PropertyDescriptor property : propertyDescriptors) {
String key = property.getName();
// 过滤class属性
if (!key.equals("class")) {
// 得到property对应的getter方法
Method getter = property.getReadMethod();
Object value = getter.invoke(obj);
map.put(key, value);
}
}
} catch (IntrospectionException | InvocationTargetException | IllegalAccessException e) {
e.printStackTrace();
}
return map;
}
- 自动评价及判断订单表是否已经写入
- 判断订单是否被锁定
- 判断程序是否已经打开
- 判断程序是否已经运行
- 判断网络是否已经断线
- 判断服务是否已经启动
- 判断窗体是否已经打开
- 判断表单是否已经打开
- 判断AccessibilityService是否已经启用
- 判断DialogFragment是否已经显示
- 判断DialogFragment是否已经显示
- 判断ocx是否已经注册
- 判断AccessibilityService是否已经启用
- 判断是否已经引入js
- 判断文件是否写入完毕
- 提交时间段订单判断是否重复
- 存储过程中判断临时表是否已经存在方法
- java web点击链接用js判断用户是否已经登录 (js获取session及判断是否为空)
- 【python】【leetcode】【算法题目344—Reverse String】
- Oracle性能优化-读懂执行计划
- ionic助手 v1.9.0 一键式开发环境工具(告别命令行,超强功能)
- 【JVM】内存区域分配机制和内存溢出异常
- 控件资源的标识:例如IDC_EDIT.IDC_BUTTON,IDI_MENU,IDD_POP等!
- 自动评价及判断订单表是否已经写入
- mysql中文乱码的解决办法
- (一)K好数 动态规划
- Http协议详解
- ORACLE外部表总结
- 各种图片上传
- 七牛Golang SDK简单使用教程
- 归纳下js面向对象的几种常见写法
- linux ssh配置