|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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.service.business.third.model.LoginUserInfo; | 
|---|
|  |  |  | import com.doumee.service.business.third.model.PageData; | 
|---|
|  |  |  | import com.doumee.service.business.third.model.PageWrap; | 
|---|
|  |  |  | import com.doumee.core.utils.Constants; | 
|---|
|  |  |  | import com.doumee.core.utils.Utils; | 
|---|
|  |  |  | import com.doumee.dao.business.ApproveParamMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.ApproveTemplMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.MemberMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.PlatformReasonMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.join.MemberJoinMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.model.*; | 
|---|
|  |  |  | import com.doumee.dao.business.model.Member; | 
|---|
|  |  |  | import com.doumee.service.business.ApproveTemplService; | 
|---|
|  |  |  | 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.apache.shiro.SecurityUtils; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Objects; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 审批模版信息表Service实现 | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ApproveParamMapper approveParamMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MemberMapper memberMapper; | 
|---|
|  |  |  | private MemberJoinMapper memberJoinMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private PlatformReasonMapper platformReasonMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) | 
|---|
|  |  |  | 
|---|
|  |  |  | if(model.getType() == null || Constants.ApproveTmplType.getName(model.getType()) == null){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | PlatformReason reason = null; | 
|---|
|  |  |  | if(Constants.equalsInteger(model.getType(),Constants.ApproveTmplType.PLATFROM_REASON.getKey())){ | 
|---|
|  |  |  | if(model.getReasonId() ==null){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | reason = platformReasonMapper.selectById(model.getReasonId()); | 
|---|
|  |  |  | if(reason ==null){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,入园原因信息不存在,请返回刷新页面重试!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ApproveTempl template = approveTemplMapper.selectOne(new QueryWrapper<ApproveTempl>().lambda() | 
|---|
|  |  |  | .eq(ApproveTempl::getType,model.getType() ) | 
|---|
|  |  |  | .eq(ApproveTempl::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | //如果是入园原因配置,根据ID查询对应的模版信息 | 
|---|
|  |  |  | .eq(Constants.equalsInteger(model.getType(),Constants.ApproveTmplType.PLATFROM_REASON.getKey()),ApproveTempl::getId,model.getReasonId()) | 
|---|
|  |  |  | .last("limit 1")); | 
|---|
|  |  |  | Date date =new Date(); | 
|---|
|  |  |  | if(template == null){ | 
|---|
|  |  |  | 
|---|
|  |  |  | template.setName(Constants.ApproveTmplType.getName(model.getType())); | 
|---|
|  |  |  | approveTemplMapper.insert(template); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | int level = 0; | 
|---|
|  |  |  | if(model.getParamList()!=null && model.getParamList().size()>0){ | 
|---|
|  |  |  | for(ApproveParam param : model.getParamList()){ | 
|---|
|  |  |  | param.setCreateDate(date); | 
|---|
|  |  |  | param.setId(null); | 
|---|
|  |  |  | param.setCreator(loginUserInfo.getId()); | 
|---|
|  |  |  | param.setEditDate(date); | 
|---|
|  |  |  | param.setEditor(loginUserInfo.getId()); | 
|---|
|  |  |  | param.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | //                param.setLevel(level); | 
|---|
|  |  |  | param.setMemberType(Constants.formatIntegerNum(param.getMemberType())); | 
|---|
|  |  |  | param.setTemplId(template.getId()); | 
|---|
|  |  |  | param.setType(Constants.formatIntegerNum(param.getType())); | 
|---|
|  |  |  | param.setAddrParam(Constants.formatIntegerNum(param.getAddrParam())); | 
|---|
|  |  |  | param.setDriverParam(Constants.formatIntegerNum(param.getDriverParam())); | 
|---|
|  |  |  | param.setApproveType(Constants.formatIntegerNum(param.getApproveType())); | 
|---|
|  |  |  | param.setApproveType(Objects.isNull(param.getApproveType())?Constants.TWO:param.getApproveType()); | 
|---|
|  |  |  | level ++ ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //先清除原来所有的就陪配置 | 
|---|
|  |  |  | approveParamMapper.delete(new UpdateWrapper<ApproveParam>().lambda() | 
|---|
|  |  |  | .eq(ApproveParam::getTemplId,template.getId())); | 
|---|
|  |  |  | //批量插入新的配置 | 
|---|
|  |  |  | approveParamMapper.insertBatchSomeColumn(model.getParamList()); | 
|---|
|  |  |  | approveParamMapper.insert(model.getParamList()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return model.getId(); | 
|---|
|  |  |  | if(Constants.equalsInteger(model.getType(),Constants.ApproveTmplType.PLATFROM_REASON.getKey())){ | 
|---|
|  |  |  | PlatformReason r = new PlatformReason(); | 
|---|
|  |  |  | r.setApproveTemplId(template.getId()); | 
|---|
|  |  |  | r.setId(model.getReasonId()); | 
|---|
|  |  |  | r.setEditor(template.getEditor()); | 
|---|
|  |  |  | r.setEditDate(new Date()); | 
|---|
|  |  |  | platformReasonMapper.updateById(r); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return 1; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public ApproveTempl findOne(ApproveTempl approveTempl) { | 
|---|
|  |  |  | QueryWrapper<ApproveTempl> wrapper = new QueryWrapper<>(approveTempl); | 
|---|
|  |  |  | return approveTemplMapper.selectOne(wrapper); | 
|---|
|  |  |  | ApproveTempl model =  approveTemplMapper.selectOne(wrapper.lambda().last("limit 1")); | 
|---|
|  |  |  | if(model!=null){ | 
|---|
|  |  |  | List<ApproveParam> approveParamList = approveParamMapper.selectList(new QueryWrapper<ApproveParam>() | 
|---|
|  |  |  | .lambda().eq(ApproveParam::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(ApproveParam::getTemplId,model.getId()) | 
|---|
|  |  |  | .orderByAsc(ApproveParam::getLevel) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | for (ApproveParam approveParam :approveParamList) { | 
|---|
|  |  |  | if(StringUtils.isNotBlank(approveParam.getObjIds())){ | 
|---|
|  |  |  | approveParam.setMemberList(memberJoinMapper.selectJoinList(Member.class,new MPJLambdaWrapper<Member>() | 
|---|
|  |  |  | .selectAll(Member.class) | 
|---|
|  |  |  | .selectAs(Company::getName,Member::getCompanyName) | 
|---|
|  |  |  | .leftJoin(Company.class,Company::getId,Member::getCompanyId) | 
|---|
|  |  |  | .eq(Member::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .in(Member::getId,approveParam.getObjIds().split(",")))); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | model.setParamList(approveParamList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return model; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|