Commit dfbb37ed by wubh

包活干V2.1.0-大搜车线下单定时任务

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@28761 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 26213d85
package com.glsx.task.mapper;
import java.util.List;
import com.glsx.task.pojo.SysOrder;
import com.glsx.task.pojo.SysOrderDeviceSupplier;
import com.glsx.task.pojo.SysServiceItem;
import com.glsx.task.pojo.SysServiceItemDeviceConfig;
import org.apache.ibatis.annotations.Param;
/**
*
* @author zhanghj
* @version 1.0.0
* @Title SysOrderMapper.java
* @Package com.glsx.task.mapper
* @Description TODO 订单mapper
* @author zhanghj
* @date 2019年4月26日 上午11:41:17
* @version 1.0.0
*/
public interface SysOrderMapper {
/**
*
* @author zhanghj
* @Title: getTimeoutOrderList
* @Description: TODO 获取超时提醒订单列表
* @return
* List<SysOrder>
*
*/
List<SysOrder> getTimeoutOrderList();
/**
* @return List<SysOrder>
* @author zhanghj
* @Title: getTimeoutOrderList
* @Description: TODO 获取超时提醒订单列表
*/
List<SysOrder> getTimeoutOrderList();
List<SysOrder> selectByRecord(SysOrder order);
int updateByRecord(SysOrder order);
SysServiceItem selectServiceItemByRecord(SysServiceItem record);
List<SysServiceItemDeviceConfig> selectDeviceConfigByRecord(SysServiceItemDeviceConfig record);
List<SysOrderDeviceSupplier> selectDeviceSupplierByRecord(SysOrderDeviceSupplier record);
int insertDeviceSupplierBatch(@Param("deviceSupplierList")
List<SysOrderDeviceSupplier> deviceSupplierList);
List<String> selectDictDataByType(@Param("dictType") String dictType);
}
package com.glsx.task.pojo;
import java.util.Date;
/**
* 大搜车派单设备对应供应商
*/
public class SysOrderDeviceSupplier {
private int id;
private Integer orderId;
private String supplier;
private String supplierType;
private String chooseSupplier;
private Integer sort;
private Date createTime;
private Date updateTime;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public Integer getOrderId() {
return orderId;
}
public void setOrderId(Integer orderId) {
this.orderId = orderId;
}
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
public String getSupplier() {
return supplier;
}
public void setSupplier(String supplier) {
this.supplier = supplier;
}
public String getSupplierType() {
return supplierType;
}
public void setSupplierType(String supplierType) {
this.supplierType = supplierType;
}
public String getChooseSupplier() {
return chooseSupplier;
}
public void setChooseSupplier(String chooseSupplier) {
this.chooseSupplier = chooseSupplier;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
@Override
public String toString() {
return "SysOrderDeviceSupplier{" +
"id=" + id +
", orderId=" + orderId +
", supplier='" + supplier + '\'' +
", supplierType='" + supplierType + '\'' +
", chooseSupplier='" + chooseSupplier + '\'' +
", sort=" + sort +
", createTime=" + createTime +
", updateTime=" + updateTime +
'}';
}
}
package com.glsx.task.pojo;
import java.util.List;
public class SysServiceItem {
private Integer id;
/**
* 服务名称
*/
private String serviceName;
private String serviceCode;
private String imgPath;
/**
* 车务单推送接口
*/
private String pushUrl;
/**
* 新增工单信息补录
*/
private Byte isUpdateInfo;
/**
* 是否需要审核订单
*/
private Byte isAudit;
/**
* 业务类型
*/
private Byte type;
/**
* 设备配置列表
*/
private List<SysServiceItemDeviceConfig> deviceConfigList;
/**
* 照片数量
*/
private Integer photoCount;
/**
* 设备类型名称
*/
private String deviceTypeName;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getServiceName() {
return serviceName;
}
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
}
public String getServiceCode() {
return serviceCode;
}
public void setServiceCode(String serviceCode) {
this.serviceCode = serviceCode;
}
public String getImgPath() {
return imgPath;
}
public void setImgPath(String imgPath) {
this.imgPath = imgPath;
}
public String getPushUrl() {
return pushUrl;
}
public void setPushUrl(String pushUrl) {
this.pushUrl = pushUrl;
}
public Byte getIsUpdateInfo() {
return isUpdateInfo;
}
public void setIsUpdateInfo(Byte isUpdateInfo) {
this.isUpdateInfo = isUpdateInfo;
}
public Byte getIsAudit() {
return isAudit;
}
public void setIsAudit(Byte isAudit) {
this.isAudit = isAudit;
}
public Byte getType() {
return type;
}
public void setType(Byte type) {
this.type = type;
}
public List<SysServiceItemDeviceConfig> getDeviceConfigList() {
return deviceConfigList;
}
public void setDeviceConfigList(
List<SysServiceItemDeviceConfig> deviceConfigList) {
this.deviceConfigList = deviceConfigList;
}
public Integer getPhotoCount() {
return photoCount;
}
public void setPhotoCount(Integer photoCount) {
this.photoCount = photoCount;
}
public String getDeviceTypeName() {
return deviceTypeName;
}
public void setDeviceTypeName(String deviceTypeName) {
this.deviceTypeName = deviceTypeName;
}
@Override
public String toString() {
return "SysServiceItem{" +
"id=" + id +
", serviceName='" + serviceName + '\'' +
", serviceCode='" + serviceCode + '\'' +
", imgPath='" + imgPath + '\'' +
", pushUrl='" + pushUrl + '\'' +
", isUpdateInfo=" + isUpdateInfo +
", isAudit=" + isAudit +
", type=" + type +
", deviceConfigList=" + deviceConfigList +
", photoCount=" + photoCount +
", deviceTypeName='" + deviceTypeName + '\'' +
'}';
}
}
package com.glsx.task.pojo;
import java.util.List;
public class SysServiceItemDeviceConfig {
private Integer id;
private Integer serviceItemId;
private String deviceType;
private Boolean isVerifyStock;
private Boolean isInstallLocation;
private String deviceVerifyUri;
private String syncUri;
private Byte sort;
private String remark;
/**
* 设备类型名称
*/
private String deviceTypeName;
private List<String> suppliers;
private String chooseSupplier;
private Integer indexNo;
public Integer getIndexNo() {
return indexNo;
}
public void setIndexNo(Integer indexNo) {
this.indexNo = indexNo;
}
public List<String> getSuppliers() {
return suppliers;
}
public void setSuppliers(List<String> suppliers) {
this.suppliers = suppliers;
}
public String getChooseSupplier() {
return chooseSupplier;
}
public void setChooseSupplier(String chooseSupplier) {
this.chooseSupplier = chooseSupplier;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getServiceItemId() {
return serviceItemId;
}
public void setServiceItemId(Integer serviceItemId) {
this.serviceItemId = serviceItemId;
}
public String getDeviceType() {
return deviceType;
}
public void setDeviceType(String deviceType) {
this.deviceType = deviceType == null ? null : deviceType.trim();
}
public Boolean getIsVerifyStock() {
return isVerifyStock;
}
public void setIsVerifyStock(Boolean isVerifyStock) {
this.isVerifyStock = isVerifyStock;
}
public Boolean getIsInstallLocation() {
return isInstallLocation;
}
public void setIsInstallLocation(Boolean isInstallLocation) {
this.isInstallLocation = isInstallLocation;
}
public String getDeviceVerifyUri() {
return deviceVerifyUri;
}
public void setDeviceVerifyUri(String deviceVerifyUri) {
this.deviceVerifyUri = deviceVerifyUri == null ? null : deviceVerifyUri.trim();
}
public String getSyncUri() {
return syncUri;
}
public void setSyncUri(String syncUri) {
this.syncUri = syncUri == null ? null : syncUri.trim();
}
public Byte getSort() {
return sort;
}
public void setSort(Byte sort) {
this.sort = sort;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark == null ? null : remark.trim();
}
public String getDeviceTypeName() {
return deviceTypeName;
}
public void setDeviceTypeName(String deviceTypeName) {
this.deviceTypeName = deviceTypeName;
}
@Override
public String toString() {
return "SysServiceItemDeviceConfig{" +
"id=" + id +
", serviceItemId=" + serviceItemId +
", deviceType='" + deviceType + '\'' +
", isVerifyStock=" + isVerifyStock +
", isInstallLocation=" + isInstallLocation +
", deviceVerifyUri='" + deviceVerifyUri + '\'' +
", syncUri='" + syncUri + '\'' +
", sort=" + sort +
", remark='" + remark + '\'' +
", deviceTypeName='" + deviceTypeName + '\'' +
", suppliers=" + suppliers +
", chooseSupplier='" + chooseSupplier + '\'' +
", indexNo=" + indexNo +
'}';
}
}
package com.glsx.task.schedule;
import com.glsx.task.service.DscOrderServiceTask;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
* <p>Description:
* <p>Project: car-service
*
* @author wbh
* @date 2020-09-30
*/
@Component
@EnableScheduling
public class DscOrderTask {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private DscOrderServiceTask dscOrderServiceTask;
@Scheduled(cron = "0 0/5 * * * ?")
public void executeTask() {
this.logger.info("==== DSC offline data task started...");
this.dscOrderServiceTask.fillOfflineOrderData();
this.logger.info("==== DSC offline data task finished.");
}
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
this.logger.info("==== DSC offline data task started...");
this.logger.info("==== DSC offline data task finished.");
}
}
package com.glsx.task.service;
import com.glsx.plat.core.web.R;
/**
* <p>Description:
* <p>Project: car-service
*
* @author wbh
* @date 2020-09-30
*/
public interface DscOrderServiceTask {
R fillOfflineOrderData();
}
package com.glsx.task.service.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.glsx.common.utils.DateUtil;
import com.glsx.common.utils.StringUtils;
import com.glsx.plat.core.web.R;
import com.glsx.task.mapper.SysOrderMapper;
import com.glsx.task.pojo.SysOrder;
import com.glsx.task.pojo.SysOrderDeviceSupplier;
import com.glsx.task.pojo.SysServiceItem;
import com.glsx.task.pojo.SysServiceItemDeviceConfig;
import com.glsx.task.service.DscOrderServiceTask;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* <p>Description:
* <p>Project: car-service
*
* @author wbh
* @date 2020-09-30
*/
@Service
public class DscOrderServiceTaskImpl implements DscOrderServiceTask {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private SysOrderMapper orderMapper;
@Override
public R fillOfflineOrderData() {
List<SysOrder> offlineOrderList = this.getDscOfflineOrderList();
if (CollectionUtils.isNotEmpty(offlineOrderList)) {
this.logger.info("==== DSC offline order detected, now updating...");
this.fillOfflineOrder(offlineOrderList);
} else {
this.logger.info("==== DSC offline order not detected.");
}
return R.ok();
}
private List<SysOrder> getDscOfflineOrderList() {
SysOrder record = new SysOrder();
record.setServiceCode("DSC_Mutil_Offline");
record.setCreateTime(DateUtil.parseDateYmd("2020-09-30"));
List<SysOrder> orderList = this.orderMapper.selectByRecord(record);
return orderList;
}
private void fillOfflineOrder(List<SysOrder> orderList) {
for (SysOrder order : orderList) {
this.updateOfflineOrder(order);
List<SysOrderDeviceSupplier> savedSupplierList = this.getDeviceSupplierList(order);
// 不存在供应商则插入
if (CollectionUtils.isEmpty(savedSupplierList)) {
this.logger.info("==== inserting device suppliers...");
List<SysOrderDeviceSupplier> supplierList = this.buildDeviceSupplierList(order);
this.insertOrderDeviceSupplier(supplierList);
}
}
}
private void updateOfflineOrder(SysOrder order) {
order.setChannel("DSC");
this.orderMapper.updateByRecord(order);
}
private List<SysOrderDeviceSupplier> getDeviceSupplierList(SysOrder order) {
SysOrderDeviceSupplier record = new SysOrderDeviceSupplier();
record.setOrderId(order.getId());
List<SysOrderDeviceSupplier> deviceSupplierList = this.orderMapper
.selectDeviceSupplierByRecord(record);
return deviceSupplierList;
}
private List<SysOrderDeviceSupplier> buildDeviceSupplierList(SysOrder order) {
List<SysOrderDeviceSupplier> deviceSupplierList = new ArrayList<>();
SysServiceItem siRecord = new SysServiceItem();
siRecord.setServiceCode(order.getServiceCode());
SysServiceItem serviceItem = this.orderMapper.selectServiceItemByRecord(siRecord);
if (serviceItem != null) {
SysServiceItemDeviceConfig sidcRecord = new SysServiceItemDeviceConfig();
sidcRecord.setServiceItemId(serviceItem.getId());
List<SysServiceItemDeviceConfig> deviceConfigList = this.orderMapper
.selectDeviceConfigByRecord(sidcRecord);
Date now = new Date();
for (SysServiceItemDeviceConfig config : deviceConfigList) {
SysOrderDeviceSupplier supplier = new SysOrderDeviceSupplier();
supplier.setOrderId(order.getId());
supplier.setSupplier(this.getDeviceSupplierStr());
supplier.setSupplierType(config.getDeviceType());
supplier.setSort(Integer.valueOf(config.getSort()));
supplier.setCreateTime(now);
supplier.setUpdateTime(now);
deviceSupplierList.add(supplier);
}
}
return deviceSupplierList;
}
private void insertOrderDeviceSupplier(List<SysOrderDeviceSupplier> deviceSupplierList) {
this.orderMapper.insertDeviceSupplierBatch(deviceSupplierList);
}
private String getDeviceSupplierStr() {
List<String> valueList = this.orderMapper.selectDictDataByType(
"sys_order_dasouche_supplier");
return StringUtils.join(valueList, "#");
}
}
......@@ -20,6 +20,7 @@
<result column="car_color" jdbcType="VARCHAR" property="carColor" />
<result column="expect_install_time" jdbcType="TIMESTAMP" property="expectInstallTime" />
<result column="service_type" jdbcType="VARCHAR" property="serviceType" />
<result column="service_code" jdbcType="VARCHAR" property="serviceCode"/>
<result column="car_owner" jdbcType="VARCHAR" property="carOwner" />
<result column="car_owner_phone" jdbcType="VARCHAR" property="carOwnerPhone" />
<result column="cancel_time" jdbcType="TIMESTAMP" property="cancelTime" />
......@@ -50,7 +51,7 @@
<result column="reassign_mechanic_time" jdbcType="TIMESTAMP" property="reassignMechanicTime" />
<result column="public_openId" jdbcType="VARCHAR" property="publicOpenId" />
</resultMap>
<select id="getTimeoutOrderList" resultMap="BaseResultMap">
<!-- 1.order_id 是null,则此单没发过任何任何类型的推送消息,
2.roder_id 不是null,
......@@ -87,13 +88,13 @@
sys_order_wechat_msg sowm
WHERE
so.id = sowm.order_id
AND
AND
sowm.msg_type = 6
)
AND so.active_status IN (6, 7)
AND so.canceled = 1
AND su.public_openId != ''
UNION
SELECT
......@@ -123,10 +124,10 @@
sys_order_wechat_msg sowm
WHERE
so.id = sowm.order_id
AND
AND
sowm.msg_type = 6
and so.reassign_mechanic_time &gt;
(SELECT MAX(create_time)
and so.reassign_mechanic_time &gt;
(SELECT MAX(create_time)
FROM sys_order_wechat_msg sowm
WHERE
so.id = sowm.order_id
......@@ -146,4 +147,73 @@
END
</select>
</mapper>
\ No newline at end of file
<select id="selectByRecord" parameterType="com.glsx.task.pojo.SysOrder"
resultMap="BaseResultMap">
select o.*
from sys_order o
<where>
<if test="id != null">
and o.id = #{id,jdbcType=INTEGER}
</if>
<if test="serviceCode != null and serviceCode != ''">
and o.service_code = #{serviceCode,jdbcType=VARCHAR}
</if>
and (o.channel is null or o.channel = '')
and o.canceled = 1
and o.create_time >= #{createTime,jdbcType=TIMESTAMP}
</where>
order by o.create_time desc
</select>
<update id="updateByRecord" parameterType="com.glsx.task.pojo.SysOrder">
update sys_order o
set o.channel = #{channel,jdbcType=VARCHAR}
where o.id = #{id}
</update>
<select id="selectDeviceSupplierByRecord" parameterType="com.glsx.task.pojo.SysOrderDeviceSupplier"
resultType="com.glsx.task.pojo.SysOrderDeviceSupplier">
select ods.*
from sys_order_device_supplier ods
<where>
<if test="orderId != null">
and order_id = #{orderId,jdbcType=INTEGER}
</if>
</where>
</select>
<insert id="insertDeviceSupplierBatch" parameterType="com.glsx.task.pojo.SysOrderDeviceSupplier">
insert into sys_order_device_supplier (order_id, supplier, supplier_type,
choose_supplier, sort, create_time, update_time)
values
<foreach collection="deviceSupplierList" item="item" separator=",">
(#{item.orderId,jdbcType=INTEGER}, #{item.supplier,jdbcType=VARCHAR},
#{item.supplierType,jdbcType=VARCHAR}, #{item.chooseSupplier,jdbcType=VARCHAR},
#{item.sort,jdbcType=INTEGER}, #{item.createTime,jdbcType=TIMESTAMP},
#{item.updateTime,jdbcType=TIMESTAMP})
</foreach>
</insert>
<select id="selectDictDataByType" parameterType="string" resultType="string">
select dd.data_value
from sys_dict_data dd
where dd.dict_type = #{dictType,jdbcType=VARCHAR}
and dd.data_status = 1
</select>
<select id="selectServiceItemByRecord" parameterType="com.glsx.task.pojo.SysServiceItem"
resultType="com.glsx.task.pojo.SysServiceItem">
select si.id, si.service_code serviceCode, si.service_name serviceName
from sys_service_item si
where si.service_code = #{serviceCode,jdbcType=VARCHAR}
</select>
<select id="selectDeviceConfigByRecord"
parameterType="com.glsx.task.pojo.SysServiceItemDeviceConfig"
resultType="com.glsx.task.pojo.SysServiceItemDeviceConfig">
select sidc.id, sidc.service_item_id serviceItemId, sidc.device_type deviceType,
sidc.sort sort
from sys_service_item_device_config sidc
where sidc.service_item_id = #{serviceItemId,jdbcType=INTEGER}
</select>
</mapper>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!