提交 fe237fda authored 作者: liuhaiquan's avatar liuhaiquan

Merge remote-tracking branch 'origin/v5.5_settlement_20231011' into v5.5_settlement_20231011

...@@ -3,6 +3,9 @@ package com.clx.performance.enums; ...@@ -3,6 +3,9 @@ package com.clx.performance.enums;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import java.util.Arrays;
import java.util.Optional;
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
@SuppressWarnings("all") @SuppressWarnings("all")
...@@ -18,6 +21,17 @@ public enum OwnerAccountEnum { ...@@ -18,6 +21,17 @@ public enum OwnerAccountEnum {
private final Integer code; private final Integer code;
private final String msg; private final String msg;
public static Optional<OwnerAccountEnum.AccountTypeStatus> getByCode(int code) {
return Arrays.stream(values()).filter(e -> e.code.equals(code)).findFirst();
}
public Integer getCode() {
return this.code;
}
public String getMsg() {
return this.msg;
}
} }
@Getter @Getter
...@@ -58,6 +72,16 @@ public enum OwnerAccountEnum { ...@@ -58,6 +72,16 @@ public enum OwnerAccountEnum {
; ;
private final Integer code; private final Integer code;
private final String msg; private final String msg;
public static Optional<OwnerAccountEnum.RunningWaterStatus> getByCode(int code) {
return Arrays.stream(values()).filter(e -> e.code.equals(code)).findFirst();
}
public Integer getCode() {
return this.code;
}
public String getMsg() {
return this.msg;
}
} }
} }
...@@ -28,5 +28,8 @@ public class PlatformAccountTopUpParam{ ...@@ -28,5 +28,8 @@ public class PlatformAccountTopUpParam{
@ApiModelProperty(value="审批拒绝原因") @ApiModelProperty(value="审批拒绝原因")
private String turnDownContent; private String turnDownContent;
@ApiModelProperty(value="是否通过 1:通过 0:拒绝",example = "true")
private Boolean passType;
} }
package com.clx.performance.vo.pc; package com.clx.performance.vo.pc;
import com.msl.common.convertor.type.MoneyOutConvert;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
...@@ -77,22 +78,30 @@ public class OwnerAccountRunningWaterRecordVO { ...@@ -77,22 +78,30 @@ public class OwnerAccountRunningWaterRecordVO {
* 变动金额 * 变动金额
*/ */
@ApiModelProperty("变动金额") @ApiModelProperty("变动金额")
@MoneyOutConvert
private BigDecimal alterationBalance; private BigDecimal alterationBalance;
/** /**
* 冻结金额 * 冻结金额
*/ */
@ApiModelProperty("冻结金额") @ApiModelProperty("冻结金额")
@MoneyOutConvert
private BigDecimal frozenBalance; private BigDecimal frozenBalance;
/** /**
* 可用余额 * 可用余额
*/ */
@ApiModelProperty("可用余额") @ApiModelProperty("可用余额")
@MoneyOutConvert
private BigDecimal usableBalance; private BigDecimal usableBalance;
/** /**
* 账户余额 * 账户余额
*/ */
@ApiModelProperty("账户余额") @ApiModelProperty("账户余额")
@MoneyOutConvert
private BigDecimal accountBalance; private BigDecimal accountBalance;
@ApiModelProperty("扣除金额")
@MoneyOutConvert
private BigDecimal takeOutBalance;
/** /**
* 操作人 * 操作人
*/ */
......
...@@ -39,7 +39,7 @@ public class OwnerCaseOutVO { ...@@ -39,7 +39,7 @@ public class OwnerCaseOutVO {
* 提现账户类型 * 提现账户类型
*/ */
@ApiModelProperty(value = "id") @ApiModelProperty(value = "id")
private Integer caseOutType; private Integer accountType;
/** /**
* 提现金额 * 提现金额
*/ */
......
...@@ -36,8 +36,8 @@ public class OwnerTopUpVO { ...@@ -36,8 +36,8 @@ public class OwnerTopUpVO {
/** /**
* 充值类型 * 充值类型
*/ */
@ApiModelProperty(value = "充值类型") @ApiModelProperty(value = "充值类型 1:保证金 2:预付运费")
private Integer topUpType; private Integer accountType;
/** /**
* 充值金额 * 充值金额
*/ */
...@@ -46,7 +46,7 @@ public class OwnerTopUpVO { ...@@ -46,7 +46,7 @@ public class OwnerTopUpVO {
/** /**
* 状态 * 状态
*/ */
@ApiModelProperty(value = "状态") @ApiModelProperty(value = "状态 10:待审批 20:审批拒绝 30:审批通过")
private Integer status; private Integer status;
/** /**
* 打款银行 * 打款银行
......
package com.clx.performance.data; package com.clx.performance.sdk.callback.message;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Getter; import lombok.*;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import java.math.BigDecimal; import java.math.BigDecimal;
import static com.clx.performance.sdk.constant.MessageConstants.ORDER_CHILD_INFO_SYNC;
@Getter @Getter
@Setter @Setter
@ToString @ToString
@NoArgsConstructor @NoArgsConstructor
public class OrderChildData { @AllArgsConstructor
@Builder
@EqualsAndHashCode
public class OrderChildMessage implements Message{
@ApiModelProperty(value = "运单编号", example = "100000000") @ApiModelProperty(value = "运单编号", example = "100000000")
private String childNo; private String childNo;
...@@ -47,4 +49,9 @@ public class OrderChildData { ...@@ -47,4 +49,9 @@ public class OrderChildData {
@ApiModelProperty(value="卸货净重",example = "41") @ApiModelProperty(value="卸货净重",example = "41")
private BigDecimal unloadNet; private BigDecimal unloadNet;
@Override
public String topic() {
return ORDER_CHILD_INFO_SYNC;
}
} }
package com.clx.performance.sdk.callback.message;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import static com.clx.performance.sdk.constant.MessageConstants.QUOTATION_INFO_SYNC;
/**
* @ClassName Quotation
* @Description 同步调价
* @Author kavin
* @Date 2023/10/14 17:56
* @Version 1.0
*/
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class QuotationUpdateMessage implements Message{
@ApiModelProperty(value = "订单编号")
private String orderNo;
@ApiModelProperty(value = "平台报价价格")
private BigDecimal platformFreightQuotation;
@ApiModelProperty(value = "报价超时时间")
private LocalDateTime quotationTimeoutTime;
@Override
public String topic() {
return QUOTATION_INFO_SYNC;
}
}
...@@ -3,7 +3,13 @@ package com.clx.performance.sdk.constant; ...@@ -3,7 +3,13 @@ package com.clx.performance.sdk.constant;
public class MessageConstants { public class MessageConstants {
public static final String QUOTATION_INFO_SYNC = "quotation.info.sync"; public static final String APP_ID = "app_id";
public static final String APP_SECRET = "app_secret";
public static final String ORDER_CHILD_INFO_SYNC_URL = "order_child_info_sync_url";
public static final String ORDER_CHILD_INFO_SYNC = "order.child.info.sync";
} }
...@@ -45,6 +45,12 @@ ...@@ -45,6 +45,12 @@
<artifactId>user-api</artifactId> <artifactId>user-api</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.clx.cy</groupId>
<artifactId>performance-sdk</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency> <dependency>
<groupId>com.msl</groupId> <groupId>com.msl</groupId>
<artifactId>user-sdk</artifactId> <artifactId>user-sdk</artifactId>
......
...@@ -104,17 +104,17 @@ public class OrderGoodsStatusLazyComponent implements InitializingBean { ...@@ -104,17 +104,17 @@ public class OrderGoodsStatusLazyComponent implements InitializingBean {
BigDecimal childSum = list.stream().map(OrderGoods::getExtractWeight).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal childSum = list.stream().map(OrderGoods::getExtractWeight).reduce(BigDecimal.ZERO, BigDecimal::add);
log.info("算出所有货单总量:{}, 订单总吨数:{}", childSum, orderInfoFeign.getTransportWeight()); log.info("算出所有货单总量:{}, 订单总吨数:{}", childSum, orderInfoFeign.getTransportWeight());
if (childSum.compareTo(new BigDecimal(orderInfoFeign.getTransportWeight())) == 0) { // if (childSum.compareTo(new BigDecimal(orderInfoFeign.getTransportWeight())) == 0) {
log.info("已完成的货单已经等于订单的拉运吨数,提前更新订单状态 已完成"); // log.info("已完成的货单已经等于订单的拉运吨数,提前更新订单状态 已完成");
//已完成的货单已经等于订单的拉运吨数,提前更新订单状态 已完成 // //已完成的货单已经等于订单的拉运吨数,提前更新订单状态 已完成
UpdateOrderInfoParam updateOrderInfoParam = new UpdateOrderInfoParam(); // UpdateOrderInfoParam updateOrderInfoParam = new UpdateOrderInfoParam();
updateOrderInfoParam.setOrderId(orderInfoFeign.getId()); // updateOrderInfoParam.setOrderId(orderInfoFeign.getId());
updateOrderInfoParam.setOrderStatus(OrderEnum.Status.SUCCESS.getCode()); // updateOrderInfoParam.setOrderStatus(OrderEnum.Status.SUCCESS.getCode());
orderFeign.updateOrderInfo(updateOrderInfoParam); // orderFeign.updateOrderInfo(updateOrderInfoParam);
} else { // } else {
log.info("判断吨数不一致:childSum{}, transportWeight {}", childSum, new BigDecimal(orderInfoFeign.getTransportWeight())); // log.info("判断吨数不一致:childSum{}, transportWeight {}", childSum, new BigDecimal(orderInfoFeign.getTransportWeight()));
//
} // }
} else { } else {
log.info("当前货单状态为已完结"); log.info("当前货单状态为已完结");
//更新货单已完结 //更新货单已完结
......
...@@ -9,6 +9,7 @@ import com.clx.performance.vo.pc.OwnerAccountRunningWaterRecordVO; ...@@ -9,6 +9,7 @@ import com.clx.performance.vo.pc.OwnerAccountRunningWaterRecordVO;
import com.clx.performance.vo.pc.OwnerAccountVO; import com.clx.performance.vo.pc.OwnerAccountVO;
import com.clx.performance.vo.pc.OwnerCaseOutVO; import com.clx.performance.vo.pc.OwnerCaseOutVO;
import com.clx.performance.vo.pc.OwnerTopUpVO; import com.clx.performance.vo.pc.OwnerTopUpVO;
import com.clx.user.param.pc.driver.truck.PageDriverTruckParam;
import com.msl.common.base.PageData; import com.msl.common.base.PageData;
import com.msl.common.convertor.aspect.UnitCovert; import com.msl.common.convertor.aspect.UnitCovert;
import com.msl.common.result.Result; import com.msl.common.result.Result;
...@@ -16,9 +17,14 @@ import io.swagger.annotations.Api; ...@@ -16,9 +17,14 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
...@@ -53,6 +59,14 @@ public class CarrierAccountController { ...@@ -53,6 +59,14 @@ public class CarrierAccountController {
return Result.page(page.getRecords(), page.getTotal(), page.getPages()); return Result.page(page.getRecords(), page.getTotal(), page.getPages());
} }
@ApiOperation(value = "保证金账户详情流水下载")
@PostMapping("/exportMarginAccountPageList")
public void exportMarginAccountPageList(@RequestBody @Validated PagePlatformMarginAccountParam param, HttpServletResponse response) throws Exception {
SXSSFWorkbook workbook = ownerAccountService.exportMarginAccountPageList(param);
response.setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_OCTET_STREAM_VALUE);
workbook.write(response.getOutputStream());
}
@ApiOperation(value = "预付金账户详情流水列表", notes = "<br>By:胡宇帆") @ApiOperation(value = "预付金账户详情流水列表", notes = "<br>By:胡宇帆")
@PostMapping("/prepaidFreightAccountPageList") @PostMapping("/prepaidFreightAccountPageList")
@UnitCovert(param = false) @UnitCovert(param = false)
...@@ -61,6 +75,14 @@ public class CarrierAccountController { ...@@ -61,6 +75,14 @@ public class CarrierAccountController {
return Result.page(page.getRecords(), page.getTotal(), page.getPages()); return Result.page(page.getRecords(), page.getTotal(), page.getPages());
} }
@ApiOperation(value = "预付金账户详情流水下载")
@PostMapping("/exportPrepaidFreightAccountPageList")
public void exportPrepaidFreightAccountPageList(@RequestBody @Validated PagePlatformPrepaidFreightAccountParam param, HttpServletResponse response) throws Exception {
SXSSFWorkbook workbook = ownerAccountService.exportPrepaidFreightAccountPageList(param);
response.setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_OCTET_STREAM_VALUE);
workbook.write(response.getOutputStream());
}
@ApiOperation(value = "充值审批", notes = "<br>By:胡宇帆") @ApiOperation(value = "充值审批", notes = "<br>By:胡宇帆")
@PostMapping("/accountTopUpApprove") @PostMapping("/accountTopUpApprove")
......
package com.clx.performance.controller.pc.owner; package com.clx.performance.controller.pc.owner;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.clx.performance.model.OwnerTransferInfo;
import com.clx.performance.param.pc.*; import com.clx.performance.param.pc.*;
import com.clx.performance.service.OwnerAccountService; import com.clx.performance.service.OwnerAccountService;
import com.clx.performance.service.OwnerCaseOutService; import com.clx.performance.service.OwnerCaseOutService;
...@@ -10,6 +11,9 @@ import com.clx.performance.vo.pc.OwnerAccountRunningWaterRecordVO; ...@@ -10,6 +11,9 @@ import com.clx.performance.vo.pc.OwnerAccountRunningWaterRecordVO;
import com.clx.performance.vo.pc.OwnerAccountVO; import com.clx.performance.vo.pc.OwnerAccountVO;
import com.clx.performance.vo.pc.OwnerCaseOutVO; import com.clx.performance.vo.pc.OwnerCaseOutVO;
import com.clx.performance.vo.pc.OwnerTopUpVO; import com.clx.performance.vo.pc.OwnerTopUpVO;
import com.clx.user.feign.OwnerInfoFeign;
import com.clx.user.param.pc.owner.UpdateOwnerBindCardFeignParam;
import com.clx.user.vo.pc.owner.OwnerBindCardVO;
import com.msl.common.base.PageData; import com.msl.common.base.PageData;
import com.msl.common.convertor.aspect.UnitCovert; import com.msl.common.convertor.aspect.UnitCovert;
import com.msl.common.result.Result; import com.msl.common.result.Result;
...@@ -17,9 +21,14 @@ import io.swagger.annotations.Api; ...@@ -17,9 +21,14 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.List; import java.util.List;
...@@ -39,6 +48,8 @@ public class OwnerAccountController { ...@@ -39,6 +48,8 @@ public class OwnerAccountController {
private final OwnerRunningWaterRecordService ownerRunningWaterRecordService; private final OwnerRunningWaterRecordService ownerRunningWaterRecordService;
private final OwnerInfoFeign ownerInfoFeign;
@ApiOperation(value = "账户信息", notes = "<br>By:胡宇帆") @ApiOperation(value = "账户信息", notes = "<br>By:胡宇帆")
@GetMapping("/accountInfo") @GetMapping("/accountInfo")
@UnitCovert(param = false) @UnitCovert(param = false)
...@@ -95,4 +106,38 @@ public class OwnerAccountController { ...@@ -95,4 +106,38 @@ public class OwnerAccountController {
IPage<OwnerAccountRunningWaterRecordVO> page = ownerRunningWaterRecordService.ownerAccountRunningWaterPageList(param); IPage<OwnerAccountRunningWaterRecordVO> page = ownerRunningWaterRecordService.ownerAccountRunningWaterPageList(param);
return Result.page(page.getRecords(), page.getTotal(), page.getPages()); return Result.page(page.getRecords(), page.getTotal(), page.getPages());
} }
@ApiOperation(value = "货主账户流水列表下载")
@PostMapping("/exportOwnerAccountRunningWaterPageList")
public void exportOwnerAccountRunningWaterPageList(@RequestBody @Validated PageOwnerAccountRunningWaterParam param, HttpServletResponse response) throws Exception {
SXSSFWorkbook workbook = ownerRunningWaterRecordService.exportOwnerAccountRunningWaterPageList(param);
response.setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_OCTET_STREAM_VALUE);
workbook.write(response.getOutputStream());
}
@ApiOperation(value = "对公转账信息", notes = "<br>By:胡宇帆")
@GetMapping("/transferPublic")
public Result<OwnerTransferInfo> transferPublic() {
return Result.ok(ownerAccountService.transferPublic());
}
@ApiOperation(value = "获取货主信息绑卡信息", notes = "<br>By:胡宇帆")
@GetMapping("/getOwnerBindCard")
public Result<OwnerBindCardVO> getOwnerBindCard(@RequestParam("userNo") @NotNull(message = "userNo不能为空") Long userNo) {
return Result.ok(ownerAccountService.getOwnerBindCard(userNo));
}
@ApiOperation(value = "绑定货主银行卡")
@PostMapping({"/bindOwnerBindCard"})
Result<Object> bindOwnerBindCard(@RequestBody UpdateOwnerBindCardFeignParam param) {
ownerAccountService.bindOwnerBindCard(param);
return Result.ok();
}
@ApiOperation(value = "解绑货主银行卡")
@PostMapping({"/unBindOwnerBindCard"})
Result<Object> unBindOwnerBindCard(@RequestBody UpdateOwnerBindCardFeignParam param) {
ownerAccountService.unBindOwnerBindCard(param);
return Result.ok();
}
} }
package com.clx.performance.dao;
import com.clx.performance.mapper.OwnerTransferInfoMapper;
import com.clx.performance.model.OwnerTransferInfo;
import com.msl.common.dao.BaseDao;
/**
* @author kavin
* Date 2023-10-16
* Time 20:01
*/
public interface OwnerTransferInfoDao extends BaseDao<OwnerTransferInfoMapper, OwnerTransferInfo, Integer> {
}
package com.clx.performance.dao.impl;
import com.clx.performance.dao.OwnerTransferInfoDao;
import com.clx.performance.mapper.OwnerTransferInfoMapper;
import com.clx.performance.model.OwnerTransferInfo;
import com.msl.common.dao.impl.BaseDaoImpl;
import org.springframework.stereotype.Repository;
/**
* @author kavin
* Date 2023-10-16
* Time 20:01
*/
@Repository
public class OwnerTransferInfoDaoImpl extends BaseDaoImpl<OwnerTransferInfoMapper, OwnerTransferInfo, Integer> implements OwnerTransferInfoDao {
}
package com.clx.performance.dto.zjxl.dts; package com.clx.performance.dto.dts;
import com.clx.performance.enums.DtsOperationTypeEnum; import com.clx.performance.enums.DtsOperationTypeEnum;
import lombok.Data; import lombok.Data;
......
package com.clx.performance.extranal.encrypt;
import com.msl.common.result.Result;
public interface EncryptService {
/**
* @Author kavin
* @Description 加密请求
* @Param [appId, secret, url, param, action]
* @return
**/
Result<?> encryptPost(String appId,String secret,String url,String param, String action);
}
package com.clx.performance.extranal.encrypt.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.clx.performance.extranal.encrypt.EncryptService;
import com.google.gson.Gson;
import com.msl.common.dto.HttpDTO;
import com.msl.common.exception.ServiceSystemException;
import com.msl.common.result.Result;
import com.msl.common.utils.EncryptUtil;
import com.msl.common.utils.HttpUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.security.GeneralSecurityException;
import static com.clx.user.enums.result.UserResultEnum.HTTP_ERROR;
@Service
@Slf4j
public class EncryptServiceImpl implements EncryptService {
@Override
public Result<?> encryptPost(String appId,String secret,String url,String param,String action) {
log.info("开始请求交易平台接口,请求action:{},请求参数:{}",action,param);
try {
HttpDTO httpDTO = EncryptUtil.buildDTO(appId, param, secret, System.currentTimeMillis());
httpDTO.setAction(action);
return HttpUtil.post(url, null, httpDTO)
.map(r -> JSON.parseObject(r, new TypeReference<HttpDTO>() {
}))
.peek(dto -> log.info("http请求返回------dto->{}", dto))
.map(HttpDTO::getData)
.mapTry(d -> EncryptUtil.decrypt(d, secret))
.mapWithObj(new TypeReference<Result<Object>>() {
}, this::covertResult)
.orElseThrow(HTTP_ERROR);
} catch (GeneralSecurityException e) {
log.error("解密失败", e);
throw new ServiceSystemException(HTTP_ERROR);
}
}
private <T> Result<T> covertResult(String result, TypeReference<Result<T>> reference) {
return new Gson().fromJson(result, reference.getType());
}
}
...@@ -2,11 +2,13 @@ package com.clx.performance.listener; ...@@ -2,11 +2,13 @@ package com.clx.performance.listener;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.clx.performance.constant.RabbitKeyConstants; import com.clx.performance.constant.RabbitKeyConstants;
import com.clx.performance.data.OrderChildData; import com.clx.performance.dto.dts.DataTransportDTO;
import com.clx.performance.dto.zjxl.dts.DataTransportDTO;
import com.clx.performance.enums.DtsOperationTypeEnum; import com.clx.performance.enums.DtsOperationTypeEnum;
import com.clx.performance.enums.OrderChildEnum; import com.clx.performance.enums.OrderChildEnum;
//import com.msl.common.utils.DtsMapConvertUtil; import com.clx.performance.extranal.encrypt.EncryptService;
import com.clx.performance.sdk.callback.message.OrderChildMessage;
import com.msl.common.utils.DtsMapConvertUtil;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message; import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.amqp.rabbit.annotation.RabbitListener;
...@@ -14,39 +16,47 @@ import org.springframework.stereotype.Component; ...@@ -14,39 +16,47 @@ import org.springframework.stereotype.Component;
import java.util.Objects; import java.util.Objects;
import static com.clx.performance.sdk.constant.MessageConstants.*;
@Slf4j @Slf4j
@Component @Component
@AllArgsConstructor
public class OrderChildDtsListener { public class OrderChildDtsListener {
private final EncryptService encryptService;
@RabbitListener(queues = RabbitKeyConstants.CLX_PERFORMANCE_ORDER_CHILD_QUEUE)
public void onMessage(Message message) {
try {
String msg = new String(message.getBody());
log.info("DTS消息同步开始, database:clx_performance.order_child, msg:{}", msg);
DataTransportDTO dataTransportDTO = JSON.parseObject(msg, DataTransportDTO.class);
OrderChildMessage before = DtsMapConvertUtil.convert(dataTransportDTO.getBeforeMap(), new OrderChildMessage());
OrderChildMessage after = DtsMapConvertUtil.convert(dataTransportDTO.getAfterMap(), new OrderChildMessage());
if(Objects.equals(DtsOperationTypeEnum.INSERT.getCode(),dataTransportDTO.getOperationType().getCode())){
//同步after数据
log.info("新增:{}"+after);
encryptService.encryptPost(APP_ID,APP_SECRET,ORDER_CHILD_INFO_SYNC_URL,JSON.toJSONString(after),after.topic());
}else if(Objects.equals(DtsOperationTypeEnum.UPDATE.getCode(),dataTransportDTO.getOperationType().getCode())){
if(OrderChildEnum.SYNC_STATUS_lIST.contains(after.getStatus()) && !Objects.equals(before.getStatus(),after.getStatus())){
//同步after数据
log.info("修改:{}"+after);
encryptService.encryptPost(APP_ID,APP_SECRET,ORDER_CHILD_INFO_SYNC_URL,JSON.toJSONString(after),after.topic());
}
}else if(Objects.equals(DtsOperationTypeEnum.DELETE.getCode(),dataTransportDTO.getOperationType().getCode())){
//数据删除
log.info("删除:{}"+before);
encryptService.encryptPost(APP_ID,APP_SECRET,ORDER_CHILD_INFO_SYNC_URL,JSON.toJSONString(before),before.topic());
}
//@RabbitListener(queues = RabbitKeyConstants.CLX_PERFORMANCE_ORDER_CHILD_QUEUE) } catch (Exception e) {
// public void onMessage(Message message) { log.info("DTS消息同步失败, database:clx_performance.order_child, error:{}", e.getMessage());
// try { }
// String msg = new String(message.getBody()); }
// log.info("DTS消息同步开始, database:clx_performance.order_child, msg:{}", msg);
//
// DataTransportDTO dataTransportDTO = JSON.parseObject(msg, DataTransportDTO.class);
//
// OrderChildData before = DtsMapConvertUtil.convert(dataTransportDTO.getBeforeMap(), new OrderChildData());
// OrderChildData after = DtsMapConvertUtil.convert(dataTransportDTO.getAfterMap(), new OrderChildData());
//
// if(Objects.equals(DtsOperationTypeEnum.INSERT.getCode(),dataTransportDTO.getOperationType().getCode())){
// //同步after数据
// System.out.println("新增:"+after);
// }else if(Objects.equals(DtsOperationTypeEnum.UPDATE.getCode(),dataTransportDTO.getOperationType().getCode())){
// if(OrderChildEnum.SYNC_STATUS_lIST.contains(after.getStatus()) && !Objects.equals(before.getStatus(),after.getStatus())){
// //同步after数据
// System.out.println("修改:"+after);
// }
// }else if(Objects.equals(DtsOperationTypeEnum.UPDATE.getCode(),dataTransportDTO.getOperationType().getCode())){
// //数据删除
// System.out.println("删除:"+before);
// }
//
//
// } catch (Exception e) {
// log.info("DTS消息同步失败, database:clx_performance.order_child, error:{}", e.getMessage());
// }
// }
} }
package com.clx.performance.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.clx.performance.model.OwnerTransferInfo;
/**
* @author kavin
* Date 2023-10-16
* Time 20:01
*/
public interface OwnerTransferInfoMapper extends BaseMapper<OwnerTransferInfo> {
}
...@@ -107,6 +107,12 @@ public class OwnerRunningWaterRecord implements HasKey<Integer> { ...@@ -107,6 +107,12 @@ public class OwnerRunningWaterRecord implements HasKey<Integer> {
*/ */
@TableField("account_balance") @TableField("account_balance")
private BigDecimal accountBalance; private BigDecimal accountBalance;
/**
* 扣除金额
*/
@TableField("take_out_balance")
private BigDecimal takeOutBalance;
/** /**
* 操作人 * 操作人
*/ */
......
package com.clx.performance.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.msl.common.config.KeyColumn;
import com.msl.common.model.HasKey;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
/**
* @author kavin
* Date 2023-10-16
* Time 20:01
*/
@Getter
@Setter
@Accessors(chain = true)
@TableName("owner_transfer_info")
public class OwnerTransferInfo implements HasKey<Integer> {
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@TableField("transfer_tip")
@ApiModelProperty("转账提示信息")
private String transferTip;
@TableField("enterprise_name")
@ApiModelProperty("企业信息")
private String enterpriseName;
@TableField("open_account_bank")
@ApiModelProperty("开户行")
private String openAccountBank;
@TableField("open_account_bank_number")
@ApiModelProperty("开户行银行代码")
private String openAccountBankNumber;
@TableField("account_number")
@ApiModelProperty("账户账号")
private String accountNumber;
@TableField("create_time")
@ApiModelProperty("创建时间")
private LocalDateTime createTime;
@TableField("modified_time")
@ApiModelProperty("修改时间")
private LocalDateTime modifiedTime;
@Override
@KeyColumn("id")
public Integer gainKey() {
return this.id;
}
}
package com.clx.performance.service; package com.clx.performance.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.clx.performance.model.OwnerTransferInfo;
import com.clx.performance.param.pc.*; import com.clx.performance.param.pc.*;
import com.clx.performance.vo.pc.OwnerAccountRunningWaterRecordVO; import com.clx.performance.vo.pc.OwnerAccountRunningWaterRecordVO;
import com.clx.performance.vo.pc.OwnerAccountVO; import com.clx.performance.vo.pc.OwnerAccountVO;
import com.clx.user.param.pc.owner.UpdateOwnerBindCardFeignParam;
import com.clx.user.vo.pc.owner.OwnerBindCardVO;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import java.util.List; import java.util.List;
...@@ -36,4 +40,26 @@ public interface OwnerAccountService { ...@@ -36,4 +40,26 @@ public interface OwnerAccountService {
* @param id * @param id
*/ */
void accountBalanceConfirm(Integer id); void accountBalanceConfirm(Integer id);
/**
*保证金导出
* @param param
* @return
*/
SXSSFWorkbook exportMarginAccountPageList(PagePlatformMarginAccountParam param);
/**
* 预付金导出
* @param param
* @return
*/
SXSSFWorkbook exportPrepaidFreightAccountPageList(PagePlatformPrepaidFreightAccountParam param);
OwnerTransferInfo transferPublic();
OwnerBindCardVO getOwnerBindCard(Long userNo);
void bindOwnerBindCard(UpdateOwnerBindCardFeignParam param);
void unBindOwnerBindCard(UpdateOwnerBindCardFeignParam param);
} }
...@@ -3,6 +3,7 @@ package com.clx.performance.service; ...@@ -3,6 +3,7 @@ package com.clx.performance.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.clx.performance.param.pc.PageOwnerAccountRunningWaterParam; import com.clx.performance.param.pc.PageOwnerAccountRunningWaterParam;
import com.clx.performance.vo.pc.OwnerAccountRunningWaterRecordVO; import com.clx.performance.vo.pc.OwnerAccountRunningWaterRecordVO;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
public interface OwnerRunningWaterRecordService { public interface OwnerRunningWaterRecordService {
...@@ -12,4 +13,11 @@ public interface OwnerRunningWaterRecordService { ...@@ -12,4 +13,11 @@ public interface OwnerRunningWaterRecordService {
* @return * @return
*/ */
IPage<OwnerAccountRunningWaterRecordVO> ownerAccountRunningWaterPageList(PageOwnerAccountRunningWaterParam param); IPage<OwnerAccountRunningWaterRecordVO> ownerAccountRunningWaterPageList(PageOwnerAccountRunningWaterParam param);
/**
* 货主资金账户管理流水下载
* @param param
* @return
*/
SXSSFWorkbook exportOwnerAccountRunningWaterPageList(PageOwnerAccountRunningWaterParam param);
} }
...@@ -2,13 +2,22 @@ package com.clx.performance.service.impl; ...@@ -2,13 +2,22 @@ package com.clx.performance.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.clx.performance.dao.OwnerRunningWaterRecordDao; import com.clx.performance.dao.OwnerRunningWaterRecordDao;
import com.clx.performance.enums.OwnerAccountEnum;
import com.clx.performance.param.pc.PageOwnerAccountRunningWaterParam; import com.clx.performance.param.pc.PageOwnerAccountRunningWaterParam;
import com.clx.performance.service.OwnerRunningWaterRecordService; import com.clx.performance.service.OwnerRunningWaterRecordService;
import com.clx.performance.utils.excel.ExcelData;
import com.clx.performance.utils.excel.ExcelField;
import com.clx.performance.utils.excel.ExcelSheet;
import com.clx.performance.utils.excel.ExcelUtil;
import com.clx.performance.vo.pc.OwnerAccountRunningWaterRecordVO; import com.clx.performance.vo.pc.OwnerAccountRunningWaterRecordVO;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Slf4j @Slf4j
@Service @Service
@AllArgsConstructor @AllArgsConstructor
...@@ -20,4 +29,62 @@ public class OwnerRunningWaterRecordServiceImpl implements OwnerRunningWaterReco ...@@ -20,4 +29,62 @@ public class OwnerRunningWaterRecordServiceImpl implements OwnerRunningWaterReco
public IPage<OwnerAccountRunningWaterRecordVO> ownerAccountRunningWaterPageList(PageOwnerAccountRunningWaterParam param) { public IPage<OwnerAccountRunningWaterRecordVO> ownerAccountRunningWaterPageList(PageOwnerAccountRunningWaterParam param) {
return ownerRunningWaterRecordDao.ownerAccountRunningWaterPageList(param); return ownerRunningWaterRecordDao.ownerAccountRunningWaterPageList(param);
} }
@Override
public SXSSFWorkbook exportOwnerAccountRunningWaterPageList(PageOwnerAccountRunningWaterParam param) {
IPage<OwnerAccountRunningWaterRecordVO> page = ownerRunningWaterRecordDao.ownerAccountRunningWaterPageList(param);
List<OwnerAccountRunningWaterRecordVO> list = page.getRecords();
// 组装表头
List<ExcelField> fieldList = new ArrayList<>();
fieldList.add(new ExcelField(0, "序号", "index", 2000));
fieldList.add(new ExcelField(1, "货主编码", "ownerUserNo", 5000));
fieldList.add(new ExcelField(2, "货主名称", "ownerName", 5000));
fieldList.add(new ExcelField(3, "联系电话", "mobile", 5000));
fieldList.add(new ExcelField(4, "账户类型", "accountType", 15000));
fieldList.add(new ExcelField(5, "流水类型", "runningWaterType", 5000));
fieldList.add(new ExcelField(6, "订单编号", "orderNo", 5000));
fieldList.add(new ExcelField(7, "运单编号", "orderChildNo", 5000));
fieldList.add(new ExcelField(8, "变动金额", "alterationBalance", 5000));
fieldList.add(new ExcelField(9, "冻结金额", "frozenBalance", 5000));
fieldList.add(new ExcelField(10, "可用余额", "usableBalance", 5000));
fieldList.add(new ExcelField(11, "账户余额", "accountBalance", 5000));
fieldList.add(new ExcelField(12, "扣除金额", "takeOutBalance", 5000));
fieldList.add(new ExcelField(13, "流水编号", "runningWaterNo", 5000));
fieldList.add(new ExcelField(14, "操作人", "createBy", 5000));
fieldList.add(new ExcelField(15, "操作时间", "createTime", 5000));
// 组装数据
List<List<ExcelData>> dataList = new ArrayList<>();
for (int i=0; i<list.size(); i++){
OwnerAccountRunningWaterRecordVO dto = list.get(i);
List<ExcelData> rowData = new ArrayList<>();
rowData.add(new ExcelData(i+1));
rowData.add(new ExcelData(dto.getOwnerUserNo().toString()));
rowData.add(new ExcelData(dto.getOwnerName()));
rowData.add(new ExcelData(dto.getMobile()));
rowData.add(new ExcelData(OwnerAccountEnum.AccountTypeStatus.getByCode(dto.getAccountType()).get().getMsg()));
rowData.add(new ExcelData(OwnerAccountEnum.RunningWaterStatus.getByCode(dto.getRunningWaterType()).get().getMsg()));
rowData.add(new ExcelData(dto.getOrderNo()));
rowData.add(new ExcelData(dto.getOrderChildNo()));
rowData.add(new ExcelData(dto.getAlterationBalance()));
rowData.add(new ExcelData(dto.getFrozenBalance()));
rowData.add(new ExcelData(dto.getUsableBalance()));
rowData.add(new ExcelData(dto.getAccountBalance()));
rowData.add(new ExcelData(dto.getTakeOutBalance()));
rowData.add(new ExcelData(dto.getRunningWaterNo().toString()));
rowData.add(new ExcelData(dto.getCreateBy()));
rowData.add(new ExcelData(dto.getCreateTime().toString()));
dataList.add(rowData);
}
ExcelSheet excelSheet = new ExcelSheet("货主资金账户管理", "货主资金账户管理", fieldList, dataList);
//创建excel
return ExcelUtil.create(excelSheet);
}
} }
...@@ -15,7 +15,7 @@ public class OwnerRunningWaterRecordSqlProvider { ...@@ -15,7 +15,7 @@ public class OwnerRunningWaterRecordSqlProvider {
String sql = new SQL() {{ String sql = new SQL() {{
SELECT("a.id, a.owner_user_no," + SELECT("a.id, a.owner_user_no," +
" a.owner_name, a.mobile, a.account_type, a.running_water_type,a.order_id,a.order_no,a.order_child_id,a.order_child_no,a.alteration_balance," + " a.owner_name, a.mobile, a.account_type, a.running_water_type,a.order_id,a.order_no,a.order_child_id,a.order_child_no,a.alteration_balance," +
" a.account_balance,a.usable_balance, a.frozen_balance,a.create_by,a.create_time"); " a.account_balance,a.usable_balance, a.frozen_balance,a.take_out_balance,a.create_by,a.create_time");
FROM("owner_running_water_record a"); FROM("owner_running_water_record a");
WHERE("a.account_type =" + OwnerAccountEnum.AccountTypeStatus.MARGIN_ACCOUNT.getCode()); WHERE("a.account_type =" + OwnerAccountEnum.AccountTypeStatus.MARGIN_ACCOUNT.getCode());
WHERE("a.owner_user_no = #{param.ownerUserNo}"); WHERE("a.owner_user_no = #{param.ownerUserNo}");
......
package com.clx.performance.utils.excel;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 数据导出类型 0数据 1小计 2合计 3总计
*/
@Getter
@AllArgsConstructor
public enum DataExcelTypeEnum {
DATA_TYPE(0, "数据"),
SUBTOTAL(1, "小计"),
EXCELLENT(2, "合计"),
ALL_TOTAL(3, "总计"),
;
private int value;
private String desc;
public static String getDesc(int value) {
for (DataExcelTypeEnum c : DataExcelTypeEnum.values()) {
if (c.getValue() == value) {
return c.desc;
}
}
return null;
}
}
package com.clx.performance.utils.excel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
@Data
@NoArgsConstructor
public class ExcelData {
private String value;
private double doubleValue;
private Integer styleType;
private Integer dataType; //数据类型:1字符串 2数字
@Getter
@AllArgsConstructor
public enum DataType{
STRING(1, "字符串"),
NUMERIC(2, "数字"),
;
private Integer value;
private String msg;
}
public ExcelData(String value) {
this(value,null);
}
public ExcelData(String value, String defaultValue) {
this.value = value;
this.dataType = DataType.STRING.value;
}
public ExcelData(Double value) {
this(value,null);
}
public ExcelData(Double value, String defaultValue) {
if (null != value) {
this.doubleValue = value;
this.dataType = DataType.NUMERIC.value;
}
else {
this.value = defaultValue;
this.dataType = DataType.STRING.value;
}
}
public ExcelData(Integer value) {
this(value,null);
}
public ExcelData(Integer value, String defaultValue) {
if (null != value) {
this.doubleValue = value;
this.dataType = DataType.NUMERIC.value;
}
else {
this.value = defaultValue;
this.dataType = DataType.STRING.value;
}
}
public ExcelData(BigDecimal value) {
this(value,null);
}
public ExcelData(BigDecimal value, String defaultValue) {
if (null != value) {
this.doubleValue = value.doubleValue();
this.dataType = DataType.NUMERIC.value;
}
else {
this.value = defaultValue;
this.dataType = DataType.STRING.value;
}
}
public double getDoubleValue() {
return doubleValue;
}
public String getStringValue() {
return value;
}
}
package com.clx.performance.utils.excel;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author: aiqingguo
* @Description:
* @Date: 2022/8/18 14:25
* @Version: 1.0
*/
@Data
@NoArgsConstructor
public class ExcelField {
private Integer column;
private String fieldName;
private String field;
private Integer width;
private Integer styleType;
private Integer contentAlignment;
public ExcelField(String fieldName, String field, Integer width) {
this.fieldName = fieldName;
this.field = field;
this.width = width;
}
public ExcelField(Integer column, String fieldName, String field, Integer width) {
this.column = column;
this.fieldName = fieldName;
this.field = field;
this.width = width;
}
}
package com.clx.performance.utils.excel;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @Author: aiqingguo
* @Description:
* @Date: 2022/8/19 9:53
* @Version: 1.0
*/
@Data
@NoArgsConstructor
public class ExcelSheet {
private String name;
private String title;
private String time;
private Integer timeStyleType;
private List<ExcelField> fieldList;
private List<List<ExcelData>> dataList;
public ExcelSheet(String name, String title) {
this.name = name;
this.title = title;
}
public ExcelSheet(String name, String title, List<ExcelField> fieldList) {
this.name = name;
this.title = title;
this.fieldList = fieldList;
}
public ExcelSheet(String name, String title, List<ExcelField> fieldList, List<List<ExcelData>> dataList) {
this.name = name;
this.title = title;
this.fieldList = fieldList;
this.dataList = dataList;
}
}
package com.clx.performance.utils.excel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.streaming.SXSSFCell;
import org.apache.poi.xssf.streaming.SXSSFRow;
import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import java.util.List;
/**
* @Author: aiqingguo
* @Description:
* @Date: 2022/8/18 14:33
* @Version: 1.0
*/
public class ExcelUtil {
@Getter
@AllArgsConstructor
public enum CellStyleType {
CONTENT_CENTER(1), //内容居中
CONTENT_LEFT(2), //内容居左
CONTENT_RIGHT(3), //内容居右
TIME_LEFT(11), //时间左边
TIME_RIGHT(12), //时间右边
;
private final Integer code;
}
/**
* 创建excel
*/
public static SXSSFWorkbook create(ExcelSheet excelSheet) {
List<ExcelField> fieldList = excelSheet.getFieldList();
List<List<ExcelData>> dataList = excelSheet.getDataList();
SXSSFWorkbook workbook = new SXSSFWorkbook();
//创建sheet
SXSSFSheet sheet = workbook.createSheet(excelSheet.getName());
int fieldSize = fieldList.size();
for (int i = 0; i < fieldSize; i++) {
sheet.setColumnWidth(i, fieldList.get(i).getWidth());
}
//添加标题
int row = 0;
CellRangeAddress cellRangeAddress = new CellRangeAddress(row, row, 0, fieldSize - 1);
SXSSFRow rowTitle = sheet.createRow(row++);
sheet.addMergedRegion(cellRangeAddress);
rowTitle.setHeightInPoints(30);
SXSSFCell titleCell = rowTitle.createCell(0);
titleCell.setCellValue(excelSheet.getTitle());
titleCell.setCellStyle(getTitleStyle(workbook));
//时间
if (StringUtils.isNotBlank(excelSheet.getTime())) {
CellRangeAddress timeCellRangeAddress = new CellRangeAddress(row, row, 0, fieldSize - 1);
SXSSFRow rowTime = sheet.createRow(row++);
sheet.addMergedRegion(timeCellRangeAddress);
SXSSFCell timeCell = rowTime.createCell(0);
timeCell.setCellValue(excelSheet.getTime());
Integer styleType = excelSheet.getTimeStyleType();
if (null != styleType) {
timeCell.setCellStyle(getCellStyle(workbook, styleType));
}
}
//添加表头
CellStyle headCellStyle = getHeadStyle(workbook);
SXSSFRow rowHead = sheet.createRow(row++);
for (int i = 0; i < fieldSize; i++) {
SXSSFCell headCell = rowHead.createCell(i);
headCell.setCellValue(fieldList.get(i).getFieldName());
Integer styleType = fieldList.get(i).getStyleType();
if (null != styleType) {
headCell.setCellStyle(getCellStyle(workbook, styleType));
} else {
headCell.setCellStyle(headCellStyle);
}
}
//内容
SXSSFRow rowData;
int dataSize = dataList.size();
for (int i = 0; i < dataSize; i++) {
rowData = sheet.createRow(row++);
for (int j = 0; j < fieldSize; j++) {
SXSSFCell dataCell = rowData.createCell(j);
ExcelData excelData = dataList.get(i).get(j);
setCellValue(dataCell, excelData);
Integer styleType = dataList.get(i).get(j).getStyleType();
if (null != styleType) {
dataCell.setCellStyle(getCellStyle(workbook, styleType));
}
}
}
return workbook;
}
/**
* 设置值
*/
private static void setCellValue(SXSSFCell dataCell, ExcelData excelData) {
if (ExcelData.DataType.STRING.getValue().equals(excelData.getDataType())) {
String stringValue = excelData.getStringValue();
dataCell.setCellValue(stringValue);
} else if (ExcelData.DataType.NUMERIC.getValue().equals(excelData.getDataType())) {
if (null == excelData.getStyleType()) {
excelData.setStyleType(CellStyleType.CONTENT_RIGHT.getCode());
}
dataCell.setCellValue(excelData.getDoubleValue());
}
}
/**
* 设置标题字体
*/
private static Font getTitleFont(SXSSFWorkbook workbook) {
Font ztFont = workbook.createFont();
ztFont.setColor(Font.COLOR_NORMAL);
ztFont.setFontHeightInPoints((short) 22);
return ztFont;
}
/**
* 设置标题样式
*/
private static CellStyle getTitleStyle(SXSSFWorkbook workbook) {
Font font = getTitleFont(workbook);
CellStyle style = workbook.createCellStyle();
style.setFont(font);
style.setAlignment(HorizontalAlignment.CENTER);
style.setVerticalAlignment(VerticalAlignment.CENTER);
return style;
}
/**
* 设置格式
*/
private static Font getHeadFont(SXSSFWorkbook workbook) {
Font ztFont = workbook.createFont();
ztFont.setBold(true);
return ztFont;
}
/**
* 设置表头样式
*/
private static CellStyle getHeadStyle(SXSSFWorkbook workbook) {
Font headFont = getHeadFont(workbook);
CellStyle style = workbook.createCellStyle();
style.setFont(headFont);
style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setAlignment(HorizontalAlignment.CENTER);
return style;
}
//获取单元格样式
private static CellStyle getCellStyle(SXSSFWorkbook workbook, Integer cellStyleType) {
if (CellStyleType.CONTENT_CENTER.getCode().equals(cellStyleType)) {
return contentCenterStyle(workbook);
}
if (CellStyleType.CONTENT_LEFT.getCode().equals(cellStyleType)) {
return contentLeftStyle(workbook);
}
if (CellStyleType.CONTENT_RIGHT.getCode().equals(cellStyleType)) {
return contentRightStyle(workbook);
}
if (CellStyleType.TIME_LEFT.getCode().equals(cellStyleType)) {
return timeLeftStyle(workbook);
}
if (CellStyleType.TIME_RIGHT.getCode().equals(cellStyleType)) {
return timeRightStyle(workbook);
}
return workbook.createCellStyle();
}
/**
* 内容居中
*/
private static CellStyle contentCenterStyle(SXSSFWorkbook workbook) {
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setAlignment(HorizontalAlignment.CENTER);
return cellStyle;
}
/**
* 内容居右
*/
private static CellStyle contentLeftStyle(SXSSFWorkbook workbook) {
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setAlignment(HorizontalAlignment.LEFT);
return cellStyle;
}
/**
* 内容居右
*/
private static CellStyle contentRightStyle(SXSSFWorkbook workbook) {
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setAlignment(HorizontalAlignment.RIGHT);
return cellStyle;
}
/**
* 时间样式
*/
private static CellStyle timeLeftStyle(SXSSFWorkbook workbook) {
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setAlignment(HorizontalAlignment.LEFT);
Font font = workbook.createFont();
font.setBold(true);
font.setFontName("宋体");
cellStyle.setFont(font);
return cellStyle;
}
private static CellStyle timeRightStyle(SXSSFWorkbook workbook) {
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setAlignment(HorizontalAlignment.RIGHT);
Font font = workbook.createFont();
font.setBold(true);
font.setFontName("宋体");
cellStyle.setFont(font);
return cellStyle;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论