| | |
| | | import com.smartearth.poiexcel.entity.ResponseMsg; |
| | | import com.smartearth.poiexcel.entity.StaticData; |
| | | import com.smartearth.poiexcel.mapper.EntMapper; |
| | | import com.smartearth.poiexcel.mapper.QiYeMapper; |
| | | import com.smartearth.poiexcel.service.EntService; |
| | | import com.smartearth.poiexcel.utils.HttpUtils; |
| | | import com.smartearth.poiexcel.utils.StringHelper; |
| | |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | |
| | | @Api(tags = "企业控制器") |
| | | @RestController |
| | | @RequestMapping("/ent") |
| | | @SuppressWarnings("ALL") |
| | | public class EntController extends BaseController { |
| | | @Resource |
| | | EntService entService; |
| | |
| | | @Resource |
| | | EntMapper entMapper; |
| | | |
| | | @Resource |
| | | QiYeMapper qiYeMapper; |
| | | |
| | | @Value("${address.code.url}") |
| | | private String addressCodeUrl; |
| | | |
| | | @ApiOperation(value = "根据名称模糊查询企业") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "企业名称或地址", dataType = "String", paramType = "query", example = "") |
| | | }) |
| | | @GetMapping({"/selectByName"}) |
| | | public ResponseMsg<Object> selectByName(String name) { |
| | | try { |
| | | List<EntEntity> list = entMapper.selectByName(StringHelper.getLikeStr(name)); |
| | | |
| | | return success(null == list ? 0 : list.size(), list); |
| | | } catch (Exception ex) { |
| | | return fail(ex, -1); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "查询令牌") |
| | | @GetMapping({"/selectToken"}) |
| | |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "查询企业") |
| | | @ApiOperation(value = "查询企业信息") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "token", value = "令牌", dataType = "String", paramType = "query", example = ""), |
| | | @ApiImplicitParam(name = "startDate", value = "开始日期", dataType = "String", paramType = "query", example = "2023-06-29"), |
| | |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "分页查询") |
| | | @ApiOperation(value = "分页查询企业") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"), |
| | | @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1") |
| | |
| | | if (null == pageIndex || pageIndex < 1) { |
| | | pageIndex = 1; |
| | | } |
| | | int count = qiYeMapper.selectCount(); |
| | | List<EntEntity> list = qiYeMapper.selectByPage(pageSize, StaticData.I100 * (pageIndex - 1)); |
| | | int count = entMapper.selectCount(); |
| | | List<EntEntity> list = entMapper.selectByPage(pageSize, StaticData.I100 * (pageIndex - 1)); |
| | | |
| | | return success(count, list); |
| | | } catch (Exception ex) { |
| | |
| | | public ResponseMsg<Object> updateCoords() { |
| | | try { |
| | | int rows = 0; |
| | | int count = qiYeMapper.selectCount(); |
| | | int count = entMapper.selectCount(); |
| | | if (0 == count) { |
| | | return success("没有数据需要更新", count); |
| | | } |
| | | |
| | | int pages = (count - 1) / StaticData.I100 + 1; |
| | | for (int i = 1; i <= pages; i++) { |
| | | List<EntEntity> list = qiYeMapper.selectByPage(StaticData.I100, StaticData.I100 * (i - 1)); |
| | | List<EntEntity> list = entMapper.selectByPage(StaticData.I100, StaticData.I100 * (i - 1)); |
| | | if (null == list || list.isEmpty()) { |
| | | continue; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | rows += qiYeMapper.updates(list); |
| | | rows += entMapper.updates(list); |
| | | } |
| | | |
| | | return success(rows); |
| | |
| | | } |
| | | |
| | | JSONObject object = jsonArray.getJSONObject(0); |
| | | String addr = object.getString("formatted_address"); |
| | | /*String addr = object.getString("formatted_address"); |
| | | if (StringHelper.isEmpty(addr)) { |
| | | return; |
| | | } |
| | |
| | | if (encoding != null) { |
| | | addr = new String(addr.getBytes(encoding)); |
| | | } |
| | | // ent.setAddress(addr) |
| | | ent.setAddress(addr);*/ |
| | | |
| | | String location = object.getString("location"); |
| | | String[] split = location.split(","); |
| | | ent.setX(Double.parseDouble(split[1])); |
| | | ent.setY(Double.parseDouble(split[0])); |
| | | ent.setX(Double.parseDouble(split[0])); |
| | | ent.setY(Double.parseDouble(split[1])); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | } |