| package com.matrix.system.hive.action; | 
|   | 
| import java.io.IOException; | 
| import java.io.OutputStream; | 
| import java.util.ArrayList; | 
| import java.util.List; | 
|   | 
| import javax.annotation.Resource; | 
| import javax.servlet.http.HttpServletRequest; | 
| import javax.servlet.http.HttpServletResponse; | 
|   | 
| import com.matrix.core.pojo.AjaxResult; | 
| import com.matrix.core.pojo.PaginationVO; | 
|   | 
| import com.matrix.core.tools.DateUtil; | 
| import com.matrix.system.hive.bean.SysCheckDetail; | 
| import com.matrix.system.hive.bean.SysCheckInfo; | 
| import com.matrix.system.hive.plugin.util.ExcelUtil; | 
| import com.matrix.system.hive.service.CodeService; | 
| import com.matrix.system.hive.service.SysCheckDetailService; | 
| import com.matrix.system.hive.service.SysCheckInfoService; | 
| import com.matrix.system.hive.service.SysStoreInfoService; | 
| import org.apache.poi.hssf.usermodel.HSSFWorkbook; | 
| import org.apache.poi.ss.formula.functions.T; | 
| import org.springframework.stereotype.Controller; | 
| import org.springframework.ui.ModelMap; | 
| import org.springframework.web.bind.annotation.RequestMapping; | 
| import org.springframework.web.bind.annotation.ResponseBody; | 
| import org.springframework.web.servlet.ModelAndView; | 
|   | 
|   | 
|   | 
|   | 
| /** | 
|  * 盘点单明细controller | 
|  *  | 
|  * @Title: CheckInfoDetailController.java   | 
|  * @Package com.zkingsoft.actions.admin   | 
|  * @description | 
|  * @author jyy | 
|  * @email 18075895212@qq.com | 
|  * @date 2016年9月3日 下午4:15:09 | 
|  */ | 
| @Controller | 
| @RequestMapping(value = "admin/checkDetail") | 
| public class CheckInfoDetailController extends BaseController { | 
|     public static final String fnCode = "checkDetail"; | 
|     public static final String search = fnCode + ":search"; | 
|     public static final String edit = fnCode + ":edit"; | 
|     public static final String del = fnCode + ":del"; | 
|     public static final String add = fnCode + ":add"; | 
|   | 
|   | 
|   | 
|     @Resource | 
|     private SysCheckDetailService currentService; | 
|   | 
|     @Resource | 
|     private SysStoreInfoService sysStoreInfoService; | 
|     @Resource | 
|     private CodeService codeService; | 
|     @Resource | 
|     private SysCheckInfoService sysCheckInfoService; | 
|   | 
|     /** | 
|      * 列表显示 | 
|      */ | 
|     @RequestMapping(value = "/showList") | 
|     public @ResponseBody | 
|     AjaxResult showList(SysCheckDetail sysCheckDetail, PaginationVO pageVo) { | 
|         List<SysCheckDetail> dataList = currentService.findInPage(sysCheckDetail, pageVo); | 
|         AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS,  dataList, currentService.findTotal(sysCheckDetail)); | 
|         return result; | 
|     } | 
|   | 
|     /** | 
|      * 列表显示 | 
|      */ | 
|     @RequestMapping(value = "/editCheckDetail") | 
|     public @ResponseBody AjaxResult editCheckDetail(SysCheckInfo sysCheckInfo) { | 
|         int i = currentService.modifyList(sysCheckInfo); | 
|         if (i > 0) { | 
|             return new AjaxResult(AjaxResult.STATUS_SUCCESS,  "保存成功"); | 
|         } else { | 
|             return new AjaxResult(AjaxResult.STATUS_SUCCESS,  "保存失败"); | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * @author jiangyouyao @Title: report  盘点单明细导出 @param @param | 
|      *         model @param @param request @param @param response @param @param | 
|      *         vipInfo @param @return 设定文件 @return ModelAndView 返回类型 @throws | 
|      */ | 
|     @RequestMapping(value = "/exportExcel") | 
|     public void report(HttpServletRequest request, HttpServletResponse response, | 
|             SysCheckDetail sysCheckDetail) throws IOException { | 
|         List<List<List<Object>>> list = new ArrayList<>(); | 
|         // 表格1内容 | 
|         List<List<Object>> list1 = new ArrayList<>(); | 
|         // 查询出来调拨单 | 
|         SysCheckInfo checkInfo = sysCheckInfoService.findById(sysCheckDetail.getCheckId()); | 
|         List<Object> temp1 = new ArrayList<>(); | 
|         temp1.add(checkInfo.getCheckType()); | 
|         temp1.add(checkInfo.getCheckNo()); | 
|         // 时间转为字符串 | 
|         String strDate = DateUtil.dateToString(checkInfo.getCheckDate(), DateUtil.DATE_FORMAT_DD); | 
|         temp1.add(strDate); | 
|         temp1.add(checkInfo.getMakingManName()); | 
|         temp1.add(checkInfo.getAppManName()); | 
|         temp1.add(checkInfo.getCheckStatus()); | 
|         list1.add(temp1); | 
|         list.add(list1); | 
|         // 表格2内容 | 
|         List<List<Object>> list2 = new ArrayList<>(); | 
|         // 调拨单明细 | 
|         SysCheckDetail queryVo = new SysCheckDetail(); | 
|         queryVo.setCheckId(sysCheckDetail.getCheckId()); | 
|         List<SysCheckDetail> dataList = currentService.findByModel(queryVo); | 
|         if (dataList.size() > 0) { | 
|             for (SysCheckDetail obj : dataList) { | 
|   | 
|                 List<Object> temp = new ArrayList<>(); | 
|                 if(obj.getGoods()!=null){ | 
|                     temp.add(obj.getGoods().getGoodsNo()); | 
|                     temp.add(obj.getGoods().getName()); | 
|                     temp.add(obj.getBeginBalance()); | 
|                     temp.add(obj.getActuallySum()); | 
|                     temp.add(obj.getRemark()); | 
|                     temp.add(obj.getGoods().getGoodsSortName()); | 
|                     temp.add(obj.getGoods().getUnit()); | 
|                 } | 
|                 list2.add(temp); | 
|             } | 
|         } | 
|         list.add(list2); | 
|         HSSFWorkbook workbook = ExcelUtil.generateExcelMore("盘点单以及明细", | 
|                 new String[][] { { "盘点单类型", "盘点单编号", "盘点时间", "制单人", "审核人", "盘点状态" }, | 
|                         { "存货编号", "存货名称", "存货数量", "实盘数", "备注", "存货分类", "存货单位"} }, | 
|                 list); | 
|   | 
|         response.setContentType("application/vnd.ms-excel"); | 
|         response.setHeader("Content-disposition", "attachment;filename=checkDetails.xls"); | 
|         OutputStream ouputStream = response.getOutputStream(); | 
|         workbook.write(ouputStream); | 
|         ouputStream.flush(); | 
|         ouputStream.close(); | 
|   | 
|     } | 
| } |