| | |
| | | package com.zy.crm.common.web; |
| | | |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.zy.crm.common.service.DbSqlServer; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.core.io.ClassPathResource; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * Created by vincent on 2023/7/25 |
| | | */ |
| | | @RestController |
| | | @SuppressWarnings("all") |
| | | public class DatavController { |
| | | |
| | | private String sql1; |
| | | private String 生产订单; |
| | | private String 销售订单; |
| | | |
| | | @PostConstruct |
| | | public void init() throws IOException { |
| | | this.sql1 = read(new ClassPathResource("datav/sql/1.sql").getInputStream()); |
| | | { |
| | | try { |
| | | this.生产订单 = read(new ClassPathResource("datav/sql/生产订单.sql").getInputStream()); |
| | | this.销售订单 = read(new ClassPathResource("datav/sql/销售订单.sql").getInputStream()); |
| | | } catch (IOException ignore) {} |
| | | } |
| | | |
| | | @GetMapping("/1test") |
| | | public R test1() { |
| | | return R.ok(this.sql1); |
| | | @Autowired |
| | | private DbSqlServer dbSqlServer; |
| | | |
| | | @GetMapping("/data1") |
| | | public R data1() { |
| | | List<Map<String, Object>> res = dbSqlServer.select(this.生产订单); |
| | | if (Cools.isEmpty(res)) { |
| | | return R.ok(); |
| | | } |
| | | int limit = 30; |
| | | if (res.size() > limit) { |
| | | res = res.subList(0, limit); |
| | | } |
| | | return R.ok().add(res); |
| | | } |
| | | |
| | | public static String read(InputStream inputStream) { |
| | | @GetMapping("/data3") |
| | | public R data3() { |
| | | List<Map<String, Object>> res = dbSqlServer.select(this.销售订单); |
| | | if (Cools.isEmpty(res)) { |
| | | return R.ok(); |
| | | } |
| | | return R.ok().add(res); |
| | | } |
| | | |
| | | private static String read(InputStream inputStream) { |
| | | StringBuilder stringBuilder = new StringBuilder(); |
| | | byte[] buffer = new byte[1024]; |
| | | try { |