package com.gk.firework.Service.ServiceImpl; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.gk.firework.Domain.AssessApply; import com.gk.firework.Domain.Enterprise; import com.gk.firework.Domain.Enum.AssessApplyStatus; import com.gk.firework.Domain.Enum.AssessPunishment; import com.gk.firework.Domain.Enum.AssessType; import com.gk.firework.Domain.Enum.PunishStatus; import com.gk.firework.Domain.Exception.BusinessException; import com.gk.firework.Domain.UserInfo; import com.gk.firework.Domain.Utils.Properties; import com.gk.firework.Domain.Utils.StringUtils; import com.gk.firework.Domain.Utils.UploadUtil; import com.gk.firework.Domain.Vo.AssessApplyAppealVo; import com.gk.firework.Mapper.AssessApplyMapper; import com.gk.firework.Service.AssessApplyService; import com.gk.firework.Service.EnterpriseService; import com.gk.firework.Service.UserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.*; @Service("assessApplyService") public class AssessApplyServiceImpl extends ServiceImpl implements AssessApplyService { @Autowired private AssessApplyMapper assessApplyMapper; @Autowired private UserService userService; @Autowired private EnterpriseService enterpriseService; @Override public void addSaleAssessApply(AssessApply assessApply, UserInfo user) { if (StringUtils.isBlank(assessApply.getEnterprisename()) || StringUtils.isBlank(assessApply.getEnterprisenumber())) throw new BusinessException("请选择企业信息"); if (assessApply.getPunishmentmeasure() == null) throw new BusinessException("请选择处罚措施"); if (StringUtils.isBlank(assessApply.getPunishmentreason())) throw new BusinessException("请填写处罚原因"); assessApply.setValidflag(true); assessApply.setCode("SA-" + System.currentTimeMillis()); assessApply.setCreatetime(new Date()); assessApply.setRequestor(user.getUsername()); assessApply.setRequestorid(user.getId()); assessApply.setPunishstatus(PunishStatus.UNPUNISH); assessApply.setStatus(AssessApplyStatus.TOSUBMIT); assessApply.setType(AssessType.SALE); if (assessApply.getFile() != null) { try { String filename = UploadUtil.uploadFile(assessApply.getFile(), Properties.assessApplyPath); assessApply.setPath1(Properties.assessApply + filename); } catch (Exception e) { e.printStackTrace(); throw new BusinessException("上传文件出现问题,请联系管理员"); } } this.save(assessApply); } @Override public void modSaleAssessApply(AssessApply assessApply, UserInfo user) { AssessApply aa = this.getById(assessApply.getId()); if (aa == null) throw new BusinessException("单子不存在,请联系管理员"); if (aa.getStatus() != AssessApplyStatus.TOSUBMIT && aa.getStatus() != AssessApplyStatus.REJECT) throw new BusinessException("提交后的单子不能修改"); if (StringUtils.isBlank(assessApply.getEnterprisename()) || StringUtils.isBlank(assessApply.getEnterprisenumber())) throw new BusinessException("请选择企业信息"); if (assessApply.getPunishmentmeasure() == null) throw new BusinessException("请选择处罚措施"); if (StringUtils.isBlank(assessApply.getPunishmentreason())) throw new BusinessException("请填写处罚原因"); if (assessApply.getFile() != null) { try { String filename = UploadUtil.uploadFile(assessApply.getFile(), Properties.assessApplyPath); aa.setPath1(Properties.assessApply + filename); } catch (Exception e) { e.printStackTrace(); throw new BusinessException("上传文件出现问题,请联系管理员"); } } aa.setPunishmentmeasure(assessApply.getPunishmentmeasure()); aa.setPunishmentreason(assessApply.getPunishmentreason()); aa.setModifytime(new Date()); aa.setEnterprisename(assessApply.getEnterprisename()); aa.setEnterprisenumber(assessApply.getEnterprisenumber()); this.updateById(aa); } @Override public void submitSaleAssessApply(Long id, UserInfo user) { AssessApply assessApply = this.getById(id); if (assessApply.getStatus() != AssessApplyStatus.REJECT && assessApply.getStatus() != AssessApplyStatus.TOSUBMIT) { throw new BusinessException("当前状态不能提交"); } assessApply.setStatus(AssessApplyStatus.PENDING); assessApply.setSubmittime(new Date()); this.updateById(assessApply); } /** * @Description: 审批通过,直接停用 * @date 2021/7/12 8:47 */ @Override @Transactional public void approveSaleAssessApply(JSONObject entity, UserInfo user) { Long id = entity.getLong("id"); // String approvenote = entity.getString("approvenote"); if (id == null ) throw new BusinessException("传参有误,请联系管理员"); AssessApply assessApply = this.getById(id); if (assessApply == null) throw new BusinessException("传参有误或者单子不存在"); assessApply.setApprover(user.getUsername()); assessApply.setApprovetime(new Date()); assessApply.setStatus(AssessApplyStatus.APPROVED); // assessApply.setApprovenote(StringUtils.isBlank(approvenote) ? null : approvenote); assessApply.setPunishstatus(PunishStatus.PUNISHING); this.updateById(assessApply); //直接执行处罚 先停用 enterpriseService.deactivateEnterprise(null,assessApply.getEnterprisenumber(), user); } @Override public void rejectSaleAssessApply(JSONObject entity, UserInfo user) { Long id = entity.getLong("id"); String lastrejectreason = entity.getString("lastrejectreason"); if (id == null ) throw new BusinessException("传参有误,请联系管理员"); if (StringUtils.isBlank(lastrejectreason)) throw new BusinessException("请填写拒绝理由"); AssessApply assessApply = this.getById(id); if (assessApply == null) throw new BusinessException("传参有误或者单子不存在"); Date now = new Date(); assessApply.setApprover(user.getUsername()); assessApply.setApprovetime(now); assessApply.setLastrejecttime(now); assessApply.setStatus(AssessApplyStatus.REJECT); assessApply.setLastrejectreason(lastrejectreason); this.updateById(assessApply); } /** * @Description: 销售评定分页查询 * @date 2021/7/5 14:30 */ @Override public IPage selectSalePages(Page page, Map filter, UserInfo user) { Map params = new HashMap<>(); params.put("type", AssessType.SALE); params.put("code", filter.get("code")); params.put("enterprisename", filter.get("enterprisename")); params.put("status", filter.get("status")); //不是超级管理员只能看到自己的 if (user.getType() != 1 && user.getType()!= 2) { params.put("requestorid", user.getId()); } List data = assessApplyMapper.selectPages(params, page); return page.setRecords(data); } @Override public void addAccessAssessApply(AssessApply assessApply, UserInfo user) { if (StringUtils.isBlank(assessApply.getEnterprisename()) || StringUtils.isBlank(assessApply.getEnterprisenumber())) throw new BusinessException("请选择企业信息"); if (assessApply.getPunishmentmeasure() == null) throw new BusinessException("请选择处罚措施"); if (StringUtils.isBlank(assessApply.getPunishmentreason())) throw new BusinessException("请填写处罚意见"); if (assessApply.getFile() == null) throw new BusinessException("请上传处罚凭证"); assessApply.setValidflag(true); assessApply.setPunishstatus(PunishStatus.UNPUNISH); assessApply.setCode("AA-" + System.currentTimeMillis()); assessApply.setCreatetime(new Date()); assessApply.setRequestor(user.getUsername()); assessApply.setRequestorid(user.getId()); assessApply.setStatus(AssessApplyStatus.TOSUBMIT); assessApply.setType(AssessType.ACCESS); try { String filename = UploadUtil.uploadFile(assessApply.getFile(), Properties.assessApplyPath); assessApply.setPath1(Properties.assessApply + filename); } catch (Exception e) { e.printStackTrace(); throw new BusinessException("上传文件出现问题,请联系管理员"); } this.save(assessApply); } @Override public void modAccessAssessApply(AssessApply assessApply, UserInfo user) { AssessApply aa = this.getById(assessApply.getId()); if (aa == null) throw new BusinessException("单子不存在,请联系管理员"); if (aa.getStatus() != AssessApplyStatus.TOSUBMIT && aa.getStatus() != AssessApplyStatus.REJECT) throw new BusinessException("提交后的单子不能修改"); if (StringUtils.isBlank(assessApply.getEnterprisename()) || StringUtils.isBlank(assessApply.getEnterprisenumber())) throw new BusinessException("请选择企业信息"); if (StringUtils.isBlank(assessApply.getPunishmentreason())) throw new BusinessException("请填写处罚意见"); if (assessApply.getFile() == null) throw new BusinessException("请上传处罚凭证"); try { String filename = UploadUtil.uploadFile(assessApply.getFile(), Properties.assessApplyPath); aa.setPath1(Properties.assessApply + filename); } catch (Exception e) { e.printStackTrace(); throw new BusinessException("上传文件出现问题,请联系管理员"); } aa.setPunishmentmeasure(assessApply.getPunishmentmeasure()); aa.setPunishmentreason(assessApply.getPunishmentreason()); aa.setModifytime(new Date()); aa.setEnterprisename(assessApply.getEnterprisename()); aa.setEnterprisenumber(assessApply.getEnterprisenumber()); //处罚的信息 this.updateById(aa); } @Override public void submitAccessAssessApply(Long id, UserInfo user) { AssessApply assessApply = this.getById(id); if (assessApply.getStatus() != AssessApplyStatus.REJECT && assessApply.getStatus() != AssessApplyStatus.TOSUBMIT) { throw new BusinessException("当前状态不能提交"); } assessApply.setStatus(AssessApplyStatus.PENDING); assessApply.setSubmittime(new Date()); this.updateById(assessApply); } @Override public List selectAllPunishingSaleAssessApply() { //条件一:type为sale 销售评定 //条件二:处罚中的单子 punishing return assessApplyMapper.selectAllPunishingSaleAssessApply(AssessType.SALE, PunishStatus.PUNISHING); } }