package org.springblade.modules.eCallEventTwo.service.impl;
|
|
import cn.hutool.core.convert.Convert;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import org.springblade.core.tool.utils.BeanUtil;
|
import org.springblade.modules.eCallEventTwo.dto.EcOrderDTO;
|
import org.springblade.modules.eCallEventTwo.entity.ECallEventTwoEntity;
|
import org.springblade.modules.eCallEventTwo.entity.EcOrder;
|
import org.springblade.modules.eCallEventTwo.mapper.EcOrderMapper;
|
import org.springblade.modules.eCallEventTwo.service.EcOrderService;
|
import org.springblade.modules.eCallEventTwo.service.IECallEventTwoService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import java.util.Arrays;
|
import java.util.List;
|
|
/**
|
* EcOrderService业务层处理
|
*
|
* @author ${context.author}
|
* @date 2024-05-27 16:26:59
|
*/
|
@Service
|
public class EcOrderServiceImpl extends ServiceImpl<EcOrderMapper, EcOrder> implements EcOrderService {
|
|
@Autowired
|
private IECallEventTwoService ecOrderService;
|
|
/**
|
* 查询工单
|
*
|
* @param orderId 工单ID
|
* @return 工单
|
*/
|
@Override
|
public EcOrderDTO selectEcOrderById(Long orderId) {
|
return this.baseMapper.selectEcOrderById(orderId);
|
}
|
|
/**
|
* 查询工单列表
|
*
|
* @param ecOrderDTO 工单
|
* @return 工单集合
|
*/
|
@Override
|
public List<EcOrderDTO> selectEcOrderList(EcOrderDTO ecOrderDTO) {
|
return this.baseMapper.selectEcOrderList(ecOrderDTO);
|
}
|
|
/**
|
* 新增工单
|
*
|
* @param ecOrderDTO 工单
|
* @return 结果
|
*/
|
@Override
|
public int insertEcOrder(EcOrderDTO ecOrderDTO) {
|
return this.baseMapper.insert(ecOrderDTO);
|
}
|
|
/**
|
* 修改工单
|
*
|
* @param ecOrderDTO 工单
|
* @return 结果
|
*/
|
@Override
|
public int updateEcOrder(EcOrderDTO ecOrderDTO) {
|
return this.baseMapper.updateById(ecOrderDTO);
|
}
|
|
/**
|
* 删除工单对象
|
*
|
* @param ids 需要删除的数据ID
|
* @return 结果
|
*/
|
@Override
|
public int deleteEcOrderByIds(String ids) {
|
return this.removeByIds(Arrays.asList(Convert.toStrArray(ids))) ? 1 : 0;
|
}
|
|
/**
|
* 删除工单信息
|
*
|
* @param orderId 工单ID
|
* @return 结果
|
*/
|
@Override
|
public int deleteEcOrderById(Long orderId) {
|
return this.removeById(orderId) ? 1 : 0;
|
}
|
|
@Override
|
public boolean SynchronizeData() {
|
processPages(100);
|
return true;
|
}
|
|
public void processPages(int pageSize) {
|
long count = count(new QueryWrapper<>());
|
int totalPages = (int) Math.ceil((double) count / pageSize); // 计算总页数
|
|
for (int pageNum = 1; pageNum <= totalPages; pageNum++) {
|
Page<EcOrder> page = new Page<>(pageNum, pageSize);
|
IPage<EcOrder> resultPage = baseMapper.selectPage(page, new QueryWrapper<>());
|
List<EcOrder> records = resultPage.getRecords();
|
List<ECallEventTwoEntity> recordEntityList = BeanUtil.copy(records, ECallEventTwoEntity.class);
|
boolean b = ecOrderService.saveOrUpdateBatch(recordEntityList);
|
System.out.println("更新第" + pageNum + "页" + b);
|
}
|
}
|
}
|