|  |  |  | 
|---|
|  |  |  | package com.doumee.service.business.impl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.doumee.biz.system.SystemDictDataBiz; | 
|---|
|  |  |  | import com.doumee.core.constants.ResponseStatus; | 
|---|
|  |  |  | import com.doumee.core.exception.BusinessException; | 
|---|
|  |  |  | import com.doumee.core.utils.Constants; | 
|---|
|  |  |  | import com.doumee.core.utils.Utils; | 
|---|
|  |  |  | import com.doumee.dao.business.CompanyDocumentsMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.model.Category; | 
|---|
|  |  |  | import com.doumee.dao.business.model.Company; | 
|---|
|  |  |  | import com.doumee.dao.business.model.CompanyDocuments; | 
|---|
|  |  |  | import com.doumee.dao.business.model.Member; | 
|---|
|  |  |  | import com.doumee.dao.system.model.SystemUser; | 
|---|
|  |  |  | import com.doumee.service.business.CompanyDocumentsService; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.doumee.service.business.third.model.LoginUserInfo; | 
|---|
|  |  |  | import com.doumee.service.business.third.model.PageData; | 
|---|
|  |  |  | import com.doumee.service.business.third.model.PageWrap; | 
|---|
|  |  |  | import com.github.yulichang.wrapper.MPJLambdaWrapper; | 
|---|
|  |  |  | import org.apache.commons.lang3.StringUtils; | 
|---|
|  |  |  | import org.checkerframework.checker.units.qual.A; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import org.springframework.util.CollectionUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Objects; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 隐患区域配置类型信息表Service实现 | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private CompanyDocumentsMapper companyDocumentsMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SystemDictDataBiz systemDictDataBiz; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Integer create(CompanyDocuments companyDocuments) { | 
|---|
|  |  |  | if(Objects.isNull(companyDocuments) | 
|---|
|  |  |  | || Objects.isNull(companyDocuments.getCompanyId()) | 
|---|
|  |  |  | || Objects.isNull(companyDocuments.getCategoryId()) | 
|---|
|  |  |  | || StringUtils.isBlank(companyDocuments.getName()) | 
|---|
|  |  |  | || StringUtils.isBlank(companyDocuments.getFileurl()) | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | companyDocuments.setId(null); | 
|---|
|  |  |  | companyDocuments.setCreateDate(new Date()); | 
|---|
|  |  |  | companyDocuments.setCreator(companyDocuments.getLoginUserInfo().getId()); | 
|---|
|  |  |  | companyDocuments.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | companyDocuments.setStatus(Constants.ZERO); | 
|---|
|  |  |  | companyDocumentsMapper.insert(companyDocuments); | 
|---|
|  |  |  | return companyDocuments.getId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void deleteById(Integer id, LoginUserInfo user) { | 
|---|
|  |  |  | companyDocumentsMapper.deleteById(id); | 
|---|
|  |  |  | UpdateWrapper<CompanyDocuments> deleteWrapper = new UpdateWrapper<>(); | 
|---|
|  |  |  | deleteWrapper.lambda().set(CompanyDocuments::getIsdeleted,Constants.ONE) | 
|---|
|  |  |  | .eq(CompanyDocuments::getId,id) | 
|---|
|  |  |  | .set(CompanyDocuments::getEditDate,new Date()) | 
|---|
|  |  |  | .set(CompanyDocuments::getEditor,user.getId()); | 
|---|
|  |  |  | companyDocumentsMapper.update(deleteWrapper); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void delete(CompanyDocuments companyDocuments) { | 
|---|
|  |  |  | UpdateWrapper<CompanyDocuments> deleteWrapper = new UpdateWrapper<>(companyDocuments); | 
|---|
|  |  |  | companyDocumentsMapper.delete(deleteWrapper); | 
|---|
|  |  |  | companyDocumentsMapper.update(deleteWrapper); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void updateById(CompanyDocuments companyDocuments) { | 
|---|
|  |  |  | if(Objects.isNull(companyDocuments) | 
|---|
|  |  |  | || Objects.isNull(companyDocuments.getId()) | 
|---|
|  |  |  | || Objects.isNull(companyDocuments.getCompanyId()) | 
|---|
|  |  |  | || Objects.isNull(companyDocuments.getCategoryId()) | 
|---|
|  |  |  | || StringUtils.isBlank(companyDocuments.getName()) | 
|---|
|  |  |  | || StringUtils.isBlank(companyDocuments.getFileurl()) | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | companyDocuments.setId(null); | 
|---|
|  |  |  | companyDocuments.setEditDate(new Date()); | 
|---|
|  |  |  | companyDocuments.setEditor(companyDocuments.getLoginUserInfo().getId()); | 
|---|
|  |  |  | companyDocumentsMapper.updateById(companyDocuments); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public CompanyDocuments findById(Integer id) { | 
|---|
|  |  |  | return companyDocumentsMapper.selectById(id); | 
|---|
|  |  |  | CompanyDocuments companyDocuments = companyDocumentsMapper.selectById(id); | 
|---|
|  |  |  | if(Objects.isNull(companyDocuments)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(StringUtils.isNotBlank(companyDocuments.getFileurl())){ | 
|---|
|  |  |  | String path = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_LOCAL_RESOURCE_PATH).getCode() | 
|---|
|  |  |  | +systemDictDataBiz.queryByCode(Constants.FTP,Constants.COMPANY_DOCUMENTS).getCode(); | 
|---|
|  |  |  | companyDocuments.setFileurlFull(path + companyDocuments.getFileurl()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return companyDocuments; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public PageData<CompanyDocuments> findPage(PageWrap<CompanyDocuments> pageWrap) { | 
|---|
|  |  |  | IPage<CompanyDocuments> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); | 
|---|
|  |  |  | QueryWrapper<CompanyDocuments> queryWrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | MPJLambdaWrapper<CompanyDocuments> queryWrapper = new MPJLambdaWrapper<>(); | 
|---|
|  |  |  | Utils.MP.blankToNull(pageWrap.getModel()); | 
|---|
|  |  |  | if (pageWrap.getModel().getId() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(CompanyDocuments::getId, pageWrap.getModel().getId()); | 
|---|
|  |  |  | CompanyDocuments queryModel = pageWrap.getModel(); | 
|---|
|  |  |  | queryWrapper.selectAll(CompanyDocuments.class) | 
|---|
|  |  |  | .selectAs(Company::getName,CompanyDocuments::getCompanyName) | 
|---|
|  |  |  | .selectAs(Category::getName,CompanyDocuments::getCategoryName) | 
|---|
|  |  |  | .selectAs(SystemUser::getRealname,CompanyDocuments::getCreatorName) | 
|---|
|  |  |  | .leftJoin(Company.class,Company::getId,CompanyDocuments::getCompanyId) | 
|---|
|  |  |  | .leftJoin(Category.class,Category::getId,CompanyDocuments::getCategoryId) | 
|---|
|  |  |  | .leftJoin(SystemUser.class,SystemUser::getId,CompanyDocuments::getCreator) | 
|---|
|  |  |  | .eq(CompanyDocuments::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .like(Objects.nonNull(queryModel)&&StringUtils.isNotBlank(queryModel.getName()),CompanyDocuments::getName,queryModel.getName()) | 
|---|
|  |  |  | .eq(Objects.nonNull(queryModel)&&Objects.nonNull(queryModel.getCategoryId()),CompanyDocuments::getCategoryId,queryModel.getCategoryId()) | 
|---|
|  |  |  | .eq(Objects.nonNull(queryModel)&&Objects.nonNull(queryModel.getCompanyId()),CompanyDocuments::getCompanyId,queryModel.getCompanyId()) | 
|---|
|  |  |  | .orderByDesc(CompanyDocuments::getSortnum) | 
|---|
|  |  |  | .orderByDesc(CompanyDocuments::getCreateDate); | 
|---|
|  |  |  | IPage<CompanyDocuments> iPage = companyDocumentsMapper.selectJoinPage(page, CompanyDocuments.class,queryWrapper); | 
|---|
|  |  |  | String path = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_LOCAL_RESOURCE_PATH).getCode() | 
|---|
|  |  |  | +systemDictDataBiz.queryByCode(Constants.FTP,Constants.COMPANY_DOCUMENTS).getCode(); | 
|---|
|  |  |  | for (CompanyDocuments companyDocuments:iPage.getRecords()) { | 
|---|
|  |  |  | companyDocuments.setFileurlFull(path + companyDocuments.getFileurl()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getCreator() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(CompanyDocuments::getCreator, pageWrap.getModel().getCreator()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getCreateDate() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().ge(CompanyDocuments::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate())); | 
|---|
|  |  |  | queryWrapper.lambda().le(CompanyDocuments::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getCreateDate())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getEditor() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(CompanyDocuments::getEditor, pageWrap.getModel().getEditor()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getEditDate() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().ge(CompanyDocuments::getEditDate, Utils.Date.getStart(pageWrap.getModel().getEditDate())); | 
|---|
|  |  |  | queryWrapper.lambda().le(CompanyDocuments::getEditDate, Utils.Date.getEnd(pageWrap.getModel().getEditDate())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getIsdeleted() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(CompanyDocuments::getIsdeleted, pageWrap.getModel().getIsdeleted()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getName() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(CompanyDocuments::getName, pageWrap.getModel().getName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getRemark() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(CompanyDocuments::getRemark, pageWrap.getModel().getRemark()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getStatus() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(CompanyDocuments::getStatus, pageWrap.getModel().getStatus()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getSortnum() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(CompanyDocuments::getSortnum, pageWrap.getModel().getSortnum()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getFileurl() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(CompanyDocuments::getFileurl, pageWrap.getModel().getFileurl()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getFileName() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(CompanyDocuments::getFileName, pageWrap.getModel().getFileName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getFileSize() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(CompanyDocuments::getFileSize, pageWrap.getModel().getFileSize()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getCategoryId() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(CompanyDocuments::getCategoryId, pageWrap.getModel().getCategoryId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getCompanyId() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(CompanyDocuments::getCompanyId, pageWrap.getModel().getCompanyId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getContent() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(CompanyDocuments::getContent, pageWrap.getModel().getContent()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for(PageWrap.SortData sortData: pageWrap.getSorts()) { | 
|---|
|  |  |  | if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { | 
|---|
|  |  |  | queryWrapper.orderByDesc(sortData.getProperty()); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | queryWrapper.orderByAsc(sortData.getProperty()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return PageData.from(companyDocumentsMapper.selectPage(page, queryWrapper)); | 
|---|
|  |  |  | return PageData.from(iPage); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|