55 changed files with 4872 additions and 1250 deletions
@ -0,0 +1,54 @@ |
|||
package com.yxt.supervise.report.api.csmcashreport; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.yxt.common.core.domain.BaseEntity; |
|||
import io.swagger.annotations.ApiModel; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/6/21 9:19 |
|||
*/ |
|||
@ApiModel(value = "每日回款审核报告-附件:昨日销售报表", description = "每日回款审核报告-附件:昨日销售报表") |
|||
@TableName("csm_cash_report") |
|||
@Data |
|||
public class CsmCashReport extends BaseEntity { |
|||
//'日期(yyyy-MM-dd)',
|
|||
private String dataDate; |
|||
// '银行Sid',
|
|||
private String bankSid; |
|||
// '银行名称',
|
|||
private String bankName; |
|||
// '公司Sid',
|
|||
private String companySid; |
|||
// '公司名称',
|
|||
private String companyName; |
|||
//昨日销售总计金额(元)',
|
|||
private double salesAmountYesterday; |
|||
// '今日应回款金额(元)',
|
|||
private double cashedAmountToday; |
|||
//'今日实际回款金额(元)',
|
|||
private double cashedAmountTodayReal; |
|||
//'回款差额金额(元)',
|
|||
private double cashedAmountDifferent; |
|||
//'序号',
|
|||
private Integer serialNumber; |
|||
// '销售日期',
|
|||
private Date saleDate; |
|||
//'支付渠道Sid',
|
|||
private String disbursementChannelSid; |
|||
// '支付渠道名称',
|
|||
private String disbursementChannelName; |
|||
//'金额(元)',
|
|||
private double amountYesterday; |
|||
//'截止时间',
|
|||
private String tillTime; |
|||
//'账户余额',
|
|||
private double accountBalance; |
|||
// '审核结果',
|
|||
private String auditResult; |
|||
//'日期(yyyy年MM月dd日)',
|
|||
private String reportDate; |
|||
} |
@ -0,0 +1,46 @@ |
|||
package com.yxt.supervise.report.api.csmcashreport; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/6/21 9:19 |
|||
*/ |
|||
public class CsmCashReportDto { |
|||
//'日期(yyyy-MM-dd)',
|
|||
private String dataDate; |
|||
// '银行Sid',
|
|||
private String bankSid; |
|||
// '银行名称',
|
|||
private String bankName; |
|||
// '公司Sid',
|
|||
private String companySid; |
|||
// '公司名称',
|
|||
private String companyName; |
|||
//昨日销售总计金额(元)',
|
|||
private double salesAmountYesterday; |
|||
// '今日应回款金额(元)',
|
|||
private double cashedAmountToday; |
|||
//'今日实际回款金额(元)',
|
|||
private double cashedAmountTodayReal; |
|||
//'回款差额金额(元)',
|
|||
private double cashedAmountDifferent; |
|||
//'序号',
|
|||
private Integer serialNumber; |
|||
// '销售日期',
|
|||
private Date saleDate; |
|||
//'支付渠道Sid',
|
|||
private String disbursementChannelSid; |
|||
// '支付渠道名称',
|
|||
private String disbursementChannelName; |
|||
//'金额(元)',
|
|||
private double amountYesterday; |
|||
//'截止时间',
|
|||
private String tillTime; |
|||
//'账户余额',
|
|||
private double accountBalance; |
|||
// '审核结果',
|
|||
private String auditResult; |
|||
//'日期(yyyy年MM月dd日)',
|
|||
private String reportDate; |
|||
} |
@ -0,0 +1,46 @@ |
|||
package com.yxt.supervise.report.api.csmcashreport; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/6/21 9:19 |
|||
*/ |
|||
public class CsmCashReportQuery { |
|||
//'日期(yyyy-MM-dd)',
|
|||
private String dataDate; |
|||
// '银行Sid',
|
|||
private String bankSid; |
|||
// '银行名称',
|
|||
private String bankName; |
|||
// '公司Sid',
|
|||
private String companySid; |
|||
// '公司名称',
|
|||
private String companyName; |
|||
//昨日销售总计金额(元)',
|
|||
private double salesAmountYesterday; |
|||
// '今日应回款金额(元)',
|
|||
private double cashedAmountToday; |
|||
//'今日实际回款金额(元)',
|
|||
private double cashedAmountTodayReal; |
|||
//'回款差额金额(元)',
|
|||
private double cashedAmountDifferent; |
|||
//'序号',
|
|||
private Integer serialNumber; |
|||
// '销售日期',
|
|||
private Date saleDate; |
|||
//'支付渠道Sid',
|
|||
private String disbursementChannelSid; |
|||
// '支付渠道名称',
|
|||
private String disbursementChannelName; |
|||
//'金额(元)',
|
|||
private double amountYesterday; |
|||
//'截止时间',
|
|||
private String tillTime; |
|||
//'账户余额',
|
|||
private double accountBalance; |
|||
// '审核结果',
|
|||
private String auditResult; |
|||
//'日期(yyyy年MM月dd日)',
|
|||
private String reportDate; |
|||
} |
@ -0,0 +1,48 @@ |
|||
package com.yxt.supervise.report.api.csmcashreport; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/6/21 9:19 |
|||
*/ |
|||
public class CsmCashReportVo { |
|||
private String id; |
|||
private String sid; |
|||
//'日期(yyyy-MM-dd)',
|
|||
private String dataDate; |
|||
// '银行Sid',
|
|||
private String bankSid; |
|||
// '银行名称',
|
|||
private String bankName; |
|||
// '公司Sid',
|
|||
private String companySid; |
|||
// '公司名称',
|
|||
private String companyName; |
|||
//昨日销售总计金额(元)',
|
|||
private double salesAmountYesterday; |
|||
// '今日应回款金额(元)',
|
|||
private double cashedAmountToday; |
|||
//'今日实际回款金额(元)',
|
|||
private double cashedAmountTodayReal; |
|||
//'回款差额金额(元)',
|
|||
private double cashedAmountDifferent; |
|||
//'序号',
|
|||
private Integer serialNumber; |
|||
// '销售日期',
|
|||
private Date saleDate; |
|||
//'支付渠道Sid',
|
|||
private String disbursementChannelSid; |
|||
// '支付渠道名称',
|
|||
private String disbursementChannelName; |
|||
//'金额(元)',
|
|||
private double amountYesterday; |
|||
//'截止时间',
|
|||
private String tillTime; |
|||
//'账户余额',
|
|||
private double accountBalance; |
|||
// '审核结果',
|
|||
private String auditResult; |
|||
//'日期(yyyy年MM月dd日)',
|
|||
private String reportDate; |
|||
} |
@ -0,0 +1,38 @@ |
|||
package com.yxt.supervise.report.api.csmcashreportcashedtoday; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.yxt.common.core.domain.BaseEntity; |
|||
import io.swagger.annotations.ApiModel; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/6/21 9:03 |
|||
*/ |
|||
@ApiModel(value = "每日回款审核报告-附件:昨日销售报表", description = "每日回款审核报告-附件:昨日销售报表") |
|||
@TableName("csm_cash_report_cashed_today") |
|||
@Data |
|||
public class CsmCashReportCashedToday extends BaseEntity { |
|||
|
|||
|
|||
// '日期(yyyy-MM-dd)',
|
|||
private String dataDate; |
|||
// '报告Sid',
|
|||
private String reportSid; |
|||
//'销售日期(yyyy年MM月dd日)',
|
|||
private String salesDate; |
|||
// '支付渠道Sid',
|
|||
private String disbursementChannelSid; |
|||
//'支付渠道名称',
|
|||
private String disbursementChannelName; |
|||
// '金额(元)',
|
|||
private double amount; |
|||
//'对应公司主体Sid',
|
|||
private String companySid; |
|||
//'对应公司主体名称',
|
|||
private String companyName; |
|||
// '回款金额',
|
|||
private double cashedAmount; |
|||
// '回款差额',
|
|||
private double differentAmount; |
|||
} |
@ -0,0 +1,33 @@ |
|||
package com.yxt.supervise.report.api.csmcashreportcashedtoday; |
|||
|
|||
import com.yxt.common.core.dto.Dto; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/6/21 9:04 |
|||
*/ |
|||
@Data |
|||
public class CsmCashReportCashedTodayDto implements Dto { |
|||
|
|||
// '日期(yyyy-MM-dd)',
|
|||
private String dataDate; |
|||
// '报告Sid',
|
|||
private String reportSid; |
|||
//'销售日期(yyyy年MM月dd日)',
|
|||
private String salesDate; |
|||
// '支付渠道Sid',
|
|||
private String disbursementChannelSid; |
|||
//'支付渠道名称',
|
|||
private String disbursementChannelName; |
|||
// '金额(元)',
|
|||
private double amount; |
|||
//'对应公司主体Sid',
|
|||
private String companySid; |
|||
//'对应公司主体名称',
|
|||
private String companyName; |
|||
// '回款金额',
|
|||
private double cashedAmount; |
|||
// '回款差额',
|
|||
private double differentAmount; |
|||
} |
@ -0,0 +1,33 @@ |
|||
package com.yxt.supervise.report.api.csmcashreportcashedtoday; |
|||
|
|||
import com.yxt.common.core.query.Query; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/6/21 9:04 |
|||
*/ |
|||
@Data |
|||
public class CsmCashReportCashedTodayQuery implements Query { |
|||
|
|||
// '日期(yyyy-MM-dd)',
|
|||
private String dataDate; |
|||
// '报告Sid',
|
|||
private String reportSid; |
|||
//'销售日期(yyyy年MM月dd日)',
|
|||
private String salesDate; |
|||
// '支付渠道Sid',
|
|||
private String disbursementChannelSid; |
|||
//'支付渠道名称',
|
|||
private String disbursementChannelName; |
|||
// '金额(元)',
|
|||
private double amount; |
|||
//'对应公司主体Sid',
|
|||
private String companySid; |
|||
//'对应公司主体名称',
|
|||
private String companyName; |
|||
// '回款金额',
|
|||
private double cashedAmount; |
|||
// '回款差额',
|
|||
private double differentAmount; |
|||
} |
@ -0,0 +1,33 @@ |
|||
package com.yxt.supervise.report.api.csmcashreportcashedtoday; |
|||
|
|||
import com.yxt.common.core.vo.Vo; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/6/21 9:03 |
|||
*/ |
|||
@Data |
|||
public class CsmCashReportCashedTodayVo implements Vo { |
|||
|
|||
// '日期(yyyy-MM-dd)',
|
|||
private String dataDate; |
|||
// '报告Sid',
|
|||
private String reportSid; |
|||
//'销售日期(yyyy年MM月dd日)',
|
|||
private String salesDate; |
|||
// '支付渠道Sid',
|
|||
private String disbursementChannelSid; |
|||
//'支付渠道名称',
|
|||
private String disbursementChannelName; |
|||
// '金额(元)',
|
|||
private double amount; |
|||
//'对应公司主体Sid',
|
|||
private String companySid; |
|||
//'对应公司主体名称',
|
|||
private String companyName; |
|||
// '回款金额',
|
|||
private double cashedAmount; |
|||
// '回款差额',
|
|||
private double differentAmount; |
|||
} |
@ -0,0 +1,33 @@ |
|||
package com.yxt.supervise.report.api.csmcashreportsalesyesterday; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.yxt.common.core.domain.BaseEntity; |
|||
import io.swagger.annotations.ApiModel; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/6/21 8:44 |
|||
*/ |
|||
@ApiModel(value = "每日回款审核报告-附件:昨日销售报表", description = "每日回款审核报告-附件:昨日销售报表") |
|||
@TableName("csm_cash_report_sales_yesterday") |
|||
@Data |
|||
public class CsmCashReportSalesYesterday extends BaseEntity { |
|||
|
|||
// '日期(yyyy-MM-dd)',
|
|||
private String dataDate; |
|||
//'报告Sid',
|
|||
private String reportSid; |
|||
//'支付渠道Sid',
|
|||
private String disbursementChannelSid; |
|||
//'支付渠道名称',
|
|||
private String disbursementChannelName; |
|||
//'金额(元)',
|
|||
private double amount; |
|||
// '对应公司主体Sid',
|
|||
private String CompanySid; |
|||
//'对应公司主体名称',
|
|||
private String companyName; |
|||
//'回款周期',
|
|||
private String accountCycle; |
|||
} |
@ -0,0 +1,28 @@ |
|||
package com.yxt.supervise.report.api.csmcashreportsalesyesterday; |
|||
|
|||
import com.yxt.common.core.vo.Vo; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/6/21 8:45 |
|||
*/ |
|||
@Data |
|||
public class CsmCashReportSalesYesterdayDto implements Vo { |
|||
// '日期(yyyy-MM-dd)',
|
|||
private String dataDate; |
|||
//'报告Sid',
|
|||
private String reportSid; |
|||
//'支付渠道Sid',
|
|||
private String disbursementChannelSid; |
|||
//'支付渠道名称',
|
|||
private String disbursementChannelName; |
|||
//'金额(元)',
|
|||
private double amount; |
|||
// '对应公司主体Sid',
|
|||
private String CompanySid; |
|||
//'对应公司主体名称',
|
|||
private String companyName; |
|||
//'回款周期',
|
|||
private String accountCycle; |
|||
} |
@ -0,0 +1,28 @@ |
|||
package com.yxt.supervise.report.api.csmcashreportsalesyesterday; |
|||
|
|||
import com.yxt.common.core.query.Query; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/6/21 8:45 |
|||
*/ |
|||
@Data |
|||
public class CsmCashReportSalesYesterdayQuery implements Query { |
|||
// '日期(yyyy-MM-dd)',
|
|||
private String dataDate; |
|||
//'报告Sid',
|
|||
private String reportSid; |
|||
//'支付渠道Sid',
|
|||
private String disbursementChannelSid; |
|||
//'支付渠道名称',
|
|||
private String disbursementChannelName; |
|||
//'金额(元)',
|
|||
private double amount; |
|||
// '对应公司主体Sid',
|
|||
private String CompanySid; |
|||
//'对应公司主体名称',
|
|||
private String companyName; |
|||
//'回款周期',
|
|||
private String accountCycle; |
|||
} |
@ -0,0 +1,28 @@ |
|||
package com.yxt.supervise.report.api.csmcashreportsalesyesterday; |
|||
|
|||
import com.yxt.common.core.vo.Vo; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/6/21 8:45 |
|||
*/ |
|||
@Data |
|||
public class CsmCashReportSalesYesterdayVo implements Vo { |
|||
// '日期(yyyy-MM-dd)',
|
|||
private String dataDate; |
|||
//'报告Sid',
|
|||
private String reportSid; |
|||
//'支付渠道Sid',
|
|||
private String disbursementChannelSid; |
|||
//'支付渠道名称',
|
|||
private String disbursementChannelName; |
|||
//'金额(元)',
|
|||
private double amount; |
|||
// '对应公司主体Sid',
|
|||
private String CompanySid; |
|||
//'对应公司主体名称',
|
|||
private String companyName; |
|||
//'回款周期',
|
|||
private String accountCycle; |
|||
} |
@ -0,0 +1,14 @@ |
|||
package com.yxt.supervise.report.api.wechat; |
|||
|
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/4/3 13:55 |
|||
*/ |
|||
@Data |
|||
public class Miniprogram { |
|||
private String appid; |
|||
private String pagepath; |
|||
|
|||
} |
@ -0,0 +1,22 @@ |
|||
package com.yxt.supervise.report.api.wechat; |
|||
|
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/4/3 14:33 |
|||
*/ |
|||
@Data |
|||
public class Template { |
|||
private String value; |
|||
private String color; |
|||
public Template(String value) { |
|||
this.value = value; |
|||
this.color = "#173177"; |
|||
} |
|||
|
|||
public Template(String value, String color) { |
|||
this.value = value; |
|||
this.color = color; |
|||
} |
|||
} |
@ -0,0 +1,26 @@ |
|||
package com.yxt.supervise.report.api.wechat; |
|||
|
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/4/3 13:46 |
|||
*/ |
|||
@Data |
|||
public class TemplateData { |
|||
private String value; |
|||
private String color; |
|||
|
|||
public String getValue() { |
|||
return value; |
|||
} |
|||
public void setValue(String value) { |
|||
this.value = value; |
|||
} |
|||
public String getColor() { |
|||
return color; |
|||
} |
|||
public void setColor(String color) { |
|||
this.color = color; |
|||
} |
|||
} |
@ -0,0 +1,57 @@ |
|||
package com.yxt.supervise.report.api.wechat; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/4/3 13:08 |
|||
*/ |
|||
@Data |
|||
public class WeChatTemplateMsg { |
|||
private String template_id; |
|||
private String touser; |
|||
private String url; |
|||
|
|||
private String client_msg_id; |
|||
|
|||
Map<String, String> miniprogram = new HashMap<>(); |
|||
|
|||
//private Miniprogram miniprogram;
|
|||
private String topcolor; |
|||
private Map<String, TemplateData> data; |
|||
|
|||
public String getTemplate_id() { |
|||
return template_id; |
|||
} |
|||
public void setTemplate_id(String template_id) { |
|||
this.template_id = template_id; |
|||
} |
|||
public String getTouser() { |
|||
return touser; |
|||
} |
|||
public void setTouser(String touser) { |
|||
this.touser = touser; |
|||
} |
|||
public String getUrl() { |
|||
return url; |
|||
} |
|||
public void setUrl(String url) { |
|||
this.url = url; |
|||
} |
|||
public String getTopcolor() { |
|||
return topcolor; |
|||
} |
|||
public void setTopcolor(String topcolor) { |
|||
this.topcolor = topcolor; |
|||
} |
|||
public Map<String,TemplateData> getData() { |
|||
return data; |
|||
} |
|||
public void setData(Map<String,TemplateData> data) { |
|||
this.data = data; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,13 @@ |
|||
package com.yxt.supervise.report.biz.csmcashreport; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.yxt.supervise.report.api.csmcashreport.CsmCashReport; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/6/21 10:50 |
|||
*/ |
|||
@Mapper |
|||
public interface CsmCashReportMapper extends BaseMapper<CsmCashReport> { |
|||
} |
@ -0,0 +1,8 @@ |
|||
<?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.yxt.supervise.report.biz.csmcashreport.CsmCashReportMapper"> |
|||
<!-- <where> ${ew.sqlSegment} </where>--> |
|||
<!-- ${ew.customSqlSegment} --> |
|||
|
|||
|
|||
</mapper> |
@ -0,0 +1,28 @@ |
|||
package com.yxt.supervise.report.biz.csmcashreport; |
|||
|
|||
import com.yxt.common.core.result.ResultBean; |
|||
import com.yxt.supervise.report.api.csmcashreport.CsmCashReportDto; |
|||
import com.yxt.supervise.report.api.reportsalesdaystore.ReportSalesDayStoreDto; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/6/21 10:51 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("/csmcashreport") |
|||
public class CsmCashReportRest { |
|||
@Autowired |
|||
CsmCashReportService csmCashReportService; |
|||
|
|||
|
|||
@PostMapping("/save") |
|||
public ResultBean save(@RequestBody CsmCashReportDto dto){ |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
return csmCashReportService.save(dto); |
|||
} |
|||
} |
@ -0,0 +1,27 @@ |
|||
package com.yxt.supervise.report.biz.csmcashreport; |
|||
|
|||
import cn.hutool.core.bean.BeanUtil; |
|||
import com.yxt.common.base.service.MybatisBaseService; |
|||
import com.yxt.common.core.result.ResultBean; |
|||
import com.yxt.supervise.report.api.csmcashreport.CsmCashReport; |
|||
import com.yxt.supervise.report.api.csmcashreport.CsmCashReportDto; |
|||
import com.yxt.supervise.report.api.reportsalesdaystore.ReportSalesDayStore; |
|||
import com.yxt.supervise.report.api.reportsalesdaystore.ReportSalesDayStoreDto; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/6/21 10:51 |
|||
*/ |
|||
@Service |
|||
public class CsmCashReportService extends MybatisBaseService<CsmCashReportMapper,CsmCashReport> { |
|||
|
|||
public ResultBean save(CsmCashReportDto dto) { |
|||
ResultBean rb=new ResultBean(); |
|||
CsmCashReport entity=new CsmCashReport(); |
|||
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|||
baseMapper.insert(entity); |
|||
return rb.success().setMsg("保存成功"); |
|||
|
|||
} |
|||
} |
@ -0,0 +1,11 @@ |
|||
package com.yxt.supervise.report.biz.csmcashreportcashedtoday; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.yxt.supervise.report.api.csmcashreportcashedtoday.CsmCashReportCashedToday; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/6/21 10:56 |
|||
*/ |
|||
public interface CsmCashReportCashedTodayMapper extends BaseMapper<CsmCashReportCashedToday> { |
|||
} |
@ -0,0 +1,8 @@ |
|||
<?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.yxt.supervise.report.biz.csmcashreportcashedtoday.CsmCashReportCashedTodayMapper"> |
|||
<!-- <where> ${ew.sqlSegment} </where>--> |
|||
<!-- ${ew.customSqlSegment} --> |
|||
|
|||
|
|||
</mapper> |
@ -0,0 +1,31 @@ |
|||
package com.yxt.supervise.report.biz.csmcashreportcashedtoday; |
|||
|
|||
import com.yxt.common.base.service.MybatisBaseService; |
|||
import com.yxt.common.core.result.ResultBean; |
|||
import com.yxt.supervise.report.api.csmcashreport.CsmCashReportDto; |
|||
import com.yxt.supervise.report.api.csmcashreportcashedtoday.CsmCashReportCashedToday; |
|||
import com.yxt.supervise.report.api.csmcashreportcashedtoday.CsmCashReportCashedTodayDto; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/6/21 10:56 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("/csmcashreportcashed") |
|||
public class CsmCashReportCashedTodayRest { |
|||
@Autowired |
|||
CsmCashReportCashedTodayService csmCashReportCashedTodayService; |
|||
|
|||
|
|||
|
|||
@PostMapping("/save") |
|||
public ResultBean save(@RequestBody CsmCashReportCashedTodayDto dto){ |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
return csmCashReportCashedTodayService.save(dto); |
|||
} |
|||
} |
@ -0,0 +1,30 @@ |
|||
package com.yxt.supervise.report.biz.csmcashreportcashedtoday; |
|||
|
|||
import cn.hutool.core.bean.BeanUtil; |
|||
import com.yxt.common.base.service.MybatisBaseService; |
|||
import com.yxt.common.core.result.ResultBean; |
|||
import com.yxt.supervise.report.api.csmcashreport.CsmCashReport; |
|||
import com.yxt.supervise.report.api.csmcashreport.CsmCashReportDto; |
|||
import com.yxt.supervise.report.api.csmcashreportcashedtoday.CsmCashReportCashedToday; |
|||
import com.yxt.supervise.report.api.csmcashreportcashedtoday.CsmCashReportCashedTodayDto; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/6/21 10:56 |
|||
*/ |
|||
@Service |
|||
public class CsmCashReportCashedTodayService extends MybatisBaseService<CsmCashReportCashedTodayMapper, CsmCashReportCashedToday> { |
|||
|
|||
|
|||
public ResultBean save(CsmCashReportCashedTodayDto dto) { |
|||
ResultBean rb=new ResultBean(); |
|||
CsmCashReportCashedToday entity=new CsmCashReportCashedToday(); |
|||
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|||
baseMapper.insert(entity); |
|||
return rb.success().setMsg("保存成功"); |
|||
|
|||
} |
|||
} |
@ -0,0 +1,11 @@ |
|||
package com.yxt.supervise.report.biz.csmcashreportsalesyesterday; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.yxt.supervise.report.api.csmcashreportsalesyesterday.CsmCashReportSalesYesterday; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/6/21 10:57 |
|||
*/ |
|||
public interface CsmCashReportSalesYesterdayMapper extends BaseMapper<CsmCashReportSalesYesterday> { |
|||
} |
@ -0,0 +1,8 @@ |
|||
<?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.yxt.supervise.report.biz.csmcashreportsalesyesterday.CsmCashReportSalesYesterdayMapper"> |
|||
<!-- <where> ${ew.sqlSegment} </where>--> |
|||
<!-- ${ew.customSqlSegment} --> |
|||
|
|||
|
|||
</mapper> |
@ -0,0 +1,27 @@ |
|||
package com.yxt.supervise.report.biz.csmcashreportsalesyesterday; |
|||
|
|||
import com.yxt.common.core.result.ResultBean; |
|||
import com.yxt.supervise.report.api.csmcashreportcashedtoday.CsmCashReportCashedTodayDto; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/6/21 10:57 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("/csmcashreportsales") |
|||
public class CsmCashReportSalesYesterdayRest { |
|||
@Autowired |
|||
CsmCashReportSalesYesterdayService csmCashReportSalesYesterdayService; |
|||
|
|||
|
|||
@PostMapping("/save") |
|||
public ResultBean save(@RequestBody CsmCashReportCashedTodayDto dto){ |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
return csmCashReportSalesYesterdayService.save(dto); |
|||
} |
|||
} |
@ -0,0 +1,22 @@ |
|||
package com.yxt.supervise.report.biz.csmcashreportsalesyesterday; |
|||
|
|||
import cn.hutool.core.bean.BeanUtil; |
|||
import com.yxt.common.base.service.MybatisBaseService; |
|||
import com.yxt.common.core.result.ResultBean; |
|||
import com.yxt.supervise.report.api.csmcashreportcashedtoday.CsmCashReportCashedTodayDto; |
|||
import com.yxt.supervise.report.api.csmcashreportsalesyesterday.CsmCashReportSalesYesterday; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/6/21 10:57 |
|||
*/ |
|||
public class CsmCashReportSalesYesterdayService extends MybatisBaseService<CsmCashReportSalesYesterdayMapper, CsmCashReportSalesYesterday> { |
|||
public ResultBean save(CsmCashReportCashedTodayDto dto) { |
|||
ResultBean rb=new ResultBean(); |
|||
CsmCashReportSalesYesterday entity=new CsmCashReportSalesYesterday(); |
|||
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|||
baseMapper.insert(entity); |
|||
return rb.success().setMsg("保存成功"); |
|||
|
|||
} |
|||
} |
@ -0,0 +1,80 @@ |
|||
package com.yxt.supervise.report.biz.util; |
|||
|
|||
import java.util.Random; |
|||
|
|||
public class CharUtil { |
|||
|
|||
/** |
|||
* 获取随机字符串 |
|||
* |
|||
* @param num |
|||
* @return |
|||
*/ |
|||
public static String getRandomString(Integer num) { |
|||
String base = "abcdefghijklmnopqrstuvwxyz0123456789"; |
|||
Random random = new Random(); |
|||
StringBuffer sb = new StringBuffer(); |
|||
for (int i = 0; i < num; i++) { |
|||
int number = random.nextInt(base.length()); |
|||
sb.append(base.charAt(number)); |
|||
} |
|||
return sb.toString(); |
|||
} |
|||
|
|||
/** |
|||
* 获取随机字符串 |
|||
* |
|||
* @param num |
|||
* @return |
|||
*/ |
|||
public static String getRandomNum(Integer num) { |
|||
String base = "0123456789"; |
|||
Random random = new Random(); |
|||
StringBuffer sb = new StringBuffer(); |
|||
for (int i = 0; i < num; i++) { |
|||
int number = random.nextInt(base.length()); |
|||
sb.append(base.charAt(number)); |
|||
} |
|||
return sb.toString(); |
|||
} |
|||
|
|||
/** |
|||
* 右补位,左对齐 |
|||
* |
|||
* @param oriStr 原字符串 |
|||
* @param len 目标字符串长度 |
|||
* @param fillChar 补位字符 |
|||
* @return 目标字符串 |
|||
*/ |
|||
public static String padRight(String oriStr, int len, char fillChar) { |
|||
String str = ""; |
|||
int strlen = oriStr.length(); |
|||
if (strlen < len) { |
|||
for (int i = 0; i < len - strlen; i++) { |
|||
str = str + fillChar; |
|||
} |
|||
} |
|||
str = str + oriStr; |
|||
return str; |
|||
} |
|||
|
|||
/** |
|||
* 左补位,右对齐 |
|||
* |
|||
* @param oriStr 原字符串 |
|||
* @param len 目标字符串长度 |
|||
* @param fillChar 补位字符 |
|||
* @return 目标字符串 |
|||
*/ |
|||
public static String padLeft(String oriStr, int len, char fillChar) { |
|||
int strlen = oriStr.length(); |
|||
String str = ""; |
|||
if (strlen < len) { |
|||
for (int i = 0; i < len - strlen; i++) { |
|||
str = str + fillChar; |
|||
} |
|||
} |
|||
str = oriStr + str; |
|||
return str; |
|||
} |
|||
} |
@ -0,0 +1,171 @@ |
|||
package com.yxt.supervise.report.biz.util; |
|||
|
|||
import redis.clients.jedis.Jedis; |
|||
|
|||
import java.util.Arrays; |
|||
import java.util.UUID; |
|||
|
|||
/** |
|||
* Redis distributed lock implementation. |
|||
* |
|||
* @author Alois Belaska <alois.belaska@gmail.com> |
|||
*/ |
|||
public class JedisLock { |
|||
|
|||
/** |
|||
* Lua script which allows for an atomic delete on the lock only |
|||
* if it is owned by the lock. This prevents locks stealing from others. |
|||
*/ |
|||
private final static String DELETE_IF_OWNED = |
|||
"if redis.call('get', KEYS[1]) == ARGV[1] then " + |
|||
"return redis.call('del', KEYS[1]) " + |
|||
"else " + |
|||
"return 0 " + |
|||
"end"; |
|||
|
|||
private Jedis jedis; |
|||
|
|||
/** |
|||
* Lock key path. |
|||
*/ |
|||
private String lockKey; |
|||
private String token; |
|||
|
|||
/** |
|||
* Lock expiration in milliseconds. |
|||
*/ |
|||
private int expireMsecs = 60 * 1000; |
|||
|
|||
/** |
|||
* Acquire timeout in milliseconds. |
|||
*/ |
|||
private int timeoutMsecs = 10 * 1000; |
|||
|
|||
private boolean locked = false; |
|||
|
|||
/** |
|||
* Detailed constructor with default acquire timeout 10000 msecs and lock expiration of 60000 msecs. |
|||
* |
|||
* @param jedis |
|||
* @param lockKey lock key (ex. account:1, ...) |
|||
*/ |
|||
public JedisLock(Jedis jedis, String lockKey) { |
|||
this.jedis = jedis; |
|||
this.lockKey = lockKey; |
|||
this.token = UUID.randomUUID().toString(); |
|||
} |
|||
|
|||
/** |
|||
* Detailed constructor with default lock expiration of 60000 msecs. |
|||
* |
|||
* @param jedis |
|||
* @param lockKey lock key (ex. account:1, ...) |
|||
* @param timeoutMsecs acquire timeout in milliseconds (default: 10000 msecs) |
|||
*/ |
|||
public JedisLock(Jedis jedis, String lockKey, int timeoutMsecs) { |
|||
this(jedis, lockKey); |
|||
this.timeoutMsecs = timeoutMsecs; |
|||
} |
|||
|
|||
/** |
|||
* Detailed constructor. |
|||
* |
|||
* @param jedis |
|||
* @param lockKey lock key (ex. account:1, ...) |
|||
* @param timeoutMsecs acquire timeout in milliseconds (default: 10000 msecs) |
|||
* @param expireMsecs lock expiration in milliseconds (default: 60000 msecs) |
|||
*/ |
|||
public JedisLock(Jedis jedis, String lockKey, int timeoutMsecs, int expireMsecs) { |
|||
this(jedis, lockKey, timeoutMsecs); |
|||
this.expireMsecs = expireMsecs; |
|||
} |
|||
|
|||
/** |
|||
* Detailed constructor with default acquire timeout 10000 msecs and lock expiration of 60000 msecs. |
|||
* |
|||
* @param lockKey lock key (ex. account:1, ...) |
|||
*/ |
|||
public JedisLock(String lockKey) { |
|||
this(null, lockKey); |
|||
} |
|||
|
|||
/** |
|||
* Detailed constructor with default lock expiration of 60000 msecs. |
|||
* |
|||
* @param lockKey lock key (ex. account:1, ...) |
|||
* @param timeoutMsecs acquire timeout in miliseconds (default: 10000 msecs) |
|||
*/ |
|||
public JedisLock(String lockKey, int timeoutMsecs) { |
|||
this(null, lockKey, timeoutMsecs); |
|||
} |
|||
|
|||
/** |
|||
* Detailed constructor. |
|||
* |
|||
* @param lockKey lock key (ex. account:1, ...) |
|||
* @param timeoutMsecs acquire timeout in miliseconds (default: 10000 msecs) |
|||
* @param expireMsecs lock expiration in miliseconds (default: 60000 msecs) |
|||
*/ |
|||
public JedisLock(String lockKey, int timeoutMsecs, int expireMsecs) { |
|||
this(null, lockKey, timeoutMsecs, expireMsecs); |
|||
} |
|||
|
|||
/** |
|||
* @return lock key |
|||
*/ |
|||
public String getLockKey() { |
|||
return lockKey; |
|||
} |
|||
|
|||
/** |
|||
* Acquire lock. |
|||
* |
|||
* @return true if lock is acquired, false acquire timeouted |
|||
* @throws InterruptedException in case of thread interruption |
|||
*/ |
|||
public synchronized boolean acquire() throws InterruptedException { |
|||
return acquire(jedis); |
|||
} |
|||
|
|||
/** |
|||
* Acquire lock. |
|||
* |
|||
* @param jedis |
|||
* @return true if lock is acquired, false acquire timed out |
|||
* @throws InterruptedException in case of thread interruption |
|||
*/ |
|||
public synchronized boolean acquire(Jedis jedis) throws InterruptedException { |
|||
int timeout = timeoutMsecs; |
|||
while (timeout >= 0) { |
|||
|
|||
if ("OK".equals(jedis.set(lockKey, token))) { |
|||
// lock acquired
|
|||
locked = true; |
|||
return true; |
|||
} |
|||
|
|||
timeout -= 100; |
|||
Thread.sleep(100); |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
/** |
|||
* Acquired lock release. |
|||
*/ |
|||
public synchronized void release() { |
|||
release(jedis); |
|||
} |
|||
|
|||
/** |
|||
* Acquired lock release. |
|||
*/ |
|||
public synchronized void release(Jedis jedis) { |
|||
if (locked) { |
|||
// prevent threads from releasing locks which they don't own
|
|||
jedis.eval(DELETE_IF_OWNED, Arrays.asList(lockKey), Arrays.asList(token)); |
|||
locked = false; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,418 @@ |
|||
package com.yxt.supervise.report.biz.util; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonFilter; |
|||
import com.fasterxml.jackson.core.JsonParseException; |
|||
import com.fasterxml.jackson.core.JsonProcessingException; |
|||
import com.fasterxml.jackson.core.type.TypeReference; |
|||
import com.fasterxml.jackson.databind.*; |
|||
import com.fasterxml.jackson.databind.ser.FilterProvider; |
|||
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; |
|||
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; |
|||
import com.google.common.collect.Lists; |
|||
import com.google.common.collect.Maps; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import net.sf.json.JsonConfig; |
|||
import net.sf.json.util.PropertyFilter; |
|||
import org.springframework.core.annotation.AnnotationUtils; |
|||
import org.springframework.util.StringUtils; |
|||
|
|||
import java.io.IOException; |
|||
import java.io.OutputStream; |
|||
import java.text.SimpleDateFormat; |
|||
import java.util.*; |
|||
|
|||
/** |
|||
* json对象映射工具类之jackson封装 |
|||
*/ |
|||
@Slf4j |
|||
public class JsonUtils { |
|||
|
|||
private static ObjectMapper objectMapper = null; |
|||
|
|||
static { |
|||
objectMapper = new ObjectMapper(); |
|||
// 设置默认日期格式
|
|||
objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); |
|||
// 提供其它默认设置
|
|||
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); |
|||
objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); |
|||
objectMapper.setFilters(new SimpleFilterProvider() |
|||
.setFailOnUnknownId(false)); |
|||
objectMapper.registerModule(new MyModule()); |
|||
} |
|||
|
|||
/** |
|||
* 将对象转换成json字符串格式(默认将转换所有的属性) |
|||
* |
|||
* @param value |
|||
* @return |
|||
*/ |
|||
public static String toJsonStr(Object value) { |
|||
try { |
|||
return objectMapper.writeValueAsString(value); |
|||
} catch (JsonProcessingException e) { |
|||
log.error("Json转换失败", e); |
|||
throw new RuntimeException(e); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 将对象转换成json字符串格式 |
|||
* |
|||
* @param value 需要转换的对象 |
|||
* @param properties 需要转换的属性 |
|||
*/ |
|||
public static String toJsonStr(Object value, String[] properties) { |
|||
try { |
|||
SimpleBeanPropertyFilter sbp = SimpleBeanPropertyFilter |
|||
.filterOutAllExcept(properties); |
|||
FilterProvider filterProvider = new SimpleFilterProvider() |
|||
.addFilter("propertyFilterMixIn", sbp); |
|||
return objectMapper.writer(filterProvider) |
|||
.writeValueAsString(value); |
|||
} catch (Exception e) { |
|||
log.error("Json转换失败", e); |
|||
throw new RuntimeException(e); |
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 将对象转换成json字符串格式 |
|||
* |
|||
* @param value 需要转换的对象 |
|||
* @param properties2Exclude 需要排除的属性 |
|||
*/ |
|||
public static String toJsonStrWithExcludeProperties(Object value, |
|||
String[] properties2Exclude) { |
|||
try { |
|||
SimpleBeanPropertyFilter sbp = SimpleBeanPropertyFilter |
|||
.serializeAllExcept(properties2Exclude); |
|||
FilterProvider filterProvider = new SimpleFilterProvider() |
|||
.addFilter("propertyFilterMixIn", sbp); |
|||
return objectMapper.writer(filterProvider) |
|||
.writeValueAsString(value); |
|||
} catch (Exception e) { |
|||
log.error("Json转换失败", e); |
|||
throw new RuntimeException(e); |
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 将对象json格式直接写出到流对象中(默认将转换所有的属性) |
|||
* |
|||
* @param out |
|||
* @return |
|||
*/ |
|||
public static void writeJsonStr(OutputStream out, Object value) { |
|||
try { |
|||
objectMapper.writeValue(out, value); |
|||
} catch (Exception e) { |
|||
log.error("Json转换失败", e); |
|||
throw new RuntimeException(e); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 将对象json格式直接写出到流对象中 |
|||
* |
|||
* @param value 需要转换的对象(注意,需要在要转换的对象中定义JsonFilter注解) |
|||
* @param properties 需要转换的属性 |
|||
*/ |
|||
public static void writeJsonStr(OutputStream out, Object value, |
|||
String[] properties) { |
|||
|
|||
try { |
|||
objectMapper.writer( |
|||
new SimpleFilterProvider().addFilter( |
|||
AnnotationUtils |
|||
.getValue( |
|||
AnnotationUtils.findAnnotation( |
|||
value.getClass(), |
|||
JsonFilter.class)) |
|||
.toString(), SimpleBeanPropertyFilter |
|||
.filterOutAllExcept(properties))) |
|||
.writeValue(out, value); |
|||
} catch (Exception e) { |
|||
log.error("Json转换失败", e); |
|||
throw new RuntimeException(e); |
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 将对象转换成json字符串格式 |
|||
* |
|||
* @param value 需要转换的对象 |
|||
* @param properties2Exclude 需要排除的属性(注意,需要在要转换的对象中定义JsonFilter注解) |
|||
*/ |
|||
public static void writeJsonStrWithExcludeProperties(OutputStream out, |
|||
Object value, String[] properties2Exclude) { |
|||
try { |
|||
objectMapper.writer( |
|||
new SimpleFilterProvider().addFilter( |
|||
AnnotationUtils |
|||
.getValue( |
|||
AnnotationUtils.findAnnotation( |
|||
value.getClass(), |
|||
JsonFilter.class)) |
|||
.toString(), SimpleBeanPropertyFilter |
|||
.serializeAllExcept(properties2Exclude))) |
|||
.writeValue(out, value); |
|||
} catch (Exception e) { |
|||
log.error("Json转换失败", e); |
|||
throw new RuntimeException(e); |
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 反序列化POJO或简单Collection如List<String>. |
|||
* <p> |
|||
* 如果JSON字符串为Null或"null"字符串, 返回Null. 如果JSON字符串为"[]", 返回空集合. |
|||
* <p> |
|||
* 如需反序列化复杂Collection如List<MyBean>, 请使用fromJson(String, JavaType) |
|||
*/ |
|||
public static <T> T fromJson(String jsonString, Class<T> clazz) { |
|||
if (StringUtils.isEmpty(jsonString)) { |
|||
return null; |
|||
} |
|||
|
|||
try { |
|||
return objectMapper.readValue(jsonString, clazz); |
|||
} catch (IOException e) { |
|||
log.warn("parse json string error:" + jsonString, e); |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
@SuppressWarnings({"unchecked", "unused"}) |
|||
public static List<Object> readJsonList(String jsondata, Object object) { |
|||
try { |
|||
List<LinkedHashMap<String, Object>> list = objectMapper.readValue( |
|||
jsondata, List.class); |
|||
|
|||
List<Object> objects = Lists.newArrayList(); |
|||
System.out.println(list.size()); |
|||
for (int i = 0; i < list.size(); i++) { |
|||
Map<String, Object> map = list.get(i); |
|||
Set<String> set = map.keySet(); |
|||
for (Iterator<String> it = set.iterator(); it.hasNext(); ) { |
|||
String key = it.next(); |
|||
System.out.println(key + ":" + map.get(key)); |
|||
} |
|||
} |
|||
} catch (JsonParseException e) { |
|||
e.printStackTrace(); |
|||
} catch (JsonMappingException e) { |
|||
e.printStackTrace(); |
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 单独解析某一个json的key值 |
|||
* |
|||
* @param @param jsonText |
|||
* @param @param key |
|||
* @param @return 设定文件 |
|||
* @return JsonNode 返回类型 |
|||
* @throws |
|||
* @Title: getjsonvalue |
|||
* @Description: TODO(这里用一句话描述这个方法的作用) |
|||
*/ |
|||
public static JsonNode getjsonvalue(String jsonText, String key) { |
|||
|
|||
try { |
|||
ObjectMapper mapper = new ObjectMapper(); |
|||
JsonNode rootNode = mapper.readTree(jsonText); // 读取Json
|
|||
|
|||
return rootNode.path(key); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
|
|||
public static JavaType getCollectionType(Class<?> collectionClass, Class<?>... elementClasses) { |
|||
ObjectMapper mapper = new ObjectMapper(); |
|||
return mapper.getTypeFactory().constructParametricType(collectionClass, elementClasses); |
|||
} |
|||
|
|||
public static <T> List<T> json2list(String jsonArrayStr, Class<T> clazz) throws Exception { |
|||
List<Map<String, Object>> list = (List) objectMapper.readValue(jsonArrayStr, new TypeReference<List<T>>() { |
|||
}); |
|||
List<T> result = new ArrayList(); |
|||
Iterator var4 = list.iterator(); |
|||
|
|||
while (var4.hasNext()) { |
|||
Map<String, Object> map = (Map) var4.next(); |
|||
result.add(map2pojo(map, clazz)); |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
|
|||
public static <T> T map2pojo(Map map, Class<T> clazz) { |
|||
return objectMapper.convertValue(map, clazz); |
|||
} |
|||
|
|||
/** |
|||
* 解析json属性,放到实体里面去 |
|||
* |
|||
* @param @param jsondata |
|||
* @param @param collectionClass |
|||
* @param @return 设定文件 |
|||
* @return List<SpecVO> 返回类型 |
|||
* @throws |
|||
* @Title: readJsonList |
|||
* @Description: TODO(这里用一句话描述这个方法的作用) |
|||
*/ |
|||
@SuppressWarnings("unchecked") |
|||
public static List<Object> readJsonList(String jsondata, Class<?> collectionClass) { |
|||
try { |
|||
ObjectMapper mapper = new ObjectMapper(); |
|||
JavaType javaType = getCollectionType(ArrayList.class, collectionClass); |
|||
List<Object> lst = (List<Object>) mapper.readValue(jsondata, javaType); |
|||
|
|||
return lst; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* json 转map |
|||
* |
|||
* @param @param jsondata |
|||
* @param @return 设定文件 |
|||
* @return Map<String, Map < String, Object>> 返回类型 |
|||
* @throws |
|||
* @Title: readJsonMap |
|||
* @Description: TODO(这里用一句话描述这个方法的作用) |
|||
*/ |
|||
@SuppressWarnings("unchecked") |
|||
public static Map<String, Object> readJsonToMap(String jsondata) { |
|||
try { |
|||
Map<String, Object> maps = objectMapper.readValue(jsondata, Map.class); |
|||
//System.out.println(maps);
|
|||
return maps; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
@SuppressWarnings("unchecked") |
|||
public static Map<String, Object> readJsonToMap1(String jsondata) { |
|||
try { |
|||
Map<String, Object> maps = objectMapper.readValue(jsondata, Map.class); |
|||
//System.out.println(maps);
|
|||
return maps; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 设置过滤值为空的属性,使得生成的 json 字符串只包含非空的值 |
|||
* |
|||
* @return |
|||
*/ |
|||
public static JsonConfig getJsonConfig() { |
|||
JsonConfig jsonConfig = new JsonConfig(); |
|||
jsonConfig.registerJsonValueProcessor(java.sql.Timestamp.class, new JsonValueProcessorImpl()); |
|||
jsonConfig.setJsonPropertyFilter(new PropertyFilter() { |
|||
@Override |
|||
public boolean apply(Object source, String name, Object value) { |
|||
return value == null; |
|||
} |
|||
}); |
|||
|
|||
jsonConfig.setIgnoreDefaultExcludes(false); // 设置默认忽略
|
|||
jsonConfig.setExcludes(new String[]{"dbName", "isDel"}); // 此处是亮点,只要将所需忽略字段加到数组中即可,在实际测试中,我发现在所返回数组中,存在大量无用属性,
|
|||
|
|||
return jsonConfig; |
|||
} |
|||
|
|||
/** |
|||
* 将对象转换成json字符串。 |
|||
*/ |
|||
public static String objectToJson(Object data) { |
|||
try { |
|||
String string = objectMapper.writeValueAsString(data); |
|||
return string; |
|||
} catch (JsonProcessingException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
/** |
|||
* 将json结果集转化为对象 |
|||
* |
|||
* @param jsonData json数据 |
|||
* @param beanType 对象中的object类型 |
|||
*/ |
|||
public static <T> T jsonToPojo(String jsonData, Class<T> beanType) { |
|||
try { |
|||
if (ValidatorUtils.notEmpty(jsonData)) { |
|||
T t = objectMapper.readValue(jsonData, beanType); |
|||
return t; |
|||
} |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
/** |
|||
* 将json数据转换成pojo对象list |
|||
*/ |
|||
public static <T> List<T> jsonToList(String jsonData, Class<T> beanType) { |
|||
JavaType javaType = objectMapper.getTypeFactory().constructParametricType(List.class, beanType); |
|||
try { |
|||
List<T> list = objectMapper.readValue(jsonData, javaType); |
|||
return list; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
return null; |
|||
} |
|||
|
|||
public static void main(String[] args) { |
|||
Map<String, Object> userData = Maps.newHashMap(); |
|||
Map<String, Object> nameStruct = Maps.newHashMap(); |
|||
nameStruct.put("firstName", "张三"); |
|||
nameStruct.put("lastName", "你大爷"); |
|||
|
|||
System.out.println(JsonUtils.toJsonStr(nameStruct)); |
|||
userData.put("name", nameStruct); |
|||
userData.put("age", 20); |
|||
List<String> stringList = Lists.newArrayList("A", "B", "C"); |
|||
System.out.println(JsonUtils.toJsonStr(userData)); |
|||
System.out.println(JsonUtils.toJsonStr(stringList)); |
|||
// String[] arr = {"37","38","41","42","43","44","45","1693","1694","1695","1696"};
|
|||
// System.out.println(toJsonStr(arr));
|
|||
|
|||
String ss = "{\"address\": \"address2\",\"name\":\"haha2\"}"; |
|||
|
|||
Map<String, Object> map = readJsonToMap(ss); |
|||
|
|||
if (map != null) { |
|||
System.out.println(map.get("address")); |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,49 @@ |
|||
/** |
|||
* |
|||
*/ |
|||
package com.yxt.supervise.report.biz.util; |
|||
|
|||
|
|||
import net.sf.json.JsonConfig; |
|||
import net.sf.json.processors.JsonValueProcessor; |
|||
|
|||
import java.text.SimpleDateFormat; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* <p>Title: JsonValueProcessorImpl.java</p> |
|||
* <p>Description: net.js.json 特殊值处理</p> |
|||
* <p>Copyright: Copyright (c) 2014-2018</p> |
|||
* <p>Company: leimingtech.com</p> |
|||
* |
|||
* @author linjm |
|||
* @version 1.0 |
|||
* @date 2015年7月17日 |
|||
*/ |
|||
public class JsonValueProcessorImpl implements JsonValueProcessor { |
|||
|
|||
private String format = "yyyy-MM-dd HH:mm:ss"; |
|||
|
|||
@Override |
|||
public Object processArrayValue(Object value, JsonConfig jsonConfig) { |
|||
String[] obj = {}; |
|||
if (value instanceof Date[]) { |
|||
SimpleDateFormat sdf = new SimpleDateFormat(format); |
|||
Date[] date = (Date[]) value; |
|||
for (int i = 0; i < date.length; i++) { |
|||
obj[i] = sdf.format(date[i]); |
|||
} |
|||
} |
|||
return obj; |
|||
} |
|||
|
|||
@Override |
|||
public Object processObjectValue(String key, Object value, JsonConfig jsonConfig) { |
|||
if (value instanceof Date) { |
|||
String str = new SimpleDateFormat(format).format(value); |
|||
return str; |
|||
} |
|||
return value.toString(); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,302 @@ |
|||
package com.yxt.supervise.report.biz.util;//package com.supervise.rms.biz.util;
|
|||
//
|
|||
//
|
|||
//import com.mysql.cj.util.StringUtils;
|
|||
//import org.apache.commons.beanutils.PropertyUtilsBean;
|
|||
//import org.apache.commons.lang.ArrayUtils;
|
|||
//import org.springframework.util.Assert;
|
|||
//
|
|||
//import java.beans.PropertyDescriptor;
|
|||
//import java.math.BigDecimal;
|
|||
//import java.sql.Date;
|
|||
//import java.sql.Timestamp;
|
|||
//import java.util.HashMap;
|
|||
//import java.util.Iterator;
|
|||
//import java.util.Map;
|
|||
//import java.util.Set;
|
|||
//
|
|||
///**
|
|||
// * 获取map中值的工具类,自动进行类型转换
|
|||
// *
|
|||
// * @author DT_panda
|
|||
// */
|
|||
//public class MapUtils {
|
|||
//
|
|||
// public static String getString(String key, Map<String, Object> map) {
|
|||
// if (map == null || key == null)
|
|||
// throw new IllegalArgumentException();
|
|||
// if (!map.containsKey(key))
|
|||
// return null;
|
|||
// Object value = map.get(key);
|
|||
// if (value == null)
|
|||
// return null;
|
|||
// return value.toString();
|
|||
// }
|
|||
//
|
|||
// public static Integer getInteger(String key, Map<String, Object> map) {
|
|||
// if (map == null || key == null)
|
|||
// throw new IllegalArgumentException();
|
|||
// if (!map.containsKey(key))
|
|||
// return null;
|
|||
// Object value = map.get(key);
|
|||
// if (value == null)
|
|||
// return null;
|
|||
// if (value instanceof Integer)
|
|||
// return (Integer) value;
|
|||
// if (value instanceof String)
|
|||
// return Integer.valueOf((String) value);
|
|||
// //Date 不支持变成为date类型
|
|||
// if (value instanceof Date)
|
|||
// throw new ClassCastException();
|
|||
// if (value instanceof Number)
|
|||
// return ((Number) value).intValue();
|
|||
// throw new ClassCastException();
|
|||
// }
|
|||
//
|
|||
// public static Long getLong(String key, Map<String, Object> map) {
|
|||
// if (map == null || key == null)
|
|||
// throw new IllegalArgumentException();
|
|||
// if (!map.containsKey(key))
|
|||
// return null;
|
|||
// Object value = map.get(key);
|
|||
// if (value == null)
|
|||
// return null;
|
|||
// if (value instanceof Long)
|
|||
// return (Long) value;
|
|||
// if (value instanceof Number)
|
|||
// return ((Number) value).longValue();
|
|||
// if (value instanceof String)
|
|||
// return Long.valueOf((String) value);
|
|||
// if (value instanceof Date) {
|
|||
// return (((Date) value).getTime());
|
|||
// }
|
|||
// if (value instanceof java.sql.Time) {
|
|||
// return ((java.sql.Time) value).getTime();
|
|||
// }
|
|||
// if (value instanceof Timestamp) {
|
|||
// return ((Timestamp) value).getTime();
|
|||
// }
|
|||
//
|
|||
// throw new ClassCastException();
|
|||
// }
|
|||
//
|
|||
// public static Double getDouble(String key, Map<String, Object> map) {
|
|||
// if (map == null || key == null)
|
|||
// throw new IllegalArgumentException();
|
|||
// if (!map.containsKey(key))
|
|||
// return null;
|
|||
// Object value = map.get(key);
|
|||
// if (value == null)
|
|||
// return null;
|
|||
// if (value instanceof Double)
|
|||
// return (Double) value;
|
|||
// if (value instanceof Number)
|
|||
// return ((Number) value).doubleValue();
|
|||
// if (value instanceof String)
|
|||
// return Double.valueOf((String) value);
|
|||
// throw new ClassCastException();
|
|||
// }
|
|||
//
|
|||
// public static BigDecimal getBigDecimal(String key, Map<String, Object> map) {
|
|||
// if (map == null || key == null)
|
|||
// throw new IllegalArgumentException();
|
|||
// if (!map.containsKey(key))
|
|||
// return null;
|
|||
// Object value = map.get(key);
|
|||
// if (value == null)
|
|||
// return null;
|
|||
// if (value instanceof BigDecimal)
|
|||
// return (BigDecimal) value;
|
|||
// if (value instanceof Integer)
|
|||
// return new BigDecimal((Integer) value);
|
|||
// if (value instanceof Short)
|
|||
// return new BigDecimal((Short) value);
|
|||
// if (value instanceof Byte)
|
|||
// return new BigDecimal((Byte) value);
|
|||
// if (value instanceof Long)
|
|||
// return new BigDecimal((Long) value);
|
|||
// if (value instanceof Float)
|
|||
// return new BigDecimal((Float) value);
|
|||
// if (value instanceof Double)
|
|||
// return new BigDecimal((Double) value);
|
|||
// if (value instanceof Date) {
|
|||
// return new BigDecimal(((Date) value).getTime());
|
|||
// }
|
|||
// if (value instanceof java.sql.Time) {
|
|||
// return new BigDecimal(((java.sql.Time) value).getTime());
|
|||
// }
|
|||
// if (value instanceof Timestamp) {
|
|||
// return new BigDecimal(((Timestamp) value).getTime());
|
|||
// }
|
|||
// if (value instanceof String) {
|
|||
// if (!StringUtils.isNullOrEmpty((String) value))
|
|||
// return new BigDecimal((String) value);
|
|||
// else
|
|||
// return null;
|
|||
// }
|
|||
// throw new ClassCastException();
|
|||
// }
|
|||
//
|
|||
// /**
|
|||
// * 将bean转化为map
|
|||
// *
|
|||
// * @param bean
|
|||
// * @return
|
|||
// */
|
|||
// public static Map<String, Object> getMap(Object bean) {
|
|||
// return beanToMap(bean);
|
|||
// }
|
|||
//
|
|||
// /**
|
|||
// * 将map中key为likeKey的value前后加上字符'%',用于like查询
|
|||
// *
|
|||
// * @param map
|
|||
// * @param likeKey
|
|||
// */
|
|||
// public static void toLikeValue(Map<String, Object> map, String... likeKey) {
|
|||
// if (ArrayUtils.isEmpty(likeKey))
|
|||
// return;
|
|||
// for (String key : likeKey) {
|
|||
// if (map.containsKey(key))
|
|||
// map.put(key, "%" + map.get(key) + "%");
|
|||
// }
|
|||
// }
|
|||
//
|
|||
// /**
|
|||
// * 获取日期
|
|||
// *
|
|||
// * @param key
|
|||
// * @param map
|
|||
// * @return
|
|||
// */
|
|||
// public static Date getDate(String key, Map<String, Object> map) {
|
|||
// if (map == null || key == null)
|
|||
// throw new IllegalArgumentException();
|
|||
// if (!map.containsKey(key))
|
|||
// return null;
|
|||
// Object value = map.get(key);
|
|||
// if (value == null)
|
|||
// return null;
|
|||
// else {
|
|||
// if (value instanceof Date) {
|
|||
// return (Date) value;
|
|||
// } else if (value instanceof Timestamp) {
|
|||
// return new Date(((Timestamp) value).getTime());
|
|||
// }
|
|||
// }
|
|||
// return null;
|
|||
// }
|
|||
//
|
|||
// /**
|
|||
// * 获取日期
|
|||
// *
|
|||
// * @param key
|
|||
// * @param map
|
|||
// * @return
|
|||
// */
|
|||
// public static java.util.Date getTimestamp(String key, Map<String, Object> map) {
|
|||
// if (map == null || key == null)
|
|||
// throw new IllegalArgumentException();
|
|||
// if (!map.containsKey(key))
|
|||
// return null;
|
|||
// Object value = map.get(key);
|
|||
// if (value == null)
|
|||
// return null;
|
|||
// else {
|
|||
// if (value instanceof Date) {
|
|||
// return (Date) value;
|
|||
// } else if (value instanceof Timestamp) {
|
|||
// Timestamp ts = (Timestamp) value;
|
|||
// return ts;
|
|||
// }
|
|||
// }
|
|||
// return null;
|
|||
// }
|
|||
//
|
|||
// /**
|
|||
// * 如果value不为空 ,则放到map中
|
|||
// *
|
|||
// * @param map
|
|||
// * @param key
|
|||
// * @param value
|
|||
// */
|
|||
// public static void putIfValueNotNull(Map<String, Object> map, String key, Object value) {
|
|||
// Assert.notNull(map);
|
|||
// Assert.hasText(key);
|
|||
// if (value != null)
|
|||
// map.put(key, value);
|
|||
// }
|
|||
//
|
|||
// /**
|
|||
// * 如果value不为空 ,则放到map中
|
|||
// *
|
|||
// * @param map
|
|||
// * @param key
|
|||
// * @param value
|
|||
// */
|
|||
// public static void putIfValueNotEmpty(Map<String, Object> map, String key, String value) {
|
|||
// Assert.notNull(map);
|
|||
// Assert.hasText(key);
|
|||
// if (!StringUtils.isNullOrEmpty(value))
|
|||
// map.put(key, value);
|
|||
// }
|
|||
//
|
|||
// /**
|
|||
// * 将map中指定的key的value值进行处理
|
|||
// *
|
|||
// * @param key
|
|||
// * @param map
|
|||
// * @param helper
|
|||
// */
|
|||
// public static void convertMapValuePattern(String key, Map<String, Object> map, DealMapValueHelper helper) {
|
|||
// Assert.hasText(key);
|
|||
// Assert.notNull(map);
|
|||
// Assert.notNull(helper);
|
|||
// helper.dealValue(key, map);
|
|||
// }
|
|||
//
|
|||
// /**
|
|||
// * 将javabean实体类转为map类型,然后返回一个map类型的值
|
|||
// *
|
|||
// * @return
|
|||
// */
|
|||
// public static Map<String, Object> beanToMap(Object beanObj) {
|
|||
// Map<String, Object> params = new HashMap<String, Object>(0);
|
|||
// try {
|
|||
// PropertyUtilsBean propertyUtilsBean = new PropertyUtilsBean();
|
|||
// PropertyDescriptor[] descriptors = propertyUtilsBean.getPropertyDescriptors(beanObj);
|
|||
// for (int i = 0; i < descriptors.length; i++) {
|
|||
// String name = descriptors[i].getName();
|
|||
// if (!"class".equals(name)) {
|
|||
// params.put(name, propertyUtilsBean.getNestedProperty(beanObj, name));
|
|||
// }
|
|||
// }
|
|||
// } catch (Exception e) {
|
|||
// e.printStackTrace();
|
|||
// }
|
|||
// return params;
|
|||
// }
|
|||
//
|
|||
// public static String convertMap2Xml(Map<Object, Object> paraMap) {
|
|||
// StringBuffer xmlStr = new StringBuffer();
|
|||
// if (paraMap != null) {
|
|||
// xmlStr.append("<xml>");
|
|||
// Set<Object> keySet = paraMap.keySet();
|
|||
// Iterator<Object> keyIte = keySet.iterator();
|
|||
// while (keyIte.hasNext()) {
|
|||
// String key = (String) keyIte.next();
|
|||
// String val = String.valueOf(paraMap.get(key));
|
|||
// xmlStr.append("<");
|
|||
// xmlStr.append(key);
|
|||
// xmlStr.append(">");
|
|||
// xmlStr.append(val);
|
|||
// xmlStr.append("</");
|
|||
// xmlStr.append(key);
|
|||
// xmlStr.append(">");
|
|||
// }
|
|||
// xmlStr.append("</xml>");
|
|||
// }
|
|||
// return xmlStr.toString();
|
|||
// }
|
|||
//}
|
|||
//
|
@ -0,0 +1,10 @@ |
|||
package com.yxt.supervise.report.biz.util; |
|||
|
|||
import com.fasterxml.jackson.databind.module.SimpleModule; |
|||
|
|||
public class MyModule extends SimpleModule { |
|||
@Override |
|||
public void setupModule(SetupContext context) { |
|||
context.setMixInAnnotations(Object.class, PropertyFilterMixIn.class); |
|||
} |
|||
} |
@ -0,0 +1,22 @@ |
|||
package com.yxt.supervise.report.biz.util; |
|||
|
|||
import javax.net.ssl.X509TrustManager; |
|||
import java.security.cert.CertificateException; |
|||
import java.security.cert.X509Certificate; |
|||
|
|||
public class MyX509TrustManager implements X509TrustManager { |
|||
@Override |
|||
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public X509Certificate[] getAcceptedIssuers() { |
|||
return null; |
|||
} |
|||
} |
@ -0,0 +1,8 @@ |
|||
package com.yxt.supervise.report.biz.util; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonFilter; |
|||
|
|||
@JsonFilter("propertyFilterMixIn") |
|||
public class PropertyFilterMixIn { |
|||
|
|||
} |
@ -0,0 +1,200 @@ |
|||
package com.yxt.supervise.report.biz.util; |
|||
|
|||
//import com.zscat.mallplus.vo.timeline.TimeSecound;
|
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.Collection; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.regex.Matcher; |
|||
import java.util.regex.Pattern; |
|||
|
|||
public class ValidatorUtils { |
|||
|
|||
/** |
|||
* 判断内容不为空 |
|||
* |
|||
* @param str |
|||
* @return |
|||
*/ |
|||
public static boolean notEmpty(Object str) { |
|||
if (str != null && str.toString().trim().length() > 0) { |
|||
return true; |
|||
} else { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 判断内容不为空(包含数组) |
|||
* |
|||
* @param str |
|||
* @return |
|||
*/ |
|||
@SuppressWarnings("unchecked") |
|||
public static boolean notEmptyIncludeArray(Object str) { |
|||
if (str != null && String.valueOf(str).trim().length() > 0) { |
|||
if (str instanceof Object[]) {// 增加了数组长度判断
|
|||
Object[] array = (Object[]) str; |
|||
if (array.length > 0) |
|||
return true; |
|||
|
|||
return false; |
|||
} else if (str instanceof List<?>) {// 增加了数组长度判断
|
|||
List<Object> list = (List<Object>) str; |
|||
if (list.size() > 0) |
|||
return true; |
|||
|
|||
return false; |
|||
} |
|||
|
|||
return true; |
|||
} else { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 判断内容是空 |
|||
* |
|||
* @param str |
|||
* @return |
|||
*/ |
|||
public static boolean isEmpty(Object str) { |
|||
if (str == null || str.toString().trim().length() == 0) { |
|||
return true; |
|||
} else { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 检查对象是否为空 |
|||
* |
|||
* @param obj 要检查的数据(数据类型: String、Number、Boolean、Collection、Map、Object[]) |
|||
* @return true: 为空; false: 不为空 <li>String:值为 null、""、"0" 时返回 true <li> |
|||
* Number:值为 null、0 时返回 true <li>Boolean:值为 null、false 时返回 true <li> |
|||
* Collection:值为 null、size=0 时返回 true <li>Map:值为 null、size=0 时返回 |
|||
* true <li>Object[]:值为 null、length=0 时返回 true |
|||
*/ |
|||
@SuppressWarnings("unchecked") |
|||
public static boolean empty(Object obj) { |
|||
if (obj == null) { |
|||
return true; |
|||
} else if (obj instanceof String && (obj.equals(""))) { |
|||
return true; |
|||
} else if (obj instanceof Number && ((Number) obj).doubleValue() == 0) { |
|||
return true; |
|||
} else if (obj instanceof Boolean && !((Boolean) obj)) { |
|||
return true; |
|||
} else if (obj instanceof Collection && ((Collection) obj).isEmpty()) { |
|||
return true; |
|||
} else if (obj instanceof Map && ((Map) obj).isEmpty()) { |
|||
return true; |
|||
} else if (obj instanceof Object[] && ((Object[]) obj).length == 0) { |
|||
return true; |
|||
} |
|||
return false; |
|||
} |
|||
|
|||
/** |
|||
* 判断是否是合法邮箱地址 |
|||
* |
|||
* @param email |
|||
* @return |
|||
*/ |
|||
public static boolean isEmail(String email) { |
|||
Pattern p = Pattern |
|||
.compile("^\\w+([\\-+.]\\w+)*@\\w+([-.]\\w+)*\\.[a-z]{2,3}"); |
|||
Matcher m = p.matcher(email); |
|||
return m.matches(); |
|||
} |
|||
|
|||
/** |
|||
* 只包含英文字母和数字、下划线 |
|||
* |
|||
* @param str |
|||
* @return |
|||
*/ |
|||
public static boolean onlyNumAndChar(String str) { |
|||
String regex = "^[a-zA-Z0-9_]+$"; |
|||
Pattern pattern = Pattern.compile(regex); |
|||
return pattern.matcher(str).matches(); |
|||
} |
|||
|
|||
/** |
|||
* 必须包含字母 |
|||
* |
|||
* @param str |
|||
* @return |
|||
*/ |
|||
public static boolean hasLetterAndNum(String str) { |
|||
Pattern pattern = Pattern.compile("^(?=.*[a-zA-Z].*).{6,}$"); |
|||
return pattern.matcher(str).matches(); |
|||
} |
|||
|
|||
/** |
|||
* 是否长度符合 |
|||
* |
|||
* @param str |
|||
* @param min 最小 |
|||
* @param max 最大 |
|||
* @return |
|||
*/ |
|||
public static boolean lengthBetween(String str, int min, int max) { |
|||
return str.length() >= min && str.length() <= max; |
|||
} |
|||
|
|||
/** |
|||
* 判断字符串是否是数字 |
|||
* |
|||
* @param str |
|||
* @return |
|||
*/ |
|||
public static boolean isNumeric(String str) { |
|||
Pattern pattern = Pattern.compile("[0-9]*"); |
|||
Matcher isNum = pattern.matcher(str); |
|||
if (!isNum.matches()) { |
|||
return false; |
|||
} |
|||
return true; |
|||
} |
|||
|
|||
public static Double rountTwo(Double num) { |
|||
if (num != null) { |
|||
BigDecimal b = new BigDecimal(num); |
|||
Double d = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|||
return d; |
|||
} else { |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
public static String doubleTrans(double d) { |
|||
if (Math.round(d) - d == 0) { |
|||
return String.valueOf((long) d); |
|||
} |
|||
return String.valueOf(d); |
|||
} |
|||
|
|||
/** |
|||
* 获取结束时间与当前的时间差 |
|||
* |
|||
* @param endTime |
|||
* @return |
|||
*/ |
|||
// public static TimeSecound getTimeSecound(Date endTime) {
|
|||
//
|
|||
// long diff = endTime.getTime() - System.currentTimeMillis();// 这样得到的差值是微秒级别
|
|||
//
|
|||
// long days = diff / (1000 * 60 * 60 * 24);//天
|
|||
//
|
|||
// long hours = (diff - days * (1000 * 60 * 60 * 24))
|
|||
// / (1000 * 60 * 60); //小时
|
|||
// long mins = (diff - days * (1000 * 60 * 60 * 24) - hours * (1000 * 60 * 60)) / (1000 * 60); //小时
|
|||
// long sc = (diff - days * (1000 * 60 * 60 * 24) - hours
|
|||
// * (1000 * 60 * 60) - mins * (1000 * 60)) / (1000); // 秒
|
|||
//
|
|||
// return new TimeSecound(days, hours, mins, sc);
|
|||
// }
|
|||
} |
@ -0,0 +1,89 @@ |
|||
package com.yxt.supervise.report.biz.util; |
|||
|
|||
import java.security.MessageDigest; |
|||
import java.security.NoSuchAlgorithmException; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/3/31 15:52 |
|||
*/ |
|||
public class WeixinCheckoutUtil { |
|||
|
|||
|
|||
// 与接口配置信息中的Token要一致
|
|||
private static String token = "yxthryy"; |
|||
|
|||
/** |
|||
* 验证签名 |
|||
* |
|||
* @param signature |
|||
* @param timestamp |
|||
* @param nonce |
|||
* @return |
|||
*/ |
|||
public static boolean checkSignature(String signature, String timestamp, String nonce) { |
|||
String[] arr = new String[] { token, timestamp, nonce }; |
|||
// 将token、timestamp、nonce三个参数进行字典序排序
|
|||
// Arrays.sort(arr);
|
|||
sort(arr); |
|||
StringBuilder content = new StringBuilder(); |
|||
for (int i = 0; i < arr.length; i++) { |
|||
content.append(arr[i]); |
|||
} |
|||
MessageDigest md = null; |
|||
String tmpStr = null; |
|||
|
|||
try { |
|||
md = MessageDigest.getInstance("SHA-1"); |
|||
// 将三个参数字符串拼接成一个字符串进行sha1加密
|
|||
byte[] digest = md.digest(content.toString().getBytes()); |
|||
tmpStr = byteToStr(digest); |
|||
} catch (NoSuchAlgorithmException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
content = null; |
|||
// 将sha1加密后的字符串可与signature对比,标识该请求来源于微信
|
|||
|
|||
return tmpStr != null ? tmpStr.equals(signature.toUpperCase()) : false; |
|||
} |
|||
|
|||
/** |
|||
* 将字节数组转换为十六进制字符串 |
|||
* |
|||
* @param byteArray |
|||
* @return |
|||
*/ |
|||
private static String byteToStr(byte[] byteArray) { |
|||
String strDigest = ""; |
|||
for (int i = 0; i < byteArray.length; i++) { |
|||
strDigest += byteToHexStr(byteArray[i]); |
|||
} |
|||
return strDigest; |
|||
} |
|||
|
|||
/** |
|||
* 将字节转换为十六进制字符串 |
|||
* |
|||
* @param mByte |
|||
* @return |
|||
*/ |
|||
private static String byteToHexStr(byte mByte) { |
|||
char[] Digit = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; |
|||
char[] tempArr = new char[2]; |
|||
tempArr[0] = Digit[(mByte >>> 4) & 0X0F]; |
|||
tempArr[1] = Digit[mByte & 0X0F]; |
|||
String s = new String(tempArr); |
|||
return s; |
|||
} |
|||
public static void sort(String a[]) { |
|||
for (int i = 0; i < a.length - 1; i++) { |
|||
for (int j = i + 1; j < a.length; j++) { |
|||
if (a[j].compareTo(a[i]) < 0) { |
|||
String temp = a[i]; |
|||
a[i] = a[j]; |
|||
a[j] = temp; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,201 @@ |
|||
package com.yxt.supervise.report.biz.util;//package com.supervise.rms.biz.util;
|
|||
//
|
|||
//
|
|||
//import com.mysql.cj.util.StringUtils;
|
|||
//import org.dom4j.Document;
|
|||
//import org.dom4j.DocumentHelper;
|
|||
//import org.dom4j.Element;
|
|||
//
|
|||
//import java.lang.reflect.Field;
|
|||
//import java.util.HashMap;
|
|||
//import java.util.List;
|
|||
//import java.util.Map;
|
|||
//
|
|||
///**
|
|||
// * xml相关的工具类
|
|||
// *
|
|||
// * @author yang.y
|
|||
// */
|
|||
//@SuppressWarnings("unchecked")
|
|||
//public class XmlUtil {
|
|||
//
|
|||
// /**
|
|||
// * xml字符串转换成bean对象
|
|||
// *
|
|||
// * @param xmlStr xml字符串
|
|||
// * @param clazz 待转换的class
|
|||
// * @return 转换后的对象
|
|||
// */
|
|||
// public static Object xmlStrToBean(String xmlStr, Class clazz) {
|
|||
// Object obj = null;
|
|||
// try {
|
|||
// // 将xml格式的数据转换成Map对象
|
|||
// Map<String, Object> map = xmlStrToMap(xmlStr);
|
|||
// // 将map对象的数据转换成Bean对象
|
|||
// obj = mapToBean(map, clazz);
|
|||
// } catch (Exception e) {
|
|||
// e.printStackTrace();
|
|||
// }
|
|||
// return obj;
|
|||
// }
|
|||
//
|
|||
// /**
|
|||
// * 将xml格式的字符串转换成Map对象
|
|||
// *
|
|||
// * @param xmlStr xml格式的字符串
|
|||
// * @return Map对象
|
|||
// * @throws Exception 异常
|
|||
// */
|
|||
// public static Map<String, Object> xmlStrToMap(String xmlStr) throws Exception {
|
|||
// if (StringUtils.isNullOrEmpty(xmlStr)) {
|
|||
// return null;
|
|||
// }
|
|||
// Map<String, Object> map = new HashMap<String, Object>();
|
|||
// // 将xml格式的字符串转换成Document对象
|
|||
// Document doc = DocumentHelper.parseText(xmlStr);
|
|||
// // 获取根节点
|
|||
// Element root = doc.getRootElement();
|
|||
// // 获取根节点下的所有元素
|
|||
// List children = root.elements();
|
|||
// // 循环所有子元素
|
|||
// if (children != null && children.size() > 0) {
|
|||
// for (int i = 0; i < children.size(); i++) {
|
|||
// Element child = (Element) children.get(i);
|
|||
// map.put(child.getName(), child.getTextTrim());
|
|||
// }
|
|||
// }
|
|||
// return map;
|
|||
// }
|
|||
//
|
|||
// /**
|
|||
// * 将xml格式字符串转换成Bean对象
|
|||
// * 多级子节点递归遍历
|
|||
// *
|
|||
// * @param xmlStr
|
|||
// * @param clazz
|
|||
// * @return
|
|||
// * @throws Exception
|
|||
// */
|
|||
// public static Object xmlStrToJavaBean(String xmlStr, Class clazz) {
|
|||
// if (StringUtils.isNullOrEmpty(xmlStr)) {
|
|||
// return null;
|
|||
// }
|
|||
// Object obj = null;
|
|||
// Map<String, Object> map = new HashMap<String, Object>();
|
|||
// // 将xml格式的字符串转换成Document对象
|
|||
// Document doc;
|
|||
// try {
|
|||
// doc = DocumentHelper.parseText(xmlStr);
|
|||
//
|
|||
// // 获取根节点
|
|||
// Element root = doc.getRootElement();
|
|||
// map = elementToMap(root, map);
|
|||
// // 将map对象的数据转换成Bean对象
|
|||
// obj = mapToBean(map, clazz);
|
|||
// } catch (Exception e) {
|
|||
// e.printStackTrace();
|
|||
// }
|
|||
// return obj;
|
|||
// }
|
|||
//
|
|||
// /**
|
|||
// * 递归遍历xml子节点,转换Map
|
|||
// *
|
|||
// * @param element
|
|||
// * @param map
|
|||
// * @return
|
|||
// */
|
|||
// public static Map<String, Object> elementToMap(Element element, Map<String, Object> map) {
|
|||
// if (element == null || map == null)
|
|||
// return null;
|
|||
// List children = element.elements();
|
|||
// if (children != null && children.size() > 0) {
|
|||
// for (int i = 0; i < children.size(); i++) {
|
|||
// Element child = (Element) children.get(i);
|
|||
// if (child.elements() != null && child.elements().size() > 0)
|
|||
// elementToMap(child, map);
|
|||
// else
|
|||
// map.put(child.getName(), child.getTextTrim());
|
|||
// }
|
|||
// }
|
|||
// return map;
|
|||
// }
|
|||
//
|
|||
// /**
|
|||
// * 将Map对象通过反射机制转换成Bean对象
|
|||
// *
|
|||
// * @param map 存放数据的map对象
|
|||
// * @param clazz 待转换的class
|
|||
// * @return 转换后的Bean对象
|
|||
// * @throws Exception 异常
|
|||
// */
|
|||
// public static Object mapToBean(Map<String, Object> map, Class clazz) throws Exception {
|
|||
// Object obj = clazz.newInstance();
|
|||
// if (map != null && map.size() > 0) {
|
|||
// for (Map.Entry<String, Object> entry : map.entrySet()) {
|
|||
// String propertyName = entry.getKey();
|
|||
// Object value = entry.getValue();
|
|||
// String setMethodName = "set" + propertyName.substring(0, 1).toUpperCase() + propertyName.substring(1);
|
|||
// Field field = getClassField(clazz, propertyName);
|
|||
// if (field != null) {
|
|||
// Class fieldTypeClass = field.getType();
|
|||
// value = convertValType(value, fieldTypeClass);
|
|||
// clazz.getMethod(setMethodName, field.getType()).invoke(obj, value);
|
|||
// }
|
|||
// }
|
|||
// }
|
|||
// return obj;
|
|||
// }
|
|||
//
|
|||
// /**
|
|||
// * 将Object类型的值,转换成bean对象属性里对应的类型值
|
|||
// *
|
|||
// * @param value Object对象值
|
|||
// * @param fieldTypeClass 属性的类型
|
|||
// * @return 转换后的值
|
|||
// */
|
|||
// private static Object convertValType(Object value, Class fieldTypeClass) {
|
|||
// Object retVal = null;
|
|||
// if (Long.class.getName().equals(fieldTypeClass.getName())
|
|||
// || long.class.getName().equals(fieldTypeClass.getName())) {
|
|||
// retVal = Long.parseLong(value.toString());
|
|||
// } else if (Integer.class.getName().equals(fieldTypeClass.getName())
|
|||
// || int.class.getName().equals(fieldTypeClass.getName())) {
|
|||
// retVal = Integer.parseInt(value.toString());
|
|||
// } else if (Float.class.getName().equals(fieldTypeClass.getName())
|
|||
// || float.class.getName().equals(fieldTypeClass.getName())) {
|
|||
// retVal = Float.parseFloat(value.toString());
|
|||
// } else if (Double.class.getName().equals(fieldTypeClass.getName())
|
|||
// || double.class.getName().equals(fieldTypeClass.getName())) {
|
|||
// retVal = Double.parseDouble(value.toString());
|
|||
// } else {
|
|||
// retVal = value;
|
|||
// }
|
|||
// return retVal;
|
|||
// }
|
|||
//
|
|||
// /**
|
|||
// * 获取指定字段名称查找在class中的对应的Field对象(包括查找父类)
|
|||
// *
|
|||
// * @param clazz 指定的class
|
|||
// * @param fieldName 字段名称
|
|||
// * @return Field对象
|
|||
// */
|
|||
// private static Field getClassField(Class clazz, String fieldName) {
|
|||
// if (Object.class.getName().equals(clazz.getName())) {
|
|||
// return null;
|
|||
// }
|
|||
// Field[] declaredFields = clazz.getDeclaredFields();
|
|||
// for (Field field : declaredFields) {
|
|||
// if (field.getName().equals(fieldName)) {
|
|||
// return field;
|
|||
// }
|
|||
// }
|
|||
//
|
|||
// Class superClass = clazz.getSuperclass();
|
|||
// if (superClass != null) {// 简单的递归一下
|
|||
// return getClassField(superClass, fieldName);
|
|||
// }
|
|||
// return null;
|
|||
// }
|
|||
//}
|
@ -0,0 +1,29 @@ |
|||
package com.yxt.supervise.report.biz.util.applet; |
|||
|
|||
import java.security.MessageDigest; |
|||
|
|||
public class MD5 { |
|||
private MD5() { |
|||
} |
|||
|
|||
/* * 生成 MD5 |
|||
* |
|||
* @param data 待处理数据 |
|||
* @return MD5结果 |
|||
*/ |
|||
public static String getMessageDigest(String data) { |
|||
StringBuilder sb = new StringBuilder(); |
|||
try { |
|||
MessageDigest md = MessageDigest.getInstance("MD5"); |
|||
byte[] array = md.digest(data.getBytes("UTF-8")); |
|||
|
|||
for (byte item : array) { |
|||
sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3)); |
|||
} |
|||
} catch (Exception e) { |
|||
return null; |
|||
} |
|||
return sb.toString().toUpperCase(); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,47 @@ |
|||
package com.yxt.supervise.report.biz.util.applet; |
|||
|
|||
/** |
|||
* 模板详细信息 |
|||
* 根据需求自己更改 |
|||
*/ |
|||
public class TemplateData { |
|||
private String value; |
|||
private String color; |
|||
|
|||
public TemplateData() { |
|||
} |
|||
|
|||
public TemplateData(String value, String color) { |
|||
this.value = value; |
|||
this.color = color; |
|||
} |
|||
|
|||
/** |
|||
* @return the value |
|||
*/ |
|||
public String getValue() { |
|||
return value; |
|||
} |
|||
|
|||
/** |
|||
* @param value the value to set |
|||
*/ |
|||
public void setValue(String value) { |
|||
this.value = value; |
|||
} |
|||
|
|||
/** |
|||
* @return the color |
|||
*/ |
|||
public String getColor() { |
|||
return color; |
|||
} |
|||
|
|||
/** |
|||
* @param color the color to set |
|||
*/ |
|||
public void setColor(String color) { |
|||
this.color = color; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,80 @@ |
|||
package com.yxt.supervise.report.biz.util.applet; |
|||
|
|||
|
|||
import com.yxt.supervise.customer.biz.util.MyX509TrustManager; |
|||
import net.sf.json.JSONObject; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
|
|||
import javax.net.ssl.HttpsURLConnection; |
|||
import javax.net.ssl.SSLContext; |
|||
import javax.net.ssl.SSLSocketFactory; |
|||
import javax.net.ssl.TrustManager; |
|||
import java.io.BufferedReader; |
|||
import java.io.InputStream; |
|||
import java.io.InputStreamReader; |
|||
import java.io.OutputStream; |
|||
import java.net.ConnectException; |
|||
import java.net.URL; |
|||
|
|||
public class WX_HttpsUtil { |
|||
|
|||
private static Logger log = LoggerFactory.getLogger(WX_HttpsUtil.class); |
|||
|
|||
/** |
|||
* 发送https请求 |
|||
* |
|||
* @param requestUrl 请求地址 |
|||
* @param requestMethod 请求方式(GET、POST) |
|||
* @param outputStr 提交的数据 |
|||
* @return JSONObject(通过JSONObject.get ( key)的方式获取json对象的属性值) |
|||
*/ |
|||
public static JSONObject httpsRequest(String requestUrl, String requestMethod, String outputStr) { |
|||
JSONObject jsonObject = null; |
|||
try { |
|||
// 创建SSLContext对象,并使用我们指定的信任管理器初始化
|
|||
TrustManager[] tm = {new MyX509TrustManager()}; |
|||
SSLContext sslContext = SSLContext.getInstance("SSL", "SunJSSE"); |
|||
sslContext.init(null, tm, new java.security.SecureRandom()); |
|||
// 从上述SSLContext对象中得到SSLSocketFactory对象
|
|||
SSLSocketFactory ssf = sslContext.getSocketFactory(); |
|||
URL url = new URL(requestUrl); |
|||
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection(); |
|||
conn.setSSLSocketFactory(ssf); |
|||
conn.setDoOutput(true); |
|||
conn.setDoInput(true); |
|||
conn.setUseCaches(false); |
|||
// 设置请求方式(GET/POST)
|
|||
conn.setRequestMethod(requestMethod); |
|||
// 当outputStr不为null时向输出流写数据
|
|||
if (null != outputStr) { |
|||
OutputStream outputStream = conn.getOutputStream(); |
|||
// 注意编码格式
|
|||
outputStream.write(outputStr.getBytes("UTF-8")); |
|||
outputStream.close(); |
|||
} |
|||
// 从输入流读取返回内容
|
|||
InputStream inputStream = conn.getInputStream(); |
|||
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "utf-8"); |
|||
BufferedReader bufferedReader = new BufferedReader(inputStreamReader); |
|||
String str = null; |
|||
StringBuffer buffer = new StringBuffer(); |
|||
while ((str = bufferedReader.readLine()) != null) { |
|||
buffer.append(str); |
|||
} |
|||
// 释放资源
|
|||
bufferedReader.close(); |
|||
inputStreamReader.close(); |
|||
inputStream.close(); |
|||
inputStream = null; |
|||
conn.disconnect(); |
|||
jsonObject = JSONObject.fromObject(buffer.toString()); |
|||
} catch (ConnectException ce) { |
|||
log.error("连接超时:{}", ce); |
|||
} catch (Exception e) { |
|||
log.error("https请求异常:{}", e); |
|||
} |
|||
return jsonObject; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,112 @@ |
|||
package com.yxt.supervise.report.biz.util.applet; |
|||
|
|||
|
|||
import net.sf.json.JSONObject; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
|
|||
import java.util.Map; |
|||
|
|||
public class WX_TemplateMsgUtil { |
|||
|
|||
private static Logger log = LoggerFactory.getLogger(WX_TemplateMsgUtil.class); |
|||
|
|||
/** |
|||
* 封装模板详细信息 |
|||
* |
|||
* @return |
|||
*/ |
|||
public static JSONObject packJsonmsg(Map<String, TemplateData> param) { |
|||
JSONObject json = new JSONObject(); |
|||
for (Map.Entry<String, TemplateData> entry : param.entrySet()) { |
|||
JSONObject keyJson = new JSONObject(); |
|||
TemplateData dta = entry.getValue(); |
|||
keyJson.put("value", dta.getValue()); |
|||
keyJson.put("color", dta.getColor()); |
|||
json.put(entry.getKey(), keyJson); |
|||
} |
|||
return json; |
|||
} |
|||
|
|||
/** |
|||
* 根据模板的编号 新增并获取模板ID |
|||
* |
|||
* @param templateSerialNumber 模板库中模板的 "编号" |
|||
* @return 模板ID |
|||
*/ |
|||
public static String getWXTemplateMsgId(String templateSerialNumber, String token) { |
|||
String tmpurl = "https://api.weixin.qq.com/cgi-bin/template/api_add_template?access_token=" + token; |
|||
JSONObject json = new JSONObject(); |
|||
json.put("template_id_short", templateSerialNumber); |
|||
JSONObject resultJson = WX_HttpsUtil.httpsRequest(tmpurl, "POST", json.toString()); |
|||
// JSONObject resultJson = JSONObject.fromObject(result);
|
|||
String errmsg = (String) resultJson.get("errmsg"); |
|||
log.info("获取模板编号返回信息:" + errmsg); |
|||
if (!"ok".equals(errmsg)) { |
|||
return "error"; |
|||
} |
|||
String templateId = (String) resultJson.get("template_id"); |
|||
return templateId; |
|||
} |
|||
|
|||
/** |
|||
* 根据模板ID 删除模板消息 |
|||
* |
|||
* @param templateId 模板ID |
|||
* @return |
|||
*/ |
|||
public static String deleteWXTemplateMsgById(String templateId, String token) { |
|||
String tmpurl = "https://api.weixin.qq.com/cgi-bin/template/del_private_template?access_token=" + token; |
|||
JSONObject json = new JSONObject(); |
|||
json.put("template_id", templateId); |
|||
try { |
|||
JSONObject resultJson = WX_HttpsUtil.httpsRequest(tmpurl, "POST", json.toString()); |
|||
// JSONObject resultJson = new JSONObject(result);
|
|||
log.info("删除" + templateId + "模板消息,返回CODE:" + resultJson.get("errcode")); |
|||
String errmsg = (String) resultJson.get("errmsg"); |
|||
if (!"ok".equals(errmsg)) { |
|||
return "error"; |
|||
} |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return "success"; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 发送微信消息(模板消息) |
|||
* |
|||
* @param touser 用户 OpenID |
|||
* @param templatId 模板消息ID |
|||
* @param page URL置空,则在发送后,点击模板消息会进入一个空白页面(ios),或无法点击(android)。 |
|||
* @param formId |
|||
* @param data 详细内容 |
|||
* @return |
|||
*/ |
|||
public static String sendWechatMsgToUser(String touser, String templatId, String page, String formId, JSONObject data, String token) { |
|||
String tmpurl = "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=" + token; |
|||
|
|||
JSONObject json = new JSONObject(); |
|||
json.put("touser", touser); |
|||
json.put("form_id", formId); |
|||
json.put("page", page); |
|||
json.put("template_id", templatId); |
|||
json.put("data", data); |
|||
try { |
|||
JSONObject resultJson = WX_HttpsUtil.httpsRequest(tmpurl, "POST", json.toString()); |
|||
// JSONObject resultJson = new JSONObject(result);
|
|||
log.info("发送微信消息返回信息:" + resultJson.get("errcode")); |
|||
String errmsg = (String) resultJson.get("errmsg"); |
|||
if (!"ok".equals(errmsg)) { //如果为errmsg为ok,则代表发送成功,公众号推送信息给用户了。
|
|||
return "error"; |
|||
} |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return "error"; |
|||
} |
|||
|
|||
return "success"; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,39 @@ |
|||
package com.yxt.supervise.report.biz.util.applet; |
|||
|
|||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory; |
|||
import org.apache.http.conn.ssl.SSLContexts; |
|||
|
|||
import javax.net.ssl.SSLContext; |
|||
import java.io.InputStream; |
|||
import java.security.KeyStore; |
|||
|
|||
@SuppressWarnings("deprecation") |
|||
public class WechatConfig { |
|||
|
|||
private static SSLConnectionSocketFactory sslcsf; |
|||
|
|||
public static SSLConnectionSocketFactory getSslcsf() { |
|||
if (null == sslcsf) { |
|||
setSsslcsf(); |
|||
} |
|||
return sslcsf; |
|||
} |
|||
|
|||
private static void setSsslcsf() { |
|||
try { |
|||
KeyStore keyStore = KeyStore.getInstance("PKCS12"); |
|||
Thread.currentThread().getContextClassLoader(); |
|||
InputStream instream = new WechatRefundApiResult().getClass().getResourceAsStream("certName"); |
|||
try { |
|||
keyStore.load(instream, "mchId".toCharArray()); |
|||
} finally { |
|||
instream.close(); |
|||
} |
|||
SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keyStore, "mchId".toCharArray()).build(); |
|||
sslcsf = new SSLConnectionSocketFactory(sslcontext, new String[]{"TLSv1"}, null, SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
|
|||
} |
@ -0,0 +1,214 @@ |
|||
package com.yxt.supervise.report.biz.util.applet; |
|||
|
|||
public class WechatRefundApiResult { |
|||
private String return_code; |
|||
private String return_msg; |
|||
|
|||
private String result_code; |
|||
private String err_code; |
|||
private String err_code_des; |
|||
private String appid; |
|||
private String mch_id; |
|||
private String device_info; |
|||
private String nonce_str; |
|||
private String sign; |
|||
private String transaction_id; |
|||
private String out_trade_no; |
|||
private String out_refund_no; |
|||
private String refund_id; |
|||
private String refund_channel; |
|||
private String refund_fee; |
|||
private String settlement_refund_fee; |
|||
private String total_fee; |
|||
private String settlement_total_fee; |
|||
private String fee_type; |
|||
private String cash_fee; |
|||
private String cash_refund_fee; |
|||
private String refund_status; |
|||
|
|||
public String getRefund_status() { |
|||
return refund_status; |
|||
} |
|||
|
|||
public void setRefund_status(String refund_status) { |
|||
this.refund_status = refund_status; |
|||
} |
|||
|
|||
public String getReturn_code() { |
|||
return return_code; |
|||
} |
|||
|
|||
public void setReturn_code(String return_code) { |
|||
this.return_code = return_code; |
|||
} |
|||
|
|||
public String getReturn_msg() { |
|||
return return_msg; |
|||
} |
|||
|
|||
public void setReturn_msg(String return_msg) { |
|||
this.return_msg = return_msg; |
|||
} |
|||
|
|||
public String getResult_code() { |
|||
return result_code; |
|||
} |
|||
|
|||
public void setResult_code(String result_code) { |
|||
this.result_code = result_code; |
|||
} |
|||
|
|||
public String getErr_code() { |
|||
return err_code; |
|||
} |
|||
|
|||
public void setErr_code(String err_code) { |
|||
this.err_code = err_code; |
|||
} |
|||
|
|||
public String getErr_code_des() { |
|||
return err_code_des; |
|||
} |
|||
|
|||
public void setErr_code_des(String err_code_des) { |
|||
this.err_code_des = err_code_des; |
|||
} |
|||
|
|||
public String getAppid() { |
|||
return appid; |
|||
} |
|||
|
|||
public void setAppid(String appid) { |
|||
this.appid = appid; |
|||
} |
|||
|
|||
public String getMch_id() { |
|||
return mch_id; |
|||
} |
|||
|
|||
public void setMch_id(String mch_id) { |
|||
this.mch_id = mch_id; |
|||
} |
|||
|
|||
public String getDevice_info() { |
|||
return device_info; |
|||
} |
|||
|
|||
public void setDevice_info(String device_info) { |
|||
this.device_info = device_info; |
|||
} |
|||
|
|||
public String getNonce_str() { |
|||
return nonce_str; |
|||
} |
|||
|
|||
public void setNonce_str(String nonce_str) { |
|||
this.nonce_str = nonce_str; |
|||
} |
|||
|
|||
public String getSign() { |
|||
return sign; |
|||
} |
|||
|
|||
public void setSign(String sign) { |
|||
this.sign = sign; |
|||
} |
|||
|
|||
public String getTransaction_id() { |
|||
return transaction_id; |
|||
} |
|||
|
|||
public void setTransaction_id(String transaction_id) { |
|||
this.transaction_id = transaction_id; |
|||
} |
|||
|
|||
public String getOut_trade_no() { |
|||
return out_trade_no; |
|||
} |
|||
|
|||
public void setOut_trade_no(String out_trade_no) { |
|||
this.out_trade_no = out_trade_no; |
|||
} |
|||
|
|||
public String getOut_refund_no() { |
|||
return out_refund_no; |
|||
} |
|||
|
|||
public void setOut_refund_no(String out_refund_no) { |
|||
this.out_refund_no = out_refund_no; |
|||
} |
|||
|
|||
public String getRefund_id() { |
|||
return refund_id; |
|||
} |
|||
|
|||
public void setRefund_id(String refund_id) { |
|||
this.refund_id = refund_id; |
|||
} |
|||
|
|||
public String getRefund_channel() { |
|||
return refund_channel; |
|||
} |
|||
|
|||
public void setRefund_channel(String refund_channel) { |
|||
this.refund_channel = refund_channel; |
|||
} |
|||
|
|||
public String getRefund_fee() { |
|||
return refund_fee; |
|||
} |
|||
|
|||
public void setRefund_fee(String refund_fee) { |
|||
this.refund_fee = refund_fee; |
|||
} |
|||
|
|||
public String getSettlement_refund_fee() { |
|||
return settlement_refund_fee; |
|||
} |
|||
|
|||
public void setSettlement_refund_fee(String settlement_refund_fee) { |
|||
this.settlement_refund_fee = settlement_refund_fee; |
|||
} |
|||
|
|||
public String getTotal_fee() { |
|||
return total_fee; |
|||
} |
|||
|
|||
public void setTotal_fee(String total_fee) { |
|||
this.total_fee = total_fee; |
|||
} |
|||
|
|||
public String getSettlement_total_fee() { |
|||
return settlement_total_fee; |
|||
} |
|||
|
|||
public void setSettlement_total_fee(String settlement_total_fee) { |
|||
this.settlement_total_fee = settlement_total_fee; |
|||
} |
|||
|
|||
public String getFee_type() { |
|||
return fee_type; |
|||
} |
|||
|
|||
public void setFee_type(String fee_type) { |
|||
this.fee_type = fee_type; |
|||
} |
|||
|
|||
public String getCash_fee() { |
|||
return cash_fee; |
|||
} |
|||
|
|||
public void setCash_fee(String cash_fee) { |
|||
this.cash_fee = cash_fee; |
|||
} |
|||
|
|||
public String getCash_refund_fee() { |
|||
return cash_refund_fee; |
|||
} |
|||
|
|||
public void setCash_refund_fee(String cash_refund_fee) { |
|||
this.cash_refund_fee = cash_refund_fee; |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,300 @@ |
|||
package com.yxt.supervise.report.biz.util.applet; |
|||
|
|||
//import com.supervise.rms.biz.util.CharUtil;
|
|||
//import com.supervise.rms.biz.util.MapUtils;
|
|||
//import com.supervise.rms.biz.util.XmlUtil;
|
|||
|
|||
import org.apache.http.HttpEntity; |
|||
import org.apache.http.HttpResponse; |
|||
import org.apache.http.client.HttpClient; |
|||
import org.apache.http.client.config.RequestConfig; |
|||
import org.apache.http.client.methods.CloseableHttpResponse; |
|||
import org.apache.http.client.methods.HttpPost; |
|||
import org.apache.http.config.RegistryBuilder; |
|||
import org.apache.http.conn.socket.ConnectionSocketFactory; |
|||
import org.apache.http.conn.socket.PlainConnectionSocketFactory; |
|||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory; |
|||
import org.apache.http.entity.StringEntity; |
|||
import org.apache.http.impl.client.CloseableHttpClient; |
|||
import org.apache.http.impl.client.HttpClientBuilder; |
|||
import org.apache.http.impl.client.HttpClients; |
|||
import org.apache.http.impl.conn.BasicHttpClientConnectionManager; |
|||
import org.apache.http.util.EntityUtils; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
|
|||
import java.io.IOException; |
|||
import java.io.UnsupportedEncodingException; |
|||
import java.net.URLEncoder; |
|||
import java.text.SimpleDateFormat; |
|||
import java.util.Arrays; |
|||
import java.util.Date; |
|||
import java.util.Map; |
|||
import java.util.Set; |
|||
|
|||
/** |
|||
* <p>Title: 微信退款工具类</p> |
|||
* <p>Description: 微信退款工具类,通过充值客户端的不同初始化不同的工具类,得到相应微信退款相关的appid和muchid</p> |
|||
* |
|||
* @author xubo |
|||
* @date 2017年6月6日 下午5:05:03 |
|||
*/ |
|||
public class WechatUtil { |
|||
/** |
|||
* 充值客户端类型--微信公众号 |
|||
*/ |
|||
public static Integer CLIENTTYPE_WX = 2; |
|||
/** |
|||
* 充值客户端类型--app |
|||
*/ |
|||
public static Integer CLIENTTYPE_APP = 1; |
|||
private static Logger logger = LoggerFactory.getLogger(WechatUtil.class); |
|||
|
|||
/** |
|||
* 方法描述:微信退款逻辑 |
|||
* 创建时间:2017年4月12日 上午11:04:25 |
|||
* 作者: xubo |
|||
* |
|||
* @param |
|||
* @return |
|||
*/ |
|||
/* public static WechatRefundApiResult wxRefund(String out_trade_no, Double orderMoney, Double refundMoney) { |
|||
//初始化请求微信服务器的配置信息包括appid密钥等
|
|||
//转换金钱格式
|
|||
BigDecimal bdOrderMoney = new BigDecimal(orderMoney, MathContext.DECIMAL32); |
|||
BigDecimal bdRefundMoney = new BigDecimal(refundMoney, MathContext.DECIMAL32); |
|||
//构建请求参数
|
|||
Map<Object, Object> params = buildRequsetMapParam(out_trade_no, bdOrderMoney, bdRefundMoney); |
|||
String mapToXml = MapUtils.convertMap2Xml(params); |
|||
//请求微信
|
|||
String reponseXml = sendSSLPostToWx(mapToXml, WechatConfig.getSslcsf()); |
|||
WechatRefundApiResult result = (WechatRefundApiResult) XmlUtil.xmlStrToBean(reponseXml, WechatRefundApiResult.class); |
|||
return result; |
|||
}*/ |
|||
|
|||
/** |
|||
* 方法描述:得到请求微信退款请求的参数 |
|||
* 创建时间:2017年6月8日 上午11:27:02 |
|||
* 作者: xubo |
|||
* |
|||
* @param |
|||
* @return |
|||
*/ |
|||
/* private static Map<Object, Object> buildRequsetMapParam(String out_trade_no, BigDecimal bdOrderMoney, BigDecimal bdRefundMoney) { |
|||
Map<Object, Object> params = new HashMap<Object, Object>(); |
|||
//微信分配的公众账号ID(企业号corpid即为此appId)
|
|||
params.put("appid", ResourceUtil.getConfigByName("wx.appId")); |
|||
//微信支付分配的商户号
|
|||
params.put("mch_id", ResourceUtil.getConfigByName("wx.mchId")); |
|||
//随机字符串,不长于32位。推荐随机数生成算法
|
|||
params.put("nonce_str", CharUtil.getRandomString(16)); |
|||
//商户侧传给微信的订单号
|
|||
params.put("out_trade_no", out_trade_no); |
|||
//商户系统内部的退款单号,商户系统内部唯一,同一退款单号多次请求只退一笔
|
|||
params.put("out_refund_no", getBundleId()); |
|||
//订单总金额,单位为分,只能为整数
|
|||
params.put("total_fee", bdOrderMoney.multiply(new BigDecimal(100)).intValue()); |
|||
//退款总金额,订单总金额,单位为分,只能为整数
|
|||
params.put("refund_fee", bdRefundMoney.multiply(new BigDecimal(100)).intValue()); |
|||
//操作员帐号, 默认为商户号
|
|||
params.put("op_user_id", ResourceUtil.getConfigByName("wx.mchId")); |
|||
//签名前必须要参数全部写在前面
|
|||
params.put("sign", arraySign(params, ResourceUtil.getConfigByName("wx.paySignKey"))); |
|||
return params; |
|||
}*/ |
|||
|
|||
/** |
|||
* ResourceUtil.getConfigByName("wx.refundUrl") |
|||
* 请求微信https |
|||
**/ |
|||
public static String sendSSLPostToWx(String mapToXml, SSLConnectionSocketFactory sslcsf, String refundUrl) { |
|||
logger.info("*******退款(WX Request:" + mapToXml); |
|||
HttpPost httPost = new HttpPost(refundUrl); |
|||
httPost.addHeader("Connection", "keep-alive"); |
|||
httPost.addHeader("Accept", "*/*"); |
|||
httPost.addHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); |
|||
httPost.addHeader("Host", "api.mch.weixin.qq.com"); |
|||
httPost.addHeader("X-Requested-With", "XMLHttpRequest"); |
|||
httPost.addHeader("Cache-Control", "max-age=0"); |
|||
httPost.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) "); |
|||
httPost.setEntity(new StringEntity(mapToXml, "UTF-8")); |
|||
CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(sslcsf).build(); |
|||
CloseableHttpResponse response = null; |
|||
try { |
|||
response = httpClient.execute(httPost); |
|||
HttpEntity entity = response.getEntity(); |
|||
String xmlStr = EntityUtils.toString(entity, "UTF-8"); |
|||
logger.info("*******退款(WX Response:" + xmlStr); |
|||
return xmlStr; |
|||
} catch (Exception e) { |
|||
logger.error(e.getMessage(), e); |
|||
return null; |
|||
} finally { |
|||
try { |
|||
if (response != null) { |
|||
response.close(); |
|||
} |
|||
} catch (IOException e) { |
|||
logger.error(e.getMessage(), e); |
|||
} |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 支付交易ID |
|||
*/ |
|||
public static String getBundleId() { |
|||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
|||
String tradeno = dateFormat.format(new Date()); |
|||
String str = "000000" + (int) (Math.random() * 1000000); |
|||
tradeno = tradeno + str.substring(str.length() - 6); |
|||
return tradeno; |
|||
} |
|||
|
|||
/** |
|||
* 方法描述:根据签名加密请求参数 |
|||
* 创建时间:2017年6月8日 上午11:28:52 |
|||
* 作者: xubo |
|||
* |
|||
* @param |
|||
* @return |
|||
*/ |
|||
public static String arraySign(Map<Object, Object> params, String paySignKey) { |
|||
boolean encode = false; |
|||
Set<Object> keysSet = params.keySet(); |
|||
Object[] keys = keysSet.toArray(); |
|||
Arrays.sort(keys); |
|||
StringBuffer temp = new StringBuffer(); |
|||
boolean first = true; |
|||
for (Object key : keys) { |
|||
if (first) { |
|||
first = false; |
|||
} else { |
|||
temp.append("&"); |
|||
} |
|||
temp.append(key).append("="); |
|||
Object value = params.get(key); |
|||
String valueString = ""; |
|||
if (null != value) { |
|||
valueString = value.toString(); |
|||
} |
|||
if (encode) { |
|||
try { |
|||
temp.append(URLEncoder.encode(valueString, "UTF-8")); |
|||
} catch (UnsupportedEncodingException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
} else { |
|||
temp.append(valueString); |
|||
} |
|||
} |
|||
temp.append("&key="); |
|||
temp.append(paySignKey); |
|||
System.out.println(temp.toString()); |
|||
String packageSign = MD5.getMessageDigest(temp.toString()); |
|||
return packageSign; |
|||
} |
|||
|
|||
/** |
|||
* 请求,只请求一次,不做重试 |
|||
* |
|||
* @param url |
|||
* @param data |
|||
* @return |
|||
* @throws Exception |
|||
*/ |
|||
public static String requestOnce(final String url, String data) throws Exception { |
|||
BasicHttpClientConnectionManager connManager; |
|||
connManager = new BasicHttpClientConnectionManager( |
|||
RegistryBuilder.<ConnectionSocketFactory>create() |
|||
.register("http", PlainConnectionSocketFactory.getSocketFactory()) |
|||
.register("https", SSLConnectionSocketFactory.getSocketFactory()) |
|||
.build(), |
|||
null, |
|||
null, |
|||
null |
|||
); |
|||
|
|||
HttpClient httpClient = HttpClientBuilder.create() |
|||
.setConnectionManager(connManager) |
|||
.build(); |
|||
|
|||
HttpPost httpPost = new HttpPost(url); |
|||
|
|||
RequestConfig requestConfig = RequestConfig.custom() |
|||
.setSocketTimeout(5000) |
|||
.setConnectTimeout(5000) |
|||
.setConnectionRequestTimeout(10000).build(); |
|||
|
|||
httpPost.setConfig(requestConfig); |
|||
|
|||
StringEntity postEntity = new StringEntity(data, "UTF-8"); |
|||
httpPost.addHeader("Content-Type", "text/xml"); |
|||
httpPost.addHeader("User-Agent", "wxpay sdk java v1.0 " + "mchId"); |
|||
httpPost.setEntity(postEntity); |
|||
|
|||
HttpResponse httpResponse = httpClient.execute(httpPost); |
|||
HttpEntity httpEntity = httpResponse.getEntity(); |
|||
String reusltObj = EntityUtils.toString(httpEntity, "UTF-8"); |
|||
logger.info("请求结果:" + reusltObj); |
|||
return reusltObj; |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 方法描述:微信查询退款逻辑 |
|||
* 创建时间:2017年4月12日 上午11:04:25 |
|||
* 作者: xubo |
|||
* |
|||
* @param |
|||
* @return |
|||
*/ |
|||
|
|||
|
|||
// public Map<String, Object> wxRefundquery(String out_trade_no, String out_refund_no) {
|
|||
// Map<Object, Object> params = new HashMap<Object, Object>();
|
|||
// //微信分配的公众账号ID(企业号corpid即为此appId)
|
|||
// params.put("appid", "xx");
|
|||
// //微信支付分配的商户号
|
|||
// params.put("mch_id", "xx");
|
|||
// //随机字符串,不长于32位。推荐随机数生成算法
|
|||
// params.put("nonce_str", CharUtil.getRandomString(16));
|
|||
// //商户侧传给微信的订单号
|
|||
// params.put("out_trade_no", out_trade_no);
|
|||
// //签名前必须要参数全部写在前面
|
|||
// //签名
|
|||
// params.put("sign", arraySign(params, "wx.paySignKey"));
|
|||
// String mapToXml = MapUtils.convertMap2Xml(params);
|
|||
// HttpPost httPost = new HttpPost("refundqueryUrl");
|
|||
// httPost.addHeader("Connection", "keep-alive");
|
|||
// httPost.addHeader("Accept", "*/*");
|
|||
// httPost.addHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
|||
// httPost.addHeader("Host", "api.mch.weixin.qq.com");
|
|||
// httPost.addHeader("X-Requested-With", "XMLHttpRequest");
|
|||
// httPost.addHeader("Cache-Control", "max-age=0");
|
|||
// httPost.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) ");
|
|||
// httPost.setEntity(new StringEntity(mapToXml, "UTF-8"));
|
|||
// CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(WechatConfig.getSslcsf()).build();
|
|||
// CloseableHttpResponse response = null;
|
|||
// try {
|
|||
// response = httpClient.execute(httPost);
|
|||
// HttpEntity entity = response.getEntity();
|
|||
// String xmlStr = EntityUtils.toString(entity, "UTF-8");
|
|||
// System.out.println(xmlStr);
|
|||
// Map<String, Object> result = XmlUtil.xmlStrToMap(xmlStr);//.xmlStrToBean(xmlStr, WechatRefundApiResult.class);
|
|||
// return result;
|
|||
// //将信息保存到数据库
|
|||
// } catch (Exception e) {
|
|||
// logger.error(e.getMessage(), e);
|
|||
// return null;
|
|||
// } finally {
|
|||
// try {
|
|||
// if (response != null) {
|
|||
// response.close();
|
|||
// }
|
|||
// } catch (IOException e) {
|
|||
// logger.error(e.getMessage(), e);
|
|||
// }
|
|||
// }
|
|||
// }
|
|||
} |
@ -0,0 +1,241 @@ |
|||
package com.yxt.supervise.report.biz.wechat; |
|||
|
|||
|
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 对接微信接口服务 |
|||
* Created by fei on 2017/4/24. |
|||
*/ |
|||
@Service |
|||
public class WechatApiService { |
|||
public final static String access_token_url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET"; |
|||
// 存放:1.token,2:获取token的时间,3.过期时间
|
|||
public final static Map<String, Object> accessTokenMap = new HashMap<String, Object>(); |
|||
private static final String WECHAT_API = "https://api.weixin.qq.com/cgi-bin"; |
|||
private static final String WECHAT_API_TOKEN = WECHAT_API + "/token"; |
|||
private static final String WECHAT_API_TICKET = WECHAT_API + "/ticket/getticket?type=jsapi&access_token="; |
|||
//private final HttpClient httpclient;
|
|||
|
|||
// @Resource
|
|||
// private SysAppletSetMapper appletSetMapper;
|
|||
// private Jedis jedis;
|
|||
// @Resource
|
|||
// private JedisPool jedisPool;
|
|||
public String getAccessToken(String appId,String appsecret) throws Exception { |
|||
// SysAppletSet appletSet = appletSetMapper.selectOne(new QueryWrapper<>());
|
|||
// if (null == appletSet) {
|
|||
// throw new ApiMallPlusException("没有设置支付配置");
|
|||
// }
|
|||
String url="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="+appId+"&secret="+appsecret; |
|||
RestTemplate restTemplate=new RestTemplate(); |
|||
String re= restTemplate.getForObject(url,String.class); |
|||
com.alibaba.fastjson.JSONObject jsonObject= com.alibaba.fastjson.JSONObject.parseObject(re); |
|||
String at=jsonObject.getString("access_token"); |
|||
return at; |
|||
} |
|||
|
|||
// public WechatApiService() {
|
|||
// RequestConfig config = RequestConfig.custom()
|
|||
// .setConnectTimeout(5000)
|
|||
// .setSocketTimeout(20000)
|
|||
// .setConnectionRequestTimeout(3000)
|
|||
// .build();
|
|||
// httpclient = HttpClients.custom().setDefaultRequestConfig(config).build();
|
|||
// }
|
|||
//
|
|||
// /**
|
|||
// * 发起https请求并获取结果
|
|||
// *
|
|||
// * @param requestUrl 请求地址
|
|||
// * @param requestMethod 请求方式(GET、POST)
|
|||
// * @param outputStr 提交的数据
|
|||
// * @return JSONObject(通过JSONObject.get ( key)的方式获取json对象的属性值)
|
|||
// */
|
|||
// public static JSONObject handleRequest(String requestUrl, String requestMethod, String outputStr) {
|
|||
// JSONObject jsonObject = null;
|
|||
//
|
|||
// try {
|
|||
// URL url = new URL(requestUrl);
|
|||
// HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
|
|||
// SSLContext ctx = SSLContext.getInstance("SSL", "SunJSSE");
|
|||
// TrustManager[] tm = {new MyX509TrustManager()};
|
|||
// ctx.init(null, tm, new SecureRandom());
|
|||
// SSLSocketFactory sf = ctx.getSocketFactory();
|
|||
// conn.setSSLSocketFactory(sf);
|
|||
// conn.setDoInput(true);
|
|||
// conn.setDoOutput(true);
|
|||
// conn.setRequestMethod(requestMethod);
|
|||
// conn.setUseCaches(false);
|
|||
//
|
|||
// if ("GET".equalsIgnoreCase(requestMethod)) {
|
|||
// conn.connect();
|
|||
// }
|
|||
//
|
|||
// if (StringUtils.isNotEmpty(outputStr)) {
|
|||
// OutputStream out = conn.getOutputStream();
|
|||
// out.write(outputStr.getBytes("utf-8"));
|
|||
// out.close();
|
|||
// }
|
|||
//
|
|||
// InputStream in = conn.getInputStream();
|
|||
// BufferedReader br = new BufferedReader(new InputStreamReader(in, "utf-8"));
|
|||
// StringBuffer buffer = new StringBuffer();
|
|||
// String line = null;
|
|||
//
|
|||
// while ((line = br.readLine()) != null) {
|
|||
// buffer.append(line);
|
|||
// }
|
|||
//
|
|||
// in.close();
|
|||
// conn.disconnect();
|
|||
//
|
|||
// jsonObject = JSONObject.fromObject(buffer.toString());
|
|||
// } catch (MalformedURLException e) {
|
|||
// e.printStackTrace();
|
|||
// } catch (IOException e) {
|
|||
// e.printStackTrace();
|
|||
// } catch (NoSuchAlgorithmException e) {
|
|||
// e.printStackTrace();
|
|||
// } catch (NoSuchProviderException e) {
|
|||
// e.printStackTrace();
|
|||
// } catch (KeyManagementException e) {
|
|||
// e.printStackTrace();
|
|||
// }
|
|||
// return jsonObject;
|
|||
// }
|
|||
//
|
|||
// /**
|
|||
// * 获取默认公众号的 access_token
|
|||
// *
|
|||
// * @return access_token
|
|||
// * @throws Exception
|
|||
// */
|
|||
//
|
|||
//
|
|||
//
|
|||
//
|
|||
// /**
|
|||
// * 获取 access_token
|
|||
// * https://mp.weixin.qq.com/wiki?action=doc&id=mp1421140183
|
|||
// *
|
|||
// * @return access_token
|
|||
// * @throws Exception
|
|||
// */
|
|||
// public String getAccessToken(String appid, String appSecret) throws Exception {
|
|||
//
|
|||
// String key = "access_token:" + appid;
|
|||
// jedis = jedisPool.getResource();
|
|||
// if (jedis.ttl(key) > 30) {
|
|||
// try {
|
|||
// return jedis.get(key);
|
|||
// } finally {
|
|||
// jedis.close();
|
|||
// }
|
|||
//
|
|||
// }
|
|||
//
|
|||
// //https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET
|
|||
// String lockKey = "lock_" + key;
|
|||
// JedisLock lock = new JedisLock(jedis, lockKey);
|
|||
// boolean acquired = lock.acquire();
|
|||
// if (!acquired) {
|
|||
// jedis.close();
|
|||
// throw new Exception("acquired lock: " + lockKey + " timeout");
|
|||
// }
|
|||
// try {
|
|||
// if (jedis.ttl(key) > 30) {
|
|||
// try {
|
|||
// return jedis.get(key);
|
|||
// } finally {
|
|||
// jedis.close();
|
|||
// }
|
|||
// }
|
|||
//
|
|||
// HttpGet get = new HttpGet(WECHAT_API_TOKEN + "?grant_type=client_credential&appid=" + appid + "&secret=" + appSecret);
|
|||
// HttpResponse response = httpclient.execute(get);
|
|||
// String text = EntityUtils.toString(response.getEntity());
|
|||
// Map<String, Object> resultMap = JsonUtils.readJsonToMap(text);
|
|||
// String accessToken = (String) resultMap.get("access_token");
|
|||
// int expiresIn = (int) resultMap.get("expires_in");
|
|||
//
|
|||
// jedis.set(key, accessToken);
|
|||
// jedis.expire(key, expiresIn);
|
|||
// return accessToken;
|
|||
// } finally {
|
|||
// lock.release();
|
|||
// jedis.close();
|
|||
// }
|
|||
// }
|
|||
//
|
|||
// /**
|
|||
// * 获取默认公众号 jsapi_ticket
|
|||
// *
|
|||
// * @return jsapi_ticket
|
|||
// * @throws Exception
|
|||
// */
|
|||
//
|
|||
// public String getJsTicket() throws Exception {
|
|||
//// SysAppletSet appletSet = appletSetMapper.selectOne(new QueryWrapper<>());
|
|||
//// if (null == appletSet) {
|
|||
//// throw new ApiMallPlusException("没有设置支付配置");
|
|||
//// }
|
|||
//// return getJsTicket(appletSet.getAppid(), appletSet.getAppsecret());
|
|||
// return null;
|
|||
// }
|
|||
//
|
|||
//
|
|||
// /**
|
|||
// * 获取 jsapi_ticket
|
|||
// * https://mp.weixin.qq.com/wiki?action=doc&id=mp1421141115
|
|||
// *
|
|||
// * @param appid
|
|||
// * @param appSecret
|
|||
// * @return ticket
|
|||
// * @throws Exception
|
|||
// */
|
|||
// public String getJsTicket(String appid, String appSecret) throws Exception {
|
|||
// jedis = jedisPool.getResource();
|
|||
// String key = "jsapi_ticket:" + appid;
|
|||
//
|
|||
// if (jedis.ttl(key) > 30) {
|
|||
// try {
|
|||
// return jedis.get(key);
|
|||
// } finally {
|
|||
// jedis.close();
|
|||
// }
|
|||
// }
|
|||
//
|
|||
// String lockKey = "lock_" + key;
|
|||
// JedisLock lock = new JedisLock(jedis, lockKey);
|
|||
// boolean acquired = lock.acquire();
|
|||
// if (!acquired) {
|
|||
// jedis.close();
|
|||
// throw new Exception("acquired lock: " + lockKey + " timeout");
|
|||
// }
|
|||
//
|
|||
// try {
|
|||
// if (jedis.ttl(key) > 30) {
|
|||
// return jedis.get(key);
|
|||
// }
|
|||
//
|
|||
// HttpGet get = new HttpGet(WECHAT_API_TICKET + getAccessToken(appid, appSecret));
|
|||
// HttpResponse response = httpclient.execute(get);
|
|||
// String text = EntityUtils.toString(response.getEntity());
|
|||
// Map<String, Object> resultMap = JsonUtils.readJsonToMap(text);
|
|||
// String ticket = (String) resultMap.get("ticket");
|
|||
// int expiresIn = (int) resultMap.get("expires_in");
|
|||
//
|
|||
// jedis.set(key, ticket);
|
|||
// jedis.expire(key, expiresIn);
|
|||
// return ticket;
|
|||
// } finally {
|
|||
// lock.release();
|
|||
// jedis.close();
|
|||
// }
|
|||
// }
|
|||
} |
@ -0,0 +1,152 @@ |
|||
package com.yxt.supervise.report.biz.wechat; |
|||
|
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.yxt.supervise.report.api.wechat.Template; |
|||
import com.yxt.supervise.report.api.wechat.WeChatTemplateMsg; |
|||
import com.yxt.supervise.report.biz.util.WeixinCheckoutUtil; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/3/31 15:44 |
|||
*/ |
|||
@Api(tags = "测试") |
|||
@RestController |
|||
@RequestMapping("v1/wechat") |
|||
public class WechatRest { |
|||
private static final String WX_URL_ACCESS_TOKEN = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET"; |
|||
private static final String WX_URL_MESSAGE_SEND = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=ACCESS_TOKEN"; |
|||
private static final String APP_ID="wx1d44e0fcd110351a"; |
|||
private static final String APPSECRET="4764e32722a7d98656dea6afd9405701"; |
|||
@Autowired |
|||
WechatService wechatService; |
|||
@Autowired |
|||
private WechatApiService wechatApiService; |
|||
@ApiOperation("token") |
|||
@GetMapping(value = "token") |
|||
public String wechate(String signature,String timestamp,String nonce,String echostr){ |
|||
String token=""; |
|||
if (signature != null && WeixinCheckoutUtil.checkSignature(signature, timestamp, nonce)) { |
|||
token=wechatService.push(); |
|||
} |
|||
|
|||
return token; |
|||
} |
|||
|
|||
@GetMapping(value = "authGet",produces = "text/plain;charset=utf-8") |
|||
public String authGet(@RequestParam(name = "signature", required = false) String signature, |
|||
@RequestParam(name = "timestamp", required = false) String timestamp, |
|||
@RequestParam(name = "nonce", required = false) String nonce, |
|||
@RequestParam(name = "echostr", required = false) String echostr) { |
|||
|
|||
if (StringUtils.isAnyBlank(signature, timestamp, nonce, echostr)) { |
|||
throw new IllegalArgumentException("请求参数非法,请核实!"); |
|||
} |
|||
if (WeixinCheckoutUtil.checkSignature( signature, timestamp, nonce)) { |
|||
return echostr; |
|||
} |
|||
return "非法请求"; |
|||
} |
|||
@PostMapping("/sendMessage") |
|||
public void sendMessage(@RequestBody WeChatTemplateMsg data) throws Exception { |
|||
// openId代表一个唯一微信用户,即微信消息的接收人
|
|||
//String openId="otnrM57kui-WCUmRtChhb1HguOgw";
|
|||
//郭
|
|||
String openId="otnrM544hxIgkMOfaDU8VpJhj_6k"; |
|||
//刘
|
|||
//String openId ="otnrM5ySvUo7ZZc4qafWzM9eyKBk";
|
|||
//聂总
|
|||
//otnrM521f8KcCsRfL2Jj4Tk8np1g
|
|||
// 模板参数
|
|||
Map<String, Template> sendMag = new HashMap<String, Template>(); |
|||
// 公众号的模板id(也有相应的接口可以查询到)
|
|||
String templateId = "fVgBuwpLC43YkeGWfl1Vw0mW0Qu5WP2giD77TfKAEc4"; |
|||
//微信的基础accessToken
|
|||
String accessToken=getAccessToken(APP_ID,APPSECRET); |
|||
String wxUrl = WX_URL_MESSAGE_SEND.replace("ACCESS_TOKEN", accessToken); |
|||
sendMag.put("first", new Template("f123")); |
|||
sendMag.put("keyword1", new Template("111")); |
|||
sendMag.put("keyword2", new Template("222")); |
|||
sendMag.put("keyword3", new Template("333")); |
|||
sendMag.put("keyword4", new Template("444")); |
|||
sendMag.put("remark", new Template("123465")); |
|||
Map<String, String> miniprogram = new HashMap<>(); |
|||
miniprogram.put("appid","wx11565021714ba796"); |
|||
miniprogram.put("pagepath","pages/index/index"); |
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
//拼接base参数
|
|||
Map<String, Object> sendBody = new HashMap<>(); |
|||
sendBody.put("miniprogram",miniprogram); |
|||
sendBody.put("touser", openId); // openId
|
|||
sendBody.put("url", ""); // 点击模板信息跳转地址
|
|||
sendBody.put("topcolor", "#FF0000"); // 顶色
|
|||
sendBody.put("data", sendMag); // 模板参数
|
|||
sendBody.put("template_id", templateId);// 模板Id
|
|||
ResponseEntity<String> forEntity = restTemplate.postForEntity(wxUrl, sendBody, String.class); |
|||
JSONObject jsonObject = JSONObject.parseObject(forEntity.getBody()); |
|||
// 0
|
|||
String messageCode = jsonObject.getString("errcode"); |
|||
// 2431260672639467520
|
|||
String msgId = jsonObject.getString("msgid"); |
|||
System.out.println("messageCode : " + messageCode + ", msgId: " +msgId); |
|||
//return forEntity.getBody();
|
|||
} |
|||
public String getAccessToken(String appId,String appsecret) throws Exception { |
|||
String url = WX_URL_ACCESS_TOKEN.replace("APPID", appId).replace("APPSECRET", appsecret); |
|||
RestTemplate restTemplate=new RestTemplate(); |
|||
String re= restTemplate.getForObject(url,String.class); |
|||
JSONObject jsonObject= JSONObject.parseObject(re); |
|||
String at=jsonObject.getString("access_token"); |
|||
return at; |
|||
} |
|||
/** |
|||
* * 发送模板消息 |
|||
* pagepath 用户点击时需要跳转的小程序页面 |
|||
* openid 接收消息的用户openid |
|||
* messageContent 推送消息主体内容 |
|||
*/ |
|||
// public static void sendTemplateMessage(String openid,String pagepath, String messageContent) {
|
|||
// WxMpInMemoryConfigStorage wxStorage = new WxMpInMemoryConfigStorage();
|
|||
// wxStorage.setAppId(tencentSubscriptionAppid);//appid 公众账号的唯一标识
|
|||
// wxStorage.setSecret(tencentSubscriptionAppSecret);//appsecret 公众账号的**
|
|||
// WxMpService wxMpService = new WxMpServiceImpl();
|
|||
// wxMpService.setWxMpConfigStorage(wxStorage);
|
|||
//
|
|||
// WxMpTemplateMessage.MiniProgram miniProgram = new WxMpTemplateMessage.MiniProgram();
|
|||
// miniProgram.setAppid(WxConfig.APP_ID);//小程序appid
|
|||
// miniProgram.setUsePath(true);
|
|||
// miniProgram.setPagePath("/pages/index/index?foo=bar");//用户点击时需要跳转的小程序页面
|
|||
// //2,推送消息
|
|||
// WxMpTemplateMessage templateMessage = WxMpTemplateMessage.builder()
|
|||
// .toUser(openid)//要推送的用户openid
|
|||
// .templateId(templateTemplateID)//消息模版id
|
|||
// //.url("http://mp.weixin.qq.com/download")//点击模版消息要访问的网址
|
|||
// .miniProgram(miniProgram)
|
|||
// .build();
|
|||
// //3,如果是正式版发送模版消息,这里需要配置你的信息
|
|||
// templateMessage.addData(new WxMpTemplateData("first","健康预警信息提示", "#FF00FF"));
|
|||
// templateMessage.addData(new WxMpTemplateData("keyword1","红色预警", "#FF00FF"));
|
|||
// templateMessage.addData(new WxMpTemplateData("keyword2","紧急处理", "#FF00FF"));
|
|||
// templateMessage.addData(new WxMpTemplateData("remark",messageContent, "#FF00FF"));
|
|||
//
|
|||
// //发起推送
|
|||
// try {
|
|||
// String msg = wxMpService.getTemplateMsgService().sendTemplateMsg(templateMessage);
|
|||
// log.info("推送成功:" + msg);
|
|||
// } catch (Exception e) {
|
|||
// log.info("推送失败:" + e.getMessage());
|
|||
// e.printStackTrace();
|
|||
// }
|
|||
//
|
|||
// }
|
|||
|
|||
} |
@ -0,0 +1,60 @@ |
|||
package com.yxt.supervise.report.biz.wechat; |
|||
|
|||
|
|||
import lombok.extern.slf4j.Slf4j; |
|||
import net.sf.json.JSONObject; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/3/31 14:00 |
|||
*/ |
|||
@Service |
|||
@Slf4j |
|||
public class WechatService { |
|||
@Autowired |
|||
private WechatApiService wechatApiService; |
|||
public String push() { |
|||
boolean flag = true; |
|||
// SysAppletSet appletSet = memberService.getSysAppletSet(0);
|
|||
// if (null == appletSet) {
|
|||
// log.error("没有设置支付配置:userId=" + umsMember.getId() + ",orderId=" + order.getId() + ",formId=" + formId);
|
|||
// flag = false;
|
|||
// }
|
|||
// log.info("发送模版消息:userId=" + umsMember.getId() + ",orderId=" + order.getId() + ",formId=" + formId);
|
|||
// if (StringUtils.isEmpty(formId)) {
|
|||
// flag = false;
|
|||
// log.error("发送模版消息:userId=" + umsMember.getId() + ",orderId=" + order.getId() + ",formId=" + formId);
|
|||
// }
|
|||
String accessToken = null; |
|||
if (flag) { |
|||
|
|||
try { |
|||
//accessToken = wechatApiService.getAccessToken();
|
|||
|
|||
// String templateId = appletSet.getTemplateid1();
|
|||
// Map<String, TemplateData> param = new HashMap<String, TemplateData>();
|
|||
// param.put("keyword1", new TemplateData(DateUtils.format(order.getCreateTime(), "yyyy-MM-dd"), "#EE0000"));
|
|||
//
|
|||
// param.put("keyword2", new TemplateData(name, "#EE0000"));
|
|||
// param.put("keyword3", new TemplateData(order.getOrderSn(), "#EE0000"));
|
|||
// param.put("keyword3", new TemplateData(order.getPayAmount() + "", "#EE0000"));
|
|||
//
|
|||
// JSONObject jsonObject = JSONObject.fromObject(param);
|
|||
JSONObject jsonObject = new JSONObject(); |
|||
//调用发送微信消息给用户的接口 ********这里写自己在微信公众平台拿到的模板ID
|
|||
String weiXinOpenId=""; |
|||
String templateId="fVgBuwpLC43YkeGWfl1Vw0mW0Qu5WP2giD77TfKAEc4"; |
|||
String orderId=""; |
|||
// WX_TemplateMsgUtil.sendWechatMsgToUser(weiXinOpenId, templateId, page + "?id=" + orderId,
|
|||
// formId, jsonObject, accessToken);
|
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
} |
|||
return accessToken; |
|||
} |
|||
} |
@ -1,292 +1,292 @@ |
|||
/********************************************************* |
|||
********************************************************* |
|||
******************** ******************* |
|||
************* ************ |
|||
******* _oo0oo_ ******* |
|||
*** o8888888o *** |
|||
* 88" . "88 * |
|||
* (| -_- |) * |
|||
* 0\ = /0 * |
|||
* ___/`---'\___ * |
|||
* .' \\| |// '. *
|
|||
* / \\||| : |||// \ *
|
|||
* / _||||| -:- |||||- \ * |
|||
* | | \\\ - /// | | *
|
|||
* | \_| ''\---/'' |_/ | * |
|||
* \ .-\__ '-' ___/-. / * |
|||
* ___'. .' /--.--\ `. .'___ * |
|||
* ."" '< `.___\_<|>_/___.' >' "". * |
|||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | * |
|||
* \ \ `_. \_ __\ /__ _/ .-` / / * |
|||
* =====`-.____`.___ \_____/___.-`___.-'===== * |
|||
* `=---=' * |
|||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * |
|||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__********* |
|||
*********************************************************/ |
|||
package com.yxt.supervise.system.flow; |
|||
|
|||
import cn.hutool.core.bean.BeanUtil; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.yxt.anrui.flowable.api.processcomment.ProcessCommentFeign; |
|||
import com.yxt.anrui.flowable.api.processcomment.ProcessCommentVo; |
|||
import com.yxt.common.base.utils.StringUtils; |
|||
import com.yxt.common.core.query.PagerQuery; |
|||
import com.yxt.common.core.result.ResultBean; |
|||
import com.yxt.common.core.vo.PagerVo; |
|||
import com.yxt.supervise.system.flow.app.FlowTaskDoQuery; |
|||
import com.yxt.supervise.system.flow.app.FlowTaskDoVo; |
|||
import com.yxt.supervise.system.flow.app.FlowTaskFinishVo; |
|||
import com.yxt.supervise.system.sysstafforg.SysStaffOrgService; |
|||
import com.yxt.supervise.system.sysstafforg.SysStaffOrgVo; |
|||
import com.yxt.supervise.system.sysuser.SysUser; |
|||
import com.yxt.supervise.system.sysuser.SysUserService; |
|||
import io.swagger.annotations.Api; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.text.SimpleDateFormat; |
|||
import java.util.ArrayList; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* Project: anrui-parent <br/> |
|||
* File: FlowableRest.java <br/> |
|||
* Class: com.yxt.anrui.portal.biz.flow.FlowableRest <br/> |
|||
* Description: <描述类的功能>. <br/> |
|||
* Copyright: Copyright (c) 2011 <br/> |
|||
* Company: https://gitee.com/liuzp315 <br/>
|
|||
* Makedate: 2021/10/23 上午11:13 <br/> |
|||
* |
|||
* @author popo |
|||
* @version 1.0 |
|||
* @since 1.0 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("v1/flow") |
|||
@Api(tags = "业务系统中业务和工作流相关操作") |
|||
public class FlowableRest implements FlowableFeign { |
|||
|
|||
@Autowired |
|||
private FlowableService flowableService; |
|||
@Autowired |
|||
private SysStaffOrgService sysStaffOrgService; |
|||
@Autowired |
|||
private SysUserService sysUserService; |
|||
@Autowired |
|||
private ProcessCommentFeign processCommentFeign; |
|||
/* |
|||
|
|||
@Override |
|||
public ResultBean businessStart(String procDefId, String userSid, Map<String, Object> variables) { |
|||
return flowableService.businessStart(procDefId, userSid, variables); |
|||
} |
|||
*/ |
|||
|
|||
@Override |
|||
public ResultBean processPagerList(Integer pageNum, Integer pageSize) { |
|||
return flowableService.processPagerList(pageNum, pageSize); |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean myprocess(String userSid, PagerQuery<FlowTaskQuery> taskQueryPagerQuery) { |
|||
return flowableService.myprocess(userSid, taskQueryPagerQuery); |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean todoTaskList(String userSid, PagerQuery<TaskQuery> pQuery) { |
|||
|
|||
SysUser sysUser = sysUserService.fetchBySid(userSid); |
|||
String staffSid = sysUser.getStaffSid(); |
|||
|
|||
List<SysStaffOrgVo> sysStaffOrgListByStaffSid = sysStaffOrgService.getSysStaffOrgListByStaffSid(staffSid); |
|||
StringBuilder sb = new StringBuilder(); |
|||
for (SysStaffOrgVo s : sysStaffOrgListByStaffSid) { |
|||
sb.append(s.getOrgSidPath()); |
|||
sb.append(","); |
|||
} |
|||
sb.delete(sb.length() - 1, sb.length()); |
|||
pQuery.getParams().setOrgSid(sb.toString()); |
|||
return flowableService.todoTaskList(userSid, pQuery); |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean readXml(String deployId) { |
|||
return flowableService.readXml(deployId); |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean getFlowViewer(String procInsId) { |
|||
return flowableService.getFlowViewer(procInsId); |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean doneTaskList(String userSid, PagerQuery<TaskQuery> pQuery) { |
|||
return flowableService.doneTaskList(userSid, pQuery); |
|||
} |
|||
|
|||
/* @Override |
|||
public ResultBean complete(Map<String, Object> variables) { |
|||
return flowableService.complete(variables); |
|||
}*/ |
|||
|
|||
@Override |
|||
public ResultBean revokeProcess(String userSid, String businessSid, FlowTaskVo flowTaskVo) { |
|||
return flowableService.revokeProcess(userSid, businessSid, flowTaskVo); |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean<FlowRecordVo> flowRecord(String procInsId, String deployId) { |
|||
ResultBean<com.yxt.anrui.flowable.api.flowtask.FlowRecordVo> flowRecordVoResultBean = flowableService.flowRecord(procInsId, deployId); |
|||
com.yxt.anrui.flowable.api.flowtask.FlowRecordVo flowRecordVo = flowRecordVoResultBean.getData(); |
|||
FlowRecordVo flowRecordVo1 = new FlowRecordVo(); |
|||
BeanUtil.copyProperties(flowRecordVo,flowRecordVo1); |
|||
ResultBean<FlowRecordVo> resultBean = new ResultBean<FlowRecordVo>().success(); |
|||
resultBean.setData(flowRecordVo1); |
|||
return resultBean; |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean<List<PCHistTaskListAndCommentList>> flowRecordAndComment(String procInsId, String deployId) { |
|||
ResultBean< com.yxt.anrui.flowable.api.flowtask.FlowRecordVo> flowRecordVoResultBean = flowableService.flowRecord(procInsId, deployId); |
|||
com.yxt.anrui.flowable.api.flowtask.FlowRecordVo flowRecordVo = flowRecordVoResultBean.getData(); |
|||
// private List<com.yxt.anrui.flowable.api.flowtask.FlowTask> flowList = new ArrayList<>();
|
|||
List<PCHistTaskListAndCommentList> flowList = new ArrayList<>(); |
|||
//流转记录
|
|||
List<com.yxt.anrui.flowable.api.flowtask.FlowTask> flowList1 = flowRecordVo.getFlowList(); |
|||
flowList1.forEach(f->{ |
|||
PCHistTaskListAndCommentList a=new PCHistTaskListAndCommentList(); |
|||
a.setTime(f.getFinishTime()==null?new Date():new Date()); |
|||
Map<String, Object> stringObjectMap = BeanUtil.beanToMap(f); |
|||
a.setFlowableRecordVo(stringObjectMap); |
|||
a.setState(0+""); |
|||
flowList.add(a); |
|||
}); |
|||
//评论记录
|
|||
ResultBean<List<ProcessCommentVo>> commentList = getCommentList(procInsId,deployId); |
|||
commentList.getData().forEach(f->{ |
|||
PCHistTaskListAndCommentList a=new PCHistTaskListAndCommentList(); |
|||
Date time = f.getTime(); |
|||
a.setTime(time); |
|||
// f.setTitle(f.getTaskUserInfo().getAssigneeName()+"添加了评论");
|
|||
Map<String, Object> stringObjectMap = BeanUtil.beanToMap(f); |
|||
a.setProcessCommentVo(stringObjectMap); |
|||
a.setState(1+""); |
|||
flowList.add(a); |
|||
}); |
|||
flowList.sort((t1, t2) -> t2.getTime().compareTo(t1.getTime())); |
|||
//flowRecordVo.setFlowList(flowList);
|
|||
ResultBean<List<PCHistTaskListAndCommentList>> resultBean = new ResultBean<List<PCHistTaskListAndCommentList>>().success(); |
|||
resultBean.setData(flowList); |
|||
return resultBean; |
|||
} |
|||
|
|||
public ResultBean<List<ProcessCommentVo>> getCommentList(String procInsId, String deployId) { |
|||
ResultBean<List<ProcessCommentVo>> rb = ResultBean.fireFail(); |
|||
ResultBean<List<com.yxt.anrui.flowable.api.processcomment.ProcessCommentVo>> commentList = processCommentFeign.getCommentList(procInsId); |
|||
List<ProcessCommentVo> list=new ArrayList<>(); |
|||
commentList.getData().forEach(f->{ |
|||
ProcessCommentVo processCommentVo = new ProcessCommentVo(); |
|||
BeanUtil.copyProperties(f,processCommentVo); |
|||
//processCommentVo.setCreateTime(f.getTime());
|
|||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); |
|||
String format = sdf.format(f.getTime()); |
|||
// processCommentVo.setTime(format);
|
|||
list.add(processCommentVo); |
|||
}); |
|||
return rb.success().setData(list); |
|||
} |
|||
@Override |
|||
public ResultBean taskReject(String businessSid, FlowTaskVo flowTaskVo) { |
|||
return flowableService.taskReject(businessSid, flowTaskVo); |
|||
} |
|||
|
|||
/* @Override |
|||
public ResultBean breakProcess(String businessSid, FlowTaskVo flowTaskVo) { |
|||
return flowableService.breakProcess(businessSid, flowTaskVo); |
|||
}*/ |
|||
|
|||
@Override |
|||
public ResultBean stopProcess(FlowTaskVo flowTaskVo) { |
|||
flowableService.stopProcess(flowTaskVo); |
|||
return ResultBean.fireSuccess(); |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean deleteProcess(String procInsId) { |
|||
flowableService.deleteProcess(procInsId); |
|||
return ResultBean.fireSuccess(); |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean<Page<FlowTaskDto>> todoAllTaskList(String userSid, PagerQuery<FlowTaskAllQuery> pQuery) {//待办列表
|
|||
SysUser sysUser = sysUserService.fetchBySid(userSid); |
|||
String staffSid = sysUser.getStaffSid(); |
|||
List<SysStaffOrgVo> sysStaffOrgListByStaffSid = sysStaffOrgService.getSysStaffOrgListByStaffSid(staffSid); |
|||
StringBuilder sb = new StringBuilder(); |
|||
for (SysStaffOrgVo s : sysStaffOrgListByStaffSid) { |
|||
sb.append(s.getOrgSidPath()); |
|||
sb.append(","); |
|||
} |
|||
if (sb.length() > 0) { |
|||
sb.delete(sb.length() - 1, sb.length()); |
|||
} |
|||
pQuery.getParams().setOrgSid(sb.toString()); |
|||
Page<FlowTaskDto> page = new Page<>(); |
|||
|
|||
BeanUtil.copyProperties(flowableService.todoAllTaskList(userSid, pQuery).getData(),page); |
|||
|
|||
ResultBean< Page<FlowTaskDto>> success = new ResultBean< Page<FlowTaskDto>>().success(); |
|||
success.setData(page); |
|||
return success; |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean<Integer> getTodoNum(String userSid) { |
|||
ResultBean<Integer> rb=ResultBean.fireFail(); |
|||
if(StringUtils.isBlank(userSid)){ |
|||
return rb.setMsg("用户sid不能为空"); |
|||
} |
|||
return flowableService.getTodoNum(userSid); |
|||
} |
|||
@Override |
|||
public ResultBean<Integer> getTodoNum(String userSid,String orgPath) { |
|||
ResultBean<Integer> rb=ResultBean.fireFail(); |
|||
if(StringUtils.isBlank(userSid)){ |
|||
return rb.setMsg("用户sid不能为空"); |
|||
} |
|||
if(StringUtils.isBlank(orgPath)){ |
|||
return rb.setMsg("用户orgPath不能为空"); |
|||
} |
|||
return flowableService.getTodoNum(userSid,orgPath); |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean<Page<FlowTaskDto>> doneAllTaskList(String userSid, PagerQuery<FlowTaskAllQuery> pQuery) {//已办列表
|
|||
ResultBean<Page<com.yxt.anrui.flowable.api.flowtask.FlowTaskDto>> pageResultBean = flowableService.doneAllTaskList(userSid, pQuery); |
|||
Page<FlowTaskDto> page = new Page<>(); |
|||
|
|||
BeanUtil.copyProperties(pageResultBean.getData(),page); |
|||
|
|||
ResultBean< Page<FlowTaskDto>> success = new ResultBean< Page<FlowTaskDto>>().success(); |
|||
success.setData(page); |
|||
return success; |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean getNextTasks(String taskId) { |
|||
return flowableService.getNextTasks(taskId); |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean<PagerVo<FlowTaskDoVo>> todoApp(PagerQuery<FlowTaskDoQuery> pagerQuery) { |
|||
return null;//flowableService.todoApp(pagerQuery);
|
|||
} |
|||
|
|||
@Override |
|||
public ResultBean<PagerVo<FlowTaskFinishVo>> finishApp(PagerQuery<FlowTaskDoQuery> pagerQuery) { |
|||
return null;//flowableService.finishApp(pagerQuery);
|
|||
} |
|||
} |
|||
///*********************************************************
|
|||
// *********************************************************
|
|||
// ******************** *******************
|
|||
// ************* ************
|
|||
// ******* _oo0oo_ *******
|
|||
// *** o8888888o ***
|
|||
// * 88" . "88 *
|
|||
// * (| -_- |) *
|
|||
// * 0\ = /0 *
|
|||
// * ___/`---'\___ *
|
|||
// * .' \\| |// '. *
|
|||
// * / \\||| : |||// \ *
|
|||
// * / _||||| -:- |||||- \ *
|
|||
// * | | \\\ - /// | | *
|
|||
// * | \_| ''\---/'' |_/ | *
|
|||
// * \ .-\__ '-' ___/-. / *
|
|||
// * ___'. .' /--.--\ `. .'___ *
|
|||
// * ."" '< `.___\_<|>_/___.' >' "". *
|
|||
// * | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
|||
// * \ \ `_. \_ __\ /__ _/ .-` / / *
|
|||
// * =====`-.____`.___ \_____/___.-`___.-'===== *
|
|||
// * `=---=' *
|
|||
// * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
|||
// *********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
|||
// *********************************************************/
|
|||
//package com.yxt.supervise.system.flow;
|
|||
//
|
|||
//import cn.hutool.core.bean.BeanUtil;
|
|||
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
//import com.yxt.anrui.flowable.api.processcomment.ProcessCommentFeign;
|
|||
//import com.yxt.anrui.flowable.api.processcomment.ProcessCommentVo;
|
|||
//import com.yxt.common.base.utils.StringUtils;
|
|||
//import com.yxt.common.core.query.PagerQuery;
|
|||
//import com.yxt.common.core.result.ResultBean;
|
|||
//import com.yxt.common.core.vo.PagerVo;
|
|||
//import com.yxt.supervise.system.flow.app.FlowTaskDoQuery;
|
|||
//import com.yxt.supervise.system.flow.app.FlowTaskDoVo;
|
|||
//import com.yxt.supervise.system.flow.app.FlowTaskFinishVo;
|
|||
//import com.yxt.supervise.system.sysstafforg.SysStaffOrgService;
|
|||
//import com.yxt.supervise.system.sysstafforg.SysStaffOrgVo;
|
|||
//import com.yxt.supervise.system.sysuser.SysUser;
|
|||
//import com.yxt.supervise.system.sysuser.SysUserService;
|
|||
//import io.swagger.annotations.Api;
|
|||
//import org.springframework.beans.factory.annotation.Autowired;
|
|||
//import org.springframework.web.bind.annotation.RequestMapping;
|
|||
//import org.springframework.web.bind.annotation.RestController;
|
|||
//
|
|||
//import java.text.SimpleDateFormat;
|
|||
//import java.util.ArrayList;
|
|||
//import java.util.Date;
|
|||
//import java.util.List;
|
|||
//import java.util.Map;
|
|||
//
|
|||
///**
|
|||
// * Project: anrui-parent <br/>
|
|||
// * File: FlowableRest.java <br/>
|
|||
// * Class: com.yxt.anrui.portal.biz.flow.FlowableRest <br/>
|
|||
// * Description: <描述类的功能>. <br/>
|
|||
// * Copyright: Copyright (c) 2011 <br/>
|
|||
// * Company: https://gitee.com/liuzp315 <br/>
|
|||
// * Makedate: 2021/10/23 上午11:13 <br/>
|
|||
// *
|
|||
// * @author popo
|
|||
// * @version 1.0
|
|||
// * @since 1.0
|
|||
// */
|
|||
//@RestController
|
|||
//@RequestMapping("v1/flow")
|
|||
//@Api(tags = "业务系统中业务和工作流相关操作")
|
|||
//public class FlowableRest implements FlowableFeign {
|
|||
//
|
|||
// @Autowired
|
|||
// private FlowableService flowableService;
|
|||
// @Autowired
|
|||
// private SysStaffOrgService sysStaffOrgService;
|
|||
// @Autowired
|
|||
// private SysUserService sysUserService;
|
|||
// @Autowired
|
|||
// private ProcessCommentFeign processCommentFeign;
|
|||
///*
|
|||
//
|
|||
// @Override
|
|||
// public ResultBean businessStart(String procDefId, String userSid, Map<String, Object> variables) {
|
|||
// return flowableService.businessStart(procDefId, userSid, variables);
|
|||
// }
|
|||
//*/
|
|||
//
|
|||
// @Override
|
|||
// public ResultBean processPagerList(Integer pageNum, Integer pageSize) {
|
|||
// return flowableService.processPagerList(pageNum, pageSize);
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public ResultBean myprocess(String userSid, PagerQuery<FlowTaskQuery> taskQueryPagerQuery) {
|
|||
// return flowableService.myprocess(userSid, taskQueryPagerQuery);
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public ResultBean todoTaskList(String userSid, PagerQuery<TaskQuery> pQuery) {
|
|||
//
|
|||
// SysUser sysUser = sysUserService.fetchBySid(userSid);
|
|||
// String staffSid = sysUser.getStaffSid();
|
|||
//
|
|||
// List<SysStaffOrgVo> sysStaffOrgListByStaffSid = sysStaffOrgService.getSysStaffOrgListByStaffSid(staffSid);
|
|||
// StringBuilder sb = new StringBuilder();
|
|||
// for (SysStaffOrgVo s : sysStaffOrgListByStaffSid) {
|
|||
// sb.append(s.getOrgSidPath());
|
|||
// sb.append(",");
|
|||
// }
|
|||
// sb.delete(sb.length() - 1, sb.length());
|
|||
// pQuery.getParams().setOrgSid(sb.toString());
|
|||
// return flowableService.todoTaskList(userSid, pQuery);
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public ResultBean readXml(String deployId) {
|
|||
// return flowableService.readXml(deployId);
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public ResultBean getFlowViewer(String procInsId) {
|
|||
// return flowableService.getFlowViewer(procInsId);
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public ResultBean doneTaskList(String userSid, PagerQuery<TaskQuery> pQuery) {
|
|||
// return flowableService.doneTaskList(userSid, pQuery);
|
|||
// }
|
|||
//
|
|||
// /* @Override
|
|||
// public ResultBean complete(Map<String, Object> variables) {
|
|||
// return flowableService.complete(variables);
|
|||
// }*/
|
|||
//
|
|||
// @Override
|
|||
// public ResultBean revokeProcess(String userSid, String businessSid, FlowTaskVo flowTaskVo) {
|
|||
// return flowableService.revokeProcess(userSid, businessSid, flowTaskVo);
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public ResultBean<FlowRecordVo> flowRecord(String procInsId, String deployId) {
|
|||
// ResultBean<com.yxt.anrui.flowable.api.flowtask.FlowRecordVo> flowRecordVoResultBean = flowableService.flowRecord(procInsId, deployId);
|
|||
// com.yxt.anrui.flowable.api.flowtask.FlowRecordVo flowRecordVo = flowRecordVoResultBean.getData();
|
|||
// FlowRecordVo flowRecordVo1 = new FlowRecordVo();
|
|||
// BeanUtil.copyProperties(flowRecordVo,flowRecordVo1);
|
|||
// ResultBean<FlowRecordVo> resultBean = new ResultBean<FlowRecordVo>().success();
|
|||
// resultBean.setData(flowRecordVo1);
|
|||
// return resultBean;
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public ResultBean<List<PCHistTaskListAndCommentList>> flowRecordAndComment(String procInsId, String deployId) {
|
|||
// ResultBean< com.yxt.anrui.flowable.api.flowtask.FlowRecordVo> flowRecordVoResultBean = flowableService.flowRecord(procInsId, deployId);
|
|||
// com.yxt.anrui.flowable.api.flowtask.FlowRecordVo flowRecordVo = flowRecordVoResultBean.getData();
|
|||
// // private List<com.yxt.anrui.flowable.api.flowtask.FlowTask> flowList = new ArrayList<>();
|
|||
// List<PCHistTaskListAndCommentList> flowList = new ArrayList<>();
|
|||
// //流转记录
|
|||
// List<com.yxt.anrui.flowable.api.flowtask.FlowTask> flowList1 = flowRecordVo.getFlowList();
|
|||
// flowList1.forEach(f->{
|
|||
// PCHistTaskListAndCommentList a=new PCHistTaskListAndCommentList();
|
|||
// a.setTime(f.getFinishTime()==null?new Date():new Date());
|
|||
// Map<String, Object> stringObjectMap = BeanUtil.beanToMap(f);
|
|||
// a.setFlowableRecordVo(stringObjectMap);
|
|||
// a.setState(0+"");
|
|||
// flowList.add(a);
|
|||
// });
|
|||
// //评论记录
|
|||
// ResultBean<List<ProcessCommentVo>> commentList = getCommentList(procInsId,deployId);
|
|||
// commentList.getData().forEach(f->{
|
|||
// PCHistTaskListAndCommentList a=new PCHistTaskListAndCommentList();
|
|||
// Date time = f.getTime();
|
|||
// a.setTime(time);
|
|||
// // f.setTitle(f.getTaskUserInfo().getAssigneeName()+"添加了评论");
|
|||
// Map<String, Object> stringObjectMap = BeanUtil.beanToMap(f);
|
|||
// a.setProcessCommentVo(stringObjectMap);
|
|||
// a.setState(1+"");
|
|||
// flowList.add(a);
|
|||
// });
|
|||
// flowList.sort((t1, t2) -> t2.getTime().compareTo(t1.getTime()));
|
|||
// //flowRecordVo.setFlowList(flowList);
|
|||
// ResultBean<List<PCHistTaskListAndCommentList>> resultBean = new ResultBean<List<PCHistTaskListAndCommentList>>().success();
|
|||
// resultBean.setData(flowList);
|
|||
// return resultBean;
|
|||
// }
|
|||
//
|
|||
// public ResultBean<List<ProcessCommentVo>> getCommentList(String procInsId, String deployId) {
|
|||
// ResultBean<List<ProcessCommentVo>> rb = ResultBean.fireFail();
|
|||
// ResultBean<List<com.yxt.anrui.flowable.api.processcomment.ProcessCommentVo>> commentList = processCommentFeign.getCommentList(procInsId);
|
|||
// List<ProcessCommentVo> list=new ArrayList<>();
|
|||
// commentList.getData().forEach(f->{
|
|||
// ProcessCommentVo processCommentVo = new ProcessCommentVo();
|
|||
// BeanUtil.copyProperties(f,processCommentVo);
|
|||
// //processCommentVo.setCreateTime(f.getTime());
|
|||
// SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
|
|||
// String format = sdf.format(f.getTime());
|
|||
// // processCommentVo.setTime(format);
|
|||
// list.add(processCommentVo);
|
|||
// });
|
|||
// return rb.success().setData(list);
|
|||
// }
|
|||
// @Override
|
|||
// public ResultBean taskReject(String businessSid, FlowTaskVo flowTaskVo) {
|
|||
// return flowableService.taskReject(businessSid, flowTaskVo);
|
|||
// }
|
|||
//
|
|||
// /* @Override
|
|||
// public ResultBean breakProcess(String businessSid, FlowTaskVo flowTaskVo) {
|
|||
// return flowableService.breakProcess(businessSid, flowTaskVo);
|
|||
// }*/
|
|||
//
|
|||
// @Override
|
|||
// public ResultBean stopProcess(FlowTaskVo flowTaskVo) {
|
|||
// flowableService.stopProcess(flowTaskVo);
|
|||
// return ResultBean.fireSuccess();
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public ResultBean deleteProcess(String procInsId) {
|
|||
// flowableService.deleteProcess(procInsId);
|
|||
// return ResultBean.fireSuccess();
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public ResultBean<Page<FlowTaskDto>> todoAllTaskList(String userSid, PagerQuery<FlowTaskAllQuery> pQuery) {//待办列表
|
|||
// SysUser sysUser = sysUserService.fetchBySid(userSid);
|
|||
// String staffSid = sysUser.getStaffSid();
|
|||
// List<SysStaffOrgVo> sysStaffOrgListByStaffSid = sysStaffOrgService.getSysStaffOrgListByStaffSid(staffSid);
|
|||
// StringBuilder sb = new StringBuilder();
|
|||
// for (SysStaffOrgVo s : sysStaffOrgListByStaffSid) {
|
|||
// sb.append(s.getOrgSidPath());
|
|||
// sb.append(",");
|
|||
// }
|
|||
// if (sb.length() > 0) {
|
|||
// sb.delete(sb.length() - 1, sb.length());
|
|||
// }
|
|||
// pQuery.getParams().setOrgSid(sb.toString());
|
|||
// Page<FlowTaskDto> page = new Page<>();
|
|||
//
|
|||
// BeanUtil.copyProperties(flowableService.todoAllTaskList(userSid, pQuery).getData(),page);
|
|||
//
|
|||
// ResultBean< Page<FlowTaskDto>> success = new ResultBean< Page<FlowTaskDto>>().success();
|
|||
// success.setData(page);
|
|||
// return success;
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public ResultBean<Integer> getTodoNum(String userSid) {
|
|||
// ResultBean<Integer> rb=ResultBean.fireFail();
|
|||
// if(StringUtils.isBlank(userSid)){
|
|||
// return rb.setMsg("用户sid不能为空");
|
|||
// }
|
|||
// return flowableService.getTodoNum(userSid);
|
|||
// }
|
|||
// @Override
|
|||
// public ResultBean<Integer> getTodoNum(String userSid,String orgPath) {
|
|||
// ResultBean<Integer> rb=ResultBean.fireFail();
|
|||
// if(StringUtils.isBlank(userSid)){
|
|||
// return rb.setMsg("用户sid不能为空");
|
|||
// }
|
|||
// if(StringUtils.isBlank(orgPath)){
|
|||
// return rb.setMsg("用户orgPath不能为空");
|
|||
// }
|
|||
// return flowableService.getTodoNum(userSid,orgPath);
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public ResultBean<Page<FlowTaskDto>> doneAllTaskList(String userSid, PagerQuery<FlowTaskAllQuery> pQuery) {//已办列表
|
|||
// ResultBean<Page<com.yxt.anrui.flowable.api.flowtask.FlowTaskDto>> pageResultBean = flowableService.doneAllTaskList(userSid, pQuery);
|
|||
// Page<FlowTaskDto> page = new Page<>();
|
|||
//
|
|||
// BeanUtil.copyProperties(pageResultBean.getData(),page);
|
|||
//
|
|||
// ResultBean< Page<FlowTaskDto>> success = new ResultBean< Page<FlowTaskDto>>().success();
|
|||
// success.setData(page);
|
|||
// return success;
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public ResultBean getNextTasks(String taskId) {
|
|||
// return flowableService.getNextTasks(taskId);
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public ResultBean<PagerVo<FlowTaskDoVo>> todoApp(PagerQuery<FlowTaskDoQuery> pagerQuery) {
|
|||
// return null;//flowableService.todoApp(pagerQuery);
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public ResultBean<PagerVo<FlowTaskFinishVo>> finishApp(PagerQuery<FlowTaskDoQuery> pagerQuery) {
|
|||
// return null;//flowableService.finishApp(pagerQuery);
|
|||
// }
|
|||
//}
|
|||
|
@ -1,449 +1,449 @@ |
|||
/********************************************************* |
|||
********************************************************* |
|||
******************** ******************* |
|||
************* ************ |
|||
******* _oo0oo_ ******* |
|||
*** o8888888o *** |
|||
* 88" . "88 * |
|||
* (| -_- |) * |
|||
* 0\ = /0 * |
|||
* ___/`---'\___ * |
|||
* .' \\| |// '. *
|
|||
* / \\||| : |||// \ *
|
|||
* / _||||| -:- |||||- \ * |
|||
* | | \\\ - /// | | *
|
|||
* | \_| ''\---/'' |_/ | * |
|||
* \ .-\__ '-' ___/-. / * |
|||
* ___'. .' /--.--\ `. .'___ * |
|||
* ."" '< `.___\_<|>_/___.' >' "". * |
|||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | * |
|||
* \ \ `_. \_ __\ /__ _/ .-` / / * |
|||
* =====`-.____`.___ \_____/___.-`___.-'===== * |
|||
* `=---=' * |
|||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * |
|||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__********* |
|||
*********************************************************/ |
|||
package com.yxt.supervise.system.flow; |
|||
|
|||
import cn.hutool.core.bean.BeanUtil; |
|||
import com.alibaba.fastjson.JSON; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.yxt.anrui.flowable.api.flow.UserAndOrgPath; |
|||
import com.yxt.anrui.flowable.api.flowdefinition.FlowDefinitionFeign; |
|||
import com.yxt.anrui.flowable.api.flowtask.FlowRecordVo; |
|||
import com.yxt.anrui.flowable.api.flowtask.FlowTaskDto; |
|||
import com.yxt.anrui.flowable.api.flowtask.FlowTaskFeign; |
|||
import com.yxt.anrui.flowable.api.flowtask.LatestTaskVo; |
|||
import com.yxt.anrui.flowable.api.sysformlink.SysFormLinkFeign; |
|||
import com.yxt.anrui.flowable.api.sysprourl.SysProUrlFeign; |
|||
import com.yxt.anrui.flowable.sqloperationsymbol.BusinessTaskParam; |
|||
import com.yxt.anrui.flowable.sqloperationsymbol.BusinessTaskQuery; |
|||
import com.yxt.anrui.flowable.sqloperationsymbol.BusinessVariables; |
|||
import com.yxt.anrui.flowable.sqloperationsymbol.SQLOperationSymbol; |
|||
import com.yxt.common.base.config.component.FileUploadComponent; |
|||
import com.yxt.common.base.service.MybatisBaseService; |
|||
import com.yxt.common.base.utils.ConstantUtils; |
|||
import com.yxt.common.base.utils.StringUtils; |
|||
import com.yxt.common.core.query.PagerQuery; |
|||
import com.yxt.common.core.result.ResultBean; |
|||
import com.yxt.common.core.vo.PagerVo; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* Project: anrui-parent <br/> |
|||
* File: FlowableService.java <br/> |
|||
* Class: com.yxt.anrui.portal.biz.flow.FlowableService <br/> |
|||
* Description: <描述类的功能>. <br/> |
|||
* Copyright: Copyright (c) 2011 <br/> |
|||
* Company: https://gitee.com/liuzp315 <br/>
|
|||
* Makedate: 2021/10/23 上午11:14 <br/> |
|||
* |
|||
* @author popo |
|||
* @version 1.0 |
|||
* @since 1.0 |
|||
*/ |
|||
@Service |
|||
public class FlowableService extends MybatisBaseService<FlowableMapper, Flowable> { |
|||
@Autowired |
|||
private FlowDefinitionFeign flowDefinitionFeign; |
|||
@Autowired |
|||
private FlowTaskFeign flowTaskFeign; |
|||
@Autowired |
|||
private SysFormLinkFeign sysFormLinkFeign; |
|||
@Autowired |
|||
private SysProUrlFeign sysProUrlFeign; |
|||
@Autowired |
|||
private FileUploadComponent fileUploadComponent; |
|||
/* |
|||
|
|||
public ResultBean businessStart(@ApiParam(value = "流程定义id") @PathVariable(value = "procDefId") String procDefId, |
|||
@ApiParam(value = "用户sid") @PathVariable(value = "userSid") String userSid, |
|||
@ApiParam(value = "变量集合,json对象") @RequestBody Map<String, Object> variables) { |
|||
|
|||
FlowDefinitionFeignBusinessStartDTO dto = new FlowDefinitionFeignBusinessStartDTO(); |
|||
dto.setProcDefId(procDefId); |
|||
dto.setUserSid(userSid); |
|||
dto.setVariables(variables); |
|||
variables.put("procDefId", procDefId); |
|||
variables.put("userSid", userSid); |
|||
variables.put("businessSid", UUID.randomUUID().toString()); |
|||
BusinessVariables bv = BusinessVariables.builder().build(); |
|||
bv.setFormVariables(variables); |
|||
ResultBean rb = flowDefinitionFeign.businessStart(bv); |
|||
return rb; |
|||
} |
|||
*/ |
|||
|
|||
public ResultBean myprocess(String userSid, PagerQuery<FlowTaskQuery> taskQueryPagerQuery) { |
|||
PagerQuery<BusinessTaskQuery> pq = new PagerQuery<>(); |
|||
String days = taskQueryPagerQuery.getParams().getDays(); |
|||
String zd = taskQueryPagerQuery.getParams().getZd(); |
|||
pq.setCurrent(taskQueryPagerQuery.getCurrent()); |
|||
pq.setSize(taskQueryPagerQuery.getSize()); |
|||
BusinessTaskQuery businessTaskQuery = BusinessTaskQuery.create(); |
|||
if (StringUtils.isNotBlank(zd)) { |
|||
BusinessTaskParam businessTaskParam = new BusinessTaskParam(); |
|||
businessTaskParam.setField("zd"); |
|||
businessTaskParam.setSqlOperationSymbol(SQLOperationSymbol.LIKE); |
|||
businessTaskParam.setValue(zd); |
|||
businessTaskQuery.add(businessTaskParam); |
|||
} |
|||
if (StringUtils.isNotBlank(days)) { |
|||
BusinessTaskParam businessTaskParam = new BusinessTaskParam(); |
|||
businessTaskParam.setField("days"); |
|||
businessTaskParam.setSqlOperationSymbol(SQLOperationSymbol.EQUAL); |
|||
businessTaskParam.setValue(days); |
|||
businessTaskQuery.add(businessTaskParam); |
|||
} |
|||
pq.setParams(businessTaskQuery); |
|||
return flowTaskFeign.businessMyprocess(userSid, pq); |
|||
} |
|||
|
|||
public ResultBean processPagerList(Integer pageNum, Integer pageSize) { |
|||
return flowDefinitionFeign.pagerList(pageNum, pageSize); |
|||
} |
|||
|
|||
public ResultBean todoTaskList(String userSid, PagerQuery<TaskQuery> pQuery) { |
|||
TaskQuery params = pQuery.getParams(); |
|||
if (StringUtils.isBlank(userSid)) { |
|||
return ResultBean.fireFail().setMsg("用户SID为空"); |
|||
} |
|||
PagerQuery<BusinessTaskQuery> taskQueryPagerQuery = new PagerQuery<>(); |
|||
taskQueryPagerQuery.setCurrent(pQuery.getCurrent()).setSize(pQuery.getSize()); |
|||
|
|||
String orgSid = params.getOrgSid(); |
|||
String days = params.getDays(); |
|||
String processDefinitionId = params.getProcessDefinitionId(); |
|||
String startTime = params.getStartTime(); |
|||
BusinessTaskQuery taskQuery = new BusinessTaskQuery(); |
|||
List<BusinessTaskParam> taskParamList = new ArrayList<>(); |
|||
if (StringUtils.isNotBlank(days)) { |
|||
BusinessTaskParam taskParam = new BusinessTaskParam(); |
|||
taskParam.setField("zd1"); |
|||
taskParam.setValue(days); |
|||
taskParam.setSqlOperationSymbol(SQLOperationSymbol.EQUAL); |
|||
taskParamList.add(taskParam); |
|||
} |
|||
if (StringUtils.isNotBlank(startTime)) { |
|||
BusinessTaskParam taskParam = new BusinessTaskParam(); |
|||
taskParam.setField("startTime"); |
|||
taskParam.setValue(startTime); |
|||
taskParam.setSqlOperationSymbol(SQLOperationSymbol.EQUAL); |
|||
taskParamList.add(taskParam); |
|||
} |
|||
if (StringUtils.isNotBlank(processDefinitionId)) { |
|||
BusinessTaskParam taskParam = new BusinessTaskParam(); |
|||
taskParam.setField("processDefinitionId"); |
|||
taskParam.setSqlOperationSymbol(SQLOperationSymbol.NONE); |
|||
taskParam.setValue(processDefinitionId); |
|||
taskParamList.add(taskParam); |
|||
} |
|||
if (StringUtils.isNotBlank(orgSid)) { |
|||
BusinessTaskParam taskParam = new BusinessTaskParam(); |
|||
taskParam.setField(BusinessVariables.ORGPATH); |
|||
taskParam.setSqlOperationSymbol(SQLOperationSymbol.NONE); |
|||
taskParam.setValue(orgSid); |
|||
taskParamList.add(taskParam); |
|||
} |
|||
taskQuery.setFields(taskParamList); |
|||
taskQueryPagerQuery.setParams(taskQuery); |
|||
return flowTaskFeign.businessTodoList(userSid, taskQueryPagerQuery); |
|||
} |
|||
|
|||
public ResultBean doneTaskList(String userSid, PagerQuery<TaskQuery> pQuery) { |
|||
TaskQuery params = pQuery.getParams(); |
|||
if (StringUtils.isBlank(userSid)) { |
|||
return ResultBean.fireFail().setMsg("用户SID为空"); |
|||
} |
|||
PagerQuery<BusinessTaskQuery> taskQueryPagerQuery = new PagerQuery<>(); |
|||
taskQueryPagerQuery.setCurrent(pQuery.getCurrent()).setSize(pQuery.getSize()); |
|||
String zd1 = params.getZd1(); |
|||
String processDefinitionId = params.getProcessDefinitionId(); |
|||
String startTime = params.getStartTime(); |
|||
BusinessTaskQuery taskQuery = new BusinessTaskQuery(); |
|||
List<BusinessTaskParam> taskParamList = new ArrayList<>(); |
|||
if (StringUtils.isNotBlank(zd1)) { |
|||
BusinessTaskParam taskParam = new BusinessTaskParam(); |
|||
taskParam.setField("zd1"); |
|||
taskParam.setValue(zd1); |
|||
taskParam.setSqlOperationSymbol(SQLOperationSymbol.EQUAL); |
|||
taskParamList.add(taskParam); |
|||
} |
|||
if (StringUtils.isNotBlank(startTime)) { |
|||
BusinessTaskParam taskParam = new BusinessTaskParam(); |
|||
taskParam.setField("startTime"); |
|||
taskParam.setValue(startTime); |
|||
taskParam.setSqlOperationSymbol(SQLOperationSymbol.EQUAL); |
|||
taskParamList.add(taskParam); |
|||
} |
|||
if (StringUtils.isNotBlank(processDefinitionId)) { |
|||
BusinessTaskParam taskParam = new BusinessTaskParam(); |
|||
taskParam.setField("processDefinitionId"); |
|||
taskParam.setSqlOperationSymbol(SQLOperationSymbol.NONE); |
|||
taskParam.setValue(processDefinitionId); |
|||
taskParamList.add(taskParam); |
|||
} |
|||
taskQuery.setFields(taskParamList); |
|||
taskQueryPagerQuery.setParams(taskQuery); |
|||
return flowTaskFeign.businessDoneList(userSid, taskQueryPagerQuery); |
|||
} |
|||
|
|||
/** |
|||
* 撤回 |
|||
* |
|||
* @param userSid |
|||
* @param businessSid |
|||
* @param flowTaskVo |
|||
* @return |
|||
*/ |
|||
public ResultBean revokeProcess(String userSid, String businessSid, FlowTaskVo flowTaskVo) { |
|||
com.yxt.anrui.flowable.api.flowtask.FlowTaskVo fl = new com.yxt.anrui.flowable.api.flowtask.FlowTaskVo(); |
|||
BeanUtil.copyProperties(flowTaskVo, fl); |
|||
fl.setUserSid(userSid); |
|||
ResultBean<List<LatestTaskVo>> resultBean = flowTaskFeign.revokeProcess(fl); |
|||
if (!resultBean.getSuccess()) { |
|||
return resultBean; |
|||
} |
|||
String nodeState = resultBean.getData().get(0).getName_(); |
|||
String taskDefKey = resultBean.getData().get(0).getTask_def_key_(); |
|||
String incomingSourceRef = resultBean.getData().get(0).getIncomingSourceRef(); |
|||
Map<String, Object> map = new HashMap<>(); |
|||
map.put("businessSid", businessSid); |
|||
/* if (incomingSourceRef.contains("start")) { |
|||
map.put("nodeState", SysFormLinkFlowStateEnum.UNCOMMITTED.getState()); |
|||
map.put("taskDefKey", taskDefKey); |
|||
map.put("flowState", SysFormLinkFlowStateEnum.UNCOMMITTED.getCode()); |
|||
} else {*/ |
|||
map.put("nodeState", nodeState); |
|||
map.put("taskDefKey", taskDefKey); |
|||
map.put("flowState", nodeState); |
|||
/* }*/ |
|||
sysFormLinkFeign.updateFiled(map); |
|||
return new ResultBean().success(); |
|||
} |
|||
|
|||
/** |
|||
* 流程历史流转记录 |
|||
* |
|||
* @param procInsId |
|||
* @param deployId |
|||
* @return |
|||
*/ |
|||
public ResultBean<FlowRecordVo> flowRecord(String procInsId, String deployId) { |
|||
ResultBean<FlowRecordVo> flowRecordVoResultBean = flowTaskFeign.businessFlowRecord(procInsId); |
|||
return flowRecordVoResultBean;//flowTaskFeign.businessFlowRecord(procInsId, deployId);
|
|||
} |
|||
|
|||
/** |
|||
* 驳回 |
|||
* |
|||
* @param businessSid |
|||
* @param flowTaskVo |
|||
* @return |
|||
*/ |
|||
public ResultBean taskReject(String businessSid, FlowTaskVo flowTaskVo) { |
|||
com.yxt.anrui.flowable.api.flowtask.FlowTaskVo fl = new com.yxt.anrui.flowable.api.flowtask.FlowTaskVo(); |
|||
BeanUtil.copyProperties(flowTaskVo, fl); |
|||
ResultBean<List<LatestTaskVo>> resultBean = flowTaskFeign.taskReject(fl); |
|||
if (!resultBean.getSuccess()) { |
|||
return resultBean; |
|||
} |
|||
String nodeState = resultBean.getData().get(0).getName_(); |
|||
String taskDefKey = resultBean.getData().get(0).getTask_def_key_(); |
|||
String incomingSourceRef = resultBean.getData().get(0).getIncomingSourceRef(); |
|||
Map<String, Object> map = new HashMap<>(); |
|||
map.put("businessSid", businessSid); |
|||
map.put("nodeState", nodeState); |
|||
map.put("taskDefKey", taskDefKey); |
|||
// if (incomingSourceRef.contains("start")) {
|
|||
map.put("flowState", nodeState); |
|||
// }
|
|||
sysFormLinkFeign.updateFiled(map); |
|||
return new ResultBean().success(); |
|||
} |
|||
|
|||
/** |
|||
* 终止流程 |
|||
* |
|||
* @param flowTaskVo |
|||
* @return |
|||
*/ |
|||
/* public ResultBean breakProcess(String businessSid, FlowTaskVo flowTaskVo) { |
|||
com.yxt.anrui.flowable.api.flowtask.FlowTaskVo fl = new com.yxt.anrui.flowable.api.flowtask.FlowTaskVo(); |
|||
BeanUtil.copyProperties(flowTaskVo, fl); |
|||
ResultBean resultBean = flowTaskFeign.breakProcess(fl); |
|||
if (!resultBean.getSuccess()) { |
|||
return resultBean; |
|||
} |
|||
Map<String, Object> map = new HashMap<>(); |
|||
map.put("businessSid", businessSid); |
|||
map.put("nodeState", String.valueOf(resultBean.getData())); |
|||
map.put("taskDefKey", "Event_end"); |
|||
map.put("flowState", FlowComment.STOP.getRemark()); |
|||
sysFormLinkFeign.updateFiled(map); |
|||
return resultBean.success(); |
|||
}*/ |
|||
public void stopProcess(FlowTaskVo flowTaskVo) { |
|||
com.yxt.anrui.flowable.api.flowtask.FlowTaskVo fl = new com.yxt.anrui.flowable.api.flowtask.FlowTaskVo(); |
|||
BeanUtil.copyProperties(flowTaskVo, fl); |
|||
flowTaskFeign.stopProcess(flowTaskVo.getUserSid(), fl); |
|||
} |
|||
|
|||
public void deleteProcess(String procInsId) { |
|||
flowTaskFeign.deleteProcess(procInsId); |
|||
} |
|||
|
|||
|
|||
public ResultBean<Page<FlowTaskDto>> todoAllTaskList(String userSid, PagerQuery<FlowTaskAllQuery> pQuery) { |
|||
ResultBean<Page<FlowTaskDto>> rb = new ResultBean<Page<FlowTaskDto>>().fireFail(); |
|||
FlowTaskAllQuery params = pQuery.getParams(); |
|||
if (StringUtils.isBlank(userSid)) { |
|||
return rb.setMsg("用户SID为空"); |
|||
} |
|||
PagerQuery<BusinessTaskQuery> taskQueryPagerQuery = new PagerQuery<>(); |
|||
taskQueryPagerQuery.setCurrent(pQuery.getCurrent()).setSize(pQuery.getSize()); |
|||
|
|||
String orgSid = params.getOrgSid(); |
|||
String processDefinitionId = params.getProcessDefinitionId(); |
|||
String proDefName = params.getProDefName(); |
|||
String startDate = params.getStartDate(); |
|||
String endDate = params.getEndDate(); |
|||
BusinessTaskQuery taskQuery = new BusinessTaskQuery(); |
|||
List<BusinessTaskParam> taskParamList = new ArrayList<>(); |
|||
if (StringUtils.isNotBlank(proDefName)) { |
|||
BusinessTaskParam taskParam = new BusinessTaskParam(); |
|||
taskParam.setField("proDefName"); |
|||
taskParam.setValue(proDefName); |
|||
taskParam.setSqlOperationSymbol(SQLOperationSymbol.LIKE); |
|||
taskParamList.add(taskParam); |
|||
} |
|||
if (StringUtils.isNotBlank(startDate)) { |
|||
BusinessTaskParam taskParam = new BusinessTaskParam(); |
|||
taskParam.setField("startDate"); |
|||
taskParam.setValue(startDate); |
|||
taskParam.setSqlOperationSymbol(SQLOperationSymbol.GE); |
|||
taskParamList.add(taskParam); |
|||
} |
|||
if (StringUtils.isNotBlank(endDate)) { |
|||
BusinessTaskParam taskParam = new BusinessTaskParam(); |
|||
taskParam.setField("endDate"); |
|||
taskParam.setValue(endDate); |
|||
taskParam.setSqlOperationSymbol(SQLOperationSymbol.LE); |
|||
taskParamList.add(taskParam); |
|||
} |
|||
if (StringUtils.isNotBlank(processDefinitionId)) { |
|||
BusinessTaskParam taskParam = new BusinessTaskParam(); |
|||
taskParam.setField("processDefinitionId"); |
|||
taskParam.setSqlOperationSymbol(SQLOperationSymbol.NONE); |
|||
taskParam.setValue(processDefinitionId); |
|||
taskParamList.add(taskParam); |
|||
} |
|||
if (StringUtils.isNotBlank(orgSid)) { |
|||
BusinessTaskParam taskParam = new BusinessTaskParam(); |
|||
taskParam.setField(BusinessVariables.ORGPATH); |
|||
taskParam.setSqlOperationSymbol(SQLOperationSymbol.NONE); |
|||
taskParam.setValue(orgSid); |
|||
taskParamList.add(taskParam); |
|||
} |
|||
|
|||
taskQuery.setFields(taskParamList); |
|||
taskQueryPagerQuery.setParams(taskQuery); |
|||
return flowTaskFeign.businessTodoList(userSid, taskQueryPagerQuery); |
|||
} |
|||
|
|||
public ResultBean<Integer> getTodoNum(String userSid) { |
|||
return flowTaskFeign.getTodoNum(userSid); |
|||
} |
|||
public ResultBean<Integer> getTodoNum(String userSid,String orgPath) { |
|||
UserAndOrgPath userAndOrgPath = new UserAndOrgPath(); |
|||
userAndOrgPath.setOrgPath(orgPath); |
|||
userAndOrgPath.setUserSid(userSid); |
|||
return flowTaskFeign.getTodoNum(userAndOrgPath); |
|||
} |
|||
|
|||
public ResultBean getNextTasks(String taskId) { |
|||
return flowTaskFeign.getNextTasks(taskId); |
|||
} |
|||
|
|||
|
|||
public ResultBean<Page<FlowTaskDto>> doneAllTaskList(String userSid, PagerQuery<FlowTaskAllQuery> pQuery) { |
|||
ResultBean<Page<FlowTaskDto>> rb = new ResultBean<Page<FlowTaskDto>>().fireFail(); |
|||
FlowTaskAllQuery params = pQuery.getParams(); |
|||
if (StringUtils.isBlank(userSid)) { |
|||
return rb.setMsg("用户SID为空"); |
|||
} |
|||
PagerQuery<BusinessTaskQuery> taskQueryPagerQuery = new PagerQuery<>(); |
|||
taskQueryPagerQuery.setCurrent(pQuery.getCurrent()).setSize(pQuery.getSize()); |
|||
String processDefinitionId = params.getProcessDefinitionId(); |
|||
String proDefName = params.getProDefName(); |
|||
String startDate = params.getStartDate(); |
|||
String endDate = params.getEndDate(); |
|||
BusinessTaskQuery taskQuery = new BusinessTaskQuery(); |
|||
List<BusinessTaskParam> taskParamList = new ArrayList<>(); |
|||
if (StringUtils.isNotBlank(proDefName)) { |
|||
BusinessTaskParam taskParam = new BusinessTaskParam(); |
|||
taskParam.setField("proDefName"); |
|||
taskParam.setValue(proDefName); |
|||
taskParam.setSqlOperationSymbol(SQLOperationSymbol.LIKE); |
|||
taskParamList.add(taskParam); |
|||
} |
|||
if (StringUtils.isNotBlank(startDate)) { |
|||
BusinessTaskParam taskParam = new BusinessTaskParam(); |
|||
taskParam.setField("startDate"); |
|||
taskParam.setValue(startDate); |
|||
taskParam.setSqlOperationSymbol(SQLOperationSymbol.GE); |
|||
taskParamList.add(taskParam); |
|||
} |
|||
if (StringUtils.isNotBlank(endDate)) { |
|||
BusinessTaskParam taskParam = new BusinessTaskParam(); |
|||
taskParam.setField("endDate"); |
|||
taskParam.setValue(endDate); |
|||
taskParam.setSqlOperationSymbol(SQLOperationSymbol.LE); |
|||
taskParamList.add(taskParam); |
|||
} |
|||
if (StringUtils.isNotBlank(processDefinitionId)) { |
|||
BusinessTaskParam taskParam = new BusinessTaskParam(); |
|||
taskParam.setField("processDefinitionId"); |
|||
taskParam.setSqlOperationSymbol(SQLOperationSymbol.NONE); |
|||
taskParam.setValue(processDefinitionId); |
|||
taskParamList.add(taskParam); |
|||
} |
|||
taskQuery.setFields(taskParamList); |
|||
taskQueryPagerQuery.setParams(taskQuery); |
|||
return flowTaskFeign.businessDoneList(userSid, taskQueryPagerQuery); |
|||
} |
|||
|
|||
public ResultBean readXml(String deployId) { |
|||
return flowTaskFeign.readXml(deployId); |
|||
} |
|||
|
|||
public ResultBean getFlowViewer(String procInsId) { |
|||
return flowTaskFeign.getFlowViewer(procInsId); |
|||
} |
|||
|
|||
} |
|||
///*********************************************************
|
|||
// *********************************************************
|
|||
// ******************** *******************
|
|||
// ************* ************
|
|||
// ******* _oo0oo_ *******
|
|||
// *** o8888888o ***
|
|||
// * 88" . "88 *
|
|||
// * (| -_- |) *
|
|||
// * 0\ = /0 *
|
|||
// * ___/`---'\___ *
|
|||
// * .' \\| |// '. *
|
|||
// * / \\||| : |||// \ *
|
|||
// * / _||||| -:- |||||- \ *
|
|||
// * | | \\\ - /// | | *
|
|||
// * | \_| ''\---/'' |_/ | *
|
|||
// * \ .-\__ '-' ___/-. / *
|
|||
// * ___'. .' /--.--\ `. .'___ *
|
|||
// * ."" '< `.___\_<|>_/___.' >' "". *
|
|||
// * | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
|||
// * \ \ `_. \_ __\ /__ _/ .-` / / *
|
|||
// * =====`-.____`.___ \_____/___.-`___.-'===== *
|
|||
// * `=---=' *
|
|||
// * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
|||
// *********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
|||
// *********************************************************/
|
|||
//package com.yxt.supervise.system.flow;
|
|||
//
|
|||
//import cn.hutool.core.bean.BeanUtil;
|
|||
//import com.alibaba.fastjson.JSON;
|
|||
//import com.alibaba.fastjson.JSONObject;
|
|||
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
//import com.yxt.anrui.flowable.api.flow.UserAndOrgPath;
|
|||
//import com.yxt.anrui.flowable.api.flowdefinition.FlowDefinitionFeign;
|
|||
//import com.yxt.anrui.flowable.api.flowtask.FlowRecordVo;
|
|||
//import com.yxt.anrui.flowable.api.flowtask.FlowTaskDto;
|
|||
//import com.yxt.anrui.flowable.api.flowtask.FlowTaskFeign;
|
|||
//import com.yxt.anrui.flowable.api.flowtask.LatestTaskVo;
|
|||
//import com.yxt.anrui.flowable.api.sysformlink.SysFormLinkFeign;
|
|||
//import com.yxt.anrui.flowable.api.sysprourl.SysProUrlFeign;
|
|||
//import com.yxt.anrui.flowable.sqloperationsymbol.BusinessTaskParam;
|
|||
//import com.yxt.anrui.flowable.sqloperationsymbol.BusinessTaskQuery;
|
|||
//import com.yxt.anrui.flowable.sqloperationsymbol.BusinessVariables;
|
|||
//import com.yxt.anrui.flowable.sqloperationsymbol.SQLOperationSymbol;
|
|||
//import com.yxt.common.base.config.component.FileUploadComponent;
|
|||
//import com.yxt.common.base.service.MybatisBaseService;
|
|||
//import com.yxt.common.base.utils.ConstantUtils;
|
|||
//import com.yxt.common.base.utils.StringUtils;
|
|||
//import com.yxt.common.core.query.PagerQuery;
|
|||
//import com.yxt.common.core.result.ResultBean;
|
|||
//import com.yxt.common.core.vo.PagerVo;
|
|||
//import org.springframework.beans.factory.annotation.Autowired;
|
|||
//import org.springframework.stereotype.Service;
|
|||
//
|
|||
//import java.util.*;
|
|||
//import java.util.stream.Collectors;
|
|||
//
|
|||
///**
|
|||
// * Project: anrui-parent <br/>
|
|||
// * File: FlowableService.java <br/>
|
|||
// * Class: com.yxt.anrui.portal.biz.flow.FlowableService <br/>
|
|||
// * Description: <描述类的功能>. <br/>
|
|||
// * Copyright: Copyright (c) 2011 <br/>
|
|||
// * Company: https://gitee.com/liuzp315 <br/>
|
|||
// * Makedate: 2021/10/23 上午11:14 <br/>
|
|||
// *
|
|||
// * @author popo
|
|||
// * @version 1.0
|
|||
// * @since 1.0
|
|||
// */
|
|||
//@Service
|
|||
//public class FlowableService extends MybatisBaseService<FlowableMapper, Flowable> {
|
|||
// @Autowired
|
|||
// private FlowDefinitionFeign flowDefinitionFeign;
|
|||
// @Autowired
|
|||
// private FlowTaskFeign flowTaskFeign;
|
|||
// @Autowired
|
|||
// private SysFormLinkFeign sysFormLinkFeign;
|
|||
// @Autowired
|
|||
// private SysProUrlFeign sysProUrlFeign;
|
|||
// @Autowired
|
|||
// private FileUploadComponent fileUploadComponent;
|
|||
///*
|
|||
//
|
|||
// public ResultBean businessStart(@ApiParam(value = "流程定义id") @PathVariable(value = "procDefId") String procDefId,
|
|||
// @ApiParam(value = "用户sid") @PathVariable(value = "userSid") String userSid,
|
|||
// @ApiParam(value = "变量集合,json对象") @RequestBody Map<String, Object> variables) {
|
|||
//
|
|||
// FlowDefinitionFeignBusinessStartDTO dto = new FlowDefinitionFeignBusinessStartDTO();
|
|||
// dto.setProcDefId(procDefId);
|
|||
// dto.setUserSid(userSid);
|
|||
// dto.setVariables(variables);
|
|||
// variables.put("procDefId", procDefId);
|
|||
// variables.put("userSid", userSid);
|
|||
// variables.put("businessSid", UUID.randomUUID().toString());
|
|||
// BusinessVariables bv = BusinessVariables.builder().build();
|
|||
// bv.setFormVariables(variables);
|
|||
// ResultBean rb = flowDefinitionFeign.businessStart(bv);
|
|||
// return rb;
|
|||
// }
|
|||
//*/
|
|||
//
|
|||
// public ResultBean myprocess(String userSid, PagerQuery<FlowTaskQuery> taskQueryPagerQuery) {
|
|||
// PagerQuery<BusinessTaskQuery> pq = new PagerQuery<>();
|
|||
// String days = taskQueryPagerQuery.getParams().getDays();
|
|||
// String zd = taskQueryPagerQuery.getParams().getZd();
|
|||
// pq.setCurrent(taskQueryPagerQuery.getCurrent());
|
|||
// pq.setSize(taskQueryPagerQuery.getSize());
|
|||
// BusinessTaskQuery businessTaskQuery = BusinessTaskQuery.create();
|
|||
// if (StringUtils.isNotBlank(zd)) {
|
|||
// BusinessTaskParam businessTaskParam = new BusinessTaskParam();
|
|||
// businessTaskParam.setField("zd");
|
|||
// businessTaskParam.setSqlOperationSymbol(SQLOperationSymbol.LIKE);
|
|||
// businessTaskParam.setValue(zd);
|
|||
// businessTaskQuery.add(businessTaskParam);
|
|||
// }
|
|||
// if (StringUtils.isNotBlank(days)) {
|
|||
// BusinessTaskParam businessTaskParam = new BusinessTaskParam();
|
|||
// businessTaskParam.setField("days");
|
|||
// businessTaskParam.setSqlOperationSymbol(SQLOperationSymbol.EQUAL);
|
|||
// businessTaskParam.setValue(days);
|
|||
// businessTaskQuery.add(businessTaskParam);
|
|||
// }
|
|||
// pq.setParams(businessTaskQuery);
|
|||
// return flowTaskFeign.businessMyprocess(userSid, pq);
|
|||
// }
|
|||
//
|
|||
// public ResultBean processPagerList(Integer pageNum, Integer pageSize) {
|
|||
// return flowDefinitionFeign.pagerList(pageNum, pageSize);
|
|||
// }
|
|||
//
|
|||
// public ResultBean todoTaskList(String userSid, PagerQuery<TaskQuery> pQuery) {
|
|||
// TaskQuery params = pQuery.getParams();
|
|||
// if (StringUtils.isBlank(userSid)) {
|
|||
// return ResultBean.fireFail().setMsg("用户SID为空");
|
|||
// }
|
|||
// PagerQuery<BusinessTaskQuery> taskQueryPagerQuery = new PagerQuery<>();
|
|||
// taskQueryPagerQuery.setCurrent(pQuery.getCurrent()).setSize(pQuery.getSize());
|
|||
//
|
|||
// String orgSid = params.getOrgSid();
|
|||
// String days = params.getDays();
|
|||
// String processDefinitionId = params.getProcessDefinitionId();
|
|||
// String startTime = params.getStartTime();
|
|||
// BusinessTaskQuery taskQuery = new BusinessTaskQuery();
|
|||
// List<BusinessTaskParam> taskParamList = new ArrayList<>();
|
|||
// if (StringUtils.isNotBlank(days)) {
|
|||
// BusinessTaskParam taskParam = new BusinessTaskParam();
|
|||
// taskParam.setField("zd1");
|
|||
// taskParam.setValue(days);
|
|||
// taskParam.setSqlOperationSymbol(SQLOperationSymbol.EQUAL);
|
|||
// taskParamList.add(taskParam);
|
|||
// }
|
|||
// if (StringUtils.isNotBlank(startTime)) {
|
|||
// BusinessTaskParam taskParam = new BusinessTaskParam();
|
|||
// taskParam.setField("startTime");
|
|||
// taskParam.setValue(startTime);
|
|||
// taskParam.setSqlOperationSymbol(SQLOperationSymbol.EQUAL);
|
|||
// taskParamList.add(taskParam);
|
|||
// }
|
|||
// if (StringUtils.isNotBlank(processDefinitionId)) {
|
|||
// BusinessTaskParam taskParam = new BusinessTaskParam();
|
|||
// taskParam.setField("processDefinitionId");
|
|||
// taskParam.setSqlOperationSymbol(SQLOperationSymbol.NONE);
|
|||
// taskParam.setValue(processDefinitionId);
|
|||
// taskParamList.add(taskParam);
|
|||
// }
|
|||
// if (StringUtils.isNotBlank(orgSid)) {
|
|||
// BusinessTaskParam taskParam = new BusinessTaskParam();
|
|||
// taskParam.setField(BusinessVariables.ORGPATH);
|
|||
// taskParam.setSqlOperationSymbol(SQLOperationSymbol.NONE);
|
|||
// taskParam.setValue(orgSid);
|
|||
// taskParamList.add(taskParam);
|
|||
// }
|
|||
// taskQuery.setFields(taskParamList);
|
|||
// taskQueryPagerQuery.setParams(taskQuery);
|
|||
// return flowTaskFeign.businessTodoList(userSid, taskQueryPagerQuery);
|
|||
// }
|
|||
//
|
|||
// public ResultBean doneTaskList(String userSid, PagerQuery<TaskQuery> pQuery) {
|
|||
// TaskQuery params = pQuery.getParams();
|
|||
// if (StringUtils.isBlank(userSid)) {
|
|||
// return ResultBean.fireFail().setMsg("用户SID为空");
|
|||
// }
|
|||
// PagerQuery<BusinessTaskQuery> taskQueryPagerQuery = new PagerQuery<>();
|
|||
// taskQueryPagerQuery.setCurrent(pQuery.getCurrent()).setSize(pQuery.getSize());
|
|||
// String zd1 = params.getZd1();
|
|||
// String processDefinitionId = params.getProcessDefinitionId();
|
|||
// String startTime = params.getStartTime();
|
|||
// BusinessTaskQuery taskQuery = new BusinessTaskQuery();
|
|||
// List<BusinessTaskParam> taskParamList = new ArrayList<>();
|
|||
// if (StringUtils.isNotBlank(zd1)) {
|
|||
// BusinessTaskParam taskParam = new BusinessTaskParam();
|
|||
// taskParam.setField("zd1");
|
|||
// taskParam.setValue(zd1);
|
|||
// taskParam.setSqlOperationSymbol(SQLOperationSymbol.EQUAL);
|
|||
// taskParamList.add(taskParam);
|
|||
// }
|
|||
// if (StringUtils.isNotBlank(startTime)) {
|
|||
// BusinessTaskParam taskParam = new BusinessTaskParam();
|
|||
// taskParam.setField("startTime");
|
|||
// taskParam.setValue(startTime);
|
|||
// taskParam.setSqlOperationSymbol(SQLOperationSymbol.EQUAL);
|
|||
// taskParamList.add(taskParam);
|
|||
// }
|
|||
// if (StringUtils.isNotBlank(processDefinitionId)) {
|
|||
// BusinessTaskParam taskParam = new BusinessTaskParam();
|
|||
// taskParam.setField("processDefinitionId");
|
|||
// taskParam.setSqlOperationSymbol(SQLOperationSymbol.NONE);
|
|||
// taskParam.setValue(processDefinitionId);
|
|||
// taskParamList.add(taskParam);
|
|||
// }
|
|||
// taskQuery.setFields(taskParamList);
|
|||
// taskQueryPagerQuery.setParams(taskQuery);
|
|||
// return flowTaskFeign.businessDoneList(userSid, taskQueryPagerQuery);
|
|||
// }
|
|||
//
|
|||
// /**
|
|||
// * 撤回
|
|||
// *
|
|||
// * @param userSid
|
|||
// * @param businessSid
|
|||
// * @param flowTaskVo
|
|||
// * @return
|
|||
// */
|
|||
// public ResultBean revokeProcess(String userSid, String businessSid, FlowTaskVo flowTaskVo) {
|
|||
// com.yxt.anrui.flowable.api.flowtask.FlowTaskVo fl = new com.yxt.anrui.flowable.api.flowtask.FlowTaskVo();
|
|||
// BeanUtil.copyProperties(flowTaskVo, fl);
|
|||
// fl.setUserSid(userSid);
|
|||
// ResultBean<List<LatestTaskVo>> resultBean = flowTaskFeign.revokeProcess(fl);
|
|||
// if (!resultBean.getSuccess()) {
|
|||
// return resultBean;
|
|||
// }
|
|||
// String nodeState = resultBean.getData().get(0).getName_();
|
|||
// String taskDefKey = resultBean.getData().get(0).getTask_def_key_();
|
|||
// String incomingSourceRef = resultBean.getData().get(0).getIncomingSourceRef();
|
|||
// Map<String, Object> map = new HashMap<>();
|
|||
// map.put("businessSid", businessSid);
|
|||
// /* if (incomingSourceRef.contains("start")) {
|
|||
// map.put("nodeState", SysFormLinkFlowStateEnum.UNCOMMITTED.getState());
|
|||
// map.put("taskDefKey", taskDefKey);
|
|||
// map.put("flowState", SysFormLinkFlowStateEnum.UNCOMMITTED.getCode());
|
|||
// } else {*/
|
|||
// map.put("nodeState", nodeState);
|
|||
// map.put("taskDefKey", taskDefKey);
|
|||
// map.put("flowState", nodeState);
|
|||
// /* }*/
|
|||
// sysFormLinkFeign.updateFiled(map);
|
|||
// return new ResultBean().success();
|
|||
// }
|
|||
//
|
|||
// /**
|
|||
// * 流程历史流转记录
|
|||
// *
|
|||
// * @param procInsId
|
|||
// * @param deployId
|
|||
// * @return
|
|||
// */
|
|||
// public ResultBean<FlowRecordVo> flowRecord(String procInsId, String deployId) {
|
|||
// ResultBean<FlowRecordVo> flowRecordVoResultBean = flowTaskFeign.businessFlowRecord(procInsId);
|
|||
// return flowRecordVoResultBean;//flowTaskFeign.businessFlowRecord(procInsId, deployId);
|
|||
// }
|
|||
//
|
|||
// /**
|
|||
// * 驳回
|
|||
// *
|
|||
// * @param businessSid
|
|||
// * @param flowTaskVo
|
|||
// * @return
|
|||
// */
|
|||
// public ResultBean taskReject(String businessSid, FlowTaskVo flowTaskVo) {
|
|||
// com.yxt.anrui.flowable.api.flowtask.FlowTaskVo fl = new com.yxt.anrui.flowable.api.flowtask.FlowTaskVo();
|
|||
// BeanUtil.copyProperties(flowTaskVo, fl);
|
|||
// ResultBean<List<LatestTaskVo>> resultBean = flowTaskFeign.taskReject(fl);
|
|||
// if (!resultBean.getSuccess()) {
|
|||
// return resultBean;
|
|||
// }
|
|||
// String nodeState = resultBean.getData().get(0).getName_();
|
|||
// String taskDefKey = resultBean.getData().get(0).getTask_def_key_();
|
|||
// String incomingSourceRef = resultBean.getData().get(0).getIncomingSourceRef();
|
|||
// Map<String, Object> map = new HashMap<>();
|
|||
// map.put("businessSid", businessSid);
|
|||
// map.put("nodeState", nodeState);
|
|||
// map.put("taskDefKey", taskDefKey);
|
|||
//// if (incomingSourceRef.contains("start")) {
|
|||
// map.put("flowState", nodeState);
|
|||
//// }
|
|||
// sysFormLinkFeign.updateFiled(map);
|
|||
// return new ResultBean().success();
|
|||
// }
|
|||
//
|
|||
// /**
|
|||
// * 终止流程
|
|||
// *
|
|||
// * @param flowTaskVo
|
|||
// * @return
|
|||
// */
|
|||
// /* public ResultBean breakProcess(String businessSid, FlowTaskVo flowTaskVo) {
|
|||
// com.yxt.anrui.flowable.api.flowtask.FlowTaskVo fl = new com.yxt.anrui.flowable.api.flowtask.FlowTaskVo();
|
|||
// BeanUtil.copyProperties(flowTaskVo, fl);
|
|||
// ResultBean resultBean = flowTaskFeign.breakProcess(fl);
|
|||
// if (!resultBean.getSuccess()) {
|
|||
// return resultBean;
|
|||
// }
|
|||
// Map<String, Object> map = new HashMap<>();
|
|||
// map.put("businessSid", businessSid);
|
|||
// map.put("nodeState", String.valueOf(resultBean.getData()));
|
|||
// map.put("taskDefKey", "Event_end");
|
|||
// map.put("flowState", FlowComment.STOP.getRemark());
|
|||
// sysFormLinkFeign.updateFiled(map);
|
|||
// return resultBean.success();
|
|||
// }*/
|
|||
// public void stopProcess(FlowTaskVo flowTaskVo) {
|
|||
// com.yxt.anrui.flowable.api.flowtask.FlowTaskVo fl = new com.yxt.anrui.flowable.api.flowtask.FlowTaskVo();
|
|||
// BeanUtil.copyProperties(flowTaskVo, fl);
|
|||
// flowTaskFeign.stopProcess(flowTaskVo.getUserSid(), fl);
|
|||
// }
|
|||
//
|
|||
// public void deleteProcess(String procInsId) {
|
|||
// flowTaskFeign.deleteProcess(procInsId);
|
|||
// }
|
|||
//
|
|||
//
|
|||
// public ResultBean<Page<FlowTaskDto>> todoAllTaskList(String userSid, PagerQuery<FlowTaskAllQuery> pQuery) {
|
|||
// ResultBean<Page<FlowTaskDto>> rb = new ResultBean<Page<FlowTaskDto>>().fireFail();
|
|||
// FlowTaskAllQuery params = pQuery.getParams();
|
|||
// if (StringUtils.isBlank(userSid)) {
|
|||
// return rb.setMsg("用户SID为空");
|
|||
// }
|
|||
// PagerQuery<BusinessTaskQuery> taskQueryPagerQuery = new PagerQuery<>();
|
|||
// taskQueryPagerQuery.setCurrent(pQuery.getCurrent()).setSize(pQuery.getSize());
|
|||
//
|
|||
// String orgSid = params.getOrgSid();
|
|||
// String processDefinitionId = params.getProcessDefinitionId();
|
|||
// String proDefName = params.getProDefName();
|
|||
// String startDate = params.getStartDate();
|
|||
// String endDate = params.getEndDate();
|
|||
// BusinessTaskQuery taskQuery = new BusinessTaskQuery();
|
|||
// List<BusinessTaskParam> taskParamList = new ArrayList<>();
|
|||
// if (StringUtils.isNotBlank(proDefName)) {
|
|||
// BusinessTaskParam taskParam = new BusinessTaskParam();
|
|||
// taskParam.setField("proDefName");
|
|||
// taskParam.setValue(proDefName);
|
|||
// taskParam.setSqlOperationSymbol(SQLOperationSymbol.LIKE);
|
|||
// taskParamList.add(taskParam);
|
|||
// }
|
|||
// if (StringUtils.isNotBlank(startDate)) {
|
|||
// BusinessTaskParam taskParam = new BusinessTaskParam();
|
|||
// taskParam.setField("startDate");
|
|||
// taskParam.setValue(startDate);
|
|||
// taskParam.setSqlOperationSymbol(SQLOperationSymbol.GE);
|
|||
// taskParamList.add(taskParam);
|
|||
// }
|
|||
// if (StringUtils.isNotBlank(endDate)) {
|
|||
// BusinessTaskParam taskParam = new BusinessTaskParam();
|
|||
// taskParam.setField("endDate");
|
|||
// taskParam.setValue(endDate);
|
|||
// taskParam.setSqlOperationSymbol(SQLOperationSymbol.LE);
|
|||
// taskParamList.add(taskParam);
|
|||
// }
|
|||
// if (StringUtils.isNotBlank(processDefinitionId)) {
|
|||
// BusinessTaskParam taskParam = new BusinessTaskParam();
|
|||
// taskParam.setField("processDefinitionId");
|
|||
// taskParam.setSqlOperationSymbol(SQLOperationSymbol.NONE);
|
|||
// taskParam.setValue(processDefinitionId);
|
|||
// taskParamList.add(taskParam);
|
|||
// }
|
|||
// if (StringUtils.isNotBlank(orgSid)) {
|
|||
// BusinessTaskParam taskParam = new BusinessTaskParam();
|
|||
// taskParam.setField(BusinessVariables.ORGPATH);
|
|||
// taskParam.setSqlOperationSymbol(SQLOperationSymbol.NONE);
|
|||
// taskParam.setValue(orgSid);
|
|||
// taskParamList.add(taskParam);
|
|||
// }
|
|||
//
|
|||
// taskQuery.setFields(taskParamList);
|
|||
// taskQueryPagerQuery.setParams(taskQuery);
|
|||
// return flowTaskFeign.businessTodoList(userSid, taskQueryPagerQuery);
|
|||
// }
|
|||
//
|
|||
// public ResultBean<Integer> getTodoNum(String userSid) {
|
|||
// return flowTaskFeign.getTodoNum(userSid);
|
|||
// }
|
|||
// public ResultBean<Integer> getTodoNum(String userSid,String orgPath) {
|
|||
// UserAndOrgPath userAndOrgPath = new UserAndOrgPath();
|
|||
// userAndOrgPath.setOrgPath(orgPath);
|
|||
// userAndOrgPath.setUserSid(userSid);
|
|||
// return flowTaskFeign.getTodoNum(userAndOrgPath);
|
|||
// }
|
|||
//
|
|||
// public ResultBean getNextTasks(String taskId) {
|
|||
// return flowTaskFeign.getNextTasks(taskId);
|
|||
// }
|
|||
//
|
|||
//
|
|||
// public ResultBean<Page<FlowTaskDto>> doneAllTaskList(String userSid, PagerQuery<FlowTaskAllQuery> pQuery) {
|
|||
// ResultBean<Page<FlowTaskDto>> rb = new ResultBean<Page<FlowTaskDto>>().fireFail();
|
|||
// FlowTaskAllQuery params = pQuery.getParams();
|
|||
// if (StringUtils.isBlank(userSid)) {
|
|||
// return rb.setMsg("用户SID为空");
|
|||
// }
|
|||
// PagerQuery<BusinessTaskQuery> taskQueryPagerQuery = new PagerQuery<>();
|
|||
// taskQueryPagerQuery.setCurrent(pQuery.getCurrent()).setSize(pQuery.getSize());
|
|||
// String processDefinitionId = params.getProcessDefinitionId();
|
|||
// String proDefName = params.getProDefName();
|
|||
// String startDate = params.getStartDate();
|
|||
// String endDate = params.getEndDate();
|
|||
// BusinessTaskQuery taskQuery = new BusinessTaskQuery();
|
|||
// List<BusinessTaskParam> taskParamList = new ArrayList<>();
|
|||
// if (StringUtils.isNotBlank(proDefName)) {
|
|||
// BusinessTaskParam taskParam = new BusinessTaskParam();
|
|||
// taskParam.setField("proDefName");
|
|||
// taskParam.setValue(proDefName);
|
|||
// taskParam.setSqlOperationSymbol(SQLOperationSymbol.LIKE);
|
|||
// taskParamList.add(taskParam);
|
|||
// }
|
|||
// if (StringUtils.isNotBlank(startDate)) {
|
|||
// BusinessTaskParam taskParam = new BusinessTaskParam();
|
|||
// taskParam.setField("startDate");
|
|||
// taskParam.setValue(startDate);
|
|||
// taskParam.setSqlOperationSymbol(SQLOperationSymbol.GE);
|
|||
// taskParamList.add(taskParam);
|
|||
// }
|
|||
// if (StringUtils.isNotBlank(endDate)) {
|
|||
// BusinessTaskParam taskParam = new BusinessTaskParam();
|
|||
// taskParam.setField("endDate");
|
|||
// taskParam.setValue(endDate);
|
|||
// taskParam.setSqlOperationSymbol(SQLOperationSymbol.LE);
|
|||
// taskParamList.add(taskParam);
|
|||
// }
|
|||
// if (StringUtils.isNotBlank(processDefinitionId)) {
|
|||
// BusinessTaskParam taskParam = new BusinessTaskParam();
|
|||
// taskParam.setField("processDefinitionId");
|
|||
// taskParam.setSqlOperationSymbol(SQLOperationSymbol.NONE);
|
|||
// taskParam.setValue(processDefinitionId);
|
|||
// taskParamList.add(taskParam);
|
|||
// }
|
|||
// taskQuery.setFields(taskParamList);
|
|||
// taskQueryPagerQuery.setParams(taskQuery);
|
|||
// return flowTaskFeign.businessDoneList(userSid, taskQueryPagerQuery);
|
|||
// }
|
|||
//
|
|||
// public ResultBean readXml(String deployId) {
|
|||
// return flowTaskFeign.readXml(deployId);
|
|||
// }
|
|||
//
|
|||
// public ResultBean getFlowViewer(String procInsId) {
|
|||
// return flowTaskFeign.getFlowViewer(procInsId);
|
|||
// }
|
|||
//
|
|||
//}
|
|||
|
@ -1,100 +1,100 @@ |
|||
package com.yxt.supervise.system.purchasingrequisition; |
|||
|
|||
import cn.hutool.core.bean.BeanUtil; |
|||
import com.yxt.anrui.flowable.api.utils.ProcDefEnum; |
|||
import com.yxt.anrui.flowable.sqloperationsymbol.BusinessVariables; |
|||
import com.yxt.common.core.query.PagerQuery; |
|||
import com.yxt.common.core.result.ResultBean; |
|||
import com.yxt.common.core.vo.PagerVo; |
|||
import com.yxt.supervise.system.flow.GetNodeQuery; |
|||
import com.yxt.supervise.system.flow.GetNodeVo; |
|||
import io.swagger.annotations.Api; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @Author dimengzhe |
|||
* @Date 2023/1/30 14:23 |
|||
* @Description |
|||
*/ |
|||
@Controller |
|||
@RequestMapping("v1/pr") |
|||
@Api(tags = "采购信息") |
|||
public class PurchasingRequisitionRest implements PurchasingRequisitionFeign { |
|||
|
|||
@Autowired |
|||
private PurchasingRequisitionService purchasingRequisitionService; |
|||
|
|||
@Override |
|||
public ResultBean<PagerVo<PurchasingRequisitionVo>> listPage(PagerQuery<PurchasingRequisitionQuery> pq) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
PagerVo<PurchasingRequisitionVo> pv = purchasingRequisitionService.listPageVo(pq); |
|||
return rb.success().setData(pv); |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean save(PurchasingRequisitionDto dto) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
purchasingRequisitionService.saveOrUpdateDto(dto); |
|||
return rb.success(); |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean submit(PurchasingRequisitionDto dto) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
purchasingRequisitionService.submit(dto); |
|||
return rb.success(); |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean delBySids(String[] sids) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
if (sids == null || sids.length == 0) { |
|||
return rb.setMsg("删除失败,虚拟订单sid不能为空!"); |
|||
} |
|||
return purchasingRequisitionService.deleteBySids(sids); |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean<PurchasingRequisitionDetailsVo> fetchDetailsBySid(String sid) { |
|||
ResultBean<PurchasingRequisitionDetailsVo> resultBean = ResultBean.fireFail(); |
|||
PurchasingRequisitionDetailsVo vo = purchasingRequisitionService.fetchDetailsBySid(sid); |
|||
return resultBean.success().setData(vo); |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean complete(PrVariables bv) { |
|||
bv.setModelId(ProcDefEnum.PR.getProDefId()); |
|||
BusinessVariables b=new BusinessVariables(); |
|||
BeanUtil.copyProperties(bv,b); |
|||
return purchasingRequisitionService.complete(b); |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean<List<GetNodeVo>> getPreviousNodesForReject(GetNodeQuery query) { |
|||
return purchasingRequisitionService.getPreviousNodesForReject(query); |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean<List<GetNodeVo>> getNextNodesForSubmit(GetNodeQuery query) { |
|||
return purchasingRequisitionService.getNextNodesForSubmit(query); |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean taskReject(PurchasingRequisitionQuery query) { |
|||
return purchasingRequisitionService.taskReject(query); |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean revokeProcess(PurchasingRequisitionQuery query) { |
|||
return purchasingRequisitionService.revokeProcess(query); |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean breakProcess(PurchasingRequisitionQuery query) { |
|||
return purchasingRequisitionService.breakProcess(query); |
|||
} |
|||
} |
|||
//package com.yxt.supervise.system.purchasingrequisition;
|
|||
//
|
|||
//import cn.hutool.core.bean.BeanUtil;
|
|||
//import com.yxt.anrui.flowable.api.utils.ProcDefEnum;
|
|||
//import com.yxt.anrui.flowable.sqloperationsymbol.BusinessVariables;
|
|||
//import com.yxt.common.core.query.PagerQuery;
|
|||
//import com.yxt.common.core.result.ResultBean;
|
|||
//import com.yxt.common.core.vo.PagerVo;
|
|||
//import com.yxt.supervise.system.flow.GetNodeQuery;
|
|||
//import com.yxt.supervise.system.flow.GetNodeVo;
|
|||
//import io.swagger.annotations.Api;
|
|||
//import org.springframework.beans.factory.annotation.Autowired;
|
|||
//import org.springframework.stereotype.Controller;
|
|||
//import org.springframework.web.bind.annotation.RequestMapping;
|
|||
//
|
|||
//import java.util.List;
|
|||
//
|
|||
///**
|
|||
// * @Author dimengzhe
|
|||
// * @Date 2023/1/30 14:23
|
|||
// * @Description
|
|||
// */
|
|||
//@Controller
|
|||
//@RequestMapping("v1/pr")
|
|||
//@Api(tags = "采购信息")
|
|||
//public class PurchasingRequisitionRest implements PurchasingRequisitionFeign {
|
|||
//
|
|||
// @Autowired
|
|||
// private PurchasingRequisitionService purchasingRequisitionService;
|
|||
//
|
|||
// @Override
|
|||
// public ResultBean<PagerVo<PurchasingRequisitionVo>> listPage(PagerQuery<PurchasingRequisitionQuery> pq) {
|
|||
// ResultBean rb = ResultBean.fireFail();
|
|||
// PagerVo<PurchasingRequisitionVo> pv = purchasingRequisitionService.listPageVo(pq);
|
|||
// return rb.success().setData(pv);
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public ResultBean save(PurchasingRequisitionDto dto) {
|
|||
// ResultBean rb = ResultBean.fireFail();
|
|||
// purchasingRequisitionService.saveOrUpdateDto(dto);
|
|||
// return rb.success();
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public ResultBean submit(PurchasingRequisitionDto dto) {
|
|||
// ResultBean rb = ResultBean.fireFail();
|
|||
// purchasingRequisitionService.submit(dto);
|
|||
// return rb.success();
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public ResultBean delBySids(String[] sids) {
|
|||
// ResultBean rb = ResultBean.fireFail();
|
|||
// if (sids == null || sids.length == 0) {
|
|||
// return rb.setMsg("删除失败,虚拟订单sid不能为空!");
|
|||
// }
|
|||
// return purchasingRequisitionService.deleteBySids(sids);
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public ResultBean<PurchasingRequisitionDetailsVo> fetchDetailsBySid(String sid) {
|
|||
// ResultBean<PurchasingRequisitionDetailsVo> resultBean = ResultBean.fireFail();
|
|||
// PurchasingRequisitionDetailsVo vo = purchasingRequisitionService.fetchDetailsBySid(sid);
|
|||
// return resultBean.success().setData(vo);
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public ResultBean complete(PrVariables bv) {
|
|||
// bv.setModelId(ProcDefEnum.PR.getProDefId());
|
|||
// BusinessVariables b=new BusinessVariables();
|
|||
// BeanUtil.copyProperties(bv,b);
|
|||
// return purchasingRequisitionService.complete(b);
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public ResultBean<List<GetNodeVo>> getPreviousNodesForReject(GetNodeQuery query) {
|
|||
// return purchasingRequisitionService.getPreviousNodesForReject(query);
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public ResultBean<List<GetNodeVo>> getNextNodesForSubmit(GetNodeQuery query) {
|
|||
// return purchasingRequisitionService.getNextNodesForSubmit(query);
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public ResultBean taskReject(PurchasingRequisitionQuery query) {
|
|||
// return purchasingRequisitionService.taskReject(query);
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public ResultBean revokeProcess(PurchasingRequisitionQuery query) {
|
|||
// return purchasingRequisitionService.revokeProcess(query);
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public ResultBean breakProcess(PurchasingRequisitionQuery query) {
|
|||
// return purchasingRequisitionService.breakProcess(query);
|
|||
// }
|
|||
//}
|
|||
|
@ -1,410 +1,410 @@ |
|||
package com.yxt.supervise.system.purchasingrequisition; |
|||
|
|||
import cn.hutool.core.bean.BeanUtil; |
|||
import cn.hutool.core.date.DateUtil; |
|||
import com.alibaba.fastjson.JSON; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.google.common.util.concurrent.ThreadFactoryBuilder; |
|||
import com.yxt.anrui.flowable.api.flow.FlowableFeign; |
|||
import com.yxt.anrui.flowable.api.flow.UpdateFlowFieldVo; |
|||
import com.yxt.anrui.flowable.api.flowtask.FlowTaskFeign; |
|||
import com.yxt.anrui.flowable.api.flowtask.FlowTaskVo; |
|||
import com.yxt.anrui.flowable.api.flowtask.LatestTaskVo; |
|||
import com.yxt.anrui.flowable.api.sysformlink.SysFormLinkFeign; |
|||
import com.yxt.anrui.flowable.api.utils.ProcDefEnum; |
|||
import com.yxt.anrui.flowable.sqloperationsymbol.BusinessVariables; |
|||
import com.yxt.common.base.service.MybatisBaseService; |
|||
import com.yxt.common.base.utils.PagerUtil; |
|||
import com.yxt.common.core.query.PagerQuery; |
|||
import com.yxt.common.core.result.ResultBean; |
|||
import com.yxt.common.core.vo.PagerVo; |
|||
import com.yxt.supervise.system.flow.GetNodeQuery; |
|||
import com.yxt.supervise.system.flow.GetNodeVo; |
|||
import com.yxt.supervise.system.region.Region; |
|||
import com.yxt.supervise.system.region.RegionListVo; |
|||
import com.yxt.supervise.system.sysstaffinfo.SysStaffinfoService; |
|||
import com.yxt.supervise.system.sysuser.SysUserService; |
|||
import com.yxt.supervise.system.sysuser.SysUserVo; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.apache.tomcat.util.threads.ThreadPoolExecutor; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.*; |
|||
import java.util.concurrent.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* @Author dimengzhe |
|||
* @Date 2023/1/30 14:24 |
|||
* @Description |
|||
*/ |
|||
@Slf4j |
|||
@Service |
|||
public class PurchasingRequisitionService extends MybatisBaseService<PurchasingRequisitionMapper, PurchasingRequisition> { |
|||
|
|||
@Autowired |
|||
private FlowTaskFeign flowTaskFeign; |
|||
|
|||
@Autowired |
|||
private FlowableFeign flowableFeign; |
|||
@Autowired |
|||
private SysStaffinfoService sysStaffinfoService; |
|||
@Autowired |
|||
private SysUserService sysUserService; |
|||
@Autowired |
|||
private SysFormLinkFeign sysFormLinkFeign; |
|||
public ResultBean saveOrUpdateDto(PurchasingRequisitionDto dto) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
String sid = dto.getSid(); |
|||
if (StringUtils.isBlank(sid)) { |
|||
PurchasingRequisition productInformation = new PurchasingRequisition(); |
|||
BeanUtil.copyProperties(dto, productInformation, "sid"); |
|||
baseMapper.insert(productInformation); |
|||
} else { |
|||
PurchasingRequisition productInformation = fetchBySid(sid); |
|||
if (productInformation == null) { |
|||
return rb.setMsg("该商品档案不存在"); |
|||
} |
|||
BeanUtil.copyProperties(dto, productInformation, "sid"); |
|||
baseMapper.updateById(productInformation); |
|||
} |
|||
return rb.success(); |
|||
} |
|||
public ResultBean submit(PurchasingRequisitionDto dto) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
String sid = dto.getSid(); |
|||
String taskid=""; |
|||
if (StringUtils.isBlank(sid)) { |
|||
PurchasingRequisition productInformation = new PurchasingRequisition(); |
|||
BeanUtil.copyProperties(dto, productInformation, "sid"); |
|||
dto.setSid(productInformation.getSid()); |
|||
baseMapper.insert(productInformation); |
|||
} else { |
|||
PurchasingRequisition productInformation = fetchBySid(sid); |
|||
taskid=productInformation.getTaskId(); |
|||
if (productInformation == null) { |
|||
return rb.setMsg("该商品档案不存在"); |
|||
} |
|||
BeanUtil.copyProperties(dto, productInformation, "sid"); |
|||
baseMapper.updateById(productInformation); |
|||
} |
|||
if (StringUtils.isBlank(taskid)) { |
|||
startProcess(dto); |
|||
} else { |
|||
PurchasingRequisition pr = fetchBySid(sid); |
|||
BusinessVariables bv = new BusinessVariables(); |
|||
//流程中的参数赋值、若有网关,则赋值网关中判断的字段。
|
|||
Map<String, Object> variables = new HashMap<>(); |
|||
//用户的部门全路径sid
|
|||
bv.setOrgSidPath("fd6435f2-0005-11ec-a033-48452053aa33/3042d730-64e8-4e34-b08a-44adca4da3a5/548c9469-f5e8-4a1a-b69f-cb54b152c5d1"); |
|||
//业务sid
|
|||
bv.setBusinessSid(sid); |
|||
//用户sid
|
|||
bv.setUserSid("0331e5b5-9d60-11ed-87ce-525401028fe7"); |
|||
//若app移动端有此功能,则传递appMap参数
|
|||
Map<String, Object> appMap = new HashMap<>(); |
|||
//需和移动端沟通业务sid保存的属性具体值:appMap中sid不是固定的。移动端提供具体字段。
|
|||
variables.put("app", appMap); |
|||
variables.put("money", pr.getMoney()); |
|||
bv.setFormVariables(variables); |
|||
//流程定义id
|
|||
bv.setModelId(ProcDefEnum.PR.getProDefId()); |
|||
bv.setTaskId(dto.getTaskId()); |
|||
bv.setTaskDefKey(pr.getNodeSid()); |
|||
bv.setComment(com.yxt.common.base.utils.StringUtils.isNotBlank(dto.getComment()) ? dto.getComment() : "重新提交"); |
|||
bv.setInstanceId(pr.getProcInstSid()); |
|||
//更新已选择的车架号的状态为审批中
|
|||
//System.out.println(JSON.toJSONString(bv));
|
|||
complete(bv); |
|||
} |
|||
return rb.success(); |
|||
} |
|||
|
|||
private void startProcess(PurchasingRequisitionDto dto) { |
|||
BusinessVariables bv = new BusinessVariables(); |
|||
//流程中的参数赋值、若有网关,则赋值网关中判断的字段。
|
|||
Map<String, Object> variables = new HashMap<>(); |
|||
//用户的部门全路径sid
|
|||
bv.setOrgSidPath("fd6435f2-0005-11ec-a033-48452053aa33/3042d730-64e8-4e34-b08a-44adca4da3a5/548c9469-f5e8-4a1a-b69f-cb54b152c5d1"); |
|||
//业务sid
|
|||
bv.setBusinessSid(dto.getSid()); |
|||
//用户sid
|
|||
bv.setUserSid("0331e5b5-9d60-11ed-87ce-525401028fe7"); |
|||
bv.setFormVariables(variables); |
|||
//若app移动端有此功能,则传递appMap参数
|
|||
Map<String, Object> appMap = new HashMap<>(); |
|||
//需和移动端沟通业务sid保存的属性具体值:appMap中sid不是固定的。移动端提供具体字段。
|
|||
variables.put("money", dto.getMoney()); |
|||
variables.put("app", appMap); |
|||
//流程定义id
|
|||
bv.setModelId(ProcDefEnum.PR.getProDefId()); |
|||
// String nextNodeUserSids_ = "0331e5b5-9d60-11ed-87ce-525401028fe8";//sysOrganization.getManagerSid();
|
|||
// bv.setNextNodeUserSids(nextNodeUserSids_);
|
|||
|
|||
int r = submitBusinessVehicleData(dto); |
|||
if (r == 1) { |
|||
ResultBean<UpdateFlowFieldVo> voResultBean = flowableFeign.startProcess(bv); |
|||
UpdateFlowFieldVo ufVo = voResultBean.getData(); |
|||
updateFlowFiled(BeanUtil.beanToMap(ufVo)); |
|||
try { |
|||
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() |
|||
.setNameFormat("demo-pool-%d").build(); |
|||
ExecutorService pool = new ThreadPoolExecutor(2, 100, |
|||
0L, TimeUnit.MILLISECONDS, |
|||
new LinkedBlockingQueue<Runnable>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
if (r == 2) { |
|||
// ToDo:驳回到发起人后再次提交
|
|||
if (StringUtils.isBlank(dto.getInstanceId())) { |
|||
} |
|||
bv.setTaskId(dto.getTaskId()); |
|||
bv.setTaskDefKey(dto.getTaskDefKey()); |
|||
bv.setComment(com.yxt.common.base.utils.StringUtils.isNotBlank(dto.getComment()) ? dto.getComment() : "重新提交"); |
|||
bv.setInstanceId(dto.getInstanceId()); |
|||
//更新已选择的车架号的状态为审批中
|
|||
complete(bv); |
|||
} |
|||
} |
|||
/** |
|||
* 判断提交的流程是否被允许 |
|||
* |
|||
* @param dto |
|||
* @return |
|||
*/ |
|||
private synchronized int submitBusinessVehicleData(PurchasingRequisitionDto dto ) { |
|||
log.info("PurchasingRequisitionDto:{}", JSONObject.toJSONString(dto)); |
|||
int r = 0; |
|||
if (StringUtils.isBlank(dto.getSid())&&StringUtils.isBlank(dto.getTaskId())) { |
|||
log.info("PurchasingRequisitionDto1:{}", JSONObject.toJSONString(dto)); |
|||
r = 1; |
|||
}else if (StringUtils.isNotBlank(dto.getSid())&&StringUtils.isBlank(dto.getTaskId())){ |
|||
log.info("PurchasingRequisitionDto2:{}", JSONObject.toJSONString(dto)); |
|||
r = 1; |
|||
} else { |
|||
log.info("PurchasingRequisitionDto3:{}", JSONObject.toJSONString(dto)); |
|||
r = 2; |
|||
} |
|||
return r; |
|||
} |
|||
/** |
|||
* 更新流程相关的状态 |
|||
* |
|||
* @param map |
|||
* @return |
|||
*/ |
|||
private int updateFlowFiled(Map<String, Object> map) { |
|||
return baseMapper.updateFlowFiled(map); |
|||
} |
|||
public ResultBean complete(BusinessVariables bv) { |
|||
String userSid = bv.getUserSid(); |
|||
SysUserVo sysUserVo = sysUserService.fetchBySidVo(userSid); |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
PurchasingRequisition pr = fetchBySid(bv.getBusinessSid()); |
|||
Map<String, Object> variables = new HashMap<>(); |
|||
Map<String, Object> appMap = new HashMap<>(); |
|||
variables.put("money", pr.getMoney()); |
|||
variables.put("app", appMap); |
|||
bv.setFormVariables(variables); |
|||
bv.setOrgSidPath(sysUserVo.getOrgSidPath()); |
|||
if (bv.getTaskId().equals(pr.getTaskId())) { |
|||
ResultBean<UpdateFlowFieldVo> resultBean = flowableFeign.handleProsess(bv); |
|||
if (!resultBean.getSuccess()) { |
|||
return rb.setMsg(resultBean.getMsg()); |
|||
} |
|||
UpdateFlowFieldVo ufVo = resultBean.getData(); |
|||
updateFlowFiled(BeanUtil.beanToMap(resultBean.getData())); |
|||
if (!"Event_end".equals(ufVo.getTaskDefKey())) { |
|||
|
|||
} else { |
|||
|
|||
|
|||
} |
|||
return rb.success().setData(resultBean.getData()); |
|||
} else { |
|||
return rb.setMsg("操作失败!提交的数据不一致"); |
|||
} |
|||
} |
|||
public PagerVo<PurchasingRequisitionVo> listPageVo(PagerQuery<PurchasingRequisitionQuery> pq) { |
|||
PurchasingRequisitionQuery query = pq.getParams(); |
|||
QueryWrapper<PurchasingRequisition> qw = createQueryWrapper(query); |
|||
IPage<PurchasingRequisition> page = PagerUtil.queryToPage(pq); |
|||
IPage<PurchasingRequisition> pagging = baseMapper.selectPage(page, qw); |
|||
PagerVo<PurchasingRequisitionVo> p = PagerUtil.pageToVo(pagging, null); |
|||
return p; |
|||
} |
|||
private QueryWrapper<PurchasingRequisition> createQueryWrapper(PurchasingRequisitionQuery query) { |
|||
// todo: 这里根据具体业务调整查询条件
|
|||
// 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
|||
QueryWrapper<PurchasingRequisition> qw = new QueryWrapper<>(); |
|||
qw.orderByDesc("id"); |
|||
return qw; |
|||
} |
|||
|
|||
public PurchasingRequisitionDetailsVo fetchDetailsBySid(String sid) { |
|||
QueryWrapper<PurchasingRequisition> qw = new QueryWrapper<>(); |
|||
qw.eq("sid",sid); |
|||
PurchasingRequisition purchasingRequisition = baseMapper.selectOne(qw); |
|||
PurchasingRequisitionDetailsVo vo=new PurchasingRequisitionDetailsVo(); |
|||
BeanUtil.copyProperties(purchasingRequisition,vo); |
|||
return vo; |
|||
} |
|||
|
|||
public ResultBean<List<GetNodeVo>> getNextNodesForSubmit(GetNodeQuery query) { |
|||
ResultBean<List<GetNodeVo>> rb = ResultBean.fireFail(); |
|||
BusinessVariables bv = new BusinessVariables(); |
|||
BeanUtil.copyProperties(query, bv); |
|||
//流程中的参数赋值、若有网关,则赋值网关中判断的字段。
|
|||
Map<String, Object> variables = new HashMap<>(); |
|||
//根据业务sid查询排产信息
|
|||
PurchasingRequisition pr = fetchBySid(query.getBusinessSid()); |
|||
variables.put("money", pr.getMoney()); |
|||
//判断是否是储备订单,若是,则isTrue网关参数为true=============添加
|
|||
bv.setFormVariables(variables); |
|||
bv.setModelId(ProcDefEnum.PR.getProDefId()); |
|||
ResultBean<List<Map<String, Object>>> resultBean = flowTaskFeign.getNextNodesForSubmit(bv); |
|||
//判断数组是否为空,若为空则赋值,若不为空,则遍历循环将map中的数据赋值给getNodeVo
|
|||
List<GetNodeVo> voList = Optional.ofNullable(resultBean.getData()).orElse(new ArrayList<>()).stream().map(m -> JSON.parseObject(JSON.toJSONString(m), GetNodeVo.class)).collect(Collectors.toList()); |
|||
return rb.success().setData(voList); |
|||
} |
|||
|
|||
public ResultBean revokeProcess(PurchasingRequisitionQuery query) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
if (StringUtils.isBlank(query.getUserSid())) { |
|||
return rb.setMsg("参数错误:userSid"); |
|||
} |
|||
//根据业务sid查询排产申请
|
|||
PurchasingRequisition pr = fetchBySid(query.getBusinessSid()); |
|||
String businessTaskId = pr.getTaskId(); |
|||
if (StringUtils.isNotBlank(businessTaskId)) { |
|||
if (businessTaskId.equals(query.getTaskId())) { |
|||
FlowTaskVo flowTaskVo = new FlowTaskVo(); |
|||
BeanUtil.copyProperties(query, flowTaskVo); |
|||
ResultBean<UpdateFlowFieldVo> resultBean = flowableFeign.revokeProcess(flowTaskVo); |
|||
if (!resultBean.getSuccess()) { |
|||
return rb.setMsg(resultBean.getMsg()); |
|||
} |
|||
updateFlowFiled(BeanUtil.beanToMap(resultBean.getData())); |
|||
return rb.success().setData(resultBean.getData()); |
|||
} |
|||
} |
|||
return rb.setMsg("操作失败,提交的数据不一致!"); |
|||
} |
|||
|
|||
public ResultBean<List<GetNodeVo>> getPreviousNodesForReject(GetNodeQuery query) { |
|||
ResultBean<List<GetNodeVo>> rb = new ResultBean<>(); |
|||
BusinessVariables bv = new BusinessVariables(); |
|||
BeanUtil.copyProperties(query, bv); |
|||
bv.setModelId(ProcDefEnum.PR.getProDefId()); |
|||
ResultBean<List<Map<String, Object>>> resultBean = flowTaskFeign.getPreviousNodesForReject(bv); |
|||
//判断数组是否为空,若为空则赋值,若不为空,则遍历循环将map中的数据赋值给getNodeVo
|
|||
List<GetNodeVo> voList = Optional.ofNullable(resultBean.getData()).orElse(new ArrayList<>()).stream().map(m -> JSON.parseObject(JSON.toJSONString(m), GetNodeVo.class)).collect(Collectors.toList()); |
|||
return rb.success().setData(voList); |
|||
} |
|||
|
|||
public ResultBean taskReject(PurchasingRequisitionQuery query) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
String businessSid = query.getBusinessSid(); |
|||
PurchasingRequisition busVehicleApply = fetchBySid(businessSid); |
|||
if (busVehicleApply == null) { |
|||
return rb.setMsg("该申请不存在"); |
|||
} |
|||
String businessTaskId = busVehicleApply.getTaskId(); |
|||
if (StringUtils.isNotBlank(businessTaskId)) { |
|||
if (businessTaskId.equals(query.getTaskId())) { |
|||
if (StringUtils.isBlank(query.getComment())) { |
|||
return rb.setMsg("请填写意见"); |
|||
} |
|||
if (StringUtils.isBlank(query.getUserSid())) { |
|||
return rb.setMsg("参数错误:userSid"); |
|||
} |
|||
FlowTaskVo flowTaskVo = new FlowTaskVo(); |
|||
BeanUtil.copyProperties(query, flowTaskVo); |
|||
Map<String, Object> variables = new HashMap<>(); |
|||
Map<String, Object> appMap = new HashMap<>(); |
|||
variables.put("app", appMap); |
|||
//根据业务sid查询排产信息
|
|||
variables.put("money", query.getMoney()); |
|||
//判断是否是储备订单,若是,则isTrue网关参数为true=============添加
|
|||
flowTaskVo.setValues(variables); |
|||
ResultBean<UpdateFlowFieldVo> resultBean = flowableFeign.taskReject(flowTaskVo); |
|||
if (!resultBean.getSuccess()) { |
|||
return rb.setMsg(resultBean.getMsg()); |
|||
} |
|||
UpdateFlowFieldVo ufVo = resultBean.getData(); |
|||
Map<String, Object> map = BeanUtil.beanToMap(ufVo); |
|||
//更新业务中的流程相关的参数
|
|||
updateFlowFiled(map); |
|||
//极光推送
|
|||
|
|||
return rb.success(); |
|||
} |
|||
} |
|||
return rb.setMsg("操作失败!提交的数据不一致!"); |
|||
} |
|||
|
|||
/** |
|||
* 终止流程 |
|||
* |
|||
* @param query |
|||
* @return |
|||
*/ |
|||
public ResultBean breakProcess(PurchasingRequisitionQuery query) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
if (StringUtils.isBlank(query.getInstanceId())) { |
|||
return rb.setMsg("参数错误:instanceId"); |
|||
} |
|||
if (StringUtils.isBlank(query.getUserSid())) { |
|||
return rb.setMsg("参数错误:userSid"); |
|||
} |
|||
if (StringUtils.isBlank(query.getComment())) { |
|||
return rb.setMsg("请填写意见"); |
|||
} |
|||
PurchasingRequisition pr = fetchBySid(query.getBusinessSid()); |
|||
String businessTaskId = pr.getTaskId(); |
|||
if (StringUtils.isNotBlank(businessTaskId)) { |
|||
if (businessTaskId.equals(query.getTaskId())) { |
|||
FlowTaskVo flowTaskVo = new FlowTaskVo(); |
|||
BeanUtil.copyProperties(query, flowTaskVo); |
|||
ResultBean<UpdateFlowFieldVo> resultBean = flowableFeign.breakProcess(flowTaskVo); |
|||
if (!resultBean.getSuccess()) { |
|||
return rb.setMsg(resultBean.getMsg()); |
|||
} |
|||
Map<String, Object> map = BeanUtil.beanToMap(resultBean.getData()); |
|||
updateFlowFiled(map); |
|||
return rb.success().setData(resultBean.getData()); |
|||
} |
|||
} |
|||
return rb.setMsg("操作失败!提交的数据不一致!"); |
|||
} |
|||
|
|||
public ResultBean deleteBySids(String[] sids) { |
|||
for (int i = 0; i < sids.length; i++) { |
|||
if (checkCouldChange(sids[i])) { |
|||
return new ResultBean().fail().setMsg("删除的数据中包含已经提交审批的数据,删除失败"); |
|||
} |
|||
deleteBySid(sids[i]); |
|||
} |
|||
return new ResultBean().success().setMsg("删除成功"); |
|||
} |
|||
/** |
|||
* 判断是否可以更改、删除(判断节点状态) |
|||
* |
|||
* @param sid |
|||
* @return |
|||
*/ |
|||
private boolean checkCouldChange(String sid) { |
|||
PurchasingRequisition pr = fetchBySid(sid); |
|||
// 判断是否可以更改(是否走了流程,更改了状态)
|
|||
if (StringUtils.isNotBlank(pr.getNodeState())) { |
|||
return true; |
|||
} |
|||
return false; |
|||
} |
|||
} |
|||
//package com.yxt.supervise.system.purchasingrequisition;
|
|||
//
|
|||
//import cn.hutool.core.bean.BeanUtil;
|
|||
//import cn.hutool.core.date.DateUtil;
|
|||
//import com.alibaba.fastjson.JSON;
|
|||
//import com.alibaba.fastjson.JSONObject;
|
|||
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||
//import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||
//import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
|||
//import com.yxt.anrui.flowable.api.flow.FlowableFeign;
|
|||
//import com.yxt.anrui.flowable.api.flow.UpdateFlowFieldVo;
|
|||
//import com.yxt.anrui.flowable.api.flowtask.FlowTaskFeign;
|
|||
//import com.yxt.anrui.flowable.api.flowtask.FlowTaskVo;
|
|||
//import com.yxt.anrui.flowable.api.flowtask.LatestTaskVo;
|
|||
//import com.yxt.anrui.flowable.api.sysformlink.SysFormLinkFeign;
|
|||
//import com.yxt.anrui.flowable.api.utils.ProcDefEnum;
|
|||
//import com.yxt.anrui.flowable.sqloperationsymbol.BusinessVariables;
|
|||
//import com.yxt.common.base.service.MybatisBaseService;
|
|||
//import com.yxt.common.base.utils.PagerUtil;
|
|||
//import com.yxt.common.core.query.PagerQuery;
|
|||
//import com.yxt.common.core.result.ResultBean;
|
|||
//import com.yxt.common.core.vo.PagerVo;
|
|||
//import com.yxt.supervise.system.flow.GetNodeQuery;
|
|||
//import com.yxt.supervise.system.flow.GetNodeVo;
|
|||
//import com.yxt.supervise.system.region.Region;
|
|||
//import com.yxt.supervise.system.region.RegionListVo;
|
|||
//import com.yxt.supervise.system.sysstaffinfo.SysStaffinfoService;
|
|||
//import com.yxt.supervise.system.sysuser.SysUserService;
|
|||
//import com.yxt.supervise.system.sysuser.SysUserVo;
|
|||
//import lombok.extern.slf4j.Slf4j;
|
|||
//import org.apache.commons.lang3.StringUtils;
|
|||
//import org.apache.tomcat.util.threads.ThreadPoolExecutor;
|
|||
//import org.springframework.beans.factory.annotation.Autowired;
|
|||
//import org.springframework.stereotype.Service;
|
|||
//
|
|||
//import java.util.*;
|
|||
//import java.util.concurrent.*;
|
|||
//import java.util.stream.Collectors;
|
|||
//
|
|||
///**
|
|||
// * @Author dimengzhe
|
|||
// * @Date 2023/1/30 14:24
|
|||
// * @Description
|
|||
// */
|
|||
//@Slf4j
|
|||
//@Service
|
|||
//public class PurchasingRequisitionService extends MybatisBaseService<PurchasingRequisitionMapper, PurchasingRequisition> {
|
|||
//
|
|||
// @Autowired
|
|||
// private FlowTaskFeign flowTaskFeign;
|
|||
//
|
|||
// @Autowired
|
|||
// private FlowableFeign flowableFeign;
|
|||
// @Autowired
|
|||
// private SysStaffinfoService sysStaffinfoService;
|
|||
// @Autowired
|
|||
// private SysUserService sysUserService;
|
|||
// @Autowired
|
|||
// private SysFormLinkFeign sysFormLinkFeign;
|
|||
// public ResultBean saveOrUpdateDto(PurchasingRequisitionDto dto) {
|
|||
// ResultBean rb = ResultBean.fireFail();
|
|||
// String sid = dto.getSid();
|
|||
// if (StringUtils.isBlank(sid)) {
|
|||
// PurchasingRequisition productInformation = new PurchasingRequisition();
|
|||
// BeanUtil.copyProperties(dto, productInformation, "sid");
|
|||
// baseMapper.insert(productInformation);
|
|||
// } else {
|
|||
// PurchasingRequisition productInformation = fetchBySid(sid);
|
|||
// if (productInformation == null) {
|
|||
// return rb.setMsg("该商品档案不存在");
|
|||
// }
|
|||
// BeanUtil.copyProperties(dto, productInformation, "sid");
|
|||
// baseMapper.updateById(productInformation);
|
|||
// }
|
|||
// return rb.success();
|
|||
// }
|
|||
// public ResultBean submit(PurchasingRequisitionDto dto) {
|
|||
// ResultBean rb = ResultBean.fireFail();
|
|||
// String sid = dto.getSid();
|
|||
// String taskid="";
|
|||
// if (StringUtils.isBlank(sid)) {
|
|||
// PurchasingRequisition productInformation = new PurchasingRequisition();
|
|||
// BeanUtil.copyProperties(dto, productInformation, "sid");
|
|||
// dto.setSid(productInformation.getSid());
|
|||
// baseMapper.insert(productInformation);
|
|||
// } else {
|
|||
// PurchasingRequisition productInformation = fetchBySid(sid);
|
|||
// taskid=productInformation.getTaskId();
|
|||
// if (productInformation == null) {
|
|||
// return rb.setMsg("该商品档案不存在");
|
|||
// }
|
|||
// BeanUtil.copyProperties(dto, productInformation, "sid");
|
|||
// baseMapper.updateById(productInformation);
|
|||
// }
|
|||
// if (StringUtils.isBlank(taskid)) {
|
|||
// startProcess(dto);
|
|||
// } else {
|
|||
// PurchasingRequisition pr = fetchBySid(sid);
|
|||
// BusinessVariables bv = new BusinessVariables();
|
|||
// //流程中的参数赋值、若有网关,则赋值网关中判断的字段。
|
|||
// Map<String, Object> variables = new HashMap<>();
|
|||
// //用户的部门全路径sid
|
|||
// bv.setOrgSidPath("fd6435f2-0005-11ec-a033-48452053aa33/3042d730-64e8-4e34-b08a-44adca4da3a5/548c9469-f5e8-4a1a-b69f-cb54b152c5d1");
|
|||
// //业务sid
|
|||
// bv.setBusinessSid(sid);
|
|||
// //用户sid
|
|||
// bv.setUserSid("0331e5b5-9d60-11ed-87ce-525401028fe7");
|
|||
// //若app移动端有此功能,则传递appMap参数
|
|||
// Map<String, Object> appMap = new HashMap<>();
|
|||
// //需和移动端沟通业务sid保存的属性具体值:appMap中sid不是固定的。移动端提供具体字段。
|
|||
// variables.put("app", appMap);
|
|||
// variables.put("money", pr.getMoney());
|
|||
// bv.setFormVariables(variables);
|
|||
// //流程定义id
|
|||
// bv.setModelId(ProcDefEnum.PR.getProDefId());
|
|||
// bv.setTaskId(dto.getTaskId());
|
|||
// bv.setTaskDefKey(pr.getNodeSid());
|
|||
// bv.setComment(com.yxt.common.base.utils.StringUtils.isNotBlank(dto.getComment()) ? dto.getComment() : "重新提交");
|
|||
// bv.setInstanceId(pr.getProcInstSid());
|
|||
// //更新已选择的车架号的状态为审批中
|
|||
// //System.out.println(JSON.toJSONString(bv));
|
|||
// complete(bv);
|
|||
// }
|
|||
// return rb.success();
|
|||
// }
|
|||
//
|
|||
// private void startProcess(PurchasingRequisitionDto dto) {
|
|||
// BusinessVariables bv = new BusinessVariables();
|
|||
// //流程中的参数赋值、若有网关,则赋值网关中判断的字段。
|
|||
// Map<String, Object> variables = new HashMap<>();
|
|||
// //用户的部门全路径sid
|
|||
// bv.setOrgSidPath("fd6435f2-0005-11ec-a033-48452053aa33/3042d730-64e8-4e34-b08a-44adca4da3a5/548c9469-f5e8-4a1a-b69f-cb54b152c5d1");
|
|||
// //业务sid
|
|||
// bv.setBusinessSid(dto.getSid());
|
|||
// //用户sid
|
|||
// bv.setUserSid("0331e5b5-9d60-11ed-87ce-525401028fe7");
|
|||
// bv.setFormVariables(variables);
|
|||
// //若app移动端有此功能,则传递appMap参数
|
|||
// Map<String, Object> appMap = new HashMap<>();
|
|||
// //需和移动端沟通业务sid保存的属性具体值:appMap中sid不是固定的。移动端提供具体字段。
|
|||
// variables.put("money", dto.getMoney());
|
|||
// variables.put("app", appMap);
|
|||
// //流程定义id
|
|||
// bv.setModelId(ProcDefEnum.PR.getProDefId());
|
|||
//// String nextNodeUserSids_ = "0331e5b5-9d60-11ed-87ce-525401028fe8";//sysOrganization.getManagerSid();
|
|||
//// bv.setNextNodeUserSids(nextNodeUserSids_);
|
|||
//
|
|||
// int r = submitBusinessVehicleData(dto);
|
|||
// if (r == 1) {
|
|||
// ResultBean<UpdateFlowFieldVo> voResultBean = flowableFeign.startProcess(bv);
|
|||
// UpdateFlowFieldVo ufVo = voResultBean.getData();
|
|||
// updateFlowFiled(BeanUtil.beanToMap(ufVo));
|
|||
// try {
|
|||
// ThreadFactory namedThreadFactory = new ThreadFactoryBuilder()
|
|||
// .setNameFormat("demo-pool-%d").build();
|
|||
// ExecutorService pool = new ThreadPoolExecutor(2, 100,
|
|||
// 0L, TimeUnit.MILLISECONDS,
|
|||
// new LinkedBlockingQueue<Runnable>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy());
|
|||
// } catch (Exception e) {
|
|||
// e.printStackTrace();
|
|||
// }
|
|||
// }
|
|||
// if (r == 2) {
|
|||
// // ToDo:驳回到发起人后再次提交
|
|||
// if (StringUtils.isBlank(dto.getInstanceId())) {
|
|||
// }
|
|||
// bv.setTaskId(dto.getTaskId());
|
|||
// bv.setTaskDefKey(dto.getTaskDefKey());
|
|||
// bv.setComment(com.yxt.common.base.utils.StringUtils.isNotBlank(dto.getComment()) ? dto.getComment() : "重新提交");
|
|||
// bv.setInstanceId(dto.getInstanceId());
|
|||
// //更新已选择的车架号的状态为审批中
|
|||
// complete(bv);
|
|||
// }
|
|||
// }
|
|||
// /**
|
|||
// * 判断提交的流程是否被允许
|
|||
// *
|
|||
// * @param dto
|
|||
// * @return
|
|||
// */
|
|||
// private synchronized int submitBusinessVehicleData(PurchasingRequisitionDto dto ) {
|
|||
// log.info("PurchasingRequisitionDto:{}", JSONObject.toJSONString(dto));
|
|||
// int r = 0;
|
|||
// if (StringUtils.isBlank(dto.getSid())&&StringUtils.isBlank(dto.getTaskId())) {
|
|||
// log.info("PurchasingRequisitionDto1:{}", JSONObject.toJSONString(dto));
|
|||
// r = 1;
|
|||
// }else if (StringUtils.isNotBlank(dto.getSid())&&StringUtils.isBlank(dto.getTaskId())){
|
|||
// log.info("PurchasingRequisitionDto2:{}", JSONObject.toJSONString(dto));
|
|||
// r = 1;
|
|||
// } else {
|
|||
// log.info("PurchasingRequisitionDto3:{}", JSONObject.toJSONString(dto));
|
|||
// r = 2;
|
|||
// }
|
|||
// return r;
|
|||
// }
|
|||
// /**
|
|||
// * 更新流程相关的状态
|
|||
// *
|
|||
// * @param map
|
|||
// * @return
|
|||
// */
|
|||
// private int updateFlowFiled(Map<String, Object> map) {
|
|||
// return baseMapper.updateFlowFiled(map);
|
|||
// }
|
|||
// public ResultBean complete(BusinessVariables bv) {
|
|||
// String userSid = bv.getUserSid();
|
|||
// SysUserVo sysUserVo = sysUserService.fetchBySidVo(userSid);
|
|||
// ResultBean rb = ResultBean.fireFail();
|
|||
// PurchasingRequisition pr = fetchBySid(bv.getBusinessSid());
|
|||
// Map<String, Object> variables = new HashMap<>();
|
|||
// Map<String, Object> appMap = new HashMap<>();
|
|||
// variables.put("money", pr.getMoney());
|
|||
// variables.put("app", appMap);
|
|||
// bv.setFormVariables(variables);
|
|||
// bv.setOrgSidPath(sysUserVo.getOrgSidPath());
|
|||
// if (bv.getTaskId().equals(pr.getTaskId())) {
|
|||
// ResultBean<UpdateFlowFieldVo> resultBean = flowableFeign.handleProsess(bv);
|
|||
// if (!resultBean.getSuccess()) {
|
|||
// return rb.setMsg(resultBean.getMsg());
|
|||
// }
|
|||
// UpdateFlowFieldVo ufVo = resultBean.getData();
|
|||
// updateFlowFiled(BeanUtil.beanToMap(resultBean.getData()));
|
|||
// if (!"Event_end".equals(ufVo.getTaskDefKey())) {
|
|||
//
|
|||
// } else {
|
|||
//
|
|||
//
|
|||
// }
|
|||
// return rb.success().setData(resultBean.getData());
|
|||
// } else {
|
|||
// return rb.setMsg("操作失败!提交的数据不一致");
|
|||
// }
|
|||
// }
|
|||
// public PagerVo<PurchasingRequisitionVo> listPageVo(PagerQuery<PurchasingRequisitionQuery> pq) {
|
|||
// PurchasingRequisitionQuery query = pq.getParams();
|
|||
// QueryWrapper<PurchasingRequisition> qw = createQueryWrapper(query);
|
|||
// IPage<PurchasingRequisition> page = PagerUtil.queryToPage(pq);
|
|||
// IPage<PurchasingRequisition> pagging = baseMapper.selectPage(page, qw);
|
|||
// PagerVo<PurchasingRequisitionVo> p = PagerUtil.pageToVo(pagging, null);
|
|||
// return p;
|
|||
// }
|
|||
// private QueryWrapper<PurchasingRequisition> createQueryWrapper(PurchasingRequisitionQuery query) {
|
|||
// // todo: 这里根据具体业务调整查询条件
|
|||
// // 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
|||
// QueryWrapper<PurchasingRequisition> qw = new QueryWrapper<>();
|
|||
// qw.orderByDesc("id");
|
|||
// return qw;
|
|||
// }
|
|||
//
|
|||
// public PurchasingRequisitionDetailsVo fetchDetailsBySid(String sid) {
|
|||
// QueryWrapper<PurchasingRequisition> qw = new QueryWrapper<>();
|
|||
// qw.eq("sid",sid);
|
|||
// PurchasingRequisition purchasingRequisition = baseMapper.selectOne(qw);
|
|||
// PurchasingRequisitionDetailsVo vo=new PurchasingRequisitionDetailsVo();
|
|||
// BeanUtil.copyProperties(purchasingRequisition,vo);
|
|||
// return vo;
|
|||
// }
|
|||
//
|
|||
// public ResultBean<List<GetNodeVo>> getNextNodesForSubmit(GetNodeQuery query) {
|
|||
// ResultBean<List<GetNodeVo>> rb = ResultBean.fireFail();
|
|||
// BusinessVariables bv = new BusinessVariables();
|
|||
// BeanUtil.copyProperties(query, bv);
|
|||
// //流程中的参数赋值、若有网关,则赋值网关中判断的字段。
|
|||
// Map<String, Object> variables = new HashMap<>();
|
|||
// //根据业务sid查询排产信息
|
|||
// PurchasingRequisition pr = fetchBySid(query.getBusinessSid());
|
|||
// variables.put("money", pr.getMoney());
|
|||
// //判断是否是储备订单,若是,则isTrue网关参数为true=============添加
|
|||
// bv.setFormVariables(variables);
|
|||
// bv.setModelId(ProcDefEnum.PR.getProDefId());
|
|||
// ResultBean<List<Map<String, Object>>> resultBean = flowTaskFeign.getNextNodesForSubmit(bv);
|
|||
// //判断数组是否为空,若为空则赋值,若不为空,则遍历循环将map中的数据赋值给getNodeVo
|
|||
// List<GetNodeVo> voList = Optional.ofNullable(resultBean.getData()).orElse(new ArrayList<>()).stream().map(m -> JSON.parseObject(JSON.toJSONString(m), GetNodeVo.class)).collect(Collectors.toList());
|
|||
// return rb.success().setData(voList);
|
|||
// }
|
|||
//
|
|||
// public ResultBean revokeProcess(PurchasingRequisitionQuery query) {
|
|||
// ResultBean rb = ResultBean.fireFail();
|
|||
// if (StringUtils.isBlank(query.getUserSid())) {
|
|||
// return rb.setMsg("参数错误:userSid");
|
|||
// }
|
|||
// //根据业务sid查询排产申请
|
|||
// PurchasingRequisition pr = fetchBySid(query.getBusinessSid());
|
|||
// String businessTaskId = pr.getTaskId();
|
|||
// if (StringUtils.isNotBlank(businessTaskId)) {
|
|||
// if (businessTaskId.equals(query.getTaskId())) {
|
|||
// FlowTaskVo flowTaskVo = new FlowTaskVo();
|
|||
// BeanUtil.copyProperties(query, flowTaskVo);
|
|||
// ResultBean<UpdateFlowFieldVo> resultBean = flowableFeign.revokeProcess(flowTaskVo);
|
|||
// if (!resultBean.getSuccess()) {
|
|||
// return rb.setMsg(resultBean.getMsg());
|
|||
// }
|
|||
// updateFlowFiled(BeanUtil.beanToMap(resultBean.getData()));
|
|||
// return rb.success().setData(resultBean.getData());
|
|||
// }
|
|||
// }
|
|||
// return rb.setMsg("操作失败,提交的数据不一致!");
|
|||
// }
|
|||
//
|
|||
// public ResultBean<List<GetNodeVo>> getPreviousNodesForReject(GetNodeQuery query) {
|
|||
// ResultBean<List<GetNodeVo>> rb = new ResultBean<>();
|
|||
// BusinessVariables bv = new BusinessVariables();
|
|||
// BeanUtil.copyProperties(query, bv);
|
|||
// bv.setModelId(ProcDefEnum.PR.getProDefId());
|
|||
// ResultBean<List<Map<String, Object>>> resultBean = flowTaskFeign.getPreviousNodesForReject(bv);
|
|||
// //判断数组是否为空,若为空则赋值,若不为空,则遍历循环将map中的数据赋值给getNodeVo
|
|||
// List<GetNodeVo> voList = Optional.ofNullable(resultBean.getData()).orElse(new ArrayList<>()).stream().map(m -> JSON.parseObject(JSON.toJSONString(m), GetNodeVo.class)).collect(Collectors.toList());
|
|||
// return rb.success().setData(voList);
|
|||
// }
|
|||
//
|
|||
// public ResultBean taskReject(PurchasingRequisitionQuery query) {
|
|||
// ResultBean rb = ResultBean.fireFail();
|
|||
// String businessSid = query.getBusinessSid();
|
|||
// PurchasingRequisition busVehicleApply = fetchBySid(businessSid);
|
|||
// if (busVehicleApply == null) {
|
|||
// return rb.setMsg("该申请不存在");
|
|||
// }
|
|||
// String businessTaskId = busVehicleApply.getTaskId();
|
|||
// if (StringUtils.isNotBlank(businessTaskId)) {
|
|||
// if (businessTaskId.equals(query.getTaskId())) {
|
|||
// if (StringUtils.isBlank(query.getComment())) {
|
|||
// return rb.setMsg("请填写意见");
|
|||
// }
|
|||
// if (StringUtils.isBlank(query.getUserSid())) {
|
|||
// return rb.setMsg("参数错误:userSid");
|
|||
// }
|
|||
// FlowTaskVo flowTaskVo = new FlowTaskVo();
|
|||
// BeanUtil.copyProperties(query, flowTaskVo);
|
|||
// Map<String, Object> variables = new HashMap<>();
|
|||
// Map<String, Object> appMap = new HashMap<>();
|
|||
// variables.put("app", appMap);
|
|||
// //根据业务sid查询排产信息
|
|||
// variables.put("money", query.getMoney());
|
|||
// //判断是否是储备订单,若是,则isTrue网关参数为true=============添加
|
|||
// flowTaskVo.setValues(variables);
|
|||
// ResultBean<UpdateFlowFieldVo> resultBean = flowableFeign.taskReject(flowTaskVo);
|
|||
// if (!resultBean.getSuccess()) {
|
|||
// return rb.setMsg(resultBean.getMsg());
|
|||
// }
|
|||
// UpdateFlowFieldVo ufVo = resultBean.getData();
|
|||
// Map<String, Object> map = BeanUtil.beanToMap(ufVo);
|
|||
// //更新业务中的流程相关的参数
|
|||
// updateFlowFiled(map);
|
|||
// //极光推送
|
|||
//
|
|||
// return rb.success();
|
|||
// }
|
|||
// }
|
|||
// return rb.setMsg("操作失败!提交的数据不一致!");
|
|||
// }
|
|||
//
|
|||
// /**
|
|||
// * 终止流程
|
|||
// *
|
|||
// * @param query
|
|||
// * @return
|
|||
// */
|
|||
// public ResultBean breakProcess(PurchasingRequisitionQuery query) {
|
|||
// ResultBean rb = ResultBean.fireFail();
|
|||
// if (StringUtils.isBlank(query.getInstanceId())) {
|
|||
// return rb.setMsg("参数错误:instanceId");
|
|||
// }
|
|||
// if (StringUtils.isBlank(query.getUserSid())) {
|
|||
// return rb.setMsg("参数错误:userSid");
|
|||
// }
|
|||
// if (StringUtils.isBlank(query.getComment())) {
|
|||
// return rb.setMsg("请填写意见");
|
|||
// }
|
|||
// PurchasingRequisition pr = fetchBySid(query.getBusinessSid());
|
|||
// String businessTaskId = pr.getTaskId();
|
|||
// if (StringUtils.isNotBlank(businessTaskId)) {
|
|||
// if (businessTaskId.equals(query.getTaskId())) {
|
|||
// FlowTaskVo flowTaskVo = new FlowTaskVo();
|
|||
// BeanUtil.copyProperties(query, flowTaskVo);
|
|||
// ResultBean<UpdateFlowFieldVo> resultBean = flowableFeign.breakProcess(flowTaskVo);
|
|||
// if (!resultBean.getSuccess()) {
|
|||
// return rb.setMsg(resultBean.getMsg());
|
|||
// }
|
|||
// Map<String, Object> map = BeanUtil.beanToMap(resultBean.getData());
|
|||
// updateFlowFiled(map);
|
|||
// return rb.success().setData(resultBean.getData());
|
|||
// }
|
|||
// }
|
|||
// return rb.setMsg("操作失败!提交的数据不一致!");
|
|||
// }
|
|||
//
|
|||
// public ResultBean deleteBySids(String[] sids) {
|
|||
// for (int i = 0; i < sids.length; i++) {
|
|||
// if (checkCouldChange(sids[i])) {
|
|||
// return new ResultBean().fail().setMsg("删除的数据中包含已经提交审批的数据,删除失败");
|
|||
// }
|
|||
// deleteBySid(sids[i]);
|
|||
// }
|
|||
// return new ResultBean().success().setMsg("删除成功");
|
|||
// }
|
|||
// /**
|
|||
// * 判断是否可以更改、删除(判断节点状态)
|
|||
// *
|
|||
// * @param sid
|
|||
// * @return
|
|||
// */
|
|||
// private boolean checkCouldChange(String sid) {
|
|||
// PurchasingRequisition pr = fetchBySid(sid);
|
|||
// // 判断是否可以更改(是否走了流程,更改了状态)
|
|||
// if (StringUtils.isNotBlank(pr.getNodeState())) {
|
|||
// return true;
|
|||
// }
|
|||
// return false;
|
|||
// }
|
|||
//}
|
|||
|
Loading…
Reference in new issue