|
@@ -2,9 +2,14 @@ package com.yh.saas.plugin.yiliangyiyun.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.alipay.sofa.runtime.api.annotation.SofaService;
|
|
import com.alipay.sofa.runtime.api.annotation.SofaService;
|
|
|
|
+import com.winsea.svc.base.base.util.DateUtils;
|
|
import com.yh.saas.common.support.util.IdGenerator;
|
|
import com.yh.saas.common.support.util.IdGenerator;
|
|
|
|
+import com.yh.saas.common.support.util.StringUtils;
|
|
|
|
+import com.yh.saas.plugin.base.service.ICommonBillOperateHisService;
|
|
import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
|
|
import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.ContractProcessInfo;
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.ContractProcessInfo;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.exception.YException;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.exception.YExceptionEnum;
|
|
import com.yh.saas.plugin.yiliangyiyun.mapper.ContractManagementInfoMapper;
|
|
import com.yh.saas.plugin.yiliangyiyun.mapper.ContractManagementInfoMapper;
|
|
import com.yh.saas.plugin.yiliangyiyun.service.IContractGoodsInfoService;
|
|
import com.yh.saas.plugin.yiliangyiyun.service.IContractGoodsInfoService;
|
|
import com.yh.saas.plugin.yiliangyiyun.service.IContractProcessInfoService;
|
|
import com.yh.saas.plugin.yiliangyiyun.service.IContractProcessInfoService;
|
|
@@ -15,15 +20,23 @@ import com.yh.saas.plugin.yiliangyiyun.entity.ContractManagementInfo;
|
|
import com.yh.saas.plugin.yiliangyiyun.service.IContractManagementInfoService;
|
|
import com.yh.saas.plugin.yiliangyiyun.service.IContractManagementInfoService;
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
|
+import org.apache.commons.httpclient.util.DateUtil;
|
|
|
|
+import org.apache.poi.hssf.usermodel.*;
|
|
|
|
+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.Autowired;
|
|
import com.baomidou.mybatisplus.plugins.Page;
|
|
import com.baomidou.mybatisplus.plugins.Page;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
|
|
|
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
-
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.io.*;
|
|
|
|
+import java.net.URLDecoder;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -38,10 +51,14 @@ import java.util.Map;
|
|
public class ContractManagementInfoServiceImpl extends ServiceImpl<ContractManagementInfoMapper, ContractManagementInfo> implements IContractManagementInfoService {
|
|
public class ContractManagementInfoServiceImpl extends ServiceImpl<ContractManagementInfoMapper, ContractManagementInfo> implements IContractManagementInfoService {
|
|
@Autowired
|
|
@Autowired
|
|
private IContractGoodsInfoService contractGoodsInfoService;
|
|
private IContractGoodsInfoService contractGoodsInfoService;
|
|
-
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IContractManagementInfoService contractManagementInfoService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICommonBillOperateHisService billOperateHisService;
|
|
@Autowired
|
|
@Autowired
|
|
private IContractProcessInfoService contractProcessInfoService;
|
|
private IContractProcessInfoService contractProcessInfoService;
|
|
-
|
|
|
|
|
|
+ @Value("${file-root-path}")
|
|
|
|
+ private String localPath;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 新增合同信息
|
|
* 新增合同信息
|
|
@@ -56,15 +73,31 @@ public class ContractManagementInfoServiceImpl extends ServiceImpl<ContractManag
|
|
contractManagementInfo.setId(IdGenerator.generateUUID());
|
|
contractManagementInfo.setId(IdGenerator.generateUUID());
|
|
contractManagementInfo.setStatusFlag(StatusEnum.CONTRACT_WAIT.getFlag());
|
|
contractManagementInfo.setStatusFlag(StatusEnum.CONTRACT_WAIT.getFlag());
|
|
contractManagementInfo.setStatus(StatusEnum.CONTRACT_WAIT.getName());
|
|
contractManagementInfo.setStatus(StatusEnum.CONTRACT_WAIT.getName());
|
|
|
|
+ //判断合同编号是否唯一
|
|
|
|
+ List<ContractManagementInfo> contractManagementInfos =
|
|
|
|
+ contractManagementInfoService.selectList(new EntityWrapper<ContractManagementInfo>()
|
|
|
|
+ .eq("contract_no", contractManagementInfo.getContractNo())
|
|
|
|
+ .eq("delete_flag","0"));
|
|
|
|
+ if (contractManagementInfos.size()>0){
|
|
|
|
+ throw new YException(YExceptionEnum.CONTRACT_NO_ERROR);
|
|
|
|
+ }
|
|
// 货物信息新增
|
|
// 货物信息新增
|
|
ContractGoodsInfo contractGoodsInfo = contractManagementInfo.getContractGoodsInfo();
|
|
ContractGoodsInfo contractGoodsInfo = contractManagementInfo.getContractGoodsInfo();
|
|
contractGoodsInfo.setId(IdGenerator.generateUUID());
|
|
contractGoodsInfo.setId(IdGenerator.generateUUID());
|
|
|
|
+ contractGoodsInfo.setContractId(contractManagementInfo.getId());
|
|
//流程新增
|
|
//流程新增
|
|
ContractProcessInfo contractProcessInfo = contractManagementInfo.getContractProcessInfo();
|
|
ContractProcessInfo contractProcessInfo = contractManagementInfo.getContractProcessInfo();
|
|
contractProcessInfo.setId(IdGenerator.generateUUID());
|
|
contractProcessInfo.setId(IdGenerator.generateUUID());
|
|
|
|
+ contractProcessInfo.setContractId(contractManagementInfo.getId());
|
|
boolean one = this.insert(contractManagementInfo);
|
|
boolean one = this.insert(contractManagementInfo);
|
|
boolean two = contractGoodsInfoService.insert(contractGoodsInfo);
|
|
boolean two = contractGoodsInfoService.insert(contractGoodsInfo);
|
|
boolean three = contractProcessInfoService.insert(contractProcessInfo);
|
|
boolean three = contractProcessInfoService.insert(contractProcessInfo);
|
|
|
|
+
|
|
|
|
+ // 插入操作历史
|
|
|
|
+ String staffName = this.billOperateHisService.getStaffAndName();
|
|
|
|
+ // 插入操作历史
|
|
|
|
+ this.billOperateHisService.saveBillOperateHis(contractManagementInfo.getId(), "CONTRACT", staffName, null,
|
|
|
|
+ StatusEnum.CONTRACT_WAIT.getName(), StatusEnum.CONTRACT_WAIT.getName(), "");
|
|
// 假如 都成功返回ok
|
|
// 假如 都成功返回ok
|
|
if (one && two && three) {
|
|
if (one && two && three) {
|
|
return "OK";
|
|
return "OK";
|
|
@@ -72,19 +105,21 @@ public class ContractManagementInfoServiceImpl extends ServiceImpl<ContractManag
|
|
return "NG";
|
|
return "NG";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 编辑合同信息
|
|
* 编辑合同信息
|
|
|
|
+ *
|
|
* @param contractManagementInfo
|
|
* @param contractManagementInfo
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public String editInfo(ContractManagementInfo contractManagementInfo){
|
|
|
|
|
|
+ public String editInfo(ContractManagementInfo contractManagementInfo) {
|
|
// 主表信息编辑
|
|
// 主表信息编辑
|
|
boolean one = this.updateById(contractManagementInfo);
|
|
boolean one = this.updateById(contractManagementInfo);
|
|
// 货物信息编辑
|
|
// 货物信息编辑
|
|
- boolean two =contractGoodsInfoService.updateById(contractManagementInfo.getContractGoodsInfo());
|
|
|
|
|
|
+ boolean two = contractGoodsInfoService.updateById(contractManagementInfo.getContractGoodsInfo());
|
|
//流程编辑
|
|
//流程编辑
|
|
- boolean three =contractProcessInfoService.updateById(contractManagementInfo.getContractProcessInfo());
|
|
|
|
|
|
+ boolean three = contractProcessInfoService.updateById(contractManagementInfo.getContractProcessInfo());
|
|
// 假如 都成功返回ok
|
|
// 假如 都成功返回ok
|
|
if (one && two && three) {
|
|
if (one && two && three) {
|
|
return "OK";
|
|
return "OK";
|
|
@@ -92,8 +127,10 @@ public class ContractManagementInfoServiceImpl extends ServiceImpl<ContractManag
|
|
return "NG";
|
|
return "NG";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 查看合同信息
|
|
* 查看合同信息
|
|
|
|
+ *
|
|
* @param id
|
|
* @param id
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@@ -118,10 +155,13 @@ public class ContractManagementInfoServiceImpl extends ServiceImpl<ContractManag
|
|
* contractManagementInfo.getPageSize());
|
|
* contractManagementInfo.getPageSize());
|
|
// 公司ID
|
|
// 公司ID
|
|
pageView.put("compId", AuthSecurityUtils.getCurrentUserInfo().getCompId());
|
|
pageView.put("compId", AuthSecurityUtils.getCurrentUserInfo().getCompId());
|
|
- pageView.put("searchKeyWord",contractManagementInfo.getSearchKeyWord());
|
|
|
|
- pageView.put("startDate",contractManagementInfo.getStartDate());
|
|
|
|
- pageView.put("endDate",contractManagementInfo.getEndDate());
|
|
|
|
- pageView.put("searchType",contractManagementInfo.getSearchType());
|
|
|
|
|
|
+ pageView.put("searchKeyWord", contractManagementInfo.getSearchKeyWord());
|
|
|
|
+ pageView.put("startDate", contractManagementInfo.getStartDate());
|
|
|
|
+ pageView.put("endDate", contractManagementInfo.getEndDate());
|
|
|
|
+ pageView.put("searchType", contractManagementInfo.getSearchType());
|
|
|
|
+ pageView.put("contractType", contractManagementInfo.getContractType());
|
|
|
|
+ pageView.put("pageSize", contractManagementInfo.getPageSize());
|
|
|
|
+ pageView.put("currentPage", contractManagementInfo.getCurrentPage());
|
|
// 查询服务商总数
|
|
// 查询服务商总数
|
|
Integer dataCount = baseMapper.getCountByCondition(pageView);
|
|
Integer dataCount = baseMapper.getCountByCondition(pageView);
|
|
List<ContractManagementInfo> dataList = baseMapper.getListByCondition(pageView);
|
|
List<ContractManagementInfo> dataList = baseMapper.getListByCondition(pageView);
|
|
@@ -136,7 +176,8 @@ public class ContractManagementInfoServiceImpl extends ServiceImpl<ContractManag
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 更改状态
|
|
|
|
|
|
+ * 更改状态
|
|
|
|
+ *
|
|
* @param id
|
|
* @param id
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@@ -148,26 +189,486 @@ public class ContractManagementInfoServiceImpl extends ServiceImpl<ContractManag
|
|
if (StatusEnum.CONTRACT_DO.getFlag().equals(contractManagementInfo.getStatusFlag())) {
|
|
if (StatusEnum.CONTRACT_DO.getFlag().equals(contractManagementInfo.getStatusFlag())) {
|
|
contractManagementInfo.setStatusFlag(StatusEnum.CONTRACT_COMPLETED.getFlag());
|
|
contractManagementInfo.setStatusFlag(StatusEnum.CONTRACT_COMPLETED.getFlag());
|
|
contractManagementInfo.setStatus(StatusEnum.CONTRACT_COMPLETED.getName());
|
|
contractManagementInfo.setStatus(StatusEnum.CONTRACT_COMPLETED.getName());
|
|
- }
|
|
|
|
- else{
|
|
|
|
|
|
+ } else {
|
|
contractManagementInfo.setStatusFlag(StatusEnum.CONTRACT_DO.getFlag());
|
|
contractManagementInfo.setStatusFlag(StatusEnum.CONTRACT_DO.getFlag());
|
|
contractManagementInfo.setStatus(StatusEnum.CONTRACT_DO.getName());
|
|
contractManagementInfo.setStatus(StatusEnum.CONTRACT_DO.getName());
|
|
}
|
|
}
|
|
this.updateById(contractManagementInfo);
|
|
this.updateById(contractManagementInfo);
|
|
|
|
+ // 插入操作历史
|
|
|
|
+ String staffName = this.billOperateHisService.getStaffAndName();
|
|
|
|
+ // 插入操作历史
|
|
|
|
+ this.billOperateHisService.saveBillOperateHis(contractManagementInfo.getId(), "CONTRACT", staffName, null,
|
|
|
|
+ contractManagementInfo.getStatus(), null, "");
|
|
return "OK";
|
|
return "OK";
|
|
}
|
|
}
|
|
return "NG";
|
|
return "NG";
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 删除
|
|
|
|
|
|
+ * 删除
|
|
|
|
+ *
|
|
* @param id
|
|
* @param id
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public void deleteInfo(String id){
|
|
|
|
|
|
+ public void deleteInfo(String id) {
|
|
ContractManagementInfo contractManagementInfo = this.selectById(id);
|
|
ContractManagementInfo contractManagementInfo = this.selectById(id);
|
|
if (contractManagementInfo != null) {
|
|
if (contractManagementInfo != null) {
|
|
|
|
+ //合同信息
|
|
this.deleteById(contractManagementInfo.getId());
|
|
this.deleteById(contractManagementInfo.getId());
|
|
|
|
+ //货物信息
|
|
|
|
+ ContractGoodsInfo contractGoodsInfo = contractGoodsInfoService.selectOne(new EntityWrapper<ContractGoodsInfo>().eq("contract_id", id));
|
|
|
|
+ //流程信息
|
|
|
|
+ ContractProcessInfo contractProcessInfo = contractProcessInfoService.selectOne(new EntityWrapper<ContractProcessInfo>().eq("contract_id", id));
|
|
|
|
+ contractGoodsInfoService.deleteById(contractGoodsInfo.getId());
|
|
|
|
+ contractProcessInfoService.deleteById(contractProcessInfo.getId());
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 导出
|
|
|
|
+ *
|
|
|
|
+ * @return
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void export(ContractManagementInfo example, HttpServletResponse response) throws Exception {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
+ // 查询在船船员
|
|
|
|
+ Page<ContractManagementInfo> contractManagementInfoPage = this.selectInfo(example);
|
|
|
|
+ List<ContractManagementInfo> contractManagementInfos = contractManagementInfoPage.getRecords();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // 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);
|
|
|
|
+
|
|
|
|
+ // 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 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, 6 * 256 + 184);
|
|
|
|
+ sheet.setColumnWidth(2, 12 * 256 + 184);
|
|
|
|
+ sheet.setColumnWidth(3, 12 * 256 + 184);
|
|
|
|
+ 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++;
|
|
|
|
+
|
|
|
|
+ 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.isNotEmpty(contractManagementInfos)) {
|
|
|
|
+ for (int i = 0; i < contractManagementInfos.size(); i++) {
|
|
|
|
+ ContractManagementInfo contractManagementInfo = contractManagementInfos.get(i);
|
|
|
|
+ HSSFRow rowx = sheet.createRow((int) rownum);
|
|
|
|
+ rowx.setHeightInPoints(20);
|
|
|
|
+ cell = rowx.createCell(1);
|
|
|
|
+ cell.setCellValue(i + 1);
|
|
|
|
+ cell.setCellStyle(styleDetail);
|
|
|
|
+ cell = rowx.createCell(2);
|
|
|
|
+ cell.setCellValue(editString(contractManagementInfo.getContractNo()));
|
|
|
|
+ cell.setCellStyle(styleDetail);
|
|
|
|
+ cell = rowx.createCell(3);
|
|
|
|
+ cell.setCellValue(editString(contractManagementInfo.getGoodsName()));
|
|
|
|
+ cell.setCellStyle(styleDetail);
|
|
|
|
+ cell = rowx.createCell(4);
|
|
|
|
+ cell.setCellValue(editString(contractManagementInfo.getGrade()));
|
|
|
|
+ cell.setCellStyle(styleDetail);
|
|
|
|
+ cell = rowx.createCell(5);
|
|
|
|
+ cell.setCellValue(editFloat(contractManagementInfo.getWeight()));
|
|
|
|
+ cell.setCellStyle(styleDetail);
|
|
|
|
+ cell = rowx.createCell(6);
|
|
|
|
+ cell.setCellValue(editDouble(contractManagementInfo.getUnitContractPrice()));
|
|
|
|
+ cell.setCellStyle(styleDetail);
|
|
|
|
+ cell = rowx.createCell(7);
|
|
|
|
+ cell.setCellValue(editString(contractManagementInfo.getPackingMethod()));
|
|
|
|
+ cell.setCellStyle(styleDetail);
|
|
|
|
+ cell = rowx.createCell(8);
|
|
|
|
+ cell.setCellValue(editString(contractManagementInfo.getBuyer()));
|
|
|
|
+ cell.setCellStyle(styleDetail);
|
|
|
|
+ cell = rowx.createCell(9);
|
|
|
|
+ cell.setCellValue(editString(contractManagementInfo.getSeller()));
|
|
|
|
+ cell.setCellStyle(styleDetail);
|
|
|
|
+ cell = rowx.createCell(10);
|
|
|
|
+ cell.setCellValue(editFloat(contractManagementInfo.getImperfectGrain()));
|
|
|
|
+ cell.setCellStyle(styleDetail);
|
|
|
|
+ cell = rowx.createCell(11);
|
|
|
|
+ cell.setCellValue(editString(contractManagementInfo.getStatus()));
|
|
|
|
+ cell.setCellStyle(styleDetail);
|
|
|
|
+ cell = rowx.createCell(12);
|
|
|
|
+ cell.setCellValue(DateUtil.formatDate(contractManagementInfo.getSigningDate()!=null?contractManagementInfo.getSigningDate():new Date(), DateUtils.DATE_FMT_YYYY_MM_DD));
|
|
|
|
+ cell.setCellStyle(styleDetail);
|
|
|
|
+ cell = rowx.createCell(13);
|
|
|
|
+ cell.setCellValue(editFloat(contractManagementInfo.getMildewGrain()));
|
|
|
|
+ cell.setCellStyle(styleDetail);
|
|
|
|
+ rownum++;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ String path = null;
|
|
|
|
+ String tempPath = null;
|
|
|
|
+ String excelPath = null;
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+
|
|
|
|
+ // 取得绝对路径
|
|
|
|
+ tempPath = URLDecoder.decode((localPath), "utf-8");
|
|
|
|
+
|
|
|
|
+ // EXCEL路径
|
|
|
|
+ excelPath = "/web/temp/repair/" + DateUtil.formatDate(new Date(), DateUtils.DATE_FMT_YYYYMMDD_NS) + '/'
|
|
|
|
+ + UUID.randomUUID().toString().replaceAll("-", "");
|
|
|
|
+
|
|
|
|
+ path = tempPath + excelPath + '/' + "合同信息"
|
|
|
|
+ + ".xls";
|
|
|
|
+
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.debug(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ // 下载
|
|
|
|
+ download(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:0.00;
|
|
|
|
+ return exampleOne;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 下载
|
|
|
|
+ *
|
|
|
|
+ * @param path
|
|
|
|
+ * @param response
|
|
|
|
+ * @author 穆永春
|
|
|
|
+ */
|
|
|
|
+ private void download(String path, HttpServletResponse response, Workbook wb) {
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+
|
|
|
|
+ // path是指欲下载的文件的路径。
|
|
|
|
+ File file = new File(path);
|
|
|
|
+ // 取得文件名。
|
|
|
|
+ String fileName = file.getName();
|
|
|
|
+ // 给文件名编码
|
|
|
|
+ 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();
|
|
|
|
+// File localFile = new File(path);
|
|
|
|
+// OutputStream os = new FileOutputStream(localFile);
|
|
|
|
+//
|
|
|
|
+// wb.write(os);
|
|
|
|
+// os.flush();
|
|
|
|
+// os.close();
|
|
|
|
+
|
|
|
|
+ } catch (IOException ex) {
|
|
|
|
+ log.debug(ex.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|