package com.doumee.service.business.impl; import com.doumee.core.constants.ResponseStatus; import com.doumee.core.exception.BusinessException; 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.YwOutinboundRecordMapper; import com.doumee.dao.business.model.*; import com.doumee.dao.system.model.SystemUser; import com.doumee.service.business.YwOutinboundRecordService; 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.lang3.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.List; import java.util.Objects; /** * 运维出入库信息明细表Service实现 * @author 江蹄蹄 * @date 2025/01/06 14:28 */ @Service public class YwOutinboundRecordServiceImpl implements YwOutinboundRecordService { @Autowired private YwOutinboundRecordMapper ywOutinboundRecordMapper; @Override public Integer create(YwOutinboundRecord ywOutinboundRecord) { ywOutinboundRecordMapper.insert(ywOutinboundRecord); return ywOutinboundRecord.getId(); } @Override public void deleteById(Integer id) { ywOutinboundRecordMapper.deleteById(id); } @Override public void delete(YwOutinboundRecord ywOutinboundRecord) { UpdateWrapper deleteWrapper = new UpdateWrapper<>(ywOutinboundRecord); ywOutinboundRecordMapper.delete(deleteWrapper); } @Override public void deleteByIdInBatch(List ids) { if (CollectionUtils.isEmpty(ids)) { return; } ywOutinboundRecordMapper.deleteBatchIds(ids); } @Override public void updateById(YwOutinboundRecord ywOutinboundRecord) { ywOutinboundRecordMapper.updateById(ywOutinboundRecord); } @Override public void updateByIdInBatch(List ywOutinboundRecords) { if (CollectionUtils.isEmpty(ywOutinboundRecords)) { return; } for (YwOutinboundRecord ywOutinboundRecord: ywOutinboundRecords) { this.updateById(ywOutinboundRecord); } } @Override public YwOutinboundRecord findById(Integer id) { return ywOutinboundRecordMapper.selectById(id); } @Override public YwOutinboundRecord findOne(YwOutinboundRecord ywOutinboundRecord) { QueryWrapper wrapper = new QueryWrapper<>(ywOutinboundRecord); return ywOutinboundRecordMapper.selectOne(wrapper); } @Override public List findList(YwOutinboundRecord ywOutinboundRecord) { QueryWrapper wrapper = new QueryWrapper<>(ywOutinboundRecord); return ywOutinboundRecordMapper.selectList(wrapper); } @Override public PageData findPage(PageWrap pageWrap) { IPage page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); MPJLambdaWrapper queryWrapper = new MPJLambdaWrapper(); Utils.MP.blankToNull(pageWrap.getModel()); YwOutinboundRecord model = pageWrap.getModel(); List typeList = new ArrayList<>(); if(!(Objects.isNull(model)||Objects.isNull(model.getInOut()))){ typeList = Constants.ywOutInType.getAllTypeKey(model.getInOut()); } queryWrapper.selectAll(YwOutinboundRecord.class) .selectAs(SystemUser::getRealname,YwOutinboundRecord::getCreateUserName) .selectAs(YwOutinbound::getCode,YwOutinboundRecord::getCode) .selectAs(YwOutinbound::getType,YwOutinboundRecord::getType) .selectAs(YwOutinbound::getDoneDate,YwOutinboundRecord::getDoneDate) .selectAs(YwWarehouse::getName,YwOutinboundRecord::getWarehouseName) .selectAs(YwMaterial::getCode,YwOutinboundRecord::getMaterialCode) .selectAs(YwMaterial::getName,YwOutinboundRecord::getMaterialName) .selectAs(YwMaterial::getQrcode,YwOutinboundRecord::getMaterialQrcode) .selectAs(YwMaterial::getBrand,YwOutinboundRecord::getMaterialBrand) .selectAs(YwMaterial::getUnitName,YwOutinboundRecord::getMaterialUnitName) .select(" c.name ",YwOutinboundRecord::getCategoryParentName) .select(" c1.name ",YwOutinboundRecord::getCategoryName) .leftJoin(YwOutinbound.class,YwOutinbound::getId,YwOutinboundRecord::getOutInBoundId) .leftJoin(SystemUser.class,SystemUser::getId,YwOutinbound::getCreator) .leftJoin(YwWarehouse.class,YwWarehouse::getId,YwOutinbound::getWarehouseId) .leftJoin(YwMaterial.class,YwMaterial::getId,YwOutinboundRecord::getMaterialId) .leftJoin("category c on t4.PARENT_CATE_ID = c.id") .leftJoin("category c1 on t4.CATE_ID = c1.id") .like(StringUtils.isNotBlank(model.getCode()),YwOutinbound::getCode,model.getCode()) .like(StringUtils.isNotBlank(model.getMaterialCode()),YwMaterial::getCode,model.getMaterialCode()) .eq(Objects.nonNull(model.getWarehouseId()),YwOutinbound::getWarehouseId,model.getWarehouseId()) .in(Objects.nonNull(model.getInOut()),YwOutinbound::getType,typeList) .ge(StringUtils.isNotBlank(model.getDoneDateStart()),YwOutinbound::getDoneDate,model.getDoneDateStart()+" 00:00:00") .le(StringUtils.isNotBlank(model.getDoneDateEnd()),YwOutinbound::getDoneDate,model.getDoneDateEnd()+" 23:59:59") .ge(StringUtils.isNotBlank(model.getCreateDateStart()),YwOutinbound::getCreateDate,model.getCreateDateStart()+" 00:00:00") .le(StringUtils.isNotBlank(model.getCreateDateEnd()),YwOutinbound::getCreateDate,model.getCreateDateEnd()+" 23:59:59") .orderByDesc(YwOutinbound::getCreateDate) ; IPage iPage = ywOutinboundRecordMapper.selectJoinPage(page,YwOutinboundRecord.class,queryWrapper); return PageData.from(iPage); } @Override public long count(YwOutinboundRecord ywOutinboundRecord) { QueryWrapper wrapper = new QueryWrapper<>(ywOutinboundRecord); return ywOutinboundRecordMapper.selectCount(wrapper); } }