mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 11:35:12 +08:00
commit
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package com.jsowell;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
|
||||
/**
|
||||
* 启动程序
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
|
||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
|
||||
public class JsowellApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// System.setProperty("spring.devtools.restart.enabled", "false");
|
||||
SpringApplication.run(JsowellApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.jsowell;
|
||||
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
|
||||
/**
|
||||
* web容器中进行部署
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class JsowellServletInitializer extends SpringBootServletInitializer {
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||
return application.sources(JsowellApplication.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.jsowell.api.uniapp;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.jsowell.common.annotation.Anonymous;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.response.RestApiResponse;
|
||||
import com.jsowell.pile.vo.uniapp.PileConnectorVO;
|
||||
import com.jsowell.service.PileService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@Anonymous
|
||||
@RestController
|
||||
@RequestMapping("/app-xcx-h5")
|
||||
public class JumpController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private PileService pileService;
|
||||
|
||||
/**
|
||||
* 查询充电桩详情
|
||||
* http://localhost:8080/app-xcx-h5/pile/pileDetail/{pileSn}
|
||||
*/
|
||||
@GetMapping("/pile/pileDetail/{pileSn}")
|
||||
public RestApiResponse<?> getPileDetail(HttpServletRequest request, @PathVariable("pileSn") String pileSn) {
|
||||
logger.info("app-xcx-h5查询充电桩详情 param:{}", pileSn);
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
PileConnectorVO vo = pileService.getPileDetailByPileSn(pileSn);
|
||||
response = new RestApiResponse<>(vo);
|
||||
} catch (BusinessException e) {
|
||||
logger.warn("app-xcx-h5查询充电桩详情 warn", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("app-xcx-h5查询充电桩详情 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_PILE_DETAIL_ERROR);
|
||||
}
|
||||
logger.info("app-xcx-h5查询充电桩详情 result:{}", JSONObject.toJSONString(response));
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询充电枪口详情
|
||||
* http://localhost:8080/app-xcx-h5/pile/connectorDetail/{pileConnectorCode}
|
||||
*/
|
||||
@GetMapping("/pile/connectorDetail/{pileConnectorCode}")
|
||||
public RestApiResponse<?> getConnectorDetail(HttpServletRequest request, @PathVariable("pileConnectorCode") String pileConnectorCode) {
|
||||
logger.info("app-xcx-h5查询充电枪口详情 param:{}", pileConnectorCode);
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
PileConnectorVO vo = pileService.getConnectorDetail(pileConnectorCode);
|
||||
response = new RestApiResponse<>(vo);
|
||||
} catch (BusinessException e) {
|
||||
logger.warn("app-xcx-h5查询充电枪口详情 warn", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("app-xcx-h5查询充电枪口详情 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_PILE_DETAIL_ERROR);
|
||||
}
|
||||
logger.info("app-xcx-h5查询充电枪口详情 result:{}", JSONObject.toJSONString(response));
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
package com.jsowell.api.uniapp;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.jsowell.common.annotation.Anonymous;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.page.PageResponse;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.exception.ServiceException;
|
||||
import com.jsowell.common.response.RestApiResponse;
|
||||
import com.jsowell.common.util.SMSUtil;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.dto.MemberRegisterAndLoginDTO;
|
||||
import com.jsowell.pile.dto.MemberRegisterDTO;
|
||||
import com.jsowell.pile.dto.UniAppQueryMemberBalanceDTO;
|
||||
import com.jsowell.pile.dto.WechatLoginDTO;
|
||||
import com.jsowell.pile.dto.WeixinPayDTO;
|
||||
import com.jsowell.pile.vo.uniapp.MemberVO;
|
||||
import com.jsowell.service.MemberService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 小程序接口
|
||||
*/
|
||||
// 不登录直接访问
|
||||
@Anonymous
|
||||
@RestController
|
||||
@RequestMapping("/uniapp/member")
|
||||
public class MemberController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private MemberService memberService;
|
||||
|
||||
/**
|
||||
* 下发短信接口 business
|
||||
* http://localhost:8080/uniapp/member/sendSMS
|
||||
*/
|
||||
@PostMapping("/sendSMS")
|
||||
public RestApiResponse<?> sendSMS(HttpServletRequest request, @RequestBody MemberRegisterAndLoginDTO dto) {
|
||||
logger.info("下发短信接口 param:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
if (StringUtils.isBlank(dto.getMobileNumber())) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
String sendSMSResult = SMSUtil.sendSMS(request, dto.getMobileNumber());
|
||||
response = new RestApiResponse<>(sendSMSResult);
|
||||
} catch (Exception e) {
|
||||
logger.error("下发短信接口 发生异常 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_SEND_SMS_ERROR);
|
||||
}
|
||||
logger.info("下发短信接口 result:{}", JSONObject.toJSONString(response));
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 会员登录注册
|
||||
* 登录成功,返回memberToken
|
||||
* http://localhost:8080/uniapp/member/memberRegisterAndLogin
|
||||
*/
|
||||
@PostMapping("/memberRegisterAndLogin")
|
||||
public RestApiResponse<?> memberRegisterAndLogin(HttpServletRequest request, @RequestBody MemberRegisterAndLoginDTO dto) {
|
||||
logger.info("会员登录注册接口 param:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
// 执行登录(查这个手机号在后台有没有数据,如果没有就静默注册)
|
||||
String memberToken = memberService.memberRegisterAndLogin(dto);
|
||||
|
||||
// 返回前端成功
|
||||
Map<String, String> map = Maps.newHashMap();
|
||||
map.put("memberToken", memberToken);
|
||||
response = new RestApiResponse<>(map);
|
||||
} catch (ServiceException e) {
|
||||
logger.warn("会员登录注册接口 warn", e);
|
||||
response = new RestApiResponse<>(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("会员登录注册接口 发生异常 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_MEMBER_REGISTER_AND_LOGIN_ERROR);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信一键登录
|
||||
* http://localhost:8080/uniapp/member/wechatLogin
|
||||
*/
|
||||
@PostMapping("/wechatLogin")
|
||||
public RestApiResponse<?> wechatLogin(@RequestBody WechatLoginDTO dto) {
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String memberToken = memberService.wechatLogin(dto);
|
||||
response = new RestApiResponse<>(ImmutableMap.of("memberToken", memberToken));
|
||||
} catch (Exception e) {
|
||||
logger.error("微信登录异常", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_WECHAT_LOGIN_ERROR);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收并处理前端用户信息
|
||||
*
|
||||
* http://localhost:8080/uniapp/member/saveUserInfo
|
||||
*/
|
||||
@PostMapping("/saveUserInfo")
|
||||
public RestApiResponse<?> saveUserInfo(@RequestBody MemberRegisterDTO dto) {
|
||||
logger.info("接受前端用户信息并处理 param:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
memberService.handleUserInfo(dto);
|
||||
response = new RestApiResponse<>();
|
||||
} catch (Exception e) {
|
||||
logger.error("处理用户信息异常", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_HANDLE_USER_INFO_ERROR);
|
||||
}
|
||||
logger.info("接受前端用户信息并处理 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户账户信息
|
||||
*
|
||||
* http://localhost:8080/uniapp/member/getMemberInfo
|
||||
* @return 用户账户信息
|
||||
*/
|
||||
@GetMapping("/getMemberInfo")
|
||||
public RestApiResponse<?> getMemberInfo(HttpServletRequest request) {
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
logger.info("查询账户总余额 param memberId:{}", memberId);
|
||||
MemberVO memberVO = memberService.getMemberInfoByMemberId(memberId);
|
||||
response = new RestApiResponse<>(memberVO);
|
||||
}catch (BusinessException e) {
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
}catch (Exception e) {
|
||||
logger.error("查询用户账户总余额异常", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_MEMBER_ACCOUNT_AMOUNT_ERROR);
|
||||
}
|
||||
logger.info("查询用户账户信息 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取openId
|
||||
* http://localhost:8080/uniapp/member/getOpenId
|
||||
*/
|
||||
@PostMapping("/getOpenId")
|
||||
public RestApiResponse<?> getOpenId(HttpServletRequest request, @RequestBody WeixinPayDTO dto) {
|
||||
logger.info("获取openId param:{}", dto.toString());
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
getMemberIdByAuthorization(request);
|
||||
String openId = memberService.getOpenIdByCode(dto.getCode());
|
||||
response = new RestApiResponse<>(ImmutableMap.of("openId", openId));
|
||||
} catch (Exception e) {
|
||||
logger.error("获取openId error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_OPEN_ID_BY_CODE_ERROR);
|
||||
}
|
||||
logger.info("获取openId result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户账户余额变动信息
|
||||
* http://localhost:8080/uniapp/member/getMemberBalanceChanges
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getMemberBalanceChanges")
|
||||
public RestApiResponse<?> getMemberBalanceChanges(HttpServletRequest request, @RequestBody UniAppQueryMemberBalanceDTO dto) {
|
||||
logger.info("查询用户账户余额变动信息 params:{}", dto.toString() );
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
dto.setMemberId(memberId);
|
||||
PageResponse pageResponse = memberService.getMemberBalanceChanges(dto);
|
||||
response = new RestApiResponse<>(pageResponse);
|
||||
} catch (Exception e) {
|
||||
logger.error("查询用户账户余额变动信息 error:", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_BALANCE_CHANGES_ERROR);
|
||||
}
|
||||
logger.info("查询用户账户余额变动信息 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,244 @@
|
||||
package com.jsowell.api.uniapp;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.jsowell.common.annotation.Anonymous;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.page.PageResponse;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.response.RestApiResponse;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.dto.GenerateOrderDTO;
|
||||
import com.jsowell.pile.dto.QueryOrderDTO;
|
||||
import com.jsowell.pile.dto.SettleOrderDTO;
|
||||
import com.jsowell.pile.dto.StopChargingDTO;
|
||||
import com.jsowell.pile.dto.UniAppQueryOrderDTO;
|
||||
import com.jsowell.pile.vo.uniapp.UniAppOrderVO;
|
||||
import com.jsowell.service.OrderService;
|
||||
import com.jsowell.service.PileRemoteService;
|
||||
import com.jsowell.wxpay.dto.WechatSendMsgDTO;
|
||||
import com.jsowell.wxpay.service.WxAppletRemoteService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 订单相关接口
|
||||
* 提供给小程序
|
||||
*/
|
||||
@Anonymous
|
||||
@RestController
|
||||
@RequestMapping("/uniapp/order")
|
||||
public class OrderController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
|
||||
@Autowired
|
||||
private PileRemoteService pileRemoteService;
|
||||
|
||||
@Autowired
|
||||
private WxAppletRemoteService wxAppletRemoteService;
|
||||
|
||||
/**
|
||||
* 生成订单
|
||||
* http://localhost:8080/uniapp/order/generateOrder
|
||||
*/
|
||||
@PostMapping("/generateOrder")
|
||||
public RestApiResponse<?> generateOrder(HttpServletRequest request, @RequestBody GenerateOrderDTO dto) {
|
||||
logger.info("生成订单 param:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
if ((StringUtils.isBlank(dto.getPileSn()) || StringUtils.isBlank(dto.getConnectorCode())) && StringUtils.isBlank(dto.getPileConnectorCode())) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
if (StringUtils.isEmpty(memberId)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_TOKEN_ERROR);
|
||||
}
|
||||
dto.setMemberId(memberId);
|
||||
// 生成订单
|
||||
dto.setStartMode(Constants.ONE); // 启动方式 1-app启动
|
||||
String orderCode = orderService.generateOrder(dto);
|
||||
response = new RestApiResponse<>(ImmutableMap.of("orderCode", orderCode));
|
||||
} catch (BusinessException e) {
|
||||
logger.warn("生成订单 warn", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("生成订单 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GENERATE_ORDER_ERROR);
|
||||
}
|
||||
logger.info("生成订单 result:{}", JSONObject.toJSONString(response));
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止充电
|
||||
* http://localhost:8080/uniapp/order/stopCharging
|
||||
*/
|
||||
@PostMapping ("/stopCharging")
|
||||
public RestApiResponse<?> stopCharging(HttpServletRequest request, @RequestBody StopChargingDTO dto) {
|
||||
logger.info("停止充电 param:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
if (StringUtils.isEmpty(memberId)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_TOKEN_ERROR);
|
||||
}
|
||||
dto.setMemberId(memberId);
|
||||
orderService.stopCharging(dto);
|
||||
response = new RestApiResponse<>();
|
||||
} catch (BusinessException e) {
|
||||
logger.warn("停止充电 warn", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("停止充电 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_STOP_CHARGING_ERROR);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 结算订单
|
||||
* http://localhost:8080/uniapp/order/settleOrder
|
||||
* @param dto 结算订单DTO
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/settleOrderForWeb")
|
||||
public RestApiResponse<?> settleOrder(HttpServletRequest request, @RequestBody SettleOrderDTO dto) {
|
||||
logger.info("结算订单 param:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
orderService.settleOrderForWeb(dto);
|
||||
response = new RestApiResponse<>();
|
||||
} catch (Exception e) {
|
||||
logger.error("结算订单错误", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_SETTLE_ORDER_ERROR);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单信息
|
||||
* http://localhost:8080/uniapp/order/getOrderList
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getOrderList")
|
||||
public RestApiResponse<?> getOrderInfo(HttpServletRequest request, @RequestBody UniAppQueryOrderDTO dto) {
|
||||
logger.info("查询订单信息 param:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
if (StringUtils.isBlank(memberId)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
// 通过memberId查询某状态订单列表
|
||||
PageResponse pageInfoList = orderService.getListByMemberIdAndOrderStatus(memberId, dto);
|
||||
response = new RestApiResponse<>(pageInfoList);
|
||||
} catch (BusinessException e) {
|
||||
logger.warn("查询订单信息 warn", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("查询订单信息 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_ORDER_INFO_BY_MEMBER_ID_ERROR);
|
||||
}
|
||||
logger.info("查询订单信息, result:{}", JSONObject.toJSONString(response));
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序获取订单详情
|
||||
* http://localhost:8080/uniapp/order/getOrderDetail
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getOrderDetail")
|
||||
public RestApiResponse<?> getOrderDetail(HttpServletRequest request, @RequestBody UniAppQueryOrderDTO dto) {
|
||||
logger.info("小程序获取订单详情 param:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
if (StringUtils.isBlank(memberId)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
UniAppOrderVO uniAppOrderDetail = orderService.getUniAppOrderDetail(dto.getOrderCode());
|
||||
response = new RestApiResponse<>(uniAppOrderDetail);
|
||||
} catch (BusinessException e) {
|
||||
logger.warn("小程序获取订单详情 warn", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("小程序获取订单详情 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_ORDER_DETAIL_ERROR);
|
||||
}
|
||||
logger.info("小程序获取订单详情, result:{}", JSONObject.toJSONString(response));
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据订单号查询充电桩启动状态
|
||||
* http://localhost:8080/uniapp/order/selectPileStarterStatus
|
||||
*/
|
||||
@PostMapping("/selectPileStarterStatus")
|
||||
public RestApiResponse<?> selectPileStarterStatus(HttpServletRequest request, @RequestBody UniAppQueryOrderDTO dto) {
|
||||
logger.info("根据订单号查询充电桩启动状态 param:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
// String memberId = getMemberIdByAuthorization(request);
|
||||
String status = orderService.selectPileStarterStatus(dto.getOrderCode());
|
||||
response = new RestApiResponse<>(ImmutableMap.of("status", status));
|
||||
} catch (Exception e) {
|
||||
logger.error("根据订单号查询充电桩启动状态 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_ORDER_DETAIL_ERROR);
|
||||
}
|
||||
logger.info("根据订单号查询充电桩启动状态 result:{}", JSONObject.toJSONString(response));
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信小程序发送启动充电推送消息
|
||||
* http://localhost:8080/uniapp/order/uniAppStartChargingSendMsg
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/uniAppStartChargingSendMsg")
|
||||
public RestApiResponse<?> uniAppStartChargingSendMsg(@RequestBody WechatSendMsgDTO dto) {
|
||||
logger.info("微信小程序发送启动充电推送消息 param:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
Map<String, String> resultMap = wxAppletRemoteService.startChargingSendMsg(dto);
|
||||
response = new RestApiResponse<>(resultMap);
|
||||
} catch (Exception e){
|
||||
logger.error("微信小程序发送启动充电推送消息 error", e);
|
||||
response = new RestApiResponse<>("00300001", "微信小程序发送启动充电推送消息异常");
|
||||
}
|
||||
logger.info("微信小程序发送启动充电推送消息 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭支付未启动的订单
|
||||
* http://localhost:8080/uniapp/order/closeStartFailedOrder
|
||||
*/
|
||||
@PostMapping("/closeStartFailedOrder")
|
||||
public RestApiResponse<?> closeStartFailedOrder(@RequestBody QueryOrderDTO dto) {
|
||||
logger.info("关闭支付未启动的订单 param:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
orderService.closeStartFailedOrder(dto);
|
||||
response = new RestApiResponse<>();
|
||||
} catch (Exception e){
|
||||
logger.error("关闭支付未启动的订单 error", e);
|
||||
response = new RestApiResponse<>("00300002", "关闭支付未启动的订单异常");
|
||||
}
|
||||
logger.info("关闭支付未启动的订单 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
package com.jsowell.api.uniapp;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.jsowell.common.annotation.Anonymous;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.enums.ykc.ScenarioEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.response.RestApiResponse;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.id.IdUtils;
|
||||
import com.jsowell.pile.dto.PayOrderDTO;
|
||||
import com.jsowell.pile.dto.PaymentScenarioDTO;
|
||||
import com.jsowell.pile.dto.WeixinPayDTO;
|
||||
import com.jsowell.service.MemberService;
|
||||
import com.jsowell.service.OrderService;
|
||||
import com.jsowell.wxpay.dto.WeChatRefundDTO;
|
||||
import com.jsowell.wxpay.response.WechatPayNotifyParameter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 支付相关controller
|
||||
*/
|
||||
@Anonymous
|
||||
@RestController
|
||||
@RequestMapping("/uniapp/pay")
|
||||
public class PayController extends BaseController {
|
||||
@Autowired
|
||||
private MemberService memberService;
|
||||
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
/**
|
||||
* 充值余额支付
|
||||
* 提供给小程序使用
|
||||
* http://localhost:8080/uniapp/pay/weixinPay
|
||||
*/
|
||||
@PostMapping("/weixinPay")
|
||||
public RestApiResponse<?> weixinPay(HttpServletRequest request, @RequestBody WeixinPayDTO dto) {
|
||||
logger.info("微信支付 param:{}", dto.toString());
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
if (StringUtils.isBlank(dto.getCode()) || StringUtils.isBlank(dto.getAmount())) {
|
||||
return new RestApiResponse<>(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
// 鉴权
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
if (StringUtils.isBlank(memberId)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_TOKEN_ERROR);
|
||||
}
|
||||
dto.setMemberId(memberId);
|
||||
String openId = memberService.getOpenIdByCode(dto.getCode());
|
||||
if (StringUtils.isBlank(openId)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_GET_OPEN_ID_BY_CODE_ERROR);
|
||||
}
|
||||
dto.setOpenId(openId);
|
||||
// 充值余额 附加参数
|
||||
PaymentScenarioDTO paymentScenarioDTO = new PaymentScenarioDTO();
|
||||
paymentScenarioDTO.setType(ScenarioEnum.BALANCE.getValue());
|
||||
paymentScenarioDTO.setMemberId(memberId);
|
||||
dto.setAttach(JSONObject.toJSONString(paymentScenarioDTO));
|
||||
dto.setDescription("会员充值余额");
|
||||
Map<String, Object> weixinMap = orderService.weixinPayV3(dto);
|
||||
response = new RestApiResponse<>(ImmutableMap.of("weixinMap", weixinMap));
|
||||
} catch (Exception e) {
|
||||
response = new RestApiResponse<>();
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付订单
|
||||
* http://localhost:8080/uniapp/pay/payOrder
|
||||
*
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/payOrder")
|
||||
public RestApiResponse<?> payOrder(HttpServletRequest request, @RequestBody PayOrderDTO dto) {
|
||||
logger.info("支付订单 param:{}", dto.toString());
|
||||
RestApiResponse<?> response;
|
||||
|
||||
// 支付订单加锁
|
||||
String lockKey = "pay_order_" + dto.getOrderCode();
|
||||
String lockValue = IdUtils.fastUUID();
|
||||
try {
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
if (StringUtils.isBlank(memberId)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_TOKEN_ERROR);
|
||||
}
|
||||
dto.setMemberId(memberId);
|
||||
dto.setLockValue(lockValue);
|
||||
// redis锁
|
||||
Boolean isLock = redisCache.lock(lockKey, lockValue, 60);
|
||||
Map<String, Object> map = null;
|
||||
if (isLock) {
|
||||
map = orderService.payOrder(dto);
|
||||
}
|
||||
// Map<String, Object> map = orderService.payOrder(dto);
|
||||
response = new RestApiResponse<>(map);
|
||||
} catch (BusinessException e) {
|
||||
logger.warn("支付订单 warn", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("支付订单 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_ORDER_PAY_ERROR);
|
||||
} finally {
|
||||
// 支付订单解锁
|
||||
if (lockValue.equals(redisCache.getCacheObject(lockKey).toString())) {
|
||||
redisCache.unLock(lockKey);
|
||||
}
|
||||
}
|
||||
logger.info("支付订单 result:{}", JSONObject.toJSONString(response));
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信支付回调接口
|
||||
* http://localhost:8080/uniapp/pay/callback
|
||||
* https://api.jsowellcloud.com/uniapp/pay/wechatPayCallback
|
||||
*/
|
||||
@PostMapping("/wechatPayCallback")
|
||||
public RestApiResponse<?> wechatPayCallback(HttpServletRequest request, @RequestBody WechatPayNotifyParameter body) {
|
||||
logger.info("1----------->微信支付回调开始 body:{}", JSONObject.toJSONString(body));
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
orderService.wechatPayCallback(request, body);
|
||||
response = new RestApiResponse<>();
|
||||
} catch (BusinessException e) {
|
||||
logger.warn("微信支付回调接口warn", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("微信支付回调接口error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_ORDER_PAY_CALLBACK_ERROR);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信退款回调接口
|
||||
* @param request
|
||||
* @param body
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/wechatPayRefundCallback")
|
||||
public RestApiResponse<?> wechatPayRefundCallback(HttpServletRequest request, @RequestBody WechatPayNotifyParameter body) {
|
||||
logger.info("微信退款回调接口 body:{}", JSONObject.toJSONString(body));
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
orderService.wechatPayRefundCallback(request, body);
|
||||
response = new RestApiResponse<>();
|
||||
} catch (BusinessException e) {
|
||||
logger.warn("微信退款回调接口warn", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("微信退款回调接口error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_ORDER_PAY_CALLBACK_ERROR);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信退款接口
|
||||
* https://api.jsowellcloud.com/uniapp/pay/refund
|
||||
*/
|
||||
@PostMapping("/refund")
|
||||
public RestApiResponse<?> weChatRefund(HttpServletRequest request, @RequestBody WeChatRefundDTO dto) {
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
if (dto.getRefundAmount() == null) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
if (StringUtils.isBlank(memberId)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_TOKEN_ERROR);
|
||||
}
|
||||
dto.setMemberId(memberId);
|
||||
dto.setRefundType("2");
|
||||
orderService.weChatRefund(dto);
|
||||
response = new RestApiResponse<>();
|
||||
} catch (BusinessException e) {
|
||||
logger.warn("微信退款接口 warn", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("微信退款接口 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_WEIXIN_REFUND_ERROR);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
package com.jsowell.api.uniapp;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.jsowell.common.annotation.Anonymous;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.page.PageResponse;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.response.RestApiResponse;
|
||||
import com.jsowell.pile.dto.PileMemberBindingDTO;
|
||||
import com.jsowell.pile.dto.QueryPersonPileDTO;
|
||||
import com.jsowell.pile.service.IPileBasicInfoService;
|
||||
import com.jsowell.pile.service.IPileMemberRelationService;
|
||||
import com.jsowell.pile.vo.uniapp.OrderVO;
|
||||
import com.jsowell.pile.vo.uniapp.PersonPileConnectorSumInfoVO;
|
||||
import com.jsowell.pile.vo.uniapp.PersonPileRealTimeVO;
|
||||
import com.jsowell.pile.vo.uniapp.PersonalPileInfoVO;
|
||||
import com.jsowell.service.PileService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 个人桩controller
|
||||
*
|
||||
* @author JS-ZZA
|
||||
* @date 2023/2/23 15:36
|
||||
*/
|
||||
@Anonymous
|
||||
@RestController
|
||||
@RequestMapping("/uniapp/personalPile")
|
||||
public class PersonPileController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IPileMemberRelationService pileMemberRelationService;
|
||||
|
||||
@Autowired
|
||||
private PileService pileService;
|
||||
|
||||
@Autowired
|
||||
private IPileBasicInfoService pileBasicInfoService;
|
||||
|
||||
/**
|
||||
* 用户绑定个人桩
|
||||
*
|
||||
* http://localhost:8080/uniapp/personalPile/pileMemberBinding
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/pileMemberBinding")
|
||||
public RestApiResponse<?> pileMemberBinding(HttpServletRequest request, @RequestBody PileMemberBindingDTO dto){
|
||||
logger.info("绑定个人桩信息 params:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
dto.setMemberId(memberId);
|
||||
int i = pileService.pileMemberBinding(dto);
|
||||
response = new RestApiResponse<>(i);
|
||||
}catch (BusinessException e){
|
||||
logger.error("绑定个人桩信息 error,", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
}catch (Exception exception){
|
||||
logger.error("绑定个人桩信息 error,", exception);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_BINDING_PERSONAL_PILE_ERROR);
|
||||
}
|
||||
logger.info("绑定个人桩信息 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 个人桩管理员下发给其他用户
|
||||
*
|
||||
* http://localhost:8080/uniapp/personalPile/adminIssuePile
|
||||
*
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/adminIssuePile")
|
||||
public RestApiResponse<?> adminIssuePile(HttpServletRequest request, @RequestBody PileMemberBindingDTO dto){
|
||||
logger.info("桩管理员下发个人桩 params: {}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
dto.setMemberId(memberId);
|
||||
pileService.adminIssuePile(dto);
|
||||
response = new RestApiResponse<>();
|
||||
}catch (BusinessException e) {
|
||||
logger.error("桩管理员下发个人桩 error", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
}catch (Exception e){
|
||||
logger.error("桩管理员下发个人桩 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_ADMIN_ISSUE_ERROR);
|
||||
}
|
||||
logger.info("桩管理员下发个人桩 result: {}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过memberId查个人桩列表
|
||||
*
|
||||
* http://localhost:8080/uniapp/personalPile/getPersonalPileList
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getPersonalPileList")
|
||||
public RestApiResponse<?> getPersonalPileList(HttpServletRequest request){
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
logger.info("通过memberId查个人桩列表 params: {}", memberId);
|
||||
List<PersonalPileInfoVO> list = pileBasicInfoService.getPileInfoByMemberId(memberId);
|
||||
response = new RestApiResponse<>(list);
|
||||
}catch (Exception e){
|
||||
logger.error("通过memberId查个人桩列表异常", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_PERSONAL_PILE_BY_MEMBER_ID_ERROR);
|
||||
}
|
||||
logger.info("通过memberId查个人桩列表 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取枪口实时数据
|
||||
*
|
||||
* http://localhost:8080/uniapp/personalPile/getConnectorRealTimeInfo
|
||||
*
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getConnectorRealTimeInfo")
|
||||
public RestApiResponse<?> getConnectorRealTimeInfo(HttpServletRequest request, @RequestBody QueryPersonPileDTO dto){
|
||||
logger.info("获取个人桩枪口实时数据 params:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
dto.setMemberId(memberId);
|
||||
PersonPileRealTimeVO connectorRealTimeInfo = pileService.getConnectorRealTimeInfo(dto);
|
||||
response = new RestApiResponse<>(connectorRealTimeInfo);
|
||||
}catch (BusinessException e){
|
||||
logger.error("获取个人桩枪口实时数据 error", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
}catch (Exception e){
|
||||
logger.error("获取个人桩枪口实时数据 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_PERSONAL_PILE_CONNECTOR_INFO_ERROR);
|
||||
}
|
||||
logger.info("获取个人桩枪口实时数据 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取某枪口某段时间内累计信息
|
||||
*
|
||||
* http://localhost:8080/uniapp/personalPile/getAccumulativeInfo
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getAccumulativeInfo")
|
||||
public RestApiResponse<?> getAccumulativeInfo(HttpServletRequest request, @RequestBody QueryPersonPileDTO dto) {
|
||||
logger.info("获取某枪口某段时间内累计信息 params:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
dto.setMemberId(memberId);
|
||||
PersonPileConnectorSumInfoVO accumulativeInfo = pileService.getAccumulativeInfo(dto);
|
||||
response = new RestApiResponse<>(accumulativeInfo);
|
||||
} catch (BusinessException e){
|
||||
logger.error("获取某枪口某段时间内累计信息 error", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
}catch (Exception e){
|
||||
logger.error("获取某枪口某段时间内累计信息 error", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("获取某枪口某段时间内累计信息 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取充电记录
|
||||
*
|
||||
* http://localhost:8080/uniapp/personalPile/getChargingRecord
|
||||
*
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getChargingRecord")
|
||||
public RestApiResponse<?> getChargingRecord(HttpServletRequest request, @RequestBody QueryPersonPileDTO dto){
|
||||
logger.info("获取个人桩充电记录 params:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
dto.setMemberId(memberId);
|
||||
PageResponse chargingRecord = pileService.getChargingRecord(dto);
|
||||
response = new RestApiResponse<>(chargingRecord);
|
||||
}catch (BusinessException e){
|
||||
logger.error("获取个人桩充电记录 error", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
}catch (Exception e){
|
||||
logger.error("获取个人桩充电记录 error", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("获取个人桩充电记录 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.jsowell.api.uniapp;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.jsowell.common.annotation.Anonymous;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.page.PageResponse;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.response.RestApiResponse;
|
||||
import com.jsowell.pile.dto.QueryConnectorListDTO;
|
||||
import com.jsowell.pile.dto.QueryStationDTO;
|
||||
import com.jsowell.pile.service.IPileConnectorInfoService;
|
||||
import com.jsowell.pile.service.IPileStationInfoService;
|
||||
import com.jsowell.pile.vo.uniapp.PersonalPileInfoVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 充电桩相关接口
|
||||
* 提供给小程序调用
|
||||
*/
|
||||
// 不登录直接访问
|
||||
@Anonymous
|
||||
@RestController
|
||||
@RequestMapping("/uniapp/pile")
|
||||
public class PileController extends BaseController {
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
private IPileStationInfoService pileStationInfoService;
|
||||
|
||||
@Autowired
|
||||
private IPileConnectorInfoService pileConnectorInfoService;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询充电站信息列表(主页)
|
||||
*
|
||||
* http://localhost:8080/uniapp/pile/queryStationInfos
|
||||
*/
|
||||
@PostMapping("/queryStationInfos")
|
||||
public RestApiResponse<?> queryStationInfos(HttpServletRequest request, @RequestBody QueryStationDTO queryStationDTO) {
|
||||
logger.info("查询充电站信息列表 param:{}", JSONObject.toJSONString(queryStationDTO));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
getMemberIdByAuthorization(request);
|
||||
// startPage();
|
||||
// List<PileStationVO> list = pileStationInfoService.uniAppQueryStationInfos(queryStationDTO);
|
||||
PageResponse pageResponse = pileStationInfoService.uniAppQueryStationInfoList(queryStationDTO);
|
||||
response = new RestApiResponse<>(pageResponse);
|
||||
} catch (BusinessException e) {
|
||||
logger.warn("查询充电站信息列表warn", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("查询充电站信息列表异常 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_PILE_STATION_INFO_ERROR);
|
||||
}
|
||||
logger.info("查询充电站信息列表 result:{}", JSONObject.toJSONString(response));
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过前端参数查询充电枪口列表
|
||||
*
|
||||
* http://localhost:8080/uniapp/pile/selectConnectorListByParams
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/selectConnectorListByParams")
|
||||
public RestApiResponse<?> selectConnectorListByParams(HttpServletRequest request, @RequestBody QueryConnectorListDTO dto) {
|
||||
logger.info("查询充电枪口列表 params:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
PageResponse pageResponse = pileConnectorInfoService.getUniAppConnectorInfoListByParams(dto);
|
||||
response = new RestApiResponse<>(pageResponse);
|
||||
} catch (Exception e) {
|
||||
logger.error("查询充电枪口列表异常", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_CONNECTOR_INFO_BY_STATION_ID_ERROR);
|
||||
}
|
||||
logger.info("查询充电枪口列表 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
package com.jsowell.service;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.jsowell.common.constant.CacheConstants;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.page.PageResponse;
|
||||
import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.common.enums.uniapp.BalanceChangesEnum;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.JWTUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.id.IdUtils;
|
||||
import com.jsowell.pile.domain.MemberBasicInfo;
|
||||
import com.jsowell.pile.domain.MemberWalletInfo;
|
||||
import com.jsowell.pile.dto.MemberRegisterAndLoginDTO;
|
||||
import com.jsowell.pile.dto.MemberRegisterDTO;
|
||||
import com.jsowell.pile.dto.UniAppQueryMemberBalanceDTO;
|
||||
import com.jsowell.pile.dto.WechatLoginDTO;
|
||||
import com.jsowell.pile.service.IMemberBasicInfoService;
|
||||
import com.jsowell.pile.service.IPileMerchantInfoService;
|
||||
import com.jsowell.pile.transaction.dto.MemberTransactionDTO;
|
||||
import com.jsowell.pile.transaction.service.TransactionService;
|
||||
import com.jsowell.pile.vo.uniapp.MemberVO;
|
||||
import com.jsowell.pile.vo.uniapp.MemberWalletLogVO;
|
||||
import com.jsowell.wxpay.service.WxAppletRemoteService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
public class MemberService {
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
@Autowired
|
||||
private TransactionService transactionService;
|
||||
|
||||
@Autowired
|
||||
private IMemberBasicInfoService memberBasicInfoService;
|
||||
|
||||
@Autowired
|
||||
private IPileMerchantInfoService pileMerchantInfoService;
|
||||
|
||||
@Autowired
|
||||
private WxAppletRemoteService wxAppletRemoteService;
|
||||
|
||||
/**
|
||||
* 校验短信验证码
|
||||
* @param dto
|
||||
*/
|
||||
public void checkVerificationCode(MemberRegisterAndLoginDTO dto) {
|
||||
// 取出缓存中的验证码进行对比,如果缓存中没有,则超时
|
||||
String captchaCode = redisCache.getCacheObject(CacheConstants.SMS_VERIFICATION_CODE_KEY + dto.getMobileNumber());
|
||||
if (StringUtils.isEmpty(captchaCode)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_VERIFICATION_CODE_TIMEOUT_ERROR);
|
||||
}
|
||||
// 如果缓存中有,但与实际不一致,则为验证码错误
|
||||
if (!StringUtils.equals(captchaCode, dto.getVerificationCode())) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_VERIFICATION_CODE_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 短信验证码登录注册
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public String memberRegisterAndLogin(MemberRegisterAndLoginDTO dto) {
|
||||
// 校验短信验证码 两种情况不能通过校验,1-验证码错误;2-超时 验证码10分钟有效
|
||||
checkVerificationCode(dto);
|
||||
String merchantId = "";
|
||||
return memberRegisterAndLogin(dto.getMobileNumber(), merchantId, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 公共登陆注册方法
|
||||
* @param phoneNumber 手机号
|
||||
* @param merchantId 商户id
|
||||
* @return
|
||||
*/
|
||||
private String memberRegisterAndLogin(String phoneNumber, String merchantId, String openId) {
|
||||
if (StringUtils.isBlank(phoneNumber)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_GET_MOBILE_NUMBER_BY_CODE_ERROR);
|
||||
}
|
||||
// if (Objects.isNull(merchantId)) {
|
||||
// throw new BusinessException(ReturnCodeEnum.CODE_GET_MERCHANT_ID_BY_APP_ID_ERROR);
|
||||
// }
|
||||
// 查询手机号码是否注册过
|
||||
MemberBasicInfo memberBasicInfo = memberBasicInfoService.selectInfoByMobileNumberAndMerchantId(phoneNumber, merchantId);
|
||||
if (Objects.isNull(memberBasicInfo)) {
|
||||
// 不存在则新增数据
|
||||
String memberId = IdUtils.getMemberId();
|
||||
memberBasicInfo = new MemberBasicInfo();
|
||||
memberBasicInfo.setStatus(Constants.ONE);
|
||||
memberBasicInfo.setMemberId(memberId);
|
||||
memberBasicInfo.setNickName("会员" + memberId);
|
||||
memberBasicInfo.setMobileNumber(phoneNumber);
|
||||
memberBasicInfo.setMerchantId(Long.valueOf(merchantId));
|
||||
memberBasicInfo.setOpenId(openId);
|
||||
|
||||
// 首次新建会员,同时新建会员钱包
|
||||
MemberWalletInfo memberWalletInfo = MemberWalletInfo.builder().memberId(memberId).build();
|
||||
MemberTransactionDTO memberTransactionDTO = MemberTransactionDTO.builder()
|
||||
.memberBasicInfo(memberBasicInfo)
|
||||
.memberWalletInfo(memberWalletInfo)
|
||||
.build();
|
||||
transactionService.createMember(memberTransactionDTO);
|
||||
} else {
|
||||
if (StringUtils.isBlank(memberBasicInfo.getOpenId()) && StringUtils.isNotBlank(openId)) {
|
||||
memberBasicInfo.setOpenId(openId);
|
||||
memberBasicInfoService.updateMemberBasicInfo(memberBasicInfo);
|
||||
}
|
||||
}
|
||||
// 服务器生成token返给前端
|
||||
String memberToken = JWTUtils.createMemberToken(memberBasicInfo.getMemberId(), memberBasicInfo.getNickName());
|
||||
// log.info("memToken:{}", memberToken);
|
||||
return memberToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信一键登录
|
||||
* @param dto
|
||||
*/
|
||||
public String wechatLogin(WechatLoginDTO dto) {
|
||||
// 通过微信传的code获取手机号码
|
||||
String mobileNumber = wxAppletRemoteService.getMobileNumberByCode(dto.getCode());
|
||||
if (StringUtils.isBlank(mobileNumber)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_GET_MOBILE_NUMBER_BY_CODE_ERROR);
|
||||
}
|
||||
// 通过appid获取运营商id
|
||||
String merchantId = pileMerchantInfoService.getMerchantIdByAppId(dto.getAppId());
|
||||
// if (Objects.isNull(merchantId)) {
|
||||
// throw new BusinessException(ReturnCodeEnum.CODE_GET_MERCHANT_ID_BY_APP_ID_ERROR);
|
||||
// }
|
||||
// 通过code获取openId
|
||||
String openId = "";
|
||||
try {
|
||||
openId = getOpenIdByCode(dto.getOpenIdCode());
|
||||
} catch (Exception e) {
|
||||
log.error("getOpenIdByCode发生异常", e);
|
||||
}
|
||||
// 查询手机号码是否注册过
|
||||
return memberRegisterAndLogin(mobileNumber, merchantId, openId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取openId
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
public String getOpenIdByCode(String code) {
|
||||
return wxAppletRemoteService.getOpenIdByCode(code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理用户信息
|
||||
*
|
||||
* @param dto 用户个人信息
|
||||
*/
|
||||
public void handleUserInfo(MemberRegisterDTO dto) {
|
||||
// 通过用户手机号查询数据库,如果数据库中存在,则更新
|
||||
MemberBasicInfo memberBasicInfo = memberBasicInfoService.selectInfoByMobileNumber(dto.getMobileNumber());
|
||||
if (Objects.nonNull(memberBasicInfo)) {
|
||||
MemberBasicInfo memberInfo = MemberBasicInfo.builder()
|
||||
.avatarUrl(dto.getAvatarUrl())
|
||||
.mobileNumber(dto.getMobileNumber())
|
||||
.nickName(dto.getNickName())
|
||||
.build();
|
||||
memberBasicInfoService.updateMemberBasicInfo(memberInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过memberToken获取用户账户信息
|
||||
*
|
||||
* @param memberId
|
||||
* @return
|
||||
*/
|
||||
public MemberVO getMemberInfoByMemberId(String memberId) {
|
||||
MemberVO memberVO = memberBasicInfoService.queryMemberInfoByMemberId(memberId);
|
||||
if (Objects.nonNull(memberVO)) {
|
||||
memberVO.setTotalAccountAmount(memberVO.getPrincipalBalance().add(memberVO.getGiftBalance()));
|
||||
}
|
||||
return memberVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户账户余额变动信息
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
public PageResponse getMemberBalanceChanges(UniAppQueryMemberBalanceDTO dto) {
|
||||
|
||||
// 获取分页信息以及memberId
|
||||
int pageNum = dto.getPageNum() == 0 ? 1 : dto.getPageNum();
|
||||
int pageSize = dto.getPageSize() == 0 ? 10 : dto.getPageSize();
|
||||
String memberId = dto.getMemberId();
|
||||
String type = dto.getType();
|
||||
|
||||
if (!StringUtils.equals("1", type) && !StringUtils.equals("2", type)) {
|
||||
type = "";
|
||||
}
|
||||
// 分页
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<MemberWalletLogVO> list = memberBasicInfoService.getMemberBalanceChanges(memberId, type);
|
||||
PageInfo<MemberWalletLogVO> pageInfo = new PageInfo<>(list);
|
||||
|
||||
for (MemberWalletLogVO walletLogVO : pageInfo.getList()) {
|
||||
String subType = walletLogVO.getSubType();
|
||||
String subTypeValue = BalanceChangesEnum.getValueByCode(subType);
|
||||
if (StringUtils.isNotBlank(subTypeValue)) {
|
||||
walletLogVO.setSubType(subTypeValue);
|
||||
}
|
||||
// walletLogVO.setTotalAccountAmount(walletLogVO.getPrincipalBalance().add(walletLogVO.getGiftBalance()));
|
||||
}
|
||||
PageResponse pageResponse = PageResponse.builder()
|
||||
.pageSize(pageSize)
|
||||
.pageNum(pageNum)
|
||||
.list(pageInfo.getList())
|
||||
.pages(pageInfo.getPages())
|
||||
.total(pageInfo.getTotal())
|
||||
.build();
|
||||
return pageResponse;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,780 @@
|
||||
package com.jsowell.service;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
|
||||
import com.jsowell.common.core.page.PageResponse;
|
||||
import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.common.enums.MemberWalletEnum;
|
||||
import com.jsowell.common.enums.ykc.ActionTypeEnum;
|
||||
import com.jsowell.common.enums.ykc.OrderPayModeEnum;
|
||||
import com.jsowell.common.enums.ykc.OrderPayRecordEnum;
|
||||
import com.jsowell.common.enums.ykc.OrderPayStatusEnum;
|
||||
import com.jsowell.common.enums.ykc.OrderStatusEnum;
|
||||
import com.jsowell.common.enums.ykc.PayModeEnum;
|
||||
import com.jsowell.common.enums.ykc.ScenarioEnum;
|
||||
import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.id.IdUtils;
|
||||
import com.jsowell.netty.command.ykc.StartChargingCommand;
|
||||
import com.jsowell.netty.service.yunkuaichong.YKCPushCommandService;
|
||||
import com.jsowell.pile.domain.MemberTransactionRecord;
|
||||
import com.jsowell.pile.domain.OrderBasicInfo;
|
||||
import com.jsowell.pile.domain.OrderDetail;
|
||||
import com.jsowell.pile.domain.OrderPayRecord;
|
||||
import com.jsowell.pile.domain.WxpayCallbackRecord;
|
||||
import com.jsowell.pile.dto.BasicPileDTO;
|
||||
import com.jsowell.pile.dto.GenerateOrderDTO;
|
||||
import com.jsowell.pile.dto.PayOrderDTO;
|
||||
import com.jsowell.pile.dto.PayOrderSuccessCallbackDTO;
|
||||
import com.jsowell.pile.dto.PaymentScenarioDTO;
|
||||
import com.jsowell.pile.dto.QueryConnectorListDTO;
|
||||
import com.jsowell.pile.dto.QueryOrderDTO;
|
||||
import com.jsowell.pile.dto.SettleOrderDTO;
|
||||
import com.jsowell.pile.dto.StopChargingDTO;
|
||||
import com.jsowell.pile.dto.UniAppQueryOrderDTO;
|
||||
import com.jsowell.pile.dto.WeixinPayDTO;
|
||||
import com.jsowell.pile.service.IMemberBasicInfoService;
|
||||
import com.jsowell.pile.service.IMemberTransactionRecordService;
|
||||
import com.jsowell.pile.service.IOrderBasicInfoService;
|
||||
import com.jsowell.pile.service.IOrderPayRecordService;
|
||||
import com.jsowell.pile.service.IPileBillingTemplateService;
|
||||
import com.jsowell.pile.service.IPileConnectorInfoService;
|
||||
import com.jsowell.pile.service.WechatPayService;
|
||||
import com.jsowell.pile.service.WxpayCallbackRecordService;
|
||||
import com.jsowell.pile.transaction.dto.OrderTransactionDTO;
|
||||
import com.jsowell.pile.transaction.service.TransactionService;
|
||||
import com.jsowell.pile.vo.base.PileInfoVO;
|
||||
import com.jsowell.pile.vo.uniapp.MemberVO;
|
||||
import com.jsowell.pile.vo.uniapp.OrderVO;
|
||||
import com.jsowell.pile.vo.uniapp.PileConnectorDetailVO;
|
||||
import com.jsowell.pile.vo.uniapp.UniAppOrderVO;
|
||||
import com.jsowell.pile.vo.web.BillingTemplateVO;
|
||||
import com.jsowell.pile.vo.web.OrderDetailInfoVO;
|
||||
import com.jsowell.pile.vo.web.UpdateMemberBalanceDTO;
|
||||
import com.jsowell.wxpay.dto.WeChatRefundDTO;
|
||||
import com.jsowell.wxpay.response.WechatPayNotifyParameter;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Service
|
||||
public class OrderService {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
@Autowired
|
||||
private TransactionService pileTransactionService;
|
||||
|
||||
@Autowired
|
||||
private IPileBillingTemplateService pileBillingTemplateService;
|
||||
|
||||
@Autowired
|
||||
private IOrderBasicInfoService orderBasicInfoService;
|
||||
|
||||
@Autowired
|
||||
private PileRemoteService pileRemoteService;
|
||||
|
||||
@Autowired
|
||||
private YKCPushCommandService ykcPushCommandService;
|
||||
|
||||
@Autowired
|
||||
private PileService pileService;
|
||||
|
||||
@Autowired
|
||||
private MemberService memberService;
|
||||
|
||||
@Autowired
|
||||
private IMemberBasicInfoService memberBasicInfoService;
|
||||
|
||||
@Autowired
|
||||
private IOrderPayRecordService orderPayRecordService;
|
||||
|
||||
@Autowired
|
||||
private WechatPayService wechatPayService;
|
||||
|
||||
@Autowired
|
||||
private WxpayCallbackRecordService wxpayCallbackRecordService;
|
||||
|
||||
@Autowired
|
||||
private IPileConnectorInfoService pileConnectorInfoService;
|
||||
|
||||
@Autowired
|
||||
private IMemberTransactionRecordService memberTransactionRecordService;
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
/**
|
||||
* 生成订单
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public String generateOrder(GenerateOrderDTO dto) {
|
||||
log.info("generateOrder param:{}", JSONObject.toJSONString(dto));
|
||||
// 处理前端传的参数
|
||||
analysisPileParameter(dto);
|
||||
|
||||
// 校验充电桩相关的信息
|
||||
checkPileInfo(dto);
|
||||
|
||||
// 保存订单到数据库 saveOrder2Database
|
||||
String orderCode = saveOrder2Database(dto);
|
||||
return orderCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单支付
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
public Map<String, Object> payOrder(PayOrderDTO dto) throws Exception {
|
||||
Map<String, Object> resultMap = Maps.newHashMap();
|
||||
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(dto.getOrderCode());
|
||||
if (orderInfo == null) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_QUERY_ORDER_NULL_ERROR);
|
||||
}
|
||||
if (!StringUtils.equals(orderInfo.getPayStatus(), "0")) {
|
||||
// 订单已支付
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_ORDER_IS_NOT_TO_BE_PAID_ERROR);
|
||||
}
|
||||
String orderCode = orderInfo.getOrderCode();
|
||||
// 该订单充电金额
|
||||
BigDecimal chargeAmount = dto.getPayAmount();
|
||||
// 记录支付流水
|
||||
List<OrderPayRecord> payRecordList = Lists.newArrayList();
|
||||
if (StringUtils.equals(dto.getPayMode(), OrderPayModeEnum.PAYMENT_OF_BALANCE.getValue())) { // 余额支付
|
||||
// 查询该会员的余额
|
||||
MemberVO memberVO = memberService.getMemberInfoByMemberId(dto.getMemberId());
|
||||
BigDecimal totalAccountAmount = memberVO.getTotalAccountAmount();
|
||||
|
||||
if (totalAccountAmount.compareTo(chargeAmount) < 0) {
|
||||
// 总余额小于充电金额
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_BALANCE_IS_INSUFFICIENT);
|
||||
}
|
||||
BigDecimal principalAmount = memberVO.getPrincipalBalance(); // 会员剩余本金金额
|
||||
BigDecimal giftAmount = memberVO.getGiftBalance(); // 会员剩余赠送余额
|
||||
|
||||
BigDecimal principalPay = null; // 30
|
||||
BigDecimal giftPay = null; // 10
|
||||
// 先扣除本金金额,再扣除赠送金额
|
||||
BigDecimal subtract = principalAmount.subtract(chargeAmount);
|
||||
if (subtract.compareTo(BigDecimal.ZERO) >= 0) {
|
||||
principalPay = chargeAmount;
|
||||
} else {
|
||||
if (principalAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
principalPay = principalAmount;
|
||||
}
|
||||
giftPay = subtract.negate();
|
||||
}
|
||||
|
||||
// 更新会员钱包
|
||||
UpdateMemberBalanceDTO updateMemberBalanceDTO = UpdateMemberBalanceDTO.builder()
|
||||
.memberId(dto.getMemberId())
|
||||
.type(MemberWalletEnum.TYPE_OUT.getValue())
|
||||
.subType(MemberWalletEnum.SUBTYPE_PAYMENT_FOR_ORDER.getValue())
|
||||
.updatePrincipalBalance(principalPay)
|
||||
.updateGiftBalance(giftPay)
|
||||
.relatedOrderCode(orderCode)
|
||||
.build();
|
||||
memberBasicInfoService.updateMemberBalance(updateMemberBalanceDTO);
|
||||
|
||||
// 记录流水
|
||||
if (principalPay != null) {
|
||||
payRecordList.add(OrderPayRecord.builder()
|
||||
.orderCode(dto.getOrderCode())
|
||||
.payMode(OrderPayRecordEnum.PRINCIPAL_BALANCE_PAYMENT.getValue())
|
||||
.payAmount(principalPay)
|
||||
.createBy(dto.getMemberId())
|
||||
.build());
|
||||
}
|
||||
if (giftPay != null) {
|
||||
payRecordList.add(OrderPayRecord.builder()
|
||||
.orderCode(dto.getOrderCode())
|
||||
.payMode(OrderPayRecordEnum.GIFT_BALANCE_PAYMENT.getValue())
|
||||
.payAmount(giftPay)
|
||||
.createBy(dto.getMemberId())
|
||||
.build());
|
||||
}
|
||||
// 余额支付可以直接调支付回调方法
|
||||
PayOrderSuccessCallbackDTO callbackDTO = PayOrderSuccessCallbackDTO.builder()
|
||||
.orderCode(orderCode)
|
||||
.payAmount(chargeAmount)
|
||||
.payMode(dto.getPayMode())
|
||||
.build();
|
||||
payOrderSuccessCallback(callbackDTO);
|
||||
|
||||
// 余额支付订单 记录会员交易流水
|
||||
MemberTransactionRecord record = MemberTransactionRecord.builder()
|
||||
.orderCode(orderCode)
|
||||
.scenarioType(ScenarioEnum.ORDER.getValue())
|
||||
.memberId(memberVO.getMemberId())
|
||||
.actionType(ActionTypeEnum.FORWARD.getValue())
|
||||
.payMode(PayModeEnum.PAYMENT_OF_BALANCE.getValue())
|
||||
.amount(dto.getPayAmount()) // 单位元
|
||||
.build();
|
||||
memberTransactionRecordService.insertSelective(record);
|
||||
} else if (StringUtils.equals(dto.getPayMode(), OrderPayModeEnum.PAYMENT_OF_WECHATPAY.getValue())) { // 微信支付
|
||||
String openId = memberService.getOpenIdByCode(dto.getCode());
|
||||
if (StringUtils.isBlank(openId)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_GET_OPEN_ID_BY_CODE_ERROR);
|
||||
}
|
||||
WeixinPayDTO weixinPayDTO = new WeixinPayDTO();
|
||||
weixinPayDTO.setOpenId(openId);
|
||||
weixinPayDTO.setAmount(dto.getPayAmount().toString());
|
||||
// 支付订单 附加参数
|
||||
PaymentScenarioDTO paymentScenarioDTO = PaymentScenarioDTO.builder()
|
||||
.type(ScenarioEnum.ORDER.getValue())
|
||||
.orderCode(dto.getOrderCode())
|
||||
.memberId(orderInfo.getMemberId())
|
||||
.build();
|
||||
weixinPayDTO.setAttach(JSONObject.toJSONString(paymentScenarioDTO));
|
||||
weixinPayDTO.setDescription("充电费用");
|
||||
Map<String, Object> weixinMap = this.weixinPayV3(weixinPayDTO);
|
||||
// 返回微信支付参数
|
||||
resultMap.put("weixinMap", weixinMap);
|
||||
} else if (StringUtils.equals(dto.getPayMode(), OrderPayModeEnum.PAYMENT_OF_ALIPAY.getValue())) { // 支付宝支付
|
||||
// TODO 返回支付宝支付参数
|
||||
}
|
||||
|
||||
// 订单支付流水入库
|
||||
if (CollectionUtils.isNotEmpty(payRecordList)) {
|
||||
orderPayRecordService.batchInsert(payRecordList);
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单支付成功 支付回调
|
||||
* 支付成功后掉用这个方法
|
||||
* 1. 修改订单支付状态
|
||||
* 2. 发送启动充电指令
|
||||
*/
|
||||
public void payOrderSuccessCallback(PayOrderSuccessCallbackDTO dto) {
|
||||
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(dto.getOrderCode());
|
||||
BigDecimal payAmount = dto.getPayAmount();
|
||||
|
||||
// 修改订单
|
||||
orderInfo.setPayMode(dto.getPayMode());
|
||||
orderInfo.setPayStatus("1");
|
||||
orderInfo.setPayAmount(payAmount);
|
||||
orderInfo.setPayTime(new Date());
|
||||
orderBasicInfoService.updateOrderBasicInfo(orderInfo);
|
||||
|
||||
// 发送启动指令
|
||||
StartChargingCommand startChargingCommand = StartChargingCommand.builder()
|
||||
.pileSn(orderInfo.getPileSn())
|
||||
.connectorCode(orderInfo.getConnectorCode())
|
||||
.orderCode(dto.getOrderCode())
|
||||
.chargeAmount(payAmount)
|
||||
.build();
|
||||
ykcPushCommandService.pushStartChargingCommand(startChargingCommand);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存订单信息到数据库
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
private String saveOrder2Database(GenerateOrderDTO dto) {
|
||||
String orderCode = IdUtils.generateOrderCode(dto.getPileSn(), dto.getConnectorCode());
|
||||
// 订单基本信息
|
||||
OrderBasicInfo orderBasicInfo = OrderBasicInfo.builder()
|
||||
.orderCode(orderCode)
|
||||
.orderStatus(OrderStatusEnum.NOT_START.getValue())
|
||||
.memberId(dto.getMemberId())
|
||||
.stationId(dto.getPileConnector().getStationId())
|
||||
.pileSn(dto.getPileSn())
|
||||
.connectorCode(dto.getConnectorCode())
|
||||
.pileConnectorCode(dto.getPileSn() + dto.getConnectorCode())
|
||||
.startMode(dto.getStartMode())
|
||||
.payStatus(Constants.ZERO)
|
||||
.payAmount(dto.getChargeAmount())
|
||||
.payMode(dto.getPayMode())
|
||||
.orderAmount(BigDecimal.ZERO)
|
||||
.build();
|
||||
|
||||
// 订单详情
|
||||
OrderDetail orderDetail = OrderDetail.builder()
|
||||
.orderCode(orderCode)
|
||||
.sharpElectricityPrice(dto.getBillingTemplate().getSharpElectricityPrice())
|
||||
.sharpServicePrice(dto.getBillingTemplate().getSharpServicePrice())
|
||||
.peakElectricityPrice(dto.getBillingTemplate().getPeakElectricityPrice())
|
||||
.peakServicePrice(dto.getBillingTemplate().getPeakServicePrice())
|
||||
.flatElectricityPrice(dto.getBillingTemplate().getFlatElectricityPrice())
|
||||
.flatServicePrice(dto.getBillingTemplate().getFlatServicePrice())
|
||||
.valleyElectricityPrice(dto.getBillingTemplate().getValleyElectricityPrice())
|
||||
.valleyServicePrice(dto.getBillingTemplate().getValleyServicePrice())
|
||||
.build();
|
||||
|
||||
OrderTransactionDTO createOrderTransactionDTO = OrderTransactionDTO.builder()
|
||||
.orderBasicInfo(orderBasicInfo)
|
||||
.orderDetail(orderDetail)
|
||||
.build();
|
||||
pileTransactionService.doCreateOrder(createOrderTransactionDTO);
|
||||
return orderCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验充电桩相关的信息
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
private void checkPileInfo(GenerateOrderDTO dto) {
|
||||
// 查询充电桩状态 是否空闲 枪口是否占用
|
||||
PileConnectorDetailVO pileConnector = pileService.queryPileConnectorDetail(dto.getPileSn() + dto.getConnectorCode());
|
||||
if (pileConnector == null) {
|
||||
log.error("checkPileInfo充电枪口为空 pileSn:{}, connectorCode:{}", dto.getPileSn(), dto.getConnectorCode());
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_CONNECTOR_INFO_NULL_ERROR);
|
||||
}
|
||||
// 判断枪口状态
|
||||
if (!(StringUtils.equals(pileConnector.getConnectorStatus(), PileConnectorDataBaseStatusEnum.FREE.getValue())
|
||||
|| StringUtils.equals(pileConnector.getConnectorStatus(), PileConnectorDataBaseStatusEnum.OCCUPIED_NOT_CHARGED.getValue()))) {
|
||||
log.error("checkPileInfo充电枪口状态不正确,当前状态为:{}", pileConnector.getConnectorStatus());
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PILE_CONNECTOR_STATUS_ERROR);
|
||||
}
|
||||
// 查询充电桩的计费模板
|
||||
BillingTemplateVO billingTemplateVO = pileBillingTemplateService.selectBillingTemplateDetailByPileSn(dto.getPileSn());
|
||||
if (billingTemplateVO == null) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_BILLING_TEMPLATE_NULL_ERROR);
|
||||
}
|
||||
dto.setPileConnector(pileConnector);
|
||||
dto.setBillingTemplate(billingTemplateVO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理前端传的参数
|
||||
* pileConnectorCode = pileSn + connectorCode
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
public void analysisPileParameter(BasicPileDTO dto) {
|
||||
if (StringUtils.isBlank(dto.getPileSn()) || StringUtils.isBlank(dto.getConnectorCode())) {
|
||||
// 从pileConnectorCode解析
|
||||
String pileConnectorCode = dto.getPileConnectorCode();
|
||||
if (StringUtils.isNotEmpty(pileConnectorCode) && pileConnectorCode.length() == Constants.PILE_CONNECTOR_CODE_LENGTH) {
|
||||
dto.setPileSn(StringUtils.substring(pileConnectorCode, 0, pileConnectorCode.length() - 2));
|
||||
dto.setConnectorCode(StringUtils.substring(pileConnectorCode, pileConnectorCode.length() - 2, pileConnectorCode.length()));
|
||||
} else {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_DATA_LENGTH_ERROR);
|
||||
}
|
||||
} else {
|
||||
// 说明pileSn 和 connectorCode前端传了,那就校验一下长度
|
||||
if (dto.getPileSn().length() != Constants.PILE_SN_LENGTH || dto.getConnectorCode().length() != Constants.CONNECTOR_CODE_LENGTH) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_DATA_LENGTH_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 结算订单
|
||||
* endCharging
|
||||
*
|
||||
* @param dto 结算订单参数
|
||||
*/
|
||||
public void settleOrderForWeb(SettleOrderDTO dto) {
|
||||
analysisPileParameter(dto);
|
||||
// 查询订单详情,验证订单中的桩编号是否正确
|
||||
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(dto.getOrderCode());
|
||||
if (orderBasicInfo == null) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_QUERY_ORDER_NULL_ERROR);
|
||||
}
|
||||
if (!(StringUtils.equals(orderBasicInfo.getPileSn(), dto.getPileSn())
|
||||
&& StringUtils.equals(orderBasicInfo.getConnectorCode(), dto.getConnectorCode()))) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_ORDER_PILE_MAPPING_ERROR);
|
||||
}
|
||||
// push远程停机指令
|
||||
pileRemoteService.remoteStopCharging(dto.getPileSn(), dto.getConnectorCode());
|
||||
|
||||
// 桩计算的消费金额
|
||||
|
||||
// 对比一下,是否需要退款
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过会员Id查询订单列表
|
||||
*
|
||||
* @param memberId 会员Id
|
||||
* @return 订单信息集合
|
||||
*/
|
||||
public PageResponse getListByMemberIdAndOrderStatus(String memberId, UniAppQueryOrderDTO dto) throws ParseException {
|
||||
String orderStatus = dto.getOrderStatus();
|
||||
if (StringUtils.isBlank(orderStatus)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
ArrayList<String> orderStatusList = Lists.newArrayList();
|
||||
if (StringUtils.equals("2", orderStatus)) {
|
||||
// 查未完成订单
|
||||
CollectionUtils.addAll(orderStatusList, "0", "1", "2", "3", "4", "5");
|
||||
} else if (StringUtils.equals("3", orderStatus)) {
|
||||
// 查已完成订单
|
||||
orderStatusList.add("6");
|
||||
}
|
||||
// 分页
|
||||
PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
|
||||
List<OrderVO> list = orderBasicInfoService.getListByMemberIdAndOrderStatus(memberId, orderStatusList);
|
||||
|
||||
PageInfo<OrderVO> pageInfo = new PageInfo<>(list);
|
||||
|
||||
for (OrderVO orderVO : pageInfo.getList()) {
|
||||
orderVO.setPileConnectorCode(orderVO.getPileSn() + orderVO.getConnectorCode());
|
||||
Date endTimeDate;
|
||||
Date startTimeDate = sdf.parse(orderVO.getStartTime());
|
||||
if (StringUtils.isNotBlank(orderVO.getEndTime())) {
|
||||
endTimeDate = sdf.parse(orderVO.getEndTime());
|
||||
} else {
|
||||
endTimeDate = new Date();
|
||||
}
|
||||
// 计算出两个时间差
|
||||
orderVO.setChargingTime(DateUtils.getDatePoor(endTimeDate, startTimeDate));
|
||||
}
|
||||
|
||||
// 返回结果集
|
||||
PageResponse pageResponse = PageResponse.builder()
|
||||
.pageNum(dto.getPageNum())
|
||||
.pageSize(dto.getPageSize())
|
||||
.list(pageInfo.getList())
|
||||
.pages(pageInfo.getPages())
|
||||
.total(pageInfo.getTotal())
|
||||
.build();
|
||||
return pageResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信支付v3
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Map<String, Object> weixinPayV3(WeixinPayDTO dto) throws Exception {
|
||||
return wechatPayService.weixinPayV3(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户停止充电
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
public void stopCharging(StopChargingDTO dto) {
|
||||
// 查订单
|
||||
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(dto.getOrderCode());
|
||||
if (orderInfo == null) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_QUERY_ORDER_NULL_ERROR);
|
||||
}
|
||||
// 校验订单中的会员与操作会员是否一致
|
||||
if (!StringUtils.equals(orderInfo.getMemberId(), dto.getMemberId())) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_ORDER_MEMBER_NOT_MATCH_ERROR);
|
||||
}
|
||||
// 发送停止指令
|
||||
pileRemoteService.remoteStopCharging(orderInfo.getPileSn(), orderInfo.getConnectorCode());
|
||||
log.info("订单号:{}发送停机指令成功", dto.getOrderCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信支付回调
|
||||
*
|
||||
* @param request
|
||||
* @param body
|
||||
* @throws Exception
|
||||
*/
|
||||
public void wechatPayCallback(HttpServletRequest request, WechatPayNotifyParameter body) throws Exception {
|
||||
// 获取微信支付成功返回的信息
|
||||
Map<String, Object> map = wechatPayService.wechatPayCallbackInfo(request, body);
|
||||
String type = (String) map.get("type");
|
||||
BigDecimal amount = (BigDecimal) map.get("amount"); // 微信给的amount单位是分
|
||||
amount = amount.divide(new BigDecimal("100"), 2, BigDecimal.ROUND_HALF_UP); // 转换为元
|
||||
|
||||
String orderCode = (String) map.get("orderCode");
|
||||
String memberId = (String) map.get("memberId");
|
||||
if (StringUtils.equals(type, ScenarioEnum.ORDER.getValue())) { // 1-订单支付
|
||||
// 支付订单成功
|
||||
// orderCode = (String) map.get("orderCode");
|
||||
PayOrderSuccessCallbackDTO callbackDTO = PayOrderSuccessCallbackDTO.builder()
|
||||
.orderCode(orderCode)
|
||||
.payAmount(amount)
|
||||
.payMode(OrderPayModeEnum.PAYMENT_OF_WECHATPAY.getValue())
|
||||
.build();
|
||||
// 订单支付成功 支付回调
|
||||
payOrderSuccessCallback(callbackDTO);
|
||||
|
||||
// 记录订单支付流水
|
||||
OrderPayRecord orderPayRecord = OrderPayRecord.builder()
|
||||
.orderCode(orderCode)
|
||||
.payMode(OrderPayRecordEnum.WECHATPAY_PAYMENT.getValue())
|
||||
.payAmount(amount)
|
||||
.createBy(null)
|
||||
.build();
|
||||
orderPayRecordService.batchInsert(Lists.newArrayList(orderPayRecord));
|
||||
} else if (StringUtils.equals(type, ScenarioEnum.BALANCE.getValue())) { // 2-充值余额
|
||||
// 充值余额成功
|
||||
// memberId = (String) map.get("memberId");
|
||||
UpdateMemberBalanceDTO dto = new UpdateMemberBalanceDTO();
|
||||
dto.setMemberId(memberId);
|
||||
dto.setType(MemberWalletEnum.TYPE_IN.getValue());
|
||||
dto.setSubType(MemberWalletEnum.SUBTYPE_TOP_UP.getValue());
|
||||
dto.setUpdatePrincipalBalance(amount);
|
||||
memberBasicInfoService.updateMemberBalance(dto);
|
||||
}
|
||||
|
||||
// 微信支付订单 记录会员交易流水
|
||||
MemberTransactionRecord record = MemberTransactionRecord.builder()
|
||||
.orderCode(orderCode)
|
||||
.scenarioType(type)
|
||||
.memberId(memberId)
|
||||
.actionType(ActionTypeEnum.FORWARD.getValue())
|
||||
.payMode(PayModeEnum.PAYMENT_OF_WECHATPAY.getValue())
|
||||
.amount(amount) // 单位元
|
||||
.outTradeNo(String.valueOf(map.get("out_trade_no")))
|
||||
.transactionId(String.valueOf(map.get("transaction_id")))
|
||||
.build();
|
||||
memberTransactionRecordService.insertSelective(record);
|
||||
}
|
||||
|
||||
public void weChatRefund(WeChatRefundDTO dto) {
|
||||
log.info("微信退款接口 param:{}", JSONObject.toJSONString(dto));
|
||||
orderBasicInfoService.weChatRefund(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单详情信息
|
||||
* @param orderCode 订单编号
|
||||
* @return
|
||||
*/
|
||||
public OrderDetailInfoVO queryOrderDetailInfo(String orderCode) {
|
||||
OrderDetailInfoVO vo = new OrderDetailInfoVO();
|
||||
|
||||
// 订单信息
|
||||
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
|
||||
if (orderBasicInfo == null) {
|
||||
return vo;
|
||||
}
|
||||
OrderDetailInfoVO.OrderInfo order = new OrderDetailInfoVO.OrderInfo();
|
||||
order.setOrderCode(orderBasicInfo.getOrderCode());
|
||||
order.setOrderStatus(orderBasicInfo.getOrderStatus());
|
||||
order.setStartTime(DateUtils.formatDateTime(orderBasicInfo.getChargeStartTime()));
|
||||
order.setEndTime(DateUtils.formatDateTime(orderBasicInfo.getChargeEndTime()));
|
||||
order.setCreateTime(DateUtils.formatDateTime(orderBasicInfo.getCreateTime()));
|
||||
order.setStopReasonMsg(orderBasicInfo.getReason());
|
||||
order.setStartSOC(orderBasicInfo.getStartSOC());
|
||||
order.setEndSOC(orderBasicInfo.getEndSOC());
|
||||
vo.setOrderInfo(order);
|
||||
|
||||
// 设备信息
|
||||
PileInfoVO pileInfoVO = pileService.selectPileInfoBySn(orderBasicInfo.getPileSn());
|
||||
vo.setPileInfo(pileInfoVO);
|
||||
|
||||
// 枪口实时数据信息
|
||||
String pileConnectorCode = orderBasicInfo.getPileSn() + orderBasicInfo.getConnectorCode();
|
||||
QueryConnectorListDTO dto = new QueryConnectorListDTO();
|
||||
dto.setConnectorCodeList(Lists.newArrayList(pileConnectorCode));
|
||||
List<RealTimeMonitorData> chargingRealTimeDataList = orderBasicInfoService.getChargingRealTimeData(orderCode);
|
||||
if (CollectionUtils.isNotEmpty(chargingRealTimeDataList)) {
|
||||
List<OrderDetailInfoVO.RealTimeMonitorData> infoList = Lists.newArrayList();
|
||||
for (RealTimeMonitorData realTimeMonitorData : chargingRealTimeDataList) {
|
||||
OrderDetailInfoVO.RealTimeMonitorData info = new OrderDetailInfoVO.RealTimeMonitorData();
|
||||
info.setInstantCurrent(realTimeMonitorData.getOutputCurrent()); // 电流
|
||||
info.setInstantVoltage(realTimeMonitorData.getOutputVoltage()); // 电压
|
||||
info.setInstantPower(realTimeMonitorData.getOutputPower()); // 功率
|
||||
info.setSOC(realTimeMonitorData.getSOC());
|
||||
info.setTime(realTimeMonitorData.getDateTime()); // 时间
|
||||
infoList.add(info);
|
||||
}
|
||||
|
||||
// 监控信息
|
||||
OrderDetailInfoVO.OrderRealTimeInfo realTimeInfo = new OrderDetailInfoVO.OrderRealTimeInfo();
|
||||
|
||||
RealTimeMonitorData realTimeMonitorData = chargingRealTimeDataList.get(0);
|
||||
realTimeInfo.setOrderAmount(realTimeMonitorData.getChargingAmount());
|
||||
// realTimeInfo.setTotalElectricityAmount();
|
||||
// realTimeInfo.setTotalServiceAmount();
|
||||
realTimeInfo.setChargedDegree(realTimeMonitorData.getChargingDegree());
|
||||
// realTimeInfo.setSOC(realTimeMonitorData.getSOC());
|
||||
realTimeInfo.setChargingTime(realTimeMonitorData.getSumChargingTime());
|
||||
vo.setOrderRealTimeInfo(realTimeInfo);
|
||||
|
||||
// 根据时间进行正序排序
|
||||
infoList = infoList.stream()
|
||||
.sorted(Comparator.comparing(OrderDetailInfoVO.RealTimeMonitorData::getTime))
|
||||
.collect(Collectors.toList());
|
||||
vo.setRealTimeMonitorDataList(infoList);
|
||||
}
|
||||
|
||||
// 支付流水
|
||||
List<OrderPayRecord> orderPayRecordList = orderPayRecordService.getOrderPayRecordList(orderCode);
|
||||
if (CollectionUtils.isNotEmpty(orderPayRecordList)) {
|
||||
OrderPayRecord orderPayRecord = orderPayRecordList.get(0);
|
||||
List<OrderDetailInfoVO.PayRecord> payRecordList = Lists.newArrayList();
|
||||
OrderDetailInfoVO.PayRecord payInfo = new OrderDetailInfoVO.PayRecord();
|
||||
// 余额支付如果是由本金和赠送一起支付的,合并为一个
|
||||
BigDecimal bigDecimal = orderPayRecordList.stream()
|
||||
.map(OrderPayRecord::getPayAmount)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
payInfo.setPayAmount(bigDecimal.toString());
|
||||
payInfo.setPayStatus(orderBasicInfo.getPayStatus());
|
||||
payInfo.setPayTime(DateUtils.formatDateTime(orderBasicInfo.getPayTime()));
|
||||
String payMode = orderPayRecord.getPayMode();
|
||||
if (StringUtils.equals(payMode, OrderPayRecordEnum.PRINCIPAL_BALANCE_PAYMENT.getValue())
|
||||
|| StringUtils.equals(payMode, OrderPayRecordEnum.GIFT_BALANCE_PAYMENT.getValue())) {
|
||||
// 使用余额支付
|
||||
payInfo.setPayMode(OrderPayModeEnum.PAYMENT_OF_BALANCE.getValue());
|
||||
payInfo.setPayModeDesc(OrderPayModeEnum.PAYMENT_OF_BALANCE.getLabel());
|
||||
} else if (StringUtils.equals(payMode, OrderPayRecordEnum.WECHATPAY_PAYMENT.getValue())){
|
||||
// 使用微信支付
|
||||
payInfo.setPayMode(OrderPayModeEnum.PAYMENT_OF_WECHATPAY.getValue());
|
||||
payInfo.setPayModeDesc(OrderPayModeEnum.PAYMENT_OF_WECHATPAY.getLabel());
|
||||
// 查微信支付回调记录
|
||||
WxpayCallbackRecord wxpayCallbackRecord = wxpayCallbackRecordService.selectByOrderCode(orderCode);
|
||||
if (wxpayCallbackRecord != null) {
|
||||
payInfo.setOutTradeNo(wxpayCallbackRecord.getOutTradeNo());
|
||||
payInfo.setTransactionId(wxpayCallbackRecord.getTransactionId());
|
||||
}
|
||||
} else if (StringUtils.equals(payMode, OrderPayRecordEnum.WHITELIST_PAYMENT.getValue())){
|
||||
// 使用白名单支付
|
||||
payInfo.setPayMode(OrderPayModeEnum.PAYMENT_OF_WHITELIST.getValue());
|
||||
payInfo.setPayModeDesc(OrderPayModeEnum.PAYMENT_OF_WHITELIST.getLabel());
|
||||
}
|
||||
payRecordList.add(payInfo);
|
||||
vo.setPayRecordList(payRecordList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 用户信息
|
||||
MemberVO memberVO = memberService.getMemberInfoByMemberId(orderBasicInfo.getMemberId());
|
||||
vo.setMemberInfo(memberVO);
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
public void wechatPayRefundCallback(HttpServletRequest request, WechatPayNotifyParameter body) throws Exception {
|
||||
// 获取微信退款成功返回的信息
|
||||
Map<String, Object> map = wechatPayService.wechatPayRefundCallbackInfo(request, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小程序订单详情
|
||||
* @param orderCode
|
||||
* @return
|
||||
*/
|
||||
public UniAppOrderVO getUniAppOrderDetail(String orderCode) {
|
||||
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
|
||||
if (orderBasicInfo == null) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_QUERY_ORDER_NULL_ERROR);
|
||||
}
|
||||
UniAppOrderVO vo = new UniAppOrderVO();
|
||||
vo.setOrderCode(orderBasicInfo.getOrderCode());
|
||||
vo.setPileSn(orderBasicInfo.getPileSn());
|
||||
vo.setConnectorCode(orderBasicInfo.getConnectorCode());
|
||||
vo.setPileConnectorCode(orderBasicInfo.getPileSn() + orderBasicInfo.getConnectorCode());
|
||||
String orderStatus = orderBasicInfo.getOrderStatus();
|
||||
vo.setOrderStatus(orderStatus);
|
||||
|
||||
// 订单状态描述
|
||||
String orderStatusDescribe;
|
||||
if (StringUtils.equals(orderStatus, OrderStatusEnum.NOT_START.getValue())) {
|
||||
// 未启动还有两种情况 待支付 / 支付成功
|
||||
String payStatus = orderBasicInfo.getPayStatus();
|
||||
if (StringUtils.equals(payStatus, OrderPayStatusEnum.paid.getValue())) {
|
||||
// 支付成功,未启动
|
||||
orderStatusDescribe = OrderPayStatusEnum.paid.getLabel() + ", " + OrderStatusEnum.getOrderStatus(orderStatus);
|
||||
} else {
|
||||
// 待支付
|
||||
orderStatusDescribe = OrderPayStatusEnum.unpaid.getLabel();
|
||||
}
|
||||
} else {
|
||||
orderStatusDescribe = OrderStatusEnum.getOrderStatus(orderStatus);
|
||||
}
|
||||
vo.setOrderStatusDescribe(orderStatusDescribe);
|
||||
|
||||
// 获取充电桩枪口信息
|
||||
PileConnectorDetailVO pileConnectorDetailVO = pileService.queryPileConnectorDetail(vo.getPileConnectorCode());
|
||||
if (pileConnectorDetailVO != null) {
|
||||
vo.setPileConnectorStatus(pileConnectorDetailVO.getConnectorStatus());
|
||||
}
|
||||
|
||||
// 获取订单充电数据
|
||||
List<RealTimeMonitorData> monitorDataList = orderBasicInfoService.getChargingRealTimeData(orderCode);
|
||||
if (CollectionUtils.isNotEmpty(monitorDataList)) {
|
||||
List<UniAppOrderVO.ChargingData> chargingDataList = Lists.newArrayList();
|
||||
UniAppOrderVO.ChargingData data = null;
|
||||
for (int i = 0; i < monitorDataList.size(); i++) {
|
||||
RealTimeMonitorData monitorData = monitorDataList.get(i);
|
||||
data = new UniAppOrderVO.ChargingData();
|
||||
data.setDateTime(monitorData.getDateTime());
|
||||
String outputVoltage = monitorData.getOutputVoltage();
|
||||
data.setOutputVoltage(outputVoltage);
|
||||
String outputCurrent = monitorData.getOutputCurrent();
|
||||
data.setOutputCurrent(outputCurrent);
|
||||
BigDecimal power = new BigDecimal(outputCurrent).multiply(new BigDecimal(outputVoltage))
|
||||
.divide(new BigDecimal("1000"), 2, BigDecimal.ROUND_HALF_UP);
|
||||
data.setPower(power.toString());
|
||||
data.setSOC(monitorData.getSOC());
|
||||
data.setBatteryMaxTemperature(monitorData.getBatteryMaxTemperature());
|
||||
chargingDataList.add(data);
|
||||
// vo中的实时数据,最新一条就取monitorDataList第一个
|
||||
if (i == 0) {
|
||||
vo.setBatteryMaxTemperature(data.getBatteryMaxTemperature());
|
||||
vo.setOutputPower(data.getPower());
|
||||
vo.setOutputCurrent(data.getOutputCurrent());
|
||||
vo.setOutputVoltage(data.getOutputVoltage());
|
||||
vo.setSOC(data.getSOC());
|
||||
BigDecimal chargingAmount = new BigDecimal(monitorData.getChargingAmount()).setScale(2, BigDecimal.ROUND_HALF_UP); // 充电金额
|
||||
vo.setChargingAmount(chargingAmount.toString());
|
||||
BigDecimal chargingDegree = new BigDecimal(monitorData.getChargingDegree()).setScale(2, BigDecimal.ROUND_HALF_UP); // 充电度数
|
||||
vo.setChargingDegree(chargingDegree.toString());
|
||||
vo.setSumChargingTime(monitorData.getSumChargingTime());
|
||||
vo.setTimeRemaining(monitorData.getTimeRemaining());
|
||||
}
|
||||
}
|
||||
// monitorDataList是按照时间倒序的,chargingDataList需要按照时间正序
|
||||
Collections.reverse(chargingDataList);
|
||||
vo.setChargingDataList(chargingDataList);
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据订单号查询充电桩启动状态
|
||||
* @param orderCode
|
||||
* @return
|
||||
*/
|
||||
public String selectPileStarterStatus(String orderCode) {
|
||||
List<RealTimeMonitorData> chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(orderCode);
|
||||
// 只有充电桩上传的实时数据中的状态为充电,才能查到实时数据列表
|
||||
return CollectionUtils.isNotEmpty(chargingRealTimeData) ? Constants.ONE : Constants.ZERO;
|
||||
}
|
||||
|
||||
public void closeStartFailedOrder(QueryOrderDTO dto) {
|
||||
orderBasicInfoService.closeStartFailedOrder(dto.getStartTime(), dto.getEndTime());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
package com.jsowell.service;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.netty.command.ykc.GetRealTimeMonitorDataCommand;
|
||||
import com.jsowell.netty.command.ykc.IssueQRCodeCommand;
|
||||
import com.jsowell.netty.command.ykc.ProofreadTimeCommand;
|
||||
import com.jsowell.netty.command.ykc.PublishPileBillingTemplateCommand;
|
||||
import com.jsowell.netty.command.ykc.RebootCommand;
|
||||
import com.jsowell.netty.command.ykc.StartChargingCommand;
|
||||
import com.jsowell.netty.command.ykc.StopChargingCommand;
|
||||
import com.jsowell.netty.command.ykc.UpdateFileCommand;
|
||||
import com.jsowell.netty.service.yunkuaichong.YKCPushCommandService;
|
||||
import com.jsowell.pile.domain.PileBillingRelation;
|
||||
import com.jsowell.pile.domain.PileBillingTemplate;
|
||||
import com.jsowell.pile.dto.PublishBillingTemplateDTO;
|
||||
import com.jsowell.pile.service.IPileBasicInfoService;
|
||||
import com.jsowell.pile.service.IPileBillingTemplateService;
|
||||
import com.jsowell.pile.vo.web.PileDetailVO;
|
||||
import com.jsowell.pile.vo.web.BillingTemplateVO;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class PileRemoteService {
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private IPileBillingTemplateService pileBillingTemplateService;
|
||||
|
||||
@Autowired
|
||||
private IPileBasicInfoService pileBasicInfoService;
|
||||
|
||||
@Autowired
|
||||
private YKCPushCommandService ykcPushCommandService;
|
||||
|
||||
/**
|
||||
* 获取充电桩实时数据信息
|
||||
*
|
||||
* @param pileSn 充电桩sn
|
||||
* @param connectorCode 枪口号
|
||||
*/
|
||||
public void getRealTimeMonitorData(String pileSn, String connectorCode) {
|
||||
if (StringUtils.isNotEmpty(pileSn) || StringUtils.isNotEmpty(connectorCode)) {
|
||||
GetRealTimeMonitorDataCommand command = GetRealTimeMonitorDataCommand.builder()
|
||||
.pileSn(pileSn)
|
||||
.connectorCode(connectorCode)
|
||||
.build();
|
||||
ykcPushCommandService.pushGetRealTimeMonitorDataCommand(command);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 重启指令
|
||||
*
|
||||
* @param pileSn 充电桩sn
|
||||
*/
|
||||
public void reboot(String pileSn) {
|
||||
RebootCommand command = RebootCommand.builder().pileSn(pileSn).build();
|
||||
ykcPushCommandService.pushRebootCommand(command);
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程启动充电 0x34
|
||||
*
|
||||
* @param pileSn 充电桩sn
|
||||
*/
|
||||
// public void remoteStartCharging(String orderCode, String pileSn, String connectorCode, BigDecimal accountBalance) {
|
||||
// // String s = "550314127823050120180619144446808800000000000101000000100000057300000000D14B0A54A0860100";
|
||||
// if (StringUtils.isEmpty(pileSn) || StringUtils.isEmpty(connectorCode)) {
|
||||
// log.warn("远程启动充电, 充电桩编号和枪口号不能为空");
|
||||
// return;
|
||||
// }
|
||||
// log.info("=====平台下发指令=====: 远程启动充电, 桩号:{}, 枪口号:{}", pileSn, connectorCode);
|
||||
// StartChargingCommand startChargingCommand = StartChargingCommand.builder()
|
||||
// .pileSn(pileSn)
|
||||
// .connectorCode(connectorCode)
|
||||
// .orderCode(orderCode)
|
||||
// .chargeAmount(accountBalance)
|
||||
// .build();
|
||||
// ykcPushCommandService.pushStartChargingCommand(startChargingCommand);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 远程停止充电
|
||||
*/
|
||||
public void remoteStopCharging(String pileSn, String connectorCode) {
|
||||
StopChargingCommand command = StopChargingCommand.builder()
|
||||
.pileSn(pileSn)
|
||||
.connectorCode(connectorCode)
|
||||
.build();
|
||||
ykcPushCommandService.pushStopChargingCommand(command);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下发充电桩二维码
|
||||
*
|
||||
* @param pileSn 充电桩sn
|
||||
*/
|
||||
public void issueQRCode(String pileSn) {
|
||||
IssueQRCodeCommand command = IssueQRCodeCommand.builder().pileSn(pileSn).build();
|
||||
ykcPushCommandService.pushIssueQRCodeCommand(command);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 充电桩对时
|
||||
*
|
||||
* @param pileSn 充电桩sn
|
||||
*/
|
||||
public void proofreadTime(String pileSn) {
|
||||
|
||||
ProofreadTimeCommand command = ProofreadTimeCommand.builder().pileSn(pileSn).build();
|
||||
ykcPushCommandService.pushProofreadTimeCommand(command);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下发充电桩计费模型
|
||||
*/
|
||||
public void publishPileBillingTemplate(String pileSn, BillingTemplateVO billingTemplateVO) {
|
||||
|
||||
PublishPileBillingTemplateCommand command = PublishPileBillingTemplateCommand.builder()
|
||||
.billingTemplateVO(billingTemplateVO)
|
||||
.pileSn(pileSn)
|
||||
.build();
|
||||
ykcPushCommandService.pushPublishPileBillingTemplate(command);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下发计费模板
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public boolean publishBillingTemplate(PublishBillingTemplateDTO dto) {
|
||||
// 获取计费模板信息
|
||||
BillingTemplateVO billingTemplateVO = pileBillingTemplateService.selectBillingTemplateByTemplateId(dto.getTemplateId());
|
||||
if (billingTemplateVO == null) {
|
||||
log.warn("获取计费模板信息, 通过模板id:{}查询计费模板为null", dto.getTemplateId());
|
||||
return false;
|
||||
}
|
||||
// 更新计费模板的发布时间
|
||||
PileBillingTemplate pileBillingTemplate = new PileBillingTemplate();
|
||||
pileBillingTemplate.setId(Long.valueOf(billingTemplateVO.getTemplateId()));
|
||||
pileBillingTemplate.setPublishTime(new Date());
|
||||
pileBillingTemplateService.updatePileBillingTemplate(pileBillingTemplate);
|
||||
|
||||
// 获取到站点下所有的桩
|
||||
List<PileDetailVO> pileList = pileBasicInfoService.selectPileListByStationIds(Lists.newArrayList(Long.valueOf(dto.getStationId())));
|
||||
if (CollectionUtils.isEmpty(pileList)) {
|
||||
log.warn("获取到站点下所有的桩, 通过站点id:{}查询充电桩列表为空", dto.getStationId());
|
||||
return false;
|
||||
}
|
||||
|
||||
// 保存计费模板和桩的关系
|
||||
List<PileBillingRelation> relationList = Lists.newArrayList();
|
||||
for (PileDetailVO pileInfoVO : pileList) {
|
||||
// push
|
||||
publishPileBillingTemplate(pileInfoVO.getPileSn(), billingTemplateVO);
|
||||
|
||||
// 入库
|
||||
relationList.add(PileBillingRelation.builder()
|
||||
.pileSn(pileInfoVO.getPileSn())
|
||||
.billingTemplateCode(billingTemplateVO.getTemplateCode())
|
||||
.stationId(dto.getStationId())
|
||||
.build());
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(relationList)) {
|
||||
pileBillingTemplateService.insertPileBillingRelation(relationList);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
/*Date date = new Date();
|
||||
String encodeCP56Time2a = DateUtils.encodeCP56Time2a(date);
|
||||
System.out.println(encodeCP56Time2a);
|
||||
System.out.println(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, date));
|
||||
|
||||
String decodeCP56Time2a = DateUtils.decodeCP56Time2a(encodeCP56Time2a);
|
||||
System.out.println(decodeCP56Time2a);*/
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程更新
|
||||
*
|
||||
* @param pileSns 前台传的桩号集合
|
||||
*/
|
||||
public void updateFile(List<String> pileSns) {
|
||||
//
|
||||
UpdateFileCommand command = UpdateFileCommand.builder().pileSnList(pileSns).build();
|
||||
ykcPushCommandService.pushUpdateFileCommand(command);
|
||||
}
|
||||
}
|
||||
438
jsowell-admin/src/main/java/com/jsowell/service/PileService.java
Normal file
438
jsowell-admin/src/main/java/com/jsowell/service/PileService.java
Normal file
@@ -0,0 +1,438 @@
|
||||
package com.jsowell.service;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
|
||||
import com.jsowell.common.core.page.PageResponse;
|
||||
import com.jsowell.common.enums.ykc.BusinessTypeEnum;
|
||||
import com.jsowell.common.enums.ykc.OrderStatusEnum;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.response.RestApiResponse;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.SecurityUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.id.SnUtils;
|
||||
import com.jsowell.pile.domain.*;
|
||||
import com.jsowell.pile.dto.BatchCreatePileDTO;
|
||||
import com.jsowell.pile.dto.MemberRegisterAndLoginDTO;
|
||||
import com.jsowell.pile.dto.PileMemberBindingDTO;
|
||||
import com.jsowell.pile.dto.QueryPersonPileDTO;
|
||||
import com.jsowell.pile.service.*;
|
||||
import com.jsowell.pile.transaction.dto.PileTransactionDTO;
|
||||
import com.jsowell.pile.transaction.service.TransactionService;
|
||||
import com.jsowell.pile.vo.base.ConnectorInfoVO;
|
||||
import com.jsowell.pile.vo.base.MerchantInfoVO;
|
||||
import com.jsowell.pile.vo.base.PileInfoVO;
|
||||
import com.jsowell.pile.vo.uniapp.*;
|
||||
import com.jsowell.pile.vo.web.PileStationVO;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class PileService {
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private TransactionService pileTransactionService;
|
||||
|
||||
@Resource
|
||||
private SnUtils snUtils;
|
||||
|
||||
@Autowired
|
||||
private IPileBasicInfoService pileBasicInfoService;
|
||||
|
||||
@Autowired
|
||||
private IPileConnectorInfoService pileConnectorInfoService;
|
||||
|
||||
@Autowired
|
||||
private IPileStationInfoService pileStationInfoService;
|
||||
|
||||
@Autowired
|
||||
private IPileMerchantInfoService pileMerchantInfoService;
|
||||
|
||||
@Autowired
|
||||
private IPileBillingTemplateService pileBillingTemplateService;
|
||||
|
||||
@Autowired
|
||||
private IPileMemberRelationService pileMemberRelationService;
|
||||
|
||||
@Autowired
|
||||
private IMemberBasicInfoService memberBasicInfoService;
|
||||
|
||||
@Autowired
|
||||
private MemberService memberService;
|
||||
|
||||
@Autowired
|
||||
private IOrderBasicInfoService orderBasicInfoService;
|
||||
|
||||
/**
|
||||
* 查询设备信息
|
||||
*
|
||||
* @param pileConnectorCode 充电枪编号 880000000000000101
|
||||
* @return 设备信息集合
|
||||
*/
|
||||
public PileConnectorDetailVO queryPileConnectorDetail(String pileConnectorCode) {
|
||||
return pileBasicInfoService.queryPileConnectorDetail(pileConnectorCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询设备信息
|
||||
*
|
||||
* @param pileSn 充电枪编号 8800000000000001
|
||||
* @param connectorCode 充电枪口号 01
|
||||
* @return 设备信息集合
|
||||
*/
|
||||
public PileConnectorDetailVO queryPileConnectorDetail(String pileSn, String connectorCode) {
|
||||
return queryPileConnectorDetail(pileSn + connectorCode);
|
||||
}
|
||||
|
||||
public int batchCreatePile(BatchCreatePileDTO dto) {
|
||||
// 批量生成sn号
|
||||
List<String> snList = snUtils.generateSN(dto.getNum());
|
||||
|
||||
//
|
||||
List<PileBasicInfo> basicInfoList = Lists.newArrayList();
|
||||
List<PileConnectorInfo> connectorInfoList = Lists.newArrayList();
|
||||
PileBasicInfo basicInfo = null;
|
||||
PileConnectorInfo connectorInfo = null;
|
||||
for (String sn : snList) {
|
||||
// 组装pile_basic_info表数据
|
||||
basicInfo = new PileBasicInfo();
|
||||
basicInfo.setSn(sn); // sn号
|
||||
basicInfo.setBusinessType(BusinessTypeEnum.OPERATING_PILE.getValue()); // 经营类型 默认运营桩
|
||||
basicInfo.setSoftwareProtocol(dto.getSoftwareProtocol()); // 软件协议
|
||||
basicInfo.setMerchantId(Long.valueOf(dto.getMerchantId())); // 运营商id
|
||||
basicInfo.setStationId(Long.valueOf(dto.getStationId())); // 站点id
|
||||
basicInfo.setModelId(Long.valueOf(dto.getModelId())); // 型号id
|
||||
basicInfo.setProductionDate(dto.getProductionDate()); // 生产日期
|
||||
basicInfo.setLicenceId(null); // TODO 证书编号
|
||||
basicInfo.setSimId(null); // TODO sim卡
|
||||
basicInfo.setRemark(dto.getRemark()); // 备注
|
||||
basicInfo.setCreateBy(SecurityUtils.getUsername()); // 创建人
|
||||
basicInfo.setDelFlag(Constants.DEL_FLAG_NORMAL); // 删除标识
|
||||
basicInfoList.add(basicInfo);
|
||||
|
||||
for (int i = 1; i < dto.getConnectorNum() + 1; i++) {
|
||||
// 组装pile_connector_info表数据
|
||||
connectorInfo = new PileConnectorInfo();
|
||||
connectorInfo.setPileSn(sn); // sn号
|
||||
String connectorCode = String.format("%1$02d", i);
|
||||
connectorInfo.setPileConnectorCode(sn + connectorCode); // 枪口号
|
||||
connectorInfo.setStatus(Constants.ZERO); //状态,默认 0-离网
|
||||
connectorInfo.setCreateBy(SecurityUtils.getUsername()); // 创建人
|
||||
connectorInfo.setDelFlag(Constants.DEL_FLAG_NORMAL); // 删除标识
|
||||
connectorInfoList.add(connectorInfo);
|
||||
}
|
||||
}
|
||||
|
||||
// 批量入库
|
||||
PileTransactionDTO transactionDTO = PileTransactionDTO.builder()
|
||||
.pileBasicInfoList(basicInfoList)
|
||||
.pileConnectorInfoList(connectorInfoList)
|
||||
.build();
|
||||
return pileTransactionService.doCreatePileTransaction(transactionDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 前端扫码跳转接口
|
||||
*/
|
||||
public PileConnectorVO getPileDetailByPileSn(String param) throws ExecutionException, InterruptedException {
|
||||
if (StringUtils.isBlank(param)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
String pileSn;
|
||||
if (param.length() == 16) {
|
||||
pileSn = StringUtils.substring(param, 0, param.length() - 2);
|
||||
} else {
|
||||
pileSn = param;
|
||||
}
|
||||
// 查询充电桩信息
|
||||
PileInfoVO pileInfoVO = pileBasicInfoService.selectPileInfoBySn(pileSn);
|
||||
if (pileInfoVO == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 查询充电桩下枪口信息
|
||||
CompletableFuture<List<ConnectorInfoVO>> connectorInfoListFuture = CompletableFuture.supplyAsync(() -> pileConnectorInfoService.selectConnectorInfoList(pileSn));
|
||||
|
||||
// 查计费模板信息
|
||||
CompletableFuture<List<BillingPriceVO>> billingPriceFuture = CompletableFuture.supplyAsync(() -> pileBillingTemplateService.queryBillingPrice(pileInfoVO.getStationId()));
|
||||
|
||||
// 查询站点信息
|
||||
CompletableFuture<PileStationVO> pileStationVOFuture = CompletableFuture.supplyAsync(() -> pileStationInfoService.getStationInfo(pileInfoVO.getStationId()));
|
||||
|
||||
// 查询运营商信息
|
||||
CompletableFuture<MerchantInfoVO> merchantInfoVOFuture = CompletableFuture.supplyAsync(() -> pileMerchantInfoService.getMerchantInfo(pileInfoVO.getMerchantId()));
|
||||
|
||||
CompletableFuture<Void> all = CompletableFuture.allOf(connectorInfoListFuture, pileStationVOFuture, merchantInfoVOFuture, billingPriceFuture);
|
||||
// .join()和.get()都会阻塞并获取线程的执行情况
|
||||
// .join()会抛出未经检查的异常,不会强制开发者处理异常 .get()会抛出检查异常,需要开发者处理
|
||||
all.join();
|
||||
all.get();
|
||||
List<ConnectorInfoVO> connectorInfoList = connectorInfoListFuture.get();
|
||||
PileStationVO pileStationVO = pileStationVOFuture.get();
|
||||
MerchantInfoVO merchantInfoVO = merchantInfoVOFuture.get();
|
||||
List<BillingPriceVO> billingPriceVOS = billingPriceFuture.get();
|
||||
|
||||
PileConnectorVO vo = PileConnectorVO.builder()
|
||||
.pileInfo(pileInfoVO)
|
||||
.connectorInfoList(connectorInfoList)
|
||||
.merchantInfo(merchantInfoVO)
|
||||
.stationInfo(pileStationVO)
|
||||
.billingPriceList(billingPriceVOS)
|
||||
.build();
|
||||
return vo;
|
||||
}
|
||||
|
||||
public PileConnectorVO getConnectorDetail(String pileConnectorCode) throws ExecutionException, InterruptedException {
|
||||
PileConnectorDetailVO pileConnectorDetailVO = queryPileConnectorDetail(pileConnectorCode);
|
||||
if (pileConnectorDetailVO == null) {
|
||||
return null;
|
||||
}
|
||||
String pileSn = pileConnectorDetailVO.getPileSn();
|
||||
PileConnectorVO resultVO = getPileDetailByPileSn(pileSn);
|
||||
List<ConnectorInfoVO> connectorInfoList = resultVO.getConnectorInfoList();
|
||||
if (connectorInfoList.size() > 1) {
|
||||
List<ConnectorInfoVO> list = Lists.newArrayList();
|
||||
// 枪口大于1个,此充电桩非单枪设备,根据参数展示对应枪口的信息
|
||||
for (ConnectorInfoVO connectorInfoVO : connectorInfoList) {
|
||||
if (StringUtils.equals(pileConnectorCode, pileSn + connectorInfoVO.getConnectorCode())) {
|
||||
list.add(connectorInfoVO);
|
||||
}
|
||||
}
|
||||
resultVO.setConnectorInfoList(list);
|
||||
}
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
public PileInfoVO selectPileInfoBySn(String pileSn) {
|
||||
return pileBasicInfoService.selectPileInfoBySn(pileSn);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户绑定个人桩
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public int pileMemberBinding(PileMemberBindingDTO dto){
|
||||
// 校验短信验证码
|
||||
MemberRegisterAndLoginDTO registerAndLoginDTO = MemberRegisterAndLoginDTO.builder()
|
||||
.mobileNumber(dto.getPhoneNumber())
|
||||
.verificationCode(dto.getVerificationCode())
|
||||
.build();
|
||||
memberService.checkVerificationCode(registerAndLoginDTO);
|
||||
|
||||
// 检查桩是否已经被绑定
|
||||
PileMemberRelation pileMemberRelation = new PileMemberRelation();
|
||||
pileMemberRelation.setPileSn(dto.getPileSn());
|
||||
List<PileMemberRelation> list = pileMemberRelationService.selectPileMemberRelationList(pileMemberRelation);
|
||||
if (CollectionUtils.isNotEmpty(list)){
|
||||
// 说明已经被绑定过,抛出异常
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PILE_HAS_BEEN_BINDING_ERROR);
|
||||
}
|
||||
// 如果没被绑定,则此用户为管理员
|
||||
pileMemberRelation.setMemberId(dto.getMemberId());
|
||||
pileMemberRelation.setType("1"); // 1-管理员
|
||||
return pileMemberRelationService.insertPileMemberRelation(pileMemberRelation);
|
||||
}
|
||||
|
||||
/**
|
||||
* 个人桩管理员下发给其他用户使用
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
public void adminIssuePile(PileMemberBindingDTO dto) {
|
||||
List<PileMemberRelation> relationList = pileMemberRelationService.selectPileMemberRelationByPileSn(dto.getPileSn());
|
||||
if (CollectionUtils.isEmpty(relationList)) {
|
||||
// 充电桩没有绑定任何人
|
||||
}
|
||||
|
||||
List<String> adminList = relationList.stream()
|
||||
.filter(x -> x.getType().equals("1"))
|
||||
.map(PileMemberRelation::getMemberId)
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(adminList)) {
|
||||
// 没有管理员
|
||||
}
|
||||
|
||||
// 校验身份
|
||||
if (!adminList.contains(dto.getMemberId())) {
|
||||
// 如果为空,说明此用户身份有误,不是管理员,抛出异常
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_AUTHENTICATION_ERROR);
|
||||
}
|
||||
|
||||
List<String> userList = relationList.stream()
|
||||
.filter(x -> !x.getType().equals("1"))
|
||||
.map(PileMemberRelation::getMemberId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
// 通过前端传的手机号查询是否有此用户
|
||||
MemberBasicInfo memberBasicInfo = memberBasicInfoService.selectInfoByMobileNumber(dto.getPhoneNumber());
|
||||
if (memberBasicInfo == null) {
|
||||
// 为空说明此用户未注册平台账号
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_USER_IS_NOT_REGISTER);
|
||||
}
|
||||
|
||||
if (userList.contains(memberBasicInfo.getMemberId())) {
|
||||
// 不为空说明已绑定
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_USER_HAS_BEEN_THIS_PILE);
|
||||
} else {
|
||||
// 进行绑定,此用户为普通用户
|
||||
PileMemberRelation info = new PileMemberRelation();
|
||||
info.setPileSn(dto.getPileSn());
|
||||
info.setMemberId(memberBasicInfo.getMemberId());
|
||||
info.setType("2");
|
||||
pileMemberRelationService.insertPileMemberRelation(info);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取枪口实时数据
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public PersonPileRealTimeVO getConnectorRealTimeInfo(QueryPersonPileDTO dto) {
|
||||
// 根据memberId查出该用户 正在充电、个人桩启动(白名单支付方式)的订单号
|
||||
OrderBasicInfo orderBasicInfo = OrderBasicInfo.builder()
|
||||
.memberId(dto.getMemberId())
|
||||
.orderStatus(OrderStatusEnum.IN_THE_CHARGING.getValue())
|
||||
.pileConnectorCode(dto.getPileConnectorCode())
|
||||
.startMode("3") // 3- 白名单支付
|
||||
.build();
|
||||
OrderBasicInfo basicInfo = orderBasicInfoService.getOrderBasicInfo(orderBasicInfo);
|
||||
if (basicInfo == null){
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_NO_CHARGING_ORDER_ERROR);
|
||||
}
|
||||
String orderCode = basicInfo.getOrderCode();
|
||||
// 根据订单号从redis中获取实时数据信息(默认时间倒叙排列,所以取第一条)
|
||||
List<RealTimeMonitorData> chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(orderCode);
|
||||
if (CollectionUtils.isEmpty(chargingRealTimeData)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_NO_REAL_TIME_INFO);
|
||||
}
|
||||
RealTimeMonitorData realTimeMonitorData = chargingRealTimeData.get(0);
|
||||
// 将需要的数据set
|
||||
PersonPileRealTimeVO vo = PersonPileRealTimeVO.builder()
|
||||
.chargingDegree(realTimeMonitorData.getChargingDegree())
|
||||
.chargingTime(realTimeMonitorData.getSumChargingTime())
|
||||
.startTime(DateUtils.formatDateTime(orderBasicInfo.getChargeStartTime()))
|
||||
.instantCurrent(realTimeMonitorData.getOutputCurrent())
|
||||
.instantVoltage(realTimeMonitorData.getOutputVoltage())
|
||||
.instantPower(realTimeMonitorData.getOutputPower())
|
||||
.build();
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某枪口某段时间内累计信息
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public PersonPileConnectorSumInfoVO getAccumulativeInfo(QueryPersonPileDTO dto) {
|
||||
List<PersonPileConnectorSumInfoVO> accumulativeInfo = orderBasicInfoService.getAccumulativeInfo(dto);
|
||||
if (CollectionUtils.isEmpty(accumulativeInfo)) {
|
||||
throw new BusinessException("00400011", "未查到相关订单信息!");
|
||||
}
|
||||
// BigDecimal sumChargingTime = BigDecimal.ZERO;
|
||||
// BigDecimal sumUsedElectricity = BigDecimal.ZERO;
|
||||
// // 将返回的结果进行for循环,将总充电量、总充电时长进行累加(充电时长需要通过 充电开始时间 和 充电结束时间 进行计算)
|
||||
// for (PersonPileConnectorSumInfoVO personPileConnectorSumInfoVO : accumulativeInfo) {
|
||||
// if (StringUtils.isNotBlank(personPileConnectorSumInfoVO.getChargeStartTime()) && StringUtils.isNotBlank(personPileConnectorSumInfoVO.getChargeEndTime())){
|
||||
// long longChargingTime = DateUtils.intervalTime(personPileConnectorSumInfoVO.getChargeStartTime(), personPileConnectorSumInfoVO.getChargeEndTime());
|
||||
// BigDecimal chargingTime = new BigDecimal(String.valueOf(longChargingTime));
|
||||
// sumChargingTime = sumChargingTime.add(chargingTime);
|
||||
// }
|
||||
// BigDecimal chargingDegree = StringUtils.isBlank(personPileConnectorSumInfoVO.getSumChargingDegree())
|
||||
// ? BigDecimal.ZERO
|
||||
// : new BigDecimal(personPileConnectorSumInfoVO.getSumChargingDegree());
|
||||
// sumUsedElectricity = sumUsedElectricity.add(chargingDegree);
|
||||
// }
|
||||
Map<String, String> sumInfo = getSumInfo(accumulativeInfo);
|
||||
// set 对象
|
||||
PersonPileConnectorSumInfoVO vo = new PersonPileConnectorSumInfoVO();
|
||||
vo.setStartTime(dto.getStartTime());
|
||||
vo.setEndTime(dto.getEndTime());
|
||||
vo.setMemberId(dto.getMemberId());
|
||||
vo.setSumChargingDegree(sumInfo.get("sumUsedElectricity"));
|
||||
vo.setSumChargingTime(sumInfo.get("sumChargingTime"));
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取充电记录(默认30天)
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
public PageResponse getChargingRecord(QueryPersonPileDTO dto) {
|
||||
int pageNum = dto.getPageNum() == 0 ? 1 : dto.getPageNum();
|
||||
int pageSize = dto.getPageSize() == 0 ? 10 : dto.getPageSize();
|
||||
// 获取三十天前的数据
|
||||
Date date = DateUtils.addMonths(new Date(), -1);
|
||||
String dateStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, date);
|
||||
dto.setStartTime(dateStr);
|
||||
dto.setEndTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, new Date()));
|
||||
|
||||
// 分页查询
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<PersonPileConnectorSumInfoVO> accumulativeInfo = orderBasicInfoService.getAccumulativeInfo(dto);
|
||||
if (CollectionUtils.isEmpty(accumulativeInfo)) {
|
||||
throw new BusinessException("00400011", "未查到相关订单信息!");
|
||||
}
|
||||
PageInfo<PersonPileConnectorSumInfoVO> pageInfo = new PageInfo<>(accumulativeInfo);
|
||||
for (PersonPileConnectorSumInfoVO personPileConnectorSumInfoVO : pageInfo.getList()) {
|
||||
if (StringUtils.isNotBlank(personPileConnectorSumInfoVO.getChargeStartTime()) && StringUtils.isNotBlank(personPileConnectorSumInfoVO.getChargeEndTime())){
|
||||
String datePoor = DateUtils.getDatePoor(DateUtils.parseDate(personPileConnectorSumInfoVO.getChargeEndTime()),
|
||||
DateUtils.parseDate(personPileConnectorSumInfoVO.getChargeStartTime()));
|
||||
personPileConnectorSumInfoVO.setSumChargingTime(datePoor);
|
||||
}
|
||||
}
|
||||
return PageResponse.builder()
|
||||
.pageNum(pageInfo.getPageNum())
|
||||
.pageSize(pageInfo.getPageSize())
|
||||
.list(pageInfo.getList())
|
||||
.pages(pageInfo.getPages())
|
||||
.total(pageInfo.getTotal())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取总充电时长、总充电量
|
||||
*
|
||||
* @param accumulativeInfo
|
||||
* @return
|
||||
*/
|
||||
private Map<String, String> getSumInfo(List<PersonPileConnectorSumInfoVO> accumulativeInfo){
|
||||
Map<String, String> resultMap = new HashMap<>();
|
||||
BigDecimal sumChargingTime = BigDecimal.ZERO;
|
||||
BigDecimal sumUsedElectricity = BigDecimal.ZERO;
|
||||
// 将返回的结果进行for循环,将总充电量、总充电时长进行累加(充电时长需要通过 充电开始时间 和 充电结束时间 进行计算)
|
||||
for (PersonPileConnectorSumInfoVO personPileConnectorSumInfoVO : accumulativeInfo) {
|
||||
if (StringUtils.isNotBlank(personPileConnectorSumInfoVO.getChargeStartTime()) && StringUtils.isNotBlank(personPileConnectorSumInfoVO.getChargeEndTime())){
|
||||
long longChargingTime = DateUtils.intervalTime(personPileConnectorSumInfoVO.getChargeStartTime(), personPileConnectorSumInfoVO.getChargeEndTime());
|
||||
BigDecimal chargingTime = new BigDecimal(String.valueOf(longChargingTime));
|
||||
sumChargingTime = sumChargingTime.add(chargingTime);
|
||||
}
|
||||
BigDecimal chargingDegree = StringUtils.isBlank(personPileConnectorSumInfoVO.getSumChargingDegree())
|
||||
? BigDecimal.ZERO
|
||||
: new BigDecimal(personPileConnectorSumInfoVO.getSumChargingDegree());
|
||||
sumUsedElectricity = sumUsedElectricity.add(chargingDegree);
|
||||
}
|
||||
resultMap.put("sumChargingTime", String.valueOf(sumChargingTime));
|
||||
resultMap.put("sumUsedElectricity", String.valueOf(sumUsedElectricity));
|
||||
return resultMap;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.jsowell.web.controller.common;
|
||||
|
||||
import com.google.code.kaptcha.Producer;
|
||||
import com.jsowell.common.config.JsowellConfig;
|
||||
import com.jsowell.common.constant.CacheConstants;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.common.util.sign.Base64;
|
||||
import com.jsowell.common.util.id.IdUtils;
|
||||
import com.jsowell.system.service.SysConfigService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.FastByteArrayOutputStream;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 验证码操作处理
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@RestController
|
||||
public class CaptchaController {
|
||||
@Resource(name = "captchaProducer")
|
||||
private Producer captchaProducer;
|
||||
|
||||
@Resource(name = "captchaProducerMath")
|
||||
private Producer captchaProducerMath;
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
@Autowired
|
||||
private SysConfigService configService;
|
||||
|
||||
Logger log = LoggerFactory.getLogger(CaptchaController.class);
|
||||
|
||||
/**
|
||||
* 生成验证码
|
||||
*/
|
||||
@GetMapping("/captchaImage")
|
||||
public AjaxResult getCode(HttpServletResponse response) throws IOException {
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
boolean captchaEnabled = configService.selectCaptchaEnabled();
|
||||
ajax.put("captchaEnabled", captchaEnabled);
|
||||
if (!captchaEnabled) {
|
||||
return ajax;
|
||||
}
|
||||
|
||||
// 保存验证码信息
|
||||
String uuid = IdUtils.simpleUUID();
|
||||
String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + uuid;
|
||||
|
||||
String capStr = null, code = null;
|
||||
BufferedImage image = null;
|
||||
|
||||
// 生成验证码
|
||||
String captchaType = JsowellConfig.getCaptchaType();
|
||||
if ("math".equals(captchaType)) {
|
||||
String capText = captchaProducerMath.createText();
|
||||
capStr = capText.substring(0, capText.lastIndexOf("@"));
|
||||
code = capText.substring(capText.lastIndexOf("@") + 1);
|
||||
image = captchaProducerMath.createImage(capStr);
|
||||
} else if ("char".equals(captchaType)) {
|
||||
capStr = code = captchaProducer.createText();
|
||||
image = captchaProducer.createImage(capStr);
|
||||
}
|
||||
log.info("获取验证码 uuid:{}, captcha:{}", uuid, capStr);
|
||||
redisCache.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
|
||||
// 转换流信息写出
|
||||
FastByteArrayOutputStream os = new FastByteArrayOutputStream();
|
||||
try {
|
||||
ImageIO.write(image, "jpg", os);
|
||||
} catch (IOException e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
|
||||
ajax.put("uuid", uuid);
|
||||
ajax.put("img", Base64.encode(os.toByteArray()));
|
||||
return ajax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package com.jsowell.web.controller.common;
|
||||
|
||||
import com.jsowell.common.config.JsowellConfig;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.file.FileUploadUtils;
|
||||
import com.jsowell.common.util.file.FileUtils;
|
||||
import com.jsowell.framework.config.ServerConfig;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 通用请求处理
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/common")
|
||||
public class CommonController {
|
||||
private static final Logger log = LoggerFactory.getLogger(CommonController.class);
|
||||
|
||||
@Autowired
|
||||
private ServerConfig serverConfig;
|
||||
|
||||
private static final String FILE_DELIMETER = ",";
|
||||
|
||||
/**
|
||||
* 通用下载请求
|
||||
*
|
||||
* @param fileName 文件名称
|
||||
* @param delete 是否删除
|
||||
*/
|
||||
@GetMapping("/download")
|
||||
public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request) {
|
||||
try {
|
||||
if (!FileUtils.checkAllowDownload(fileName)) {
|
||||
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
|
||||
}
|
||||
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
|
||||
String filePath = JsowellConfig.getDownloadPath() + fileName;
|
||||
|
||||
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||
FileUtils.setAttachmentResponseHeader(response, realFileName);
|
||||
FileUtils.writeBytes(filePath, response.getOutputStream());
|
||||
if (delete) {
|
||||
FileUtils.deleteFile(filePath);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("下载文件失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用上传请求(单个)
|
||||
*/
|
||||
@PostMapping("/upload")
|
||||
public AjaxResult uploadFile(MultipartFile file) throws Exception {
|
||||
try {
|
||||
// 上传文件路径
|
||||
String filePath = JsowellConfig.getUploadPath();
|
||||
// 上传并返回新文件名称
|
||||
String fileName = FileUploadUtils.upload(filePath, file);
|
||||
String url = serverConfig.getUrl() + fileName;
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("url", url);
|
||||
ajax.put("fileName", fileName);
|
||||
ajax.put("newFileName", FileUtils.getName(fileName));
|
||||
ajax.put("originalFilename", file.getOriginalFilename());
|
||||
return ajax;
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用上传请求(多个)
|
||||
*/
|
||||
@PostMapping("/uploads")
|
||||
public AjaxResult uploadFiles(List<MultipartFile> files) throws Exception {
|
||||
try {
|
||||
// 上传文件路径
|
||||
String filePath = JsowellConfig.getUploadPath();
|
||||
List<String> urls = new ArrayList<String>();
|
||||
List<String> fileNames = new ArrayList<String>();
|
||||
List<String> newFileNames = new ArrayList<String>();
|
||||
List<String> originalFilenames = new ArrayList<String>();
|
||||
for (MultipartFile file : files) {
|
||||
// 上传并返回新文件名称
|
||||
String fileName = FileUploadUtils.upload(filePath, file);
|
||||
String url = serverConfig.getUrl() + fileName;
|
||||
urls.add(url);
|
||||
fileNames.add(fileName);
|
||||
newFileNames.add(FileUtils.getName(fileName));
|
||||
originalFilenames.add(file.getOriginalFilename());
|
||||
}
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("urls", StringUtils.join(urls, FILE_DELIMETER));
|
||||
ajax.put("fileNames", StringUtils.join(fileNames, FILE_DELIMETER));
|
||||
ajax.put("newFileNames", StringUtils.join(newFileNames, FILE_DELIMETER));
|
||||
ajax.put("originalFilenames", StringUtils.join(originalFilenames, FILE_DELIMETER));
|
||||
return ajax;
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地资源通用下载
|
||||
*/
|
||||
@GetMapping("/download/resource")
|
||||
public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response)
|
||||
throws Exception {
|
||||
try {
|
||||
if (!FileUtils.checkAllowDownload(resource)) {
|
||||
throw new Exception(StringUtils.format("资源文件({})非法,不允许下载。 ", resource));
|
||||
}
|
||||
// 本地资源路径
|
||||
String localPath = JsowellConfig.getProfile();
|
||||
// 数据库资源地址
|
||||
String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX);
|
||||
// 下载名称
|
||||
String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
|
||||
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||
FileUtils.setAttachmentResponseHeader(response, downloadName);
|
||||
FileUtils.writeBytes(downloadPath, response.getOutputStream());
|
||||
} catch (Exception e) {
|
||||
log.error("下载文件失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.jsowell.web.controller.index;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.response.RestApiResponse;
|
||||
import com.jsowell.pile.service.IOrderBasicInfoService;
|
||||
import com.jsowell.pile.vo.web.IndexGeneralSituationVO;
|
||||
import com.jsowell.pile.dto.IndexQueryDTO;
|
||||
import com.jsowell.pile.service.IPileBasicInfoService;
|
||||
import com.jsowell.pile.vo.web.IndexOrderInfoVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 首页数据展示Controller
|
||||
*
|
||||
* @author JS-ZZA
|
||||
* @date 2023/2/3 10:11
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/index")
|
||||
public class indexController extends BaseController {
|
||||
@Autowired
|
||||
IPileBasicInfoService pileBasicInfoService;
|
||||
|
||||
@Autowired
|
||||
IOrderBasicInfoService orderBasicInfoService;
|
||||
|
||||
@PostMapping("/getGeneralSituation")
|
||||
public RestApiResponse<?> getGeneralSituation(@RequestBody IndexQueryDTO dto) {
|
||||
logger.info("首页基础数据查询 param:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
IndexGeneralSituationVO generalSituation = pileBasicInfoService.getGeneralSituation(dto);
|
||||
response = new RestApiResponse<>(generalSituation);
|
||||
}catch (Exception e) {
|
||||
logger.error("首页数据查询错误:{}", e.getMessage());
|
||||
response = new RestApiResponse<>("00200001", "首页基础数据查询错误");
|
||||
}
|
||||
logger.info("首页数据查询 result:{}", JSONObject.toJSONString(response));
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页订单数据汇总信息
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getOrderInfo")
|
||||
public RestApiResponse<?> getOrderInfo(@RequestBody IndexQueryDTO dto) {
|
||||
logger.info("首页订单相关信息查询 param:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
List<IndexOrderInfoVO> indexOrderInfo = orderBasicInfoService.getIndexOrderInfo(dto);
|
||||
response = new RestApiResponse<>(indexOrderInfo);
|
||||
} catch (Exception e) {
|
||||
logger.error("首页订单相关信息查询错误!{}", e.getMessage());
|
||||
response = new RestApiResponse<>("00200002", "首页订单数据查询错误");
|
||||
}
|
||||
logger.info("首页订单相关信息查询 result:{}", JSONObject.toJSONString(response));
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.jsowell.web.controller.monitor;
|
||||
|
||||
import com.jsowell.common.constant.CacheConstants;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.system.domain.SysCache;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisCallback;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 缓存监控
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/monitor/cache")
|
||||
public class CacheController {
|
||||
@Autowired
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
|
||||
private final static List<SysCache> caches = new ArrayList<SysCache>();
|
||||
|
||||
{
|
||||
caches.add(new SysCache(CacheConstants.LOGIN_TOKEN_KEY, "用户信息"));
|
||||
caches.add(new SysCache(CacheConstants.SYS_CONFIG_KEY, "配置信息"));
|
||||
caches.add(new SysCache(CacheConstants.SYS_DICT_KEY, "数据字典"));
|
||||
caches.add(new SysCache(CacheConstants.CAPTCHA_CODE_KEY, "验证码"));
|
||||
caches.add(new SysCache(CacheConstants.REPEAT_SUBMIT_KEY, "防重提交"));
|
||||
caches.add(new SysCache(CacheConstants.RATE_LIMIT_KEY, "限流处理"));
|
||||
caches.add(new SysCache(CacheConstants.PWD_ERR_CNT_KEY, "密码错误次数"));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||
@GetMapping()
|
||||
public AjaxResult getInfo() throws Exception {
|
||||
Properties info = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info());
|
||||
Properties commandStats = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info("commandstats"));
|
||||
Object dbSize = redisTemplate.execute((RedisCallback<Object>) connection -> connection.dbSize());
|
||||
|
||||
Map<String, Object> result = new HashMap<>(3);
|
||||
result.put("info", info);
|
||||
result.put("dbSize", dbSize);
|
||||
|
||||
List<Map<String, String>> pieList = new ArrayList<>();
|
||||
commandStats.stringPropertyNames().forEach(key -> {
|
||||
Map<String, String> data = new HashMap<>(2);
|
||||
String property = commandStats.getProperty(key);
|
||||
data.put("name", StringUtils.removeStart(key, "cmdstat_"));
|
||||
data.put("value", StringUtils.substringBetween(property, "calls=", ",usec"));
|
||||
pieList.add(data);
|
||||
});
|
||||
result.put("commandStats", pieList);
|
||||
return AjaxResult.success(result);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||
@GetMapping("/getNames")
|
||||
public AjaxResult cache() {
|
||||
return AjaxResult.success(caches);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||
@GetMapping("/getKeys/{cacheName}")
|
||||
public AjaxResult getCacheKeys(@PathVariable String cacheName) {
|
||||
Set<String> cacheKeys = redisTemplate.keys(cacheName + "*");
|
||||
return AjaxResult.success(cacheKeys);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||
@GetMapping("/getValue/{cacheName}/{cacheKey}")
|
||||
public AjaxResult getCacheValue(@PathVariable String cacheName, @PathVariable String cacheKey) {
|
||||
String cacheValue = redisTemplate.opsForValue().get(cacheKey);
|
||||
SysCache sysCache = new SysCache(cacheName, cacheKey, cacheValue);
|
||||
return AjaxResult.success(sysCache);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||
@DeleteMapping("/clearCacheName/{cacheName}")
|
||||
public AjaxResult clearCacheName(@PathVariable String cacheName) {
|
||||
Collection<String> cacheKeys = redisTemplate.keys(cacheName + "*");
|
||||
redisTemplate.delete(cacheKeys);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||
@DeleteMapping("/clearCacheKey/{cacheKey}")
|
||||
public AjaxResult clearCacheKey(@PathVariable String cacheKey) {
|
||||
redisTemplate.delete(cacheKey);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||
@DeleteMapping("/clearCacheAll")
|
||||
public AjaxResult clearCacheAll() {
|
||||
Collection<String> cacheKeys = redisTemplate.keys("*");
|
||||
redisTemplate.delete(cacheKeys);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.jsowell.web.controller.monitor;
|
||||
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.framework.web.domain.Server;
|
||||
|
||||
/**
|
||||
* 服务器监控
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/monitor/server")
|
||||
public class ServerController {
|
||||
@PreAuthorize("@ss.hasPermi('monitor:server:list')")
|
||||
@GetMapping()
|
||||
public AjaxResult getInfo() throws Exception {
|
||||
Server server = new Server();
|
||||
server.copyTo();
|
||||
return AjaxResult.success(server);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.jsowell.web.controller.monitor;
|
||||
|
||||
import com.jsowell.common.annotation.Log;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.core.page.TableDataInfo;
|
||||
import com.jsowell.common.enums.BusinessType;
|
||||
import com.jsowell.common.util.poi.ExcelUtil;
|
||||
import com.jsowell.framework.web.service.SysPasswordService;
|
||||
import com.jsowell.system.domain.SysLogininfor;
|
||||
import com.jsowell.system.service.SysLogininforService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统访问记录
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/monitor/logininfor")
|
||||
public class SysLogininforController extends BaseController {
|
||||
@Autowired
|
||||
private SysLogininforService logininforService;
|
||||
|
||||
@Autowired
|
||||
private SysPasswordService passwordService;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysLogininfor logininfor) {
|
||||
startPage();
|
||||
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:export')")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysLogininfor logininfor) {
|
||||
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
||||
ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
|
||||
util.exportExcel(response, list, "登录日志");
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
|
||||
@Log(title = "登录日志", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{infoIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] infoIds) {
|
||||
return toAjax(logininforService.deleteLogininforByIds(infoIds));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
|
||||
@Log(title = "登录日志", businessType = BusinessType.CLEAN)
|
||||
@DeleteMapping("/clean")
|
||||
public AjaxResult clean() {
|
||||
logininforService.cleanLogininfor();
|
||||
return success();
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:unlock')")
|
||||
@Log(title = "账户解锁", businessType = BusinessType.OTHER)
|
||||
@GetMapping("/unlock/{userName}")
|
||||
public AjaxResult unlock(@PathVariable("userName") String userName) {
|
||||
passwordService.clearLoginRecordCache(userName);
|
||||
return success();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.jsowell.web.controller.monitor;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.jsowell.common.annotation.Log;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.core.page.TableDataInfo;
|
||||
import com.jsowell.common.enums.BusinessType;
|
||||
import com.jsowell.common.util.poi.ExcelUtil;
|
||||
import com.jsowell.system.domain.SysOperLog;
|
||||
import com.jsowell.system.service.SysOperLogService;
|
||||
|
||||
/**
|
||||
* 操作日志记录
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/monitor/operlog")
|
||||
public class SysOperlogController extends BaseController {
|
||||
@Autowired
|
||||
private SysOperLogService operLogService;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysOperLog operLog) {
|
||||
startPage();
|
||||
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@Log(title = "操作日志", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:export')")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysOperLog operLog) {
|
||||
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
||||
ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
|
||||
util.exportExcel(response, list, "操作日志");
|
||||
}
|
||||
|
||||
@Log(title = "操作日志", businessType = BusinessType.DELETE)
|
||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
|
||||
@DeleteMapping("/{operIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] operIds) {
|
||||
return toAjax(operLogService.deleteOperLogByIds(operIds));
|
||||
}
|
||||
|
||||
@Log(title = "操作日志", businessType = BusinessType.CLEAN)
|
||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
|
||||
@DeleteMapping("/clean")
|
||||
public AjaxResult clean() {
|
||||
operLogService.cleanOperLog();
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.jsowell.web.controller.monitor;
|
||||
|
||||
import com.jsowell.common.annotation.Log;
|
||||
import com.jsowell.common.constant.CacheConstants;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.core.domain.model.LoginUser;
|
||||
import com.jsowell.common.core.page.TableDataInfo;
|
||||
import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.common.enums.BusinessType;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.system.domain.SysUserOnline;
|
||||
import com.jsowell.system.service.SysUserOnlineService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 在线用户监控
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/monitor/online")
|
||||
public class SysUserOnlineController extends BaseController {
|
||||
@Autowired
|
||||
private SysUserOnlineService userOnlineService;
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:online:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(String ipaddr, String userName) {
|
||||
Collection<String> keys = redisCache.keys(CacheConstants.LOGIN_TOKEN_KEY + "*");
|
||||
List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>();
|
||||
for (String key : keys) {
|
||||
LoginUser user = redisCache.getCacheObject(key);
|
||||
if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName)) {
|
||||
if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername())) {
|
||||
userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user));
|
||||
}
|
||||
} else if (StringUtils.isNotEmpty(ipaddr)) {
|
||||
if (StringUtils.equals(ipaddr, user.getIpaddr())) {
|
||||
userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user));
|
||||
}
|
||||
} else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser())) {
|
||||
if (StringUtils.equals(userName, user.getUsername())) {
|
||||
userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user));
|
||||
}
|
||||
} else {
|
||||
userOnlineList.add(userOnlineService.loginUserToUserOnline(user));
|
||||
}
|
||||
}
|
||||
Collections.reverse(userOnlineList);
|
||||
userOnlineList.removeAll(Collections.singleton(null));
|
||||
return getDataTable(userOnlineList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 强退用户
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('monitor:online:forceLogout')")
|
||||
@Log(title = "在线用户", businessType = BusinessType.FORCE)
|
||||
@DeleteMapping("/{tokenId}")
|
||||
public AjaxResult forceLogout(@PathVariable String tokenId) {
|
||||
redisCache.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + tokenId);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
package com.jsowell.web.controller.pile;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.jsowell.common.annotation.Log;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.core.page.TableDataInfo;
|
||||
import com.jsowell.common.enums.BusinessType;
|
||||
import com.jsowell.common.enums.uniapp.BalanceChangesEnum;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.domain.MemberBasicInfo;
|
||||
import com.jsowell.pile.dto.UniAppQueryMemberBalanceDTO;
|
||||
import com.jsowell.pile.service.IMemberBasicInfoService;
|
||||
import com.jsowell.pile.service.IMemberTransactionRecordService;
|
||||
import com.jsowell.pile.vo.uniapp.MemberVO;
|
||||
import com.jsowell.pile.vo.uniapp.MemberWalletLogVO;
|
||||
import com.jsowell.pile.vo.web.MemberTransactionVO;
|
||||
import com.jsowell.pile.vo.web.UpdateMemberBalanceDTO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 会员基础信息Controller
|
||||
*
|
||||
* @author jsowell
|
||||
* @date 2022-10-12
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/member/info")
|
||||
public class MemberBasicInfoController extends BaseController {
|
||||
@Autowired
|
||||
private IMemberBasicInfoService memberBasicInfoService;
|
||||
|
||||
@Autowired
|
||||
private IMemberTransactionRecordService memberTransactionRecordService;
|
||||
|
||||
/**
|
||||
* 查询会员基础信息列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('member:info:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(MemberBasicInfo memberBasicInfo) {
|
||||
startPage();
|
||||
List<MemberVO> list = memberBasicInfoService.selectMemberList(memberBasicInfo.getMobileNumber(), memberBasicInfo.getNickName());
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出会员基础信息列表
|
||||
*/
|
||||
/*@PreAuthorize("@ss.hasPermi('member:info:export')")
|
||||
@Log(title = "会员基础信息", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, MemberBasicInfo memberBasicInfo) {
|
||||
List<MemberBasicInfo> list = memberBasicInfoService.selectMemberBasicInfoList(memberBasicInfo);
|
||||
ExcelUtil<MemberBasicInfo> util = new ExcelUtil<MemberBasicInfo>(MemberBasicInfo.class);
|
||||
util.exportExcel(response, list, "会员基础信息数据");
|
||||
}*/
|
||||
|
||||
/**
|
||||
* 获取会员基础信息详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('member:info:query')")
|
||||
@GetMapping(value = "/{memberId}")
|
||||
public AjaxResult getInfo(@PathVariable("memberId") String memberId) {
|
||||
return AjaxResult.success(memberBasicInfoService.queryMemberInfoByMemberId(memberId));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('member:info:query')")
|
||||
@GetMapping(value = "/getMemberPersonPileInfo/{memberId}")
|
||||
public AjaxResult getMemberPersonPileInfo(@PathVariable("memberId") String memberId){
|
||||
return AjaxResult.success(memberBasicInfoService.getMemberPersonPileInfo(memberId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增会员基础信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('member:info:add')")
|
||||
@Log(title = "会员基础信息", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody MemberBasicInfo memberBasicInfo) {
|
||||
return toAjax(memberBasicInfoService.insertMemberBasicInfo(memberBasicInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改会员基础信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('member:info:edit')")
|
||||
@Log(title = "会员基础信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody MemberBasicInfo memberBasicInfo) {
|
||||
return toAjax(memberBasicInfoService.updateMemberBasicInfo(memberBasicInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除会员基础信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('member:info:remove')")
|
||||
@Log(title = "会员基础信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Integer[] ids) {
|
||||
return toAjax(memberBasicInfoService.deleteMemberBasicInfoByIds(Lists.newArrayList(ids)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 充值/扣款余额
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('member:balance:update')")
|
||||
@Log(title = "会员充值/扣款余额", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/updateGiftBalance")
|
||||
public AjaxResult updateGiftBalance(@RequestBody UpdateMemberBalanceDTO dto) {
|
||||
logger.info("后管充值/扣款余额 param:{}", dto.toString());
|
||||
// 判断入参
|
||||
return toAjax(memberBasicInfoService.updateMemberBalance(dto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询会员钱包流水
|
||||
*/
|
||||
@PostMapping("/queryMemberBalanceChanges")
|
||||
public TableDataInfo queryMemberBalanceChanges(@RequestBody UniAppQueryMemberBalanceDTO dto) {
|
||||
String type = dto.getType();
|
||||
if (!StringUtils.equals("1", type) && !StringUtils.equals("2", type)) {
|
||||
type = "";
|
||||
}
|
||||
PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
|
||||
List<MemberWalletLogVO> list = memberBasicInfoService.getMemberBalanceChanges(dto.getMemberId(), type);
|
||||
for (MemberWalletLogVO walletLogVO : list) {
|
||||
String subType = walletLogVO.getSubType();
|
||||
String subTypeValue = BalanceChangesEnum.getValueByCode(subType);
|
||||
if (StringUtils.isNotBlank(subTypeValue)) {
|
||||
walletLogVO.setSubType(subTypeValue);
|
||||
}
|
||||
}
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询会员交易流水
|
||||
* IMemberTransactionRecordService
|
||||
*/
|
||||
@PostMapping("/selectMemberTransactionRecordList")
|
||||
public TableDataInfo selectMemberTransactionRecordList(@RequestBody UniAppQueryMemberBalanceDTO dto) {
|
||||
startPage();
|
||||
List<MemberTransactionVO> list = memberTransactionRecordService.selectMemberTransactionRecordList(dto.getMemberId());
|
||||
return getDataTable(list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.jsowell.web.controller.pile;
|
||||
|
||||
import com.jsowell.common.annotation.Log;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.core.page.TableDataInfo;
|
||||
import com.jsowell.common.enums.BusinessType;
|
||||
import com.jsowell.common.util.poi.ExcelUtil;
|
||||
import com.jsowell.pile.domain.OrderAbnormalRecord;
|
||||
import com.jsowell.pile.service.IOrderAbnormalRecordService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单异常记录Controller
|
||||
*
|
||||
* @author jsowell
|
||||
* @date 2023-02-13
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/order/abnormalRecord")
|
||||
public class OrderAbnormalRecordController extends BaseController {
|
||||
@Autowired
|
||||
private IOrderAbnormalRecordService orderAbnormalRecordService;
|
||||
|
||||
/**
|
||||
* 查询订单异常记录列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('order:abnormalRecord:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(OrderAbnormalRecord orderAbnormalRecord) {
|
||||
startPage();
|
||||
List<OrderAbnormalRecord> list = orderAbnormalRecordService.selectOrderAbnormalRecordList(orderAbnormalRecord);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出订单异常记录列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('order:abnormalRecord:export')")
|
||||
@Log(title = "订单异常记录", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, OrderAbnormalRecord orderAbnormalRecord) {
|
||||
List<OrderAbnormalRecord> list = orderAbnormalRecordService.selectOrderAbnormalRecordList(orderAbnormalRecord);
|
||||
ExcelUtil<OrderAbnormalRecord> util = new ExcelUtil<OrderAbnormalRecord>(OrderAbnormalRecord.class);
|
||||
util.exportExcel(response, list, "订单异常记录数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单异常记录详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('order:abnormalRecord:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Integer id) {
|
||||
return AjaxResult.success(orderAbnormalRecordService.selectOrderAbnormalRecordById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增订单异常记录
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('order:abnormalRecord:add')")
|
||||
@Log(title = "订单异常记录", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody OrderAbnormalRecord orderAbnormalRecord) {
|
||||
return toAjax(orderAbnormalRecordService.insertOrderAbnormalRecord(orderAbnormalRecord));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改订单异常记录
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('order:abnormalRecord:edit')")
|
||||
@Log(title = "订单异常记录", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody OrderAbnormalRecord orderAbnormalRecord) {
|
||||
return toAjax(orderAbnormalRecordService.updateOrderAbnormalRecord(orderAbnormalRecord));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除订单异常记录
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('order:abnormalRecord:remove')")
|
||||
@Log(title = "订单异常记录", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Integer[] ids) {
|
||||
return toAjax(orderAbnormalRecordService.deleteOrderAbnormalRecordByIds(ids));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.jsowell.web.controller.pile;
|
||||
|
||||
import com.jsowell.common.annotation.Log;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.core.page.TableDataInfo;
|
||||
import com.jsowell.common.enums.BusinessType;
|
||||
import com.jsowell.common.util.poi.ExcelUtil;
|
||||
import com.jsowell.pile.domain.OrderBasicInfo;
|
||||
import com.jsowell.pile.dto.QueryOrderDTO;
|
||||
import com.jsowell.pile.service.IOrderBasicInfoService;
|
||||
import com.jsowell.pile.vo.web.OrderListVO;
|
||||
import com.jsowell.service.OrderService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单Controller
|
||||
*
|
||||
* @author jsowell
|
||||
* @date 2022-09-30
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/order")
|
||||
public class OrderBasicInfoController extends BaseController {
|
||||
@Autowired
|
||||
private IOrderBasicInfoService orderBasicInfoService;
|
||||
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
|
||||
/**
|
||||
* 查询订单列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('order:order:list')")
|
||||
@GetMapping("/order/list")
|
||||
public TableDataInfo list(QueryOrderDTO orderBasicInfo) {
|
||||
startPage();
|
||||
List<OrderListVO> list = orderBasicInfoService.selectOrderBasicInfoList(orderBasicInfo);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据参数查询用电度数和消费金额
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('order:order:list')")
|
||||
@GetMapping("/order/totalData")
|
||||
public AjaxResult getOrderTotalData(QueryOrderDTO orderBasicInfo) {
|
||||
return AjaxResult.success(orderBasicInfoService.getOrderTotalData(orderBasicInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出订单列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('order:order:export')")
|
||||
@Log(title = "订单", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/order/export")
|
||||
public void export(HttpServletResponse response, QueryOrderDTO orderBasicInfo) {
|
||||
List<OrderListVO> list = orderBasicInfoService.selectOrderBasicInfoList(orderBasicInfo);
|
||||
ExcelUtil<OrderListVO> util = new ExcelUtil<OrderListVO>(OrderListVO.class);
|
||||
util.exportExcel(response, list, "订单数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单详细信息
|
||||
* http://localhost:8080/order/orderDetail/88000000000001012211161342359448
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('order:order:query')")
|
||||
@GetMapping(value = "/orderDetail/{orderCode}")
|
||||
public AjaxResult getInfo(@PathVariable("orderCode") String orderCode) {
|
||||
return AjaxResult.success(orderService.queryOrderDetailInfo(orderCode));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改订单 后管调用
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('order:order:edit')")
|
||||
@Log(title = "订单", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/order")
|
||||
public AjaxResult edit(@RequestBody OrderBasicInfo orderBasicInfo) {
|
||||
return toAjax(orderBasicInfoService.updateOrderBasicInfo(orderBasicInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除订单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('order:order:remove')")
|
||||
@Log(title = "订单", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/order/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(orderBasicInfoService.deleteOrderBasicInfoByIds(ids));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
package com.jsowell.web.controller.pile;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.jsowell.common.annotation.Log;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.core.page.TableDataInfo;
|
||||
import com.jsowell.common.enums.BusinessType;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.poi.ExcelUtil;
|
||||
import com.jsowell.pile.domain.PileBasicInfo;
|
||||
import com.jsowell.pile.dto.BatchCreatePileDTO;
|
||||
import com.jsowell.pile.dto.QueryPileDTO;
|
||||
import com.jsowell.pile.dto.ReplaceMerchantStationDTO;
|
||||
import com.jsowell.pile.service.IPileBasicInfoService;
|
||||
import com.jsowell.pile.service.IPileMsgRecordService;
|
||||
import com.jsowell.pile.vo.web.PileDetailVO;
|
||||
import com.jsowell.service.PileService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设备管理Controller
|
||||
*
|
||||
* @author jsowell
|
||||
* @date 2022-08-26
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/pile/basic")
|
||||
public class PileBasicInfoController extends BaseController {
|
||||
@Autowired
|
||||
private IPileBasicInfoService pileBasicInfoService;
|
||||
|
||||
@Autowired
|
||||
private PileService pileService;
|
||||
|
||||
@Autowired
|
||||
private IPileMsgRecordService pileMsgRecordService;
|
||||
/**
|
||||
* 查询设备管理列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:basic:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(QueryPileDTO queryPileDTO) {
|
||||
// startPage(); // 在方法中分页
|
||||
List<PileDetailVO> list = pileBasicInfoService.queryPileInfos(queryPileDTO);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出设备管理列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:basic:export')")
|
||||
@Log(title = "设备管理", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, PileBasicInfo pileBasicInfo) {
|
||||
List<PileBasicInfo> list = pileBasicInfoService.selectPileBasicInfoList(pileBasicInfo);
|
||||
ExcelUtil<PileBasicInfo> util = new ExcelUtil<PileBasicInfo>(PileBasicInfo.class);
|
||||
util.exportExcel(response, list, "设备管理数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备管理详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:basic:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return AjaxResult.success(pileBasicInfoService.selectPileBasicInfoById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增设备管理
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:basic:add')")
|
||||
@Log(title = "设备管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody PileBasicInfo pileBasicInfo) {
|
||||
return toAjax(pileBasicInfoService.insertPileBasicInfo(pileBasicInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量生成充电桩
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:basic:add')")
|
||||
@Log(title = "设备管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/batchAdd")
|
||||
public AjaxResult batchAdd(@RequestBody BatchCreatePileDTO dto) {
|
||||
logger.info("批量生成充电桩 param:{}", JSONObject.toJSONString(dto));
|
||||
return toAjax(pileService.batchCreatePile(dto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改设备管理
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:basic:edit')")
|
||||
@Log(title = "设备管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody PileBasicInfo pileBasicInfo) {
|
||||
return toAjax(pileBasicInfoService.updatePileBasicInfo(pileBasicInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除设备管理
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:basic:remove')")
|
||||
@Log(title = "设备管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(pileBasicInfoService.deletePileBasicInfoByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量更新充电桩
|
||||
* 运营商 站点
|
||||
*/
|
||||
@PostMapping("/batchUpdatePileList")
|
||||
public AjaxResult batchUpdatePileList( @RequestBody ReplaceMerchantStationDTO dto) {
|
||||
logger.info("批量更新充电桩 param:{}", JSONObject.toJSONString(dto));
|
||||
return toAjax(pileBasicInfoService.replaceMerchantStationByPileIds(dto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询充电桩详情
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getPileDetailById")
|
||||
public AjaxResult getPileDetailById(@RequestBody QueryPileDTO queryPileDTO) {
|
||||
logger.info("查询充电桩详情 param:{}", JSONObject.toJSONString(queryPileDTO));
|
||||
if (StringUtils.isBlank(queryPileDTO.getPileId())) {
|
||||
return AjaxResult.error("充电桩id不能为空");
|
||||
}
|
||||
return AjaxResult.success(pileBasicInfoService.selectBasicInfoById(Long.valueOf(queryPileDTO.getPileId())));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询充电桩通讯日志
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getPileFeedList")
|
||||
public AjaxResult getPileFeedList(@RequestBody QueryPileDTO dto) {
|
||||
// logger.info("查询充电桩通信日志 param:{}", dto.getPileSn());
|
||||
if (StringUtils.isBlank(dto.getPileSn())) {
|
||||
return AjaxResult.error("充电桩Sn不能为空");
|
||||
}
|
||||
return AjaxResult.success(pileMsgRecordService.getPileFeedList(dto));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
package com.jsowell.web.controller.pile;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.jsowell.common.annotation.Log;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.core.page.TableDataInfo;
|
||||
import com.jsowell.common.enums.BusinessType;
|
||||
import com.jsowell.common.util.poi.ExcelUtil;
|
||||
import com.jsowell.pile.domain.PileBillingTemplate;
|
||||
import com.jsowell.pile.dto.CreateOrUpdateBillingTemplateDTO;
|
||||
import com.jsowell.pile.dto.ImportBillingTemplateDTO;
|
||||
import com.jsowell.pile.dto.PublishBillingTemplateDTO;
|
||||
import com.jsowell.pile.service.IPileBillingTemplateService;
|
||||
import com.jsowell.pile.vo.web.BillingTemplateVO;
|
||||
import com.jsowell.service.PileRemoteService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 计费模板Controller
|
||||
*
|
||||
* @author jsowell
|
||||
* @date 2022-09-20
|
||||
*/
|
||||
@Api(value = "计费模板Controller", tags = { "计费模板" })
|
||||
@RestController
|
||||
@RequestMapping("/billing/template")
|
||||
public class PileBillingTemplateController extends BaseController {
|
||||
@Autowired
|
||||
private IPileBillingTemplateService pileBillingTemplateService;
|
||||
|
||||
@Autowired
|
||||
private PileRemoteService pileRemoteService;
|
||||
|
||||
/**
|
||||
* 查询计费模板列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('billing:template:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(PileBillingTemplate pileBillingTemplate) {
|
||||
startPage();
|
||||
// 只查询公共的
|
||||
pileBillingTemplate.setPublicFlag(Constants.ONE);
|
||||
List<PileBillingTemplate> list = pileBillingTemplateService.selectPileBillingTemplateList(pileBillingTemplate);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出计费模板列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('billing:template:export')")
|
||||
@Log(title = "计费模板", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, PileBillingTemplate pileBillingTemplate) {
|
||||
List<PileBillingTemplate> list = pileBillingTemplateService.selectPileBillingTemplateList(pileBillingTemplate);
|
||||
ExcelUtil<PileBillingTemplate> util = new ExcelUtil<PileBillingTemplate>(PileBillingTemplate.class);
|
||||
util.exportExcel(response, list, "计费模板数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取计费模板详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('billing:template:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfoById(@PathVariable("id") Long id) {
|
||||
return AjaxResult.success(pileBillingTemplateService.queryPileBillingTemplateById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改计费模板
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('billing:template:edit')")
|
||||
@Log(title = "计费模板", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody PileBillingTemplate pileBillingTemplate) {
|
||||
return toAjax(pileBillingTemplateService.updatePileBillingTemplate(pileBillingTemplate));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除计费模板
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('billing:template:remove')")
|
||||
@Log(title = "计费模板", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(pileBillingTemplateService.deletePileBillingTemplateByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增计费模板
|
||||
* http://localhost:8080/billing/template/createBillingTemplate
|
||||
*/
|
||||
@ApiOperation("新增计费模板")
|
||||
@PreAuthorize("@ss.hasPermi('billing:template:add')")
|
||||
@Log(title = "计费模板", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/createBillingTemplate")
|
||||
public AjaxResult createBillingTemplate(@RequestBody CreateOrUpdateBillingTemplateDTO dto) {
|
||||
logger.info("新增计费模板 param:{}", JSONObject.toJSONString(dto));
|
||||
pileBillingTemplateService.createBillingTemplate(dto);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新计费模板 前端
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/updateBillingTemplate")
|
||||
public AjaxResult updateBillingTemplate(@RequestBody CreateOrUpdateBillingTemplateDTO dto) {
|
||||
logger.info("修改计费模板 param:{}", JSONObject.toJSONString(dto));
|
||||
pileBillingTemplateService.updateBillingTemplate(dto);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询公共计费模板
|
||||
*/
|
||||
@GetMapping("/queryPublicBillingTemplateList")
|
||||
public TableDataInfo queryPublicBillingTemplateList() {
|
||||
List<BillingTemplateVO> list = pileBillingTemplateService.queryPublicBillingTemplateList();
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 站点导入计费模板接口
|
||||
* http://localhost:8080/billing/template/stationImportBillingTemplate
|
||||
*/
|
||||
@PostMapping("/stationImportBillingTemplate")
|
||||
public AjaxResult stationImportBillingTemplate(@RequestBody ImportBillingTemplateDTO dto) {
|
||||
logger.info("站点导入计费模板 param:{}", JSONObject.toJSONString(dto));
|
||||
return toAjax(pileBillingTemplateService.stationImportBillingTemplate(dto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询站点计费模板
|
||||
*/
|
||||
@GetMapping("/queryStationBillingTemplateList/{stationId}")
|
||||
public TableDataInfo queryStationBillingTemplateList(@PathVariable("stationId") String stationId) {
|
||||
logger.info("查询站点计费模板 param:{}", stationId);
|
||||
List<BillingTemplateVO> list = pileBillingTemplateService.queryStationBillingTemplateList(stationId);
|
||||
logger.info("查询站点计费模板 result:{}", JSONObject.toJSONString(list));
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发布计费模板
|
||||
*/
|
||||
@PostMapping("/publishBillingTemplate")
|
||||
public AjaxResult publishBillingTemplate(@RequestBody PublishBillingTemplateDTO dto) {
|
||||
return toAjax(pileRemoteService.publishBillingTemplate(dto));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.jsowell.web.controller.pile;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.jsowell.common.annotation.Log;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.page.TableDataInfo;
|
||||
import com.jsowell.common.enums.BusinessType;
|
||||
import com.jsowell.common.util.poi.ExcelUtil;
|
||||
import com.jsowell.pile.domain.PileConnectorInfo;
|
||||
import com.jsowell.pile.dto.QueryConnectorDTO;
|
||||
import com.jsowell.pile.dto.QueryConnectorListDTO;
|
||||
import com.jsowell.pile.service.IPileConnectorInfoService;
|
||||
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 充电桩枪口信息Controller
|
||||
*
|
||||
* @author jsowell
|
||||
* @date 2022-08-31
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/pile/connector")
|
||||
public class PileConnectorInfoController extends BaseController {
|
||||
@Autowired
|
||||
private IPileConnectorInfoService pileConnectorInfoService;
|
||||
|
||||
/**
|
||||
* 查询充电桩枪口信息列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:connector:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(QueryConnectorDTO queryConnectorDTO) {
|
||||
startPage();
|
||||
List<PileConnectorInfoVO> list = pileConnectorInfoService.getConnectorInfoListByParams(queryConnectorDTO);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出充电桩枪口信息列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:connector:export')")
|
||||
@Log(title = "充电桩枪口信息", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, PileConnectorInfo pileConnectorInfo) {
|
||||
List<PileConnectorInfo> list = pileConnectorInfoService.selectPileConnectorInfoList(pileConnectorInfo);
|
||||
ExcelUtil<PileConnectorInfo> util = new ExcelUtil<PileConnectorInfo>(PileConnectorInfo.class);
|
||||
util.exportExcel(response, list, "充电桩枪口信息数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过入参 查询接口列表
|
||||
* http://localhost:8080/pile/connector/getConnectorInfoListByParams?pileIds=1,2
|
||||
* 多id使用逗号拼接
|
||||
*/
|
||||
@PostMapping("/getConnectorInfoListByParams")
|
||||
public TableDataInfo getConnectorInfoListByParams(@RequestBody QueryConnectorListDTO dto) {
|
||||
logger.info("查询接口列表 param:{}", JSONObject.toJSONString(dto));
|
||||
List<PileConnectorInfoVO> list = pileConnectorInfoService.getConnectorInfoListByParams(dto);
|
||||
logger.info("查询接口列表 result:{}", JSONObject.toJSONString(list));
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取充电桩枪口信息详细信息
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('pile:connector:query')")
|
||||
// @GetMapping(value = "/{id}")
|
||||
// public AjaxResult getInfo(@PathVariable("id") Integer id) {
|
||||
// return AjaxResult.success(pileConnectorInfoService.selectPileConnectorInfoById(id));
|
||||
// }
|
||||
|
||||
/**
|
||||
* 新增充电桩枪口信息
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('pile:connector:add')")
|
||||
// @Log(title = "充电桩枪口信息", businessType = BusinessType.INSERT)
|
||||
// @PostMapping
|
||||
// public AjaxResult add(@RequestBody PileConnectorInfo pileConnectorInfo) {
|
||||
// return toAjax(pileConnectorInfoService.insertPileConnectorInfo(pileConnectorInfo));
|
||||
// }
|
||||
|
||||
/**
|
||||
* 修改充电桩枪口信息
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('pile:connector:edit')")
|
||||
// @Log(title = "充电桩枪口信息", businessType = BusinessType.UPDATE)
|
||||
// @PutMapping
|
||||
// public AjaxResult edit(@RequestBody PileConnectorInfo pileConnectorInfo) {
|
||||
// return toAjax(pileConnectorInfoService.updatePileConnectorInfo(pileConnectorInfo));
|
||||
// }
|
||||
|
||||
/**
|
||||
* 删除充电桩枪口信息
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('pile:connector:remove')")
|
||||
// @Log(title = "充电桩枪口信息", businessType = BusinessType.DELETE)
|
||||
// @DeleteMapping("/{ids}")
|
||||
// public AjaxResult remove(@PathVariable Integer[] ids) {
|
||||
// return toAjax(pileConnectorInfoService.deletePileConnectorInfoByIds(ids));
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.jsowell.web.controller.pile;
|
||||
|
||||
import com.jsowell.common.annotation.Log;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.core.page.TableDataInfo;
|
||||
import com.jsowell.common.enums.BusinessType;
|
||||
import com.jsowell.common.util.poi.ExcelUtil;
|
||||
import com.jsowell.pile.domain.PileLicenceInfo;
|
||||
import com.jsowell.pile.service.IPileLicenceInfoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 充电桩证书信息Controller
|
||||
*
|
||||
* @author jsowell
|
||||
* @date 2022-08-27
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/pile/licence")
|
||||
public class PileLicenceInfoController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IPileLicenceInfoService pileLicenceInfoService;
|
||||
|
||||
/**
|
||||
* 查询充电桩证书信息列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:licence:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(PileLicenceInfo pileLicenceInfo)
|
||||
{
|
||||
startPage();
|
||||
List<PileLicenceInfo> list = pileLicenceInfoService.selectPileLicenceInfoList(pileLicenceInfo);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出充电桩证书信息列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:licence:export')")
|
||||
@Log(title = "充电桩证书信息", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, PileLicenceInfo pileLicenceInfo)
|
||||
{
|
||||
List<PileLicenceInfo> list = pileLicenceInfoService.selectPileLicenceInfoList(pileLicenceInfo);
|
||||
ExcelUtil<PileLicenceInfo> util = new ExcelUtil<PileLicenceInfo>(PileLicenceInfo.class);
|
||||
util.exportExcel(response, list, "充电桩证书信息数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取充电桩证书信息详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:licence:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return AjaxResult.success(pileLicenceInfoService.selectPileLicenceInfoById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增充电桩证书信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:licence:add')")
|
||||
@Log(title = "充电桩证书信息", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody PileLicenceInfo pileLicenceInfo)
|
||||
{
|
||||
return toAjax(pileLicenceInfoService.insertPileLicenceInfo(pileLicenceInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改充电桩证书信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:licence:edit')")
|
||||
@Log(title = "充电桩证书信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody PileLicenceInfo pileLicenceInfo)
|
||||
{
|
||||
return toAjax(pileLicenceInfoService.updatePileLicenceInfo(pileLicenceInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除充电桩证书信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:licence:remove')")
|
||||
@Log(title = "充电桩证书信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(pileLicenceInfoService.deletePileLicenceInfoByIds(ids));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.jsowell.web.controller.pile;
|
||||
|
||||
import com.jsowell.common.annotation.Log;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.core.page.TableDataInfo;
|
||||
import com.jsowell.common.enums.BusinessType;
|
||||
import com.jsowell.common.util.poi.ExcelUtil;
|
||||
import com.jsowell.pile.domain.PileMerchantInfo;
|
||||
import com.jsowell.pile.service.IPileMerchantInfoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 充电桩运营商信息Controller
|
||||
*
|
||||
* @author jsowell
|
||||
* @date 2022-08-27
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/pile/merchant")
|
||||
public class PileMerchantInfoController extends BaseController {
|
||||
@Autowired
|
||||
private IPileMerchantInfoService pileMerchantInfoService;
|
||||
|
||||
/**
|
||||
* 查询充电桩运营商信息列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:merchant:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(PileMerchantInfo pileMerchantInfo) {
|
||||
startPage();
|
||||
List<PileMerchantInfo> list = pileMerchantInfoService.selectPileMerchantInfoList(pileMerchantInfo);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取运营商列表 不分页
|
||||
* @param pileMerchantInfo
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:merchant:list')")
|
||||
@GetMapping("/getMerchantList")
|
||||
public TableDataInfo getMerchantList(PileMerchantInfo pileMerchantInfo) {
|
||||
List<PileMerchantInfo> list = pileMerchantInfoService.selectPileMerchantInfoList(pileMerchantInfo);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出充电桩运营商信息列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:merchant:export')")
|
||||
@Log(title = "充电桩运营商信息", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, PileMerchantInfo pileMerchantInfo) {
|
||||
List<PileMerchantInfo> list = pileMerchantInfoService.selectPileMerchantInfoList(pileMerchantInfo);
|
||||
ExcelUtil<PileMerchantInfo> util = new ExcelUtil<PileMerchantInfo>(PileMerchantInfo.class);
|
||||
util.exportExcel(response, list, "充电桩运营商信息数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取充电桩运营商信息详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:merchant:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return AjaxResult.success(pileMerchantInfoService.selectPileMerchantInfoById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增充电桩运营商信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:merchant:add')")
|
||||
@Log(title = "充电桩运营商信息", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody PileMerchantInfo pileMerchantInfo) {
|
||||
return toAjax(pileMerchantInfoService.insertPileMerchantInfo(pileMerchantInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改充电桩运营商信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:merchant:edit')")
|
||||
@Log(title = "充电桩运营商信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody PileMerchantInfo pileMerchantInfo) {
|
||||
return toAjax(pileMerchantInfoService.updatePileMerchantInfo(pileMerchantInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除充电桩运营商信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:merchant:remove')")
|
||||
@Log(title = "充电桩运营商信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(pileMerchantInfoService.deletePileMerchantInfoByIds(ids));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.jsowell.web.controller.pile;
|
||||
|
||||
import com.jsowell.common.annotation.Log;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.core.page.TableDataInfo;
|
||||
import com.jsowell.common.enums.BusinessType;
|
||||
import com.jsowell.common.util.poi.ExcelUtil;
|
||||
import com.jsowell.pile.domain.PileModelInfo;
|
||||
import com.jsowell.pile.service.IPileModelInfoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 充电桩型号信息Controller
|
||||
*
|
||||
* @author jsowell
|
||||
* @date 2022-08-26
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/pile/model")
|
||||
public class PileModelInfoController extends BaseController {
|
||||
@Autowired
|
||||
private IPileModelInfoService pileModelInfoService;
|
||||
|
||||
/**
|
||||
* 查询充电桩型号信息列表
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('pile:model:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(PileModelInfo pileModelInfo) {
|
||||
startPage();
|
||||
List<PileModelInfo> list = pileModelInfoService.selectPileModelInfoList(pileModelInfo);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出充电桩型号信息列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:model:export')")
|
||||
@Log(title = "充电桩型号信息", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, PileModelInfo pileModelInfo) {
|
||||
List<PileModelInfo> list = pileModelInfoService.selectPileModelInfoList(pileModelInfo);
|
||||
ExcelUtil<PileModelInfo> util = new ExcelUtil<PileModelInfo>(PileModelInfo.class);
|
||||
util.exportExcel(response, list, "充电桩型号信息数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取充电桩型号信息详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:model:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return AjaxResult.success(pileModelInfoService.selectPileModelInfoById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增充电桩型号信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:model:add')")
|
||||
@Log(title = "充电桩型号信息", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody PileModelInfo pileModelInfo) {
|
||||
return toAjax(pileModelInfoService.insertPileModelInfo(pileModelInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改充电桩型号信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:model:edit')")
|
||||
@Log(title = "充电桩型号信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody PileModelInfo pileModelInfo) {
|
||||
return toAjax(pileModelInfoService.updatePileModelInfo(pileModelInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除充电桩型号信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:model:remove')")
|
||||
@Log(title = "充电桩型号信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(pileModelInfoService.deletePileModelInfoByIds(ids));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.jsowell.web.controller.pile;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.pile.dto.GenerateOrderDTO;
|
||||
import com.jsowell.pile.dto.QueryPileDTO;
|
||||
import com.jsowell.service.OrderService;
|
||||
import com.jsowell.service.PileRemoteService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 远程控制controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/remote")
|
||||
public class PileRemoteController {
|
||||
|
||||
@Autowired
|
||||
private PileRemoteService pileRemoteService;
|
||||
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
|
||||
/**
|
||||
* 获取实时上传数据
|
||||
* http://localhost:8080/remote/getRealTimeMonitorData
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getRealTimeMonitorData")
|
||||
public AjaxResult getRealTimeMonitorData(@RequestBody QueryPileDTO queryPileDTO) {
|
||||
pileRemoteService.getRealTimeMonitorData(queryPileDTO.getPileSn(), queryPileDTO.getConnectorCode());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程重启
|
||||
* http://localhost:8080/remote/reboot
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/reboot")
|
||||
public AjaxResult reboot(@RequestBody QueryPileDTO queryPileDTO) {
|
||||
pileRemoteService.reboot(queryPileDTO.getPileSn());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 后管-远程启动充电
|
||||
* http://localhost:8080/remote/remoteStartChargingForWeb
|
||||
*/
|
||||
@PostMapping("/remoteStartChargingForWeb")
|
||||
public AjaxResult remoteStartCharging(@RequestBody GenerateOrderDTO dto) {
|
||||
// pileRemoteService.remoteStartCharging(queryPileDTO.getPileSn(), queryPileDTO.getConnectorCode());
|
||||
// 生成订单并远程启动充电
|
||||
dto.setStartMode(Constants.ZERO);
|
||||
String orderCode = orderService.generateOrder(dto);
|
||||
return AjaxResult.success(ImmutableMap.of("orderCode", orderCode));
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程停止充电
|
||||
* http://localhost:8080/remote/remoteStopCharging
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/remoteStopCharging")
|
||||
public AjaxResult remoteStopCharging(@RequestBody QueryPileDTO dto) {
|
||||
pileRemoteService.remoteStopCharging(dto.getPileSn(), dto.getConnectorCode());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程下发二维码
|
||||
* http://localhost:8080/remote/issueQRCode
|
||||
*/
|
||||
@PostMapping("/issueQRCode")
|
||||
public AjaxResult issueQRCode(@RequestBody QueryPileDTO queryPileDTO) {
|
||||
pileRemoteService.issueQRCode(queryPileDTO.getPileSn());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 对时
|
||||
* http://localhost:8080/remote/proofreadTime
|
||||
*/
|
||||
@PostMapping("/proofreadTime")
|
||||
public AjaxResult proofreadTime(@RequestBody QueryPileDTO queryPileDTO) {
|
||||
pileRemoteService.proofreadTime(queryPileDTO.getPileSn());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程升级
|
||||
* http://localhost:8080/remote/updateFile
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/updateFile")
|
||||
public AjaxResult updateFile(@RequestBody QueryPileDTO queryPileDTO) {
|
||||
pileRemoteService.updateFile(queryPileDTO.getPileSns());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package com.jsowell.web.controller.pile;
|
||||
|
||||
import com.jsowell.common.annotation.Log;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.core.page.TableDataInfo;
|
||||
import com.jsowell.common.enums.BusinessType;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.poi.ExcelUtil;
|
||||
import com.jsowell.pile.domain.PileSimInfo;
|
||||
import com.jsowell.pile.dto.QuerySimInfoDTO;
|
||||
import com.jsowell.pile.dto.SimRenewDTO;
|
||||
import com.jsowell.pile.service.IPileSimInfoService;
|
||||
import com.jsowell.pile.service.SimCardService;
|
||||
import com.jsowell.pile.vo.web.SimCardInfoVO;
|
||||
import com.jsowell.pile.vo.web.SimRenewResultVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 充电桩SIM卡信息Controller
|
||||
*
|
||||
* @author jsowell
|
||||
* @date 2022-08-26
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/pile/sim")
|
||||
public class PileSimInfoController extends BaseController {
|
||||
@Autowired
|
||||
private IPileSimInfoService pileSimInfoService;
|
||||
|
||||
@Autowired
|
||||
private SimCardService simCardService;
|
||||
|
||||
/**
|
||||
* 查询充电桩SIM卡信息列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:sim:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(PileSimInfo pileSimInfo) {
|
||||
startPage();
|
||||
List<PileSimInfo> list = pileSimInfoService.selectPileSimInfoList(pileSimInfo);
|
||||
|
||||
// List<SimCardInfoVO> list = pileSimInfoService.getSimInfoList(pileSimInfo);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('pile:sim:list')")
|
||||
@PostMapping("/getSimInfo")
|
||||
public TableDataInfo getSimInfo(QuerySimInfoDTO dto) {
|
||||
startPage();
|
||||
List<SimCardInfoVO> simInfoList = pileSimInfoService.getSimInfoList(dto);
|
||||
return getDataTable(simInfoList);
|
||||
}
|
||||
/**
|
||||
* 导出充电桩SIM卡信息列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:sim:export')")
|
||||
@Log(title = "充电桩SIM卡信息", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, PileSimInfo pileSimInfo) {
|
||||
List<PileSimInfo> list = pileSimInfoService.selectPileSimInfoList(pileSimInfo);
|
||||
ExcelUtil<PileSimInfo> util = new ExcelUtil<PileSimInfo>(PileSimInfo.class);
|
||||
util.exportExcel(response, list, "充电桩SIM卡信息数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取充电桩SIM卡信息详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:sim:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return AjaxResult.success(pileSimInfoService.selectPileSimInfoById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增充电桩SIM卡信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:sim:add')")
|
||||
@Log(title = "充电桩SIM卡信息", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody PileSimInfo pileSimInfo) {
|
||||
return toAjax(pileSimInfoService.insertPileSimInfo(pileSimInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改充电桩SIM卡信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:sim:edit')")
|
||||
@Log(title = "充电桩SIM卡信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody PileSimInfo pileSimInfo) {
|
||||
return toAjax(pileSimInfoService.updatePileSimInfo(pileSimInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除充电桩SIM卡信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:sim:remove')")
|
||||
@Log(title = "充电桩SIM卡信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(pileSimInfoService.deletePileSimInfoByIds(ids));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 续费sim卡周期
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:sim:edit')")
|
||||
@PostMapping("/simRenew")
|
||||
public AjaxResult simRenew(@RequestBody SimRenewDTO dto) {
|
||||
List<SimRenewResultVO> list = simCardService.renewSimByLoop(dto.getIccIds(), dto.getCycleNumber());
|
||||
return AjaxResult.success(list);
|
||||
|
||||
|
||||
// AjaxResult result;
|
||||
// try {
|
||||
// List<SimRenewResultVO> list = simCardService.renewSimByLoop(dto.getIccIds(), dto.getCycleNumber());
|
||||
// result = AjaxResult.
|
||||
// } catch (BusinessException e) {
|
||||
// result = AjaxResult.error(Integer.parseInt(e.getCode()), e.getMessage());
|
||||
// } catch (Exception e) {
|
||||
// result = AjaxResult.error();
|
||||
// }
|
||||
// return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
package com.jsowell.web.controller.pile;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.jsowell.common.annotation.Log;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.core.page.TableDataInfo;
|
||||
import com.jsowell.common.enums.BusinessType;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.poi.ExcelUtil;
|
||||
import com.jsowell.pile.domain.PileStationInfo;
|
||||
import com.jsowell.pile.dto.FastCreateStationDTO;
|
||||
import com.jsowell.pile.dto.QueryStationDTO;
|
||||
import com.jsowell.pile.service.IPileStationInfoService;
|
||||
import com.jsowell.pile.vo.web.PileStationVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 充电站信息Controller
|
||||
*
|
||||
* @author jsowell
|
||||
* @date 2022-08-30
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/pile/station")
|
||||
public class PileStationInfoController extends BaseController {
|
||||
@Autowired
|
||||
private IPileStationInfoService pileStationInfoService;
|
||||
|
||||
|
||||
/**
|
||||
* 查询充电站信息列表NEW
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:station:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(QueryStationDTO queryStationDTO) {
|
||||
startPage();
|
||||
// List<PileStationInfo> list = pileStationInfoService.selectPileStationInfoList(pileStationInfo);
|
||||
List<PileStationVO> list = pileStationInfoService.queryStationInfos(queryStationDTO);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 快速建站接口
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('pile:station:add')")
|
||||
@PostMapping("/fastCreateStation")
|
||||
public AjaxResult fastCreateStation(@RequestBody FastCreateStationDTO dto) {
|
||||
logger.info("快速建站接口 param:{}", JSONObject.toJSONString(dto));
|
||||
int i = 0;
|
||||
try {
|
||||
i = pileStationInfoService.fastCreateStation(dto);
|
||||
} catch (BusinessException e) {
|
||||
logger.warn("快速建站接口 warn", e);
|
||||
} catch (Exception e) {
|
||||
logger.error("快速建站接口 error", e);
|
||||
}
|
||||
return toAjax(i);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询充电站信息列表
|
||||
*/
|
||||
/*@PreAuthorize("@ss.hasPermi('pile:station:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(PileStationInfo pileStationInfo) {
|
||||
startPage();
|
||||
List<PileStationInfo> list = pileStationInfoService.selectPileStationInfoList(pileStationInfo);
|
||||
return getDataTable(list);
|
||||
}*/
|
||||
|
||||
/**
|
||||
* 导出充电站信息列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:station:export')")
|
||||
@Log(title = "充电站信息", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, PileStationInfo pileStationInfo) {
|
||||
List<PileStationInfo> list = pileStationInfoService.selectPileStationInfoList(pileStationInfo);
|
||||
ExcelUtil<PileStationInfo> util = new ExcelUtil<PileStationInfo>(PileStationInfo.class);
|
||||
util.exportExcel(response, list, "充电站信息数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取充电站信息详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:station:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return AjaxResult.success(pileStationInfoService.selectPileStationInfoById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 后管站点基本资料页面
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:station:query')")
|
||||
@GetMapping(value = "/getStationInfo/{stationId}")
|
||||
public AjaxResult getStationInfo(@PathVariable("stationId") String stationId) {
|
||||
return AjaxResult.success(pileStationInfoService.getStationInfo(stationId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增充电站信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:station:add')")
|
||||
@Log(title = "充电站信息", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody PileStationInfo pileStationInfo) {
|
||||
return toAjax(pileStationInfoService.insertPileStationInfo(pileStationInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改充电站信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:station:edit')")
|
||||
@Log(title = "充电站信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody PileStationInfo pileStationInfo) {
|
||||
logger.info("修改充电站信息 param:{}", pileStationInfo.toString());
|
||||
return toAjax(pileStationInfoService.updatePileStationInfo(pileStationInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除充电站信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:station:remove')")
|
||||
@Log(title = "充电站信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(pileStationInfoService.deletePileStationInfoByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据运营商id获取充电站列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:station:query')")
|
||||
@PostMapping(value = "/selectStationListByMerchantId")
|
||||
public AjaxResult selectStationListByMerchantId(@RequestBody QueryStationDTO dto) {
|
||||
return AjaxResult.success(pileStationInfoService.selectStationListByMerchantId(Long.valueOf(dto.getMerchantId())));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package com.jsowell.web.controller.system;
|
||||
|
||||
import com.jsowell.common.annotation.Log;
|
||||
import com.jsowell.common.constant.UserConstants;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.core.page.TableDataInfo;
|
||||
import com.jsowell.common.enums.BusinessType;
|
||||
import com.jsowell.common.util.poi.ExcelUtil;
|
||||
import com.jsowell.system.domain.SysConfig;
|
||||
import com.jsowell.system.service.SysConfigService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 参数配置 信息操作处理
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/config")
|
||||
public class SysConfigController extends BaseController {
|
||||
@Autowired
|
||||
private SysConfigService configService;
|
||||
|
||||
/**
|
||||
* 获取参数配置列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:config:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysConfig config) {
|
||||
startPage();
|
||||
List<SysConfig> list = configService.selectConfigList(config);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:config:export')")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysConfig config) {
|
||||
List<SysConfig> list = configService.selectConfigList(config);
|
||||
ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class);
|
||||
util.exportExcel(response, list, "参数数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据参数编号获取详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:config:query')")
|
||||
@GetMapping(value = "/{configId}")
|
||||
public AjaxResult getInfo(@PathVariable Long configId) {
|
||||
return AjaxResult.success(configService.selectConfigById(configId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据参数键名查询参数值
|
||||
*/
|
||||
@GetMapping(value = "/configKey/{configKey}")
|
||||
public AjaxResult getConfigKey(@PathVariable String configKey) {
|
||||
return AjaxResult.success(configService.selectConfigByKey(configKey));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增参数配置
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:config:add')")
|
||||
@Log(title = "参数管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysConfig config) {
|
||||
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) {
|
||||
return AjaxResult.error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||
}
|
||||
config.setCreateBy(getUsername());
|
||||
return toAjax(configService.insertConfig(config));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改参数配置
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:config:edit')")
|
||||
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysConfig config) {
|
||||
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) {
|
||||
return AjaxResult.error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||
}
|
||||
config.setUpdateBy(getUsername());
|
||||
return toAjax(configService.updateConfig(config));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除参数配置
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:config:remove')")
|
||||
@Log(title = "参数管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{configIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] configIds) {
|
||||
configService.deleteConfigByIds(configIds);
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新参数缓存
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:config:remove')")
|
||||
@Log(title = "参数管理", businessType = BusinessType.CLEAN)
|
||||
@DeleteMapping("/refreshCache")
|
||||
public AjaxResult refreshCache() {
|
||||
configService.resetConfigCache();
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package com.jsowell.web.controller.system;
|
||||
|
||||
import com.jsowell.common.annotation.Log;
|
||||
import com.jsowell.common.constant.UserConstants;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.core.domain.entity.SysDept;
|
||||
import com.jsowell.common.enums.BusinessType;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.system.service.SysDeptService;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 部门信息
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/dept")
|
||||
public class SysDeptController extends BaseController {
|
||||
@Autowired
|
||||
private SysDeptService deptService;
|
||||
|
||||
/**
|
||||
* 获取部门列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dept:list')")
|
||||
@GetMapping("/list")
|
||||
public AjaxResult list(SysDept dept) {
|
||||
List<SysDept> depts = deptService.selectDeptList(dept);
|
||||
return AjaxResult.success(depts);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询部门列表(排除节点)
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dept:list')")
|
||||
@GetMapping("/list/exclude/{deptId}")
|
||||
public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) {
|
||||
List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
||||
Iterator<SysDept> it = depts.iterator();
|
||||
while (it.hasNext()) {
|
||||
SysDept d = (SysDept) it.next();
|
||||
if (d.getDeptId().intValue() == deptId
|
||||
|| ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
return AjaxResult.success(depts);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据部门编号获取详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dept:query')")
|
||||
@GetMapping(value = "/{deptId}")
|
||||
public AjaxResult getInfo(@PathVariable Long deptId) {
|
||||
deptService.checkDeptDataScope(deptId);
|
||||
return AjaxResult.success(deptService.selectDeptById(deptId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门下拉树列表
|
||||
*/
|
||||
@GetMapping("/treeselect")
|
||||
public AjaxResult treeselect(SysDept dept) {
|
||||
List<SysDept> depts = deptService.selectDeptList(dept);
|
||||
return AjaxResult.success(deptService.buildDeptTreeSelect(depts));
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载对应角色部门列表树
|
||||
*/
|
||||
@GetMapping(value = "/roleDeptTreeselect/{roleId}")
|
||||
public AjaxResult roleDeptTreeselect(@PathVariable("roleId") Long roleId) {
|
||||
List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
|
||||
ajax.put("depts", deptService.buildDeptTreeSelect(depts));
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增部门
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dept:add')")
|
||||
@Log(title = "部门管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysDept dept) {
|
||||
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) {
|
||||
return AjaxResult.error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||
}
|
||||
dept.setCreateBy(getUsername());
|
||||
return toAjax(deptService.insertDept(dept));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改部门
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dept:edit')")
|
||||
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysDept dept) {
|
||||
Long deptId = dept.getDeptId();
|
||||
deptService.checkDeptDataScope(deptId);
|
||||
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) {
|
||||
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||
} else if (dept.getParentId().equals(deptId)) {
|
||||
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
||||
} else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0) {
|
||||
return AjaxResult.error("该部门包含未停用的子部门!");
|
||||
}
|
||||
dept.setUpdateBy(getUsername());
|
||||
return toAjax(deptService.updateDept(dept));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除部门
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dept:remove')")
|
||||
@Log(title = "部门管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{deptId}")
|
||||
public AjaxResult remove(@PathVariable Long deptId) {
|
||||
if (deptService.hasChildByDeptId(deptId)) {
|
||||
return AjaxResult.error("存在下级部门,不允许删除");
|
||||
}
|
||||
if (deptService.checkDeptExistUser(deptId)) {
|
||||
return AjaxResult.error("部门存在用户,不允许删除");
|
||||
}
|
||||
deptService.checkDeptDataScope(deptId);
|
||||
return toAjax(deptService.deleteDeptById(deptId));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.jsowell.web.controller.system;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.jsowell.common.annotation.Log;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.core.domain.entity.SysDictData;
|
||||
import com.jsowell.common.core.page.TableDataInfo;
|
||||
import com.jsowell.common.enums.BusinessType;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.poi.ExcelUtil;
|
||||
import com.jsowell.system.service.SysDictDataService;
|
||||
import com.jsowell.system.service.SysDictTypeService;
|
||||
|
||||
/**
|
||||
* 数据字典信息
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/dict/data")
|
||||
public class SysDictDataController extends BaseController {
|
||||
@Autowired
|
||||
private SysDictDataService dictDataService;
|
||||
|
||||
@Autowired
|
||||
private SysDictTypeService dictTypeService;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysDictData dictData) {
|
||||
startPage();
|
||||
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:export')")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysDictData dictData) {
|
||||
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
||||
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
|
||||
util.exportExcel(response, list, "字典数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询字典数据详细
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:query')")
|
||||
@GetMapping(value = "/{dictCode}")
|
||||
public AjaxResult getInfo(@PathVariable Long dictCode) {
|
||||
return AjaxResult.success(dictDataService.selectDictDataById(dictCode));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型查询字典数据信息
|
||||
*/
|
||||
@GetMapping(value = "/type/{dictType}")
|
||||
public AjaxResult dictType(@PathVariable String dictType) {
|
||||
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
|
||||
if (StringUtils.isNull(data)) {
|
||||
data = new ArrayList<SysDictData>();
|
||||
}
|
||||
return AjaxResult.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增字典类型
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:add')")
|
||||
@Log(title = "字典数据", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysDictData dict) {
|
||||
dict.setCreateBy(getUsername());
|
||||
return toAjax(dictDataService.insertDictData(dict));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存字典类型
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:edit')")
|
||||
@Log(title = "字典数据", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysDictData dict) {
|
||||
dict.setUpdateBy(getUsername());
|
||||
return toAjax(dictDataService.updateDictData(dict));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字典类型
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
||||
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{dictCodes}")
|
||||
public AjaxResult remove(@PathVariable Long[] dictCodes) {
|
||||
dictDataService.deleteDictDataByIds(dictCodes);
|
||||
return success();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.jsowell.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.jsowell.common.annotation.Log;
|
||||
import com.jsowell.common.constant.UserConstants;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.core.domain.entity.SysDictType;
|
||||
import com.jsowell.common.core.page.TableDataInfo;
|
||||
import com.jsowell.common.enums.BusinessType;
|
||||
import com.jsowell.common.util.poi.ExcelUtil;
|
||||
import com.jsowell.system.service.SysDictTypeService;
|
||||
|
||||
/**
|
||||
* 数据字典信息
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/dict/type")
|
||||
public class SysDictTypeController extends BaseController {
|
||||
@Autowired
|
||||
private SysDictTypeService dictTypeService;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysDictType dictType) {
|
||||
startPage();
|
||||
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:export')")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysDictType dictType) {
|
||||
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
||||
ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class);
|
||||
util.exportExcel(response, list, "字典类型");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询字典类型详细
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:query')")
|
||||
@GetMapping(value = "/{dictId}")
|
||||
public AjaxResult getInfo(@PathVariable Long dictId) {
|
||||
return AjaxResult.success(dictTypeService.selectDictTypeById(dictId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增字典类型
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:add')")
|
||||
@Log(title = "字典类型", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysDictType dict) {
|
||||
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) {
|
||||
return AjaxResult.error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||
}
|
||||
dict.setCreateBy(getUsername());
|
||||
return toAjax(dictTypeService.insertDictType(dict));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典类型
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:edit')")
|
||||
@Log(title = "字典类型", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysDictType dict) {
|
||||
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) {
|
||||
return AjaxResult.error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||
}
|
||||
dict.setUpdateBy(getUsername());
|
||||
return toAjax(dictTypeService.updateDictType(dict));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字典类型
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
||||
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{dictIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] dictIds) {
|
||||
dictTypeService.deleteDictTypeByIds(dictIds);
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新字典缓存
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
||||
@Log(title = "字典类型", businessType = BusinessType.CLEAN)
|
||||
@DeleteMapping("/refreshCache")
|
||||
public AjaxResult refreshCache() {
|
||||
dictTypeService.resetDictCache();
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典选择框列表
|
||||
*/
|
||||
@GetMapping("/optionselect")
|
||||
public AjaxResult optionselect() {
|
||||
List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
|
||||
return AjaxResult.success(dictTypes);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.jsowell.web.controller.system;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.jsowell.common.config.JsowellConfig;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
|
||||
/**
|
||||
* 首页
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@RestController
|
||||
public class SysIndexController {
|
||||
/**
|
||||
* 系统基础配置
|
||||
*/
|
||||
@Autowired
|
||||
private JsowellConfig jsowellConfig;
|
||||
|
||||
/**
|
||||
* 访问首页,提示语
|
||||
*/
|
||||
@RequestMapping("/")
|
||||
public String index() {
|
||||
return StringUtils.format("欢迎使用{}后台管理框架,当前版本:v{},请通过前端地址访问。", jsowellConfig.getName(), jsowellConfig.getVersion());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.jsowell.web.controller.system;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.core.domain.entity.SysMenu;
|
||||
import com.jsowell.common.core.domain.entity.SysUser;
|
||||
import com.jsowell.common.core.domain.model.LoginBody;
|
||||
import com.jsowell.common.util.SecurityUtils;
|
||||
import com.jsowell.framework.web.service.SysLoginService;
|
||||
import com.jsowell.framework.web.service.SysPermissionService;
|
||||
import com.jsowell.system.service.SysMenuService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 登录验证
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@RestController
|
||||
public class SysLoginController {
|
||||
Logger logs = LoggerFactory.getLogger(this.getClass());
|
||||
@Autowired
|
||||
private SysLoginService loginService;
|
||||
|
||||
@Autowired
|
||||
private SysMenuService menuService;
|
||||
|
||||
@Autowired
|
||||
private SysPermissionService permissionService;
|
||||
|
||||
/**
|
||||
* 登录方法
|
||||
*
|
||||
* @param loginBody 登录信息
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/login")
|
||||
public AjaxResult login(@RequestBody LoginBody loginBody) {
|
||||
logs.info("登录param:{}", JSONObject.toJSONString(loginBody));
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
// 生成令牌
|
||||
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
|
||||
loginBody.getUuid());
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
logs.info("登录 result:{}", ajax.toString());
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*
|
||||
* @return 用户信息
|
||||
*/
|
||||
@GetMapping("getInfo")
|
||||
public AjaxResult getInfo() {
|
||||
SysUser user = SecurityUtils.getLoginUser().getUser();
|
||||
// 角色集合
|
||||
Set<String> roles = permissionService.getRolePermission(user);
|
||||
// 权限集合
|
||||
Set<String> permissions = permissionService.getMenuPermission(user);
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("user" , user);
|
||||
ajax.put("roles" , roles);
|
||||
ajax.put("permissions" , permissions);
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取路由信息
|
||||
*
|
||||
* @return 路由信息
|
||||
*/
|
||||
@GetMapping("getRouters")
|
||||
public AjaxResult getRouters() {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
|
||||
logs.info("获取路由信息userId:{}, menus:{}, 菜单数量:{}", userId, menus, menus.size());
|
||||
return AjaxResult.success(menuService.buildMenus(menus));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.jsowell.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.jsowell.common.annotation.Log;
|
||||
import com.jsowell.common.constant.UserConstants;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.core.domain.entity.SysMenu;
|
||||
import com.jsowell.common.enums.BusinessType;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.system.service.SysMenuService;
|
||||
|
||||
/**
|
||||
* 菜单信息
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/menu")
|
||||
public class SysMenuController extends BaseController {
|
||||
@Autowired
|
||||
private SysMenuService menuService;
|
||||
|
||||
/**
|
||||
* 获取菜单列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:menu:list')")
|
||||
@GetMapping("/list")
|
||||
public AjaxResult list(SysMenu menu) {
|
||||
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
|
||||
return AjaxResult.success(menus);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据菜单编号获取详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:menu:query')")
|
||||
@GetMapping(value = "/{menuId}")
|
||||
public AjaxResult getInfo(@PathVariable Long menuId) {
|
||||
return AjaxResult.success(menuService.selectMenuById(menuId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单下拉树列表
|
||||
*/
|
||||
@GetMapping("/treeselect")
|
||||
public AjaxResult treeselect(SysMenu menu) {
|
||||
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
|
||||
return AjaxResult.success(menuService.buildMenuTreeSelect(menus));
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载对应角色菜单列表树
|
||||
*/
|
||||
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
|
||||
public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId) {
|
||||
List<SysMenu> menus = menuService.selectMenuList(getUserId());
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
|
||||
ajax.put("menus", menuService.buildMenuTreeSelect(menus));
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增菜单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:menu:add')")
|
||||
@Log(title = "菜单管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysMenu menu) {
|
||||
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) {
|
||||
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||
} else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.isHttp(menu.getPath())) {
|
||||
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
||||
}
|
||||
menu.setCreateBy(getUsername());
|
||||
return toAjax(menuService.insertMenu(menu));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改菜单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:menu:edit')")
|
||||
@Log(title = "菜单管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysMenu menu) {
|
||||
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) {
|
||||
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||
} else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.isHttp(menu.getPath())) {
|
||||
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
||||
} else if (menu.getMenuId().equals(menu.getParentId())) {
|
||||
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己");
|
||||
}
|
||||
menu.setUpdateBy(getUsername());
|
||||
return toAjax(menuService.updateMenu(menu));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除菜单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:menu:remove')")
|
||||
@Log(title = "菜单管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{menuId}")
|
||||
public AjaxResult remove(@PathVariable("menuId") Long menuId) {
|
||||
if (menuService.hasChildByMenuId(menuId)) {
|
||||
return AjaxResult.error("存在子菜单,不允许删除");
|
||||
}
|
||||
if (menuService.checkMenuExistRole(menuId)) {
|
||||
return AjaxResult.error("菜单已分配,不允许删除");
|
||||
}
|
||||
return toAjax(menuService.deleteMenuById(menuId));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.jsowell.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.jsowell.common.annotation.Log;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.core.page.TableDataInfo;
|
||||
import com.jsowell.common.enums.BusinessType;
|
||||
import com.jsowell.system.domain.SysNotice;
|
||||
import com.jsowell.system.service.SysNoticeService;
|
||||
|
||||
/**
|
||||
* 公告 信息操作处理
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/notice")
|
||||
public class SysNoticeController extends BaseController {
|
||||
@Autowired
|
||||
private SysNoticeService noticeService;
|
||||
|
||||
/**
|
||||
* 获取通知公告列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:notice:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysNotice notice) {
|
||||
startPage();
|
||||
List<SysNotice> list = noticeService.selectNoticeList(notice);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据通知公告编号获取详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:notice:query')")
|
||||
@GetMapping(value = "/{noticeId}")
|
||||
public AjaxResult getInfo(@PathVariable Long noticeId) {
|
||||
return AjaxResult.success(noticeService.selectNoticeById(noticeId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增通知公告
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:notice:add')")
|
||||
@Log(title = "通知公告", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysNotice notice) {
|
||||
notice.setCreateBy(getUsername());
|
||||
return toAjax(noticeService.insertNotice(notice));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改通知公告
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:notice:edit')")
|
||||
@Log(title = "通知公告", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysNotice notice) {
|
||||
notice.setUpdateBy(getUsername());
|
||||
return toAjax(noticeService.updateNotice(notice));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除通知公告
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:notice:remove')")
|
||||
@Log(title = "通知公告", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{noticeIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] noticeIds) {
|
||||
return toAjax(noticeService.deleteNoticeByIds(noticeIds));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package com.jsowell.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.jsowell.common.annotation.Log;
|
||||
import com.jsowell.common.constant.UserConstants;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.core.page.TableDataInfo;
|
||||
import com.jsowell.common.enums.BusinessType;
|
||||
import com.jsowell.common.util.poi.ExcelUtil;
|
||||
import com.jsowell.system.domain.SysPost;
|
||||
import com.jsowell.system.service.SysPostService;
|
||||
|
||||
/**
|
||||
* 岗位信息操作处理
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/post")
|
||||
public class SysPostController extends BaseController {
|
||||
@Autowired
|
||||
private SysPostService postService;
|
||||
|
||||
/**
|
||||
* 获取岗位列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:post:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysPost post) {
|
||||
startPage();
|
||||
List<SysPost> list = postService.selectPostList(post);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:post:export')")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysPost post) {
|
||||
List<SysPost> list = postService.selectPostList(post);
|
||||
ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
|
||||
util.exportExcel(response, list, "岗位数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据岗位编号获取详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:post:query')")
|
||||
@GetMapping(value = "/{postId}")
|
||||
public AjaxResult getInfo(@PathVariable Long postId) {
|
||||
return AjaxResult.success(postService.selectPostById(postId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增岗位
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:post:add')")
|
||||
@Log(title = "岗位管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysPost post) {
|
||||
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) {
|
||||
return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
||||
} else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) {
|
||||
return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
||||
}
|
||||
post.setCreateBy(getUsername());
|
||||
return toAjax(postService.insertPost(post));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改岗位
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:post:edit')")
|
||||
@Log(title = "岗位管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysPost post) {
|
||||
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) {
|
||||
return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
||||
} else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) {
|
||||
return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
||||
}
|
||||
post.setUpdateBy(getUsername());
|
||||
return toAjax(postService.updatePost(post));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除岗位
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:post:remove')")
|
||||
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{postIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] postIds) {
|
||||
return toAjax(postService.deletePostByIds(postIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取岗位选择框列表
|
||||
*/
|
||||
@GetMapping("/optionselect")
|
||||
public AjaxResult optionselect() {
|
||||
List<SysPost> posts = postService.selectPostAll();
|
||||
return AjaxResult.success(posts);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package com.jsowell.web.controller.system;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.jsowell.common.annotation.Log;
|
||||
import com.jsowell.common.config.JsowellConfig;
|
||||
import com.jsowell.common.constant.UserConstants;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.core.domain.entity.SysUser;
|
||||
import com.jsowell.common.core.domain.model.LoginUser;
|
||||
import com.jsowell.common.enums.BusinessType;
|
||||
import com.jsowell.common.util.SecurityUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.file.FileUploadUtils;
|
||||
import com.jsowell.common.util.file.MimeTypeUtils;
|
||||
import com.jsowell.framework.web.service.TokenService;
|
||||
import com.jsowell.system.service.SysUserService;
|
||||
|
||||
/**
|
||||
* 个人信息 业务处理
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/user/profile")
|
||||
public class SysProfileController extends BaseController {
|
||||
@Autowired
|
||||
private SysUserService userService;
|
||||
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
|
||||
/**
|
||||
* 个人信息
|
||||
*/
|
||||
@GetMapping
|
||||
public AjaxResult profile() {
|
||||
LoginUser loginUser = getLoginUser();
|
||||
SysUser user = loginUser.getUser();
|
||||
AjaxResult ajax = AjaxResult.success(user);
|
||||
ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername()));
|
||||
ajax.put("postGroup", userService.selectUserPostGroup(loginUser.getUsername()));
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户
|
||||
*/
|
||||
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult updateProfile(@RequestBody SysUser user) {
|
||||
LoginUser loginUser = getLoginUser();
|
||||
SysUser sysUser = loginUser.getUser();
|
||||
user.setUserName(sysUser.getUserName());
|
||||
if (StringUtils.isNotEmpty(user.getPhone())
|
||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
|
||||
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||
}
|
||||
if (StringUtils.isNotEmpty(user.getEmail())
|
||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
|
||||
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||
}
|
||||
user.setUserId(sysUser.getUserId());
|
||||
user.setPassword(null);
|
||||
user.setAvatar(null);
|
||||
user.setDeptId(null);
|
||||
if (userService.updateUserProfile(user) > 0) {
|
||||
// 更新缓存用户信息
|
||||
sysUser.setNickName(user.getNickName());
|
||||
sysUser.setPhone(user.getPhone());
|
||||
sysUser.setEmail(user.getEmail());
|
||||
sysUser.setSex(user.getSex());
|
||||
tokenService.setLoginUser(loginUser);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
return AjaxResult.error("修改个人信息异常,请联系管理员");
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
*/
|
||||
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/updatePwd")
|
||||
public AjaxResult updatePwd(String oldPassword, String newPassword) {
|
||||
LoginUser loginUser = getLoginUser();
|
||||
String userName = loginUser.getUsername();
|
||||
String password = loginUser.getPassword();
|
||||
if (!SecurityUtils.matchesPassword(oldPassword, password)) {
|
||||
return AjaxResult.error("修改密码失败,旧密码错误");
|
||||
}
|
||||
if (SecurityUtils.matchesPassword(newPassword, password)) {
|
||||
return AjaxResult.error("新密码不能与旧密码相同");
|
||||
}
|
||||
if (userService.resetUserPwd(userName, SecurityUtils.encryptPassword(newPassword)) > 0) {
|
||||
// 更新缓存用户密码
|
||||
loginUser.getUser().setPassword(SecurityUtils.encryptPassword(newPassword));
|
||||
tokenService.setLoginUser(loginUser);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
return AjaxResult.error("修改密码异常,请联系管理员");
|
||||
}
|
||||
|
||||
/**
|
||||
* 头像上传
|
||||
*/
|
||||
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/avatar")
|
||||
public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws Exception {
|
||||
if (!file.isEmpty()) {
|
||||
LoginUser loginUser = getLoginUser();
|
||||
String avatar = FileUploadUtils.upload(JsowellConfig.getAvatarPath(), file, MimeTypeUtils.IMAGE_EXTENSION);
|
||||
if (userService.updateUserAvatar(loginUser.getUsername(), avatar)) {
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("imgUrl", avatar);
|
||||
// 更新缓存用户头像
|
||||
loginUser.getUser().setAvatar(avatar);
|
||||
tokenService.setLoginUser(loginUser);
|
||||
return ajax;
|
||||
}
|
||||
}
|
||||
return AjaxResult.error("上传图片异常,请联系管理员");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.jsowell.web.controller.system;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.core.domain.model.RegisterBody;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.framework.web.service.SysRegisterService;
|
||||
import com.jsowell.system.service.SysConfigService;
|
||||
|
||||
/**
|
||||
* 注册验证
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@RestController
|
||||
public class SysRegisterController extends BaseController {
|
||||
@Autowired
|
||||
private SysRegisterService registerService;
|
||||
|
||||
@Autowired
|
||||
private SysConfigService configService;
|
||||
|
||||
@PostMapping("/register")
|
||||
public AjaxResult register(@RequestBody RegisterBody user) {
|
||||
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) {
|
||||
return error("当前系统没有开启注册功能!");
|
||||
}
|
||||
String msg = registerService.register(user);
|
||||
return StringUtils.isEmpty(msg) ? success() : error(msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
package com.jsowell.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.jsowell.common.annotation.Log;
|
||||
import com.jsowell.common.constant.UserConstants;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.core.domain.entity.SysRole;
|
||||
import com.jsowell.common.core.domain.entity.SysUser;
|
||||
import com.jsowell.common.core.domain.model.LoginUser;
|
||||
import com.jsowell.common.core.page.TableDataInfo;
|
||||
import com.jsowell.common.enums.BusinessType;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.poi.ExcelUtil;
|
||||
import com.jsowell.framework.web.service.SysPermissionService;
|
||||
import com.jsowell.framework.web.service.TokenService;
|
||||
import com.jsowell.system.domain.SysUserRole;
|
||||
import com.jsowell.system.service.SysRoleService;
|
||||
import com.jsowell.system.service.SysUserService;
|
||||
|
||||
/**
|
||||
* 角色信息
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/role")
|
||||
public class SysRoleController extends BaseController {
|
||||
@Autowired
|
||||
private SysRoleService roleService;
|
||||
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
|
||||
@Autowired
|
||||
private SysPermissionService permissionService;
|
||||
|
||||
@Autowired
|
||||
private SysUserService userService;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('system:role:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysRole role) {
|
||||
startPage();
|
||||
List<SysRole> list = roleService.selectRoleList(role);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:role:export')")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysRole role) {
|
||||
List<SysRole> list = roleService.selectRoleList(role);
|
||||
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
|
||||
util.exportExcel(response, list, "角色数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色编号获取详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:query')")
|
||||
@GetMapping(value = "/{roleId}")
|
||||
public AjaxResult getInfo(@PathVariable Long roleId) {
|
||||
roleService.checkRoleDataScope(roleId);
|
||||
return AjaxResult.success(roleService.selectRoleById(roleId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增角色
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:add')")
|
||||
@Log(title = "角色管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysRole role) {
|
||||
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) {
|
||||
return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||
} else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) {
|
||||
return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
||||
}
|
||||
role.setCreateBy(getUsername());
|
||||
return toAjax(roleService.insertRole(role));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存角色
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysRole role) {
|
||||
roleService.checkRoleAllowed(role);
|
||||
roleService.checkRoleDataScope(role.getRoleId());
|
||||
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) {
|
||||
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||
} else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) {
|
||||
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
||||
}
|
||||
role.setUpdateBy(getUsername());
|
||||
|
||||
if (roleService.updateRole(role) > 0) {
|
||||
// 更新缓存用户权限
|
||||
LoginUser loginUser = getLoginUser();
|
||||
if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin()) {
|
||||
loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser()));
|
||||
loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName()));
|
||||
tokenService.setLoginUser(loginUser);
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,请联系管理员");
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存数据权限
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/dataScope")
|
||||
public AjaxResult dataScope(@RequestBody SysRole role) {
|
||||
roleService.checkRoleAllowed(role);
|
||||
roleService.checkRoleDataScope(role.getRoleId());
|
||||
return toAjax(roleService.authDataScope(role));
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态修改
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/changeStatus")
|
||||
public AjaxResult changeStatus(@RequestBody SysRole role) {
|
||||
roleService.checkRoleAllowed(role);
|
||||
roleService.checkRoleDataScope(role.getRoleId());
|
||||
role.setUpdateBy(getUsername());
|
||||
return toAjax(roleService.updateRoleStatus(role));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除角色
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:remove')")
|
||||
@Log(title = "角色管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{roleIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] roleIds) {
|
||||
return toAjax(roleService.deleteRoleByIds(roleIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色选择框列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:query')")
|
||||
@GetMapping("/optionselect")
|
||||
public AjaxResult optionselect() {
|
||||
return AjaxResult.success(roleService.selectRoleAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询已分配用户角色列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:list')")
|
||||
@GetMapping("/authUser/allocatedList")
|
||||
public TableDataInfo allocatedList(SysUser user) {
|
||||
startPage();
|
||||
List<SysUser> list = userService.selectAllocatedList(user);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询未分配用户角色列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:list')")
|
||||
@GetMapping("/authUser/unallocatedList")
|
||||
public TableDataInfo unallocatedList(SysUser user) {
|
||||
startPage();
|
||||
List<SysUser> list = userService.selectUnallocatedList(user);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消授权用户
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||
@PutMapping("/authUser/cancel")
|
||||
public AjaxResult cancelAuthUser(@RequestBody SysUserRole userRole) {
|
||||
return toAjax(roleService.deleteAuthUser(userRole));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量取消授权用户
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||
@PutMapping("/authUser/cancelAll")
|
||||
public AjaxResult cancelAuthUserAll(Long roleId, Long[] userIds) {
|
||||
return toAjax(roleService.deleteAuthUsers(roleId, userIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量选择用户授权
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||
@PutMapping("/authUser/selectAll")
|
||||
public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds) {
|
||||
roleService.checkRoleDataScope(roleId);
|
||||
return toAjax(roleService.insertAuthUsers(roleId, userIds));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
package com.jsowell.web.controller.system;
|
||||
|
||||
import com.jsowell.common.annotation.Log;
|
||||
import com.jsowell.common.constant.UserConstants;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.core.domain.entity.SysRole;
|
||||
import com.jsowell.common.core.domain.entity.SysUser;
|
||||
import com.jsowell.common.core.page.TableDataInfo;
|
||||
import com.jsowell.common.enums.BusinessType;
|
||||
import com.jsowell.common.util.SecurityUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.poi.ExcelUtil;
|
||||
import com.jsowell.system.service.SysPostService;
|
||||
import com.jsowell.system.service.SysRoleService;
|
||||
import com.jsowell.system.service.SysUserService;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/user")
|
||||
public class SysUserController extends BaseController {
|
||||
@Autowired
|
||||
private SysUserService userService;
|
||||
|
||||
@Autowired
|
||||
private SysRoleService roleService;
|
||||
|
||||
@Autowired
|
||||
private SysPostService postService;
|
||||
|
||||
/**
|
||||
* 获取用户列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysUser user) {
|
||||
startPage();
|
||||
List<SysUser> list = userService.selectUserList(user);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:user:export')")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysUser user) {
|
||||
List<SysUser> list = userService.selectUserList(user);
|
||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||
util.exportExcel(response, list, "用户数据");
|
||||
}
|
||||
|
||||
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:user:import')")
|
||||
@PostMapping("/importData")
|
||||
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
|
||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||
List<SysUser> userList = util.importExcel(file.getInputStream());
|
||||
String operName = getUsername();
|
||||
String message = userService.importUser(userList, updateSupport, operName);
|
||||
return AjaxResult.success(message);
|
||||
}
|
||||
|
||||
@PostMapping("/importTemplate")
|
||||
public void importTemplate(HttpServletResponse response) {
|
||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||
util.importTemplateExcel(response, "用户数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户编号获取详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:query')")
|
||||
@GetMapping(value = {"/", "/{userId}"})
|
||||
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId) {
|
||||
userService.checkUserDataScope(userId);
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
List<SysRole> roles = roleService.selectRoleAll();
|
||||
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||
ajax.put("posts", postService.selectPostAll());
|
||||
if (StringUtils.isNotNull(userId)) {
|
||||
SysUser sysUser = userService.selectUserById(userId);
|
||||
ajax.put(AjaxResult.DATA_TAG, sysUser);
|
||||
ajax.put("postIds", postService.selectPostListByUserId(userId));
|
||||
ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()));
|
||||
}
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增用户
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:add')")
|
||||
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysUser user) {
|
||||
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user.getUserName()))) {
|
||||
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
||||
} else if (StringUtils.isNotEmpty(user.getPhone())
|
||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
|
||||
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||
} else if (StringUtils.isNotEmpty(user.getEmail())
|
||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
|
||||
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||
}
|
||||
user.setCreateBy(getUsername());
|
||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||
return toAjax(userService.insertUser(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysUser user) {
|
||||
userService.checkUserAllowed(user);
|
||||
userService.checkUserDataScope(user.getUserId());
|
||||
if (StringUtils.isNotEmpty(user.getPhone())
|
||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
|
||||
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||
} else if (StringUtils.isNotEmpty(user.getEmail())
|
||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
|
||||
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||
}
|
||||
user.setUpdateBy(getUsername());
|
||||
return toAjax(userService.updateUser(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:remove')")
|
||||
@Log(title = "用户管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{userIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] userIds) {
|
||||
if (ArrayUtils.contains(userIds, getUserId())) {
|
||||
return error("当前用户不能删除");
|
||||
}
|
||||
return toAjax(userService.deleteUserByIds(userIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:resetPwd')")
|
||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/resetPwd")
|
||||
public AjaxResult resetPwd(@RequestBody SysUser user) {
|
||||
userService.checkUserAllowed(user);
|
||||
userService.checkUserDataScope(user.getUserId());
|
||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||
user.setUpdateBy(getUsername());
|
||||
return toAjax(userService.resetPwd(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态修改
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/changeStatus")
|
||||
public AjaxResult changeStatus(@RequestBody SysUser user) {
|
||||
userService.checkUserAllowed(user);
|
||||
userService.checkUserDataScope(user.getUserId());
|
||||
user.setUpdateBy(getUsername());
|
||||
return toAjax(userService.updateUserStatus(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户编号获取授权角色
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:query')")
|
||||
@GetMapping("/authRole/{userId}")
|
||||
public AjaxResult authRole(@PathVariable("userId") Long userId) {
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
SysUser user = userService.selectUserById(userId);
|
||||
List<SysRole> roles = roleService.selectRolesByUserId(userId);
|
||||
ajax.put("user", user);
|
||||
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户授权角色
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||
@Log(title = "用户管理", businessType = BusinessType.GRANT)
|
||||
@PutMapping("/authRole")
|
||||
public AjaxResult insertAuthRole(Long userId, Long[] roleIds) {
|
||||
userService.checkUserDataScope(userId);
|
||||
userService.insertUserAuth(userId, roleIds);
|
||||
return success();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(SecurityUtils.encryptPassword("admin123"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.jsowell.web.controller.tool;
|
||||
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
|
||||
/**
|
||||
* swagger 接口
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/tool/swagger")
|
||||
public class SwaggerController extends BaseController {
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('tool:swagger:view')")
|
||||
@GetMapping()
|
||||
public String index() {
|
||||
return redirect("/swagger-ui.html");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
package com.jsowell.web.controller.tool;
|
||||
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.domain.R;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* swagger 用户测试方法
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@Api("用户信息管理123")
|
||||
@RestController
|
||||
@RequestMapping("/test/user")
|
||||
public class TestController extends BaseController {
|
||||
private final static Map<Integer, UserEntity> users = new LinkedHashMap<Integer, UserEntity>();
|
||||
|
||||
{
|
||||
users.put(1, new UserEntity(1, "thinkgem" , "admin123" , "15888888888"));
|
||||
users.put(2, new UserEntity(2, "jsowell-test" , "admin123" , "15666666666"));
|
||||
}
|
||||
|
||||
@ApiOperation("获取用户列表")
|
||||
@GetMapping("/list")
|
||||
public R<List<UserEntity>> userList() {
|
||||
List<UserEntity> userList = new ArrayList<UserEntity>(users.values());
|
||||
return R.ok(userList);
|
||||
}
|
||||
|
||||
@ApiOperation("获取用户详细123")
|
||||
@ApiImplicitParam(name = "userId" , value = "用户ID" , required = true, dataType = "int" , paramType = "path" , dataTypeClass = Integer.class)
|
||||
@GetMapping("/{userId}")
|
||||
public R<UserEntity> getUser(@PathVariable Integer userId) {
|
||||
if (!users.isEmpty() && users.containsKey(userId)) {
|
||||
return R.ok(users.get(userId));
|
||||
} else {
|
||||
return R.fail("用户不存在");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("新增用户")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "userId" , value = "用户id" , dataType = "Integer" , dataTypeClass = Integer.class),
|
||||
@ApiImplicitParam(name = "username" , value = "用户名称" , dataType = "String" , dataTypeClass = String.class),
|
||||
@ApiImplicitParam(name = "password" , value = "用户密码" , dataType = "String" , dataTypeClass = String.class),
|
||||
@ApiImplicitParam(name = "mobile" , value = "用户手机" , dataType = "String" , dataTypeClass = String.class)
|
||||
})
|
||||
@PostMapping("/save")
|
||||
public R<String> save(UserEntity user) {
|
||||
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) {
|
||||
return R.fail("用户ID不能为空");
|
||||
}
|
||||
users.put(user.getUserId(), user);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@ApiOperation("更新用户")
|
||||
@PutMapping("/update")
|
||||
public R<String> update(@RequestBody UserEntity user) {
|
||||
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) {
|
||||
return R.fail("用户ID不能为空");
|
||||
}
|
||||
if (users.isEmpty() || !users.containsKey(user.getUserId())) {
|
||||
return R.fail("用户不存在");
|
||||
}
|
||||
users.remove(user.getUserId());
|
||||
users.put(user.getUserId(), user);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@ApiOperation("删除用户信息")
|
||||
@ApiImplicitParam(name = "userId" , value = "用户ID" , required = true, dataType = "int" , paramType = "path" , dataTypeClass = Integer.class)
|
||||
@DeleteMapping("/{userId}")
|
||||
public R<String> delete(@PathVariable Integer userId) {
|
||||
if (!users.isEmpty() && users.containsKey(userId)) {
|
||||
users.remove(userId);
|
||||
return R.ok();
|
||||
} else {
|
||||
return R.fail("用户不存在");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ApiModel(value = "UserEntity" , description = "用户实体")
|
||||
class UserEntity {
|
||||
@ApiModelProperty("用户ID")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty("用户名称")
|
||||
private String username;
|
||||
|
||||
@ApiModelProperty("用户密码")
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty("用户手机")
|
||||
private String mobile;
|
||||
|
||||
public UserEntity() {
|
||||
|
||||
}
|
||||
|
||||
public UserEntity(Integer userId, String username, String password, String mobile) {
|
||||
this.userId = userId;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.jsowell.web.core.config;
|
||||
|
||||
import com.jsowell.common.config.JsowellConfig;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.models.auth.In;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.*;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spi.service.contexts.SecurityContext;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Swagger2的接口配置
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@Configuration
|
||||
public class SwaggerConfig {
|
||||
/**
|
||||
* 系统基础配置
|
||||
*/
|
||||
@Autowired
|
||||
private JsowellConfig jsowellConfig;
|
||||
|
||||
/**
|
||||
* 是否开启swagger
|
||||
*/
|
||||
@Value("${swagger.enabled}")
|
||||
private boolean enabled;
|
||||
|
||||
/**
|
||||
* 设置请求的统一前缀
|
||||
*/
|
||||
@Value("${swagger.pathMapping}")
|
||||
private String pathMapping;
|
||||
|
||||
/**
|
||||
* 创建API
|
||||
*/
|
||||
@Bean
|
||||
public Docket createRestApi() {
|
||||
return new Docket(DocumentationType.OAS_30)
|
||||
// 是否启用Swagger
|
||||
.enable(enabled)
|
||||
// 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息)
|
||||
.apiInfo(apiInfo())
|
||||
// 设置哪些接口暴露给Swagger展示
|
||||
.select()
|
||||
// 扫描所有有注解的api,用这种方式更灵活
|
||||
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
|
||||
// 扫描指定包中的swagger注解
|
||||
// .apis(RequestHandlerSelectors.basePackage("com.jsowell.project.tool.swagger"))
|
||||
// 扫描所有
|
||||
.apis(RequestHandlerSelectors.any())
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
/* 设置安全模式,swagger可以设置访问token */
|
||||
.securitySchemes(securitySchemes())
|
||||
.securityContexts(securityContexts())
|
||||
.pathMapping(pathMapping);
|
||||
}
|
||||
|
||||
/**
|
||||
* 安全模式,这里指定token通过Authorization头请求头传递
|
||||
*/
|
||||
private List<SecurityScheme> securitySchemes() {
|
||||
List<SecurityScheme> apiKeyList = new ArrayList<SecurityScheme>();
|
||||
apiKeyList.add(new ApiKey("Authorization" , "Authorization" , In.HEADER.toValue()));
|
||||
return apiKeyList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 安全上下文
|
||||
*/
|
||||
private List<SecurityContext> securityContexts() {
|
||||
List<SecurityContext> securityContexts = new ArrayList<>();
|
||||
securityContexts.add(
|
||||
SecurityContext.builder()
|
||||
.securityReferences(defaultAuth())
|
||||
.operationSelector(o -> o.requestMappingPattern().matches("/.*"))
|
||||
.build());
|
||||
return securityContexts;
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认的安全上引用
|
||||
*/
|
||||
private List<SecurityReference> defaultAuth() {
|
||||
AuthorizationScope authorizationScope = new AuthorizationScope("global" , "accessEverything");
|
||||
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
|
||||
authorizationScopes[0] = authorizationScope;
|
||||
List<SecurityReference> securityReferences = new ArrayList<>();
|
||||
securityReferences.add(new SecurityReference("Authorization" , authorizationScopes));
|
||||
return securityReferences;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加摘要信息
|
||||
*/
|
||||
private ApiInfo apiInfo() {
|
||||
// 用ApiInfoBuilder进行定制
|
||||
return new ApiInfoBuilder()
|
||||
// 设置标题
|
||||
.title("标题:举视后台管理系统_接口文档")
|
||||
// 描述
|
||||
// .description("描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...")
|
||||
// 作者信息
|
||||
.contact(new Contact(jsowellConfig.getName(), null, null))
|
||||
// 版本
|
||||
.version("版本号:" + jsowellConfig.getVersion())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user