Compare commits

...

9 Commits

33 changed files with 1542 additions and 100 deletions

26
pom.xml

@ -13,22 +13,13 @@
<version>0.0.1-SNAPSHOT</version>
<name>JdcProject</name>
<description>JdcProject</description>
<url/>
<licenses>
<license/>
</licenses>
<developers>
<developer/>
</developers>
<scm>
<connection/>
<developerConnection/>
<tag/>
<url/>
</scm>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>17</java.version>
<lombok.version>1.18.4</lombok.version>
<lombok.version>1.18.20</lombok.version>
<mysql.version>8.0.33</mysql.version>
<druid.version>1.2.19</druid.version>
<mybatis-plus.version>3.5.8</mybatis-plus.version>
@ -42,6 +33,7 @@
<servlet-api.version>5.0.0</servlet-api.version>
<common-io.version>2.17.0</common-io.version>
<swagger3.version>2.8.6</swagger3.version>
<easyexcel.version>4.0.3</easyexcel.version>
</properties>
<dependencies>
@ -105,7 +97,11 @@
<artifactId>commons-lang</artifactId>
<version>${commons-lang.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>${easyexcel.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>

@ -1,6 +1,7 @@
package com.jdc.jdcproject.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jdc.jdcproject.entity.DicekeMiningloss;
import com.jdc.jdcproject.entity.DicekePlatearea;
import com.jdc.jdcproject.entity.DicekeShovel;
@ -9,6 +10,7 @@ import com.jdc.jdcproject.service.IDicekePlateareaService;
import com.jdc.jdcproject.service.IDicekeShovelService;
import com.jdc.jdcproject.utils.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
@ -33,29 +35,51 @@ public class DicekeMininglossController {
private IDicekeMininglossService dicekeMininglossService;
@Operation(summary = "查询损失和贫化报表")
@GetMapping("findAllMininggloss")
@GetMapping("findAllMiningloss")
public Result findAllLoss(){
List<DicekeMininglossVo> dicekeMininglossVoList = dicekeMininglossService.findAllLoss();
System.out.println(dicekeMininglossVoList.toString());
return Result.successResult().data("dicekeMininglossVoList", dicekeMininglossVoList);
}
@Operation(summary = "分页查询")
@GetMapping("lossPageList")
public Result lossPageList(@RequestParam(defaultValue = "1") int pageNum){
return Result.successResult().data("Page",dicekeMininglossService.getPage(pageNum));
}
@Operation(summary = "查当前或上一个月")
@GetMapping("findMonth")
public Result findMonth() {
LocalDate currentDate = LocalDate.now();
List<DicekeMininglossVo> LossMonthList = dicekeMininglossService.getLossByMonth(currentDate);
System.out.println(LossMonthList.toString());
return Result.successResult().data("LossMonthVoList", LossMonthList);
}
@Operation(summary = "通过Month查询损失和贫化报表")
@GetMapping("findLossByMonth")
public Result findLossByMonth(@RequestParam(required = false) LocalDate Month,
@RequestParam(required = false) LocalDate endMonth) {
public Result findLossByMonth(@RequestParam(required = false)
@Parameter(description = "yyyy-MM-dd",example = "2002-10-11")LocalDate LossMonth
/*,@RequestParam(required = false) LocalDate endMonth*/) {
/*
if(Month != null && endMonth != null){ //两个时间段内查询
List<DicekeMininglossVo> LossByMonthRangeVoList = dicekeMininglossService.getLossByMonthRange(Month,endMonth);
System.out.println(LossByMonthRangeVoList.toString());
return Result.successResult().data("LossMonthRangeList", LossByMonthRangeVoList);
} else if (Month != null){ //Month存在 通过获取year年和month月查询此月报表
List<DicekeMininglossVo> LossByMonthVoList = dicekeMininglossService.getLossByMonth(Month);
} else
*/
if (LossMonth != null){ //Month存在 通过获取year年和month月查询此月报表
List<DicekeMininglossVo> LossByMonthVoList = dicekeMininglossService.getLossByMonth(LossMonth);
System.out.println(LossByMonthVoList.toString());
return Result.successResult().data("LossMonthVoList", LossByMonthVoList);
} else {
return null;
return Result.errorResult().data("时间为空",null);
}
}
@ -90,18 +114,17 @@ public class DicekeMininglossController {
@Operation(summary = "新增损失和贫化信息")
@PostMapping("savedicekeMiningloss")
public Result saveLoss(@RequestBody DicekeMininglossVo dicekeMininglossVo){
public Result saveLoss(@RequestBody DicekeMiningloss dicekeMiningloss){
int savedml = dicekeMininglossService.savedml(dicekeMininglossVo);
if(savedml == 1) {
return Result.errorResult().data("平盘不存在",savedml);
} else if (savedml == 2) {
return Result.errorResult().data("电铲不存在",savedml);
} else {
return Result.successResult();
}
boolean updateflag = dicekeMininglossService.save(dicekeMiningloss);
if (updateflag){
return Result.successResult();
} else {
return Result.errorResult();
}
}
}

@ -1,9 +1,12 @@
package com.jdc.jdcproject.controller;
import com.jdc.jdcproject.entity.DicekeMiningloss;
import com.jdc.jdcproject.entity.VO.DicekeTotalMiningVo;
import com.jdc.jdcproject.service.IDicekeMininglossService;
import com.jdc.jdcproject.service.IDicekeTotalMiningService;
import com.jdc.jdcproject.utils.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -18,20 +21,61 @@ import java.util.List;
* @author xvxboo
*/
/*
* 该业务只是查询diceke_miningloss表并不存在自己的数据库
* */
@RestController
@RequestMapping("/dicekeTotalMining")
public class DicekeTotalMiningController {
@Autowired
private IDicekeTotalMiningService iDicekeTotalMiningService;
private IDicekeTotalMiningService dicekeTotalMiningService;
@Autowired
private IDicekeMininglossService dicekeMininglossService;
@Operation(summary = "通过Month查询采剥量报表")
@GetMapping("findTotalMiningByMonth")
public Result findTotalMiningByMonth(@RequestParam(required = false) LocalDate Month){
List<DicekeTotalMiningVo> totalMiningVoList = iDicekeTotalMiningService.getTotalMiningByMonth(Month);
@GetMapping("findTotalMiningByMonth/{Month}")
public Result findTotalMiningByMonth(@RequestParam(required = false)
@Parameter(description = "yyyy-MM-dd",example = "2002-10-11")LocalDate Month){
List<DicekeTotalMiningVo> totalMiningVoList = dicekeTotalMiningService.getTotalMiningByMonth(Month);
System.out.println(totalMiningVoList.toString());
return Result.successResult().data("totalMiningVoList",totalMiningVoList);
}
@Operation(summary = "修改采剥量报表")
@PostMapping("updateTotalMining")
public Result updateTotalMining(@RequestBody DicekeTotalMiningVo dtm){
DicekeMiningloss dml = new DicekeMiningloss();
dml.setLossID(dtm.getTotalID());
dml.setPlateID(dtm.getPlateID());
dml.setShovelID(dtm.getShovelID());
dml.setBeizhu(dtm.getBeizhu());
dml.setStrippingTon(dtm.getStrippingTon());
dml.setStrippingAndTotalMiningTon(dtm.getStrippingAndTotalMiningTon());
dml.setMonth(dtm.getMonth());
boolean updateFlag = dicekeMininglossService.updateById(dml);
if (updateFlag){
return Result.successResult();
} else {
return Result.errorResult();
}
}
//TODO: 删除不清楚业务逻辑是否直接删除所使用的diceke_miningloss表数据
@Operation(summary = "删除采剥量报表")
@DeleteMapping("deleteTotalMining/{totalID}")
public Result deleteLoss(@PathVariable String totalID){
boolean updateflag = dicekeMininglossService.removeById(totalID);
if(updateflag){
return Result.successResult();
} else {
return Result.errorResult();
}
}
}

@ -2,20 +2,23 @@ package com.jdc.jdcproject.controller;
import com.jdc.jdcproject.entity.FangpaishuiPumpoperationrecord;
import com.jdc.jdcproject.entity.FangpaishuiUnit;
import com.jdc.jdcproject.entity.VO.FangpaishuiPumpoperationrecordVo;
import com.jdc.jdcproject.entity.VO.FangpaishuiUnitVo;
import com.jdc.jdcproject.entity.FangpaishuiWatertreatmentrecord;
import com.jdc.jdcproject.entity.VO.*;
import com.jdc.jdcproject.service.EquipmentService;
import com.jdc.jdcproject.service.FangpaishuiPumpoperationrecordService;
import com.jdc.jdcproject.utils.LastDayOfMonth;
import com.jdc.jdcproject.utils.Result;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.sql.SQLOutput;
import java.text.ParseException;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/FangpaishuiPumpoperationrecordController")
@ -78,4 +81,22 @@ public class FangpaishuiPumpoperationrecordController {
return Result.errorResult();
}
}
@Operation(summary = "根据月查询排/倒水月报表")
@GetMapping("findFangpaishuiPumpoperationrecordByMonth/{date}")
public Result findWatertreatmentrecordByMonth(@PathVariable String date) throws ParseException {
String[] s = date.split("-");
int year = Integer.parseInt(s[0]);
int month = Integer.parseInt(s[1]);
LastDayOfMonth lastDayOfMonth = new LastDayOfMonth();
String upDay = lastDayOfMonth.getLastDayOfMonth(year, month-1);
String lastDay = lastDayOfMonth.getLastDayOfMonth(year, month);
upDay = lastDayOfMonth.dateCalculations(upDay,5);
lastDay = lastDayOfMonth.dateCalculations(lastDay,6);
FangpaishuiPumpoperationrecordReportByYearCountVo fangpaishuiPumpoperationrecordReportByYearCountVo =fangpaishuiPumpoperationrecordService.findAll(upDay,lastDay);
return Result.successResult().data("fangpaishuiPumpoperationrecordReportByYearCountVo",fangpaishuiPumpoperationrecordReportByYearCountVo);
}
}

@ -0,0 +1,120 @@
package com.jdc.jdcproject.controller;
import com.google.gson.Gson;
import com.jdc.jdcproject.entity.Users;
import com.jdc.jdcproject.exceptionhandler.JdcException;
import com.jdc.jdcproject.service.IUsersService;
import com.jdc.jdcproject.utils.ConstantUtils;
import com.jdc.jdcproject.utils.HttpUtils;
import com.jdc.jdcproject.utils.JwtUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashMap;
@Controller
@RequestMapping("/api/ucenter/wx")
@CrossOrigin
public class WxApiController {
@Autowired
private IUsersService usersService;
@GetMapping("login")
public String genQrConnect(HttpSession session) {
// 微信开放平台授权baseUrl
String baseUrl = "https://open.weixin.qq.com/connect/qrconnect" +
"?appid=%s" +
"&redirect_uri=%s" +
"&response_type=code" +
"&scope=snsapi_login" +
"&state=%s" +
"#wechat_redirect";
// 回调地址
String redirectUrl = ConstantUtils.WX_OPEN_REDIRECT_URL; //获取业务服务器重定向地址
try {
redirectUrl = URLEncoder.encode(redirectUrl, "UTF-8"); //url编码
} catch (UnsupportedEncodingException e) {
throw new JdcException(20001, e.getMessage());
}
// 防止csrf攻击跨站请求伪造攻击
//String state = UUID.randomUUID().toString().replaceAll("-", "");//一般情况下会使用一个随机数
String state = "imhelen";//为了让大家能够使用我搭建的外网的微信回调跳转服务器这里填写你在ngrok的前置域名
System.out.println("state = " + state);
// 采用redis等进行缓存state 使用sessionId为key 30分钟后过期可配置
//"wechar-open-state-" + httpServletRequest.getSession().getId()
//satte
//过期时间30分钟
//生成qrcodeUrl
String qrcodeUrl = String.format(
baseUrl,
ConstantUtils.WX_OPEN_APP_ID,
redirectUrl,
state);
return "redirect:" + qrcodeUrl;
}
@GetMapping("callback")
public String callback(String code, String state, HttpSession session) {
try {
//得到授权临时票据code
System.out.println("code = " + code);
System.out.println("state = " + state);
//向认证服务器发送请求换取access_token
String baseAccessTokenUrl = "https://api.weixin.qq.com/sns/oauth2/access_token" +
"?appid=%s" +
"&secret=%s" +
"&code=%s" +
"&grant_type=authorization_code";
String accessTokenUrl = String.format(baseAccessTokenUrl,
ConstantUtils.WX_OPEN_APP_ID,
ConstantUtils.WX_OPEN_APP_SECRET,
code);
String result = HttpUtils.get(accessTokenUrl);
System.out.println("accessToken=============" + result);
//解析json字符串
Gson gson = new Gson();
HashMap map = gson.fromJson(result, HashMap.class);
String accessToken = (String) map.get("access_token");
String openid = (String) map.get("openid");
//查询数据库当前用用户是否曾经使用过微信登录
/* Users member = usersService.getByOpenid(openid);
if (member == null) {
System.out.println("新用户注册");
//访问微信的资源服务器获取用户信息
String baseUserInfoUrl = "https://api.weixin.qq.com/sns/userinfo" +
"?access_token=%s" +
"&openid=%s";
String userInfoUrl = String.format(baseUserInfoUrl, accessToken, openid);
String resultUserInfo = null;
resultUserInfo = HttpUtils.get(userInfoUrl);
System.out.println("resultUserInfo==========" + resultUserInfo);
HashMap<String, Object> mapUserInfo = gson.fromJson(resultUserInfo, HashMap.class);
String nickname = (String) mapUserInfo.get("nickname");
String headimgurl = (String) mapUserInfo.get("headimgurl");
}*/
//String memberIdByJwtToken = JwtUtils.getJwtToken(member.getId(), member.getUsername());
return "redirect:http://localhost:8000?token=" ;
} catch (Exception e) {
throw new JdcException(20001, "登陆失败");
}
}
}

@ -35,10 +35,14 @@ public class DicekeMiningloss implements Serializable {
@Schema(description = "月份")
private LocalDate month;
@Schema(description = "剥离量(吨)")
@Schema(description = "圈定矿量(吨)")
private Double DefineMineralReserves;
@Schema(description = "剥离量(吨)")
private Double strippingTon;
@Schema(description = "采剥总量(吨)")
@Schema(description = "实采总量(吨)")
private Double strippingAndTotalMiningTon;
@Schema(description = "采下废石(吨)")
@ -47,25 +51,34 @@ public class DicekeMiningloss implements Serializable {
@Schema(description = "贫化率(%")
private Double dilutionRate;
@Schema(description = "损失矿量(吨)")
private Double LossMineralTon;
@Schema(description = "损失率(%")
private Double lossRate;
@Schema(description = "配矿配矿量(吨)")
private Double allocationTon;
@Schema(description = "备注")
private String beizhu;
@Override
public String toString() {
return "DicekeMiningloss{" +
"lossID = " + lossID +
", plateID = " + plateID +
", shovelID = " + shovelID +
", month = " + month +
", strippingTon = " + strippingTon +
", strippingAndTotalMiningTon = " + strippingAndTotalMiningTon +
", wasteRockTon = " + wasteRockTon +
", dilutionRate = " + dilutionRate +
", lossRate = " + lossRate +
", allocationTon = " + allocationTon +
"}";
"lossID='" + lossID + '\'' +
", plateID='" + plateID + '\'' +
", shovelID='" + shovelID + '\'' +
", month=" + month +
", DefineMineralReserves=" + DefineMineralReserves +
", strippingTon=" + strippingTon +
", strippingAndTotalMiningTon=" + strippingAndTotalMiningTon +
", wasteRockTon=" + wasteRockTon +
", dilutionRate=" + dilutionRate +
", LossMineralTon=" + LossMineralTon +
", lossRate=" + lossRate +
", allocationTon=" + allocationTon +
", beizhu='" + beizhu + '\'' +
'}';
}
}

@ -26,10 +26,13 @@ public class DicekeMininglossVo {
@Schema(description = "月份")
private LocalDate month;
@Schema(description = "圈定矿量(吨)")
private Double DefineMineralReserves;
@Schema(description = "剥离量(吨)")
private Double strippingTon;
@Schema(description = "总量(吨)")
@Schema(description = "采总量(吨)")
private Double strippingAndTotalMiningTon;
@Schema(description = "采下废石(吨)")
@ -38,6 +41,9 @@ public class DicekeMininglossVo {
@Schema(description = "贫化率(%")
private Double dilutionRate;
@Schema(description = "损失矿量(吨)")
private Double LossMineralTon;
@Schema(description = "损失率(%")
private Double lossRate;
@ -49,18 +55,18 @@ public class DicekeMininglossVo {
@Override
public String toString() {
return "DicekeMiningloss{" +
"lossID = " + lossID +
", plateID = " + plateRange +
", shovelID = " + shovelCode +
", month = " + month +
", strippingTon = " + strippingTon +
", strippingAndTotalMiningTon = " + strippingAndTotalMiningTon +
", wasteRockTon = " + wasteRockTon +
", dilutionRate = " + dilutionRate +
", lossRate = " + lossRate +
", allocationTon = " + allocationTon +
", beizhu = " + beizhu +
"}";
return "DicekeMininglossVo{" +
"lossID='" + lossID + '\'' +
", plateRange='" + plateRange + '\'' +
", shovelCode='" + shovelCode + '\'' +
", month=" + month +
", DefineMineralReserves=" + DefineMineralReserves +
", strippingAndTotalMiningTon=" + strippingAndTotalMiningTon +
", wasteRockTon=" + wasteRockTon +
", dilutionRate=" + dilutionRate +
", lossRate=" + lossRate +
", allocationTon=" + allocationTon +
", beizhu='" + beizhu + '\'' +
'}';
}
}

@ -10,18 +10,23 @@ public class DicekeTotalMiningVo {
private static final long serialVersionUID = 1L;
@Schema(description = "平盘名称")
private String plateRange;
@Schema(description = "TotalID") /*传LossID,涉及修改或删除Loss表*/
@TableId("TotalID")
private String TotalID;
@Schema(description = "铲号")
private String shovelCode;
@Schema(description = "外键关联平盘表")
private String plateID;
@Schema(description = "外键关联铲号表")
private String shovelID;
@Schema(description = "备注")
private String beizhu;
/*
@Schema(description = "计量单位")
private String UOM;
*/
@Schema(description = "出矿量(吨)")
private Double OreYield;
@ -31,21 +36,23 @@ public class DicekeTotalMiningVo {
@Schema(description = "采剥总量(吨)")
private Double strippingAndTotalMiningTon;
@Schema(description = "月份")
@Schema(description = "月份",name="月份")
private LocalDate month;
public DicekeTotalMiningVo(String plateRange,
String shovelCode,
public DicekeTotalMiningVo(String totalID,
String plateID,
String shovelID,
String beizhu,
String UOM,
Double oreYield,
Double strippingTon,
Double strippingAndTotalMiningTon,
LocalDate month) {
this.plateRange = plateRange;
this.shovelCode = shovelCode;
TotalID = totalID;
this.plateID = plateID;
this.shovelID = shovelID;
this.beizhu = beizhu;
this.UOM = UOM;
// this.UOM = UOM;
OreYield = oreYield;
this.strippingTon = strippingTon;
this.strippingAndTotalMiningTon = strippingAndTotalMiningTon;
@ -55,10 +62,11 @@ public class DicekeTotalMiningVo {
@Override
public String toString() {
return "DicekeTotalMiningVo{" +
"plateRange='" + plateRange + '\'' +
", shovelCode='" + shovelCode + '\'' +
"TotalID='" + TotalID + '\'' +
", plateID='" + plateID + '\'' +
", shovelID='" + shovelID + '\'' +
", beizhu='" + beizhu + '\'' +
", UOM='" + UOM + '\'' +
// ", UOM='" + UOM + '\'' +
", OreYield=" + OreYield +
", strippingTon=" + strippingTon +
", strippingAndTotalMiningTon=" + strippingAndTotalMiningTon +

@ -0,0 +1,32 @@
package com.jdc.jdcproject.entity.VO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class FangpaishuiPumpoperationrecordReportByMonthCountVo implements Serializable {
@Schema(description = "排/倒明细总")
private List<FangpaishuiPumpoperationrecordReportVo> fangpaishuiPumpoperationrecordReportVos;
@Schema(description = "所有泵站月总排和倒水量")
private int VolumeAllByMouth;
@Schema(description = "所有泵站年总排和倒水量")
private int VolumeAllByYear;
@Schema(description = "类型")
private String type;
}

@ -0,0 +1,28 @@
package com.jdc.jdcproject.entity.VO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class FangpaishuiPumpoperationrecordReportByYearCountVo implements Serializable {
@Schema(description = "合计报表")
private List<FangpaishuiPumpoperationrecordReportByMonthCountVo> fangpaishuiPumpoperationrecordReportByMonthCountVos;
@Schema(description = "月总排和倒水量")
private int VolumeByMouthCount;
@Schema(description = "年总排和倒水量")
private int VolumeByYearCount;
}

@ -0,0 +1,29 @@
package com.jdc.jdcproject.entity.VO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@Data
public class FangpaishuiPumpoperationrecordReportVo implements Serializable {
@Schema(description = "泵站名称")
private String EquipmentName;
@Schema(description = "日志数据")
private List<FangpaishuiPumpoperationrecordVo> fangpaishuiPumpoperationrecordVos;
@Schema(description = "本泵站月总排/倒水量")
private int VolumeByMouth;
}

@ -1,8 +1,10 @@
package com.jdc.jdcproject.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jdc.jdcproject.entity.DicekeMiningloss;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jdc.jdcproject.entity.VO.DicekeMininglossVo;
import com.jdc.jdcproject.entity.VO.DicekeTotalMiningVo;
import org.apache.ibatis.annotations.Mapper;
import java.time.LocalDate;
@ -21,9 +23,14 @@ public interface DicekeMininglossMapper extends BaseMapper<DicekeMiningloss> {
List<DicekeMininglossVo> findAllLoss();
/*
// 两个时间内查询
List<DicekeMininglossVo> findLossByMonthRange(int SmonthM, int SmonthY, int endMonthM, int endMonthY);
*/
List<DicekeMininglossVo> findLossByMonth(int monthV,int year);
Page<DicekeMininglossVo> selectLossPage(Page<DicekeMininglossVo> page);
}

@ -2,8 +2,10 @@ package com.jdc.jdcproject.mapper;
import com.jdc.jdcproject.entity.FangpaishuiPumpoperationrecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jdc.jdcproject.entity.VO.FangpaishuiPumpoperationrecordReportVo;
import com.jdc.jdcproject.entity.VO.FangpaishuiPumpoperationrecordVo;
import com.jdc.jdcproject.entity.VO.FangpaishuiUnitVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -16,6 +18,11 @@ import java.util.List;
public interface FangpaishuiPumpoperationrecordMapper extends BaseMapper<FangpaishuiPumpoperationrecord> {
List<FangpaishuiPumpoperationrecordVo> findDetail(FangpaishuiPumpoperationrecordVo vo);
List<FangpaishuiPumpoperationrecordVo> findAll(String upDate, String lastDate);
int findCount(@Param("type")String type, @Param("upDate")String upDate, @Param("lastDate") String lastDate);
}

@ -7,10 +7,11 @@
select dml.LossID,
dp.PlateRange,
ds.ShovelCode,
dml.StrippingTon,
dml.DefineMineralReserves,
dml.StrippingAndTotalMiningTon,
dml.WasteRockTon,
dml.DilutionRate,
dml.LossMineralTon,
dml.LossRate,
dml.AllocationTon,
dml.Month,
@ -19,7 +20,8 @@
LEFT JOIN diceke_platearea dp ON dml.PlateID = dp.PlateID
LEFT JOIN diceke_shovel ds ON dml.ShovelID = ds.ShovelID
</select>
<!--
// 两个时间内查询
<select id="findLossByMonthRange" resultType="com.jdc.jdcproject.entity.VO.DicekeMininglossVo">
select dml.LossID,
dp.PlateRange,
@ -39,15 +41,18 @@
AND
(YEAR(dml.Month) &lt; #{endMonthY} OR (YEAR(dml.Month) = #{endMonthY} AND MONTH(dml.Month) &lt;= #{endMonthM}))
</select>
-->
<select id="findLossByMonth" resultType="com.jdc.jdcproject.entity.VO.DicekeMininglossVo">
select dml.LossID,
dp.PlateRange,
ds.ShovelCode,
dml.DefineMineralReserves,
dml.StrippingTon,
dml.StrippingAndTotalMiningTon,
dml.WasteRockTon,
dml.DilutionRate,
dml.LossMineralTon,
dml.LossRate,
dml.AllocationTon,
dml.Month,
@ -57,4 +62,23 @@
LEFT JOIN diceke_shovel ds ON dml.ShovelID = ds.ShovelID
WHERE YEAR(dml.Month) = #{year} AND MONTH(dml.Month) = #{monthV}
</select>
<select id="selectLossPage" resultType="com.jdc.jdcproject.entity.VO.DicekeMininglossVo">
select dml.LossID,
dp.PlateRange,
ds.ShovelCode,
dml.DefineMineralReserves,
dml.StrippingAndTotalMiningTon,
dml.WasteRockTon,
dml.DilutionRate,
dml.LossMineralTon,
dml.LossRate,
dml.AllocationTon,
dml.Month,
dml.beizhu FROM diceke_miningloss dml
LEFT JOIN diceke_platearea dp ON dml.PlateID = dp.PlateID
LEFT JOIN diceke_shovel ds ON dml.ShovelID = ds.ShovelID
</select>
</mapper>

@ -26,5 +26,39 @@
</where>
</select>
<select id="findAll" parameterType="com.jdc.jdcproject.entity.VO.FangpaishuiPumpoperationrecordVo" resultType="com.jdc.jdcproject.entity.VO.FangpaishuiPumpoperationrecordVo">
SELECT
fp.RecordID,
e.EquipmentId,
e.EquipmentName,
fn.UnitId,
fn.UnitCode,
fn.RatedCapacity,
fp.OperationType,
fp.Sailings,
fp.StartupTime,
fp.EndTime,
fp.OperationTime,
fp.Volume,
fp.MONTH
FROM
fangpaishui_pumpoperationrecord fp
LEFT JOIN fangpaishui_unit fn ON fn.UnitID = fp.UnitID
JOIN equipment e ON fn.EquipmentId = e.EquipmentId
WHERE
fp.Month BETWEEN '${upDate}' AND '${lastDate}'
</select>
<select id="findCount" resultType="int">
SELECT
SUM(Volume)
FROM
fangpaishui_pumpoperationrecord
WHERE
Month BETWEEN '${upDate}' AND '${lastDate}'
and
OperationType = '${type}'
</select>
</mapper>

@ -2,6 +2,8 @@ package com.jdc.jdcproject.service;
import com.jdc.jdcproject.entity.FangpaishuiPumpoperationrecord;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jdc.jdcproject.entity.VO.FangpaishuiPumpoperationrecordReportByYearCountVo;
import com.jdc.jdcproject.entity.VO.FangpaishuiPumpoperationrecordReportVo;
import com.jdc.jdcproject.entity.VO.FangpaishuiPumpoperationrecordVo;
import com.jdc.jdcproject.entity.VO.FangpaishuiUnitVo;
@ -13,5 +15,12 @@ import java.util.List;
* @createDate 2025-05-07 13:37:49
*/
public interface FangpaishuiPumpoperationrecordService extends IService<FangpaishuiPumpoperationrecord> {
//查询泵站操作明细
List<FangpaishuiPumpoperationrecordVo> findDetail(FangpaishuiPumpoperationrecordVo vo);
//查询泵站操作总报表
FangpaishuiPumpoperationrecordReportByYearCountVo findAll(String upDate, String lastDate);
//查询操作时间节点查询年总量
int findCount(String type,String lastDate);
}

@ -1,9 +1,9 @@
package com.jdc.jdcproject.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jdc.jdcproject.entity.DicekeMiningloss;
import com.jdc.jdcproject.entity.VO.DicekeMininglossVo;
import com.jdc.jdcproject.utils.Result;
import java.time.LocalDate;
import java.util.List;
@ -20,11 +20,19 @@ public interface IDicekeMininglossService extends IService<DicekeMiningloss> {
List<DicekeMininglossVo> findAllLoss();
Page<DicekeMininglossVo> getPage(int pageNum);
/*
int savedml(DicekeMininglossVo dicekeMininglossVo);
*/
/*
// 两个时间内查询
List<DicekeMininglossVo> getLossByMonthRange(LocalDate Month, LocalDate endMonth);
*/
List<DicekeMininglossVo> getLossByMonth(LocalDate currentDate);
List<DicekeMininglossVo> getLossByMonth(LocalDate Month);
}

@ -1,6 +1,7 @@
package com.jdc.jdcproject.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jdc.jdcproject.entity.DicekeMiningloss;
import com.jdc.jdcproject.entity.DicekePlatearea;
import com.jdc.jdcproject.entity.DicekeShovel;
@ -10,10 +11,6 @@ import com.jdc.jdcproject.mapper.DicekePlateareaMapper;
import com.jdc.jdcproject.mapper.DicekeShovelMapper;
import com.jdc.jdcproject.service.IDicekeMininglossService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jdc.jdcproject.service.IDicekePlateareaService;
import com.jdc.jdcproject.service.IDicekeShovelService;
import com.jdc.jdcproject.utils.Result;
import org.apache.commons.lang.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -43,7 +40,8 @@ public class DicekeMininglossServiceImpl extends ServiceImpl<DicekeMininglossMap
return baseMapper.findAllLoss();
}
/*
// 两个时间内查询
@Override
public List<DicekeMininglossVo> getLossByMonthRange(LocalDate month, LocalDate endMonth) {
@ -72,22 +70,41 @@ public class DicekeMininglossServiceImpl extends ServiceImpl<DicekeMininglossMap
}
}
*/
@Override
public List<DicekeMininglossVo> getLossByMonth(LocalDate month) {
int year = month.getYear();
int monthV = month.getMonthValue();
return baseMapper.findLossByMonth(monthV,year);
public List<DicekeMininglossVo> getLossByMonth(LocalDate currentDate) {
int year = currentDate.getYear();
int monthV = currentDate.getMonthValue();
List<DicekeMininglossVo> lossMonthList = baseMapper.findLossByMonth(monthV, year);
if (lossMonthList.isEmpty()) {
LocalDate lastMonth;
if (currentDate.getMonthValue() == 1) {
lastMonth = LocalDate.of(currentDate.getYear() - 1, 12, 1);
} else {
lastMonth = LocalDate.of(currentDate.getYear(), currentDate.getMonthValue() - 1, 1);
}
return baseMapper.findLossByMonth(lastMonth.getMonthValue(),lastMonth.getYear());
}
return lossMonthList;
}
@Override
public Page<DicekeMininglossVo> getPage(int pageNum) {
Page<DicekeMininglossVo> page = new Page<>(pageNum, 30);
return baseMapper.selectLossPage(page);
}
/*
@Override
public int savedml(DicekeMininglossVo dicekeMininglossVo) {
/*
*//*
QueryWrapper<DicekePlatearea> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("plateRange",dicekeMininglossVo.getPlateRange());
DicekePlatearea dp = dicekePlateareaService.getOne(queryWrapper);
*/
*//*
//平盘和电铲查找是否单独一个工具类如果使用次数多
DicekePlatearea dp = dicekePlateareaMapper.selectOne(
@ -114,7 +131,7 @@ public class DicekeMininglossServiceImpl extends ServiceImpl<DicekeMininglossMap
dml.setShovelID(ds.getShovelID());
dml.setPlateID(dp.getPlateID());
dml.setMonth(dicekeMininglossVo.getMonth());
dml.setStrippingTon(dicekeMininglossVo.getStrippingTon());
dml.setDefineMineralReserves(dicekeMininglossVo.getDefineMineralReserves());
dml.setStrippingAndTotalMiningTon(dicekeMininglossVo.getStrippingAndTotalMiningTon());
dml.setWasteRockTon(dicekeMininglossVo.getWasteRockTon());
dml.setDilutionRate(dicekeMininglossVo.getDilutionRate());
@ -123,6 +140,7 @@ public class DicekeMininglossServiceImpl extends ServiceImpl<DicekeMininglossMap
dicekeMininglossMapper.insert(dml);
return 20000;
}
*/

@ -30,6 +30,7 @@ public class DicekeTotalMiningServiceImpl extends ServiceImpl<DicekeMininglossMa
List<DicekeTotalMiningVo> totalMiningList = new ArrayList<>();
//将mininglossListt赋值给totalMiningList
for (DicekeMininglossVo dmlVoLItem : mininglossVoList){
String TotalID = dmlVoLItem.getLossID();
String plateR = dmlVoLItem.getPlateRange();
String shovelC = dmlVoLItem.getShovelCode();
String beiZ = dmlVoLItem.getBeizhu();
@ -40,7 +41,7 @@ public class DicekeTotalMiningServiceImpl extends ServiceImpl<DicekeMininglossMa
Double strippingAndTMT = dmlVoLItem.getStrippingAndTotalMiningTon();
LocalDate mon = dmlVoLItem.getMonth();
DicekeTotalMiningVo dtmVoItem = new DicekeTotalMiningVo(plateR,
DicekeTotalMiningVo dtmVoItem = new DicekeTotalMiningVo(TotalID,plateR,
shovelC,beiZ,uom,oreY,strippingT,strippingAndTMT,mon);
totalMiningList.add(dtmVoItem);

@ -2,12 +2,19 @@ package com.jdc.jdcproject.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jdc.jdcproject.entity.FangpaishuiPumpoperationrecord;
import com.jdc.jdcproject.entity.VO.FangpaishuiPumpoperationrecordReportByMonthCountVo;
import com.jdc.jdcproject.entity.VO.FangpaishuiPumpoperationrecordReportByYearCountVo;
import com.jdc.jdcproject.entity.VO.FangpaishuiPumpoperationrecordReportVo;
import com.jdc.jdcproject.entity.VO.FangpaishuiPumpoperationrecordVo;
import com.jdc.jdcproject.service.FangpaishuiPumpoperationrecordService;
import com.jdc.jdcproject.mapper.FangpaishuiPumpoperationrecordMapper;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* @author 95262
@ -22,6 +29,109 @@ public class FangpaishuiPumpoperationrecordServiceImpl extends ServiceImpl<Fangp
public List<FangpaishuiPumpoperationrecordVo> findDetail(FangpaishuiPumpoperationrecordVo vo) {
return baseMapper.findDetail(vo);
}
@Override
public FangpaishuiPumpoperationrecordReportByYearCountVo findAll(String upDate, String lastDate) {
List<FangpaishuiPumpoperationrecordVo> fangpaishuiPumpoperationrecordVos = baseMapper.findAll(upDate,lastDate);
//根据类型分组排水/倒水
Map<String, List<FangpaishuiPumpoperationrecordVo>> stringListMap = fangpaishuiPumpoperationrecordVos.stream().collect(Collectors.groupingBy(FangpaishuiPumpoperationrecordVo::getOperationType));
List<FangpaishuiPumpoperationrecordVo> fangpaishuiPumpoperationrecordVoPais = new ArrayList<>();
List<FangpaishuiPumpoperationrecordVo> fangpaishuiPumpoperationrecordVoDao = new ArrayList<>();
Set<Map.Entry<String, List<FangpaishuiPumpoperationrecordVo>>> entries = stringListMap.entrySet();
for(Map.Entry m : entries){
if (m.getKey().equals("排水")){
fangpaishuiPumpoperationrecordVoPais.addAll((List<FangpaishuiPumpoperationrecordVo>) m.getValue());
}else {
fangpaishuiPumpoperationrecordVoDao.addAll((List<FangpaishuiPumpoperationrecordVo>) m.getValue());
}
}
//排水根据机组合并数据
fangpaishuiPumpoperationrecordVoPais = fangpaishuiPumpoperationrecordVoPais.stream().collect(Collectors.toMap(FangpaishuiPumpoperationrecordVo::getUnitID, a -> a, (o1,o2)-> {
o1.setOperationTime(o1.getOperationTime() + o2.getOperationTime());
o1.setVolume(o1.getVolume () + o2.getVolume ());
return o1;
})).values().stream().collect(Collectors.toList());
//倒水根据机组合并数据
fangpaishuiPumpoperationrecordVoDao = fangpaishuiPumpoperationrecordVoDao.stream().collect(Collectors.toMap(FangpaishuiPumpoperationrecordVo::getUnitID, a -> a, (o1,o2)-> {
o1.setOperationTime(o1.getOperationTime() + o2.getOperationTime());
o1.setVolume(o1.getVolume () + o2.getVolume ());
return o1;
})).values().stream().collect(Collectors.toList());
//排水根据泵站分组
Map<String, List<FangpaishuiPumpoperationrecordVo>> paiMap = fangpaishuiPumpoperationrecordVoPais.stream().collect(Collectors.groupingBy(FangpaishuiPumpoperationrecordVo::getEquipmentName));
Set<Map.Entry<String, List<FangpaishuiPumpoperationrecordVo>>> paiEntries = paiMap.entrySet();
List<FangpaishuiPumpoperationrecordReportVo> fangpaishuiPumpoperationrecordReportVosPai = new ArrayList<>();
for(Map.Entry m : paiEntries){
FangpaishuiPumpoperationrecordReportVo vo = new FangpaishuiPumpoperationrecordReportVo();
vo.setEquipmentName((String) m.getKey());
vo.setFangpaishuiPumpoperationrecordVos((List<FangpaishuiPumpoperationrecordVo>) m.getValue());
int VolumeByMouth =0;
for (FangpaishuiPumpoperationrecordVo fangpaishuiPumpoperationrecordVo : (List<FangpaishuiPumpoperationrecordVo>) m.getValue()) {
VolumeByMouth+=fangpaishuiPumpoperationrecordVo.getVolume();
}
vo.setVolumeByMouth(VolumeByMouth);
fangpaishuiPumpoperationrecordReportVosPai.add(vo);
}
//倒水根据泵站分组
Map<String, List<FangpaishuiPumpoperationrecordVo>> paiMap1 = fangpaishuiPumpoperationrecordVoDao.stream().collect(Collectors.groupingBy(FangpaishuiPumpoperationrecordVo::getEquipmentName));
Set<Map.Entry<String, List<FangpaishuiPumpoperationrecordVo>>> paiEntries1 = paiMap1.entrySet();
List<FangpaishuiPumpoperationrecordReportVo> fangpaishuiPumpoperationrecordReportVosDao = new ArrayList<>();
for(Map.Entry m : paiEntries1){
FangpaishuiPumpoperationrecordReportVo vo = new FangpaishuiPumpoperationrecordReportVo();
vo.setEquipmentName((String) m.getKey());
vo.setFangpaishuiPumpoperationrecordVos((List<FangpaishuiPumpoperationrecordVo>) m.getValue());
int VolumeByMouth =0;
for (FangpaishuiPumpoperationrecordVo fangpaishuiPumpoperationrecordVo : (List<FangpaishuiPumpoperationrecordVo>) m.getValue()) {
VolumeByMouth+=fangpaishuiPumpoperationrecordVo.getVolume();
}
vo.setVolumeByMouth(VolumeByMouth);
fangpaishuiPumpoperationrecordReportVosDao.add( vo);
}
FangpaishuiPumpoperationrecordReportByMonthCountVo fPai = new FangpaishuiPumpoperationrecordReportByMonthCountVo();
fPai.setFangpaishuiPumpoperationrecordReportVos(fangpaishuiPumpoperationrecordReportVosPai);
int VolumeAllByMouth = 0;
for (FangpaishuiPumpoperationrecordReportVo fangpaishuiPumpoperationrecordReportVo : fangpaishuiPumpoperationrecordReportVosPai) {
VolumeAllByMouth+=fangpaishuiPumpoperationrecordReportVo.getVolumeByMouth();
}
fPai.setVolumeAllByMouth(VolumeAllByMouth);
fPai.setType("排水");
fPai.setVolumeAllByYear(findCount("排水",lastDate));
FangpaishuiPumpoperationrecordReportByMonthCountVo fDao = new FangpaishuiPumpoperationrecordReportByMonthCountVo();
fDao.setFangpaishuiPumpoperationrecordReportVos(fangpaishuiPumpoperationrecordReportVosDao);
int VolumeAllByMouth1 = 0;
for (FangpaishuiPumpoperationrecordReportVo fangpaishuiPumpoperationrecordReportVo : fangpaishuiPumpoperationrecordReportVosDao) {
VolumeAllByMouth1+=fangpaishuiPumpoperationrecordReportVo.getVolumeByMouth();
}
fDao.setVolumeAllByMouth(VolumeAllByMouth1);
fDao.setType("倒水");
fDao.setVolumeAllByYear(findCount("倒水",lastDate));
FangpaishuiPumpoperationrecordReportByYearCountVo fangpaishuiPumpoperationrecordReportByYearCountVo = new FangpaishuiPumpoperationrecordReportByYearCountVo();
List<FangpaishuiPumpoperationrecordReportByMonthCountVo> all = new ArrayList<>();
all.add(fDao);
all.add(fPai);
fangpaishuiPumpoperationrecordReportByYearCountVo.setFangpaishuiPumpoperationrecordReportByMonthCountVos(all);
fangpaishuiPumpoperationrecordReportByYearCountVo.setVolumeByMouthCount(fDao.getVolumeAllByMouth()+fPai.getVolumeAllByMouth());
fangpaishuiPumpoperationrecordReportByYearCountVo.setVolumeByYearCount(fDao.getVolumeAllByYear()+fPai.getVolumeAllByYear());
return fangpaishuiPumpoperationrecordReportByYearCountVo;
}
@Override
public int findCount(String type, String lastDate) {
int year = Integer.valueOf(lastDate.substring(0,4)).intValue()-1;
String update =String.valueOf(year)+"-12-26";
return baseMapper.findCount(type,update,lastDate);
}
}

@ -56,6 +56,7 @@ public class UsersServiceImpl extends ServiceImpl<UsersMapper, Users> implements
// 校验密码
if (!MD5.encrypt(password).equals(users.getPassword())) {
// if (passwprd.equals(users.getPassword())) {
// 密码错误增加错误次数
Integer errorCount = users.getErrlogincount() == null ? 0 : users.getErrlogincount();
errorCount++;

@ -0,0 +1,30 @@
package com.jdc.jdcproject.utils;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;
@Component
public class ConstantUtils implements InitializingBean {
@Value("${wx.open.app_id}")
private String appId;
@Value("${wx.open.app_secret}")
private String appSecret;
@Value("${wx.open.redirect_url}")
private String redirectUrl;
public static String WX_OPEN_APP_ID;
public static String WX_OPEN_APP_SECRET;
public static String WX_OPEN_REDIRECT_URL;
@Override
public void afterPropertiesSet() throws Exception {
WX_OPEN_APP_ID = appId;
WX_OPEN_APP_SECRET = appSecret;
WX_OPEN_REDIRECT_URL = redirectUrl;
}
}

@ -0,0 +1,764 @@
package com.jdc.jdcproject.utils;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.SocketTimeoutException;
import java.net.URLEncoder;
import java.security.GeneralSecurityException;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.text.ParseException;
import java.util.*;
import javax.net.ssl.*;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.http.Consts;
import org.apache.http.HttpEntity;
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.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.*;
import org.apache.http.client.utils.HttpClientUtils;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.*;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
public class HttpUtils {
public static final int connTimeout = 10000;
public static final int readTimeout = 10000;
public static final String charset = "UTF-8";
private static HttpClient client = null;
private String url;
private Map<String, String> param;
private int statusCode;
private String content;
private String xmlParam;
private boolean isHttps;
/**
* get
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @return
* @throws Exception
*/
public static HttpResponse doGet(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpGet request = new HttpGet(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
return httpClient.execute(request);
}
/**
* post form
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param bodys
* @return
* @throws Exception
*/
public static HttpResponse doPost(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys,
Map<String, String> bodys)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPost request = new HttpPost(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (bodys != null) {
List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();
for (String key : bodys.keySet()) {
nameValuePairList.add(new BasicNameValuePair(key, bodys.get(key)));
}
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8");
formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8");
request.setEntity(formEntity);
}
return httpClient.execute(request);
}
/**
* Post String
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public static HttpResponse doPost(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys,
String body)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPost request = new HttpPost(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (StringUtils.isNotBlank(body)) {
request.setEntity(new StringEntity(body, "utf-8"));
}
return httpClient.execute(request);
}
/**
* Post stream
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public static HttpResponse doPost(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys,
byte[] body)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPost request = new HttpPost(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (body != null) {
request.setEntity(new ByteArrayEntity(body));
}
return httpClient.execute(request);
}
/**
* Put String
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public static HttpResponse doPut(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys,
String body)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPut request = new HttpPut(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (StringUtils.isNotBlank(body)) {
request.setEntity(new StringEntity(body, "utf-8"));
}
return httpClient.execute(request);
}
/**
* Put stream
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public static HttpResponse doPut(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys,
byte[] body)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPut request = new HttpPut(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (body != null) {
request.setEntity(new ByteArrayEntity(body));
}
return httpClient.execute(request);
}
/**
* Delete
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @return
* @throws Exception
*/
public static HttpResponse doDelete(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpDelete request = new HttpDelete(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
return httpClient.execute(request);
}
private static String buildUrl(String host, String path, Map<String, String> querys) throws UnsupportedEncodingException {
StringBuilder sbUrl = new StringBuilder();
sbUrl.append(host);
if (!StringUtils.isBlank(path)) {
sbUrl.append(path);
}
if (null != querys) {
StringBuilder sbQuery = new StringBuilder();
for (Map.Entry<String, String> query : querys.entrySet()) {
if (0 < sbQuery.length()) {
sbQuery.append("&");
}
if (StringUtils.isBlank(query.getKey()) && !StringUtils.isBlank(query.getValue())) {
sbQuery.append(query.getValue());
}
if (!StringUtils.isBlank(query.getKey())) {
sbQuery.append(query.getKey());
if (!StringUtils.isBlank(query.getValue())) {
sbQuery.append("=");
sbQuery.append(URLEncoder.encode(query.getValue(), "utf-8"));
}
}
}
if (0 < sbQuery.length()) {
sbUrl.append("?").append(sbQuery);
}
}
return sbUrl.toString();
}
private static HttpClient wrapClient(String host) {
HttpClient httpClient = new DefaultHttpClient();
if (host.startsWith("https://")) {
sslClient(httpClient);
}
return httpClient;
}
private static void sslClient(HttpClient httpClient) {
try {
SSLContext ctx = SSLContext.getInstance("TLS");
X509TrustManager tm = new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(X509Certificate[] xcs, String str) {
}
public void checkServerTrusted(X509Certificate[] xcs, String str) {
}
};
ctx.init(null, new TrustManager[]{tm}, null);
SSLSocketFactory ssf = new SSLSocketFactory(ctx);
ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
ClientConnectionManager ccm = httpClient.getConnectionManager();
SchemeRegistry registry = ccm.getSchemeRegistry();
registry.register(new Scheme("https", 443, ssf));
} catch (KeyManagementException ex) {
throw new RuntimeException(ex);
} catch (NoSuchAlgorithmException ex) {
throw new RuntimeException(ex);
}
}
/**======================================================================================================================================*/
/**======================================================================================================================================*/
/**======================================================================================================================================*/
/**======================================================================================================================================*/
/**======================================================================================================================================*/
/**======================================================================================================================================*/
static {
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
cm.setMaxTotal(128);
cm.setDefaultMaxPerRoute(128);
client = HttpClients.custom().setConnectionManager(cm).build();
}
public static String postParameters(String url, String parameterStr) throws ConnectTimeoutException, SocketTimeoutException, Exception {
return post(url, parameterStr, "application/x-www-form-urlencoded", charset, connTimeout, readTimeout);
}
public static String postParameters(String url, String parameterStr, String charset, Integer connTimeout, Integer readTimeout) throws ConnectTimeoutException, SocketTimeoutException, Exception {
return post(url, parameterStr, "application/x-www-form-urlencoded", charset, connTimeout, readTimeout);
}
public static String postParameters(String url, Map<String, String> params) throws ConnectTimeoutException,
SocketTimeoutException, Exception {
return postForm(url, params, null, connTimeout, readTimeout);
}
public static String postParameters(String url, Map<String, String> params, Integer connTimeout, Integer readTimeout) throws ConnectTimeoutException,
SocketTimeoutException, Exception {
return postForm(url, params, null, connTimeout, readTimeout);
}
public static String get(String url) throws Exception {
return get(url, charset, null, null);
}
public static String get(String url, String charset) throws Exception {
return get(url, charset, connTimeout, readTimeout);
}
/**
* 发送一个 Post 请求, 使用指定的字符集编码.
*
* @param url
* @param body RequestBody
* @param mimeType 例如 application/xml "application/x-www-form-urlencoded" a=1&b=2&c=3
* @param charset 编码
* @param connTimeout 建立链接超时时间,毫秒.
* @param readTimeout 响应超时时间,毫秒.
* @return ResponseBody, 使用指定的字符集编码.
* @throws ConnectTimeoutException 建立链接超时异常
* @throws SocketTimeoutException 响应超时
* @throws Exception
*/
public static String post(String url, String body, String mimeType, String charset, Integer connTimeout, Integer readTimeout)
throws ConnectTimeoutException, SocketTimeoutException, Exception {
HttpClient client = null;
HttpPost post = new HttpPost(url);
String result = "";
try {
if (StringUtils.isNotBlank(body)) {
HttpEntity entity = new StringEntity(body, ContentType.create(mimeType, charset));
post.setEntity(entity);
}
// 设置参数
RequestConfig.Builder customReqConf = RequestConfig.custom();
if (connTimeout != null) {
customReqConf.setConnectTimeout(connTimeout);
}
if (readTimeout != null) {
customReqConf.setSocketTimeout(readTimeout);
}
post.setConfig(customReqConf.build());
HttpResponse res;
if (url.startsWith("https")) {
// 执行 Https 请求.
client = createSSLInsecureClient();
res = client.execute(post);
} else {
// 执行 Http 请求.
client = HttpUtils.client;
res = client.execute(post);
}
result = IOUtils.toString(res.getEntity().getContent(), charset);
} finally {
post.releaseConnection();
if (url.startsWith("https") && client != null && client instanceof CloseableHttpClient) {
((CloseableHttpClient) client).close();
}
}
return result;
}
/**
* 提交form表单
*
* @param url
* @param params
* @param connTimeout
* @param readTimeout
* @return
* @throws ConnectTimeoutException
* @throws SocketTimeoutException
* @throws Exception
*/
public static String postForm(String url, Map<String, String> params, Map<String, String> headers, Integer connTimeout, Integer readTimeout) throws ConnectTimeoutException,
SocketTimeoutException, Exception {
HttpClient client = null;
HttpPost post = new HttpPost(url);
try {
if (params != null && !params.isEmpty()) {
List<NameValuePair> formParams = new ArrayList<NameValuePair>();
Set<Map.Entry<String, String>> entrySet = params.entrySet();
for (Map.Entry<String, String> entry : entrySet) {
formParams.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
}
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formParams, Consts.UTF_8);
post.setEntity(entity);
}
if (headers != null && !headers.isEmpty()) {
for (Map.Entry<String, String> entry : headers.entrySet()) {
post.addHeader(entry.getKey(), entry.getValue());
}
}
// 设置参数
RequestConfig.Builder customReqConf = RequestConfig.custom();
if (connTimeout != null) {
customReqConf.setConnectTimeout(connTimeout);
}
if (readTimeout != null) {
customReqConf.setSocketTimeout(readTimeout);
}
post.setConfig(customReqConf.build());
HttpResponse res = null;
if (url.startsWith("https")) {
// 执行 Https 请求.
client = createSSLInsecureClient();
res = client.execute(post);
} else {
// 执行 Http 请求.
client = HttpUtils.client;
res = client.execute(post);
}
return IOUtils.toString(res.getEntity().getContent(), "UTF-8");
} finally {
post.releaseConnection();
if (url.startsWith("https") && client != null
&& client instanceof CloseableHttpClient) {
((CloseableHttpClient) client).close();
}
}
}
/**
* 发送一个 GET 请求
*
* @param url
* @param charset
* @param connTimeout 建立链接超时时间,毫秒.
* @param readTimeout 响应超时时间,毫秒.
* @return
* @throws ConnectTimeoutException 建立链接超时
* @throws SocketTimeoutException 响应超时
* @throws Exception
*/
public static String get(String url, String charset, Integer connTimeout, Integer readTimeout)
throws ConnectTimeoutException, SocketTimeoutException, Exception {
HttpClient client = null;
HttpGet get = new HttpGet(url);
String result = "";
try {
// 设置参数
RequestConfig.Builder customReqConf = RequestConfig.custom();
if (connTimeout != null) {
customReqConf.setConnectTimeout(connTimeout);
}
if (readTimeout != null) {
customReqConf.setSocketTimeout(readTimeout);
}
get.setConfig(customReqConf.build());
HttpResponse res = null;
if (url.startsWith("https")) {
// 执行 Https 请求.
client = createSSLInsecureClient();
res = client.execute(get);
} else {
// 执行 Http 请求.
client = HttpUtils.client;
res = client.execute(get);
}
result = IOUtils.toString(res.getEntity().getContent(), charset);
} finally {
get.releaseConnection();
if (url.startsWith("https") && client != null && client instanceof CloseableHttpClient) {
((CloseableHttpClient) client).close();
}
}
return result;
}
/**
* response 里获取 charset
*
* @param ressponse
* @return
*/
@SuppressWarnings("unused")
private static String getCharsetFromResponse(HttpResponse ressponse) {
// Content-Type:text/html; charset=GBK
if (ressponse.getEntity() != null && ressponse.getEntity().getContentType() != null && ressponse.getEntity().getContentType().getValue() != null) {
String contentType = ressponse.getEntity().getContentType().getValue();
if (contentType.contains("charset=")) {
return contentType.substring(contentType.indexOf("charset=") + 8);
}
}
return null;
}
/**
* 创建 SSL连接
*
* @return
* @throws GeneralSecurityException
*/
private static CloseableHttpClient createSSLInsecureClient() throws GeneralSecurityException {
try {
SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() {
public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
return true;
}
}).build();
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, new X509HostnameVerifier() {
@Override
public boolean verify(String arg0, SSLSession arg1) {
return true;
}
@Override
public void verify(String host, SSLSocket ssl)
throws IOException {
}
@Override
public void verify(String host, X509Certificate cert)
throws SSLException {
}
@Override
public void verify(String host, String[] cns,
String[] subjectAlts) throws SSLException {
}
});
return HttpClients.custom().setSSLSocketFactory(sslsf).build();
} catch (GeneralSecurityException e) {
throw e;
}
}
public static void main(String[] args) {
try {
String str = post("https://localhost:443/ssl/test.shtml", "name=12&page=34", "application/x-www-form-urlencoded", "UTF-8", 10000, 10000);
//String str= get("https://localhost:443/ssl/test.shtml?name=12&page=34","GBK");
/*Map<String,String> map = new HashMap<String,String>();
map.put("name", "111");
map.put("page", "222");
String str= postForm("https://localhost:443/ssl/test.shtml",map,null, 10000, 10000);*/
System.out.println(str);
} catch (ConnectTimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SocketTimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**======================================================================================================================================*/
/**======================================================================================================================================*/
/**======================================================================================================================================*/
/**======================================================================================================================================*/
/**======================================================================================================================================*/
/**======================================================================================================================================*/
public boolean isHttps() {
return isHttps;
}
public void setHttps(boolean isHttps) {
this.isHttps = isHttps;
}
public String getXmlParam() {
return xmlParam;
}
public void setXmlParam(String xmlParam) {
this.xmlParam = xmlParam;
}
public HttpUtils(String url, Map<String, String> param) {
this.url = url;
this.param = param;
}
public HttpUtils(String url) {
this.url = url;
}
public void setParameter(Map<String, String> map) {
param = map;
}
public void addParameter(String key, String value) {
if (param == null)
param = new HashMap<String, String>();
param.put(key, value);
}
public void post() throws ClientProtocolException, IOException {
HttpPost http = new HttpPost(url);
setEntity(http);
execute(http);
}
public void put() throws ClientProtocolException, IOException {
HttpPut http = new HttpPut(url);
setEntity(http);
execute(http);
}
public void get() throws ClientProtocolException, IOException {
if (param != null) {
StringBuilder url = new StringBuilder(this.url);
boolean isFirst = true;
for (String key : param.keySet()) {
if (isFirst)
url.append("?");
else
url.append("&");
url.append(key).append("=").append(param.get(key));
}
this.url = url.toString();
}
HttpGet http = new HttpGet(url);
execute(http);
}
/**
* set http post,put param
*/
private void setEntity(HttpEntityEnclosingRequestBase http) {
if (param != null) {
List<NameValuePair> nvps = new LinkedList<NameValuePair>();
for (String key : param.keySet())
nvps.add(new BasicNameValuePair(key, param.get(key))); // 参数
http.setEntity(new UrlEncodedFormEntity(nvps, Consts.UTF_8)); // 设置参数
}
if (xmlParam != null) {
http.setEntity(new StringEntity(xmlParam, Consts.UTF_8));
}
}
private void execute(HttpUriRequest http) throws ClientProtocolException,
IOException {
CloseableHttpClient httpClient = null;
try {
if (isHttps) {
SSLContext sslContext = new SSLContextBuilder()
.loadTrustMaterial(null, new TrustStrategy() {
// 信任所有
public boolean isTrusted(X509Certificate[] chain,
String authType)
throws CertificateException {
return true;
}
}).build();
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
sslContext);
httpClient = HttpClients.custom().setSSLSocketFactory(sslsf)
.build();
} else {
httpClient = HttpClients.createDefault();
}
CloseableHttpResponse response = httpClient.execute(http);
try {
if (response != null) {
if (response.getStatusLine() != null)
statusCode = response.getStatusLine().getStatusCode();
HttpEntity entity = response.getEntity();
// 响应内容
content = EntityUtils.toString(entity, Consts.UTF_8);
}
} finally {
response.close();
}
} catch (Exception e) {
e.printStackTrace();
} finally {
httpClient.close();
}
}
public int getStatusCode() {
return statusCode;
}
public String getContent() throws ParseException, IOException {
return content;
}
}

@ -30,7 +30,7 @@ public final class MD5 {
}
public static void main(String[] args) {
System.out.println(MD5.encrypt("111111"));
System.out.println(MD5.encrypt("123456789"));
}
}

@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: com.jdc.jdcproject.JdcProjectApplication

@ -18,3 +18,8 @@ server:
springdoc:
swagger-ui:
path: /swagger-ui.html
wx:
open:
app_id:
app_secret:
redirect_url: http://localhost:8000/

@ -0,0 +1,16 @@
package com.jdc.jdcproject;
import com.alibaba.excel.EasyExcel;
public class EasyexcelReader {
public static void main(String[] args) {
String fileName = "D:\\ProgramFiles\\project\\JdcProject\\src\\test\\test.xlsx";
EasyExcel.read(fileName, new ExcelListener(data->{
}))// 从第3行开始是数据
.sheet()
.doRead();
}
}

@ -0,0 +1,23 @@
package com.jdc.jdcproject;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import java.util.Map;
public class ExcelListener extends AnalysisEventListener<Map<String, Object>> {
@Override
public void invoke(Map<String,Object> data, AnalysisContext context) {
System.out.println("读取到数据:" + data);
}
@Override
public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
System.out.println("表头:" + headMap);
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
System.out.println("所有数据读取完成");
}
}

@ -0,0 +1,41 @@
package com.jdc.jdcproject;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
@Data
public class MineWorkEntity {
@ExcelProperty(value = "日期",index = 0)
private String date;
@ExcelProperty(value = "白班", index = 1)
private String dayShift;
@ExcelProperty(value = "大厂要矿时间",index = 2)
private String dayRequestTime;
@ExcelProperty(value = "下去时间",index = 3)
private String dayDownTime;
@ExcelProperty(value = "11节列数",index = 4)
private String day11Count;
@ExcelProperty(value = "夜班",index = 5)
private String nightShift;
@ExcelProperty(value = "大厂要矿时间",index = 6)
private String nightRequestTime;
@ExcelProperty(value = "下去时间",index = 7)
private String nightDownTime;
@ExcelProperty(value = "11节列数",index = 8)
private String night11Count;
@ExcelProperty(value = "夜班早晨7点以后下",index = 9)
private String nightAfter7;
@ExcelProperty(value = "白班早晨8点以后回来",index = 10)
private String dayAfter8Return;
}

@ -0,0 +1,21 @@
package com.jdc.jdcproject;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
@Data
public class Testexcel {
@ExcelProperty("姓名")
private String name;
@ExcelProperty("年龄")
private String age;
@ExcelProperty("性别")
private String sex;
@ExcelProperty("备注")
private String beizhu;
}

BIN
src/test/test.xlsx Normal file

Binary file not shown.

Binary file not shown.