| | |
| | | package com.zy.crm.manager.service.impl; |
| | | |
| | | import com.zy.crm.manager.mapper.PlanMapper; |
| | | import com.zy.crm.manager.entity.Plan; |
| | | import com.zy.crm.manager.service.PlanService; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.core.common.Cools; |
| | | import com.zy.crm.manager.entity.Plan; |
| | | import com.zy.crm.manager.mapper.PlanMapper; |
| | | import com.zy.crm.manager.service.PlanService; |
| | | import io.swagger.models.License; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Service("planService") |
| | | public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements PlanService { |
| | | |
| | | @Override |
| | | public Plan selectByUuid(Long hostId, String uuid) { |
| | | return this.baseMapper.selectByUuid(hostId, uuid); |
| | | } |
| | | |
| | | @Override |
| | | public void increasePlanUrl(int planId, String url,String name,Long size) { |
| | | this.baseMapper.increasePlanUrl(planId, url,name,size); |
| | | } |
| | | |
| | | @Override |
| | | public List<Integer> selectPlanUrlId(int planId) { |
| | | return this.baseMapper.selectPlanUrlId(planId); |
| | | } |
| | | |
| | | @Override |
| | | public String selectPlanUrlPlanIdUrl(int id) { |
| | | return this.baseMapper.selectPlanUrlPlanIdUrl(id); |
| | | } |
| | | |
| | | @Override |
| | | public String selectPlanUrlPlanIdName(int id) { |
| | | return this.baseMapper.selectPlanUrlPlanIdName(id); |
| | | } |
| | | |
| | | @Override |
| | | public Long selectPlanUrlPlanIdSize(int id) { |
| | | return this.baseMapper.selectPlanUrlPlanIdSize(id); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public String getUuid(Long hostId) { |
| | | String uuid = null; |
| | | int times = 0; |
| | | while (Cools.isEmpty(uuid)) { |
| | | if (times > 100) { break; } |
| | | String nextUuid = getNextUuid(hostId); |
| | | if (selectByUuid(hostId, nextUuid) == null) { |
| | | uuid = nextUuid; |
| | | } |
| | | times ++; |
| | | } |
| | | return uuid; |
| | | } |
| | | |
| | | @Override |
| | | public Page<Plan> getPage(Page<Plan> page, Long hostId, String deptId, Long userId, String condition) { |
| | | return page.setRecords(baseMapper.listByPage(page, hostId, deptId, userId, condition)); |
| | | } |
| | | |
| | | private String getNextUuid(Long hostId) { |
| | | Plan plan = this.baseMapper.selectPlanByNewestUuid(hostId); |
| | | if (plan == null) { |
| | | return "0001"; |
| | | } |
| | | return zerofill(String.valueOf(Integer.parseInt(plan.getUuid()) + 1), 4); |
| | | } |
| | | |
| | | public static String zerofill(String msg, Integer count){ |
| | | if (msg.length() == count){ |
| | | return msg; |
| | | } else if (msg.length() > count){ |
| | | return msg.substring(0, 16); |
| | | } else { |
| | | StringBuilder msgBuilder = new StringBuilder(msg); |
| | | for (int i = 0; i<count-msg.length(); i++){ |
| | | msgBuilder.insert(0,"0"); |
| | | } |
| | | return msgBuilder.toString(); |
| | | } |
| | | } |
| | | |
| | | } |