更新清分同步任务
This commit is contained in:
parent
474aecfec6
commit
570daa37c0
@ -14,10 +14,11 @@ import java.util.Map;
|
||||
*/
|
||||
public interface XhpcHistoryOrderMapper {
|
||||
|
||||
List<XhpcHistoryOrderDomain> selectUnsyncOrderList();
|
||||
List<XhpcHistoryOrderDomain> selectUnsyncOrderList(@Param("limit") Integer limit);
|
||||
|
||||
int selectUnsyncOrderListCount();
|
||||
|
||||
int updateStatusBatchByOrderIds(@Param("orderIds") List<Long> orderIds, @Param("status") Integer status);
|
||||
int updateStatusBatchByOrderIds(@Param("orderIds") String orderIds, @Param("status") Integer status);
|
||||
|
||||
|
||||
BigDecimal selectUnclearingAmount(@Param("operatorId")String operatorId);
|
||||
|
||||
@ -5,6 +5,7 @@ import com.xhpc.activity.domain.XhpcClearingHistoryOrderDomain;
|
||||
import com.xhpc.activity.domain.XhpcHistoryOrderDomain;
|
||||
import com.xhpc.activity.mapper.XhpcClearingHistoryOrderMapper;
|
||||
import com.xhpc.activity.mapper.XhpcHistoryOrderMapper;
|
||||
import com.xhpc.common.core.utils.DateUtils;
|
||||
import com.xhpc.common.core.utils.bean.BeanUtils;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -12,11 +13,11 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Component
|
||||
@Transactional
|
||||
public class SyncHistoryOrderTask {
|
||||
|
||||
|
||||
@ -31,24 +32,39 @@ public class SyncHistoryOrderTask {
|
||||
* 每天六点自动同步一天之前所有未同步订单
|
||||
*/
|
||||
@Scheduled(cron = "0 0 6 * * ? ")
|
||||
private void ExpiredTenantStatusTask(){
|
||||
@Transactional
|
||||
void ExpiredTenantStatusTask(){
|
||||
System.out.println(" ============== 自动同步订单到清分 开始 ==========================");
|
||||
|
||||
List<XhpcHistoryOrderDomain> unclearingDomainList = historyOrderMapper.selectUnsyncOrderList();
|
||||
try {
|
||||
int orderTotal = historyOrderMapper.selectUnsyncOrderListCount();
|
||||
int oneTimeCount = 1000;
|
||||
System.out.println("总共查询到未清分审核订单记录:" + orderTotal);
|
||||
int count = 0;
|
||||
while (orderTotal > 0){
|
||||
List<XhpcHistoryOrderDomain> unClearingDomainList = historyOrderMapper.selectUnsyncOrderList(oneTimeCount);
|
||||
|
||||
List<XhpcClearingHistoryOrderDomain> clearingHistoryOrderDomainList = new ArrayList<>();
|
||||
List<Long> orderIds = new ArrayList<>();
|
||||
for (XhpcHistoryOrderDomain domain : unclearingDomainList){
|
||||
StringBuilder orderIds = new StringBuilder();
|
||||
for (XhpcHistoryOrderDomain domain : unClearingDomainList){
|
||||
XhpcClearingHistoryOrderDomain clearingDomain = new XhpcClearingHistoryOrderDomain();
|
||||
|
||||
BeanUtils.copyProperties(domain, clearingDomain);
|
||||
clearingDomain.setClearingOrderId(domain.getHistoryOrderId());
|
||||
clearingDomain.setCheckStatus(0);
|
||||
clearingHistoryOrderDomainList.add(clearingDomain);
|
||||
orderIds.add(domain.getHistoryOrderId());
|
||||
orderIds.append(",").append(domain.getHistoryOrderId());
|
||||
}
|
||||
clearingHistoryOrderMapper.insertBatch(clearingHistoryOrderDomainList);
|
||||
historyOrderMapper.updateStatusBatchByOrderIds(orderIds, 3);
|
||||
|
||||
historyOrderMapper.updateStatusBatchByOrderIds(orderIds.toString(), 3);
|
||||
orderTotal = orderTotal - oneTimeCount; count ++;
|
||||
System.out.println(" ============== 自动同步订单到清分 第"+count+"次循环结束,"+ DateUtils.parseDateToStr(new Date()) + " ==========================");
|
||||
}
|
||||
System.out.println(" ============== 自动同步订单到清分,结束 ==========================");
|
||||
} catch (Exception e){
|
||||
System.out.println(" ============= 同步异常 ============");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -83,6 +83,9 @@
|
||||
left join xhpc_charging_station as ct on ct.charging_station_id = ho.charging_station_id
|
||||
left join xhpc_operator as op on op.operator_id = ct.operator_id
|
||||
where ho.state <![CDATA[ <> ]]> 3 and ho.del_flag=0
|
||||
<if test="limit != null and limit > 0">
|
||||
limit #{limit}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
@ -98,10 +101,7 @@
|
||||
|
||||
<update id="updateStatusBatchByOrderIds">
|
||||
update xhpc_history_order set state=#{status}
|
||||
where history_order_id in
|
||||
<foreach collection="orderIds" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
where find_in_set(history_order_id, #{orderIds})
|
||||
</update>
|
||||
|
||||
|
||||
@ -195,4 +195,12 @@
|
||||
and ho.create_time <![CDATA[ <= ]]> #{endTime}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectUnsyncOrderListCount" resultType="java.lang.Integer">
|
||||
select
|
||||
count(1)
|
||||
from xhpc_history_order as ho
|
||||
where ho.state <![CDATA[ <> ]]> 3 and ho.del_flag=0
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user