|
@@ -0,0 +1,164 @@
|
|
|
+package com.yh.saas.plugin.yiliangyiyun.service.impl;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.alipay.sofa.runtime.api.annotation.SofaReference;
|
|
|
+import com.baomidou.mybatisplus.plugins.Page;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import com.winsea.svc.base.base.entity.CommonRoleResource;
|
|
|
+import com.winsea.svc.base.base.service.ICommonRoleResourceService;
|
|
|
+import com.winsea.svc.base.security.entity.User;
|
|
|
+import com.winsea.svc.base.security.util.AuthSecurityUtils;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.entity.ContractManagementInfo;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.entity.PurchaseReceiptReport;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.entity.StockPurchaseReceiptReport;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.mapper.StockPurchaseReceiptReportMapper;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.service.IContractManagementInfoService;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.service.INewWorkflowService;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.service.IStockPurchaseReceiptReportService;
|
|
|
+import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 现货采购入库报表 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author Gdc
|
|
|
+ * @since 2021-09-17
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class StockPurchaseReceiptReportServiceImpl extends ServiceImpl<StockPurchaseReceiptReportMapper, StockPurchaseReceiptReport> implements IStockPurchaseReceiptReportService {
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private INewWorkflowService workflowService;
|
|
|
+
|
|
|
+ @SofaReference
|
|
|
+ private ICommonRoleResourceService roleResourceService;
|
|
|
+ @Autowired
|
|
|
+ private IContractManagementInfoService contractManagementInfoService;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 采购入库统计
|
|
|
+ *
|
|
|
+ * @param stockPurchaseReceiptReport
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Page<StockPurchaseReceiptReport> selectPurchaseOrder(StockPurchaseReceiptReport stockPurchaseReceiptReport) {
|
|
|
+ Map<String, Object> pageView = new HashMap<>();
|
|
|
+ pageView.put("startRecord", (stockPurchaseReceiptReport.getCurrentPage() - 1)
|
|
|
+ * stockPurchaseReceiptReport.getPageSize());
|
|
|
+ List<String> businessKeys = null;
|
|
|
+ if ("1".equals(stockPurchaseReceiptReport.getSearchType())) {
|
|
|
+ businessKeys = workflowService.getTaskBusinessKeysByCode("STOCK-PROCUREMENT-RECEIPT-REPORT");
|
|
|
+ }
|
|
|
+ List<String> statusSet = new ArrayList<>();
|
|
|
+ List<String> resourceIdList = this.getResourceIdList();
|
|
|
+ if (resourceIdList.contains("procurementStockInReport-Edit")) { // 填写,提交 权限做完以后替换
|
|
|
+ List<String> statusList = Lists.newArrayList(StatusEnum.PUR_RETURN.getFlag());
|
|
|
+ statusSet.addAll(statusList);
|
|
|
+ }
|
|
|
+ //公司id
|
|
|
+ pageView.put("compId", stockPurchaseReceiptReport.getCompId());
|
|
|
+ pageView.put("searchKeyWord", stockPurchaseReceiptReport.getSearchKeyWord());
|
|
|
+ pageView.put("searchType", stockPurchaseReceiptReport.getSearchType());
|
|
|
+ pageView.put("pageSize", stockPurchaseReceiptReport.getPageSize());
|
|
|
+ pageView.put("currentPage", stockPurchaseReceiptReport.getCurrentPage());
|
|
|
+ pageView.put("contractNo", stockPurchaseReceiptReport.getContractNo());
|
|
|
+ pageView.put("statusFlag", stockPurchaseReceiptReport.getStatusFlag());
|
|
|
+ pageView.put("businessKeys", businessKeys);
|
|
|
+ pageView.put("statusSet", statusSet);
|
|
|
+ // 查询采购入库总数
|
|
|
+ Integer dataCount = baseMapper.getCountByCondition(pageView);
|
|
|
+ List<StockPurchaseReceiptReport> dataList = baseMapper.getListByCondition(pageView);
|
|
|
+ if (!CollectionUtils.isEmpty(dataList)) {
|
|
|
+ dataList.forEach(purchaseReceiptReport1 -> {
|
|
|
+
|
|
|
+ String taskId = "";
|
|
|
+ // 只有待审核状态才有taskId
|
|
|
+ if (StringUtils.isNotBlank(purchaseReceiptReport1.getWorkflowId())) {
|
|
|
+ JSONObject jsonObject = workflowService.getActiveTask(Lists.newArrayList(purchaseReceiptReport1.getWorkflowId()), purchaseReceiptReport1.getId());
|
|
|
+ taskId = jsonObject.getString("taskId");
|
|
|
+ purchaseReceiptReport1.setTaskId(taskId);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ Page<StockPurchaseReceiptReport> page = new Page<>();
|
|
|
+ page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
|
|
|
+ page.setTotal(dataCount == null ? 0 : dataCount);
|
|
|
+ page.setCurrent(stockPurchaseReceiptReport.getCurrentPage());
|
|
|
+ page.setSize(stockPurchaseReceiptReport.getPageSize());
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 定金/备注
|
|
|
+ *
|
|
|
+ * @param contractManagementInfo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public String disAndRemark(ContractManagementInfo contractManagementInfo) {
|
|
|
+ //查询合同
|
|
|
+ ContractManagementInfo contractManagementInfo1 = contractManagementInfoService.selectById(contractManagementInfo.getId());
|
|
|
+ if (contractManagementInfo1 != null) {
|
|
|
+ if(StringUtils.isNotBlank(contractManagementInfo.getDeposit())){
|
|
|
+ contractManagementInfo1.setDeposit(contractManagementInfo.getDeposit());
|
|
|
+ contractManagementInfo1.setDepositUrl(contractManagementInfo.getDepositUrl());
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(contractManagementInfo.getRemark())){
|
|
|
+ contractManagementInfo1.setRemark(contractManagementInfo.getRemark());
|
|
|
+ }
|
|
|
+ //更改采购入库报表信息
|
|
|
+ contractManagementInfoService.updateById(contractManagementInfo1);
|
|
|
+ return "OK";
|
|
|
+ }
|
|
|
+ return "NG";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改结算重量
|
|
|
+ *
|
|
|
+ * @param stockPurchaseReceiptReport
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public String edit(StockPurchaseReceiptReport stockPurchaseReceiptReport) {
|
|
|
+ //查询采购入库报表
|
|
|
+ StockPurchaseReceiptReport stockPurchaseReceiptReport1 = this.selectById(stockPurchaseReceiptReport.getId());
|
|
|
+ if (stockPurchaseReceiptReport1 != null) {
|
|
|
+ stockPurchaseReceiptReport1.setSettlementWeight(stockPurchaseReceiptReport.getSettlementWeight());
|
|
|
+ //更改采购入库报表信息
|
|
|
+ this.updateById(stockPurchaseReceiptReport1);
|
|
|
+ return "OK";
|
|
|
+ }
|
|
|
+ return "NG";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private List<String> getResourceIdList() {
|
|
|
+ User currentUser = AuthSecurityUtils.getCurrentUserInfo();
|
|
|
+ // 当前登录人主要角色
|
|
|
+ return roleResourceService.getBindResourcesByUserId(currentUser.getUserId()).stream()
|
|
|
+ .map(CommonRoleResource::getResourceId).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+}
|