|
@@ -0,0 +1,106 @@
|
|
|
+package com.ym.mec.education.service.impl;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.ym.mec.education.base.BaseResponse;
|
|
|
+import com.ym.mec.education.base.PageResponse;
|
|
|
+import com.ym.mec.education.entity.SysUser;
|
|
|
+import com.ym.mec.education.enums.ApprovalStatusEnum;
|
|
|
+import com.ym.mec.education.req.ApprovalReq;
|
|
|
+import com.ym.mec.education.resp.ApprovalResp;
|
|
|
+import com.ym.mec.education.service.ApprovalService;
|
|
|
+import com.ym.mec.education.service.ISysUserService;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.snaker.engine.IQueryService;
|
|
|
+import org.snaker.engine.access.Page;
|
|
|
+import org.snaker.engine.access.QueryFilter;
|
|
|
+import org.snaker.engine.entity.WorkItem;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.Optional;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @program: mec
|
|
|
+ * @description: 教务审批
|
|
|
+ * @author: xw
|
|
|
+ * @create: 2019-10-11 15:35
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class ApprovalServiceImpl implements ApprovalService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IQueryService queryService;
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService userService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageResponse<ApprovalResp> getProcessingList(ApprovalReq approvalReq) {
|
|
|
+ if (Objects.isNull(approvalReq.getUserId())) {
|
|
|
+ return PageResponse.errorParam();
|
|
|
+ }
|
|
|
+ Page<WorkItem> page = new Page();
|
|
|
+ page.setPageNo(approvalReq.getPageNo());
|
|
|
+ page.setPageSize(approvalReq.getPageSize());
|
|
|
+ QueryFilter queryFilter = new QueryFilter();
|
|
|
+ queryFilter.setOperator(approvalReq.getUserId().toString());
|
|
|
+ queryService.getWorkItems(page, queryFilter);
|
|
|
+ return PageResponse.success(workItem2Approval(page));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageResponse<ApprovalResp> getProcessedList(ApprovalReq approvalReq) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageResponse<ApprovalResp> getLaunchList(ApprovalReq approvalReq) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public BaseResponse<ApprovalResp> getLaunchInfo(ApprovalReq approvalReq) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public BaseResponse<ApprovalResp> cancel(ApprovalReq approvalReq) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageResponse<ApprovalResp> getCcList(ApprovalReq approvalReq) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Page<ApprovalResp> workItem2Approval(Page<WorkItem> page) {
|
|
|
+ Page<ApprovalResp> pageResult = new Page();
|
|
|
+ BeanUtils.copyProperties(page, pageResult);
|
|
|
+ List<ApprovalResp> list = new ArrayList<>(page.getResult().size());
|
|
|
+ if (!CollectionUtils.isEmpty(page.getResult())) {
|
|
|
+ page.getResult().forEach(item -> {
|
|
|
+ ApprovalResp approvalResp = new ApprovalResp();
|
|
|
+ SysUser user = userService.getById(item.getCreator());
|
|
|
+ Optional.ofNullable(user.getRealName()).ifPresent(name -> approvalResp.setApplicant(name));
|
|
|
+ String orderVariable = item.getOrderVariable();
|
|
|
+ if (StringUtils.isNotBlank(orderVariable)) {
|
|
|
+ JSONObject jsonObject = JSON.parseObject(orderVariable);
|
|
|
+ approvalResp.setStatus(ApprovalStatusEnum.getMsgByCode(jsonObject.getString("status")));
|
|
|
+ Optional.ofNullable(jsonObject.getString("startTime")).ifPresent(time -> approvalResp.setStartTime(time));
|
|
|
+ Optional.ofNullable(jsonObject.getString("endTime")).ifPresent(time -> approvalResp.setEndTime(time));
|
|
|
+ Optional.ofNullable(jsonObject.getString("remark")).ifPresent(remark -> approvalResp.setRemark(remark));
|
|
|
+ }
|
|
|
+ approvalResp.setTaskId(item.getTaskId()).setApprovalType(item.getTaskName())
|
|
|
+ .setApprovalDate(item.getOrderCreateTime());
|
|
|
+ list.add(approvalResp);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ pageResult.setResult(list);
|
|
|
+ return pageResult;
|
|
|
+ }
|
|
|
+}
|