Commit dd7ea989 authored by yff's avatar yff

修改产品跟踪导出操作

parent 9823ea7f
......@@ -440,10 +440,10 @@ public class GpfkDaoImpl extends BaseDaoImpl implements GpfkDao {
public List<GpfkVO> queryWosngzByWosnid(String wosnid,String[] lhids){
SqlMap sqlMap = new SqlMap();
sqlMap.setTranslate(false);
sqlMap.append("select GPFK_ID, GPFK_FKSJ, GPFK_FKJSSJ, GPFK_HGBZ, GPFK_FKSL, ");
sqlMap.append("select GPFK_ID,WOGYLX_XH, GPFK_FKSJ, GPFK_FKJSSJ, GPFK_HGBZ, GPFK_FKSL, ");
sqlMap.append(" GPFK_HGSL, GPFK_BHGSL, GPFK_FKR, BZGX_NAME,BZGX_CODE, BZGX_GXLX ");
sqlMap.append("from ( ");
sqlMap.append(" select GPFK_ID, GPFK_FKSJ, GPFK_FKJSSJ, GPFK_HGBZ, GPFK_FKSL, ");
sqlMap.append(" select GPFK_ID,WOGYLX_XH, GPFK_FKSJ, GPFK_FKJSSJ, GPFK_HGBZ, GPFK_FKSL, ");
sqlMap.append(" GPFK_HGSL, GPFK_BHGSL, GPFK_FKR, BZGX_NAME,BZGX_CODE, BZGX_GXLX ");
sqlMap.append(" from GPFK ");
sqlMap.append(" left join WOGYLX on WOGYLX_ID = GPFK_FKGX ");
......@@ -452,7 +452,7 @@ public class GpfkDaoImpl extends BaseDaoImpl implements GpfkDao {
sqlMap.append(" and GPFK_WOSNID = :pCode ");
sqlMap.setParamValue("pCode",wosnid);
sqlMap.append(" )GC ");
sqlMap.append("order by GPFK_FKSJ ");
sqlMap.append("order by WOGYLX_XH asc,BZGX_NAME asc,GPFK_FKSJ ");
return sqlMap.query(GpfkVO.class);
}
......
......@@ -23,13 +23,17 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFRow;
......@@ -87,6 +91,8 @@ public class UWosnServiceImpl extends BaseEditServiceImpl implements UWosnServic
XSSFWorkbook wb =null;
OutputStream outputStream =null;
try {
//3.将Excel文件通过Response输出到前端
outputStream = response.getOutputStream();
File file = resource.getFile();
fs = new FileInputStream(file);
wb= new XSSFWorkbook(fs);
......@@ -130,18 +136,47 @@ public class UWosnServiceImpl extends BaseEditServiceImpl implements UWosnServic
cellStyle.setBorderTop(BorderStyle.THIN);
//设置居中
cellStyle.setAlignment(HorizontalAlignment.CENTER);
String currentXh ="";
String currentGx ="";
int startRow =6;
int endRow = 5;
List<Map> maps = new ArrayList<Map>();
for(int i=0;i<gpfkVOList.size();i++) {
XSSFRow row = sheet.createRow(6 + i);
XSSFCell bzCell = row.createCell(1);
bzCell.setCellStyle(cellStyle);
XSSFCell gwCell = row.createCell(1);
gwCell.setCellStyle(cellStyle);
XSSFCell gxCell = row.createCell(2);
gxCell.setCellStyle(cellStyle);
XSSFCell zynrCell = row.createCell(3);
XSSFCell bzCell = row.createCell(3);
bzCell.setCellStyle(cellStyle);
XSSFCell zynrCell = row.createCell(4);
zynrCell.setCellStyle(cellStyle);
XSSFCell zyygCell = row.createCell(4);
XSSFCell zyygCell = row.createCell(5);
zyygCell.setCellStyle(cellStyle);
XSSFCell zysjCell = row.createCell(5);
XSSFCell zysjCell = row.createCell(6);
zysjCell.setCellStyle(cellStyle);
if(!currentXh.equals(gpfkVOList.get(i).getXh())) {
if(i!=0) {
Map map =new HashMap();
map.put("start", startRow);
map.put("end", endRow);
map.put("gx", currentGx);
map.put("gw", "工位"+currentXh);
maps.add(map);
}
currentGx =gpfkVOList.get(i).getBzgxName();
currentXh = gpfkVOList.get(i).getXh();
startRow = 6+i;
}
endRow =endRow+1;
if(i==gpfkVOList.size()-1) {
Map map =new HashMap();
map.put("start", startRow);
map.put("end", endRow);
map.put("gx", currentGx);
map.put("gw", "工位"+currentXh);
maps.add(map);
}
if(StringUtils.isNotEmpty(gpfkVOList.get(i).getBzgxGxlx())) {
String id =HzGylxEnum.getIdByName(gpfkVOList.get(i).getBzgxGxlx());
bzCell.setCellValue(id);
......@@ -182,10 +217,30 @@ public class UWosnServiceImpl extends BaseEditServiceImpl implements UWosnServic
zysjCell.setCellValue(DateUtils.formatDate(gpfkVOList.get(i).getFksj()));
}
}
if(maps!=null&&maps.size()>0) {
for(Map map1:maps) {
int start = (int) map1.get("start");
int end = (int) map1.get("end");
String gw = (String) map1.get("gw");
String gx = (String) map1.get("gx");
if(start!=end) {
CellRangeAddress gwRange = new CellRangeAddress(start, end,1, 1);
// sheet 中合并要合并的单元格地址对象
sheet.addMergedRegion(gwRange);
CellRangeAddress gxRange = new CellRangeAddress(start, end,2, 2);
// sheet 中合并要合并的单元格地址对象
sheet.addMergedRegion(gxRange);
}
XSSFRow startrow1 = sheet.getRow(start);
XSSFCell startCell1 = startrow1.getCell(1);
startCell1.setCellValue(gw);
XSSFRow startrow2 = sheet.getRow(start);
XSSFCell startCell2 = startrow2.getCell(2);
startCell2.setCellValue(gx);
}
}
}
}
//3.将Excel文件通过Response输出到前端
outputStream = response.getOutputStream();
// 清空response
response.reset();
response.setContentType("application/vnd.ms-excel");
......
......@@ -64,6 +64,16 @@ public class GpfkVO extends Gpfk {
@FieldMeta(fieldName = "SNYEAR", caption = "条码创建年")
private String snyear;
@FieldMeta(fieldName = "WOGYLX_XH", caption = "序号")
private String xh;
public String getXh() {
return xh;
}
public void setXh(String xh) {
this.xh = xh;
}
public String getSnyear() {
return snyear;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment