|
|
@@ -0,0 +1,116 @@
|
|
|
+package com.java110.common.cmd.itemRelease;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.java110.core.annotation.Java110Cmd;
|
|
|
+import com.java110.core.context.ICmdDataFlowContext;
|
|
|
+import com.java110.core.event.cmd.Cmd;
|
|
|
+import com.java110.core.event.cmd.CmdEvent;
|
|
|
+import com.java110.dto.itemRelease.ItemReleaseDto;
|
|
|
+import com.java110.dto.oaWorkflow.OaWorkflowDto;
|
|
|
+import com.java110.dto.workflow.WorkflowDto;
|
|
|
+import com.java110.entity.audit.AuditUser;
|
|
|
+import com.java110.intf.common.IItemReleaseV1InnerServiceSMO;
|
|
|
+import com.java110.intf.common.IOaWorkflowUserInnerServiceSMO;
|
|
|
+import com.java110.intf.oa.IOaWorkflowInnerServiceSMO;
|
|
|
+import com.java110.utils.exception.CmdException;
|
|
|
+import com.java110.utils.util.BeanConvertUtil;
|
|
|
+import com.java110.vo.ResultVo;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
+
|
|
|
+import java.text.ParseException;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 查询物品放行已办单
|
|
|
+ */
|
|
|
+@Java110Cmd(serviceCode = "itemRelease.queryFinishItemRelease")
|
|
|
+public class QueryFinishItemReleaseCmd extends Cmd {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IOaWorkflowUserInnerServiceSMO oaWorkflowUserInnerServiceSMOImpl;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IOaWorkflowInnerServiceSMO oaWorkflowInnerServiceSMOImpl;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IItemReleaseV1InnerServiceSMO itemReleaseV1InnerServiceSMOImpl;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
|
|
|
+ super.validatePageInfo(reqJson);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
|
|
|
+ String userId = context.getReqHeaders().get("user-id");
|
|
|
+ String storeId = context.getReqHeaders().get("store-id");
|
|
|
+
|
|
|
+ OaWorkflowDto oaWorkflowDto = new OaWorkflowDto();
|
|
|
+ oaWorkflowDto.setState(OaWorkflowDto.STATE_COMPLAINT);
|
|
|
+ oaWorkflowDto.setFlowType(OaWorkflowDto.FLOW_TYPE_ITEM_RELEASE);
|
|
|
+ List<OaWorkflowDto> oaWorkflowDtos = oaWorkflowInnerServiceSMOImpl.queryOaWorkflows(oaWorkflowDto);
|
|
|
+
|
|
|
+ if (oaWorkflowDtos == null || oaWorkflowDtos.size() < 1) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<String> flowIds = new ArrayList<>();
|
|
|
+ for (OaWorkflowDto tmpOaWorkflowDto : oaWorkflowDtos) {
|
|
|
+ flowIds.add(WorkflowDto.DEFAULT_PROCESS + tmpOaWorkflowDto.getFlowId());
|
|
|
+ }
|
|
|
+
|
|
|
+ AuditUser auditUser = new AuditUser();
|
|
|
+ auditUser.setProcessDefinitionKeys(flowIds);
|
|
|
+ auditUser.setUserId(userId);
|
|
|
+ auditUser.setStoreId(storeId);
|
|
|
+ auditUser.setPage(reqJson.getInteger("page"));
|
|
|
+ auditUser.setRow(reqJson.getInteger("row"));
|
|
|
+
|
|
|
+ long count = oaWorkflowUserInnerServiceSMOImpl.getDefinitionKeysUserHistoryTaskCount(auditUser);
|
|
|
+
|
|
|
+ List<JSONObject> datas = null;
|
|
|
+
|
|
|
+ if (count > 0) {
|
|
|
+ datas = oaWorkflowUserInnerServiceSMOImpl.getDefinitionKeysUserHistoryTasks(auditUser);
|
|
|
+ //刷新 表单数据
|
|
|
+ refreshFormData(datas, reqJson);
|
|
|
+ } else {
|
|
|
+ datas = new ArrayList<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reqJson.getInteger("row")), count, datas);
|
|
|
+
|
|
|
+ ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
|
|
|
+ context.setResponseEntity(responseEntity);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void refreshFormData(List<JSONObject> datas, JSONObject paramIn) {
|
|
|
+
|
|
|
+ List<String> ids = new ArrayList<>();
|
|
|
+ for (JSONObject data : datas) {
|
|
|
+ ids.add(data.getString("id"));
|
|
|
+ }
|
|
|
+ if (ids.size() < 1) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ ItemReleaseDto itemReleaseDto = new ItemReleaseDto();
|
|
|
+ itemReleaseDto.setIrIds(ids.toArray(new String[ids.size()]));
|
|
|
+ List<ItemReleaseDto> itemReleaseDtos = itemReleaseV1InnerServiceSMOImpl.queryItemReleases(itemReleaseDto);
|
|
|
+ if (itemReleaseDtos == null || itemReleaseDtos.size() < 1) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (JSONObject data : datas) {
|
|
|
+ for (ItemReleaseDto form : itemReleaseDtos) {
|
|
|
+ if (data.getString("id").equals(form.getIrId())) {
|
|
|
+ data.putAll(BeanConvertUtil.beanCovertJson(form));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|