zhangyuewww 3 年 前
コミット
4e8ea63d04
18 ファイル変更1288 行追加88 行削除
  1. 7 1
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/ContractManagementInfoController.java
  2. 11 0
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/ExpenseInfoController.java
  3. 23 2
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/WarehousingOrderController.java
  4. 4 0
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/ContractExpensesInfo.java
  5. 14 1
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/ContractManagementInfo.java
  6. 6 0
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/SourceRelationInfo.java
  7. 5 0
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/WarehousingOrder.java
  8. 15 0
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/mapper/ContractManagementInfoMapper.java
  9. 8 1
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/IExpenseInfoService.java
  10. 17 0
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/IWarehousingOrderService.java
  11. 5 10
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/ContractExpensesInfoServiceImpl.java
  12. 16 0
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/ContractManagementInfoServiceImpl.java
  13. 745 21
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/WarehousingOrderServiceImpl.java
  14. 29 19
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/workflow/WarehousingOrderListener.java
  15. 27 33
      winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/ContractExpensesInfoMapper.xml
  16. 341 0
      winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/ContractManagementInfoMapper.xml
  17. 2 0
      winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/ExpenseInfoMapper.xml
  18. 13 0
      winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/WarehousingOrderMapper.xml

+ 7 - 1
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/ContractManagementInfoController.java

@@ -135,6 +135,12 @@ public class ContractManagementInfoController {
     public Page<ContractManagementInfo> selectContractInfo(ContractManagementInfo contractManagementInfo) {
         return contractManagementInfoService.selectContractInfo(contractManagementInfo);
     }
-
+    /**
+     * 合同利润图表
+     */
+    @GetMapping("/selectContractChart")
+    public ContractManagementInfo selectContractChart(ContractManagementInfo contractManagementInfo) {
+        return contractManagementInfoService.selectContractChart(contractManagementInfo);
+    }
     }
 

+ 11 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/ExpenseInfoController.java

@@ -9,6 +9,7 @@ import com.yh.saas.plugin.yiliangyiyun.service.IExpenseInfoService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import java.util.Date;
 import java.util.List;
@@ -115,6 +116,16 @@ public class ExpenseInfoController {
     public List<ExpenseInfo> expenseList(String compId, String startDate, String endDate){
         return expenseInfoService.expenseList(compId,startDate,endDate);
     }
+    /**
+     * 手机审核文件下载
+     *
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/exportPhone")
+    public String exportPhone(@RequestBody ExpenseInfo example, HttpServletResponse response) throws Exception {
+        return expenseInfoService.exportPhone(example,response);
+    }
 
 }
 

+ 23 - 2
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/WarehousingOrderController.java

@@ -2,9 +2,8 @@ package com.yh.saas.plugin.yiliangyiyun.controller;
 
 
 import com.yh.saas.plugin.yiliangyiyun.entity.SourceRelationInfo;
-import com.yh.saas.plugin.yiliangyiyun.entity.WarehouseInOutInfo;
 import com.yh.saas.plugin.yiliangyiyun.entity.WarehousingOrder;
-import com.yh.saas.plugin.yiliangyiyun.service.IWarehouseInOutInfoService;
+import com.yh.saas.plugin.yiliangyiyun.entity.view.PaymentView;
 import com.yh.saas.plugin.yiliangyiyun.service.IWarehousingOrderService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -13,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import com.baomidou.mybatisplus.plugins.Page;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 
 import java.util.List;
@@ -67,6 +67,27 @@ public class WarehousingOrderController {
     public String payMoney(@RequestBody WarehousingOrder warehousingOrder){
         return warehousingOrderService.payMoney(warehousingOrder);
     }
+    /**
+     * 手机审核文件下载
+     *
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/exportPhone")
+    public String exportPhone(@RequestBody WarehousingOrder example, HttpServletResponse response) throws Exception {
+        return warehousingOrderService.exportPhone(example,response);
+    }
+
+    /**
+     * 手机审核数据
+     *
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/exportPhoneData")
+    public WarehousingOrder exportPhoneData(@RequestBody WarehousingOrder warehousingOrder) {
+        return warehousingOrderService.exportPhoneData(warehousingOrder);
+    }
 
 }
 

+ 4 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/ContractExpensesInfo.java

@@ -60,6 +60,10 @@ public class ContractExpensesInfo extends BaseModel<ContractExpensesInfo> {
      * 类型(1收入2支出)
      */
     private String expensesType;
+    /**
+     * 费用类型(1粮款3非粮款5保证金)
+     */
+    private String grainType;
     /**
      * 费用名称
      */

+ 14 - 1
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/ContractManagementInfo.java

@@ -555,7 +555,20 @@ public class ContractManagementInfo extends BaseModel<ContractManagementInfo> {
      */
     @TableField(exist = false)
     private String searchContractType;
-
+    /**
+     * 图表类型
+     */
+    @TableField(exist = false)
+    private String type;
+    /**
+     * 图表合同利润
+     */
+    @TableField(exist = false)
+    private Double contractProfit;
+    @TableField(exist = false)
+    private List<ContractManagementInfo> chartList;
+    @TableField(exist = false)
+    private List<ContractManagementInfo> formList;
 
     @Override
     protected Serializable pkVal() {

+ 6 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/SourceRelationInfo.java

@@ -2,6 +2,7 @@ package com.yh.saas.plugin.yiliangyiyun.entity;
 
 import java.util.Date;
 import java.io.Serializable;
+import java.util.List;
 
 import com.baomidou.mybatisplus.annotations.TableField;
 import com.baomidou.mybatisplus.annotations.TableId;
@@ -95,6 +96,11 @@ public class SourceRelationInfo extends BaseModel<SourceRelationInfo> {
      */
     @TableField(exist = false)
     private String returnTickFlag;
+    /**
+     * 货源关联列表
+     */
+    @TableField(exist = false)
+    private List<SourceRelationInfo> sourceRelationInfoList;
 
     @Override
     protected Serializable pkVal() {

+ 5 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/WarehousingOrder.java

@@ -253,6 +253,11 @@ public class WarehousingOrder extends BaseModel<WarehousingOrder> {
      */
     @TableField(exist = false)
     private Float inWarehouseWeightTotal;
+    /**
+     *車數
+     */
+    @TableField(exist = false)
+    private Integer count;
 
     @Override
     protected Serializable pkVal() {

+ 15 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/mapper/ContractManagementInfoMapper.java

@@ -50,4 +50,19 @@ public interface ContractManagementInfoMapper extends BaseMapper<ContractManagem
      * @return
      */
     List<ContractManagementInfo> getContractListByCondition(Map<String, Object> pageView);
+
+    /**
+     * 合同利润图
+     *
+     * @param pageView
+     * @return
+     */
+    List<ContractManagementInfo> getContractChartByCondition(Map<String, Object> pageView);
+    /**
+     * 合同利润表
+     *
+     * @param pageView
+     * @return
+     */
+    List<ContractManagementInfo> getContractFormByCondition(Map<String, Object> pageView);
 }

+ 8 - 1
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/IExpenseInfoService.java

@@ -5,7 +5,7 @@ import com.yh.saas.plugin.yiliangyiyun.entity.ExpenseInfo;
 import com.baomidou.mybatisplus.service.IService;
 import com.yh.saas.plugin.yiliangyiyun.entity.WarehousingOrder;
 
-import java.util.Date;
+import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 
 /**
@@ -76,4 +76,11 @@ public interface IExpenseInfoService extends IService<ExpenseInfo> {
      * @return
      */
     List<ExpenseInfo> expenseList(String compId,String startDate,String endDate);
+    /**
+     * 手机审核文件下载
+     * @param expenseInfo
+     * @param response
+     * @throws Exception
+     */
+    String exportPhone(ExpenseInfo expenseInfo, HttpServletResponse response) throws Exception;
 }

+ 17 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/IWarehousingOrderService.java

@@ -1,11 +1,14 @@
 package com.yh.saas.plugin.yiliangyiyun.service;
 
 import com.baomidou.mybatisplus.plugins.Page;
+import com.yh.saas.plugin.yiliangyiyun.entity.PaymentManagement;
 import com.yh.saas.plugin.yiliangyiyun.entity.SourceRelationInfo;
 import com.yh.saas.plugin.yiliangyiyun.entity.WarehouseInOutInfo;
 import com.yh.saas.plugin.yiliangyiyun.entity.WarehousingOrder;
 import com.baomidou.mybatisplus.service.IService;
+import com.yh.saas.plugin.yiliangyiyun.entity.view.PaymentView;
 
+import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 
 /**
@@ -43,5 +46,19 @@ public interface IWarehousingOrderService extends IService<WarehousingOrder> {
      * @param warehousingOrder
      */
     String payMoney(WarehousingOrder warehousingOrder);
+    /**
+     * 手机审核文件下载
+     * @param warehousingOrder
+     * @param response
+     * @throws Exception
+     */
+    String exportPhone(WarehousingOrder warehousingOrder, HttpServletResponse response) throws Exception;
+    /**
+     * 手机审核数据
+     * @param warehousingOrder
+     * @param
+     * @throws Exception
+     */
+    WarehousingOrder exportPhoneData(WarehousingOrder warehousingOrder);
 
 }

+ 5 - 10
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/ContractExpensesInfoServiceImpl.java

@@ -36,16 +36,11 @@ public class ContractExpensesInfoServiceImpl extends ServiceImpl<ContractExpense
                 * contractExpensesInfo.getPageSize());
         //  公司ID
         pageView.put("compId", AuthSecurityUtils.getCurrentUserInfo().getCompId());
-        //合同费用
-        if("1".equals(contractExpensesInfo.getCostType())){
-            pageView.put("contractNo", contractExpensesInfo.getContractNo());
-        }
-        //库点费用
-        else{
-            pageView.put("warehouseName",contractExpensesInfo.getWarehouseName());
-            pageView.put("startDate", contractExpensesInfo.getStartDate());
-            pageView.put("endDate", contractExpensesInfo.getEndDate());
-        }
+        pageView.put("contractNo", contractExpensesInfo.getContractNo());
+        pageView.put("costType",contractExpensesInfo.getCostType());
+        pageView.put("warehouseName",contractExpensesInfo.getWarehouseName());
+        pageView.put("startDate", contractExpensesInfo.getStartDate());
+        pageView.put("endDate", contractExpensesInfo.getEndDate());
         pageView.put("pageSize", contractExpensesInfo.getPageSize());
         pageView.put("currentPage", contractExpensesInfo.getCurrentPage());
         // 查询服务商总数

+ 16 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/ContractManagementInfoServiceImpl.java

@@ -2292,4 +2292,20 @@ public class ContractManagementInfoServiceImpl extends ServiceImpl<ContractManag
         return page;
     }
 
+    @Override
+    public ContractManagementInfo selectContractChart(ContractManagementInfo contractManagementInfo) {
+        ContractManagementInfo  contractManagementInfo1=new ContractManagementInfo();
+        Map<String, Object> pageView = new HashMap<>();
+        //  公司ID
+        pageView.put("compId", AuthSecurityUtils.getCurrentUserInfo().getCompId());
+        pageView.put("startDate", contractManagementInfo.getStartDate());
+        pageView.put("endDate", contractManagementInfo.getEndDate());
+        List<ContractManagementInfo> dataList = baseMapper.getContractChartByCondition(pageView);
+        List<ContractManagementInfo> dataList1 = baseMapper.getContractFormByCondition(pageView);
+        contractManagementInfo1.setChartList(dataList);
+        contractManagementInfo1.setFormList(dataList1);
+
+        return contractManagementInfo1;
+    }
+
 }

+ 745 - 21
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/WarehousingOrderServiceImpl.java

@@ -1,12 +1,18 @@
 package com.yh.saas.plugin.yiliangyiyun.service.impl;
 
+import com.alipay.sofa.runtime.api.annotation.SofaService;
+import com.aliyun.oss.OSSClient;
+import com.aliyun.oss.model.ObjectMetadata;
+import com.aliyun.oss.model.PutObjectRequest;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.baomidou.mybatisplus.mapper.Wrapper;
+import com.winsea.svc.base.base.util.DateUtils;
 import com.winsea.svc.base.workflow.entity.Workflow;
 import com.yh.saas.plugin.yiliangyiyun.entity.InOutWarehouseTask;
 import com.yh.saas.plugin.yiliangyiyun.entity.PaymentManagement;
 import com.yh.saas.plugin.yiliangyiyun.entity.WarehouseInOutInfo;
 import com.yh.saas.plugin.yiliangyiyun.entity.WarehousingOrder;
+import com.yh.saas.plugin.yiliangyiyun.entity.view.PaymentView;
 import com.yh.saas.plugin.yiliangyiyun.exception.YException;
 import com.yh.saas.plugin.yiliangyiyun.exception.YExceptionEnum;
 import com.yh.saas.plugin.yiliangyiyun.mapper.WarehousingOrderMapper;
@@ -28,13 +34,31 @@ import com.yh.saas.plugin.yiliangyiyun.constant.NumberConstant;
 import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
 import com.yh.saas.plugin.yiliangyiyun.entity.*;
 import com.yh.saas.plugin.yiliangyiyun.service.*;
+import lombok.Getter;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.httpclient.util.DateUtil;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.http.entity.ContentType;
+import org.apache.poi.hssf.usermodel.*;
+import org.apache.poi.hssf.util.HSSFColor;
+import org.apache.poi.ss.usermodel.IndexedColors;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.util.CellRangeAddress;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.mock.web.MockMultipartFile;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
+import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.math.RoundingMode;
+import java.net.URLDecoder;
+import java.nio.charset.StandardCharsets;
+import java.text.DecimalFormat;
 import java.util.ArrayList;
 import java.util.List;
 import java.text.SimpleDateFormat;
@@ -50,6 +74,7 @@ import java.util.stream.Collectors;
  * @since 2022-05-17
  */
 @Service
+@Slf4j
 public class WarehousingOrderServiceImpl extends ServiceImpl<WarehousingOrderMapper, WarehousingOrder> implements IWarehousingOrderService {
     @Autowired
     private IInOutWarehouseTaskService inOutWarehouseTaskService;
@@ -63,6 +88,15 @@ public class WarehousingOrderServiceImpl extends ServiceImpl<WarehousingOrderMap
     private IPaymentManagementService paymentManagementService;
     @Autowired
     private IWarehouseBaseInfoService warehouseBaseInfoService;
+    @Value("${file-root-path}")
+    private String localPath;
+    @Autowired
+    private OSSClient ossClient;
+    @Value("${oss.endpoint.internal:}")
+    private String baseUrl;
+    @Getter
+    @Value("${oss.bucket.name:}")
+    private String bucket;
     @Autowired
     private IIdentityAuthenticationInfoService identityAuthenticationInfoService;
     @Autowired
@@ -106,10 +140,8 @@ public class WarehousingOrderServiceImpl extends ServiceImpl<WarehousingOrderMap
                     List<SourceRelationInfo> sourceRelationInfoList1 = sourceRelationInfoService.selectList(new EntityWrapper<SourceRelationInfo>()
                             .eq("task_id", inOutWarehouseTask.getId())
                             .eq("delete_flag", "0"));
-                    if (!CollectionUtils.isEmpty(sourceRelationInfoList)){
-                        for (SourceRelationInfo sourceRelationInfo1:sourceRelationInfoList1){
-                            goodsSource=goodsSource+","+sourceRelationInfo1.getGoodsSource();
-                        }
+                    if (!CollectionUtils.isEmpty(sourceRelationInfoList1)){
+                        sourceRelationInfo.setSourceRelationInfoList(sourceRelationInfoList1);
                     }
                 }
                 sourceRelationInfo.setGoodsSource(goodsSource);
@@ -160,7 +192,7 @@ public class WarehousingOrderServiceImpl extends ServiceImpl<WarehousingOrderMap
                 String taskId = "";
                 // 只有待审核状态才有taskId
                 if (StringUtils.isNotBlank(warehousingOrder1.getWorkflowId())) {
-                    JSONObject jsonObject = workflowService.getActiveTask(Lists.newArrayList(warehousingOrder1.getWorkflowId()), warehousingOrder1.getId());
+                    JSONObject jsonObject = workflowService.getActiveTask(Lists.newArrayList(warehousingOrder1.getWorkflowId()), warehousingOrder1.getBatchId());
                     taskId = jsonObject.getString("taskId");
                     warehousingOrder1.setTaskId(taskId);
                 }
@@ -226,7 +258,6 @@ public class WarehousingOrderServiceImpl extends ServiceImpl<WarehousingOrderMap
                 this.insert(warehousingOrder);
             }
         }
-        String compId = AuthSecurityUtils.getStaffById(AuthSecurityUtils.getCurrentUserId()).getCompId();
         //采购入库
         List<WarehouseInOutInfo> warehouseInOutInfoList = warehouseInOutInfoService.selectList(new EntityWrapper<WarehouseInOutInfo>()
                 .eq("status", "已提交")
@@ -354,17 +385,106 @@ public class WarehousingOrderServiceImpl extends ServiceImpl<WarehousingOrderMap
      * @return
      */
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public String editInfo(WarehousingOrder warehousingOrder) {
         // 插入操作历史
         String staffName = this.billOperateHisService.getStaffAndName();
         if ("0".equals(warehousingOrder.getFlag())) {
+            warehousingOrder.setInventoryStatus(StatusEnum.GRAIN_REVIEWED.getName());
+            warehousingOrder.setOperationFlag("盘盈");
             // 插入操作历史
             this.billOperateHisService.saveBillOperateHis(warehousingOrder.getId(), NumberConstant.INVENTORY_CHECK, staffName, null,
-                    "盘盈" + "(" + warehousingOrder.getProfitAndLoss() + ")", null, "审核中");
+                    "盘盈" + "(" + warehousingOrder.getPlValue() + ")", null, "审核中");
+//            boolean isStartWorkflow = StringUtils.isBlank(warehousingOrder.getWorkflowId());
+//                // 不是退回的单子
+//                if (isStartWorkflow) {
+//                    Workflow workflow = workflowService
+//                            .findLatestWorkflowByBusinessCodeByApp(warehousingOrder.getCompId(), "WAREHOUSING-DEBIT-APPROVE");
+//                    // 没配置审核流程,直接结束并处理信息
+//                    if (workflow == null) {
+//                        throw new YException(YExceptionEnum.PURCHASE_ORDER_ERROR);
+//                    }
+//                    // 开启审核流
+//                    else {
+//
+//                        // 设置状态 已提交审核
+//                        warehousingOrder.setWorkflowId(workflow.getId());
+//                        this.updateById(warehousingOrder);
+//                        workflowService.startInstance(workflow.getId(), warehousingOrder.getId());
+//                    }
+//                }
+//                // 退回的单子 再启用
+//                else {
+//
+//                    this.updateById(warehousingOrder);
+//                    workflowService.activateInstance(warehousingOrder.getWorkflowId(), warehousingOrder.getId());
+//                }
         }
         else if ("1".equals(warehousingOrder.getFlag())){
+            warehousingOrder.setInventoryStatus(StatusEnum.GRAIN_REVIEWED.getName());
+            warehousingOrder.setOperationFlag("盘亏");
             this.billOperateHisService.saveBillOperateHis(warehousingOrder.getId(), NumberConstant.INVENTORY_CHECK, staffName, null,
-                    "盘亏" + "(" + warehousingOrder.getProfitAndLoss() + ")", null, "审核中");
+                    "盘亏" + "(" + warehousingOrder.getPlValue() + ")", null, "审核中");
+//            boolean isStartWorkflow = StringUtils.isBlank(warehousingOrder.getWorkflowId());
+//                // 不是退回的单子
+//                if (isStartWorkflow) {
+//                    Workflow workflow = workflowService
+//                            .findLatestWorkflowByBusinessCodeByApp(warehousingOrder.getCompId(), "WAREHOUSING-DEBIT-APPROVE");
+//                    // 没配置审核流程,直接结束并处理信息
+//                    if (workflow == null) {
+//                        throw new YException(YExceptionEnum.PURCHASE_ORDER_ERROR);
+//                    }
+//                    // 开启审核流
+//                    else {
+//
+//                        // 设置状态 已提交审核
+//                        warehousingOrder.setWorkflowId(workflow.getId());
+//                        this.updateById(warehousingOrder);
+//                        workflowService.startInstance(workflow.getId(), warehousingOrder.getId());
+//                    }
+//                }
+//                // 退回的单子 再启用
+//                else {
+//
+//                    this.updateById(warehousingOrder);
+//                    workflowService.activateInstance(warehousingOrder.getWorkflowId(), warehousingOrder.getId());
+//                }
+        }
+        //盘盈通过
+        else if ("2".equals(warehousingOrder.getFlag())){
+            warehousingOrder.setProfitAndLoss(warehousingOrder.getProfitAndLoss()+warehousingOrder.getPlValue());
+            warehousingOrder.setPlValue(0f);
+            warehousingOrder.setOperationFlag("");
+            warehousingOrder.setInventoryStatus(StatusEnum.GRAIN_ADOPT.getName());
+            this.billOperateHisService.saveBillOperateHis(warehousingOrder.getId(), NumberConstant.INVENTORY_CHECK, staffName, null,
+                    "盘盈" + "(" + warehousingOrder.getPlValue() + ")", null, "已通过");
+        }
+        //盘亏通过
+        else if ("3".equals(warehousingOrder.getFlag())){
+            warehousingOrder.setInventoryStatus(StatusEnum.GRAIN_ADOPT.getName());
+            warehousingOrder.setProfitAndLoss(warehousingOrder.getProfitAndLoss()+warehousingOrder.getPlValue());
+            warehousingOrder.setOperationFlag("");
+            warehousingOrder.setPlValue(0f);
+            warehousingOrder.setProfitAndLoss(warehousingOrder.getProfitAndLoss()+warehousingOrder.getPlValue());
+            this.billOperateHisService.saveBillOperateHis(warehousingOrder.getId(), NumberConstant.INVENTORY_CHECK, staffName, null,
+                    "盘亏" + "(" + warehousingOrder.getPlValue() + ")", null, "已通过");
+        }
+        //盘盈驳回
+        else if ("4".equals(warehousingOrder.getFlag())){
+            warehousingOrder.setPlValue(0f);
+            warehousingOrder.setInventoryStatus(StatusEnum.GRAIN_REJECT.getName());
+            warehousingOrder.setOperationFlag("");
+            this.billOperateHisService.saveBillOperateHis(warehousingOrder.getId(), NumberConstant.INVENTORY_CHECK, staffName, null,
+                    "盘盈" + "(" + warehousingOrder.getPlValue() + ")", null, "已驳回");
+        }
+        //盘亏驳回
+        else if ("5".equals(warehousingOrder.getFlag())){
+            warehousingOrder.setInventoryStatus(StatusEnum.GRAIN_REJECT.getName());
+            warehousingOrder.setOperationFlag("");
+            warehousingOrder.setPlValue(0f);
+            warehousingOrder.setProfitAndLoss(warehousingOrder.getProfitAndLoss()+warehousingOrder.getPlValue());
+            this.billOperateHisService.saveBillOperateHis(warehousingOrder.getId(), NumberConstant.INVENTORY_CHECK, staffName, null,
+                    "盘亏" + "(" + warehousingOrder.getPlValue() + ")", null, "已驳回 ");
         }
         // 主表信息编辑
         boolean one = this.updateById(warehousingOrder);
@@ -377,21 +497,24 @@ public class WarehousingOrderServiceImpl extends ServiceImpl<WarehousingOrderMap
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public String payMoney(WarehousingOrder warehousingOrder) {
         List<WarehousingOrder> warehousingOrderList = warehousingOrder.getWarehousingOrderList();
         if (!CollectionUtils.isEmpty(warehousingOrderList)) {
             //付款多条
             if ("0".equals(warehousingOrder.getFlag())) {
                 for (WarehousingOrder warehousingOrder1 : warehousingOrderList) {
-                    warehousingOrder1.setAmountNotPayable(0d);
-                    warehousingOrder1.setAmountEdPayable(warehousingOrder1.getGrainFund());
+                    warehousingOrder1.setAmountNotPayable(warehousingOrder1.getAmountNotPayable()-warehousingOrder1.getRequestFunds());
+                    warehousingOrder1.setAmountEdPayable(warehousingOrder1.getAmountEdPayable()+warehousingOrder1.getRequestFunds());
+                    warehousingOrder1.setRequestFunds(0d);
                     this.updateById(warehousingOrder1);
                 }
             }
             //请款
             else {
-                String batchId = UUID.randomUUID().toString();
+                String batchId = IdGenerator.generateUUID();
                 String workflowId = "";
+
                 if(warehousingOrderList.size() > 0){
                     WarehousingOrder warehousingOrder1 = warehousingOrderList.get(0);
                     boolean isStartWorkflow = StringUtils.isBlank(warehousingOrder1.getWorkflowId());
@@ -406,30 +529,631 @@ public class WarehousingOrderServiceImpl extends ServiceImpl<WarehousingOrderMap
                         // 开启审核流
                         else {
                             workflowId = workflow.getId();
+                            for (WarehousingOrder warehousingOrder2 : warehousingOrderList) {
+                                warehousingOrder2.setStatusFlag(StatusEnum.PENDING_PAYMENT.getFlag());
+                                warehousingOrder2.setStatus(StatusEnum.PENDING_PAYMENT.getName());
+                                warehousingOrder2.setWorkflowId(workflowId);
+                                warehousingOrder2.setBatchId(batchId);
+                                this.updateById(warehousingOrder2);
+                            }
                             // 设置状态 已提交审核
-                            warehousingOrder1.setWorkflowId(workflow.getId());
-                            this.updateById(warehousingOrder1);
                             workflowService.startInstance(workflow.getId(), batchId);
                         }
                     }
                     // 退回的单子 再启用
                     else {
-                        this.updateById(warehousingOrder1);
+                        batchId = warehousingOrder1.getBatchId();
+                        for (WarehousingOrder warehousingOrder2 : warehousingOrderList) {
+                            warehousingOrder2.setStatusFlag(StatusEnum.PENDING_PAYMENT.getFlag());
+                            warehousingOrder2.setStatus(StatusEnum.PENDING_PAYMENT.getName());
+                            warehousingOrder2.setWorkflowId(workflowId);
+                            warehousingOrder2.setBatchId(batchId);
+                            this.updateById(warehousingOrder2);
+                        }
                         workflowService.activateInstance(warehousingOrder1.getWorkflowId(), warehousingOrder1.getBatchId());
                     }
                 }
-
-                for (WarehousingOrder warehousingOrder1 : warehousingOrderList) {
-                    warehousingOrder1.setStatusFlag(StatusEnum.PENDING_PAYMENT.getFlag());
-                    warehousingOrder1.setStatus(StatusEnum.PENDING_PAYMENT.getName());
-                    warehousingOrder1.setWorkflowId(workflowId);
-                    this.updateById(warehousingOrder1);
-                }
             }
         }
         return "OK";
     }
 
+    @Override
+    public String exportPhone(WarehousingOrder warehousingOrder, HttpServletResponse response) throws Exception {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+
+
+        // 1.Excel的头部信息
+        String headerTitle = "";
+
+        // 2.创建一个webbook 对应一个Excel文件
+        HSSFWorkbook wb = new HSSFWorkbook();
+
+        // 3.在webbook中添加一个sheet,对应Excel文件中的sheet
+        HSSFSheet sheet;
+
+        sheet = wb.createSheet("入库单信息");
+        headerTitle = "入库单信息";
+
+        // 4.设置打印参数
+        sheet.setMargin(HSSFSheet.TopMargin, (short) 1);// 页边距(上)
+        sheet.setMargin(HSSFSheet.BottomMargin, (short) 1);// 页边距(下)
+        sheet.setMargin(HSSFSheet.LeftMargin, (short) 1);// 页边距(左)
+        sheet.setMargin(HSSFSheet.RightMargin, (short) 1);// 页边距(右)
+
+        // 不显示网格
+        sheet.setDisplayGridlines(false);
+        // 设置水平居中
+        sheet.setHorizontallyCenter(true);
+
+        /**************** 数据行样式 start ****************/
+        HSSFFont fontTitle = wb.createFont();
+        fontTitle.setFontName("宋体");
+        fontTitle.setFontHeightInPoints((short) 14);
+        // 设置字体加粗
+        fontTitle.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
+
+        HSSFFont fontComp = wb.createFont();
+        fontComp.setFontName("宋体");
+        fontComp.setFontHeightInPoints((short) 16);
+        // 设置字体加粗
+        fontComp.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
+
+        HSSFFont fontDetail = wb.createFont();
+        fontDetail.setFontName("宋体");
+        fontDetail.setFontHeightInPoints((short) 12);
+
+        HSSFFont fontDetail1 = wb.createFont();
+        fontDetail1.setFontName("宋体");
+        fontDetail1.setFontHeightInPoints((short) 12);
+        fontDetail1.setColor(HSSFColor.RED.index);
+
+        // title
+        HSSFCellStyle styleTitle = wb.createCellStyle();
+        // 指定单元格居中对齐
+        styleTitle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
+        // 指定单元格垂直居中对齐
+        styleTitle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
+        // 指定单元格自动换行
+        styleTitle.setWrapText(true);
+        // 设置单元格字体
+        styleTitle.setFont(fontTitle);
+        // 右边框
+        styleTitle.setBorderRight(HSSFCellStyle.BORDER_NONE);
+        // 左边框
+        styleTitle.setBorderLeft(HSSFCellStyle.BORDER_NONE);
+        // 上边框
+        styleTitle.setBorderTop(HSSFCellStyle.BORDER_NONE);
+        // 下边框
+        styleTitle.setBorderBottom(HSSFCellStyle.BORDER_NONE);
+
+        // title
+        HSSFCellStyle styleComp = wb.createCellStyle();
+        // 指定单元格居中对齐
+        styleComp.setAlignment(HSSFCellStyle.ALIGN_CENTER);
+        // 指定单元格垂直居中对齐
+        styleComp.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
+        // 指定单元格自动换行
+        styleComp.setWrapText(true);
+        // 设置单元格字体
+        styleComp.setFont(fontComp);
+        // 右边框
+        styleComp.setBorderRight(HSSFCellStyle.BORDER_NONE);
+        // 左边框
+        styleComp.setBorderLeft(HSSFCellStyle.BORDER_NONE);
+        // 上边框
+        styleComp.setBorderTop(HSSFCellStyle.BORDER_NONE);
+        // 下边框
+        styleComp.setBorderBottom(HSSFCellStyle.BORDER_NONE);
+
+        HSSFCellStyle styleInfo = wb.createCellStyle();
+        // 指定单元格居中对齐
+        styleInfo.setAlignment(HSSFCellStyle.ALIGN_LEFT);
+        // 指定单元格垂直居中对齐
+        styleInfo.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
+        // 指定单元格自动换行
+        styleInfo.setWrapText(true);
+        // 设置单元格字体
+        styleInfo.setFont(fontDetail);
+        // 右边框
+        styleInfo.setBorderRight(HSSFCellStyle.BORDER_NONE);
+        // 左边框
+        styleInfo.setBorderLeft(HSSFCellStyle.BORDER_NONE);
+        // 上边框
+        styleInfo.setBorderTop(HSSFCellStyle.BORDER_NONE);
+        // 下边框
+        styleInfo.setBorderBottom(HSSFCellStyle.BORDER_NONE);
+
+        HSSFCellStyle styleDetail = wb.createCellStyle();
+        // 指定单元格居中对齐
+        styleDetail.setAlignment(HSSFCellStyle.ALIGN_CENTER);
+        // 指定单元格垂直居中对齐
+        styleDetail.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
+        // 指定单元格自动换行
+        styleDetail.setWrapText(true);
+        // 设置单元格字体
+        styleDetail.setFont(fontDetail);
+        // 右边框
+        styleDetail.setBorderRight(HSSFCellStyle.BORDER_THIN);
+        // 左边框
+        styleDetail.setBorderLeft(HSSFCellStyle.BORDER_THIN);
+        // 上边框
+        styleDetail.setBorderTop(HSSFCellStyle.BORDER_THIN);
+        // 下styleDetailTitle
+        styleDetail.setBorderBottom(HSSFCellStyle.BORDER_THIN);
+
+        HSSFCellStyle styleDetail1 = wb.createCellStyle();
+        // 指定单元格居中对齐
+        styleDetail1.setAlignment(HSSFCellStyle.ALIGN_CENTER);
+        // 指定单元格垂直居中对齐
+        styleDetail1.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
+        // 指定单元格自动换行
+        styleDetail1.setWrapText(true);
+        // 设置单元格字体
+        styleDetail1.setFont(fontDetail1);
+        // 右边框
+        styleDetail1.setBorderRight(HSSFCellStyle.BORDER_THIN);
+        // 左边框
+        styleDetail1.setBorderLeft(HSSFCellStyle.BORDER_THIN);
+        // 上边框
+        styleDetail1.setBorderTop(HSSFCellStyle.BORDER_THIN);
+        // 下styleDetailTitle
+        styleDetail1.setBorderBottom(HSSFCellStyle.BORDER_THIN);
+
+        HSSFCellStyle contextstyle = wb.createCellStyle();
+        // 指定单元格居中对齐
+        contextstyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
+        // 指定单元格垂直居中对齐
+        contextstyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
+        // 指定单元格自动换行
+        contextstyle.setWrapText(true);
+        // 设置单元格字体
+        contextstyle.setFont(fontDetail);
+        // 右边框
+        contextstyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
+        // 左边框
+        contextstyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
+        // 上边框
+        contextstyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
+        // 下styleDetailTitle
+        contextstyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
+
+        HSSFCellStyle contextstyle1 = wb.createCellStyle();
+        // 指定单元格居中对齐
+        contextstyle1.setAlignment(HSSFCellStyle.ALIGN_CENTER);
+        // 指定单元格垂直居中对齐
+        contextstyle1.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
+        // 指定单元格自动换行
+        contextstyle1.setWrapText(true);
+        // 设置单元格字体
+        contextstyle1.setFont(fontDetail1);
+        // 右边框
+        contextstyle1.setBorderRight(HSSFCellStyle.BORDER_THIN);
+        // 左边框
+        contextstyle1.setBorderLeft(HSSFCellStyle.BORDER_THIN);
+        // 上边框
+        contextstyle1.setBorderTop(HSSFCellStyle.BORDER_THIN);
+        // 下styleDetailTitle
+        contextstyle1.setBorderBottom(HSSFCellStyle.BORDER_THIN);
+
+        HSSFCellStyle styleDetailYellow = wb.createCellStyle();
+        // 指定单元格居中对齐
+        styleDetailYellow.setAlignment(HSSFCellStyle.ALIGN_CENTER);
+        // 指定单元格垂直居中对齐
+        styleDetailYellow.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
+        // 指定单元格自动换行
+        styleDetailYellow.setWrapText(true);
+        // 设置单元格字体
+        styleDetailYellow.setFont(fontDetail);
+        // 右边框
+        styleDetailYellow.setBorderRight(HSSFCellStyle.BORDER_THIN);
+        // 左边框
+        styleDetailYellow.setBorderLeft(HSSFCellStyle.BORDER_THIN);
+        // 上边框
+        styleDetailYellow.setBorderTop(HSSFCellStyle.BORDER_THIN);
+        // 下styleDetailTitle
+        styleDetailYellow.setBorderBottom(HSSFCellStyle.BORDER_THIN);
+        styleDetailYellow.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
+        styleDetailYellow.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
+
+
+        HSSFCellStyle styleDetailLeft = wb.createCellStyle();
+        // 指定单元格居中对齐
+        styleDetailLeft.setAlignment(HSSFCellStyle.ALIGN_LEFT);
+        // 指定单元格垂直居中对齐
+        styleDetailLeft.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
+        // 指定单元格自动换行
+        styleDetailLeft.setWrapText(true);
+        // 设置单元格字体
+        styleDetailLeft.setFont(fontDetail);
+        // 右边框
+        styleDetailLeft.setBorderRight(HSSFCellStyle.BORDER_THIN);
+        // 左边框
+        styleDetailLeft.setBorderLeft(HSSFCellStyle.BORDER_THIN);
+        // 上边框
+        styleDetailLeft.setBorderTop(HSSFCellStyle.BORDER_THIN);
+        // 下styleDetailTitle
+        styleDetailLeft.setBorderBottom(HSSFCellStyle.BORDER_THIN);
+        /**************** 数据行样式 end ****************/
+
+        // 设置列宽
+        sheet.setColumnWidth(0, 1 * 256 + 184);
+        sheet.setColumnWidth(1, "货源".getBytes().length*3*256);
+        sheet.setColumnWidth(2, "发货库".getBytes().length*25/10*256);
+        sheet.setColumnWidth(3, "货名".getBytes().length*3*256);
+        sheet.setColumnWidth(4, 12 * 256 + 184);
+        sheet.setColumnWidth(5, 12 * 256 + 184);
+        sheet.setColumnWidth(6, 12 * 256 + 184);
+        sheet.setColumnWidth(7, 12 * 256 + 184);
+        sheet.setColumnWidth(8, 12 * 256 + 184);
+        sheet.setColumnWidth(9, 12 * 256 + 184);
+        sheet.setColumnWidth(10, 12 * 256 + 184);
+        sheet.setColumnWidth(11, 12 * 256 + 184);
+        sheet.setColumnWidth(12, 12 * 256 + 184);
+        sheet.setColumnWidth(13, 12 * 256 + 184);
+        sheet.setColumnWidth(14, 1 * 256 + 184);
+
+        // 创建单元格对象
+        HSSFCell cell = null;
+
+        // 创建打印设置对象
+        HSSFPrintSetup ps = sheet.getPrintSetup();
+        // 打印方向,true:横向,false:纵向(默认)
+        ps.setLandscape(false);
+        // // 打印质量
+        // ps.setVResolution((short) 700)
+        // 设置缩放比例
+        ps.setScale((short) 80);
+        // 纸张类型
+        ps.setPaperSize(HSSFPrintSetup.A4_PAPERSIZE);
+
+
+        int rownum = 1;
+        HSSFRow row0 = sheet.createRow((int) rownum);
+        row0.setHeightInPoints(25);
+        cell = row0.createCell(1);
+        cell.setCellStyle(styleTitle);
+        cell.setCellValue("入库单信息");
+        sheet.addMergedRegion(new CellRangeAddress(rownum, rownum, (short) 1, (short) 13));
+        cell = row0.createCell(2);
+        cell.setCellStyle(styleTitle);
+        cell = row0.createCell(3);
+        cell.setCellStyle(styleTitle);
+        cell = row0.createCell(4);
+        cell.setCellStyle(styleTitle);
+        cell = row0.createCell(5);
+        cell.setCellStyle(styleTitle);
+        cell = row0.createCell(6);
+        cell.setCellStyle(styleTitle);
+        cell = row0.createCell(7);
+        cell.setCellStyle(styleTitle);
+        cell = row0.createCell(8);
+        cell.setCellStyle(styleTitle);
+        cell = row0.createCell(9);
+        cell.setCellStyle(styleTitle);
+        cell = row0.createCell(10);
+        cell.setCellStyle(styleTitle);
+        cell = row0.createCell(11);
+        cell.setCellStyle(styleTitle);
+        cell = row0.createCell(12);
+        cell.setCellStyle(styleTitle);
+        cell = row0.createCell(13);
+        cell.setCellStyle(styleTitle);
+        rownum++;
+
+        List<String> businessKeys = null;
+        if ("1".equals(warehousingOrder.getSearchType())) {
+            businessKeys = workflowService.getTaskBusinessKeysByCode("WAREHOUSING-ORDER-APPROVE");
+        }
+
+        Map<String, Object> pageView = new HashMap<>();
+        pageView.put("businessKeys", businessKeys);
+        pageView.put("batchId", warehousingOrder.getBatchId());
+        // 查询入库单总数
+        List<WarehousingOrder> dataList = baseMapper.getListByCondition(pageView);
+
+
+
+        Double requestFundsTotal = 0d;//请款合计
+        for (int i = 0; i < dataList.size(); i++) {
+            WarehousingOrder warehousingOrder1 = dataList.get(i);
+            //请款累计和
+            requestFundsTotal = requestFundsTotal + warehousingOrder1.getRequestFunds();
+        }
+
+        HSSFRow rowp = sheet.createRow((int)(rownum));
+        rowp.setHeightInPoints(20);
+        cell = rowp.createCell(1);
+        cell.setCellValue("合计");
+        cell.setCellStyle(styleDetail);
+        cell = rowp.createCell(2);
+        cell.setCellStyle(styleDetail);
+        cell = rowp.createCell(3);
+        cell.setCellStyle(styleDetail);
+        cell = rowp.createCell(4);
+        cell.setCellStyle(styleDetail);
+        cell = rowp.createCell(5);
+        cell.setCellStyle(styleDetail);
+        cell = rowp.createCell(6);
+        cell.setCellStyle(styleDetail);
+        cell = rowp.createCell(7);
+        cell.setCellStyle(styleDetail);
+        cell = rowp.createCell(8);
+        cell.setCellStyle(styleDetail);
+        cell = rowp.createCell(9);
+        cell.setCellStyle(styleDetail);
+        cell = rowp.createCell(10);
+        cell.setCellStyle(styleDetail);
+        cell = rowp.createCell(11);
+        cell.setCellStyle(styleDetail);
+        cell = rowp.createCell(12);
+        cell.setCellStyle(styleDetail);
+        cell = rowp.createCell(13);
+        cell.setCellValue(requestFundsTotal);
+        cell.setCellStyle(styleDetail1);
+        rownum++;
+
+        HSSFRow row1 = sheet.createRow((int) rownum);
+        row1.setHeightInPoints(30);
+        cell = row1.createCell(1);
+        cell.setCellValue("货源");
+        cell.setCellStyle(styleDetail);
+        cell = row1.createCell(2);
+        cell.setCellValue("发货库");
+        cell.setCellStyle(styleDetail);
+        cell = row1.createCell(3);
+        cell.setCellValue("货名");
+        cell.setCellStyle(styleDetail);
+        cell = row1.createCell(4);
+        cell.setCellValue("入库重量(吨)");
+        cell.setCellStyle(styleDetail);
+        cell = row1.createCell(5);
+        cell.setCellValue("出库重量(吨)");
+        cell.setCellStyle(styleDetail);
+        cell = row1.createCell(6);
+        cell.setCellValue("盈亏(吨)");
+        cell.setCellStyle(styleDetail);
+        cell = row1.createCell(7);
+        cell.setCellValue("剩余重量(吨)");
+        cell.setCellStyle(styleDetail);
+        cell = row1.createCell(8);
+        cell.setCellValue("粮款(元)");
+        cell.setCellStyle(styleDetail);
+        cell = row1.createCell(9);
+        cell.setCellValue("已付(元)");
+        cell.setCellStyle(styleDetail);
+        cell = row1.createCell(10);
+        cell.setCellValue("未付(元)");
+        cell.setCellStyle(styleDetail);
+        cell = row1.createCell(11);
+        cell.setCellValue("费用(元)");
+        cell.setCellStyle(styleDetail);
+        cell = row1.createCell(12);
+        cell.setCellValue("平均成本(元/吨)");
+        cell.setCellStyle(styleDetail);
+        cell = row1.createCell(13);
+        cell.setCellValue("请款(元)");
+        cell.setCellStyle(styleDetail);
+        rownum++;
+
+        // 详情信息
+        if (!CollectionUtils.isEmpty(dataList)) {
+            for (int i = 0; i < dataList.size(); i++) {
+                WarehousingOrder warehousingOrder1 = dataList.get(i);
+
+                HSSFRow rowx = sheet.createRow((int) rownum);
+                rowx.setHeightInPoints(20);
+                cell = rowx.createCell(1);
+                cell.setCellValue(editString(warehousingOrder1.getGoodsSource()));
+                cell.setCellStyle(styleDetail);
+                cell = rowx.createCell(2);
+                cell.setCellValue(editString(warehousingOrder1.getDeliveryWarehouse()));
+                cell.setCellStyle(styleDetail);
+                cell = rowx.createCell(3);
+                cell.setCellValue(editString(warehousingOrder1.getGoodsName()));
+                cell.setCellStyle(styleDetail);
+                cell = rowx.createCell(4);
+                cell.setCellValue(editFloat(warehousingOrder1.getInWarehouseWeight()));
+                cell.setCellStyle(styleDetail);
+                cell = rowx.createCell(5);
+                cell.setCellValue(editFloat(warehousingOrder1.getOutWarehouseWeight()));
+                cell.setCellStyle(styleDetail);
+                cell = rowx.createCell(6);
+                cell.setCellValue(editFloat(warehousingOrder1.getProfitAndLoss()));
+                cell.setCellStyle(styleDetail);
+                cell = rowx.createCell(7);
+                cell.setCellValue(editFloat(warehousingOrder1.getSurplusWeight()));
+                cell.setCellStyle(styleDetail);
+                cell = rowx.createCell(8);
+                cell.setCellValue(editDouble(warehousingOrder1.getGrainFund()));
+                cell.setCellStyle(styleDetail);
+                cell = rowx.createCell(9);
+                cell.setCellValue(editDouble(warehousingOrder1.getAmountEdPayable()));
+                cell.setCellStyle(styleDetail);
+                cell = rowx.createCell(10);
+                cell.setCellValue(editDouble(warehousingOrder1.getAmountNotPayable()));
+                cell.setCellStyle(styleDetail);
+                cell = rowx.createCell(11);
+                cell.setCellValue(editDouble(warehousingOrder1.getAmountMoney()));
+                cell.setCellStyle(styleDetail);
+                cell = rowx.createCell(12);
+                cell.setCellValue(editDouble(warehousingOrder1.getAvgCost()));
+                cell.setCellStyle(styleDetail);
+                cell = rowx.createCell(13);
+                cell.setCellValue(editDouble(warehousingOrder1.getRequestFunds()));
+                cell.setCellStyle(styleDetail);
+                rownum++;
+            }
+
+        }
+
+
+        String path = null;
+        String tempPath = null;
+        String excelPath = null;
+
+        try {
+
+            // 取得绝对路径
+            tempPath = URLDecoder.decode((localPath), "utf-8");
+
+            // EXCEL路径
+            excelPath = "/web/temp/pay/" + DateUtil.formatDate(new Date(), DateUtils.DATE_FMT_YYYYMMDD_NS) + '/'
+                    + UUID.randomUUID().toString().replaceAll("-", "");
+
+            path = tempPath + excelPath + '/' + "仓库信息"
+                    + ".xlsx";
+
+        } catch (Exception e) {
+            log.debug(e.getMessage());
+        }
+
+        return downloadPhone(path, response, wb);
+    }
+    /**
+     * 判断字符串
+     *
+     * @param example
+     * @return
+     */
+    private String editString(String example) {
+        String exampleOne = example != null ? example : "";
+        return exampleOne;
+    }
+    /**
+     * 判断浮点数
+     *
+     * @param example
+     * @return
+     */
+    private Float editFloat(Float example) {
+        Float exampleOne = example != null ? example : 0f;
+        return exampleOne;
+    }
+    /**
+     * 判断浮点数
+     *
+     * @param example
+     * @return
+     */
+    private Double editDouble(Double example) {
+        Double exampleOne = example != null ? example : 0d;
+        return exampleOne;
+    }
+
+    /**
+     * 下载
+     *
+     * @param path
+     * @param response
+     */
+    private String downloadPhone(String path, HttpServletResponse response, Workbook wb) {
+
+        try {
+            // 取得文件名。
+            String fileName = "excel";
+            // 给文件名编码
+            fileName = new String(fileName.getBytes("GBK"), "ISO-8859-1");
+
+            response.setContentType("application/vnd.ms-excel");
+            response.addHeader("Content-Disposition", "attachment;filename=" + fileName);
+
+            // 定义byte输出流
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+            // 写导出文件
+            wb.write(out);
+
+            // 取得模板文件中的数据
+            byte[] result = out.toByteArray();
+
+            // 设置输出数据类型
+            response.setContentType("application/vnd.ms-excel");
+            // 设置输出数据长度
+            response.setContentLength(result.length);
+
+            // 设置文件名称
+            response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
+            // 将文件流输出到画面
+//            response.getOutputStream().write(result);
+
+            out.flush();
+            out.close();
+            //生成的新文件路径
+            String outputFile = "templates" + File.separator + fileName + ".xlsx";
+            File file1 = new File(new String(outputFile.getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8));
+            try (FileOutputStream fos = new FileOutputStream(file1)) {
+                wb.write(fos);
+            }
+
+            FileInputStream fileInputStream = new FileInputStream(file1.getAbsoluteFile());
+
+            MultipartFile multipartFile = new MockMultipartFile(ContentType.APPLICATION_OCTET_STREAM.toString(), fileInputStream);
+            String result1 = upload(multipartFile, fileName);
+            file1.delete();
+            return result1;
+        } catch (IOException ex) {
+            log.debug(ex.getMessage());
+        }
+        return "ng";
+    }
+    /**
+     * 后台通过服务器间接传文件
+     *
+     * @param file
+     * @return
+     * @throws IOException
+     */
+    public String upload(MultipartFile file, String name) throws IOException {
+        ObjectMetadata objectMetadata = new ObjectMetadata();
+        objectMetadata.setContentLength(file.getSize());
+        objectMetadata.setContentType(file.getContentType());
+        PutObjectRequest putObjectRequest = new PutObjectRequest(bucket, "pcfiles/" + name + ".xlsx", file.getInputStream(), objectMetadata);
+        ossClient.putObject(putObjectRequest);
+        return baseUrl + "pcfiles/" + name + ".xlsx";
+    }
+
+    @Override
+    public WarehousingOrder exportPhoneData(WarehousingOrder warehousingOrder) {
+        List<String> businessKeys = null;
+        if ("1".equals(warehousingOrder.getSearchType())) {
+            businessKeys = workflowService.getTaskBusinessKeysByCode("WAREHOUSING-ORDER-APPROVE");
+        }
+
+        Map<String, Object> pageView = new HashMap<>();
+        pageView.put("businessKeys", businessKeys);
+        pageView.put("batchId", warehousingOrder.getBatchId());
+        // 查询入库单总数
+        List<WarehousingOrder> dataList = baseMapper.getListByCondition(pageView);
+
+        Double requestFundsTotal = 0d;//请款合计
+        Float inWarehouseWeightTotal = 0f;//重量合计
+        for (int i = 0; i < dataList.size(); i++) {
+            WarehousingOrder warehousingOrder1 = dataList.get(i);
+            //请款累计和
+            requestFundsTotal = requestFundsTotal + warehousingOrder1.getRequestFunds();
+            inWarehouseWeightTotal=inWarehouseWeightTotal+warehousingOrder1.getInWarehouseWeight();
+        }
+
+        // 返回数据
+        WarehousingOrder warehousingOrder1=new WarehousingOrder();
+        warehousingOrder1.setRequestFundsTotal(requestFundsTotal);
+        warehousingOrder1.setCount(dataList.size());
+        warehousingOrder1.setInWarehouseWeightTotal(inWarehouseWeightTotal);
+        if (dataList.size()>0) {
+            warehousingOrder1.setWarehouseName(dataList.get(0).getWarehouseName());
+            warehousingOrder1.setIssuingTime(dataList.get(0).getIssuingTime());
+            String taskId = "";
+            // 只有待审核状态才有taskId
+            if (StringUtils.isNotBlank(dataList.get(0).getWorkflowId())) {
+                JSONObject jsonObject = workflowService.getActiveTask(Lists.newArrayList(dataList.get(0).getWorkflowId()), dataList.get(0).getBatchId());
+                taskId = jsonObject.getString("taskId");
+                warehousingOrder1.setTaskId(taskId);
+            }
+        }
+        return warehousingOrder1;
+    }
+
     private List<String> getResourceIdList() {
         User currentUser = AuthSecurityUtils.getCurrentUserInfo();
         // 当前登录人主要角色

+ 29 - 19
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/workflow/WarehousingOrderListener.java

@@ -1,5 +1,6 @@
 package com.yh.saas.plugin.yiliangyiyun.workflow;
 
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.yh.saas.common.support.workflow.AbstractWorkflowTaskListener;
 import com.yh.saas.common.support.workflow.annotation.WorkflowTaskListener;
 import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
@@ -8,6 +9,8 @@ import com.yh.saas.plugin.yiliangyiyun.service.IContractManagementInfoService;
 import com.yh.saas.plugin.yiliangyiyun.service.IWarehousingOrderService;
 import org.springframework.beans.factory.annotation.Autowired;
 
+import java.util.List;
+
 @WorkflowTaskListener(name = "仓库管理", group = "入库单")
 public class WarehousingOrderListener extends AbstractWorkflowTaskListener {
 
@@ -18,31 +21,38 @@ public class WarehousingOrderListener extends AbstractWorkflowTaskListener {
 
     @Override
     public void handleStatusChanged(String businessKey, String status, String statusEn, boolean processIsEnd) {
-        WarehousingOrder warehousingOrder = warehousingOrderService.selectById(businessKey);
-        if (warehousingOrder == null) {
-            return;
-        }
-        if (processIsEnd) {
-            warehousingOrder.setStatusFlag(StatusEnum.NOT_COLLECTION_PAY.getFlag());
-            warehousingOrder.setStatus(StatusEnum.NOT_COLLECTION_PAY.getName());
-            warehousingOrder.setWorkflowId(null);
-            warehousingOrder.setApproveStatus(null);
-        } else {
-            warehousingOrder.setApproveStatus(status);
+        List<WarehousingOrder> list = warehousingOrderService.selectList(new EntityWrapper<WarehousingOrder>().eq("batch_id",businessKey));
+        for(WarehousingOrder warehousingOrder : list){
+            if (warehousingOrder == null) {
+                return;
+            }
+            if (processIsEnd) {
+                warehousingOrder.setStatusFlag(StatusEnum.NOT_COLLECTION_PAY.getFlag());
+                warehousingOrder.setStatus(StatusEnum.NOT_COLLECTION_PAY.getName());
+                warehousingOrder.setWorkflowId(null);
+                warehousingOrder.setApproveStatus(null);
+            } else {
+                warehousingOrder.setApproveStatus(status);
+            }
+            warehousingOrderService.updateAllColumnById(warehousingOrder);
         }
-        warehousingOrderService.updateAllColumnById(warehousingOrder);
+
     }
 
     @Override
     public void handleRejectApplicationRepulsed(String workflowId, String businessKey, boolean needReapply) {
-        WarehousingOrder warehousingOrder = warehousingOrderService.selectById(businessKey);
-        if (warehousingOrder == null) {
-            return;
+        List<WarehousingOrder> list = warehousingOrderService.selectList(new EntityWrapper<WarehousingOrder>().eq("batch_id",businessKey));
+        for(WarehousingOrder warehousingOrder : list){
+            warehousingOrder = warehousingOrderService.selectById(businessKey);
+            if (warehousingOrder == null) {
+                return;
+            }
+            warehousingOrder.setStatusFlag(StatusEnum.TASK_RETURN.getFlag());
+            warehousingOrder.setStatus(StatusEnum.TASK_RETURN.getName());
+            warehousingOrder.setApproveStatus(null);
+            warehousingOrderService.updateAllColumnById(warehousingOrder);
         }
-        warehousingOrder.setStatusFlag(StatusEnum.TASK_RETURN.getFlag());
-        warehousingOrder.setStatus(StatusEnum.TASK_RETURN.getName());
-        warehousingOrder.setApproveStatus(null);
-        warehousingOrderService.updateAllColumnById(warehousingOrder);
+
 
     }
 

+ 27 - 33
winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/ContractExpensesInfoMapper.xml

@@ -10,23 +10,20 @@
         WHERE
         ce.comp_id = #{compId}
         AND ce.delete_flag = '0'
-        <if test="costType = '1'">
-            <if test="contractNo != null and contractNo != ''">
-                AND ce.contract_no = #{contractNo}
-            </if>
+        AND ce.cost_type = #{costType}
+        <if test="contractNo != null and contractNo != ''">
+            AND ce.contract_no = #{contractNo}
         </if>
-        <if test="costType = '3'">
-            <if test="warehouseName != null and warehouseName != ''">
-                AND ce.warehouse_name = #{warehouseName}
-            </if>
-            <if test="startDate != null">
-                AND (DATE_FORMAT(ce.pay_deadline,"%Y%m%d") &gt;=
-                DATE_FORMAT(#{startDate},"%Y%m%d"))
-            </if>
-            <if test="endDate != null">
-                AND (DATE_FORMAT(ce.pay_deadline,"%Y%m%d") &lt;=
-                DATE_FORMAT(#{endDate},"%Y%m%d"))
-            </if>
+        <if test="warehouseName != null and warehouseName != ''">
+            AND ce.warehouse_name = #{warehouseName}
+        </if>
+        <if test="startDate != null">
+            AND (DATE_FORMAT(ce.pay_deadline,"%Y%m%d") &gt;=
+            DATE_FORMAT(#{startDate},"%Y%m%d"))
+        </if>
+        <if test="endDate != null">
+            AND (DATE_FORMAT(ce.pay_deadline,"%Y%m%d") &lt;=
+            DATE_FORMAT(#{endDate},"%Y%m%d"))
         </if>
     </select>
     <!--合同费用列表查询-->
@@ -37,7 +34,7 @@
         ce.comp_id as compId,
         ce.contract_id as contractId,
         ce.contract_no as contractNo,
-        ce.warehouseName,
+        ce.warehouse_name as warehouseName,
         ce.warehouse_id as warehouseId,
         ce.expenses_type as expensesType,
         ce.expenses_name as expensesName,
@@ -58,23 +55,20 @@
         WHERE
         ce.comp_id = #{compId}
         AND ce.delete_flag = '0'
-        <if test="costType = '1'">
-            <if test="contractNo != null and contractNo != ''">
-                AND ce.contract_no = #{contractNo}
-            </if>
+        AND ce.cost_type = #{costType}
+        <if test="contractNo != null and contractNo != ''">
+            AND ce.contract_no = #{contractNo}
+        </if>
+        <if test="warehouseName != null and warehouseName != ''">
+            AND ce.warehouse_name = #{warehouseName}
+        </if>
+        <if test="startDate != null">
+            AND (DATE_FORMAT(ce.pay_deadline,"%Y%m%d") &gt;=
+            DATE_FORMAT(#{startDate},"%Y%m%d"))
         </if>
-        <if test="costType = '3'">
-            <if test="warehouseName != null and warehouseName != ''">
-                AND ce.warehouse_name = #{warehouseName}
-            </if>
-            <if test="startDate != null">
-                AND (DATE_FORMAT(ce.pay_deadline,"%Y%m%d") &gt;=
-                DATE_FORMAT(#{startDate},"%Y%m%d"))
-            </if>
-            <if test="endDate != null">
-                AND (DATE_FORMAT(ce.pay_deadline,"%Y%m%d") &lt;=
-                DATE_FORMAT(#{endDate},"%Y%m%d"))
-            </if>
+        <if test="endDate != null">
+            AND (DATE_FORMAT(ce.pay_deadline,"%Y%m%d") &lt;=
+            DATE_FORMAT(#{endDate},"%Y%m%d"))
         </if>
         <if test="currentPage != null and currentPage != ''">
             LIMIT ${startRecord}, ${pageSize}

+ 341 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/ContractManagementInfoMapper.xml

@@ -380,4 +380,345 @@
             LIMIT ${startRecord}, ${pageSize}
         </if>
     </select>
+    <!--合同利润图查询-->
+    <select id="getContractChartByCondition" parameterType="Map"
+            resultType="com.yh.saas.plugin.yiliangyiyun.entity.ContractManagementInfo">
+        SELECT
+        '采购' AS type,
+        SUM( IFNULL( sri.proportion, 1 ) * IFNULL( ssrr.amount_ing_receivable, 0 ) ) + SUM( exi.amount_money )- SUM( exi2.amount_money ) AS contractProfit
+        FROM
+        contract_management_info cmi
+        LEFT JOIN expense_info exi ON exi.contract_id = cmi.id
+        AND exi.expenses_type = '1'
+        AND exi.expenses_purpose = '1'
+        AND exi.delete_flag = '0'
+        LEFT JOIN expense_info exi2 ON exi2.contract_id = cmi.id
+        AND exi2.expenses_type = '2'
+        AND exi2.expenses_purpose = '1'
+        AND exi2.delete_flag = '0'
+        LEFT JOIN warehousing_order war ON war.contract_no = cmi.contract_no
+        AND war.comp_id = cmi.comp_id
+        AND war.delete_flag = '0'
+        LEFT JOIN source_relation_info sri ON sri.source_id = war.id
+        AND sri.delete_flag = '0'
+        LEFT JOIN in_out_warehouse_task iowt ON iowt.id = sri.task_id
+        AND iowt.in_out_flag = 1
+        AND iowt.in_out_type_key = 1
+        AND iowt.delete_flag = '0'
+        LEFT JOIN warehouse_in_out_info wioi ON wioi.in_out_task_no = iowt.in_out_task_no
+        and wioi.car_no = sri.car_no
+        AND wioi.delete_flag = 0
+        AND wioi.status_flag = 3
+        LEFT JOIN stock_sale_receipt_report ssrr ON ssrr.contract_no = iowt.contract_no
+        AND ssrr.warehouse_record_id = wioi.id
+        and ssrr.delete_flag = 0
+        WHERE
+        cmi.comp_id =  #{compId}
+        AND cmi.delete_flag = '0'
+        AND (DATE_FORMAT(cmi.create_date,"%Y%m%d") &gt;=
+        DATE_FORMAT(#{startDate},"%Y%m%d"))
+        AND (DATE_FORMAT(cmi.create_date,"%Y%m%d") &lt;=
+        DATE_FORMAT(#{endDate},"%Y%m%d"))
+        AND cmi.contract_type = '2'
+        UNION ALL
+        SELECT
+        '销售' AS type,
+        SUM( exi.amount_money )- SUM(ssrr.settlement_weight* wo.avg_cost)- SUM( exi2.unallocated_amount ) AS contractProfit
+        FROM
+        contract_management_info cmi
+        LEFT JOIN expense_info exi ON exi.contract_id = cmi.id
+        AND exi.expenses_type = '1'
+        AND exi.expenses_purpose = '1'
+        AND exi.delete_flag = '0'
+        LEFT JOIN expense_info exi2 ON exi2.contract_id = cmi.id
+        AND exi2.expenses_type = '2'
+        AND exi2.expenses_purpose = '1'
+        AND exi2.delete_flag = '0'
+        LEFT JOIN stock_sale_receipt_report ssrr ON ssrr.contract_no = cmi.contract_no
+        and ssrr.delete_flag = 0
+        LEFT JOIN warehouse_in_out_info wioi ON wioi.id = ssrr.warehouse_record_id
+        AND wioi.delete_flag = '0'
+        LEFT JOIN in_out_warehouse_task iowt ON iowt.in_out_task_no=wioi.in_out_task_no and iowt.delete_flag='0'
+        LEFT JOIN source_relation_info sri on sri.task_id=iowt.id and sri.delete_flag='0'
+        LEFT JOIN warehousing_order wo on wo.id=sri.source_id and wo.delete_flag='0'
+        WHERE
+        cmi.comp_id =  #{compId}
+        AND cmi.delete_flag = '0'
+        AND (DATE_FORMAT(cmi.create_date,"%Y%m%d") &gt;=
+        DATE_FORMAT(#{startDate},"%Y%m%d"))
+        AND (DATE_FORMAT(cmi.create_date,"%Y%m%d") &lt;=
+        DATE_FORMAT(#{endDate},"%Y%m%d"))
+        AND cmi.contract_type = '1'
+        AND cmi.agreement_no != '代储合同'
+        UNION ALL
+        SELECT
+        '代收' AS type,
+        SUM( exi.amount_money )- SUM( exi2.unallocated_amount ) AS contractProfit
+        FROM
+        contract_management_info cmi
+        LEFT JOIN expense_info exi ON exi.contract_id = cmi.id
+        AND exi.expenses_type = '1'
+        AND exi.expenses_purpose = '1'
+        AND exi.delete_flag = '0'
+        LEFT JOIN expense_info exi2 ON exi2.contract_id = cmi.id
+        AND exi2.expenses_type = '2'
+        AND exi2.expenses_purpose = '1'
+        AND exi2.delete_flag = '0'
+        WHERE
+        cmi.comp_id =  #{compId}
+        AND cmi.delete_flag = '0'
+        AND (DATE_FORMAT(cmi.create_date,"%Y%m%d") &gt;=
+        DATE_FORMAT(#{startDate},"%Y%m%d"))
+        AND (DATE_FORMAT(cmi.create_date,"%Y%m%d") &lt;=
+        DATE_FORMAT(#{endDate},"%Y%m%d"))
+        AND cmi.contract_type = '3'
+        UNION ALL
+        SELECT
+        '代储' AS type,
+        SUM( exi.amount_money )- SUM( exi2.unallocated_amount ) AS contractProfit
+        FROM
+        contract_management_info cmi
+        LEFT JOIN expense_info exi ON exi.contract_id = cmi.id
+        AND exi.expenses_type = '1'
+        AND exi.expenses_purpose = '1'
+        AND exi.delete_flag = '0'
+        LEFT JOIN expense_info exi2 ON exi2.contract_id = cmi.id
+        AND exi2.expenses_type = '2'
+        AND exi2.expenses_purpose = '1'
+        AND exi2.delete_flag = '0'
+        WHERE
+        cmi.comp_id =  #{compId}
+        AND cmi.delete_flag = '0'
+        AND (DATE_FORMAT(cmi.create_date,"%Y%m%d") &gt;=
+        DATE_FORMAT(#{startDate},"%Y%m%d"))
+        AND (DATE_FORMAT(cmi.create_date,"%Y%m%d") &lt;=
+        DATE_FORMAT(#{endDate},"%Y%m%d"))
+        AND cmi.contract_type = '1'
+        AND cmi.agreement_no = '代储合同'
+    </select>
+    <!--合同利润表查询-->
+    <select id="getContractFormByCondition" parameterType="Map"
+            resultType="com.yh.saas.plugin.yiliangyiyun.entity.ContractManagementInfo">
+        SELECT
+            '采购重量' AS type,
+            SUM( wioi.net_weight )+ IFNULL( SUM( wioi4.net_weight ), 0 )+ IFNULL( SUM( wioi2.net_weight ), 0 )- IFNULL( SUM( wioi3.net_weight ), 0 ) AS profit
+        FROM
+            warehouse_base_info wbi
+                LEFT JOIN warehouse_in_out_info wioi ON wioi.base_id = wbi.id
+                AND wbi.warehouse_type = '1'
+                AND (DATE_FORMAT(wioi.in_out_date,"%Y%m%d") &gt;=
+                     DATE_FORMAT(#{startDate},"%Y%m%d"))
+                AND (DATE_FORMAT(wioi.in_out_date,"%Y%m%d") &lt;=
+                     DATE_FORMAT(#{endDate},"%Y%m%d"))
+                AND wioi.status_flag = '3'
+                AND ( wioi.in_out_type = '采购入库' OR wioi.in_out_type = '收购入库' )
+                AND wioi.delete_flag = '0'
+                LEFT JOIN warehouse_in_out_info wioi2 ON wioi2.base_id = wbi.id
+                AND wbi.warehouse_type = '2'
+                AND wbi.create_type = '1'
+                AND (DATE_FORMAT(wioi2.in_out_date,"%Y%m%d") &gt;=
+                     DATE_FORMAT(#{startDate},"%Y%m%d"))
+                AND (DATE_FORMAT(wioi2.in_out_date,"%Y%m%d") &lt;=
+                     DATE_FORMAT(#{endDate},"%Y%m%d"))
+                AND wioi2.status_flag = '3'
+                AND wioi2.in_out_type = '销售出库'
+                AND wioi2.delete_flag = '0'
+                LEFT JOIN warehouse_in_out_info wioi3 ON wioi3.base_id = wbi.id
+                AND wbi.warehouse_type = '2'
+                AND wbi.create_type = '1'
+                AND (DATE_FORMAT(wioi3.in_out_date,"%Y%m%d") &gt;=
+                     DATE_FORMAT(#{startDate},"%Y%m%d"))
+                AND (DATE_FORMAT(wioi3.in_out_date,"%Y%m%d") &lt;=
+                     DATE_FORMAT(#{endDate},"%Y%m%d"))
+                AND wioi3.status_flag = '3'
+                AND wioi3.in_out_type = '退库'
+                AND wioi3.delete_flag = '0'
+                LEFT JOIN warehouse_in_out_info wioi4 ON wioi4.base_id = wbi.id
+                AND wbi.warehouse_type = '2'
+                AND wbi.create_type = '1'
+                AND (DATE_FORMAT(wioi4.in_out_date,"%Y%m%d") &gt;=
+                     DATE_FORMAT(#{startDate},"%Y%m%d"))
+                AND (DATE_FORMAT(wioi4.in_out_date,"%Y%m%d") &lt;=
+                     DATE_FORMAT(#{endDate},"%Y%m%d"))
+                AND wioi4.status_flag = '3'
+                AND wioi4.in_out_type = '移库入库'
+                AND wioi4.delete_flag = '0'
+        WHERE
+            wbi.comp_id =  #{compId}
+          AND wbi.delete_flag = '0' UNION ALL
+        SELECT
+            '销售重量' AS type,
+            SUM( wioi1.net_weight )- IFNULL( SUM( wioi2.net_weight ), 0 ) AS profit
+        FROM
+            warehouse_base_info wbi
+                LEFT JOIN warehouse_in_out_info wioi1 ON wioi1.base_id = wbi.id
+                AND wioi1.in_out_type = '销售出库'
+                AND wioi1.delete_flag = '0'
+                AND (DATE_FORMAT(wioi1.in_out_date,"%Y%m%d") &gt;=
+                     DATE_FORMAT(#{startDate},"%Y%m%d"))
+                AND (DATE_FORMAT(wioi1.in_out_date,"%Y%m%d") &lt;=
+                     DATE_FORMAT(#{endDate},"%Y%m%d"))
+                AND wioi1.status_flag = '3'
+                LEFT JOIN warehouse_in_out_info wioi2 ON wioi2.base_id = wbi.id
+                AND wbi.warehouse_type = '1'
+                AND (DATE_FORMAT(wioi2.in_out_date,"%Y%m%d") &gt;=
+                     DATE_FORMAT(#{startDate},"%Y%m%d"))
+                AND (DATE_FORMAT(wioi2.in_out_date,"%Y%m%d") &lt;=
+                     DATE_FORMAT(#{endDate},"%Y%m%d"))
+                AND wioi2.status_flag = '3'
+                AND wioi2.in_out_type = '退库'
+                AND wioi2.delete_flag = '0'
+        WHERE
+            wbi.comp_id =  #{compId}
+          AND wbi.delete_flag = '0' UNION ALL
+        SELECT
+            '支付粮款' AS type,
+            IFNULL( sum( ei1.amount_money ), 0 ) - IFNULL( sum( ei2.amount_money ), 0 )+ IFNULL( sum( ei3.amount_money ), 0 ) - IFNULL( sum( ei4.amount_money ), 0 ) AS profit
+        FROM
+            contract_management_info cmi
+                LEFT JOIN expense_info ei1 ON ei1.contract_id = cmi.id
+                AND ei1.delete_flag = 0
+                AND ei1.cost_type = '1'
+                AND ei1.expenses_type = '2'
+                AND (DATE_FORMAT(ei1.create_date,"%Y%m%d") &gt;=
+                     DATE_FORMAT(#{startDate},"%Y%m%d"))
+                AND (DATE_FORMAT(ei1.create_date,"%Y%m%d") &lt;=
+                     DATE_FORMAT(#{endDate},"%Y%m%d"))
+                LEFT JOIN expense_info ei2 ON ei2.contract_id = cmi.id
+                AND ei2.delete_flag = 0
+                AND ei2.cost_type = '1'
+                AND ei2.expenses_type = '1'
+                AND (DATE_FORMAT(ei2.create_date,"%Y%m%d") &gt;=
+                     DATE_FORMAT(#{startDate},"%Y%m%d"))
+                AND (DATE_FORMAT(ei2.create_date,"%Y%m%d") &lt;=
+                     DATE_FORMAT(#{endDate},"%Y%m%d"))
+                LEFT JOIN expense_info ei3 ON ei3.contract_id = cmi.id
+                AND ei3.delete_flag = 0
+                AND ei3.cost_type = '5'
+                AND ei3.expenses_type = '1'
+                AND (DATE_FORMAT(ei3.create_date,"%Y%m%d") &gt;=
+                     DATE_FORMAT(#{startDate},"%Y%m%d"))
+                AND (DATE_FORMAT(ei3.create_date,"%Y%m%d") &lt;=
+                     DATE_FORMAT(#{endDate},"%Y%m%d"))
+                LEFT JOIN expense_info ei4 ON ei4.contract_id = cmi.id
+                AND ei4.delete_flag = 0
+                AND ei4.cost_type = '5'
+                AND ei4.expenses_type = '1'
+                AND (DATE_FORMAT(ei4.create_date,"%Y%m%d") &gt;=
+                     DATE_FORMAT(#{startDate},"%Y%m%d"))
+                AND (DATE_FORMAT(ei4.create_date,"%Y%m%d") &lt;=
+                     DATE_FORMAT(#{endDate},"%Y%m%d"))
+        WHERE
+            cmi.delete_flag = 0
+          AND cmi.contract_type = '2'
+          AND cmi.comp_id =  #{compId} UNION ALL
+        SELECT
+            '收入粮款' AS type,
+            IFNULL( sum( ei1.amount_money ), 0 ) - IFNULL( sum( ei2.amount_money ), 0 )+ IFNULL( sum( ei3.amount_money ), 0 ) - IFNULL( sum( ei4.amount_money ), 0 ) AS profit
+        FROM
+            contract_management_info cmi
+                LEFT JOIN expense_info ei1 ON ei1.contract_id = cmi.id
+                AND ei1.delete_flag = 0
+                AND ei1.cost_type = '1'
+                AND ei1.expenses_type = '1'
+                AND (DATE_FORMAT(ei1.create_date,"%Y%m%d") &gt;=
+                     DATE_FORMAT(#{startDate},"%Y%m%d"))
+                AND (DATE_FORMAT(ei1.create_date,"%Y%m%d") &lt;=
+                     DATE_FORMAT(#{endDate},"%Y%m%d"))
+                LEFT JOIN expense_info ei2 ON ei2.contract_id = cmi.id
+                AND ei2.delete_flag = 0
+                AND ei2.cost_type = '1'
+                AND ei2.expenses_type = '2'
+                AND (DATE_FORMAT(ei2.create_date,"%Y%m%d") &gt;=
+                     DATE_FORMAT(#{startDate},"%Y%m%d"))
+                AND (DATE_FORMAT(ei2.create_date,"%Y%m%d") &lt;=
+                     DATE_FORMAT(#{endDate},"%Y%m%d"))
+                LEFT JOIN expense_info ei3 ON ei3.contract_id = cmi.id
+                AND ei3.delete_flag = 0
+                AND ei3.cost_type = '5'
+                AND ei3.expenses_type = '1'
+                AND (DATE_FORMAT(ei3.create_date,"%Y%m%d") &gt;=
+                     DATE_FORMAT(#{startDate},"%Y%m%d"))
+                AND (DATE_FORMAT(ei3.create_date,"%Y%m%d") &lt;=
+                     DATE_FORMAT(#{endDate},"%Y%m%d"))
+                LEFT JOIN expense_info ei4 ON ei4.contract_id = cmi.id
+                AND ei4.delete_flag = 0
+                AND ei4.cost_type = '5'
+                AND ei4.expenses_type = '1'
+                AND (DATE_FORMAT(ei4.create_date,"%Y%m%d") &gt;=
+                     DATE_FORMAT(#{startDate},"%Y%m%d"))
+                AND (DATE_FORMAT(ei4.create_date,"%Y%m%d") &lt;=
+                     DATE_FORMAT(#{endDate},"%Y%m%d"))
+        WHERE
+            cmi.delete_flag = 0
+          AND cmi.contract_type = '1'
+          AND cmi.comp_id =  #{compId} UNION ALL
+        SELECT
+            '其他支出' AS type,
+            SUM( ei.amount_money ) AS profit
+        FROM
+            expense_info ei
+        WHERE
+            ei.delete_flag = 0
+          AND ei.cost_type != '1'
+        AND ei.expenses_type = '2'
+        AND (DATE_FORMAT(ei.create_date,"%Y%m%d") &gt;=
+        DATE_FORMAT(#{startDate},"%Y%m%d"))
+          AND (DATE_FORMAT(ei.create_date,"%Y%m%d") &lt;=
+            DATE_FORMAT(#{endDate},"%Y%m%d"))
+          AND ei.comp_id =  #{compId} UNION ALL
+        SELECT
+            '其他收入' AS type,
+            IFNULL( SUM( ei.amount_money ), 0 ) AS profit
+        FROM
+            expense_info ei
+        WHERE
+            ei.delete_flag = 0
+          AND ei.cost_type != '1'
+        AND ei.expenses_type = '1'
+        AND (DATE_FORMAT(ei.create_date,"%Y%m%d") &gt;=
+        DATE_FORMAT(#{startDate},"%Y%m%d"))
+          AND (DATE_FORMAT(ei.create_date,"%Y%m%d") &lt;=
+            DATE_FORMAT(#{endDate},"%Y%m%d"))
+          AND ei.comp_id =  #{compId} UNION ALL
+        SELECT
+            '运费' AS type,
+            SUM( ei1.amount_money )- SUM( ei2.amount_money ) AS profit
+        FROM
+            expense_info ei
+                LEFT JOIN expense_info ei1 ON ei1.id = ei.id
+                AND ei1.delete_flag = 0
+                AND ei1.expenses_type = '1'
+                LEFT JOIN expense_info ei2 ON ei2.id = ei.id
+                AND ei2.delete_flag = 0
+                AND ei2.expenses_type = '2'
+        WHERE
+            ei.delete_flag = 0
+          AND ei.comp_id =  #{compId}
+          AND (DATE_FORMAT(ei.create_date,"%Y%m%d") &gt;=
+               DATE_FORMAT(#{startDate},"%Y%m%d"))
+          AND (DATE_FORMAT(ei.create_date,"%Y%m%d") &lt;=
+               DATE_FORMAT(#{endDate},"%Y%m%d"))
+          AND ei.cost_type = '1'
+        UNION ALL
+        SELECT
+            '总利润' AS type,
+            SUM( ei1.amount_money )- SUM( ei2.amount_money ) AS profit
+        FROM
+            expense_info ei
+                LEFT JOIN expense_info ei1 ON ei1.id = ei.id
+                AND ei1.delete_flag = 0
+                AND ei1.expenses_type = '1'
+                LEFT JOIN expense_info ei2 ON ei2.id = ei.id
+                AND ei2.delete_flag = 0
+                AND ei2.expenses_type = '2'
+        WHERE
+            ei.delete_flag = 0
+          AND ei.comp_id =  #{compId}
+          AND (DATE_FORMAT(ei.create_date,"%Y%m%d") &gt;=
+               DATE_FORMAT(#{startDate},"%Y%m%d"))
+          AND (DATE_FORMAT(ei.create_date,"%Y%m%d") &lt;=
+               DATE_FORMAT(#{endDate},"%Y%m%d"))
+          AND ei.cost_type = '1'
+    </select>
 </mapper>

+ 2 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/ExpenseInfoMapper.xml

@@ -42,8 +42,10 @@
         unallocated_amount as unallocatedAmount,
         address_url as addressUrl,
         agent,
+        status,
         distribution_status as distributionStatus,
         approve_status as approveStatus,
+        workflow_id as workflowId,
         create_date as createDate
         FROM expense_info
         WHERE

+ 13 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/WarehousingOrderMapper.xml

@@ -32,6 +32,9 @@
                 AND profit_and_loss &lt; 0
             </if>
         </if>
+        <if test="batchId != null and batchId != ''">
+            AND batch_id= #{batchId}
+        </if>
         <if test="searchKeyWord != null and searchKeyWord != ''">
             AND (lower(goods_source) like lower(CONCAT('%',#{searchKeyWord},'%')))
         </if>
@@ -42,14 +45,18 @@
         SELECT
         id,
         comp_id as compId,
+        batch_id as batchId,
         car_no as carNo,
         goods_source as goodsSource,
         warehouse_name as warehouseName,
         contract_no as contractNo,
+        inventory_status as inventoryStatus,
         goods_name as goodsName,
+        address_url as addressUrl,
         in_warehouse_weight as inWarehouseWeight,
         out_warehouse_weight as outWarehouseWeight,
         profit_and_loss as profitAndLoss,
+        pl_value as plValue,
         surplus_weight as surplusWeight,
         grain_fund as grainFund,
         amount_ed_payable as amountEdPayable,
@@ -58,6 +65,9 @@
         avg_cost as avgCost,
         in_type as inType,
         request_funds as requestFunds,
+        issuing_time as issuingTime,
+        workflow_id as workflowId,
+        status,
         approve_status as approveStatus,
         update_date as updateDate
         FROM warehousing_order
@@ -90,6 +100,9 @@
                 AND profit_and_loss &lt; 0
             </if>
         </if>
+        <if test="batchId != null and batchId != ''">
+            AND batch_id= #{batchId}
+        </if>
         ORDER BY base_id,update_date DESC
         <if test="currentPage != null and currentPage != ''">
             LIMIT ${startRecord}, ${pageSize}