| ¶Ô±ÈÐÂÎļþ | 
|  |  |  | 
|---|
|  |  |  | package com.doumee.service.business.impl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.doumee.core.model.PageData; | 
|---|
|  |  |  | import com.doumee.core.model.PageWrap; | 
|---|
|  |  |  | import com.doumee.core.utils.Constants; | 
|---|
|  |  |  | import com.doumee.core.utils.Utils; | 
|---|
|  |  |  | import com.doumee.dao.business.PlatformLogMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.join.PlatformLogJoinMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.model.*; | 
|---|
|  |  |  | import com.doumee.dao.openapi.request.CarLogsListRequest; | 
|---|
|  |  |  | import com.doumee.dao.openapi.response.CarLogsListResponse; | 
|---|
|  |  |  | import com.doumee.service.business.PlatformLogService; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
|---|
|  |  |  | import com.github.yulichang.wrapper.MPJLambdaWrapper; | 
|---|
|  |  |  | import org.apache.commons.lang.StringUtils; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import org.springframework.util.CollectionUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Objects; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * æå°_ä½ä¸æä½åå²è¡¨Serviceå®ç° | 
|---|
|  |  |  | * @author æ±è¹è¹ | 
|---|
|  |  |  | * @date 2024/06/28 10:03 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Service | 
|---|
|  |  |  | public class PlatformLogServiceImpl implements PlatformLogService { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private PlatformLogMapper platformLogMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private PlatformLogJoinMapper platformLogJoinMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Integer create(PlatformLog platformLog) { | 
|---|
|  |  |  | platformLogMapper.insert(platformLog); | 
|---|
|  |  |  | return platformLog.getId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void deleteById(Integer id) { | 
|---|
|  |  |  | platformLogMapper.deleteById(id); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void delete(PlatformLog platformLog) { | 
|---|
|  |  |  | UpdateWrapper<PlatformLog> deleteWrapper = new UpdateWrapper<>(platformLog); | 
|---|
|  |  |  | platformLogMapper.delete(deleteWrapper); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void deleteByIdInBatch(List<Integer> ids) { | 
|---|
|  |  |  | if (CollectionUtils.isEmpty(ids)) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | platformLogMapper.deleteBatchIds(ids); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void updateById(PlatformLog platformLog) { | 
|---|
|  |  |  | platformLogMapper.updateById(platformLog); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void updateByIdInBatch(List<PlatformLog> platformLogs) { | 
|---|
|  |  |  | if (CollectionUtils.isEmpty(platformLogs)) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (PlatformLog platformLog: platformLogs) { | 
|---|
|  |  |  | this.updateById(platformLog); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public PlatformLog findById(Integer id) { | 
|---|
|  |  |  | return platformLogMapper.selectById(id); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public PlatformLog findOne(PlatformLog platformLog) { | 
|---|
|  |  |  | QueryWrapper<PlatformLog> wrapper = new QueryWrapper<>(platformLog); | 
|---|
|  |  |  | return platformLogMapper.selectOne(wrapper); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<PlatformLog> findList(PlatformLog platformLog) { | 
|---|
|  |  |  | QueryWrapper<PlatformLog> wrapper = new QueryWrapper<>(platformLog); | 
|---|
|  |  |  | return platformLogMapper.selectList(wrapper); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public PageData<PlatformLog> findPage(PageWrap<PlatformLog> pageWrap) { | 
|---|
|  |  |  | IPage<PlatformLog> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); | 
|---|
|  |  |  | MPJLambdaWrapper<PlatformLog> queryWrapper = new MPJLambdaWrapper<>(); | 
|---|
|  |  |  | Utils.MP.blankToNull(pageWrap.getModel()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | queryWrapper.selectAll(PlatformLog.class) | 
|---|
|  |  |  | .selectAs(Platform::getName,PlatformLog::getPlatformName) | 
|---|
|  |  |  | .selectAs(PlatformGroup::getName,PlatformLog::getPlatformGroupName) | 
|---|
|  |  |  | .selectAs(PlatformJob::getCarCodeFront,PlatformLog::getCarCodeFront) | 
|---|
|  |  |  | .selectAs(PlatformJob::getCarCodeBack,PlatformLog::getCarCodeBack) | 
|---|
|  |  |  | .selectAs(PlatformJob::getBillCode,PlatformLog::getBillCode) | 
|---|
|  |  |  | .selectAs(PlatformJob::getContractNum,PlatformLog::getContractNum) | 
|---|
|  |  |  | .leftJoin(PlatformJob.class,PlatformJob::getId,PlatformLog::getJobId) | 
|---|
|  |  |  | .leftJoin(Platform.class,Platform::getId,PlatformLog::getRemark) | 
|---|
|  |  |  | .leftJoin(PlatformGroup.class,PlatformGroup::getId,Platform::getGroupId) | 
|---|
|  |  |  | .like(pageWrap.getModel().getPlatformName() != null, Platform::getName, pageWrap.getModel().getPlatformName()) | 
|---|
|  |  |  | .eq(pageWrap.getModel().getPlatformGroupId() != null, PlatformGroup::getId, pageWrap.getModel().getPlatformGroupId()) | 
|---|
|  |  |  | .like(pageWrap.getModel().getCarCodeFront() != null, PlatformJob::getCarCodeFront, pageWrap.getModel().getCarCodeFront()) | 
|---|
|  |  |  | .ge(pageWrap.getModel().getBeginWorkDateStart() != null, PlatformLog::getParam1, Utils.Date.getStart(pageWrap.getModel().getBeginWorkDateStart())) | 
|---|
|  |  |  | .le(pageWrap.getModel().getBeginWorkDateEnd() != null, PlatformLog::getParam2, Utils.Date.getEnd(pageWrap.getModel().getBeginWorkDateEnd())) | 
|---|
|  |  |  | .apply(pageWrap.getModel().getQueryStatus() != null, " find_in_set(t.OBJ_TYPE,'"+pageWrap.getModel().getQueryStatus()+"') and t.remark is not null  ") | 
|---|
|  |  |  | ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for(PageWrap.SortData sortData: pageWrap.getSorts()) { | 
|---|
|  |  |  | if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { | 
|---|
|  |  |  | queryWrapper.orderByDesc(sortData.getProperty()); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | queryWrapper.orderByAsc(sortData.getProperty()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | IPage<PlatformLog> platformJobIPage = platformLogJoinMapper.selectJoinPage(page,PlatformLog.class,queryWrapper); | 
|---|
|  |  |  | for (PlatformLog platformLog:platformJobIPage.getRecords()) { | 
|---|
|  |  |  | if(StringUtils.isBlank(platformLog.getBillCode())){ | 
|---|
|  |  |  | platformLog.setBillCode(platformLog.getContractNum()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return PageData.from(platformJobIPage); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public long count(PlatformLog platformLog) { | 
|---|
|  |  |  | QueryWrapper<PlatformLog> wrapper = new QueryWrapper<>(platformLog); | 
|---|
|  |  |  | return platformLogMapper.selectCount(wrapper); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<CarLogsListResponse> getCarLogsListResponse(CarLogsListRequest carLogsListRequest){ | 
|---|
|  |  |  | List<CarLogsListResponse> carLogsListResponseList = new ArrayList<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<PlatformLog> platformLogList = platformLogMapper.selectList(new QueryWrapper<PlatformLog>().lambda() | 
|---|
|  |  |  | .notIn(PlatformLog::getObjType, | 
|---|
|  |  |  | Constants.PlatformJobLogType.CREATE.getKey(), | 
|---|
|  |  |  | Constants.PlatformJobLogType.CONFIRM_TASK.getKey() | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | .orderByDesc(PlatformLog::getCreateDate) | 
|---|
|  |  |  | .last(Objects.nonNull(carLogsListRequest)&&Objects.nonNull(carLogsListRequest.getLimitNum())," limit " +carLogsListRequest.getLimitNum()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | for (PlatformLog platformLog:platformLogList) { | 
|---|
|  |  |  | CarLogsListResponse carLogsListResponse = new CarLogsListResponse(); | 
|---|
|  |  |  | carLogsListResponse.setCarCode(platformLog.getParam4()); | 
|---|
|  |  |  | carLogsListResponse.setContent(platformLog.getContent()); | 
|---|
|  |  |  | carLogsListResponse.setCreateDate(new Date()); | 
|---|
|  |  |  | carLogsListResponseList.add(carLogsListResponse); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return carLogsListResponseList; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|