|  |  |  | 
|---|
|  |  |  | import com.doumee.biz.system.SystemDictDataBiz; | 
|---|
|  |  |  | import com.doumee.core.constants.ResponseStatus; | 
|---|
|  |  |  | import com.doumee.core.exception.BusinessException; | 
|---|
|  |  |  | import com.doumee.dao.business.JkLineMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.model.JkLine; | 
|---|
|  |  |  | import com.doumee.service.business.third.model.LoginUserInfo; | 
|---|
|  |  |  | import com.doumee.service.business.third.model.PageData; | 
|---|
|  |  |  | import com.doumee.service.business.third.model.PageWrap; | 
|---|
|  |  |  | 
|---|
|  |  |  | private SystemDictDataBiz systemDictDataBiz; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private CategoryMapper categoryMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private JkLineMapper jkLineMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {Exception.class, BindException.class}) | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void deleteById(Integer id) { | 
|---|
|  |  |  | Category c = categoryMapper.selectById(id); | 
|---|
|  |  |  | if(c == null||Constants.equalsInteger(c.getIsdeleted(),Constants.ONE)){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.DATA_EMPTY); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(Constants.equalsInteger(c.getType(),Constants.FOUR)){ | 
|---|
|  |  |  | //如果是新线路,检查是否有子线路,有则不允许删除 | 
|---|
|  |  |  | if(jkLineMapper.selectCount(new MPJLambdaWrapper<JkLine>().eq(JkLine::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(JkLine::getCategoryId,id)) >0){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"主线路【"+c.getName()+"】下已存在子线路,不允许删除!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | categoryMapper.update(null,new UpdateWrapper<Category>().lambda().set(Category::getIsdeleted,Constants.ONE) | 
|---|
|  |  |  | .eq(Category::getId,id) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | 
|---|
|  |  |  | if (CollectionUtils.isEmpty(ids)) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | categoryMapper.update(null,new UpdateWrapper<Category>().lambda().set(Category::getIsdeleted,Constants.ONE) | 
|---|
|  |  |  | for(Integer id :ids){ | 
|---|
|  |  |  | Category c = categoryMapper.selectById(id); | 
|---|
|  |  |  | if(c == null ||Constants.equalsInteger(c.getIsdeleted(),Constants.ONE)){ | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(Constants.equalsInteger(c.getType(),Constants.FOUR)){ | 
|---|
|  |  |  | //如果是新线路,检查是否有子线路,有则不允许删除 | 
|---|
|  |  |  | if(jkLineMapper.selectCount(new MPJLambdaWrapper<JkLine>().eq(JkLine::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(JkLine::getCategoryId,id)) >0){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"主线路【"+c.getName()+"】下已存在子线路,不允许删除!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | categoryMapper.update(null,new UpdateWrapper<Category>().lambda().set(Category::getIsdeleted,Constants.ONE) | 
|---|
|  |  |  | .in(Category::getId,ids) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | //如果是主线路,查询线路数和客户数 | 
|---|
|  |  |  | queryWrapper.select( "(select count(1) from jk_line b where b.isdeleted=0 and b.CATEGORY_ID = t.id)",Category::getLineNum); | 
|---|
|  |  |  | queryWrapper.select( "(select count(1) from jk_customer b left join jk_line c on b.line_id=c.id where c.isdeleted=0 and b.isdeleted=0 and c.CATEGORY_ID = t.id)",Category::getCustomerNum); | 
|---|
|  |  |  | queryWrapper.select( "(select count(1) from jk_customer b left join jk_line c on b.line_id=c.id where c.isdeleted=0 and b.isdeleted=0 and c.CATEGORY_ID = t.id b.DISTANCE_STATUS = 1)",Category::getCustomerDoneNum); | 
|---|
|  |  |  | queryWrapper.select( "(select count(1) from jk_customer b left join jk_line c on b.line_id=c.id where c.isdeleted=0 and b.isdeleted=0 and c.CATEGORY_ID = t.id and b.DISTANCE_STATUS = 1)",Category::getCustomerDoneNum); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | queryWrapper.eq(Category::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(Objects.nonNull(pageWrap.getModel().getType()),Category::getType,pageWrap.getModel().getType()) | 
|---|