| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.zy.acs.common.utils.CodeUtils; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.manager.common.domain.CodeExcel; |
| | | import com.zy.acs.manager.common.exception.BusinessException; |
| | | import com.zy.acs.manager.manager.entity.Code; |
| | |
| | | import com.zy.acs.manager.manager.service.CodeGapService; |
| | | import com.zy.acs.manager.manager.service.CodeService; |
| | | import com.zy.acs.manager.manager.service.RouteService; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | @Autowired |
| | | private RouteService routeService; |
| | | |
| | | public static final Map<Long, Code> CODE_ID_CACHE = new HashMap<>(); |
| | | public static final Map<String, Code> CODE_DATA_CACHE = new HashMap<>(); |
| | | |
| | | @PostConstruct |
| | | public void init() { |
| | | for (Code code : this.list()) { |
| | | CODE_ID_CACHE.put(code.getId(), code); |
| | | CODE_DATA_CACHE.put(code.getData(), code); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Code selectByData(String data) { |
| | | return this.getOne(new LambdaQueryWrapper<Code>().eq(Code::getData, data)); |
| | | } |
| | | |
| | | @Override |
| | | public Code getCacheById(Long id) { |
| | | Code code = CODE_ID_CACHE.get(id); |
| | | if (code == null) { |
| | | code = this.getById(id); |
| | | } |
| | | return code; |
| | | } |
| | | |
| | | @Override |
| | | public Code getCacheByData(String data) { |
| | | Code code = CODE_DATA_CACHE.get(data); |
| | | if (code == null) { |
| | | code = this.selectByData(data); |
| | | } |
| | | return code; |
| | | } |
| | | |
| | | @Override |
| | | public void importExecute(List<CodeExcel> excelList) { |
| | | for (CodeExcel excel : excelList) { |
| | | Code code = this.selectByData(excel.getCode()); |