Commit 7b830c6f by wqc

接大屏数据接口

parent 01c5c67e
......@@ -124,6 +124,20 @@ public class BigScreenController {
return ResultVo.success(bigScreenService.getCityArea());
}
@ApiOperation("平台成果")
@GetMapping(value = "/getPingTaiData")
public ResultVo getPingTaiData() {
return ResultVo.success(bigScreenService.getPingTaiData());
}
@ApiOperation("质量指标")
@GetMapping(value = "/getZhiBiaoData")
public ResultVo getZhiBiaoData(@RequestParam String diqu,String type) {
return ResultVo.success(bigScreenService.getZhiBiaoData(diqu,type));
}
}
......@@ -44,7 +44,11 @@ public class Ajzlzypjzbdy {
/**
* 案件名称
*/
private String name;
private String caseRatioName;
private String casesName;
private String pieceName;
/**
* createTime
......
package com.zq.datacollect.entity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "proxy_type")
@Builder
public class ProxyType {
/**
* id
*/
@TableId(type = IdType.AUTO)
private Integer id;
/**
* 案
*/
private String cases;
/**
* 件
*/
private String piece;
/**
* 案件比
*/
private String caseRatio;
}
package com.zq.datacollect.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zq.datacollect.entity.ProxyType;
import org.apache.ibatis.annotations.Select;
import java.util.List;
@DS("hjk")
public interface ProxyTypeMapper extends BaseMapper<ProxyType> {
@Select("SELECT case_ratio as caseRatio FROM proxy_type")
List<Object> selectCaseRatio();
@Select("SELECT cases FROM proxy_type")
List<Object> selectCases();
@Select("SELECT piece FROM proxy_type")
List<Object> selectPiece();
}
......@@ -285,7 +285,7 @@ public class BigScreenService {
toDbId = list.getToDbId();
}
JdbcTemplate jdbcTemplate = DatabaseHolder.getJdbcTemplate(toDbId);
List<Map<String, Object>> objects = jdbcTemplate.queryForList("SELECT t.`南宁` as shiyuan,t.`线索条` as xiansuo,t.`核查条` as hecha,t.`成案件` as chengan,t.`成案件` as shouli,t.`成案件` as lian,t.`成案线索转化率` as chengan_rate,t.`线索转化率` as xiansuo_rate,t.`挽回损失万` as wanhui,t.`发放救助金万` as fafangjiuzhu,t.`推动建章立制` as jianzhanglizhi FROM bananchengxiao t ");
List<Map<String, Object>> objects = jdbcTemplate.queryForList("SELECT t.`南宁` as shiyuan,t.`线索条` as xiansuo,t.`核查条` as hecha,t.`成案件` as chengan,t.`成案件` as shouli,t.`成案件` as lian,t.`成案线索转化率` as chenganRate,t.`线索转化率` as xiansuoRate,t.`挽回损失万` as wanhui,t.`发放救助金万` as fafangjiuzhu,t.`推动建章立制` as jianzhanglizhi FROM bananchengxiao t ");
return objects;
}
......@@ -308,7 +308,7 @@ public class BigScreenService {
toDbId = list.getToDbId();
}
JdbcTemplate jdbcTemplate = DatabaseHolder.getJdbcTemplate(toDbId);
List<Map<String, Object>> objects = jdbcTemplate.queryForList("SELECT t.caseratio FROM proxy_type t");
List<Map<String, Object>> objects = jdbcTemplate.queryForList("SELECT t.case_ratio FROM proxy_type t");
return objects;
}
......@@ -322,4 +322,32 @@ public class BigScreenService {
List<Map<String, Object>> cityArea = jdbcTemplate.queryForList("SELECT id,diqu FROM city_area");
return cityArea;
}
public Object getPingTaiData() {
List<DataCollectSetting> collectList = getCollectList();
Integer toDbId = null;
for (DataCollectSetting list : collectList) {
toDbId = list.getToDbId();
}
JdbcTemplate jdbcTemplate = DatabaseHolder.getJdbcTemplate(toDbId);
List<Map<String, Object>> objects = jdbcTemplate.queryForList("SELECT * FROM pingtaichengguo");
return objects;
}
public Object getZhiBiaoData(String diqu,String type) {
List<DataCollectSetting> collectList = getCollectList();
Integer toDbId = null;
for (DataCollectSetting list : collectList) {
toDbId = list.getToDbId();
}
JdbcTemplate jdbcTemplate = DatabaseHolder.getJdbcTemplate(toDbId);
List<Map<String, Object>> mapList =null;
if (diqu==null||diqu.equals("")) {
mapList = jdbcTemplate.queryForList("SELECT cases,piece,case_ratio as caseRatio,unit,cases_name as casesName,piece_name as pieceName ,case_ratio_name as caseRatioName FROM ajzlzypjzbdy WHERE case_ratio_name LIKE CONCAT('%','" + type + "','%')");
}else {
mapList = jdbcTemplate.queryForList("SELECT cases,piece,case_ratio as caseRatio,unit,cases_name as casesName,piece_name as pieceName ,case_ratio_name as caseRatioName FROM ajzlzypjzbdy WHERE unit LIKE CONCAT('%','" + diqu + "','%') AND case_ratio_name LIKE CONCAT('%','" + type + "','%')");
}
return mapList;
}
}
......@@ -7,6 +7,7 @@ import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zq.common.exception.BusinessException;
......@@ -45,6 +46,9 @@ public class DataCollectFileServiceImpl extends ServiceImpl<DataCollectSettingFi
@Resource
private BananChengxiaoMapper bananChengxiaoMapper;
@Resource
private ProxyTypeMapper proxyTypeMapper;
@Override
public DataCollectSettingFile get(Integer dataCollectSettingId) {
return lambdaQuery().eq(DataCollectSettingFile::getDataCollectSettingId, dataCollectSettingId).one();
......@@ -53,7 +57,7 @@ public class DataCollectFileServiceImpl extends ServiceImpl<DataCollectSettingFi
@Override
@Transactional
public void add(DataCollectFileAddReq dataCollectFileAddReq) {
AssertUtils.isTrue(dataCollectMapper.insert(dataCollectFileAddReq.getDataCollectSetting())==1, "添加失败");
AssertUtils.isTrue(dataCollectMapper.insert(dataCollectFileAddReq.getDataCollectSetting()) == 1, "添加失败");
DataCollectSettingFile settingFile = dataCollectFileAddReq.getDataCollectSettingFile();
settingFile.setDataCollectSettingId(dataCollectFileAddReq.getDataCollectSetting().getId());
AssertUtils.isTrue(save(settingFile), "添加失败");
......@@ -63,9 +67,9 @@ public class DataCollectFileServiceImpl extends ServiceImpl<DataCollectSettingFi
@Transactional
public void update(DataCollectFileAddReq dataCollectFileAddReq) {
DataCollectSetting dataCollectSetting = dataCollectMapper.selectById(dataCollectFileAddReq.getDataCollectSetting().getId());
AssertUtils.isTrue(dataCollectSetting.getDataType()==dataCollectFileAddReq.getDataCollectSetting().getDataType(), "修改失败,数据来源不允许修改");
AssertUtils.isTrue(dataCollectSetting.getDataType() == dataCollectFileAddReq.getDataCollectSetting().getDataType(), "修改失败,数据来源不允许修改");
AssertUtils.isTrue(updateById(dataCollectFileAddReq.getDataCollectSettingFile()), "修改失败");
AssertUtils.isTrue(dataCollectMapper.updateById(dataCollectFileAddReq.getDataCollectSetting())==1, "修改失败");
AssertUtils.isTrue(dataCollectMapper.updateById(dataCollectFileAddReq.getDataCollectSetting()) == 1, "修改失败");
}
@Override
......@@ -92,10 +96,10 @@ public class DataCollectFileServiceImpl extends ServiceImpl<DataCollectSettingFi
JdbcTemplate toDbJdbcTemplate = DatabaseHolder.getJdbcTemplate(dataCollectSetting.getToDbId());
Set<String> set = list.get(0).keySet();
set.remove("id");
if(collectType == 0){
if (collectType == 0) {
toDbJdbcTemplate.execute("TRUNCATE TABLE " + dataCollectSetting.getToTable() + ";");
}
if(dataCollectSetting.getCreateTable()==1 && toDbJdbcTemplate.queryForList("SHOW TABLES LIKE '"+ dataCollectSetting.getToTable() + "'").size()==0){
if (dataCollectSetting.getCreateTable() == 1 && toDbJdbcTemplate.queryForList("SHOW TABLES LIKE '" + dataCollectSetting.getToTable() + "'").size() == 0) {
toDbJdbcTemplate.execute(SqlUtil.joinCreateTableSql(dataCollectSetting.getToTable(), dataCollectSetting.getTaskName(), set));
}
toDbJdbcTemplate.batchUpdate(SqlUtil.jointInsertSql(dataCollectSetting.getToTable(), set), new BatchPreparedStatementSetter() {
......@@ -113,9 +117,9 @@ public class DataCollectFileServiceImpl extends ServiceImpl<DataCollectSettingFi
return list.size();
}
});
dataCollectTaskLogMapper.insert(new DataCollectTaskLog(dataCollectSettingId, new Date(start), new Date(), Long.valueOf(((System.currentTimeMillis()-start)/1000)).intValue(), 2, null));
dataCollectTaskLogMapper.insert(new DataCollectTaskLog(dataCollectSettingId, new Date(start), new Date(), Long.valueOf(((System.currentTimeMillis() - start) / 1000)).intValue(), 2, null));
} catch (IOException e) {
dataCollectTaskLogMapper.insert(new DataCollectTaskLog(dataCollectSettingId, new Date(start), new Date(), Long.valueOf(((System.currentTimeMillis()-start)/1000)).intValue(), 3, e.getMessage()));
dataCollectTaskLogMapper.insert(new DataCollectTaskLog(dataCollectSettingId, new Date(start), new Date(), Long.valueOf(((System.currentTimeMillis() - start) / 1000)).intValue(), 3, e.getMessage()));
throw new BusinessException("文件读取失败,请检查后重试");
}
}
......@@ -124,8 +128,8 @@ public class DataCollectFileServiceImpl extends ServiceImpl<DataCollectSettingFi
public Object importExcelToDb(MultipartFile file) {
List<Ajzlzypjzbdy> list = ajzlzypjzbdyMapper.selectList(Wrappers.lambdaQuery(Ajzlzypjzbdy.builder().build()));
if (list!= null && list.size() > 0) {
for(Ajzlzypjzbdy one:list){
if (list != null && list.size() > 0) {
for (Ajzlzypjzbdy one : list) {
ajzlzypjzbdyMapper.deleteById(one.getId());
}
}
......@@ -136,8 +140,8 @@ public class DataCollectFileServiceImpl extends ServiceImpl<DataCollectSettingFi
e.printStackTrace();
throw new BusinessException("文件解析失败");
}
List<List<Object>> readList = reader.read(2,17);
List<Object> titleRow = reader.readRow(15);
List<List<Object>> readList = reader.read(2, 17);
List<Object> titleRow = reader.readRow(16);
int end = 0;
String pre = "";
List<String> rateList = new ArrayList<>();
......@@ -154,18 +158,32 @@ public class DataCollectFileServiceImpl extends ServiceImpl<DataCollectSettingFi
}
end++;
}
List<Object> caseRatio = proxyTypeMapper.selectCaseRatio();
List<Object> cases = proxyTypeMapper.selectCases();
List<Object> selectPiece = proxyTypeMapper.selectPiece();
for (List<Object> objectList : readList) {
String city = Convert.toStr(CollUtil.get(objectList, 0), "");
int index = 1;
int k = 0;
int a = 0;
int b = 0;
for (int i = 0; i < rateList.size(); i++) {
String caseRatioName = Convert.toStr(CollUtil.get(caseRatio, k++), "");
String casesName = Convert.toStr(CollUtil.get(cases, a++), "");
String pieceName = Convert.toStr(CollUtil.get(selectPiece, b++), "");
Ajzlzypjzbdy ajzlzypjzbdy = new Ajzlzypjzbdy();
ajzlzypjzbdy.setUnit(city);
ajzlzypjzbdy.setCases(Convert.toStr(CollUtil.get(objectList, index++)));
ajzlzypjzbdy.setPiece(Convert.toStr(CollUtil.get(objectList, index++)));
ajzlzypjzbdy.setCaseRatio(Convert.toStr(CollUtil.get(objectList, index++)));
// ajzlzypjzbdy.setName();
ajzlzypjzbdy.setCasesName(casesName);
ajzlzypjzbdy.setPieceName(pieceName);
ajzlzypjzbdy.setCaseRatioName(caseRatioName);
ajzlzypjzbdy.setCreateTime(DateUtil.date());
if (ajzlzypjzbdy.getCases()!=null && ajzlzypjzbdy.getPiece()!=null && ajzlzypjzbdy.getCaseRatio()!=null){
if (ajzlzypjzbdy.getCases() != null && ajzlzypjzbdy.getPiece() != null && ajzlzypjzbdy.getCaseRatio() != null) {
ajzlzypjzbdyMapper.insert(ajzlzypjzbdy);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment