定时任务 订单列表时间条件查询 配置yml mysql 连接 时间的多一天问题
正在显示
10 个修改的文件
包含
57 行增加
和
40 行删除
| @@ -3,9 +3,13 @@ package com.sunyo.energy.location; | @@ -3,9 +3,13 @@ package com.sunyo.energy.location; | ||
| 3 | import org.mybatis.spring.annotation.MapperScan; | 3 | import org.mybatis.spring.annotation.MapperScan; |
| 4 | import org.springframework.boot.SpringApplication; | 4 | import org.springframework.boot.SpringApplication; |
| 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; | 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| 6 | +import org.springframework.context.annotation.ComponentScan; | ||
| 7 | +import org.springframework.scheduling.annotation.EnableScheduling; | ||
| 6 | 8 | ||
| 7 | @SpringBootApplication() | 9 | @SpringBootApplication() |
| 10 | +@EnableScheduling | ||
| 8 | @MapperScan("com.sunyo.energy.location.dao") | 11 | @MapperScan("com.sunyo.energy.location.dao") |
| 12 | +@ComponentScan("com.sunyo.energy.location") | ||
| 9 | public class BootApplication { | 13 | public class BootApplication { |
| 10 | 14 | ||
| 11 | public static void main(String[] args) { | 15 | public static void main(String[] args) { |
| @@ -26,8 +26,9 @@ public class PayOrderController { | @@ -26,8 +26,9 @@ public class PayOrderController { | ||
| 26 | @RequestMapping("/list") | 26 | @RequestMapping("/list") |
| 27 | public PageInfo<PayRecords> getOrder(@RequestParam(value = "pageSize", required = false, defaultValue = "1") int pageSize, | 27 | public PageInfo<PayRecords> getOrder(@RequestParam(value = "pageSize", required = false, defaultValue = "1") int pageSize, |
| 28 | @RequestParam(value = "pageNum", required = false, defaultValue = "5") int pageNum, | 28 | @RequestParam(value = "pageNum", required = false, defaultValue = "5") int pageNum, |
| 29 | - @RequestParam(value = "orderNumber",required = false) String orderNumber){ | ||
| 30 | - return payOrderService.getOrder(pageSize, pageNum, orderNumber); | 29 | + @RequestParam(value = "orderNumber",required = false) String orderNumber, |
| 30 | + @RequestParam(value = "payTime", required = false) String payTime ){ | ||
| 31 | + return payOrderService.getOrder(pageSize, pageNum, orderNumber, payTime); | ||
| 31 | } | 32 | } |
| 32 | 33 | ||
| 33 | 34 |
| @@ -17,25 +17,25 @@ public class WaterMeterController { | @@ -17,25 +17,25 @@ public class WaterMeterController { | ||
| 17 | @Autowired | 17 | @Autowired |
| 18 | private WaterMeterService waterMeterService; | 18 | private WaterMeterService waterMeterService; |
| 19 | 19 | ||
| 20 | - /** | ||
| 21 | - * 水表实施信息入库 | ||
| 22 | - * @param resultJson | ||
| 23 | - * @return | ||
| 24 | - */ | ||
| 25 | - @RequestMapping("/realTime") | ||
| 26 | - @ResponseBody | ||
| 27 | - public ResultJson realTime(ResultJson resultJson){ | ||
| 28 | - int i = waterMeterService.realTime(); | ||
| 29 | - if (i>0){ | ||
| 30 | - resultJson.setCode("200"); | ||
| 31 | - resultJson.setMsg("操作成功"); | ||
| 32 | - }else { | ||
| 33 | - resultJson.setCode("500"); | ||
| 34 | - resultJson.setMsg("操作失败"); | ||
| 35 | - } | ||
| 36 | - | ||
| 37 | - return resultJson; | ||
| 38 | - } | 20 | +// /** |
| 21 | +// * 水表实施信息入库 | ||
| 22 | +// * @param resultJson | ||
| 23 | +// * @return | ||
| 24 | +// */ | ||
| 25 | +// @RequestMapping("/realTime") | ||
| 26 | +// @ResponseBody | ||
| 27 | +// public ResultJson realTime(ResultJson resultJson){ | ||
| 28 | +// int i = waterMeterService.realTime(); | ||
| 29 | +// if (i>0){ | ||
| 30 | +// resultJson.setCode("200"); | ||
| 31 | +// resultJson.setMsg("操作成功"); | ||
| 32 | +// }else { | ||
| 33 | +// resultJson.setCode("500"); | ||
| 34 | +// resultJson.setMsg("操作失败"); | ||
| 35 | +// } | ||
| 36 | +// | ||
| 37 | +// return resultJson; | ||
| 38 | +// } | ||
| 39 | 39 | ||
| 40 | /** | 40 | /** |
| 41 | * 水表单个实施信息查询 | 41 | * 水表单个实施信息查询 |
| @@ -18,5 +18,7 @@ public interface PayRecordsMapper { | @@ -18,5 +18,7 @@ public interface PayRecordsMapper { | ||
| 18 | 18 | ||
| 19 | int updateByPrimaryKey(PayRecords record); | 19 | int updateByPrimaryKey(PayRecords record); |
| 20 | 20 | ||
| 21 | - List<PayRecords> findAll(@Param(value = "orderNumber") String orderNumber); | 21 | + List<PayRecords> findAll(@Param(value = "orderNumber") String orderNumber, |
| 22 | + @Param(value = "startTime") String startTime, | ||
| 23 | + @Param(value = "endTime") String endTime); | ||
| 22 | } | 24 | } |
| @@ -7,7 +7,7 @@ import com.sunyo.energy.location.model.PayRecords; | @@ -7,7 +7,7 @@ import com.sunyo.energy.location.model.PayRecords; | ||
| 7 | * Created by XYH on 2019/12/16. | 7 | * Created by XYH on 2019/12/16. |
| 8 | */ | 8 | */ |
| 9 | public interface PayOrderService { | 9 | public interface PayOrderService { |
| 10 | - PageInfo<PayRecords> getOrder(int pageSize, int pageNum, String orderNumber); | 10 | + PageInfo<PayRecords> getOrder(int pageSize, int pageNum, String orderNumber, String payTime); |
| 11 | 11 | ||
| 12 | int addOrder(PayRecords payRecords); | 12 | int addOrder(PayRecords payRecords); |
| 13 | 13 |
| @@ -22,7 +22,12 @@ public class PayOrderImpl implements PayOrderService { | @@ -22,7 +22,12 @@ public class PayOrderImpl implements PayOrderService { | ||
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | @Override | 24 | @Override |
| 25 | - public PageInfo<PayRecords> getOrder(int pageSize, int pageNum, String orderNumber) { | 25 | + public PageInfo<PayRecords> getOrder(int pageSize, int pageNum, String orderNumber, String payTime) { |
| 26 | + | ||
| 27 | + // 开始时间 | ||
| 28 | + String startTime = ""; | ||
| 29 | + // 结束时间 | ||
| 30 | + String endTime = ""; | ||
| 26 | 31 | ||
| 27 | Page<PayRecords> page = PageHelper.startPage(pageNum,pageSize); | 32 | Page<PayRecords> page = PageHelper.startPage(pageNum,pageSize); |
| 28 | 33 | ||
| @@ -33,7 +38,13 @@ public class PayOrderImpl implements PayOrderService { | @@ -33,7 +38,13 @@ public class PayOrderImpl implements PayOrderService { | ||
| 33 | orderNumber = stringBuffer.insert(3, "-").toString(); | 38 | orderNumber = stringBuffer.insert(3, "-").toString(); |
| 34 | } | 39 | } |
| 35 | 40 | ||
| 36 | - List<PayRecords> list = recordsMapper.findAll(orderNumber); | 41 | + if (!StringUtils.isEmpty(payTime) && !payTime.contains("undefined")){ |
| 42 | + String[] split = payTime.split(","); | ||
| 43 | + startTime = split[0].toString(); | ||
| 44 | + endTime = split[1].toString(); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + List<PayRecords> list = recordsMapper.findAll(orderNumber, startTime, endTime); | ||
| 37 | 48 | ||
| 38 | PageInfo<PayRecords> result = new PageInfo<>(list); | 49 | PageInfo<PayRecords> result = new PageInfo<>(list); |
| 39 | return result; | 50 | return result; |
| @@ -5,11 +5,14 @@ import com.alibaba.fastjson.JSONArray; | @@ -5,11 +5,14 @@ import com.alibaba.fastjson.JSONArray; | ||
| 5 | import com.sunyo.energy.location.dao.WaterMeterMapper; | 5 | import com.sunyo.energy.location.dao.WaterMeterMapper; |
| 6 | import com.sunyo.energy.location.model.WaterMeter; | 6 | import com.sunyo.energy.location.model.WaterMeter; |
| 7 | import com.sunyo.energy.location.service.WaterMeterService; | 7 | import com.sunyo.energy.location.service.WaterMeterService; |
| 8 | +import com.sunyo.energy.location.utils.HttpsUtils; | ||
| 8 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
| 10 | +import org.springframework.scheduling.annotation.Scheduled; | ||
| 9 | import org.springframework.stereotype.Service; | 11 | import org.springframework.stereotype.Service; |
| 10 | -import utils.HttpsUtils; | 12 | +import java.util.Date; |
| 13 | +import java.util.HashMap; | ||
| 14 | +import java.util.Map; | ||
| 11 | 15 | ||
| 12 | -import java.util.*; | ||
| 13 | 16 | ||
| 14 | @Service | 17 | @Service |
| 15 | public class WaterMeterServiceImp implements WaterMeterService { | 18 | public class WaterMeterServiceImp implements WaterMeterService { |
| @@ -19,6 +22,7 @@ public class WaterMeterServiceImp implements WaterMeterService { | @@ -19,6 +22,7 @@ public class WaterMeterServiceImp implements WaterMeterService { | ||
| 19 | 22 | ||
| 20 | 23 | ||
| 21 | @Override | 24 | @Override |
| 25 | + @Scheduled(cron = "0 0 10 * * ?" ) | ||
| 22 | public int realTime() { | 26 | public int realTime() { |
| 23 | 27 | ||
| 24 | try { | 28 | try { |
| @@ -26,9 +30,7 @@ public class WaterMeterServiceImp implements WaterMeterService { | @@ -26,9 +30,7 @@ public class WaterMeterServiceImp implements WaterMeterService { | ||
| 26 | String url = "http://123.56.159.203:8023/nowwmrd/getSelectNowwmrdbyProjectID"; | 30 | String url = "http://123.56.159.203:8023/nowwmrd/getSelectNowwmrdbyProjectID"; |
| 27 | Map<String, Object> datas = new HashMap<>(); | 31 | Map<String, Object> datas = new HashMap<>(); |
| 28 | datas.put("ProjectID", "33-99-00-00-00-00-01"); | 32 | datas.put("ProjectID", "33-99-00-00-00-00-01"); |
| 29 | - | ||
| 30 | String s = HttpsUtils.httpRequest(url, datas); | 33 | String s = HttpsUtils.httpRequest(url, datas); |
| 31 | - List<WaterMeter> waterMeterList = new ArrayList<>(); | ||
| 32 | JSONArray jsonArray = JSON.parseArray(s); | 34 | JSONArray jsonArray = JSON.parseArray(s); |
| 33 | for (Object jsonObject:jsonArray){ | 35 | for (Object jsonObject:jsonArray){ |
| 34 | WaterMeter waterMeter= new WaterMeter(); | 36 | WaterMeter waterMeter= new WaterMeter(); |
| 1 | -package utils; | ||
| 2 | - | ||
| 3 | -import com.alibaba.fastjson.JSON; | ||
| 4 | -import com.alibaba.fastjson.JSONArray; | ||
| 5 | -import com.alibaba.fastjson.JSONObject; | ||
| 6 | -import com.sunyo.energy.location.model.WaterMeter; | ||
| 7 | -import jdk.nashorn.internal.parser.JSONParser; | 1 | +package com.sunyo.energy.location.utils; |
| 8 | 2 | ||
| 9 | import java.io.*; | 3 | import java.io.*; |
| 10 | import java.net.HttpURLConnection; | 4 | import java.net.HttpURLConnection; |
| 11 | import java.net.URL; | 5 | import java.net.URL; |
| 12 | import java.net.URLConnection; | 6 | import java.net.URLConnection; |
| 13 | import java.net.URLEncoder; | 7 | import java.net.URLEncoder; |
| 14 | -import java.util.ArrayList; | ||
| 15 | -import java.util.HashMap; | ||
| 16 | -import java.util.List; | ||
| 17 | import java.util.Map; | 8 | import java.util.Map; |
| 18 | 9 | ||
| 19 | public class HttpsUtils { | 10 | public class HttpsUtils { |
| @@ -67,7 +67,7 @@ spring: | @@ -67,7 +67,7 @@ spring: | ||
| 67 | # password: vmvnv1v2 | 67 | # password: vmvnv1v2 |
| 68 | #spring datasource mysql,注意编码配置,缺少数据库编码配置容易引起中文入库乱码 | 68 | #spring datasource mysql,注意编码配置,缺少数据库编码配置容易引起中文入库乱码 |
| 69 | #url: jdbc:mysql://127.0.0.1:3307/statistics?useUnicode=true&characterEncoding=utf8&nullCatalogMeansCurrent=true | 69 | #url: jdbc:mysql://127.0.0.1:3307/statistics?useUnicode=true&characterEncoding=utf8&nullCatalogMeansCurrent=true |
| 70 | - url: jdbc:mysql://118.31.66.166:3306/EMPT?useUnicode=true&characterEncoding=utf8&nullCatalogMeansCurrent=true | 70 | + url: jdbc:mysql://118.31.66.166:3306/EMPT?useUnicode=true&characterEncoding=utf8&nullCatalogMeansCurrent=true&serverTimezone=Asia/Shanghai |
| 71 | username: 110 | 71 | username: 110 |
| 72 | password: QAHqCJf2kFYCLirM | 72 | password: QAHqCJf2kFYCLirM |
| 73 | driver-class-name: com.mysql.cj.jdbc.Driver | 73 | driver-class-name: com.mysql.cj.jdbc.Driver |
| @@ -38,6 +38,12 @@ | @@ -38,6 +38,12 @@ | ||
| 38 | <if test="orderNumber != '' and orderNumber != null"> | 38 | <if test="orderNumber != '' and orderNumber != null"> |
| 39 | and orderNumber = #{orderNumber,jdbcType=VARCHAR} | 39 | and orderNumber = #{orderNumber,jdbcType=VARCHAR} |
| 40 | </if> | 40 | </if> |
| 41 | + <if test="startTime != '' and startTime != null"> | ||
| 42 | + and payTime > #{startTime,jdbcType=VARCHAR} | ||
| 43 | + </if> | ||
| 44 | + <if test="endTime != '' and endTime != null"> | ||
| 45 | + and payTime < #{endTime,jdbcType=VARCHAR} | ||
| 46 | + </if> | ||
| 41 | order by payTime desc | 47 | order by payTime desc |
| 42 | </select> | 48 | </select> |
| 43 | 49 |
-
请 注册 或 登录 后发表评论