前后端联调

This commit is contained in:
18792927508
2024-01-15 17:48:02 +08:00
parent 8800948317
commit 7bcec78774
31 changed files with 1622 additions and 41 deletions
@@ -106,13 +106,13 @@ public class CommonController
* 保存到案件附件表
* @param
* @param annexType
* @param fileName
* @param path
* @param originalFilename
*/
private Long saveCaseAttach(Integer annexType, String fileName, String originalFilename) {
private Long saveCaseAttach(Integer annexType, String path, String originalFilename) {
MsCaseAttach caseAttach = MsCaseAttach.builder()
.annexName(originalFilename)
.annexPath(fileName)
.annexPath(path)
.annexType(annexType)
.useId(SecurityUtils.getUserId())
.useAccount(SecurityUtils.getUsername())
@@ -1,8 +1,11 @@
package com.ruoyi.web.controller.wisdomarbitrate.mscase;
import cn.hutool.core.util.StrUtil;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseApplication;
import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseApplicationReq;
import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseApplicationVO;
import com.ruoyi.wisdomarbitrate.service.mscase.MsCaseApplicationService;
@@ -80,8 +83,72 @@ public class MsCaseApplicationController extends BaseController {
return caseApplicationService.uploadCaseZipFile(file,templateId);
}
/**
* 生成调解申请书
* @param
* @return
* @throws IOException
*/
@PostMapping("/generateApplication")
public AjaxResult generateApplication(@RequestBody MsCaseApplicationReq req) {
if (req.getTemplateId() == null||req.getCaseFlowId() == null || (req.getId() == null && StrUtil.isEmpty(req.getBatchNumber()))) {
return error("参数校验失败");
}
return caseApplicationService.generateApplication(req);
}
/**
* 证据上传
* @param file
* @param annexType
* @param id
* @return
*/
@PostMapping("/batchUpload")
public AjaxResult batchUpload(@RequestParam("file") MultipartFile[] file, @RequestParam("annexType")Integer annexType, @RequestParam("id")Long id) {
if(file==null){
return error("请选择要上传的文件");
}
return caseApplicationService.batchUpload(file, annexType, id);
}
/**
* 案件受理
* @param req
* @return
*/
@PostMapping("/accept")
public AjaxResult accept(@RequestBody MsCaseApplication req ) {
if (StrUtil.isEmpty(req.getMediationMethod())
|| req.getPaperFlag() == null
|| req.getCaseFlowId() == null
|| req.getArbitrateConfirm() == null
|| (req.getId() == null && StrUtil.isEmpty(req.getBatchNumber()))) {
return error("参数校验失败");
}
return caseApplicationService.accept(req);
}
/**
* 案件提交
* @param req
* @return
*/
@PostMapping("/submit")
public AjaxResult submit(@RequestBody MsCaseApplication req ) {
if (req.getCaseFlowId() == null
|| (req.getId() == null && StrUtil.isEmpty(req.getBatchNumber()))) {
return error("参数校验失败");
}
return caseApplicationService.submit(req);
}
/**
* 查询调解员
* @param
* @return
*/
@GetMapping("/listMediator")
public AjaxResult listMediator( ) {
return caseApplicationService.listMediator();
}
}
@@ -0,0 +1,95 @@
package com.ruoyi.web.controller.wisdomarbitrate.mscase;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.wisdomarbitrate.domain.dto.mscase.CaseConfirmPayDTO;
import com.ruoyi.wisdomarbitrate.domain.dto.mscase.CasePayDTO;
import com.ruoyi.wisdomarbitrate.service.mscase.MsCasePaymentService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* 案件缴费控制层
* @Author wangqiong
* @Date 2024/01/8
* @Version V1.0
*/
@RestController
@RequestMapping("/pay")
public class MsCaseApplicationPayController extends BaseController {
@Resource
private MsCasePaymentService casePaymentService;
/**
* 根据案件id或者批次号查询申请人及应缴费用
* @param dto 缴费传入参数
* @return 统一响应结果
*/
@PostMapping("/selectTotalFee")
public AjaxResult selectTotalFee(@RequestBody CasePayDTO dto) {
if ((dto.getCaseId() == null && StrUtil.isEmpty(dto.getBatchNumber()))
) {
return error("参数校验失败");
}
return casePaymentService.selectTotalFee(dto);
}
/**
* 根据案件id查询缴费单
* @param id
* @return 统一响应结果
*/
@GetMapping("/selectPaymentDetail")
public AjaxResult selectPaymentDetail(@RequestParam(value = "id",required = true) Long id) {
return AjaxResult.success(casePaymentService.selectPaymentDetail(id));
}
/**
* 案件缴费,线上缴费,支持批量(batchNumber不为空,则为批量缴费)
* @param dto 缴费传入参数
* @return 统一响应结果
*/
@PostMapping("/casePay")
public AjaxResult casePay(@Validated @RequestBody CasePayDTO dto) {
if ((dto.getCaseId() == null && StrUtil.isEmpty(dto.getBatchNumber()))
|| StrUtil.isEmpty(dto.getPlatform()) ||StrUtil.isEmpty(dto.getTradeType())
) {
return error("参数校验失败");
}
return casePaymentService.casePay(dto);
}
/**
* 确认缴费,支持批量(batchNumber不为空,则为批量)
* @param dto 缴费传入参数
* @return 统一响应结果
*/
@PostMapping("/confirmPayment")
public AjaxResult confirmPayment(@RequestBody CaseConfirmPayDTO dto) {
if ((dto.getCaseId() == null && StrUtil.isEmpty(dto.getBatchNumber()))
|| StrUtil.isEmpty(dto.getPayType()) || CollectionUtil.isEmpty(dto.getPayOrderList())
|| dto.getCaseFlowId() == null) {
return error("参数校验失败");
}
return casePaymentService.confirmPayment(dto);
}
/**
* 确认已缴费,支持批量(batchNumber不为空,则为批量)
* @param dto 缴费传入参数
* @return 统一响应结果
*/
@PostMapping("/confirmPaid")
public AjaxResult confirmPaid(@RequestBody CaseConfirmPayDTO dto) {
if ((dto.getCaseId() == null && StrUtil.isEmpty(dto.getBatchNumber()))
|| dto.getCaseFlowId() == null) {
return error("参数校验失败");
}
return casePaymentService.confirmPaid(dto);
}
}
@@ -0,0 +1,66 @@
package com.ruoyi.common.enums;
import com.ruoyi.common.interfaces.EnumsInterface;
/**
* @Classname AnnexTypeEnum
* @Description 附件类型枚举
* @Version 1.0.0
* @Date 2024/1/12 17:50
* @Created wangqiong
*/
public enum AnnexTypeEnum implements EnumsInterface {
APPLICATION(1, "仲裁申请书"),
APPLICATION_EVIDENCE(2, "申请人证据"),
MEDIATION_APPLICATION(3, "调解申请书"),
PAYMENT_RECEIPT(4, "缴费单"),
;
private final Integer code;
private final String text;
AnnexTypeEnum(Integer code, String text)
{
this.code = code;
this.text = text;
}
public Integer getCode()
{
return code;
}
public String getText()
{
return text;
}
/**
* 根据code获取text
* @param codeNo
* @return
*/
public static String getTextByCode(Integer codeNo){
for (AnnexTypeEnum value : AnnexTypeEnum.values()) {
if (value.getCode().equals(codeNo)){
return value.getText();
}
}
return codeNo.toString();
}
/**
* 根据text获取code
* @param textStr
* @return
*/
public static String getCodeByText(String textStr){
for (AnnexTypeEnum value : AnnexTypeEnum.values()) {
if (value.getText().equals(textStr)){
return value.getText();
}
}
return textStr;
}
}
@@ -0,0 +1,65 @@
package com.ruoyi.common.enums;
import com.ruoyi.common.interfaces.EnumsInterface;
/**
* @Classname PaymentStatusEnum
* @Description 支付状态枚举
* @Version 1.0.0
* @Date 2024/1/12 18:07
* @Created wangqiong
*/
public enum PaymentStatusEnum implements EnumsInterface {
UNPAID(0, "未支付"),
PAID(1, "已支付"),
;
private final Integer code;
private final String text;
PaymentStatusEnum(Integer code, String text)
{
this.code = code;
this.text = text;
}
public Integer getCode()
{
return code;
}
public String getText()
{
return text;
}
/**
* 根据code获取text
* @param codeNo
* @return
*/
public static String getTextByCode(Integer codeNo){
for (PaymentStatusEnum value : PaymentStatusEnum.values()) {
if (value.getCode().equals(codeNo)){
return value.getText();
}
}
return codeNo.toString();
}
/**
* 根据text获取code
* @param textStr
* @return
*/
public static String getCodeByText(String textStr){
for (PaymentStatusEnum value : PaymentStatusEnum.values()) {
if (value.getText().equals(textStr)){
return value.getText();
}
}
return textStr;
}
}
@@ -0,0 +1,61 @@
package com.ruoyi.common.utils;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @Classname BookMarkUtil
* @Description 获取模板中的占位符{{xxx}}
* @Version 1.0.0
* @Date 2024/1/11 18:07
* @Created wangqiong
*/
public class BookMarkUtil {
/**
* 根据裁决书模板获取所有的占位符,占位符必须是{{name}}格式
*
* @param path
* @return
*/
public static List<String> getBookmarkByDocx(String path) {
XWPFDocument xwpfDocument = null;
try {
FileInputStream fileInputStream = new FileInputStream(path);
xwpfDocument = new XWPFDocument(fileInputStream);
} catch (IOException e) {
e.printStackTrace();
}
if (xwpfDocument == null) {
return new ArrayList<>();
}
List<XWPFParagraph> paragraphs = xwpfDocument.getParagraphs();
if (CollectionUtil.isEmpty(xwpfDocument.getParagraphs())) {
return new ArrayList<>();
}
String regex = "\\{\\{.*?\\}\\}"; // 定义占位符的正则表达式
Pattern pattern = Pattern.compile(regex);
List<String> bookmarkList = new ArrayList<>();
for (XWPFParagraph paragraph : paragraphs) {
String text = paragraph.getText();
if (StrUtil.isNotEmpty(text)) {
Matcher matcher = pattern.matcher(text);
while (matcher.find()) {
String placeholder = matcher.group();
String keyword = placeholder.substring(2, placeholder.length() - 2);
bookmarkList.add(keyword);
}
}
}
return bookmarkList;
}
}
@@ -2,15 +2,12 @@ package com.ruoyi.common.utils;
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.cvm.v20170312.CvmClient;
import com.tencentcloudapi.cvm.v20170312.models.DescribeRegionsRequest;
import com.tencentcloudapi.cvm.v20170312.models.DescribeRegionsResponse;
import com.tencentcloudapi.sms.v20210111.SmsClient;
import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
import com.tencentcloudapi.sms.v20210111.models.SendStatus;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import lombok.var;
@@ -53,10 +50,39 @@ public class SmsUtils {
}
return Boolean.FALSE;
}
public static Boolean sendSms(Long caseId,String templateId,String phone,String[] templateParamSet) {
SendSmsRequest request = new SendSmsRequest(phone,templateId,templateParamSet,caseId);
Credential cred = new Credential(SECRET_ID, SECRET_KEY );
SmsClient client = new SmsClient(cred, "ap-guangzhou");
final var req = new com.tencentcloudapi.sms.v20210111.models.SendSmsRequest();
req.setPhoneNumberSet(new String[]{"+86" + request.getPhone()});
req.setSmsSdkAppId(SDK_APP_ID );
req.setSignName(SIGN_NAME);
req.setTemplateId(request.getTemplateId());
req.setTemplateParamSet(request.getTemplateParamSet());
SendSmsResponse res = null;
try {
res = client.SendSms(req);
} catch (TencentCloudSDKException e) {
log.error("发送短信出错:", e);
return Boolean.FALSE;
}
SendStatus sendStatus = res.getSendStatusSet()[0];
log.info("发送短信结果:Code={}, Message={}", sendStatus.getCode(), sendStatus.getMessage());
if (Objects.nonNull(res.getSendStatusSet()) && res.getSendStatusSet().length > 0 && "Ok".equals(res.getSendStatusSet()[0].getCode())){
return Boolean.TRUE;
}
return Boolean.FALSE;
}
/**
* 参数对象
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class SendSmsRequest {
/**
* 电话
@@ -1,7 +1,16 @@
package com.ruoyi.system.mapper.flow;
import com.ruoyi.system.domain.entity.flow.MsCaseFlow;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;
public interface MsCaseFlowMapper extends Mapper<MsCaseFlow> {
/**
* 根据流程查找下一个流程
*
* @param caseFlowId 流程id
* @return
*/
@Select("select f1.id,f1.node_id nodeId,f1.node_name nodeName,f1.case_status_name caseStatusName,f1.back_flow_id backFlowId,f1.sort from ms_case_flow f1 join ms_case_flow f2 on f2.id=#{caseFlowId} and f1.sort=f2.sort+1 ")
MsCaseFlow nextFlow(Integer caseFlowId);
}
@@ -0,0 +1,34 @@
package com.ruoyi.wisdomarbitrate.domain.dto.mscase;
import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAttach;
import lombok.Data;
import java.util.List;
/**
* 案件确认缴费传入对象
*/
@Data
public class CaseConfirmPayDTO {
/**
* 案件id
*/
private Long caseId;
/**
* 批次号
*/
private String batchNumber;
/**
* 支付方式 0线上支付,1线下支付
*/
private String payType;
/**
* 流程节点id
*/
private Integer caseFlowId;
/**
* 缴费凭证
*/
private List<MsCaseAttach> payOrderList;
}
@@ -0,0 +1,47 @@
package com.ruoyi.wisdomarbitrate.domain.dto.mscase;
import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAttach;
import lombok.Data;
import java.util.List;
/**
* 案件缴费传入对象
*/
@Data
public class CasePayDTO {
/**
* 案件id
*/
private Long caseId;
/**
* 案件流程节点id
*/
private Integer caseFlowId;
/**
* 订单金额 单位:分
*/
private int totalFee;
/**
* 交易类型 native(扫码) / jsapi(小程序) / app / h5
*/
private String tradeType;
/**
* 支付方式 wxpay(微信) alipay(支付宝)
*/
private String platform;
/**
* 支付方式 0线上支付,1线下支付
*/
private String payType;
/**
* 缴费凭证
*/
private List<MsCaseAttach> payOrderList;
/**
* 批号
*/
private String batchNumber;
}
@@ -0,0 +1,44 @@
package com.ruoyi.wisdomarbitrate.domain.dto.mscase;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
@Data
public class CasePaymentRecord {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
private Integer id;
/**
* 案件id
*/
private Long caseId;
/**
* 订单号
*/
private String orderNumber;
/**
* 支付状态(0未支付,1已支付)
*/
private Integer paymentStatus;
/**
* 支付时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date paymentTime;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/** 更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
/**
* 支付方式 0线上支付,1线下支付
*/
private Integer payType;
}
@@ -42,4 +42,12 @@ public class SmsSendRecord extends BaseEntity {
* 发送状态
*/
private Integer sendStatus;
public SmsSendRecord(Long caseId, String caseNum, String phone, Date sendTime, String sendContent) {
this.caseId = caseId;
this.caseNum = caseNum;
this.phone = phone;
this.sendTime = sendTime;
this.sendContent = sendContent;
}
}
@@ -138,6 +138,16 @@ public class MsCaseApplication {
*/
@Column(name = "respon_isWrit_hear")
private Integer responIswritHear;
/**
* 是否纸质送达,0-否,1-是
*/
@Column(name = "paper_flag")
private Integer paperFlag;
/**
* 是否需要仲裁确认,0-否,1-是
*/
@Column(name = "arbitrate_confirm")
private Integer arbitrateConfirm;
/**
* 创建者
@@ -210,4 +220,5 @@ public class MsCaseApplication {
*/
@Column(name = "mediation_agreement")
private String mediationAgreement;
}
@@ -0,0 +1,63 @@
package com.ruoyi.wisdomarbitrate.domain.entity.mscase;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
@Getter
@Setter
@ToString
@Table(name = "ms_case_payment_record")
public class MsCasePaymentRecord {
@Id
@GeneratedValue(generator = "JDBC")
private Long id;
/**
* 案件id
*/
@Column(name = "case_id")
private Long caseId;
/**
* 订单号
*/
@Column(name = "order_number")
private String orderNumber;
/**
* 支付时间
*/
@Column(name = "payment_time")
private Date paymentTime;
/**
* 创建时间
*/
@Column(name = "create_time")
private Date createTime;
/**
* 更新时间
*/
@Column(name = "update_time")
private Date updateTime;
/**
* 支付状态(0未支付,1已支付)
*/
@Column(name = "payment_status")
private Integer paymentStatus;
/**
* 支付方式(0线上支付,1线下支付)
*/
@Column(name = "pay_type")
private Integer payType;
}
@@ -0,0 +1,34 @@
package com.ruoyi.wisdomarbitrate.domain.vo.mscase;
import lombok.Data;
/**
* @Classname MediatorVO
* @Description 调解员VO
* @Version 1.0.0
* @Date 2024/1/15 15:48
* @Created wangqiong
*/
@Data
public class MediatorVO {
/**
* 调解员id
*/
private Long mediatorId;
/**
* 调解员名称
*/
private String mediatorName;
/**
* 专业
*/
private String specialty;
/**
* 待办数量
*/
private Integer todoAmount;
/**
* 已办数量
*/
private Integer completeAmount;
}
@@ -8,6 +8,14 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor
@Data
public class MsCaseApplicationReq {
/**
* 案件ID
*/
private Long id;
/**
* 模板id
*/
private String templateId;
/**
* 批次
*/
@@ -24,7 +32,7 @@ public class MsCaseApplicationReq {
/**
* 案件状态ID
*/
private Long caseFlowId;
private Integer caseFlowId;
/**
* 开始时间
*/
@@ -0,0 +1,54 @@
package com.ruoyi.wisdomarbitrate.domain.vo.mscase;
import com.ruoyi.common.annotation.EnumsConvert;
import com.ruoyi.common.enums.PaymentStatusEnum;
import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAttach;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.util.List;
/**
* @Classname PaymentDetailVO
* @Description 缴费单详情VO
* @Version 1.0.0
* @Date 2024/1/12 17:59
* @Created wangqiong
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class PaymentDetailVO {
private String caseNum;
/**
* 案件标的(欠款总金额)
*/
private BigDecimal caseSubjectAmount;
/**
* 缴费金额
*/
private BigDecimal feePayable;
/**
* 缴费单
*/
private List<MsCaseAttach> caseAttachList;
/**
* 申请人
*/
private String applicationOrganName;
/**
* 案件状态
*/
private String caseStatusName;
/**
* 案件状态
*/
@EnumsConvert(getEnumsInterface= PaymentStatusEnum.class,targetField = "paymentStatusName")
private String paymentStatus;
/**
* 案件状态
*/
private String paymentStatusName;
}
@@ -1,6 +1,7 @@
package com.ruoyi.wisdomarbitrate.mapper.mscase;
import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseApplication;
import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MediatorVO;
import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseApplicationReq;
import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseApplicationVO;
import org.apache.ibatis.annotations.Param;
@@ -114,4 +115,11 @@ public interface MsCaseApplicationMapper extends Mapper<MsCaseApplication> {
" ) t order by t.createTime desc,t.caseNum desc" +
" </script>")
List<MsCaseApplicationVO> list(@Param("req")MsCaseApplicationReq req, @Param("caseStatusNames") List<String> caseStatusNames);
/**
* 查询调解员列表
* @return
*/
@Select("select a.id id,a.mediator_name mediatorName,a.mediator_phone mediatorPhone,a.mediator_email mediatorEmail,a.mediator_address mediatorAddress,a.mediator_id mediatorId,a.mediator_type mediatorType,a.mediator_status mediatorStatus,a.mediator_remark mediatorRemark,a.create_time createTime from ms_case_mediator a")
List<MediatorVO> listMediator();
}
@@ -18,12 +18,13 @@ public interface MsCaseAttachMapper {
int updateCaseAttach(MsCaseAttach caseAttach);
void batchUpdate(@Param("list") List<MsCaseAttach> caseAttachList);
int updateCaseAttachBycaseid(MsCaseAttach caseAttach);
int deleteByFileIds(@Param("ids") List<Integer> fileIds);
List<MsCaseAttach> getCaseAttachByCaseIdAndType(MsCaseAttach caseAttach);
List<MsCaseAttach> listCaseAttachByCaseIdAndType(@Param("caseAppliId")Long caseAppliId,@Param("annexType") int annexType);
MsCaseAttach queryAnnexById(@Param("annexId") Long annexId);
@@ -35,4 +36,6 @@ public interface MsCaseAttachMapper {
void deleteByCasedIdAndType(@Param("caseAppliId")Long caseAppliId,@Param("annexType") int annexType,@Param("isBatchUpload") int isBatchUpload);
void deleteCaseAttachByCasedIdAndType(@Param("caseAppliId")Long caseAppliId,@Param("annexType") int annexType);
}
@@ -0,0 +1,8 @@
package com.ruoyi.wisdomarbitrate.mapper.mscase;
import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCasePaymentRecord;
import tk.mybatis.mapper.common.Mapper;
public interface MsCasePaymentRecordMapper extends Mapper<MsCasePaymentRecord> {
}
@@ -2,6 +2,7 @@ package com.ruoyi.wisdomarbitrate.mapper.template;
import com.ruoyi.wisdomarbitrate.domain.dto.template.TemplateManage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -12,4 +13,5 @@ public interface TemplateManageMapper {
int insertTemplateManage(TemplateManage templateManage);
int updateTemplateManage(TemplateManage templateManage);
TemplateManage selectById(@Param("id") String id);
}
@@ -418,15 +418,11 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
String filePath = RuoYiConfig.getUploadPath();
// 上传
String fileName = FileUploadUtils.upload(filePath, file);
String prefix = "/profile";
int startIndex = fileName.indexOf(prefix);
startIndex += prefix.length();
String annexPath = "uploadPath" + fileName.substring(startIndex);
templateManage.setTemOrigPath(annexPath);
templateManage.setTemOrigPath(fileName);
String format = getFileExtension(fileName);
templateManage.setTemFormat(format);
String subFileName = fileName.substring(fileName.lastIndexOf("/") + 1);
templateManage.setFileName(subFileName);
templateManage.setFileName(file.getOriginalFilename());
templateManage.setCreateBy(getUsername());
int i = templateManageMapper.insertTemplateManage(templateManage);
if (i > 0) {
@@ -449,13 +445,9 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
String filePath = RuoYiConfig.getUploadPath();
// 上传
String fileName = FileUploadUtils.upload(filePath, file);
String prefix = "/profile";
int startIndex = fileName.indexOf(prefix);
startIndex += prefix.length();
String annexPath = "uploadPath" + fileName.substring(startIndex);
templateManage.setTemOrigPath(annexPath);
String subFileName = fileName.substring(fileName.lastIndexOf("/") + 1);
templateManage.setFileName(subFileName);
templateManage.setTemOrigPath(fileName);
templateManage.setFileName(file.getOriginalFilename());
String format = getFileExtension(fileName);
templateManage.setTemFormat(format);
}
@@ -1,7 +1,9 @@
package com.ruoyi.wisdomarbitrate.service.mscase;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.entity.flow.MsCaseFlow;
import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAffiliate;
import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseApplication;
import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseApplicationReq;
import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseApplicationVO;
import org.springframework.web.multipart.MultipartFile;
@@ -56,4 +58,64 @@ public interface MsCaseApplicationService {
* @return
*/
AjaxResult uploadCaseZipFile(MultipartFile file, Long templateId);
/**
* 生成调解申请书
* @param req
* @return
*/
AjaxResult generateApplication(MsCaseApplicationReq req);
/**
* 根据批次号和流程id查找未锁定的案件
* @param batchNumber
* @param caseFlowId 案件流程id
* @return
*/
List<MsCaseApplication> listByBatchNumber(String batchNumber,Integer caseFlowId);
/**
* 批量更新附件
* @param req
* @return
*/
AjaxResult batchUpdateAttach(MsCaseApplicationVO req);
/**
* 批量上传证据
* @param file
* @param annexType
* @param id
* @return
*/
AjaxResult batchUpload(MultipartFile[] file, Integer annexType, Long id);
/**
* 流向下一个流程节点
* @param caseId 案件id
* @param caseFlowId 案件流程id
* @param lockStatus '是否锁定,0-否,1-是',单独操作案件时需要锁定
* @return
*/
MsCaseFlow nextFlow(Long caseId, Integer caseFlowId,Integer lockStatus);
/**
* 案件受理
* @param req
* @return
*/
AjaxResult accept(MsCaseApplication req);
/**
* 案件提交
* @param req
* @return
*/
AjaxResult submit(MsCaseApplication req);
/**
* 查询调解员
* @return
*/
AjaxResult listMediator();
}
@@ -0,0 +1,36 @@
package com.ruoyi.wisdomarbitrate.service.mscase;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.wisdomarbitrate.domain.dto.mscase.CaseConfirmPayDTO;
import com.ruoyi.wisdomarbitrate.domain.dto.mscase.CasePayDTO;
import com.ruoyi.wisdomarbitrate.domain.vo.mscase.PaymentDetailVO;
public interface MsCasePaymentService {
/**
* 案件线上缴费
*/
AjaxResult casePay(CasePayDTO casePayDTO);
/**
* 缴费
* @param payDTO
* @return
*/
AjaxResult confirmPayment(CaseConfirmPayDTO payDTO);
/**
* 根据案件id或者批次号查询申请人及应缴费用
* @param dto
* @return
*/
AjaxResult selectTotalFee(CasePayDTO dto);
/**
* 根据案件id查询缴费单
* @param id
* @return
*/
PaymentDetailVO selectPaymentDetail(Long id);
AjaxResult confirmPaid(CaseConfirmPayDTO dto);
}
@@ -11,13 +11,12 @@ import org.springframework.stereotype.Component;
@Component
@Slf4j
public class CallBackHandleServiceImpl implements CallBackService {
// todo
// @Autowired
// private CasePaymentServiceImpl casePaymentService;
@Autowired
private MsCasePaymentServiceImpl casePaymentService;
@Override
public void successPay(String orderSn) {
// casePaymentService.callback(orderSn);
casePaymentService.callback(orderSn);
}
@Override
@@ -3,33 +3,43 @@ package com.ruoyi.wisdomarbitrate.service.mscase.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.enums.AnnexTypeEnum;
import com.ruoyi.common.enums.YesOrNoEnum;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.*;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.system.domain.entity.flow.MsCaseFlow;
import com.ruoyi.system.domain.entity.flow.MsCaseFlowRoleRelated;
import com.ruoyi.system.mapper.*;
import com.ruoyi.system.mapper.flow.MsCaseFlowMapper;
import com.ruoyi.system.mapper.flow.MsCaseFlowRoleRelatedMapper;
import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord;
import com.ruoyi.wisdomarbitrate.domain.dto.template.FatchRule;
import com.ruoyi.wisdomarbitrate.domain.dto.template.TemplateManage;
import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAffiliate;
import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseApplication;
import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAttach;
import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MediatorVO;
import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseApplicationReq;
import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseApplicationVO;
import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsColumnValueVO;
import com.ruoyi.wisdomarbitrate.mapper.mscase.*;
import com.ruoyi.wisdomarbitrate.mapper.sendrecord.SmsRecordMapper;
import com.ruoyi.wisdomarbitrate.mapper.template.FatchRuleMapper;
import com.ruoyi.wisdomarbitrate.mapper.template.TemplateManageMapper;
import com.ruoyi.wisdomarbitrate.service.mscase.MsCaseApplicationService;
import com.ruoyi.wisdomarbitrate.utils.CaseLogUtils;
import com.ruoyi.wisdomarbitrate.utils.OCRUtils;
import com.ruoyi.wisdomarbitrate.utils.UnZipFileUtils;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -39,10 +49,17 @@ import tk.mybatis.mapper.entity.Example;
import java.io.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import static com.ruoyi.common.utils.BookMarkUtil.getBookmarkByDocx;
import static com.ruoyi.common.utils.SecurityUtils.getUsername;
/**
@@ -86,6 +103,10 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
FatchRuleMapper fatchRuleMapper;
@Autowired
SysDictDataMapper dictDataMapper;
@Autowired
TemplateManageMapper templateManageMapper;
@Autowired
private SmsRecordMapper smsRecordMapper;
// 案件基本字段
public static final List<String> CASE_BASE_COLUMN = Arrays.asList("caseSubjectAmount", "arbitratClaims", "facts", "requestRule");
public static final SimpleDateFormat yyyymmddFormat = new SimpleDateFormat("yyyy-MM-dd");
@@ -233,11 +254,16 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
}
// 保存案件附件
if (CollectionUtil.isNotEmpty(caseAttachList) && !caseApplication.isImportFlag()) {
if (CollectionUtil.isNotEmpty(caseAttachList)) {
for (MsCaseAttach caseAttach : caseAttachList) {
caseAttach.setCaseAppliId(caseApplication.getId());
}
if(!caseApplication.isImportFlag()) {
// 修改案件附件
msCaseAttachMapper.updateCaseAttach(caseAttach);
msCaseAttachMapper.batchUpdate(caseAttachList);
}else {
// 压缩包导入保存附件
msCaseAttachMapper.batchSave(caseAttachList);
}
}
List<MsColumnValueVO> columnValueList = caseApplication.getColumnValueList();
@@ -373,8 +399,9 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
}
//查询批次号
String batchNumber = getBatchNumber();
// 抓取内容
Map<String, String> fatchMap = new HashMap<>();
// 案件数量
int caseCount = 0;
for (File outFile : files) {
if (!outFile.isDirectory() || outFile.listFiles() == null) {
continue;
@@ -384,6 +411,8 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
// 所有的文件,fileMap<fileName,filePath>
Map<String, String> fileMap = findFile(inFile);
if (fileMap != null && !fileMap.isEmpty()) {
// 抓取内容
Map<String, String> fatchMap = new HashMap<>();
// 根据抓取规则设置字段值
for (Map.Entry<String, List<FatchRule>> entry : fatchRuleMap.entrySet()) {
getFatchContent(fileMap, entry.getKey(), fatchMap, entry.getValue());
@@ -429,15 +458,406 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
caseApplicationVO.setColumnValueList(columnValueList);
caseApplicationVO.setImportFlag(true);
insert(caseApplicationVO);
caseCount++;
}
}
}
}
if(caseCount>0) {
return AjaxResult.success();
}else {
return AjaxResult.error("请检查压缩包!");
}
}
/**
* 生成调解申请书
* @param req
* @return
*/
@Override
public AjaxResult generateApplication(MsCaseApplicationReq req) {
// 根据模板id查询申请书
TemplateManage templateManage=templateManageMapper.selectById(req.getTemplateId());
if(templateManage==null||StrUtil.isEmpty(templateManage.getTemOrigPath())){
return AjaxResult.error("未找到调解申请书模板");
}
String templatePath = templateManage.getTemOrigPath();
try {
File file = new File(templatePath);
} catch (Exception e) {
return AjaxResult.error("未找到调解申请书模板");
}
// 获取模板中的占位符key
List<String> bookmarkList = getBookmarkByDocx(templatePath);
if (CollectionUtil.isEmpty(bookmarkList)) {
return AjaxResult.success("请检查模板是否配置正确,未获取到占位符");
}
// 在系统表中查询案件内置字段
SysDictData sysDictData = new SysDictData();
sysDictData.setDictType("case_built_type");
List<SysDictData> dictDataList = dictDataMapper.selectDictDataList(sysDictData);
if(CollectionUtil.isEmpty(dictDataList)){
return AjaxResult.error("未找到系统内置字段");
}
// 如果批号不为空,则为批量操作,根据批号查询未锁定的案件
if(StrUtil.isNotEmpty(req.getBatchNumber())){
List<MsCaseApplication> caseApplicationList=listByBatchNumber(req.getBatchNumber(),req.getCaseFlowId());
if(CollectionUtil.isEmpty(caseApplicationList)){
return AjaxResult.error("该批次号下未找到案件");
}
// 案件ids
List<Long> caseIds = caseApplicationList.stream().map(MsCaseApplication::getId).collect(Collectors.toList());
// 根据ids查询案件关联人员
Example afflicateExample = new Example(MsCaseFlow.class);
afflicateExample.createCriteria().andIn("case_appli_id", caseIds);
List<MsCaseAffiliate> affiliateList = msCaseAffiliateMapper.selectByExample(caseIds);
if(CollectionUtil.isEmpty(affiliateList)){
return AjaxResult.error("该批次号下未找到案件关联人员");
}
Map<Long, MsCaseAffiliate> affiliateMap = affiliateList.stream().collect(Collectors.toMap(MsCaseAffiliate::getCaseAppliId, Function.identity()));
// 循环生成调解申请书
for (MsCaseApplication application : caseApplicationList) {
// 案件相关人员
MsCaseAffiliate affiliate = affiliateMap.get(application.getId());
if(affiliate==null){
continue;
}
createMediateApplication(application, affiliate, templatePath, bookmarkList,dictDataList);
}
}else {
// 单独生成调解申请书
// 根据案件id查询案件信息
MsCaseApplication application = msCaseApplicationMapper.selectByPrimaryKey(req.getId());
// 查询案件关联人员
MsCaseAffiliate caseAffiliate = msCaseAffiliateMapper.selectByPrimaryKey(req.getId());
if (application == null || caseAffiliate == null) {
return AjaxResult.error("该案件不存在");
}
createMediateApplication(application, caseAffiliate, templatePath, bookmarkList,dictDataList);
}
return AjaxResult.success("调解申请书生成成功");
}
public List<MsCaseApplication> listByBatchNumber(String batchNumber,Integer caseFlowId) {
Example example = new Example(MsCaseFlow.class);
example.createCriteria().andEqualTo("batch_number", batchNumber);
example.createCriteria().andEqualTo("lock_status", 0);
if(caseFlowId!=null){
example.createCriteria().andEqualTo("case_flow_id",caseFlowId);
}
return msCaseApplicationMapper.selectByExample(example);
}
@Override
public AjaxResult batchUpdateAttach(MsCaseApplicationVO req) {
for (MsCaseAttach attach : req.getCaseAttachList()) {
attach.setCaseAppliId(req.getId());
msCaseAttachMapper.updateCaseAttach(attach);
}
return null;
}
@Override
public AjaxResult batchUpload(MultipartFile[] files, Integer annexType, Long id) {
List<MsCaseAttach> successList = new ArrayList<>();
try {
String filePath = RuoYiConfig.getUploadPath();
for (MultipartFile file : files) {
// 上传
String path = FileUploadUtils.upload(filePath, file);
MsCaseAttach caseAttach = MsCaseAttach.builder().caseAppliId(id)
.annexName(file.getOriginalFilename())
.annexPath(path)
.annexType(annexType)
.useId(SecurityUtils.getUserId())
.useAccount(SecurityUtils.getUsername())
.isBatchUpload(1L)
.build();
int count = msCaseAttachMapper.save(caseAttach);
if (count > 0 ) {
MsCaseAttach caseAttachselect = new MsCaseAttach();
caseAttachselect.setAnnexId(caseAttach.getAnnexId());
caseAttachselect.setAnnexName(caseAttach.getAnnexName());
caseAttachselect.setAnnexType(caseAttach.getAnnexType());
successList.add(caseAttachselect);
}
}
} catch (IOException e) {
e.printStackTrace();
return AjaxResult.error("上传失败");
}
return AjaxResult.success("上传成功", successList);
}
/**
* 案件受理
* @param req
* @return
*/
@Override
public AjaxResult accept(MsCaseApplication req) {
if (StrUtil.isNotEmpty(req.getBatchNumber())) {
// 根据批号查询未锁定的案件
List<MsCaseApplication> applicationList = listByBatchNumber(req.getBatchNumber(), req.getCaseFlowId());
if (CollectionUtil.isEmpty(applicationList)) {
return AjaxResult.error("该批次号下未找到案件");
}
// 查询案件关联人员
Example example = new Example(MsCaseAffiliate.class);
example.createCriteria().andIn("case_appli_id", applicationList.stream().map(MsCaseApplication::getId).collect(Collectors.toList()));
List<MsCaseAffiliate> affiliateList = msCaseAffiliateMapper.selectByExample(example);
if (CollectionUtil.isEmpty(affiliateList)) {
return AjaxResult.error("该批次号下未找到案件");
}
Map<Long, MsCaseAffiliate> affiliateMap = affiliateList.stream().collect(Collectors.toMap(MsCaseAffiliate::getCaseAppliId, Function.identity()));
for (MsCaseApplication application : applicationList) {
accept(application,req,affiliateMap);
}
} else {
// 根据案件id查询案件相关人
MsCaseAffiliate caseAffiliate = msCaseAffiliateMapper.selectByPrimaryKey(req.getId());
if (caseAffiliate == null) {
return AjaxResult.error("该案件不存在");
}
// 锁定该案件
req.setLockStatus(YesOrNoEnum.YES.getCode());
Map<Long, MsCaseAffiliate> affiliateMap=new HashMap<>();
affiliateMap.put(req.getId(),caseAffiliate);
accept(req,req,affiliateMap);
}
return AjaxResult.success("受理成功");
}
/**
* 案件提交
* @param req
* @return
*/
@Override
public AjaxResult submit(MsCaseApplication req) {
if(StrUtil.isNotEmpty(req.getBatchNumber())){
// 批量提交
List<MsCaseApplication> list = listByBatchNumber(req.getBatchNumber(), req.getCaseFlowId());
if(CollectionUtil.isEmpty(list)){
return AjaxResult.error("该批次号下未找到案件");
}
for (MsCaseApplication application : list) {
MsCaseFlow caseFlow = nextFlow(application.getId(), req.getCaseFlowId(), YesOrNoEnum.NO.getCode());
CaseLogUtils.insertCaseLog(application.getId(), caseFlow.getNodeId(), caseFlow.getCaseStatusName(), "提交成功");
}
}else {
MsCaseFlow caseFlow = nextFlow(req.getId(), req.getCaseFlowId(), YesOrNoEnum.NO.getCode());
CaseLogUtils.insertCaseLog(req.getId(), caseFlow.getNodeId(), caseFlow.getCaseStatusName(), "提交成功");
}
return AjaxResult.success("提交成功");
}
@Override
public AjaxResult listMediator() {
List<MediatorVO> mediatorVOS = new ArrayList<MediatorVO>();
mediatorVOS= msCaseApplicationMapper.listMediator();
return null;
}
/**
* 案件受理
* @param application
* @param req
* @param affiliateMap
*/
private void accept(MsCaseApplication application, MsCaseApplication req, Map<Long, MsCaseAffiliate> affiliateMap) {
application.setUpdateBy(SecurityUtils.getUsername());
application.setUpdateTime(new Date());
msCaseApplicationMapper.updateByPrimaryKeySelective(application);
MsCaseFlow caseFlow = nextFlow(application.getId(), req.getCaseFlowId(),req.getLockStatus());
// 给申请人被申请人发送短信
if (affiliateMap.containsKey(application.getId())) {
MsCaseAffiliate affiliate = affiliateMap.get(application.getId());
if (StrUtil.isNotEmpty(affiliate.getContactTelphoneAgent())) {
String sendContent = "尊敬的" + affiliate.getNameAgent() + "用户,您的" + application.getCaseNum() + "{2}仲裁案件,已成功受理,请知晓,如非本人操作,请忽略本短信";
// 给申请人发送案件受理短信 尊敬的{1}用户,您的{2}仲裁案件,已成功受理,请知晓,如非本人操作,请忽略本短信
Boolean smsFlag = SmsUtils.sendSms(application.getId(), "2049503", affiliate.getContactTelphoneAgent(), new String[]{affiliate.getNameAgent(), application.getCaseNum()});
CaseLogUtils.insertCaseLog(application.getId(), caseFlow.getNodeId(), caseFlow.getNodeName(), "向申请人发送短信," + sendContent);
SmsSendRecord smsSendRecord = new SmsSendRecord(application.getId(), application.getCaseNum(), affiliate.getContactTelphoneAgent(), new Date(), sendContent);
if (smsFlag) {
// 发送成功
smsSendRecord.setSendStatus(YesOrNoEnum.YES.getCode());
} else {
smsSendRecord.setSendStatus(YesOrNoEnum.NO.getCode());
}
smsRecordMapper.saveSmsSendRecord(smsSendRecord);
}
// 给申请人被申请人发送短信
if (StrUtil.isNotEmpty(affiliate.getRespondentPhone())) {
String sendContent = "尊敬的" + affiliate.getRespondentName() + "用户,您的" + application.getCaseNum() + "{2}仲裁案件,已成功受理,请知晓,如非本人操作,请忽略本短信";
// 给被申请人发送案件受理短信 尊敬的{1}用户,您的{2}仲裁案件,已成功受理,请知晓,如非本人操作,请忽略本短信
Boolean smsFlag = SmsUtils.sendSms(application.getId(), "2049503", affiliate.getRespondentPhone(), new String[]{affiliate.getRespondentName(), application.getCaseNum()});
CaseLogUtils.insertCaseLog(application.getId(), caseFlow.getNodeId(), caseFlow.getNodeName(), "向被申请人发送短信," + sendContent);
SmsSendRecord smsSendRecord = new SmsSendRecord(application.getId(), application.getCaseNum(), affiliate.getRespondentPhone(), new Date(), sendContent);
if (smsFlag) {
// 发送成功
smsSendRecord.setSendStatus(YesOrNoEnum.YES.getCode());
} else {
smsSendRecord.setSendStatus(YesOrNoEnum.NO.getCode());
}
smsRecordMapper.saveSmsSendRecord(smsSendRecord);
}
}
}
/**
* 流向下一个流程节点
* @param caseId 案件id
* @param caseFlowId 案件流程id
* @param lockStatus '是否锁定,0-否,1-是',单独操作案件时需要锁定
* @return
*/
@Override
public MsCaseFlow nextFlow(Long caseId,Integer caseFlowId,Integer lockStatus) {
MsCaseFlow nextFlow = caseFlowMapper.nextFlow(caseFlowId);
if (nextFlow == null) {
throw new ServiceException("未找到下一个流程节点");
}
MsCaseApplication application = new MsCaseApplication();
application.setId(caseId);
// 更改案件流程id和案件状态
application.setCaseFlowId(nextFlow.getId());
application.setCaseStatusName(nextFlow.getCaseStatusName());
application.setLockStatus(lockStatus);
msCaseApplicationMapper.updateByPrimaryKeySelective(application);
// 新增日志
CaseLogUtils.insertCaseLog(application.getId(), nextFlow.getNodeId(), nextFlow.getCaseStatusName(),"");
return nextFlow;
}
/**
* 生成调解申请书
* @param application 案件基本信息
* @param affiliate 案件相关人员
* @param templatePath 模板路径
* @param bookmarkList 标签
* @param dictDataList 内置字段
*/
private void createMediateApplication(MsCaseApplication application, MsCaseAffiliate affiliate, String templatePath, List<String> bookmarkList, List<SysDictData> dictDataList) {
// 申请书需要的字段和内容,valueMap<占位符,替换的值>
Map<String, String> valueMap = new HashMap<>();
for (SysDictData dictData : dictDataList) {
if (CASE_BASE_COLUMN.contains(dictData.getDictValue())) {
valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(application, dictData.getDictValue()));
} else {
// 相关人员字段
valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(affiliate, dictData.getDictValue()));
}
}
// 书签对应值
Map<String, Object> bookmarkValueMap = new HashMap<>();
// 读取调节申请书,找到占位符,替换值
// 遍历书签,给书签赋值
replaceBookmark(bookmarkList, bookmarkValueMap, valueMap);
// 根据条件替换书签
// conditionReplaceBookmark(caseApplicationById, bookmarkValueMap, agentName, resName, arbitrateRecordSelect);
// 申请书生成时间
LocalDate now = LocalDate.now();
int year = now.getYear();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日");
// 格式化当前日期
String formattedDate = now.format(formatter);
bookmarkValueMap.put("日期", formattedDate);
String month = String.format("%02d", now.getMonthValue());
String day = String.format("%02d", now.getDayOfMonth());
// todo
String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
// String saveFolderPath = "D:/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
String orgFileName="调解申请书";
String fileName = UUID.randomUUID().toString().replace("-", "")+orgFileName + ".docx";
// todo
String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
// String saveName = "D:/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day + "/" + fileName;
String resultFilePath = saveFolderPath + "/" + fileName;
// 将word中的标签替换掉,生成新的word
wordChangeText(templatePath, bookmarkValueMap,saveFolderPath,resultFilePath);
// String savePath = docFilePath.substring(0, docFilePath.indexOf("/upload/") + 8);
// 保存裁决书附件
// saveArbitorFile(id, saveName, savePath, caseApplicationById, arbitrateRecordSelect);
MsCaseAttach caseAttach = MsCaseAttach.builder()
.caseAppliId(application.getId())
.annexName(orgFileName)
.annexPath(resultFilePath)
.annexType(AnnexTypeEnum.MEDIATION_APPLICATION.getCode())
.build();
//保存到附件表里,先删除之前的在保存
msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(caseAttach.getCaseAppliId(), 3);
msCaseAttachMapper.save(caseAttach);
}
/**
* 将word中的标签替换掉,生成新的word
*
* @param modalFilePath 调解申请书模板路径
* @param datas 替换标签的内容
* @param resultFilePath 保存路径
* @return
* @throws IOException
*/
private void wordChangeText(String modalFilePath, Map<String, Object> datas, String saveFolderPath, String resultFilePath) {
// 调解申请书保存的路径
// 创建日期目录
File saveFolder = new File(saveFolderPath);
if (!saveFolder.exists()) {
saveFolder.mkdirs();
}
Path sourcePath = new File(modalFilePath).toPath();
Path destinationPath = new File(resultFilePath).toPath();
try {
Files.copy(sourcePath, destinationPath, StandardCopyOption.REPLACE_EXISTING);
WordUtil.getDocFilePath(datas, modalFilePath, resultFilePath);
File file = new File(resultFilePath);
if (file.exists()) {
InputStream in = new FileInputStream(file);
XWPFDocument xwpfDocument = new XWPFDocument(in);
WordUtil.changeText(xwpfDocument);
}
} catch (IOException e) {
throw new RuntimeException("请检查文件路径是否有误");
}
}
/**
* 给模板中的占位符赋值
*
* @param bookmarkList 书签
* @param bookmarkValueMap 书签赋值
* @param valueMap 案件内容
*/
private void replaceBookmark(List<String> bookmarkList, Map<String, Object> bookmarkValueMap, Map<String, String> valueMap) {
for (String bookmark : bookmarkList) {
if (valueMap.containsKey(bookmark)) {
bookmarkValueMap.put(bookmark, valueMap.get(bookmark));
}
}
}
/**
* 组装附件
*
@@ -463,12 +883,12 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
// caseAttach.setAnnexName(entry.getKey());
// }
// 申请人提供的证据材料
caseAttach.setAnnexType(2);
caseAttach.setAnnexType(AnnexTypeEnum.APPLICATION_EVIDENCE.getCode());
attachList.add(caseAttach);
if (fileUrl.contains("仲裁申请书")) {
MsCaseAttach applyFile = new MsCaseAttach();
BeanUtil.copyProperties(caseAttach, applyFile);
applyFile.setAnnexType(1);
applyFile.setAnnexType(AnnexTypeEnum.APPLICATION.getCode());
attachList.add(applyFile);
}
@@ -0,0 +1,332 @@
package com.ruoyi.wisdomarbitrate.service.mscase.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import com.ruoyi.ElegentPay;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.AnnexTypeEnum;
import com.ruoyi.common.enums.PaymentStatusEnum;
import com.ruoyi.common.enums.YesOrNoEnum;
import com.ruoyi.dto.PayRequest;
import com.ruoyi.dto.PayResponse;
import com.ruoyi.system.domain.entity.flow.MsCaseFlow;
import com.ruoyi.system.mapper.flow.MsCaseFlowMapper;
import com.ruoyi.wisdomarbitrate.domain.dto.mscase.CaseConfirmPayDTO;
import com.ruoyi.wisdomarbitrate.domain.dto.mscase.CasePayDTO;
import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAffiliate;
import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseApplication;
import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAttach;
import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCasePaymentRecord;
import com.ruoyi.wisdomarbitrate.domain.vo.mscase.PaymentDetailVO;
import com.ruoyi.wisdomarbitrate.mapper.mscase.MsCaseAffiliateMapper;
import com.ruoyi.wisdomarbitrate.mapper.mscase.MsCaseApplicationMapper;
import com.ruoyi.wisdomarbitrate.mapper.mscase.MsCaseAttachMapper;
import com.ruoyi.wisdomarbitrate.mapper.mscase.MsCasePaymentRecordMapper;
import com.ruoyi.wisdomarbitrate.mapper.sendrecord.SmsRecordMapper;
import com.ruoyi.wisdomarbitrate.service.mscase.MsCaseApplicationService;
import com.ruoyi.wisdomarbitrate.service.mscase.MsCasePaymentService;
import com.ruoyi.wisdomarbitrate.utils.CaseLogUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Service
public class MsCasePaymentServiceImpl implements MsCasePaymentService {
@Autowired
private ElegentPay elegentPay;
@Autowired
private MsCasePaymentRecordMapper casePaymentRecordMapper;
@Autowired
private MsCaseAttachMapper caseAttachMapper;
@Autowired
private MsCaseApplicationMapper caseApplicationMapper;
@Autowired
private SmsRecordMapper smsRecordMapper;
@Resource
private MsCaseApplicationService applicationService;
@Autowired
MsCaseFlowMapper caseFlowMapper;
@Autowired
MsCaseAffiliateMapper caseAffiliateMapper;
@Override
@Transactional
public AjaxResult casePay(CasePayDTO casePayDTO) {
List<MsCaseApplication> applicationList = new ArrayList<>();
PayRequest payRequest = new PayRequest();
payRequest.setBody("案件缴费");
payRequest.setOrderSn(System.currentTimeMillis() + "");
// 计算缴费总金额
int totalFee = 0;
if (StrUtil.isNotEmpty(casePayDTO.getBatchNumber())) {
// 批量缴费
applicationList = applicationService.listByBatchNumber(casePayDTO.getBatchNumber(), casePayDTO.getCaseFlowId());
if (CollectionUtil.isEmpty(applicationList)) {
return AjaxResult.error("该批号下未找到案件");
}
for (MsCaseApplication application : applicationList) {
// 应缴费用单位为元,将应缴费用转换为分即*100
if (application.getFeePayable() != null) {
totalFee += ((application.getFeePayable().multiply(new BigDecimal("100")))).intValue();
}
}
} else {
MsCaseApplication application = caseApplicationMapper.selectByPrimaryKey(casePayDTO.getCaseId());
if (application == null) {
return AjaxResult.error("该案件不存在");
}
applicationList.add(application);
totalFee += ((application.getFeePayable().multiply(new BigDecimal("100")))).intValue();
}
// 单位分
payRequest.setTotalFee(totalFee);
PayResponse response = elegentPay.requestPay(payRequest, casePayDTO.getTradeType(), casePayDTO.getPlatform());
if (response.getCode_url() == null) {
return AjaxResult.error();
}
for (MsCaseApplication application : applicationList) {
//缴费记录表里新增数据
MsCasePaymentRecord casePaymentRecord = new MsCasePaymentRecord();
casePaymentRecord.setCaseId(application.getId());
casePaymentRecord.setOrderNumber(payRequest.getOrderSn());
casePaymentRecord.setPaymentStatus(PaymentStatusEnum.UNPAID.getCode());
casePaymentRecord.setCreateTime(new Date());
casePaymentRecordMapper.insert(casePaymentRecord);
}
return AjaxResult.success(response);
}
/**
* 支付回调
*
* @param orderNumber
* @return
*/
@Transactional
public AjaxResult callback(String orderNumber) {
//查询记录
Example casePayExample = new Example(MsCasePaymentRecord.class);
casePayExample.createCriteria().andEqualTo("order_number", orderNumber);
List<MsCasePaymentRecord> casePaymentRecords = casePaymentRecordMapper.selectByExample(orderNumber);
if (casePaymentRecords != null && casePaymentRecords.size() > 0) {
for (MsCasePaymentRecord casePaymentRecord : casePaymentRecords) {
//更改记录表里的支付状态和支付时间
casePaymentRecord.setPaymentStatus(1);
casePaymentRecord.setPaymentTime(new Date());
casePaymentRecord.setUpdateTime(new Date());
casePaymentRecordMapper.updateByPrimaryKeySelective(casePaymentRecord);
}
} else {
return AjaxResult.error("未查询到相关记录");
}
return AjaxResult.success("支付成功");
}
/**
* 确认缴费
*
* @param dto
* @return
*/
@Transactional
@Override
public AjaxResult confirmPayment(CaseConfirmPayDTO dto) {
// 根据流程id查找下一个流程节点
MsCaseFlow nextFlow = caseFlowMapper.nextFlow(dto.getCaseFlowId());
if (nextFlow == null) {
return AjaxResult.error("未找到下一个流程节点");
}
if (StrUtil.isNotEmpty(dto.getBatchNumber())) {
// 批量操作
// 查询该批号下该流程的案件
List<MsCaseApplication> applicationList = applicationService.listByBatchNumber(dto.getBatchNumber(), dto.getCaseFlowId());
if (CollectionUtil.isEmpty(applicationList)) {
return AjaxResult.error("该批号下未找到案件");
}
for (MsCaseApplication application : applicationList) {
confirmPayment(nextFlow, application, dto);
}
} else {
// 单独
MsCaseApplication application = new MsCaseApplication();
application.setId(dto.getCaseId());
application.setLockStatus(YesOrNoEnum.YES.getCode());
confirmPayment(nextFlow, application, dto);
}
return AjaxResult.success("确认缴费成功");
}
/**
* 查询应缴费用和申请人
*
* @param casePayDTO
* @return
*/
@Override
public AjaxResult selectTotalFee(CasePayDTO casePayDTO) {
Long caseId = null;
// 计算缴费总金额
int totalFee = 0;
if (StrUtil.isNotEmpty(casePayDTO.getBatchNumber())) {
// 批量缴费
List<MsCaseApplication> applicationList = applicationService.listByBatchNumber(casePayDTO.getBatchNumber(), casePayDTO.getCaseFlowId());
if (CollectionUtil.isEmpty(applicationList)) {
return AjaxResult.error("该批号下未找到案件");
}
caseId = applicationList.get(0).getId();
for (MsCaseApplication application : applicationList) {
// 应缴费用单位为元,将应缴费用转换为分即*100
if (application.getFeePayable() != null) {
totalFee += ((application.getFeePayable().multiply(new BigDecimal("100")))).intValue();
}
}
} else {
MsCaseApplication resultApplication = caseApplicationMapper.selectByPrimaryKey(casePayDTO.getCaseId());
if (resultApplication == null) {
return AjaxResult.error("该案件不存在");
}
caseId = resultApplication.getId();
totalFee += ((resultApplication.getFeePayable().multiply(new BigDecimal("100")))).intValue();
}
// 根据caseId查询申请人
MsCaseAffiliate affiliate = caseAffiliateMapper.selectByPrimaryKey(caseId);
if (affiliate == null) {
return AjaxResult.error("该案件不存在");
}
JSONObject jsonObject = new JSONObject();
jsonObject.set("totalFee", totalFee);
jsonObject.set("applicationOrganName", affiliate.getApplicationOrganName());
return AjaxResult.success(jsonObject);
}
/**
* 根据案件id查询缴费单
*
* @param id
* @return
*/
@Override
public PaymentDetailVO selectPaymentDetail(Long id) {
PaymentDetailVO result = null;
MsCaseApplication application = caseApplicationMapper.selectByPrimaryKey(id);
if (application == null) {
return null;
}
result=new PaymentDetailVO();
result.setCaseNum(application.getCaseNum());
result.setCaseSubjectAmount(application.getCaseSubjectAmount());
result.setFeePayable(application.getFeePayable());
result.setCaseStatusName(application.getCaseStatusName());
MsCaseAffiliate affiliate = caseAffiliateMapper.selectByPrimaryKey(application.getId());
if(affiliate != null) {
result.setApplicationOrganName(affiliate.getApplicationOrganName());
}
// 查询缴费单
result.setCaseAttachList(caseAttachMapper.listCaseAttachByCaseIdAndType(id, AnnexTypeEnum.PAYMENT_RECEIPT.getCode()));
return result;
}
/**
* 确认已缴费
* @param dto
* @return
*/
@Transactional
@Override
public AjaxResult confirmPaid(CaseConfirmPayDTO dto) {
// 根据流程id查找下一个流程节点
MsCaseFlow nextFlow = caseFlowMapper.nextFlow(dto.getCaseFlowId());
if (nextFlow == null) {
return AjaxResult.error("未找到下一个流程节点");
}
if (StrUtil.isNotEmpty(dto.getBatchNumber())) {
// 批量
List<MsCaseApplication> applicationList = applicationService.listByBatchNumber(dto.getBatchNumber(), dto.getCaseFlowId());
if(CollectionUtil.isEmpty(applicationList)){
return AjaxResult.error("该批号下未找到案件");
}
for (MsCaseApplication application : applicationList) {
confirmPaid(nextFlow, application);
}
}else {
MsCaseApplication caseApplication=new MsCaseApplication();
caseApplication.setId(dto.getCaseId());
caseApplication.setLockStatus(YesOrNoEnum.YES.getCode());
confirmPaid(nextFlow,caseApplication );
}
return AjaxResult.success("确认缴费成功");
}
/**
* 确认已缴费
* @param nextFlow
* @param application
* @param
*/
private void confirmPaid(MsCaseFlow nextFlow, MsCaseApplication application) {
//更改记录表里的支付状态和支付时间
MsCasePaymentRecord casePaymentRecord = new MsCasePaymentRecord();
casePaymentRecord.setPaymentStatus(1);
casePaymentRecord.setCaseId(application.getId());
casePaymentRecord.setPaymentTime(new Date());
casePaymentRecord.setUpdateTime(new Date());
Example example = new Example(MsCasePaymentRecord.class);
example.createCriteria().andEqualTo("caseId", casePaymentRecord.getCaseId());
casePaymentRecordMapper.updateByExampleSelective(casePaymentRecord,example);
// 更改案件流程id和案件状态
application.setCaseFlowId(nextFlow.getId());
application.setCaseStatusName(nextFlow.getCaseStatusName());
caseApplicationMapper.updateByPrimaryKeySelective(application);
// 新增日志
CaseLogUtils.insertCaseLog(application.getId(), nextFlow.getNodeId(), nextFlow.getCaseStatusName(),"确认已缴费");
}
/**
* 确认缴费
*
* @param nextFlow
* @param application
* @param dto
*/
private void confirmPayment(MsCaseFlow nextFlow, MsCaseApplication application, CaseConfirmPayDTO dto) {
application.setPayType(dto.getPayType());
// 修改缴费附件
if (CollectionUtil.isNotEmpty(dto.getPayOrderList())) {
for (MsCaseAttach caseAttach : dto.getPayOrderList()) {
caseAttach.setCaseAppliId(application.getId());
caseAttachMapper.updateCaseAttach(caseAttach);
}
}
// 修改支付方式,流程节点和案件状态名称
application.setCaseFlowId(nextFlow.getId());
application.setCaseStatusName(nextFlow.getCaseStatusName());
caseApplicationMapper.updateByPrimaryKeySelective(application);
CaseLogUtils.insertCaseLog(application.getId(), nextFlow.getNodeId(), nextFlow.getCaseStatusName(),"确认缴费");
}
}
@@ -49,7 +49,7 @@
where case_appli_id =#{id}
</select>
<select id="getCaseAttachByCaseIdAndType" resultType="com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAttach" resultMap="CaseAttachResult">
<select id="listCaseAttachByCaseIdAndType" resultType="com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAttach" resultMap="CaseAttachResult">
select annex_id,case_appli_id,annex_name,annex_path,annex_type,note,use_id,use_account
from ms_case_attach
<where>
@@ -102,7 +102,15 @@
case_appli_id= #{caseAppliId}
where annex_id = #{annexId}
</update>
<update id="batchUpdate">
<foreach collection="list" item="item" >
update ms_case_attach
set
case_appli_id= #{item.caseAppliId}
where annex_id = #{item.annexId};
</foreach>
</update>
<update id="updateCaseAttachBycaseid" parameterType="com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAttach" >
update ms_case_attach
<set>
@@ -120,5 +128,4 @@
</update>
</mapper>
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.wisdomarbitrate.mapper.mscase.MsCasePaymentRecordMapper">
<resultMap id="BaseResultMap" type="com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCasePaymentRecord">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="BIGINT" property="id" />
<result column="case_id" jdbcType="BIGINT" property="caseId" />
<result column="order_number" jdbcType="VARCHAR" property="orderNumber" />
<result column="payment_time" jdbcType="TIMESTAMP" property="paymentTime" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="payment_status" jdbcType="INTEGER" property="paymentStatus" />
<result column="pay_type" jdbcType="INTEGER" property="payType" />
</resultMap>
</mapper>
@@ -19,7 +19,7 @@
</resultMap>
<insert id="saveSmsSendRecord" parameterType="com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord" useGeneratedKeys="true" keyProperty="id">
insert into sms_send_record(
insert into ms_sms_send_record(
<if test="caseId != null ">case_appli_id,</if>
<if test="caseNum != null ">case_num,</if>
<if test="phone != null and phone != ''">phone,</if>
@@ -41,7 +41,7 @@
</insert>
<insert id="batchSaveSmsSendRecord">
insert into sms_send_record(
insert into ms_sms_send_record(
case_appli_id,
case_num,
phone,
@@ -68,7 +68,7 @@
<select id="getSmsSendRecord" parameterType="com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord" resultMap="SmsSendRecordResult">
select id ,case_appli_id ,case_num ,phone ,send_time ,send_content,send_status
from sms_send_record
from ms_sms_send_record
<where>
<if test="caseNum != null and caseNum != ''">
AND case_num = #{caseNum}
@@ -82,4 +82,7 @@
ORDER BY create_time DESC
</select>
<select id="selectById" resultMap="TemplateManageResult">
select * from ms_template_manage where id=#{id}
</select>
</mapper>