|  |  |  | 
|---|
|  |  |  | package com.doumee.service.business.impl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.doumee.core.constants.ResponseStatus; | 
|---|
|  |  |  | import com.doumee.core.exception.BusinessException; | 
|---|
|  |  |  | import com.doumee.core.model.LoginUserInfo; | 
|---|
|  |  |  | 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.PlatformReasonMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.model.Platform; | 
|---|
|  |  |  | import com.doumee.dao.business.model.PlatformGroup; | 
|---|
|  |  |  | import com.doumee.dao.business.model.PlatformReason; | 
|---|
|  |  |  | import com.doumee.service.business.PlatformReasonService; | 
|---|
|  |  |  | 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.query.MPJQueryWrapper; | 
|---|
|  |  |  | import com.github.yulichang.wrapper.MPJLambdaWrapper; | 
|---|
|  |  |  | import org.apache.shiro.SecurityUtils; | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Integer create(PlatformReason platformReason) { | 
|---|
|  |  |  | platformReason.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | platformReason.setStatus(Constants.ZERO); | 
|---|
|  |  |  | platformReason.setCreator(platformReason.getLoginUserInfo().getId()); | 
|---|
|  |  |  | platformReason.setCreateDate(new Date()); | 
|---|
|  |  |  | platformReason.setEditDate(platformReason.getCreateDate()); | 
|---|
|  |  |  | platformReason.setEditor(platformReason.getCreator()); | 
|---|
|  |  |  | platformReasonMapper.insert(platformReason); | 
|---|
|  |  |  | return platformReason.getId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void deleteById(Integer id) { | 
|---|
|  |  |  | platformReasonMapper.deleteById(id); | 
|---|
|  |  |  | public void deleteById(Integer id, LoginUserInfo user) { | 
|---|
|  |  |  | PlatformReason param = new PlatformReason(); | 
|---|
|  |  |  | param.setId(id); | 
|---|
|  |  |  | param.setIsdeleted(Constants.ONE); | 
|---|
|  |  |  | param.setEditor(user.getId()); | 
|---|
|  |  |  | param.setEditDate(new Date()); | 
|---|
|  |  |  | platformReasonMapper.updateById(param); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void deleteByIdInBatch(List<Integer> ids) { | 
|---|
|  |  |  | public void deleteByIdInBatch(List<Integer> ids, LoginUserInfo user) { | 
|---|
|  |  |  | if (CollectionUtils.isEmpty(ids)) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | platformReasonMapper.deleteBatchIds(ids); | 
|---|
|  |  |  | for(Integer id : ids){ | 
|---|
|  |  |  | deleteById(id,user); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void updateById(PlatformReason platformReason) { | 
|---|
|  |  |  | platformReason.setEditDate(new Date()); | 
|---|
|  |  |  | platformReason.setEditor(platformReason.getLoginUserInfo().getId()); | 
|---|
|  |  |  | platformReasonMapper.updateById(platformReason); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<PlatformReason> findList(PlatformReason platformReason) { | 
|---|
|  |  |  | QueryWrapper<PlatformReason> wrapper = new QueryWrapper<>(platformReason); | 
|---|
|  |  |  | wrapper.eq("isdeleted",Constants.ZERO); | 
|---|
|  |  |  | wrapper.eq("STATUS",Constants.ZERO); | 
|---|
|  |  |  | wrapper.orderByAsc("SORTNUM"); | 
|---|
|  |  |  | return platformReasonMapper.selectList(wrapper); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public PageData<PlatformReason> findPage(PageWrap<PlatformReason> pageWrap) { | 
|---|
|  |  |  | IPage<PlatformReason> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); | 
|---|
|  |  |  | QueryWrapper<PlatformReason> queryWrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | MPJLambdaWrapper<PlatformReason> queryWrapper = new MPJLambdaWrapper<>(); | 
|---|
|  |  |  | Utils.MP.blankToNull(pageWrap.getModel()); | 
|---|
|  |  |  | pageWrap.getModel().setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | queryWrapper.selectAll(PlatformReason.class) | 
|---|
|  |  |  | .selectAs(PlatformGroup::getName,PlatformReason::getGroupName) | 
|---|
|  |  |  | .leftJoin(PlatformGroup.class,PlatformGroup::getId,PlatformReason::getGroupId); | 
|---|
|  |  |  | if (pageWrap.getModel().getId() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(PlatformReason::getId, pageWrap.getModel().getId()); | 
|---|
|  |  |  | queryWrapper.eq(PlatformReason::getId, pageWrap.getModel().getId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getCreator() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(PlatformReason::getCreator, pageWrap.getModel().getCreator()); | 
|---|
|  |  |  | queryWrapper.eq(PlatformReason::getCreator, pageWrap.getModel().getCreator()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getCreateDate() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().ge(PlatformReason::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate())); | 
|---|
|  |  |  | queryWrapper.lambda().le(PlatformReason::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getCreateDate())); | 
|---|
|  |  |  | queryWrapper.ge(PlatformReason::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate())); | 
|---|
|  |  |  | queryWrapper.le(PlatformReason::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getCreateDate())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getEditor() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(PlatformReason::getEditor, pageWrap.getModel().getEditor()); | 
|---|
|  |  |  | queryWrapper.eq(PlatformReason::getEditor, pageWrap.getModel().getEditor()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getEditDate() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().ge(PlatformReason::getEditDate, Utils.Date.getStart(pageWrap.getModel().getEditDate())); | 
|---|
|  |  |  | queryWrapper.lambda().le(PlatformReason::getEditDate, Utils.Date.getEnd(pageWrap.getModel().getEditDate())); | 
|---|
|  |  |  | queryWrapper.ge(PlatformReason::getEditDate, Utils.Date.getStart(pageWrap.getModel().getEditDate())); | 
|---|
|  |  |  | queryWrapper.le(PlatformReason::getEditDate, Utils.Date.getEnd(pageWrap.getModel().getEditDate())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getIsdeleted() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(PlatformReason::getIsdeleted, pageWrap.getModel().getIsdeleted()); | 
|---|
|  |  |  | queryWrapper.eq(PlatformReason::getIsdeleted, pageWrap.getModel().getIsdeleted()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getRemark() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(PlatformReason::getRemark, pageWrap.getModel().getRemark()); | 
|---|
|  |  |  | queryWrapper.eq(PlatformReason::getRemark, pageWrap.getModel().getRemark()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getReason() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(PlatformReason::getReason, pageWrap.getModel().getReason()); | 
|---|
|  |  |  | queryWrapper.like(PlatformReason::getReason, pageWrap.getModel().getReason()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getIocode() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(PlatformReason::getIocode, pageWrap.getModel().getIocode()); | 
|---|
|  |  |  | queryWrapper.eq(PlatformReason::getIocode, pageWrap.getModel().getIocode()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getGroupId() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(PlatformReason::getGroupId, pageWrap.getModel().getGroupId()); | 
|---|
|  |  |  | queryWrapper.eq(PlatformReason::getGroupId, pageWrap.getModel().getGroupId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getLimitNum() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(PlatformReason::getLimitNum, pageWrap.getModel().getLimitNum()); | 
|---|
|  |  |  | queryWrapper.eq(PlatformReason::getLimitNum, pageWrap.getModel().getLimitNum()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (pageWrap.getModel().getSortnum() != null) { | 
|---|
|  |  |  | queryWrapper.lambda().eq(PlatformReason::getSortnum, pageWrap.getModel().getSortnum()); | 
|---|
|  |  |  | queryWrapper.eq(PlatformReason::getSortnum, pageWrap.getModel().getSortnum()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for(PageWrap.SortData sortData: pageWrap.getSorts()) { | 
|---|
|  |  |  | if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { | 
|---|
|  |  |  | queryWrapper.orderByDesc(sortData.getProperty()); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | queryWrapper.orderByAsc(sortData.getProperty()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | queryWrapper.orderByAsc(PlatformReason::getSortnum); | 
|---|
|  |  |  | return PageData.from(platformReasonMapper.selectPage(page, queryWrapper)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | QueryWrapper<PlatformReason> wrapper = new QueryWrapper<>(platformReason); | 
|---|
|  |  |  | return platformReasonMapper.selectCount(wrapper); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void updateStatusById(PlatformReason platform) { | 
|---|
|  |  |  | PlatformReason model  =platformReasonMapper.selectById(platform.getId()); | 
|---|
|  |  |  | if(model ==null) { | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,该记录不存在!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|---|
|  |  |  | if(loginUserInfo == null){ | 
|---|
|  |  |  | loginUserInfo = platform.getLoginUserInfo(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | PlatformReason update = new PlatformReason(); | 
|---|
|  |  |  | update.setEditDate(new Date()); | 
|---|
|  |  |  | update.setId(model.getId()); | 
|---|
|  |  |  | update.setEditor(loginUserInfo.getId()); | 
|---|
|  |  |  | update.setStatus(platform.getStatus()); | 
|---|
|  |  |  | platformReasonMapper.updateById(update); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|