|
@@ -1,26 +1,56 @@
|
|
package com.zhaoliangsz.grainsearch.service.impl;
|
|
package com.zhaoliangsz.grainsearch.service.impl;
|
|
|
|
|
|
|
|
+
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.zhaoliangsz.grainsearch.domain.entity.AskLeave;
|
|
import com.zhaoliangsz.grainsearch.domain.entity.InventoryTable;
|
|
import com.zhaoliangsz.grainsearch.domain.entity.InventoryTable;
|
|
|
|
+import com.zhaoliangsz.grainsearch.domain.entity.SzgcColor;
|
|
import com.zhaoliangsz.grainsearch.domain.entity.TestTable;
|
|
import com.zhaoliangsz.grainsearch.domain.entity.TestTable;
|
|
|
|
+import com.zhaoliangsz.grainsearch.mapper.AskLeaveMapper;
|
|
import com.zhaoliangsz.grainsearch.mapper.InventoryTableMapper;
|
|
import com.zhaoliangsz.grainsearch.mapper.InventoryTableMapper;
|
|
|
|
+import com.zhaoliangsz.grainsearch.mapper.SzgcColorMapper;
|
|
import com.zhaoliangsz.grainsearch.mapper.TestTableMapper;
|
|
import com.zhaoliangsz.grainsearch.mapper.TestTableMapper;
|
|
import com.zhaoliangsz.grainsearch.service.ITestTableService;
|
|
import com.zhaoliangsz.grainsearch.service.ITestTableService;
|
|
-import com.baomidou.mybatisplus.extension.service.IService;
|
|
|
|
|
|
+import org.apache.http.HttpResponse;
|
|
|
|
+import org.apache.http.NameValuePair;
|
|
|
|
+import org.apache.http.client.ClientProtocolException;
|
|
|
|
+import org.apache.http.client.HttpClient;
|
|
|
|
+import org.apache.http.client.config.RequestConfig;
|
|
|
|
+import org.apache.http.entity.StringEntity;
|
|
|
|
+import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
|
+import org.apache.http.impl.client.HttpClients;
|
|
|
|
+import org.apache.http.client.entity.UrlEncodedFormEntity;
|
|
|
|
+import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
|
+import org.apache.http.client.methods.HttpPost;
|
|
|
|
+import org.apache.http.client.utils.URIBuilder;
|
|
|
|
+import org.apache.http.message.BasicNameValuePair;
|
|
|
|
+import org.apache.http.util.EntityUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import com.zhaoliangsz.grainsearch.basic.exception.ServiceException;
|
|
import com.zhaoliangsz.grainsearch.basic.exception.ServiceException;
|
|
-import com.zhaoliangsz.grainsearch.basic.result.PageResult;
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
-import java.sql.Wrapper;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
|
+import java.net.URISyntaxException;
|
|
|
|
+import java.sql.Connection;
|
|
|
|
+import java.sql.DriverManager;
|
|
|
|
+import java.sql.SQLException;
|
|
|
|
+import java.sql.Statement;
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
+import java.time.ZonedDateTime;
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import com.zhaoliangsz.grainsearch.basic.exception.ExceptionDefinition;
|
|
import com.zhaoliangsz.grainsearch.basic.exception.ExceptionDefinition;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
* 服务实现类
|
|
* 服务实现类
|
|
@@ -36,23 +66,27 @@ public class TestTableServiceImpl extends ServiceImpl<TestTableMapper, TestTable
|
|
private TestTableMapper testTableMapper;
|
|
private TestTableMapper testTableMapper;
|
|
@Autowired
|
|
@Autowired
|
|
private InventoryTableMapper inventoryTableMapper;
|
|
private InventoryTableMapper inventoryTableMapper;
|
|
- @Override
|
|
|
|
- public PageResult<TestTable> queryTestTableList(TestTable queryTestTable) throws ServiceException{
|
|
|
|
- try{
|
|
|
|
- Map<String,Object>pageView=new HashMap<>();
|
|
|
|
- pageView.put("startRecord",(queryTestTable.getCurrentPage()-1)
|
|
|
|
- *queryTestTable.getPageSize());
|
|
|
|
- pageView.put("pageSize",queryTestTable.getPageSize());
|
|
|
|
- pageView.put("currentPage",queryTestTable.getCurrentPage());
|
|
|
|
- Integer dataCount=baseMapper.getCountByCondition(pageView);
|
|
|
|
- List<TestTable>dataList=baseMapper.getListByCondition(pageView);
|
|
|
|
- return new PageResult<>(dataList==null?new ArrayList<>():dataList,dataCount==null?0:dataCount);
|
|
|
|
- }
|
|
|
|
- catch(Exception ex){
|
|
|
|
- log.error("[TestTableServiceImpl.queryTestTableList]异常:{}",ex.toString());
|
|
|
|
- throw new ServiceException(ExceptionDefinition.QUERY_DATA_EXCEPTION);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private AskLeaveMapper askLeaveMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private SzgcColorMapper szgcColorMapper;
|
|
|
|
+// @Override
|
|
|
|
+// public PageResult<TestTable> queryTestTableList(TestTable queryTestTable) throws ServiceException{
|
|
|
|
+// try{
|
|
|
|
+// Map<String,Object>pageView=new HashMap<>();
|
|
|
|
+// pageView.put("startRecord",(queryTestTable.getCurrentPage()-1)
|
|
|
|
+// *queryTestTable.getPageSize());
|
|
|
|
+// pageView.put("pageSize",queryTestTable.getPageSize());
|
|
|
|
+// pageView.put("currentPage",queryTestTable.getCurrentPage());
|
|
|
|
+// Integer dataCount=baseMapper.getCountByCondition(pageView);
|
|
|
|
+// List<TestTable>dataList=baseMapper.getListByCondition(pageView);
|
|
|
|
+// return new PageResult<>(dataList==null?new ArrayList<>():dataList,dataCount==null?0:dataCount);
|
|
|
|
+// }
|
|
|
|
+// catch(Exception ex){
|
|
|
|
+// log.error("[TestTableServiceImpl.queryTestTableList]异常:{}",ex.toString());
|
|
|
|
+// throw new ServiceException(ExceptionDefinition.QUERY_DATA_EXCEPTION);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -191,14 +225,233 @@ public class TestTableServiceImpl extends ServiceImpl<TestTableMapper, TestTable
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public TestTable getTableList(TestTable queryTestTable) {
|
|
|
|
+ Map<String,Object>pageView=new HashMap<>();
|
|
|
|
+ pageView.put("date",queryTestTable.getRecordDate());
|
|
|
|
+ TestTable testTable=baseMapper.getTableListByCondition(pageView);
|
|
|
|
+ return testTable;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
- * 每天23.55点更新(新)
|
|
|
|
|
|
+ * 每天7.55点更新(新) 考勤请假信息取数
|
|
*/
|
|
*/
|
|
-// @Transactional(rollbackFor = Exception.class)
|
|
|
|
-// @Scheduled(cron = "0 55 23 * * ?")
|
|
|
|
-// public String addInfo() {
|
|
|
|
-// if ("3".equals(ENV)) {
|
|
|
|
-// }
|
|
|
|
-// return "OK";
|
|
|
|
-// }
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ @Scheduled(cron = "0 55 07 * * ?")
|
|
|
|
+ public String callFixedApi() throws URISyntaxException, UnsupportedEncodingException, SQLException {
|
|
|
|
+ String resultString = "";
|
|
|
|
+ Date date = new Date();
|
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
+ String today = dateFormat.format(date);
|
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
|
+ cal.add(Calendar.DAY_OF_MONTH, -10);
|
|
|
|
+ Date date1 = cal.getTime();
|
|
|
|
+ String yesterday = dateFormat.format(date1);
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
+ jsonObject.put("currentPage","1");
|
|
|
|
+ jsonObject.put("pageSize","1000");
|
|
|
|
+ jsonObject.put("startTimes",yesterday);
|
|
|
|
+ jsonObject.put("endTime",today);
|
|
|
|
+ // 将JSONObject转换为JSON字符串
|
|
|
|
+ String jsonString = jsonObject.toString();
|
|
|
|
+ HashMap<String, String> map =new HashMap<>();
|
|
|
|
+ map.put("corpId","wwd6fc036111f244df");
|
|
|
|
+ map.put("data", jsonString);
|
|
|
|
+ CloseableHttpClient client = null;
|
|
|
|
+ CloseableHttpResponse response = null;
|
|
|
|
+ RequestConfig defaultRequestConfig = RequestConfig.custom().setSocketTimeout(550000).setConnectTimeout(550000)
|
|
|
|
+ .setConnectionRequestTimeout(550000).setStaleConnectionCheckEnabled(true).build();
|
|
|
|
+ client = HttpClients.custom().setDefaultRequestConfig(defaultRequestConfig).build();
|
|
|
|
+ URIBuilder uriBuilder = new URIBuilder("http://m.cofcotunhe.com:8090/wxqyh/api/askAction!getAskList.action");
|
|
|
|
+
|
|
|
|
+ HttpPost httpPost = new HttpPost(uriBuilder.build());
|
|
|
|
+ httpPost.setHeader("Connection", "Keep-Alive");
|
|
|
|
+ httpPost.setHeader("Charset", "UTF-8");
|
|
|
|
+ httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");
|
|
|
|
+ Iterator<Map.Entry<String, String>> it = map.entrySet().iterator();
|
|
|
|
+ List<NameValuePair> params = new ArrayList<NameValuePair>();
|
|
|
|
+
|
|
|
|
+ while (it.hasNext()) {
|
|
|
|
+ Map.Entry<String, String> entry = it.next();
|
|
|
|
+ NameValuePair pair = new BasicNameValuePair(entry.getKey(), entry.getValue());
|
|
|
|
+ params.add(pair);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ httpPost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
|
|
|
|
+ try {
|
|
|
|
+ response = client.execute(httpPost);
|
|
|
|
+ resultString = EntityUtils.toString(response.getEntity(), "utf-8");
|
|
|
|
+ //将JSON字符串转为JSON对象
|
|
|
|
+ JSONObject jsonObject1 = JSONObject.parseObject(resultString);
|
|
|
|
+ String data = jsonObject1.getString("data");
|
|
|
|
+ JSONObject jsonObjects= JSONObject.parseObject(data);
|
|
|
|
+ JSONArray pageData = jsonObjects.getJSONArray("pageData");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // 数据库连接信息
|
|
|
|
+ String url = "jdbc:mysql://10.23.250.88:3306/dt";
|
|
|
|
+ String user = "admin";
|
|
|
|
+ String password = "14789632";
|
|
|
|
+ Connection conn = null;
|
|
|
|
+ Statement stmt = null;
|
|
|
|
+ try {
|
|
|
|
+ // 注册JDBC驱动
|
|
|
|
+ Class.forName("com.mysql.cj.jdbc.Driver");
|
|
|
|
+ // 打开连接
|
|
|
|
+ conn = DriverManager.getConnection(url, user, password);
|
|
|
|
+ // 执行SQL语句
|
|
|
|
+ stmt = conn.createStatement();
|
|
|
|
+ String sql = "DELETE FROM " + "ask_leave";
|
|
|
|
+ stmt.executeUpdate(sql);
|
|
|
|
+ System.out.println("表数据删除成功!");
|
|
|
|
+ } catch (ClassNotFoundException e) {
|
|
|
|
+ System.out.println("JDBC驱动未找到!");
|
|
|
|
+ } catch (SQLException e) {
|
|
|
|
+ System.out.println("SQL执行出错:" + e.getMessage());
|
|
|
|
+ } finally {
|
|
|
|
+ // 关闭资源
|
|
|
|
+ try {
|
|
|
|
+ if (stmt != null) stmt.close();
|
|
|
|
+ if (conn != null) conn.close();
|
|
|
|
+ } catch (SQLException e) {
|
|
|
|
+ System.out.println("资源关闭出错:" + e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < pageData.size(); i++) {
|
|
|
|
+ JSONObject qingjia = pageData.getJSONObject(i);
|
|
|
|
+ String askStatus = qingjia.getString("askStatus");
|
|
|
|
+ String isover = qingjia.getString("isover");
|
|
|
|
+ String departmentName = qingjia.getString("departmentName");
|
|
|
|
+ String personName = qingjia.getString("personName");
|
|
|
|
+ String title = qingjia.getString("title");
|
|
|
|
+ String sumAskDays = qingjia.getString("sumAskDays");
|
|
|
|
+ String startTime=qingjia.getString("startTime");
|
|
|
|
+ String endTime=qingjia.getString("endTime");
|
|
|
|
+ //辽糖审批通过
|
|
|
|
+ if ("2".equals(askStatus)&&"1".equals(isover)&&departmentName.contains("中粮糖业辽宁有限公司")){
|
|
|
|
+ AskLeave askLeave=new AskLeave();
|
|
|
|
+ askLeave.setDepartmentName(departmentName);
|
|
|
|
+ askLeave.setTitle(title);
|
|
|
|
+ askLeave.setPersonName(personName);
|
|
|
|
+ askLeave.setSumAskDays(sumAskDays);
|
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ LocalDateTime localDateTime = LocalDateTime.parse(startTime, formatter);
|
|
|
|
+ LocalDateTime localDateTime1 = LocalDateTime.parse(endTime, formatter);
|
|
|
|
+ askLeave.setStartTime(localDateTime);
|
|
|
|
+ askLeave.setEndTime(localDateTime1);
|
|
|
|
+ askLeave.setAskStatus(askStatus);
|
|
|
|
+ askLeave.setIsover(isover);
|
|
|
|
+ askLeaveMapper.insert(askLeave);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } catch (ClientProtocolException e) {
|
|
|
|
+ throw new RuntimeException("创建连接失败" + e);
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
|
|
+ return "ok";
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 每天8点更新(新) 数字工厂四色图取数
|
|
|
|
+ */
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ @Scheduled(cron = "0 00 08 * * ?")
|
|
|
|
+ public void szgcApi() {
|
|
|
|
+ JSONObject jsonParams = new JSONObject();
|
|
|
|
+ jsonParams.put("qxid","c2c66c0a-5526-47da-bd3e-f25f745e8a82");
|
|
|
|
+ jsonParams.put("departid","c2c66c0a-5526-47da-bd3e-f25f745e8a82");
|
|
|
|
+
|
|
|
|
+ HttpClient httpClient = HttpClients.createDefault();
|
|
|
|
+ HttpPost httpPost = new HttpPost("http://safety.cofcotunhe.com/api/user/workUnit/getWorkUnitListBydepartIdPagination");
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ StringEntity entity = new StringEntity(jsonParams.toString());
|
|
|
|
+ entity.setContentType("application/json");
|
|
|
|
+ httpPost.setEntity(entity);
|
|
|
|
+
|
|
|
|
+ HttpResponse response = httpClient.execute(httpPost);
|
|
|
|
+ String responseString = EntityUtils.toString(response.getEntity());
|
|
|
|
+ //将JSON字符串转为JSON对象
|
|
|
|
+ JSONObject jsonObject1 = JSONObject.parseObject(responseString);
|
|
|
|
+ String data = jsonObject1.getString("data");
|
|
|
|
+ JSONObject jsonObjects= JSONObject.parseObject(data);
|
|
|
|
+ JSONArray pageData = jsonObjects.getJSONArray("rows");
|
|
|
|
+ // 数据库连接信息
|
|
|
|
+ String url = "jdbc:mysql://10.23.250.88:3306/dt";
|
|
|
|
+ String user = "admin";
|
|
|
|
+ String password = "14789632";
|
|
|
|
+ Connection conn = null;
|
|
|
|
+ Statement stmt = null;
|
|
|
|
+ try {
|
|
|
|
+ // 注册JDBC驱动
|
|
|
|
+ Class.forName("com.mysql.cj.jdbc.Driver");
|
|
|
|
+ // 打开连接
|
|
|
|
+ conn = DriverManager.getConnection(url, user, password);
|
|
|
|
+ // 执行SQL语句
|
|
|
|
+ stmt = conn.createStatement();
|
|
|
|
+ String sql = "DELETE FROM " + "szgc_color";
|
|
|
|
+ stmt.executeUpdate(sql);
|
|
|
|
+ System.out.println("表数据删除成功!");
|
|
|
|
+ } catch (ClassNotFoundException e) {
|
|
|
|
+ System.out.println("JDBC驱动未找到!");
|
|
|
|
+ } catch (SQLException e) {
|
|
|
|
+ System.out.println("SQL执行出错:" + e.getMessage());
|
|
|
|
+ } finally {
|
|
|
|
+ // 关闭资源
|
|
|
|
+ try {
|
|
|
|
+ if (stmt != null) stmt.close();
|
|
|
|
+ if (conn != null) conn.close();
|
|
|
|
+ } catch (SQLException e) {
|
|
|
|
+ System.out.println("资源关闭出错:" + e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < pageData.size(); i++) {
|
|
|
|
+ JSONObject colorData = pageData.getJSONObject(i);
|
|
|
|
+ String id = colorData.getString("id");
|
|
|
|
+ String name = colorData.getString("name");
|
|
|
|
+ String level = colorData.getString("level");
|
|
|
|
+ String color = colorData.getString("color");
|
|
|
|
+ String position = colorData.getString("position");
|
|
|
|
+ String createtime = colorData.getString("createtime");
|
|
|
|
+ String departid=colorData.getString("departid");
|
|
|
|
+ String qyid=colorData.getString("qyid");
|
|
|
|
+ String worktype=colorData.getString("worktype");
|
|
|
|
+
|
|
|
|
+ SzgcColor szgcColor=new SzgcColor();
|
|
|
|
+ szgcColor.setId(id);
|
|
|
|
+ szgcColor.setName(name);
|
|
|
|
+ szgcColor.setLevel(level);
|
|
|
|
+ szgcColor.setColor(color);
|
|
|
|
+ szgcColor.setPosition(position);
|
|
|
|
+ szgcColor.setCreatetime(createtime);
|
|
|
|
+ szgcColor.setDepartid(departid);
|
|
|
|
+ szgcColor.setQyid(qyid);
|
|
|
|
+ szgcColor.setWorktype(worktype);
|
|
|
|
+ szgcColorMapper.insert(szgcColor);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|