更改同步清分订单的任务
This commit is contained in:
parent
230cc1e34e
commit
4ab77c7fa9
@ -14,9 +14,11 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public interface XhpcHistoryOrderMapper {
|
public interface XhpcHistoryOrderMapper {
|
||||||
|
|
||||||
List<XhpcHistoryOrderDomain> selectUnsyncOrderList(@Param("limit") Integer limit);
|
List<XhpcHistoryOrderDomain> selectUnsyncOrderList();
|
||||||
|
|
||||||
int selectUnsyncOrderListCount();
|
String selectSyncedOrderIds();
|
||||||
|
|
||||||
|
int selectUnsyncOrderListCount(@Param("endTime")String endTime);
|
||||||
|
|
||||||
int updateStatusBatchByOrderIds(@Param("orderIds") String orderIds, @Param("status") Integer status);
|
int updateStatusBatchByOrderIds(@Param("orderIds") String orderIds, @Param("status") Integer status);
|
||||||
|
|
||||||
|
|||||||
@ -5,16 +5,14 @@ import com.xhpc.activity.domain.XhpcClearingHistoryOrderDomain;
|
|||||||
import com.xhpc.activity.domain.XhpcHistoryOrderDomain;
|
import com.xhpc.activity.domain.XhpcHistoryOrderDomain;
|
||||||
import com.xhpc.activity.mapper.XhpcClearingHistoryOrderMapper;
|
import com.xhpc.activity.mapper.XhpcClearingHistoryOrderMapper;
|
||||||
import com.xhpc.activity.mapper.XhpcHistoryOrderMapper;
|
import com.xhpc.activity.mapper.XhpcHistoryOrderMapper;
|
||||||
import com.xhpc.common.core.utils.DateUtils;
|
import com.xhpc.common.core.utils.StringUtils;
|
||||||
import com.xhpc.common.core.utils.bean.BeanUtils;
|
import com.xhpc.common.core.utils.bean.BeanUtils;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@ -34,35 +32,40 @@ public class SyncHistoryOrderTask {
|
|||||||
*/
|
*/
|
||||||
@Scheduled(cron = "0 0 0/1 * * ?")
|
@Scheduled(cron = "0 0 0/1 * * ?")
|
||||||
@Transactional
|
@Transactional
|
||||||
void ExpiredTenantStatusTask(){
|
void ExpiredTenantStatusTask() {
|
||||||
System.out.println(" ============== 自动同步订单到清分 开始 ==========================");
|
System.out.println(" ============== 自动同步订单到清分 开始 ==========================");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int orderTotal = historyOrderMapper.selectUnsyncOrderListCount();
|
String syncedOrderIds = historyOrderMapper.selectSyncedOrderIds();
|
||||||
int oneTimeCount = 1000;
|
if (StringUtils.isNotEmpty(syncedOrderIds)) {
|
||||||
System.out.println("总共查询到未清分审核订单记录:" + orderTotal);
|
historyOrderMapper.updateStatusBatchByOrderIds(syncedOrderIds, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isFinish = false;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
while (orderTotal > 0){
|
while (!isFinish) {
|
||||||
List<XhpcHistoryOrderDomain> unClearingDomainList = historyOrderMapper.selectUnsyncOrderList(oneTimeCount);
|
List<XhpcHistoryOrderDomain> unClearingDomainList = historyOrderMapper.selectUnsyncOrderList();
|
||||||
|
if (unClearingDomainList.size() > 0) {
|
||||||
|
List<XhpcClearingHistoryOrderDomain> clearingHistoryOrderDomainList = new ArrayList<>();
|
||||||
|
StringBuilder orderIds = new StringBuilder();
|
||||||
|
for (XhpcHistoryOrderDomain domain : unClearingDomainList) {
|
||||||
|
XhpcClearingHistoryOrderDomain clearingDomain = new XhpcClearingHistoryOrderDomain();
|
||||||
|
|
||||||
List<XhpcClearingHistoryOrderDomain> clearingHistoryOrderDomainList = new ArrayList<>();
|
BeanUtils.copyProperties(domain, clearingDomain);
|
||||||
StringBuilder orderIds = new StringBuilder();
|
clearingDomain.setClearingOrderId(domain.getHistoryOrderId());
|
||||||
for (XhpcHistoryOrderDomain domain : unClearingDomainList){
|
clearingDomain.setCheckStatus(0);
|
||||||
XhpcClearingHistoryOrderDomain clearingDomain = new XhpcClearingHistoryOrderDomain();
|
clearingHistoryOrderDomainList.add(clearingDomain);
|
||||||
|
orderIds.append(",").append(domain.getHistoryOrderId());
|
||||||
BeanUtils.copyProperties(domain, clearingDomain);
|
}
|
||||||
clearingDomain.setClearingOrderId(domain.getHistoryOrderId());
|
clearingHistoryOrderMapper.insertBatch(clearingHistoryOrderDomainList);
|
||||||
clearingDomain.setCheckStatus(0);
|
historyOrderMapper.updateStatusBatchByOrderIds(orderIds.toString(), 3);
|
||||||
clearingHistoryOrderDomainList.add(clearingDomain);
|
} else {
|
||||||
orderIds.append(",").append(domain.getHistoryOrderId());
|
isFinish = true;
|
||||||
}
|
}
|
||||||
clearingHistoryOrderMapper.insertBatch(clearingHistoryOrderDomainList);
|
count += unClearingDomainList.size();
|
||||||
historyOrderMapper.updateStatusBatchByOrderIds(orderIds.toString(), 3);
|
}
|
||||||
orderTotal = orderTotal - oneTimeCount; count ++;
|
System.out.println(" ============== 自动同步订单到清分,结束; 总计同步数量:" + count + " ==========================");
|
||||||
System.out.println(" ============== 自动同步订单到清分 第"+count+"次循环结束,"+ DateUtils.parseDateToStr(new Date()) + " ==========================");
|
} catch (Exception e) {
|
||||||
}
|
|
||||||
System.out.println(" ============== 自动同步订单到清分,结束 ==========================");
|
|
||||||
} catch (Exception e){
|
|
||||||
System.out.println(" ============= 同步异常 ============");
|
System.out.println(" ============= 同步异常 ============");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -78,21 +78,6 @@
|
|||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
|
||||||
<select id="selectUnsyncOrderList" resultType="com.xhpc.activity.domain.XhpcHistoryOrderDomain">
|
|
||||||
select
|
|
||||||
<include refid="Base_Column_List" />,
|
|
||||||
op.operator_id,
|
|
||||||
op.name as 'operator_name'
|
|
||||||
from xhpc_history_order as ho
|
|
||||||
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>
|
|
||||||
|
|
||||||
|
|
||||||
<select id="selectUnclearingAmount" resultType="java.math.BigDecimal">
|
<select id="selectUnclearingAmount" resultType="java.math.BigDecimal">
|
||||||
select
|
select
|
||||||
ifnull(sum(ho.act_power_price + ho.act_service_price), 0)
|
ifnull(sum(ho.act_power_price + ho.act_service_price), 0)
|
||||||
@ -209,5 +194,26 @@
|
|||||||
count(1)
|
count(1)
|
||||||
from xhpc_history_order as ho
|
from xhpc_history_order as ho
|
||||||
where ho.state <![CDATA[ <> ]]> 3 and ho.del_flag=0
|
where ho.state <![CDATA[ <> ]]> 3 and ho.del_flag=0
|
||||||
|
<if test="endTime !=null and endTime !=''">
|
||||||
|
and ho.update_time <![CDATA[ <= ]]> #{endTime}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectUnsyncOrderList" resultType="com.xhpc.activity.domain.XhpcHistoryOrderDomain">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List" />,
|
||||||
|
op.operator_id,
|
||||||
|
op.name as 'operator_name'
|
||||||
|
from xhpc_history_order as ho
|
||||||
|
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 limit 1000
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectSyncedOrderIds" resultType="java.lang.String">
|
||||||
|
SELECT GROUP_CONCAT( `history_order_id`) FROM `xhpc_history_order` WHERE state <![CDATA[ <> ]]> 3 and `del_flag` = 0 and `history_order_id` in ( SELECT clearing_order_id from `xhpc_clearing_history_order`)
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user