|
|
@@ -0,0 +1,612 @@
|
|
|
+package com.yw.contract.client.action;
|
|
|
+
|
|
|
+import com.yw.bpm.core.model.ProcessResult;
|
|
|
+import com.yw.bpm.core.service.CoreService;
|
|
|
+import com.yw.contract.common.sync.mes.MesCommonHelper;
|
|
|
+import com.yw.contract.paymentApply.model.Account;
|
|
|
+import com.yw.contract.paymentApply.model.PaymentApply;
|
|
|
+import com.yw.contract.paymentApply.service.AccountService;
|
|
|
+import com.yw.contract.paymentApply.service.PaymentApplyService;
|
|
|
+import com.yw.core.clientImpl.model.ResultVo;
|
|
|
+import com.yw.core.clientImpl.service.RequestAbs;
|
|
|
+import com.yw.core.session.AppSession;
|
|
|
+import com.yw.core.session.OASession;
|
|
|
+import com.yw.core.utils.DateUtil;
|
|
|
+import com.yw.core.utils.ParameterHelper;
|
|
|
+import com.yw.core.utils.StringUtil;
|
|
|
+import com.yw.eu.base.code.service.CodeRuleService;
|
|
|
+import com.yw.eu.base.user.model.Group;
|
|
|
+import com.yw.eu.base.user.model.GroupXUser;
|
|
|
+import com.yw.eu.base.user.model.User;
|
|
|
+import com.yw.eu.base.user.service.UserService;
|
|
|
+import net.sf.json.JSONArray;
|
|
|
+import net.sf.json.JSONObject;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.springframework.context.ApplicationContext;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 小程序端付款申请流程发起相关接口
|
|
|
+ */
|
|
|
+public class PaymentApplyMiniAppAction extends RequestAbs {
|
|
|
+ public final String serviceId = "miniapp_paymentApply";
|
|
|
+ private ApplicationContext cxt = null;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getResult() {
|
|
|
+ String param = getParameters();
|
|
|
+ JSONObject json = JSONObject.fromObject(param);
|
|
|
+ String task = json.getString("task");
|
|
|
+
|
|
|
+ if (null == cxt) {
|
|
|
+ cxt = AppSession.getApplicationContext();
|
|
|
+ }
|
|
|
+
|
|
|
+ ResultVo rv = null;
|
|
|
+ try {
|
|
|
+ if ("getInitData".equals(task)) {
|
|
|
+ rv = getInitData(json);
|
|
|
+ } else if ("startPaymentApply".equals(task)) {
|
|
|
+ rv = startPaymentApply(json);
|
|
|
+ } else if ("getPaymentFormData".equals(task)) {
|
|
|
+ rv = getPaymentFormData(json);
|
|
|
+ } else if ("getPaymentDataByInsId".equals(task)) {
|
|
|
+ rv = getPaymentDataByInsId(json);
|
|
|
+ } else if ("selectSupplier".equals(task)) {
|
|
|
+ rv = selectSupplier(json);
|
|
|
+ } else if ("selectContract".equals(task)) {
|
|
|
+ rv = selectContract(json);
|
|
|
+ } else if ("selectPurchaseOrder".equals(task)) {
|
|
|
+ rv = selectPurchaseOrder(json);
|
|
|
+ } else if ("selectStorageOrder".equals(task)) {
|
|
|
+ rv = selectStorageOrder(json);
|
|
|
+ } else {
|
|
|
+ rv = new ResultVo();
|
|
|
+ rv.setReturnCode("-1");
|
|
|
+ rv.setReturnMsg("未知操作:" + task);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ rv = new ResultVo();
|
|
|
+ rv.setReturnCode("-1");
|
|
|
+ rv.setReturnMsg("操作失败:" + e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return JSONObject.fromObject(rv, config).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取初始化数据(申请人信息、默认账户等)
|
|
|
+ */
|
|
|
+ private ResultVo getInitData(JSONObject json) throws Exception {
|
|
|
+ ResultVo rv = new ResultVo();
|
|
|
+ User user = getUserFromJson(json);
|
|
|
+
|
|
|
+ // 获取默认账户信息
|
|
|
+ AccountService accountService = (AccountService) cxt.getBean("accountService");
|
|
|
+ Account defaultAccount = accountService.getDefaultAccount(user.getUnitId());
|
|
|
+
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ result.put("initiator", user.getName());
|
|
|
+ result.put("department", user.getGroupXUser().getGroupName());
|
|
|
+ result.put("applyDate", DateUtil.getCurrDate("yyyy-MM-dd"));
|
|
|
+ result.put("depid", user.getGroupXUser().getGroupID());
|
|
|
+
|
|
|
+ // 设置默认经办人(当前登录用户)
|
|
|
+ result.put("operator", user.getName());
|
|
|
+ result.put("operatorId", user.getUseId());
|
|
|
+
|
|
|
+ // 设置默认账户信息
|
|
|
+ if (defaultAccount != null) {
|
|
|
+ result.put("bankName", defaultAccount.getOpeningBank());
|
|
|
+ result.put("bankAccount", defaultAccount.getAccount());
|
|
|
+ result.put("accountId", defaultAccount.getAccountId());
|
|
|
+ result.put("accountName", defaultAccount.getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ rv.setReturnCode("1");
|
|
|
+ rv.setReturnMsg("success");
|
|
|
+ rv.setReturnParams(result);
|
|
|
+ return rv;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发起付款申请流程(包含表单、附件)
|
|
|
+ */
|
|
|
+ @Transactional
|
|
|
+ public ResultVo startPaymentApply(JSONObject json) throws Exception {
|
|
|
+ ResultVo rv = new ResultVo();
|
|
|
+ User user = getUserFromJson(json);
|
|
|
+ JSONObject formData = json.getJSONObject("formData");
|
|
|
+
|
|
|
+ // 获取流程信息
|
|
|
+ JSONObject flowInfo = json.optJSONObject("flowInfo");
|
|
|
+ String modelId = "";
|
|
|
+ String tmodelId = "";
|
|
|
+ String insName = "";
|
|
|
+ String formId = "";
|
|
|
+ String creator = "";
|
|
|
+ String username = "";
|
|
|
+ String groupid = "";
|
|
|
+ String gxid = "";
|
|
|
+ if (flowInfo != null) {
|
|
|
+ modelId = flowInfo.optString("modelId", "");
|
|
|
+ tmodelId = flowInfo.optString("tmodelId", "");
|
|
|
+ insName = flowInfo.optString("insName", "");
|
|
|
+ formId = flowInfo.optString("formId", "");
|
|
|
+ creator = flowInfo.optString("staffId", user.getUseId().toString());
|
|
|
+ username = flowInfo.optString("staffName", user.getName());
|
|
|
+ groupid = flowInfo.optString("groupId", user.getGroupXUser().getGroupID().toString());
|
|
|
+ gxid = flowInfo.optString("gxId", user.getGroupXUser().getGroupID().toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取附件 IDs
|
|
|
+ String fileIds = "";
|
|
|
+ if (flowInfo != null && flowInfo.has("fileIds")) {
|
|
|
+ Object fileIdsObj = flowInfo.get("fileIds");
|
|
|
+ if (fileIdsObj instanceof JSONArray) {
|
|
|
+ JSONArray fileIdsArray = (JSONArray) fileIdsObj;
|
|
|
+ List<String> fileIdList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < fileIdsArray.size(); i++) {
|
|
|
+ String fileId = fileIdsArray.getString(i);
|
|
|
+ if (StringUtils.isNotEmpty(fileId)) {
|
|
|
+ fileIdList.add(fileId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fileIds = StringUtils.join(fileIdList.toArray(), ",");
|
|
|
+ } else {
|
|
|
+ fileIds = flowInfo.optString("fileIds", "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ PaymentApplyService paymentApplyService = (PaymentApplyService) cxt.getBean("paymentApplyService");
|
|
|
+
|
|
|
+ // 构建主表数据
|
|
|
+ PaymentApply paymentApply = new PaymentApply();
|
|
|
+ Long universalid = StringUtil.getSeq();
|
|
|
+ paymentApply.setUniversalid(universalid);
|
|
|
+ paymentApply.setlFormInsId(universalid);
|
|
|
+ paymentApply.setIsValid(9);
|
|
|
+ paymentApply.setCreateTime(new Date());
|
|
|
+ paymentApply.setCreator(user.getUseId());
|
|
|
+ paymentApply.setUnitId(user.getUnitId());
|
|
|
+
|
|
|
+ // 设置表单字段(注意:processId由BPM流程引擎自动生成,不需要前端传入)
|
|
|
+
|
|
|
+ String payerName = formData.optString("payerName", "");
|
|
|
+ if (StringUtils.isNotEmpty(payerName)) {
|
|
|
+ paymentApply.setPayerName(payerName);
|
|
|
+ }
|
|
|
+
|
|
|
+ String payeeName = formData.optString("payeeName", "");
|
|
|
+ if (StringUtils.isNotEmpty(payeeName)) {
|
|
|
+ paymentApply.setPayeeName(payeeName);
|
|
|
+ }
|
|
|
+
|
|
|
+ String vendorCode = formData.optString("vendorCode", "");
|
|
|
+ if (StringUtils.isNotEmpty(vendorCode)) {
|
|
|
+ paymentApply.setVendorCode(vendorCode);
|
|
|
+ }
|
|
|
+
|
|
|
+ String contractId = formData.optString("contractId", "");
|
|
|
+ if (StringUtils.isNotEmpty(contractId) && !"0".equals(contractId)) {
|
|
|
+ paymentApply.setContractId(StringUtil.strToLong(contractId));
|
|
|
+ }
|
|
|
+
|
|
|
+ String contractNumber = formData.optString("contractNumber", "");
|
|
|
+ if (StringUtils.isNotEmpty(contractNumber)) {
|
|
|
+ paymentApply.setContractNumber(contractNumber);
|
|
|
+ }
|
|
|
+
|
|
|
+ String contractName = formData.optString("contractName", "");
|
|
|
+ if (StringUtils.isNotEmpty(contractName)) {
|
|
|
+ paymentApply.setContractName(contractName);
|
|
|
+ }
|
|
|
+
|
|
|
+ String purchaseOrderNo = formData.optString("purchaseOrderNo", "");
|
|
|
+ if (StringUtils.isNotEmpty(purchaseOrderNo)) {
|
|
|
+ paymentApply.setPurchaseOrderNo(purchaseOrderNo);
|
|
|
+ }
|
|
|
+
|
|
|
+ String storageOrderNo = formData.optString("storageOrderNo", "");
|
|
|
+ if (StringUtils.isNotEmpty(storageOrderNo)) {
|
|
|
+ paymentApply.setStorageOrderNo(storageOrderNo);
|
|
|
+ }
|
|
|
+
|
|
|
+ String orderIdFromMes = formData.optString("orderIdFromMes", "");
|
|
|
+ if (StringUtils.isNotEmpty(orderIdFromMes)) {
|
|
|
+ paymentApply.setOrderIdFromMes(orderIdFromMes);
|
|
|
+ }
|
|
|
+
|
|
|
+ String amountLowerStr = formData.optString("amountLower", "");
|
|
|
+ if (StringUtils.isNotEmpty(amountLowerStr)) {
|
|
|
+ paymentApply.setAmountLower(new BigDecimal(amountLowerStr));
|
|
|
+ }
|
|
|
+
|
|
|
+ String amountUpper = formData.optString("amountUpper", "");
|
|
|
+ if (StringUtils.isNotEmpty(amountUpper)) {
|
|
|
+ paymentApply.setAmountUpper(amountUpper);
|
|
|
+ }
|
|
|
+
|
|
|
+ String paymentType = formData.optString("paymentType", "");
|
|
|
+ if (StringUtils.isNotEmpty(paymentType)) {
|
|
|
+ paymentApply.setPaymentType(paymentType);
|
|
|
+ }
|
|
|
+
|
|
|
+ String paymentMethod = formData.optString("paymentMethod", "");
|
|
|
+ if (StringUtils.isNotEmpty(paymentMethod)) {
|
|
|
+ paymentApply.setPaymentMethod(paymentMethod);
|
|
|
+ }
|
|
|
+
|
|
|
+ String paymentDate = formData.optString("paymentDate", "");
|
|
|
+ if (StringUtils.isNotEmpty(paymentDate)) {
|
|
|
+ paymentApply.setPaymentDate(paymentDate);
|
|
|
+ }
|
|
|
+
|
|
|
+ String purpose = formData.optString("purpose", "");
|
|
|
+ if (StringUtils.isNotEmpty(purpose)) {
|
|
|
+ paymentApply.setPurpose(purpose);
|
|
|
+ }
|
|
|
+
|
|
|
+ String operator = formData.optString("operator", "");
|
|
|
+ if (StringUtils.isNotEmpty(operator)) {
|
|
|
+ paymentApply.setOperator(operator);
|
|
|
+ }
|
|
|
+
|
|
|
+ String operatorId = formData.optString("operatorId", "");
|
|
|
+ if (StringUtils.isNotEmpty(operatorId)) {
|
|
|
+ paymentApply.setOperatorId(StringUtil.strToLong(operatorId));
|
|
|
+ }
|
|
|
+
|
|
|
+ String payeeBankAccount = formData.optString("payeeBankAccount", "");
|
|
|
+ if (StringUtils.isNotEmpty(payeeBankAccount)) {
|
|
|
+ paymentApply.setPayeeBankAccount(payeeBankAccount);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置默认账户信息(隐藏域)
|
|
|
+ String bankName = formData.optString("bankName", "");
|
|
|
+ if (StringUtils.isNotEmpty(bankName)) {
|
|
|
+ paymentApply.setBankName(bankName);
|
|
|
+ }
|
|
|
+
|
|
|
+ String bankAccount = formData.optString("bankAccount", "");
|
|
|
+ if (StringUtils.isNotEmpty(bankAccount)) {
|
|
|
+ paymentApply.setBankAccount(bankAccount);
|
|
|
+ }
|
|
|
+
|
|
|
+ String accountId = formData.optString("accountId", "");
|
|
|
+ if (StringUtils.isNotEmpty(accountId)) {
|
|
|
+ paymentApply.setAccountId(accountId);
|
|
|
+ }
|
|
|
+
|
|
|
+ String accountName = formData.optString("accountName", "");
|
|
|
+ if (StringUtils.isNotEmpty(accountName)) {
|
|
|
+ paymentApply.setAccountName(accountName);
|
|
|
+ }
|
|
|
+
|
|
|
+ String applyDate = formData.optString("applyDate", "");
|
|
|
+ if (StringUtils.isNotEmpty(applyDate)) {
|
|
|
+ paymentApply.setApplyDate(applyDate);
|
|
|
+ }
|
|
|
+
|
|
|
+ String department = formData.optString("department", "");
|
|
|
+ if (StringUtils.isNotEmpty(department)) {
|
|
|
+ paymentApply.setDepartment(department);
|
|
|
+ }
|
|
|
+
|
|
|
+ String initiator = formData.optString("initiator", "");
|
|
|
+ if (StringUtils.isNotEmpty(initiator)) {
|
|
|
+ paymentApply.setInitiator(initiator);
|
|
|
+ }
|
|
|
+
|
|
|
+ String depid = formData.optString("depid", "");
|
|
|
+ if (StringUtils.isNotEmpty(depid)) {
|
|
|
+ paymentApply.setDepid(depid);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 1. 先保存付款申请表单数据
|
|
|
+ int num = paymentApplyService.addPaymentApply(paymentApply);
|
|
|
+ if (num <= 0) {
|
|
|
+ rv.setReturnCode("-1");
|
|
|
+ rv.setReturnMsg("表单提交失败!");
|
|
|
+ return rv;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 调用 BPM 流程启动逻辑
|
|
|
+ try {
|
|
|
+ String formInsId = String.valueOf(paymentApply.getlFormInsId());
|
|
|
+
|
|
|
+ CoreService bpmCoreService = (CoreService) cxt.getBean("bpmCoreService");
|
|
|
+ ProcessResult pr = bpmCoreService.startFlowComplete(flowInfo, user, formInsId);
|
|
|
+
|
|
|
+ if (pr.isResultState()) {
|
|
|
+ rv.setReturnCode("1");
|
|
|
+ rv.setReturnMsg("提交成功");
|
|
|
+ rv.setReturnParams("{\"universalid\":\"" + universalid + "\"}");
|
|
|
+ } else {
|
|
|
+ rv.setReturnCode("-1");
|
|
|
+ rv.setReturnMsg(pr.getResultInfo());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ rv.setReturnCode("-1");
|
|
|
+ rv.setReturnMsg("提交流程失败!" + e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return rv;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取付款申请表单数据(用于审批页面展示)
|
|
|
+ */
|
|
|
+ private ResultVo getPaymentFormData(JSONObject json) throws Exception {
|
|
|
+ ResultVo rv = new ResultVo();
|
|
|
+ User user = getUserFromJson(json);
|
|
|
+
|
|
|
+ String formInsId = json.optString("formInsId", "");
|
|
|
+
|
|
|
+ if (StringUtil.isEmpty(formInsId)) {
|
|
|
+ rv.setReturnCode("-1");
|
|
|
+ rv.setReturnMsg("缺少必要参数:formInsId");
|
|
|
+ return rv;
|
|
|
+ }
|
|
|
+
|
|
|
+ PaymentApplyService paymentApplyService = (PaymentApplyService) cxt.getBean("paymentApplyService");
|
|
|
+
|
|
|
+ PaymentApply paymentApply = new PaymentApply();
|
|
|
+ paymentApply.setlFormInsId(StringUtil.strToLong(formInsId));
|
|
|
+ paymentApply = paymentApplyService.getPaymentApply(paymentApply);
|
|
|
+
|
|
|
+ if (paymentApply == null) {
|
|
|
+ rv.setReturnCode("-1");
|
|
|
+ rv.setReturnMsg("未找到付款申请数据");
|
|
|
+ return rv;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 将对象转为 JSONObject
|
|
|
+ JSONObject paymentApplyJson = JSONObject.fromObject(paymentApply);
|
|
|
+
|
|
|
+ rv.setReturnCode("1");
|
|
|
+ rv.setReturnMsg("success");
|
|
|
+ rv.setReturnParams(paymentApplyJson);
|
|
|
+ return rv;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取付款申请表单数据(用于查看页面)
|
|
|
+ */
|
|
|
+ private ResultVo getPaymentDataByInsId(JSONObject json) throws Exception {
|
|
|
+ ResultVo rv = new ResultVo();
|
|
|
+ User user = getUserFromJson(json);
|
|
|
+
|
|
|
+ String insId = json.optString("insId", "");
|
|
|
+
|
|
|
+ if (StringUtil.isEmpty(insId)) {
|
|
|
+ rv.setReturnCode("-1");
|
|
|
+ rv.setReturnMsg("缺少必要参数:insId");
|
|
|
+ return rv;
|
|
|
+ }
|
|
|
+
|
|
|
+ PaymentApplyService paymentApplyService = (PaymentApplyService) cxt.getBean("paymentApplyService");
|
|
|
+
|
|
|
+ PaymentApply paymentApply = new PaymentApply();
|
|
|
+ paymentApply.setFlowInsId(Long.parseLong(insId));
|
|
|
+ paymentApply = paymentApplyService.getPaymentApply(paymentApply);
|
|
|
+
|
|
|
+ if (paymentApply == null) {
|
|
|
+ rv.setReturnCode("-1");
|
|
|
+ rv.setReturnMsg("未找到付款申请数据");
|
|
|
+ return rv;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 将对象转为 JSONObject
|
|
|
+ JSONObject paymentApplyJson = JSONObject.fromObject(paymentApply);
|
|
|
+
|
|
|
+ rv.setReturnCode("1");
|
|
|
+ rv.setReturnMsg("success");
|
|
|
+ rv.setReturnParams(paymentApplyJson);
|
|
|
+ return rv;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 选择供应商(支持分页搜索)
|
|
|
+ */
|
|
|
+ private ResultVo selectSupplier(JSONObject json) throws Exception {
|
|
|
+ ResultVo rv = new ResultVo();
|
|
|
+ User user = getUserFromJson(json);
|
|
|
+
|
|
|
+ int page = json.optInt("page", 1);
|
|
|
+ int pageSize = json.optInt("pageSize", 20);
|
|
|
+ String vendorName = json.optString("vendorName", "");
|
|
|
+
|
|
|
+ MesCommonHelper mesCommonHelper = new MesCommonHelper();
|
|
|
+ org.json.JSONObject resp = mesCommonHelper.getSupplier(page, pageSize, vendorName);
|
|
|
+ int total = resp.getInt("total");
|
|
|
+ org.json.JSONArray rowsArray = resp.getJSONArray("rows");
|
|
|
+
|
|
|
+ List<Map<String, Object>> supplierList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < rowsArray.length(); i++) {
|
|
|
+ org.json.JSONObject jsonObject = rowsArray.getJSONObject(i);
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ for (String key : jsonObject.keySet()) {
|
|
|
+ Object value = jsonObject.get(key);
|
|
|
+ map.put(key, value);
|
|
|
+ }
|
|
|
+ supplierList.add(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("list", supplierList);
|
|
|
+ resultMap.put("total", total);
|
|
|
+
|
|
|
+ rv.setReturnCode("1");
|
|
|
+ rv.setReturnMsg("success");
|
|
|
+ rv.setReturnParams(resultMap);
|
|
|
+ return rv;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 选择合同(支持分页搜索)
|
|
|
+ */
|
|
|
+ private ResultVo selectContract(JSONObject json) throws Exception {
|
|
|
+ ResultVo rv = new ResultVo();
|
|
|
+ User user = getUserFromJson(json);
|
|
|
+
|
|
|
+ int page = json.optInt("page", 1);
|
|
|
+ int pageSize = json.optInt("pageSize", 20);
|
|
|
+ String contractName = json.optString("contractName", "");
|
|
|
+ String supplierCode = json.optString("supplierCode", "");
|
|
|
+ String contractType = json.optString("contractType", "");
|
|
|
+
|
|
|
+ // 使用 ContractEntryService 查询合同列表
|
|
|
+ com.yw.contract.contract.service.ContractEntryService contractEntryService =
|
|
|
+ (com.yw.contract.contract.service.ContractEntryService) cxt.getBean("contractEntryService");
|
|
|
+
|
|
|
+ ParameterHelper ph = new ParameterHelper();
|
|
|
+ ph.setParam("unitId", user.getUnitId());
|
|
|
+ if (StringUtils.isNotEmpty(contractName)) {
|
|
|
+ ph.setParam("contract_search_name", "%" + contractName + "%");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(supplierCode)) {
|
|
|
+ ph.setParam("supplierCode", supplierCode);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(contractType)) {
|
|
|
+ ph.setParam("contract_search_type", contractType);
|
|
|
+ }
|
|
|
+ // 只查询已审批通过的合同
|
|
|
+ ph.setParam("isValid", "1");
|
|
|
+
|
|
|
+ com.yw.contract.contract.model.ContractInfo info = new com.yw.contract.contract.model.ContractInfo();
|
|
|
+ OASession oasession = new OASession();
|
|
|
+ oasession.setUnit(new Group());
|
|
|
+ oasession.getUnit().setId(user.getUnitId());
|
|
|
+
|
|
|
+ List<com.yw.contract.contract.model.ContractInfo> contractList =
|
|
|
+ contractEntryService.contractEntryList(String.valueOf(page), String.valueOf(pageSize), ph, info, oasession);
|
|
|
+ int total = contractEntryService.countContractEntry(ph, oasession);
|
|
|
+
|
|
|
+ // 转换为 Map 列表
|
|
|
+ List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
+ for (com.yw.contract.contract.model.ContractInfo contract : contractList) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("universalid", contract.getUniversalid());
|
|
|
+ map.put("processId", contract.getProcessId());
|
|
|
+ map.put("contract_number", contract.getContract_number());
|
|
|
+ map.put("contract_name", contract.getContract_name());
|
|
|
+ map.put("contract_type", contract.getContract_type());
|
|
|
+ map.put("contract_type_name", contract.getContract_type_name());
|
|
|
+ map.put("secondparty_name", contract.getSecondparty_name());
|
|
|
+ map.put("firstparty_name", contract.getFirstparty_name());
|
|
|
+ map.put("supplierName", contract.getSupplierName());
|
|
|
+ map.put("supplierCode", contract.getSupplierCode());
|
|
|
+ resultList.add(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("list", resultList);
|
|
|
+ resultMap.put("total", total);
|
|
|
+
|
|
|
+ rv.setReturnCode("1");
|
|
|
+ rv.setReturnMsg("success");
|
|
|
+ rv.setReturnParams(resultMap);
|
|
|
+ return rv;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 选择采购订单(支持分页搜索)
|
|
|
+ */
|
|
|
+ private ResultVo selectPurchaseOrder(JSONObject json) throws Exception {
|
|
|
+ ResultVo rv = new ResultVo();
|
|
|
+ User user = getUserFromJson(json);
|
|
|
+
|
|
|
+ String vendorCode = json.optString("vendorCode", "");
|
|
|
+ int page = json.optInt("page", 1);
|
|
|
+ int pageSize = json.optInt("pageSize", 20);
|
|
|
+
|
|
|
+ MesCommonHelper mesCommonHelper = new MesCommonHelper();
|
|
|
+ org.json.JSONObject resp = mesCommonHelper.getPurchases(page, pageSize, "", vendorCode);
|
|
|
+ int total = resp.getInt("total");
|
|
|
+ org.json.JSONArray rowsArray = resp.getJSONArray("rows");
|
|
|
+
|
|
|
+ List<Map<String, Object>> orderList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < rowsArray.length(); i++) {
|
|
|
+ org.json.JSONObject jsonObject = rowsArray.getJSONObject(i);
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ for (String key : jsonObject.keySet()) {
|
|
|
+ Object value = jsonObject.get(key);
|
|
|
+ map.put(key, value);
|
|
|
+ }
|
|
|
+ orderList.add(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("list", orderList);
|
|
|
+ resultMap.put("total", total);
|
|
|
+
|
|
|
+ rv.setReturnCode("1");
|
|
|
+ rv.setReturnMsg("success");
|
|
|
+ rv.setReturnParams(resultMap);
|
|
|
+ return rv;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 选择入库单(支持分页搜索)
|
|
|
+ */
|
|
|
+ private ResultVo selectStorageOrder(JSONObject json) throws Exception {
|
|
|
+ ResultVo rv = new ResultVo();
|
|
|
+ User user = getUserFromJson(json);
|
|
|
+
|
|
|
+ String vendorCode = json.optString("vendorCode", "");
|
|
|
+ int page = json.optInt("page", 1);
|
|
|
+ int pageSize = json.optInt("pageSize", 20);
|
|
|
+
|
|
|
+ MesCommonHelper mesCommonHelper = new MesCommonHelper();
|
|
|
+ org.json.JSONObject resp = mesCommonHelper.getItemrecpts(page, pageSize, "", vendorCode);
|
|
|
+ int total = resp.getInt("total");
|
|
|
+ org.json.JSONArray rowsArray = resp.getJSONArray("rows");
|
|
|
+
|
|
|
+ List<Map<String, Object>> orderList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < rowsArray.length(); i++) {
|
|
|
+ org.json.JSONObject jsonObject = rowsArray.getJSONObject(i);
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ for (String key : jsonObject.keySet()) {
|
|
|
+ Object value = jsonObject.get(key);
|
|
|
+ map.put(key, value);
|
|
|
+ }
|
|
|
+ orderList.add(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("list", orderList);
|
|
|
+ resultMap.put("total", total);
|
|
|
+
|
|
|
+ rv.setReturnCode("1");
|
|
|
+ rv.setReturnMsg("success");
|
|
|
+ rv.setReturnParams(resultMap);
|
|
|
+ return rv;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 从 JSON 获取用户信息
|
|
|
+ */
|
|
|
+ private User getUserFromJson(JSONObject json) throws Exception {
|
|
|
+ UserService userService = (UserService) cxt.getBean("userService");
|
|
|
+ String useId = json.getString("useId");
|
|
|
+ User user = userService.findUserById(useId);
|
|
|
+ GroupXUser groupXUser = userService.loadOwnGroupXuser(user.getUseId());
|
|
|
+ user.setGroupXUser(groupXUser);
|
|
|
+ return user;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getServiceId() {
|
|
|
+ return serviceId;
|
|
|
+ }
|
|
|
+}
|