zhangyuewww 3 年之前
父节点
当前提交
be15a6048c

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

@@ -277,6 +277,11 @@ public class ExpenseInfo extends BaseModel<ExpenseInfo> {
      */
     @TableField(exist = false)
     private List<ExpenseAllocationInfo> expenseAllocationInfoList;
+    /**
+     * 分配详情(驳回)
+     */
+    @TableField(exist = false)
+    private List<ExpenseAllocationInfo> expenseAllocationInfoListBH;
 
     @Override
     protected Serializable pkVal() {

+ 653 - 14
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/ExpenseInfoServiceImpl.java

@@ -2,36 +2,58 @@ package com.yh.saas.plugin.yiliangyiyun.service.impl;
 
 import com.alibaba.fastjson.JSONObject;
 import com.alipay.sofa.runtime.api.annotation.SofaReference;
+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.baomidou.mybatisplus.plugins.Page;
 import com.google.common.collect.Lists;
 import com.winsea.svc.base.base.entity.CommonRoleResource;
+import com.winsea.svc.base.base.entity.CommonStaff;
 import com.winsea.svc.base.base.service.ICommonRoleResourceService;
+import com.winsea.svc.base.base.service.ICommonStaffService;
+import com.winsea.svc.base.base.util.DateUtils;
 import com.winsea.svc.base.security.entity.User;
 import com.winsea.svc.base.security.util.AuthSecurityUtils;
 import com.winsea.svc.base.workflow.entity.Workflow;
+import com.winsea.svc.notice.entity.NoticeTaskInfo;
+import com.winsea.svc.notice.entity.base.BaseNotice;
+import com.winsea.svc.notice.service.INoticeService;
+import com.winsea.svc.notice.service.INoticeTaskService;
 import com.yh.saas.common.support.util.IdGenerator;
 import com.yh.saas.plugin.base.service.ICommonBillOperateHisService;
 import com.yh.saas.plugin.yiliangyiyun.constant.NumberConstant;
 import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
-import com.yh.saas.plugin.yiliangyiyun.entity.ExpenseAllocationInfo;
-import com.yh.saas.plugin.yiliangyiyun.entity.ExpenseInfo;
-import com.yh.saas.plugin.yiliangyiyun.entity.WarehousingOrder;
+import com.yh.saas.plugin.yiliangyiyun.entity.*;
 import com.yh.saas.plugin.yiliangyiyun.entity.view.WarehouseNumView;
 import com.yh.saas.plugin.yiliangyiyun.exception.YException;
 import com.yh.saas.plugin.yiliangyiyun.exception.YExceptionEnum;
 import com.yh.saas.plugin.yiliangyiyun.mapper.ExpenseInfoMapper;
-import com.yh.saas.plugin.yiliangyiyun.service.IExpenseAllocationInfoService;
-import com.yh.saas.plugin.yiliangyiyun.service.IExpenseInfoService;
+import com.yh.saas.plugin.yiliangyiyun.service.*;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
-import com.yh.saas.plugin.yiliangyiyun.service.INewWorkflowService;
-import com.yh.saas.plugin.yiliangyiyun.service.IWarehousingOrderService;
+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.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.net.URLDecoder;
+import java.nio.charset.StandardCharsets;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -45,6 +67,7 @@ import java.util.stream.Collectors;
  * @since 2022-05-29
  */
 @Service
+@Slf4j
 public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, ExpenseInfo> implements IExpenseInfoService {
     @Autowired
     private INewWorkflowService workflowService;
@@ -56,6 +79,21 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
     private ICommonBillOperateHisService billOperateHisService;
     @Autowired
     private IWarehousingOrderService warehousingOrderService;
+    @Autowired
+    private IContractExpensesInfoService contractExpensesInfoService;
+    @Autowired
+    private IContractManagementInfoService contractManagementInfoService;
+    @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;
 
     @Override
     public Page<ExpenseInfo> selectInfo(ExpenseInfo expenseInfo) {
@@ -64,7 +102,7 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
                 * expenseInfo.getPageSize());
         List<String> businessKeys = null;
         if ("2".equals(expenseInfo.getSearchType())) {
-            businessKeys = workflowService.getTaskBusinessKeysByCode("COLLECTION-WAREHOUSING-RECORD");
+            businessKeys = workflowService.getTaskBusinessKeysByCode("FEIYONGGUANLI-APPROVE");
         }
         List<String> statusSet = new ArrayList<>();
         List<String> resourceIdList = this.getResourceIdList();
@@ -93,6 +131,19 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
                     taskId = jsonObject.getString("taskId");
                     expenseInfo1.setTaskId(taskId);
                 }
+                List<ExpenseAllocationInfo> expenseAllocationInfos=expenseAllocationInfoService.selectList(new EntityWrapper<ExpenseAllocationInfo>()
+                        .eq("info_id",expenseInfo1.getId())
+                        .eq("status","待确认"));
+                if (expenseAllocationInfos.size()>0){
+                    expenseInfo1.setDistributionStatus(StatusEnum.TO_BE_CONFIRMED.getName());
+                    expenseInfo1.setExpenseAllocationInfoList(expenseAllocationInfos);
+                }
+                List<ExpenseAllocationInfo> expenseAllocationInfoList=expenseAllocationInfoService.selectList(new EntityWrapper<ExpenseAllocationInfo>()
+                        .eq("info_id",expenseInfo1.getId())
+                        .eq("status","已驳回"));
+                if (expenseAllocationInfoList.size()>0){
+                    expenseInfo1.setExpenseAllocationInfoListBH(expenseAllocationInfoList);
+                }
             });
 
         }
@@ -134,11 +185,19 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public String addInfo(ExpenseInfo expenseInfo) {
         expenseInfo.setId(IdGenerator.generateUUID());
         //收入
         if ("1".equals(expenseInfo.getExpensesType())){
+            expenseInfo.setStatusFlag(StatusEnum.TO_BE_CONFIRMED.getFlag());
+            expenseInfo.setStatus(StatusEnum.TO_BE_CONFIRMED.getName());
             this.insert(expenseInfo);
+            // 插入操作历史
+            String staffName = this.billOperateHisService.getStaffAndName();
+            // 插入操作历史
+            this.billOperateHisService.saveBillOperateHis(expenseInfo.getId(), NumberConstant.EXPENSE_MANAGEMENT, staffName, null,
+                    "收款"+"("+expenseInfo.getAmountMoney()+")", null, expenseInfo.getRemark());
         }
         //支出
         else
@@ -167,7 +226,7 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
             // 不是退回的单子
             if (isStartWorkflow) {
                 Workflow workflow = workflowService
-                        .findLatestWorkflowByBusinessCodeByApp(expenseInfo.getCompId(), "FEE_DETAILS_MANG");
+                        .findLatestWorkflowByBusinessCodeByApp(expenseInfo.getCompId(), "FEIYONGGUANLI-APPROVE");
                 // 没配置审核流程,直接结束并处理信息
                 if (workflow == null) {
                     throw new YException(YExceptionEnum.PURCHASE_ORDER_ERROR);
@@ -190,11 +249,46 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public String editInfo(ExpenseInfo expenseInfo) {
+        ExpenseInfo expenseInfo1=this.selectById(expenseInfo.getId());
         //确认收款
         if ("0".equals(expenseInfo.getFlag())) {
             expenseInfo.setStatusFlag(StatusEnum.COST_RECEIVED.getFlag());
             expenseInfo.setStatus(StatusEnum.COST_RECEIVED.getName());
+            ContractExpensesInfo contractExpensesInfo=new ContractExpensesInfo();
+            contractExpensesInfo.setCompId(expenseInfo1.getCompId());
+            contractExpensesInfo.setExpensesType("1");
+            contractExpensesInfo.setExpensesName(expenseInfo1.getExpenseName());
+            contractExpensesInfo.setPersonName(expenseInfo1.getAgent());
+            contractExpensesInfo.setPayDeadline(new Date());
+            contractExpensesInfo.setExpensesId(expenseInfo1.getId());
+            contractExpensesInfo.setExpensesPrice(expenseInfo1.getAmountMoney());
+            //保证金也属于粮款
+            if ("5".equals(expenseInfo1.getCostType())){
+                contractExpensesInfo.setGrainType("1");
+            }
+            else {
+                contractExpensesInfo.setGrainType(expenseInfo1.getCostType());
+            }
+            //合同费用
+            if ("1".equals(expenseInfo1.getExpensesPurpose())){
+                contractExpensesInfo.setContractId(expenseInfo1.getContractId());
+                contractExpensesInfo.setContractNo(expenseInfo1.getContractNo());
+                contractExpensesInfo.setCostType("1");
+            }
+            //库点费用
+            else if ("3".equals(expenseInfo1.getExpensesPurpose())){
+                contractExpensesInfo.setWarehouseId(expenseInfo1.getWarehouseId());
+                contractExpensesInfo.setWarehouseName(expenseInfo1.getWarehouseName());
+                contractExpensesInfo.setCostType("3");
+            }
+            contractExpensesInfoService.insert(contractExpensesInfo);
+            // 插入操作历史
+            String staffName = this.billOperateHisService.getStaffAndName();
+            // 插入操作历史
+            this.billOperateHisService.saveBillOperateHis(expenseInfo.getId(), NumberConstant.EXPENSE_MANAGEMENT, staffName, null,
+                    "确认"+"("+expenseInfo.getAmountMoney()+")", null, expenseInfo.getRemark());
         }
         //完成收款
         else if ("1".equals(expenseInfo.getFlag())){
@@ -203,16 +297,56 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
         }
         //确认分配
         else if ("2".equals(expenseInfo.getFlag())){
-            expenseInfo.setDistributionStatusFlag(StatusEnum.COMPLETED.getFlag());
-            expenseInfo.setDistributionStatus(StatusEnum.COMPLETED.getName());
+            expenseInfo.setDistributionStatusFlag("");
+            expenseInfo.setDistributionStatus("");
             List<ExpenseAllocationInfo> expenseAllocationInfos=expenseAllocationInfoService.selectList(new EntityWrapper<ExpenseAllocationInfo>()
-            .eq("info_id",expenseInfo.getId())
-            .eq("status","待确认"));
+                    .eq("info_id",expenseInfo.getId())
+                    .eq("status","待确认"));
             if (!CollectionUtils.isEmpty(expenseAllocationInfos)){
                 for (ExpenseAllocationInfo expenseAllocationInfo:expenseAllocationInfos){
                     expenseAllocationInfo.setStatusFlag(StatusEnum.COST_ADOPTED.getFlag());
                     expenseAllocationInfo.setStatus(StatusEnum.COST_ADOPTED.getName());
                     expenseAllocationInfoService.updateById(expenseAllocationInfo);
+                    //库点费用
+                    if ("3".equals(expenseInfo1.getExpensesPurpose())) {
+                        ContractExpensesInfo contractExpensesInfo = new ContractExpensesInfo();
+                        contractExpensesInfo.setCompId(expenseInfo1.getCompId());
+                        contractExpensesInfo.setExpensesType("2");
+                        contractExpensesInfo.setExpensesName(expenseInfo1.getExpenseName());
+                        contractExpensesInfo.setPersonName(expenseInfo1.getAgent());
+                        contractExpensesInfo.setPayDeadline(new Date());
+                        contractExpensesInfo.setExpensesId(expenseInfo1.getId());
+                        contractExpensesInfo.setExpensesPrice(expenseAllocationInfo.getDistributionMoney());
+                        //保证金也属于粮款
+                        if ("5".equals(expenseInfo1.getCostType())) {
+                            contractExpensesInfo.setGrainType("1");
+                        } else {
+                            contractExpensesInfo.setGrainType(expenseInfo1.getCostType());
+                        }
+                        WarehousingOrder warehousingOrder=warehousingOrderService.selectById(expenseAllocationInfo.getOrderId());
+                        if (warehousingOrder!=null&&"采购入库".equals(warehousingOrder.getInType())){
+                            ContractManagementInfo contractManagementInfo=contractManagementInfoService.selectOne(new EntityWrapper<ContractManagementInfo>()
+                                    .eq("contract_no",warehousingOrder.getContractNo())
+                                    .eq("comp_id",warehousingOrder.getCompId()));
+                            if (contractManagementInfo!=null){
+                                contractExpensesInfo.setContractId(contractManagementInfo.getId());
+                                contractExpensesInfo.setContractNo(contractManagementInfo.getContractNo());
+                                contractExpensesInfo.setCostType("1");
+                            }
+                            else {
+                                WarehouseBaseInfo warehouseBaseInfo=warehouseBaseInfoService.selectOne(new EntityWrapper<WarehouseBaseInfo>()
+                                        .eq("warehouse_name",warehousingOrder.getWarehouseName())
+                                        .eq("comp_id",warehousingOrder.getCompId()));
+                                if (warehouseBaseInfo!=null) {
+                                    contractExpensesInfo.setWarehouseId(warehouseBaseInfo.getId());
+                                    contractExpensesInfo.setWarehouseName(warehouseBaseInfo.getWarehouseName());
+                                    contractExpensesInfo.setCostType("3");
+                                }
+                            }
+                        }
+                        contractExpensesInfoService.insert(contractExpensesInfo);
+                    }
+
                 }
             }
         }
@@ -221,11 +355,45 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
             List<ExpenseAllocationInfo> expenseAllocationInfoList = expenseInfo.getExpenseAllocationInfoList();
             if (!CollectionUtils.isEmpty(expenseAllocationInfoList)) {
                 for (ExpenseAllocationInfo expenseAllocationInfo : expenseAllocationInfoList) {
-                    expenseAllocationInfoService.updateById(expenseAllocationInfo);
+                    //有id的编辑
+                    if (expenseAllocationInfo.getId()!=null) {
+                        expenseAllocationInfoService.updateById(expenseAllocationInfo);
+                    }
+                    else{
+                        expenseAllocationInfo.setId(IdGenerator.generateUUID());
+                        expenseAllocationInfo.setInfoId(expenseInfo.getId());
+                        expenseAllocationInfo.setStatusFlag(StatusEnum.TO_BE_CONFIRMED.getFlag());
+                        expenseAllocationInfo.setStatus(StatusEnum.TO_BE_CONFIRMED.getName());
+                        expenseAllocationInfoService.insert(expenseAllocationInfo);
+                    }
                 }
             }
         }
         //主表编辑 flag==4
+        else if ("4".equals(expenseInfo.getFlag())){
+            boolean isStartWorkflow = StringUtils.isBlank(expenseInfo.getWorkflowId());
+            // 不是退回的单子
+            if (isStartWorkflow) {
+                Workflow workflow = workflowService
+                        .findLatestWorkflowByBusinessCodeByApp(expenseInfo.getCompId(), "FEIYONGGUANLI-APPROVE");
+                // 没配置审核流程,直接结束并处理信息
+                if (workflow == null) {
+                    throw new YException(YExceptionEnum.PURCHASE_ORDER_ERROR);
+                }
+                // 开启审核流
+                else {
+                    // 设置状态 已提交审核
+                    expenseInfo.setWorkflowId(workflow.getId());
+                    this.updateById(expenseInfo);
+                    workflowService.startInstance(workflow.getId(), expenseInfo.getId());
+                }
+            }
+            // 退回的单子 再启用
+            else {
+                this.updateById(expenseInfo);
+                workflowService.activateInstance(expenseInfo.getWorkflowId(), expenseInfo.getId());
+            }
+        }
         //驳回分配
         else if ("5".equals(expenseInfo.getFlag())){
             expenseInfo.setDistributionStatusFlag(StatusEnum.REJECTED.getFlag());
@@ -262,10 +430,33 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
      * @return
      */
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public String payment(ExpenseInfo expenseInfo) {
         expenseInfo.setStatusFlag(StatusEnum.COST_PAID.getFlag());
         expenseInfo.setStatus(StatusEnum.COST_PAID.getName());
         this.updateById(expenseInfo);
+        ExpenseInfo expenseInfo1=this.selectById(expenseInfo.getId());
+        //合同费用
+        if ("1".equals(expenseInfo1.getExpensesPurpose())) {
+            ContractExpensesInfo contractExpensesInfo = new ContractExpensesInfo();
+            contractExpensesInfo.setCompId(expenseInfo1.getCompId());
+            contractExpensesInfo.setExpensesType("2");
+            contractExpensesInfo.setExpensesName(expenseInfo1.getExpenseName());
+            contractExpensesInfo.setPersonName(expenseInfo1.getAgent());
+            contractExpensesInfo.setPayDeadline(new Date());
+            contractExpensesInfo.setExpensesId(expenseInfo1.getId());
+            contractExpensesInfo.setExpensesPrice(expenseInfo1.getAmountMoney());
+            //保证金也属于粮款
+            if ("5".equals(expenseInfo1.getCostType())) {
+                contractExpensesInfo.setGrainType("1");
+            } else {
+                contractExpensesInfo.setGrainType(expenseInfo1.getCostType());
+            }
+            contractExpensesInfo.setContractId(expenseInfo1.getContractId());
+            contractExpensesInfo.setContractNo(expenseInfo1.getContractNo());
+            contractExpensesInfo.setCostType("1");
+            contractExpensesInfoService.insert(contractExpensesInfo);
+        }
         // 插入操作历史
         String staffName = this.billOperateHisService.getStaffAndName();
         // 插入操作历史
@@ -302,6 +493,7 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
         if (receiptDocDate!=null){
             warehousingOrderWrapper.like("issuing_time", receiptDocDate);
         }
+        warehousingOrderWrapper.ne("in_type","退库");
         warehousingOrderWrapper.orderBy("update_date");
         List<WarehousingOrder> warehousingOrderList = warehousingOrderService.selectList(warehousingOrderWrapper);
         return warehousingOrderList;
@@ -352,6 +544,453 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
         return dataList;
     }
 
+    @Override
+    public String exportPhone(ExpenseInfo expenseInfo, 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*2*256);
+        sheet.setColumnWidth(3, 12 * 256 + 184);
+        sheet.setColumnWidth(4, 12 * 256 + 184);
+        sheet.setColumnWidth(5, 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) 4));
+        cell = row0.createCell(2);
+        cell.setCellStyle(styleTitle);
+        cell = row0.createCell(3);
+        cell.setCellStyle(styleTitle);
+        cell = row0.createCell(4);
+        cell.setCellStyle(styleTitle);
+        rownum++;
+
+
+        // 费用分配总数
+        List<ExpenseAllocationInfo> expenseAllocationInfos=expenseAllocationInfoService.selectList(new EntityWrapper<ExpenseAllocationInfo>()
+                .eq("info_id",expenseInfo.getId())
+                .ne("status","已通过"));
+
+        HSSFRow rowp = sheet.createRow((int)(rownum));
+        rowp.setHeightInPoints(20);
+        cell = rowp.createCell(1);
+        cell.setCellStyle(styleDetail);
+        cell = rowp.createCell(2);
+        cell.setCellStyle(styleDetail);
+        cell = rowp.createCell(3);
+        cell.setCellStyle(styleDetail);
+        cell = rowp.createCell(4);
+        cell.setCellStyle(styleDetail);
+        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);
+        rownum++;
+
+        // 详情信息
+        if (!CollectionUtils.isEmpty(expenseAllocationInfos)) {
+            for (int i = 0; i < expenseAllocationInfos.size(); i++) {
+                ExpenseAllocationInfo expenseAllocationInfo = expenseAllocationInfos.get(i);
+
+                HSSFRow rowx = sheet.createRow((int) rownum);
+                rowx.setHeightInPoints(20);
+                cell = rowx.createCell(1);
+                cell.setCellValue(editString(expenseAllocationInfo.getWarehouseName()));
+                cell.setCellStyle(styleDetail);
+                cell = rowx.createCell(2);
+                String date = addDateOneDay(expenseAllocationInfo.getReceiptDocDate());
+                cell.setCellValue(date);
+                cell.setCellStyle(styleDetail);
+                cell = rowx.createCell(3);
+                cell.setCellValue(editFloat(expenseAllocationInfo.getInWarehouseWeight()));
+                cell.setCellStyle(styleDetail);
+                cell = rowx.createCell(4);
+                cell.setCellValue(editDouble(expenseAllocationInfo.getDistributionMoney()));
+                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);
+    }
+    private String addDateOneDay(Date date) {
+        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        sdf.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
+        return sdf.format(date);
+    }
+    /**
+     * 判断字符串
+     *
+     * @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";
+    }
+
+
     private List<String> getResourceIdList() {
         User currentUser = AuthSecurityUtils.getCurrentUserInfo();
         // 当前登录人主要角色

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

@@ -16,6 +16,13 @@
                 AND expenses_type = '2'
             </if>
         </if>
+        <if test="businessKeys != null and businessKeys.size > 0">
+            and(
+            <foreach collection="businessKeys" item="businessValue" open="(" close=")" separator="or">
+                a.id = #{businessValue}
+            </foreach>
+            )
+        </if>
         <if test="startDate != null">
             AND (DATE_FORMAT(create_date,"%Y%m%d") &gt;=
             DATE_FORMAT(#{startDate},"%Y%m%d"))
@@ -58,6 +65,13 @@
                 AND expenses_type = '2'
             </if>
         </if>
+        <if test="businessKeys != null and businessKeys.size > 0">
+            and(
+            <foreach collection="businessKeys" item="businessValue" open="(" close=")" separator="or">
+                a.id = #{businessValue}
+            </foreach>
+            )
+        </if>
         <if test="searchKeyWord != null and searchKeyWord != ''">
             AND (lower(expense_name) like lower(CONCAT('%',#{searchKeyWord},'%')))
         </if>