|
@@ -0,0 +1,307 @@
|
|
|
+package com.jeeplus.sys.utils;
|
|
|
+
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.util.ArrayUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.jeeplus.sys.dto.reimbursement.ReimbursementAmountInfo;
|
|
|
+import com.jeeplus.sys.dto.reimbursement.ReimbursementDetailInfo;
|
|
|
+import com.jeeplus.sys.dto.reimbursement.SaveInfoDto;
|
|
|
+import com.jeeplus.sys.dto.reimbursement.WorkAttachmentDto;
|
|
|
+import com.jeeplus.sys.service.dto.UserDTO;
|
|
|
+import com.jeeplus.sys.vo.ProcessVo;
|
|
|
+import com.jeeplus.sys.vo.TaskVo;
|
|
|
+
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+public class ConvertServiceUtil {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量将ccpm系统待办返回的字段转换为当前系统待办需要的字段
|
|
|
+ * @param res
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static List<ProcessVo> convertProcessVoList(List<Map<String, Object>> res) throws Exception {
|
|
|
+ ArrayList<ProcessVo> processVoList = new ArrayList<>();
|
|
|
+ String ccpm_task = Global.getConfig("CCPM_TASK"); // 获取ccpm可查看的待办数据
|
|
|
+ if (StringUtils.isNotBlank(ccpm_task)) {
|
|
|
+ String[] taskAliasList = ccpm_task.split(","); // 获取到ccpm待办
|
|
|
+ if(CollectionUtil.isNotEmpty(res) && ArrayUtil.isNotEmpty(taskAliasList)) {
|
|
|
+ String[] distinctTaskAlias = ArrayUtil.distinct(taskAliasList); // ccpm待办去重
|
|
|
+ for (Map<String, Object> item : res) {
|
|
|
+ for (String taskAlias : distinctTaskAlias) {
|
|
|
+ if (taskAlias.equals(item.get("type").toString()) && item.get("remarks").toString().contains("待审批")) {
|
|
|
+ ProcessVo processVo = convertProcessVo(item);
|
|
|
+ processVoList.add(processVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return processVoList;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * ccpm系统待办返回的字段转换为当前系统待办需要的字段
|
|
|
+ * @param map
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static ProcessVo convertProcessVo(Map<String, Object> map) throws Exception {
|
|
|
+ ProcessVo processVo = new ProcessVo();
|
|
|
+ Map<String, String> vars = new HashMap();
|
|
|
+ TaskVo task = new TaskVo();
|
|
|
+ if (CollectionUtil.isNotEmpty(map)) {
|
|
|
+ // 标题
|
|
|
+ if (Objects.nonNull(map.get("title"))){
|
|
|
+ vars.put("title", map.get("title").toString());
|
|
|
+ }
|
|
|
+ // 流程名称
|
|
|
+ if (Objects.nonNull(map.get("typeLabel"))){
|
|
|
+ processVo.setProcessDefinitionName(map.get("typeLabel").toString());
|
|
|
+ }
|
|
|
+ // 当前环节
|
|
|
+ if (Objects.nonNull(map.get("notifyRole"))){
|
|
|
+ task.setName(map.get("notifyRole").toString());
|
|
|
+ }
|
|
|
+ // 流程发起人
|
|
|
+ if (Objects.nonNull(map.get("createUserName"))){
|
|
|
+ vars.put("userName", map.get("createUserName").toString());
|
|
|
+ }
|
|
|
+ // 创建时间
|
|
|
+ if (Objects.nonNull(map.get("createDate"))){
|
|
|
+ task.setCreateTime((new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).parse(map.get("createDate").toString()));
|
|
|
+ }
|
|
|
+ // 流程id
|
|
|
+ if (Objects.nonNull(map.get("id"))){
|
|
|
+ task.setId(map.get("id").toString());
|
|
|
+ }
|
|
|
+ // 数据id
|
|
|
+ if (Objects.nonNull(map.get("notifyId"))){
|
|
|
+ vars.put("notifyId", map.get("notifyId").toString());
|
|
|
+ }
|
|
|
+ // 审批状态
|
|
|
+ if (Objects.nonNull(map.get("remarks"))){
|
|
|
+ vars.put("remarks", map.get("remarks").toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ processVo.setVars(vars);
|
|
|
+ processVo.setTask(task);
|
|
|
+ processVo.setBelongProject("ccpm");
|
|
|
+ processVo.setStatus ("todo");
|
|
|
+ return processVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将结果排序后分页
|
|
|
+ * 由于是根据数据中的creaTime字段来进行排序,所以此字段不可以为空,否则会报空指针
|
|
|
+ * @param page
|
|
|
+ * @param list
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static Page getSortAndPaging(Page page,List<ProcessVo> list) {
|
|
|
+ // 将数据按照creaTime倒序排序
|
|
|
+ List<ProcessVo> sort = CollectionUtil.sort(list, new Comparator<ProcessVo>() {
|
|
|
+ @Override
|
|
|
+ public int compare(ProcessVo o1, ProcessVo o2) {
|
|
|
+ return o2.getTask().getCreateTime().compareTo(o1.getTask().getCreateTime());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 将数据分页
|
|
|
+ page.setTotal(list.size());
|
|
|
+ List<ProcessVo> records = new ArrayList<>();
|
|
|
+ int startIndex = (int) ((page.getCurrent() - 1) * page.getSize());
|
|
|
+ for (int i = 0; i < page.getSize() ; i ++) {
|
|
|
+ if (startIndex == list.size() || ObjectUtil.isEmpty(list.get(startIndex))) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ records.add(list.get(startIndex));
|
|
|
+ startIndex++;
|
|
|
+ }
|
|
|
+ page.setRecords(records);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * ccpm报销转换
|
|
|
+ * @param response
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static SaveInfoDto convertReim(Object response) {
|
|
|
+ SaveInfoDto result = new SaveInfoDto();
|
|
|
+ if (Objects.nonNull(response)) {
|
|
|
+ Map<String, Object> resp = JSONObject.parseObject(JSON.toJSONString(response));
|
|
|
+ if (CollectionUtil.isNotEmpty(resp)) {
|
|
|
+ // processInstanceId
|
|
|
+ if (ObjectUtil.isNotEmpty(resp.get("processInstanceId"))) {
|
|
|
+ result.setProcInsId(resp.get("processInstanceId").toString());
|
|
|
+ }
|
|
|
+ // 经办人
|
|
|
+ if (ObjectUtil.isNotEmpty(resp.get("submitterName"))) { // 报销人
|
|
|
+ result.setUserName(resp.get("submitterName").toString());
|
|
|
+ }
|
|
|
+ // 报销编号
|
|
|
+ if (ObjectUtil.isNotEmpty(resp.get("number"))) { // 报销编号
|
|
|
+ result.setNo(resp.get("number").toString());
|
|
|
+ }
|
|
|
+ // 所属部门
|
|
|
+ if (ObjectUtil.isNotEmpty(resp.get("officeName"))) { // 所属部门
|
|
|
+ result.setDepartmentName(resp.get("officeName").toString());
|
|
|
+ }
|
|
|
+ // 报销日期
|
|
|
+ if (ObjectUtil.isNotEmpty(resp.get("createDate"))) { // 报销日期、创建时间
|
|
|
+ result.setReimDate(DateUtil.parse(resp.get("createDate").toString()));
|
|
|
+ }
|
|
|
+ // 备注
|
|
|
+ if (ObjectUtil.isNotEmpty(resp.get("remarks"))) { // 备注
|
|
|
+ result.setRemarks(resp.get("remarks").toString());
|
|
|
+ }
|
|
|
+ // 附件
|
|
|
+ if (ObjectUtil.isNotEmpty(resp.get("workAttachments"))) {
|
|
|
+ String jsonString = JSON.toJSONString(resp.get("workAttachments"));
|
|
|
+ List<Object> attachmentList = JSON.parseArray(jsonString, Object.class);
|
|
|
+ List<WorkAttachmentDto> attachments = new ArrayList<>();
|
|
|
+ if (CollectionUtil.isNotEmpty(attachmentList)) {
|
|
|
+ attachmentList.stream().forEach(attachment -> {
|
|
|
+ WorkAttachmentDto attachmentDto = new WorkAttachmentDto();
|
|
|
+ UserDTO userDTO = new UserDTO();
|
|
|
+ Map<String, Object> fileMap = JSONObject.parseObject(JSON.toJSONString(attachment));
|
|
|
+ if (ObjectUtil.isNotEmpty(fileMap.get("attachmentName"))) { // 附件名称
|
|
|
+ attachmentDto.setName(fileMap.get("attachmentName").toString());
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(fileMap.get("createName"))) { // 创建人
|
|
|
+ userDTO.setName(fileMap.get("createName").toString());
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(fileMap.get("createDate"))) { // 创建时间
|
|
|
+ attachmentDto.setCreateDate(DateUtil.parse(fileMap.get("createDate").toString()));
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(fileMap.get("url"))) { // 文件地址
|
|
|
+ attachmentDto.setUrl(fileMap.get("url").toString());
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(fileMap.get("temporaryUrl"))) { // 文件临时地址
|
|
|
+ attachmentDto.setLsUrl(fileMap.get("temporaryUrl").toString());
|
|
|
+ }
|
|
|
+ attachmentDto.setCreateBy(userDTO);
|
|
|
+ attachments.add(attachmentDto);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ result.setFiles(attachments);
|
|
|
+ }
|
|
|
+ // 专用发票信息
|
|
|
+ if (ObjectUtil.isNotEmpty(resp.get("reimbursementVATTaxes"))) {
|
|
|
+ String jsonString = JSON.toJSONString(resp.get("reimbursementVATTaxes"));
|
|
|
+ List<Object> reimVATTaxeList = JSON.parseArray(jsonString, Object.class);
|
|
|
+ List<ReimbursementAmountInfo> reimbursementAmountInfoList = new ArrayList<>();
|
|
|
+ if (CollectionUtil.isNotEmpty(reimVATTaxeList)) {
|
|
|
+ reimVATTaxeList.stream().forEach(reim -> {
|
|
|
+ ReimbursementAmountInfo reimbursementAmountInfo = new ReimbursementAmountInfo();
|
|
|
+ Map<String, Object> vaTaxeMap = JSONObject.parseObject(JSON.toJSONString(reim));
|
|
|
+ if (ObjectUtil.isNotEmpty(vaTaxeMap.get("invoiceCode"))) { // 发票代码
|
|
|
+ reimbursementAmountInfo.setCode(vaTaxeMap.get("invoiceCode").toString());
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(vaTaxeMap.get("invoiceNumber"))) { // 发票号
|
|
|
+ reimbursementAmountInfo.setNumber(vaTaxeMap.get("invoiceNumber").toString());
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(vaTaxeMap.get("money"))) { // 金额
|
|
|
+ reimbursementAmountInfo.setAmount(vaTaxeMap.get("money").toString());
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(vaTaxeMap.get("taxAmount"))) { // 税额
|
|
|
+ reimbursementAmountInfo.setTaxAmount(vaTaxeMap.get("taxAmount").toString());
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(vaTaxeMap.get("sumMoney"))) { // 价税合计
|
|
|
+ reimbursementAmountInfo.setCount(vaTaxeMap.get("sumMoney").toString());
|
|
|
+ }
|
|
|
+ reimbursementAmountInfoList.add(reimbursementAmountInfo);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ result.setAmountInfos(reimbursementAmountInfoList);
|
|
|
+ }
|
|
|
+ // 报销详情
|
|
|
+ if (ObjectUtil.isNotEmpty(resp.get("workAccountList"))) {
|
|
|
+ String jsonString = JSON.toJSONString(resp.get("workAccountList"));
|
|
|
+ List<Object> workAccountList = JSON.parseArray(jsonString, Object.class);
|
|
|
+ List<ReimbursementDetailInfo> reimbursementDetailInfos = new ArrayList<>();
|
|
|
+ if (CollectionUtil.isNotEmpty(workAccountList)) {
|
|
|
+ workAccountList.stream().forEach(detail -> {
|
|
|
+ Map<String, Object> detailMap = JSONObject.parseObject(JSON.toJSONString(detail));
|
|
|
+ ReimbursementDetailInfo detailInfo = new ReimbursementDetailInfo();
|
|
|
+ if (ObjectUtil.isNotEmpty(detailMap.get("reimbursementName"))) { // 报销人
|
|
|
+ detailInfo.setUserName(detailMap.get("reimbursementName").toString());
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(detailMap.get("officeId"))) { // 报销部门
|
|
|
+ detailInfo.setDeptName(detailMap.get("officeId").toString());
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(detailMap.get("typeName"))) { // 报销类别
|
|
|
+ detailInfo.setTypeName(detailMap.get("typeName").toString());
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(detailMap.get("project"))) { // 报销项目
|
|
|
+ Map<String, Object> projectMap = JSONObject.parseObject(JSON.toJSONString(detailMap.get("project")));
|
|
|
+ if (ObjectUtil.isNotEmpty(projectMap.get("projectName"))) {
|
|
|
+ detailInfo.setProjectName(projectMap.get("projectName").toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(detailMap.get("projectReportNumber"))) { // 报告号
|
|
|
+ detailInfo.setReportNumber(detailMap.get("projectReportNumber").toString());
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(detailMap.get("money"))) { // 费用(元)
|
|
|
+ detailInfo.setNumber(detailMap.get("money").toString());
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(detailMap.get("bills"))) { // 收据张数
|
|
|
+ detailInfo.setReceiptNumbers(detailMap.get("bills").toString());
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(detailMap.get("evectionNumber"))) { // 出差天数
|
|
|
+ detailInfo.setEvectionNumber(detailMap.get("evectionNumber").toString());
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(detailMap.get("remarks"))) { // 内容
|
|
|
+ detailInfo.setContent(detailMap.get("remarks").toString());
|
|
|
+ }
|
|
|
+ reimbursementDetailInfos.add(detailInfo);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ result.setDetailInfos(reimbursementDetailInfos);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * ccpm流程历史转换
|
|
|
+ * @param list
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static List<Map<String,Object>> convertHisFlowList(List<Map<String, Object>> list) {
|
|
|
+ if (CollectionUtil.isNotEmpty(list)) {
|
|
|
+ list.stream().forEach(item -> {
|
|
|
+ // beginDate日期格式化后重新赋值
|
|
|
+ if (Objects.nonNull(item.get("beginDate"))) {
|
|
|
+ Long beginDate = Long.valueOf(String.valueOf(item.get("beginDate")));
|
|
|
+ item.remove("beginDate");
|
|
|
+ item.put("beginDate",formatLongDate(beginDate));
|
|
|
+ }
|
|
|
+ // endDate日期格式化后重新赋值
|
|
|
+ if (Objects.nonNull(item.get("endDate"))) {
|
|
|
+ Long beginDate = Long.valueOf(String.valueOf(item.get("endDate")));
|
|
|
+ item.remove("endDate");
|
|
|
+ item.put("endDate",formatLongDate(beginDate));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将Long类型时间转换为String时间格式
|
|
|
+ * @param date
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static String formatLongDate (Long date) {
|
|
|
+ Date dt=new Date(date);
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
|
|
|
+ String format = sdf.format(dt);
|
|
|
+ return format;
|
|
|
+ }
|
|
|
+}
|