|
@@ -2,16 +2,15 @@ package com.iamberry.rst.controllers.pts;
|
|
|
|
|
|
import com.alibaba.dubbo.common.json.JSONObject;
|
|
|
import com.iamberry.rst.core.page.PagedResult;
|
|
|
-import com.iamberry.rst.core.pts.Produce;
|
|
|
-import com.iamberry.rst.core.pts.PtsBom;
|
|
|
-import com.iamberry.rst.core.pts.PtsComponents;
|
|
|
-import com.iamberry.rst.core.pts.PtsSupplier;
|
|
|
+import com.iamberry.rst.core.pts.*;
|
|
|
import com.iamberry.rst.faces.pts.MachinePartsService;
|
|
|
import com.iamberry.rst.faces.pts.MachineSupplierService;
|
|
|
import com.iamberry.rst.faces.pts.ProduceService;
|
|
|
import com.iamberry.rst.faces.pts.PtsBomService;
|
|
|
import com.iamberry.rst.utils.ExcelUtil;
|
|
|
import com.iamberry.rst.utils.StitchAttrUtil;
|
|
|
+import com.iamberry.wechat.tools.DateTimeUtil;
|
|
|
+import com.iamberry.wechat.tools.ObjectExcelView;
|
|
|
import com.iamberry.wechat.tools.ResponseJson;
|
|
|
import com.iamberry.wechat.tools.ResultInfo;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
@@ -37,10 +36,7 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.*;
|
|
|
import java.text.MessageFormat;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.Iterator;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
import static com.iamberry.rst.util.SmsConfig.SEND_NOTICE;
|
|
|
|
|
@@ -104,7 +100,9 @@ public class AdminMachinePartsController {
|
|
|
return responseJson;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 导入EXCEL生产零件(图片为默认图片)
|
|
|
+ * **/
|
|
|
@RequestMapping("/excelAdd")
|
|
|
@ResponseBody
|
|
|
public boolean excelAdd(@RequestParam("sourceFile") MultipartFile sourceFile, HttpServletRequest request, HttpServletResponse response)throws IOException {
|
|
@@ -154,6 +152,75 @@ public class AdminMachinePartsController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 导出零件列表Excel
|
|
|
+ * 2017-11-13 14:46:37
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping("/generation_excel")
|
|
|
+ public ModelAndView generationExcel(){
|
|
|
+ // 准备model
|
|
|
+ Map<String, Object> model = new HashMap<String, Object>();
|
|
|
+ model.put("fileName", "零件列表"); // 下载文件名称
|
|
|
+
|
|
|
+ // 标题
|
|
|
+ List<String> titles = new ArrayList<String>();
|
|
|
+ titles.add("零件编号");
|
|
|
+ titles.add("供应商");
|
|
|
+ titles.add("零件名称");
|
|
|
+ titles.add("图片(url)");
|
|
|
+ titles.add("状态");
|
|
|
+ titles.add("成本(元)");
|
|
|
+ titles.add("重量(g)");
|
|
|
+ titles.add("材料");
|
|
|
+ titles.add("材料类型");
|
|
|
+ titles.add("MBSC");
|
|
|
+ titles.add("规格");
|
|
|
+ model.put("titles", titles);
|
|
|
+ PtsComponents ptsComponents = new PtsComponents();
|
|
|
+ // 内容
|
|
|
+ List<List<Object>> countexts = new ArrayList<List<Object>>();
|
|
|
+ List<PtsComponents> list = machinePartsService.listPtsComponents(ptsComponents);
|
|
|
+ for (PtsComponents info : list) {
|
|
|
+ List<Object> row = new ArrayList<Object>();
|
|
|
+ row.add(info.getComponentsNo() == null ? null:info.getComponentsNo());
|
|
|
+ row.add(info.getSupplierName() == null ? null:info.getSupplierName());
|
|
|
+ row.add(info.getComponentsName() == null ? null:info.getComponentsName());
|
|
|
+ row.add(info.getComponentsImg() == null ? null:info.getComponentsImg());
|
|
|
+ row.add(info.getComponentsStatus() == 0 ? "停止使用":"正常使用");
|
|
|
+ row.add(info.getComponentsCost()/100);
|
|
|
+ row.add(info.getComponentsWeight());
|
|
|
+ row.add(info.getComponentsMaterial() == null ? null:info.getComponentsMaterial());
|
|
|
+ String type = "";
|
|
|
+ switch (info.getComponentsType()){
|
|
|
+ case 1:
|
|
|
+ type = "塑胶件";
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ type = "五金件";
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ type = "电子类";
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ type = "线材";
|
|
|
+ break;
|
|
|
+ case 5:
|
|
|
+ type = "辅材";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ row.add(info.getComponentsType() == null ? null:type);
|
|
|
+ row.add(info.getComponentsMbsc() == null ? null:info.getComponentsMbsc());
|
|
|
+ row.add(info.getComponentsSpecification() == null ? null:info.getComponentsSpecification());
|
|
|
+ countexts.add(row);
|
|
|
+ }
|
|
|
+ model.put("varList", countexts);
|
|
|
+
|
|
|
+ ObjectExcelView erv = new ObjectExcelView();
|
|
|
+ ModelAndView mv = new ModelAndView(erv,model);
|
|
|
+ return mv;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 获取机器零件列表
|
|
|
*
|
|
|
* @param request
|