# Conflicts:
#	jsowell-netty/src/main/java/com/jsowell/netty/handler/LoginRequestHandler.java
This commit is contained in:
Lemon
2023-05-15 10:30:53 +08:00
16 changed files with 154 additions and 88 deletions

View File

@@ -1,5 +1,6 @@
package com.jsowell.common.util;
import com.alibaba.fastjson2.JSONObject;
import com.google.common.collect.Lists;
import com.jsowell.common.constant.HttpStatus;
import com.jsowell.common.core.domain.entity.SysDept;
@@ -8,6 +9,7 @@ import com.jsowell.common.core.domain.entity.SysUser;
import com.jsowell.common.core.domain.model.LoginUser;
import com.jsowell.common.core.domain.vo.AuthorizedDeptVO;
import com.jsowell.common.exception.ServiceException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
@@ -19,6 +21,7 @@ import java.util.List;
*
* @author jsowell
*/
@Slf4j
public class SecurityUtils {
/**
* 用户ID
@@ -120,8 +123,10 @@ public class SecurityUtils {
// 登录用户所属部门(运营商或站点 根据父级id判断
SysDept dept = user.getDept();
if (dept == null) {
log.info("用户id:{}, 获取不到所属部门信息", user.getUserId());
return null;
}
log.info("用户id:{}, 所属部门信息:{}", user.getUserId(), JSONObject.toJSONString(dept));
// 登录用户角色
List<SysRole> roles = user.getRoles();
Long parentId = dept.getParentId();

View File

@@ -138,49 +138,47 @@ public class LoginRequestHandler extends AbstractHandler{
if (pileInfoVO != null) {
flag = Constants.zeroByteArray;
// 登录成功保存桩号和channel的关系
PileChannelEntity.put(pileSn, channel);
// 更改桩和该桩下的枪口状态分别为 在线、空闲 公共方法修改状态
pileBasicInfoService.updateStatus(BytesUtil.bcd2Str(ykcDataProtocol.getFrameType()), pileSn, null, null, null);
}
// 充电桩使用的sim卡把信息存库
if (StringUtils.equals("00", internetConnection)) {
try {
pileBasicInfoService.updatePileSimInfo(pileSn, iccid);
} catch (Exception e) {
log.error("更新充电桩sim卡信息失败", e);
// 充电桩使用的sim卡把信息存库
if (StringUtils.equals("00", internetConnection)) {
try {
pileBasicInfoService.updatePileSimInfo(pileSn, iccid);
} catch (Exception e) {
log.error("更新充电桩sim卡信息失败", e);
}
}
CompletableFuture.runAsync(() -> {
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
// 对时
ProofreadTimeCommand command = ProofreadTimeCommand.builder().pileSn(pileSn).build();
ykcPushCommandService.pushProofreadTimeCommand(command);
});
// log.info("下面进行下发二维码 pileSn:{}, thread:{}", pileSn, Thread.currentThread().getName());
CompletableFuture.runAsync(() -> {
try {
Thread.sleep(600);
} catch (InterruptedException e) {
e.printStackTrace();
}
// 下发二维码
IssueQRCodeCommand issueQRCodeCommand = IssueQRCodeCommand.builder().pileSn(pileSn).build();
ykcPushCommandService.pushIssueQRCodeCommand(issueQRCodeCommand);
});
}
// 保存报文
// 保存报文 TODO 没有登录认证通过还要不要保存报文?
String jsonMsg = JSONObject.toJSONString(loginRequestData);
pileMsgRecordService.save(pileSn, pileSn, type, jsonMsg, ykcDataProtocol.getHEXString());
CompletableFuture.runAsync(() -> {
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
// 对时
ProofreadTimeCommand command = ProofreadTimeCommand.builder().pileSn(pileSn).build();
ykcPushCommandService.pushProofreadTimeCommand(command);
});
// log.info("下面进行下发二维码 pileSn:{}, thread:{}", pileSn, Thread.currentThread().getName());
CompletableFuture.runAsync(() -> {
try {
Thread.sleep(600);
} catch (InterruptedException e) {
e.printStackTrace();
}
// 下发二维码
IssueQRCodeCommand issueQRCodeCommand = IssueQRCodeCommand.builder().pileSn(pileSn).build();
ykcPushCommandService.pushIssueQRCodeCommand(issueQRCodeCommand);
});
// 消息体
byte[] messageBody = Bytes.concat(pileSnByte, flag);
return getResult(ykcDataProtocol, messageBody);

View File

@@ -3,6 +3,8 @@ package com.jsowell.pile.dto;
import com.jsowell.common.core.domain.BaseEntity;
import lombok.Data;
import java.util.List;
/**
* 首页数据展示DTO
*
@@ -15,4 +17,6 @@ public class IndexQueryDTO extends BaseEntity {
* 站点id
*/
private String stationId;
private List<String> stationIdList;
}

View File

@@ -1,6 +1,7 @@
package com.jsowell.pile.mapper;
import com.jsowell.pile.domain.PileMerchantInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@@ -67,4 +68,6 @@ public interface PileMerchantInfoMapper {
* @return 结果
*/
public int deletePileMerchantInfoByIds(Long[] ids);
List<String> queryByMerchantDeptIds(@Param("merchantDeptIds") List<String> merchantDeptIds);
}

View File

@@ -77,4 +77,6 @@ public interface PileStationInfoMapper {
* @return
*/
List<PileStationInfo> getStationInfoForLianLian();
List<String> queryByStationDeptIds(@Param("stationDeptIds") List<String> stationDeptIds);
}

View File

@@ -63,4 +63,11 @@ public interface IPileMerchantInfoService {
String getMerchantIdByAppId(String appId);
MerchantInfoVO getMerchantInfo(String merchantId);
/**
* 根据运营商部门ids 查询所有站点id
* @param merchantDeptIds
* @return
*/
List<String> queryByMerchantDeptIds(List<String> merchantDeptIds);
}

View File

@@ -92,4 +92,6 @@ public interface IPileStationInfoService {
PileStationVO getStationInfoByPileSn(String pileSn);
List<PileStationInfo> getStationInfoForLianLian();
List<String> queryByStationDeptIds(List<String> stationIds);
}

View File

@@ -55,6 +55,8 @@ import com.jsowell.pile.service.IPileAuthCardService;
import com.jsowell.pile.service.IPileBasicInfoService;
import com.jsowell.pile.service.IPileBillingTemplateService;
import com.jsowell.pile.service.IPileConnectorInfoService;
import com.jsowell.pile.service.IPileMerchantInfoService;
import com.jsowell.pile.service.IPileStationInfoService;
import com.jsowell.pile.service.OrderMonitorDataService;
import com.jsowell.pile.service.WechatPayService;
import com.jsowell.pile.service.WxpayCallbackRecordService;
@@ -159,6 +161,12 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
@Autowired
private OrderMonitorDataService orderMonitorDataService;
@Autowired
private IPileStationInfoService pileStationInfoService;
@Autowired
private IPileMerchantInfoService pileMerchantInfoService;
/**
* 条件查询订单基本信息
*
@@ -1094,6 +1102,28 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
*/
@Override
public List<IndexOrderInfoVO> getIndexOrderInfo(IndexQueryDTO dto) {
AuthorizedDeptVO authorizedMap = SecurityUtils.getAuthorizedMap();
if (authorizedMap == null) {
return Lists.newArrayList();
}
List<String> stationIdList = Lists.newArrayList();
List<String> stationDeptIds = authorizedMap.getStationDeptIds();
if (CollectionUtils.isNotEmpty(stationDeptIds)) {
// 根据部门id查询站点id
List<String> list = pileStationInfoService.queryByStationDeptIds(stationDeptIds);
if (CollectionUtils.isNotEmpty(list)) {
stationIdList.addAll(list);
}
}
List<String> merchantDeptIds = authorizedMap.getMerchantDeptIds();
if (CollectionUtils.isNotEmpty(merchantDeptIds)) {
// 根据运营商部门id查询下面所有站点id
List<String> list = pileMerchantInfoService.queryByMerchantDeptIds(merchantDeptIds);
if (CollectionUtils.isNotEmpty(list)) {
stationIdList.addAll(list);
}
}
dto.setStationIdList(stationIdList);
return orderBasicInfoMapper.getIndexOrderInfo(dto);
}

View File

@@ -27,6 +27,7 @@ import com.jsowell.pile.service.IPileConnectorInfoService;
import com.jsowell.pile.service.IPileMerchantInfoService;
import com.jsowell.pile.service.IPileModelInfoService;
import com.jsowell.pile.service.IPileSimInfoService;
import com.jsowell.pile.service.IPileStationInfoService;
import com.jsowell.pile.service.SimCardService;
import com.jsowell.pile.vo.base.MerchantInfoVO;
import com.jsowell.pile.vo.base.PileInfoVO;
@@ -71,6 +72,9 @@ public class PileBasicInfoServiceImpl implements IPileBasicInfoService {
@Autowired
private IPileMerchantInfoService pileMerchantInfoService;
@Autowired
private IPileStationInfoService pileStationInfoService;
@Autowired
private IPileSimInfoService pileSimInfoService;
@@ -565,8 +569,25 @@ public class PileBasicInfoServiceImpl implements IPileBasicInfoService {
if (authorizedMap == null) {
return new IndexGeneralSituationVO();
}
dto.setStationDeptIds(authorizedMap.getStationDeptIds());
dto.setMerchantDeptIds(authorizedMap.getMerchantDeptIds());
List<String> stationIdList = Lists.newArrayList();
List<String> stationDeptIds = authorizedMap.getStationDeptIds();
if (CollectionUtils.isNotEmpty(stationDeptIds)) {
// 根据部门id查询站点id
List<String> list = pileStationInfoService.queryByStationDeptIds(stationDeptIds);
if (CollectionUtils.isNotEmpty(list)) {
stationIdList.addAll(list);
}
}
List<String> merchantDeptIds = authorizedMap.getMerchantDeptIds();
if (CollectionUtils.isNotEmpty(merchantDeptIds)) {
// 根据运营商部门id查询下面所有站点id
List<String> list = pileMerchantInfoService.queryByMerchantDeptIds(merchantDeptIds);
if (CollectionUtils.isNotEmpty(list)) {
stationIdList.addAll(list);
}
}
log.info("后管首页基本信息查询 authorizedMap:{}, dto:{}", JSONObject.toJSONString(authorizedMap), JSONObject.toJSONString(dto));
dto.setStationIdList(stationIdList);
return pileBasicInfoMapper.getGeneralSituation(dto);
}

View File

@@ -175,4 +175,9 @@ public class PileMerchantInfoServiceImpl implements IPileMerchantInfoService {
.build();
return vo;
}
@Override
public List<String> queryByMerchantDeptIds(List<String> merchantDeptIds) {
return pileMerchantInfoMapper.queryByMerchantDeptIds(merchantDeptIds);
}
}

View File

@@ -163,6 +163,11 @@ public class PileStationInfoServiceImpl implements IPileStationInfoService {
return pileStationInfoMapper.getStationInfoForLianLian();
}
@Override
public List<String> queryByStationDeptIds(List<String> stationIds) {
return pileStationInfoMapper.queryByStationDeptIds(stationIds);
}
/**
* 查询充电站信息列表
*

View File

@@ -779,7 +779,13 @@
date(t1.create_time) >= DATE_SUB(CURDATE(),INTERVAL 30 day)
and t1.order_status = '6'
<if test="dto.stationId != null and dto.stationId != ''">
and t1,station_id = #{dto.stationId,jdbcType=VARCHAR}
and t1.station_id = #{dto.stationId,jdbcType=VARCHAR}
</if>
<if test="dto.stationIdList != null and dto.stationIdList.size() != 0">
and t1.station_id in
<foreach collection="dto.stationIdList" item="item" open="(" separator="," close=")">
#{item,jdbcType=VARCHAR}
</foreach>
</if>
group by DATE_FORMAT(t1.create_time,'%Y-%m-%d')
</select>

View File

@@ -330,10 +330,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and t1.station_id = #{IndexQueryDTO.stationId,jdbcType=VARCHAR}
</if>
<!-- 数据范围过滤 -->
<if test="IndexQueryDTO.stationDeptIds != null and IndexQueryDTO.stationDeptIds.size() != 0">
<if test="IndexQueryDTO.stationIdList != null and IndexQueryDTO.stationIdList.size() != 0">
and t1.station_id in
<foreach collection="IndexQueryDTO.stationDeptIds" item="stationDeptId" open="(" separator="," close=")">
#{stationDeptId}
<foreach collection="IndexQueryDTO.stationIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
group by t4.totalMemberAmount

View File

@@ -264,4 +264,18 @@
where
app_id = #{appId,jdbcType=VARCHAR}
</select>
<select id="queryByMerchantDeptIds" resultType="java.lang.String">
SELECT
t2.id
FROM
pile_merchant_info t1
LEFT JOIN pile_station_info t2 ON t2.merchant_id = t1.id and t2.del_flag = '0'
WHERE
t1.del_flag = '0'
AND t1.dept_id IN
<foreach collection="merchantDeptIds" item="item" open="(" separator="," close=")">
#{item,jdbcType=VARCHAR}
</foreach>
</select>
</mapper>

View File

@@ -373,4 +373,14 @@
<include refid="selectPileStationInfoVo"/>
where public_flag = '1'
</select>
<select id="queryByStationDeptIds" resultType="java.lang.String">
select id
from pile_station_info
where del_flag = '0'
and dept_id in
<foreach collection="stationDeptIds" item="item" open="(" separator="," close=")">
#{item,jdbcType=VARCHAR}
</foreach>
</select>
</mapper>

View File

@@ -104,7 +104,7 @@
<el-table-column type="selection" width="55" align="center" />
<!--<el-table-column label="ID" align="center" prop="id" />-->
<el-table-column label="会员id" align="center" prop="memberId" />
<el-table-column label="申请订单编号" align="center" prop="orderCodes" />
<!--<el-table-column label="申请订单编号" align="center" prop="orderCodes" />-->
<el-table-column label="状态" align="center" prop="status" >
<template slot-scope="scope">
<dict-tag
@@ -116,16 +116,10 @@
<el-table-column label="开票总金额" align="center" prop="totalAmount" />
<el-table-column label="总服务费金额" align="center" prop="totalServiceAmount" />
<el-table-column label="总电费金额" align="center" prop="totalElecAmount" />
<el-table-column label="申请时间" align="center" prop="createTime" />
<el-table-column label="开票时间" align="center" prop="updateTime" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<!--<el-button
v-if="scope.row.status === '0'"
size="mini"
type="text"
icon="el-icon-edit"
@click="clickInvoiceStatus(scope.row.id)"
v-hasPermi="['order:invoice:edit']"
>已开发票</el-button>-->
<el-button
size="mini"
type="text"
@@ -144,46 +138,6 @@
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改申请开票对话框 -->
<!--<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>-->
<!-- <el-form ref="form" :model="form" :rules="rules" label-width="80px">-->
<!-- <el-form-item label="会员id" prop="memberId">-->
<!-- <el-input v-model="form.memberId" placeholder="请输入会员id" />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="申请订单编号" prop="orderCodes">-->
<!-- <el-input v-model="form.orderCodes" placeholder="请输入申请订单编号" />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="开票总金额" prop="totalAmount">-->
<!-- <el-input v-model="form.totalAmount" placeholder="请输入开票总金额" />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="总服务费金额" prop="totalServiceAmount">-->
<!-- <el-input v-model="form.totalServiceAmount" placeholder="请输入总服务费金额" />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="总电费金额" prop="totalElecAmount">-->
<!-- <el-input v-model="form.totalElecAmount" placeholder="请输入总电费金额" />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="删除标识" prop="delFlag">-->
<!-- <el-input v-model="form.delFlag" placeholder="请输入删除标识" />-->
<!-- </el-form-item>-->
<!-- </el-form>-->
<!-- <div slot="footer" class="dialog-footer">-->
<!-- <el-button type="primary" @click="submitForm"> </el-button>-->
<!-- <el-button @click="cancel"> </el-button>-->
<!-- </div>-->
<!--</el-dialog>-->
<el-dialog
title="提示"
:visible.sync="dialogVisible"
width="35%"
>
点击确定将此记录更改为已开票状态
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" @click="updateInvoiceStatus"> </el-button>
</span>
</el-dialog>
</div>
</template>