|
@@ -1,10 +1,27 @@
|
|
package com.yh.saas.plugin.yiliangyiyun.service.impl;
|
|
package com.yh.saas.plugin.yiliangyiyun.service.impl;
|
|
|
|
|
|
|
|
+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.SalesDeliveryReport;
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.SalesDeliveryReport;
|
|
import com.yh.saas.plugin.yiliangyiyun.mapper.SalesDeliveryReportMapper;
|
|
import com.yh.saas.plugin.yiliangyiyun.mapper.SalesDeliveryReportMapper;
|
|
import com.yh.saas.plugin.yiliangyiyun.service.ISalesDeliveryReportService;
|
|
import com.yh.saas.plugin.yiliangyiyun.service.ISalesDeliveryReportService;
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
|
|
+import com.yh.saas.toolkit.workflow.service.IWorkflowService;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+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>
|
|
@@ -16,5 +33,148 @@ import org.springframework.stereotype.Service;
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
public class SalesDeliveryReportServiceImpl extends ServiceImpl<SalesDeliveryReportMapper, SalesDeliveryReport> implements ISalesDeliveryReportService {
|
|
public class SalesDeliveryReportServiceImpl extends ServiceImpl<SalesDeliveryReportMapper, SalesDeliveryReport> implements ISalesDeliveryReportService {
|
|
|
|
+ @Autowired
|
|
|
|
+ private IWorkflowService workflowService;
|
|
|
|
+ @SofaReference
|
|
|
|
+ private ICommonRoleResourceService roleResourceService;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 销售出库统计列表
|
|
|
|
+ * @param salesDeliveryReport
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public Page<SalesDeliveryReport> selectSalesDeliveryReport(SalesDeliveryReport salesDeliveryReport) {
|
|
|
|
+ Map<String, Object> pageView = new HashMap<>();
|
|
|
|
+ pageView.put("startRecord", (salesDeliveryReport.getCurrentPage() - 1)
|
|
|
|
+ * salesDeliveryReport.getPageSize());
|
|
|
|
+ List<String> businessKeys = null;
|
|
|
|
+ businessKeys = workflowService.getTaskBusinessKeysByCode("PURCHASE-RECEIPT-REPORT");
|
|
|
|
+ List<String> statusSet = new ArrayList<>();
|
|
|
|
+ List<String> resourceIdList = this.getResourceIdList();
|
|
|
|
+ if (resourceIdList.contains("PURCHAS")) { // 填写,提交 权限做完以后替换
|
|
|
|
+ List<String> statusList = Lists.newArrayList(StatusEnum.PUR_RETURN.getFlag());
|
|
|
|
+ statusSet.addAll(statusList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //公司id
|
|
|
|
+ pageView.put("compId", salesDeliveryReport.getCompId());
|
|
|
|
+ pageView.put("searchKeyWord", salesDeliveryReport.getSearchKeyWord());
|
|
|
|
+ pageView.put("searchType", salesDeliveryReport.getSearchType());
|
|
|
|
+ pageView.put("pageSize", salesDeliveryReport.getPageSize());
|
|
|
|
+ pageView.put("currentPage", salesDeliveryReport.getCurrentPage());
|
|
|
|
+ pageView.put("contractNo", salesDeliveryReport.getContractNo());
|
|
|
|
+ pageView.put("businessKeys", businessKeys);
|
|
|
|
+ pageView.put("statusSet", statusSet);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // 查询采购订单总数
|
|
|
|
+ Integer dataCount = baseMapper.getCountByCondition(pageView);
|
|
|
|
+ List<SalesDeliveryReport> dataList = baseMapper.getListByCondition(pageView);
|
|
|
|
+ Page<SalesDeliveryReport> page = new Page<>();
|
|
|
|
+ page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
|
|
|
|
+ page.setTotal(dataCount == null ? 0 : dataCount);
|
|
|
|
+ page.setCurrent(salesDeliveryReport.getCurrentPage());
|
|
|
|
+ page.setSize(salesDeliveryReport.getPageSize());
|
|
|
|
+ return page;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 出纳收款
|
|
|
|
+ * @param salesDeliveryReport
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String collectMoney(SalesDeliveryReport salesDeliveryReport) {
|
|
|
|
+ List<SalesDeliveryReport> salesDeliveryReportList=salesDeliveryReport.getSalesDeliveryReportList();
|
|
|
|
+ Float money = salesDeliveryReport.getMoney();
|
|
|
|
+ //收款多条
|
|
|
|
+ if (!CollectionUtils.isEmpty(salesDeliveryReportList)){
|
|
|
|
+ for (SalesDeliveryReport salesDeliveryReport1 : salesDeliveryReportList) {
|
|
|
|
+ //收款金额大于本次循环未收金额
|
|
|
|
+ if (money >= salesDeliveryReport1.getCollectionNotPayable()) {
|
|
|
|
+ money=money-salesDeliveryReport1.getCollectionNotPayable();
|
|
|
|
+ //全部收款
|
|
|
|
+ salesDeliveryReport1.setStatus(StatusEnum.PUR_PAYaLL.getName());
|
|
|
|
+ salesDeliveryReport1.setStatusFlag(StatusEnum.PUR_PAYaLL.getFlag());
|
|
|
|
+ salesDeliveryReport1.setCollectionEdPayable(salesDeliveryReport1.getCollectionEdPayable()+salesDeliveryReport1.getCollectionNotPayable());
|
|
|
|
+ salesDeliveryReport1.setCollectionNotPayable(0.0f);
|
|
|
|
+ this.updateById(salesDeliveryReport1);
|
|
|
|
+ } else if (money> 0) {
|
|
|
|
+ Float moneyTmp = money-salesDeliveryReport1.getCollectionNotPayable();
|
|
|
|
+ //部分收款
|
|
|
|
+ salesDeliveryReport1.setStatus(StatusEnum.PUR_PAY.getName());
|
|
|
|
+ salesDeliveryReport1.setStatusFlag(StatusEnum.PUR_PAY.getFlag());
|
|
|
|
+ salesDeliveryReport1.setCollectionEdPayable(salesDeliveryReport1.getCollectionEdPayable()+money);
|
|
|
|
+ salesDeliveryReport1.setCollectionNotPayable(salesDeliveryReport1.getCollectionNotPayable()-money);
|
|
|
|
+ this.updateById(salesDeliveryReport1);
|
|
|
|
+ money=moneyTmp;
|
|
|
|
+ } else {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return "ok";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 开发票
|
|
|
|
+ * @param salesDeliveryReport
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String openInvoice(SalesDeliveryReport salesDeliveryReport) {
|
|
|
|
+ //查询销售出库报表
|
|
|
|
+ SalesDeliveryReport salesDeliveryReport1=this.selectById(salesDeliveryReport.getId());
|
|
|
|
+ if (salesDeliveryReport1 != null ){
|
|
|
|
+ //更改已开发票
|
|
|
|
+ salesDeliveryReport1.setAlreadyInvoice(salesDeliveryReport1.getAlreadyInvoice()+salesDeliveryReport1.getAlreadyInvoice());
|
|
|
|
+ //更改销售出库报表信息
|
|
|
|
+ this.updateById(salesDeliveryReport1);
|
|
|
|
+ return "OK";
|
|
|
|
+ }
|
|
|
|
+ return "NG";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 批量开发票
|
|
|
|
+ * @param salesDeliveryReport
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String openInvoiceList(SalesDeliveryReport salesDeliveryReport) {
|
|
|
|
+ List<SalesDeliveryReport> salesDeliveryReportList=salesDeliveryReport.getSalesDeliveryReportList();
|
|
|
|
+ //批量
|
|
|
|
+ if (!CollectionUtils.isEmpty(salesDeliveryReportList)){
|
|
|
|
+ for (SalesDeliveryReport salesDeliveryReport1 : salesDeliveryReportList) {
|
|
|
|
+ //已开发票金额等于已收金额
|
|
|
|
+ salesDeliveryReport1.setAlreadyInvoice(salesDeliveryReport1.getCollectionEdPayable());
|
|
|
|
+ this.updateById(salesDeliveryReport1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return "ok";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 最终结算价
|
|
|
|
+ * @param salesDeliveryReport
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String editSalesDeliveryReport(SalesDeliveryReport salesDeliveryReport) {
|
|
|
|
+ boolean one = this.updateById(salesDeliveryReport);
|
|
|
|
+ if (one) {
|
|
|
|
+ return "OK";
|
|
|
|
+ } else {
|
|
|
|
+ return "NG";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<String> getResourceIdList() {
|
|
|
|
+ User currentUser = AuthSecurityUtils.getCurrentUserInfo();
|
|
|
|
+ // 当前登录人主要角色
|
|
|
|
+ return roleResourceService.getBindResourcesByUserId(currentUser.getUserId()).stream()
|
|
|
|
+ .map(CommonRoleResource::getResourceId).collect(Collectors.toList());
|
|
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|