diff --git a/src/main/java/com/zzjee/wm/controller/WmOmNoticeHController.java b/src/main/java/com/zzjee/wm/controller/WmOmNoticeHController.java index 39391a37..ddf58619 100644 --- a/src/main/java/com/zzjee/wm/controller/WmOmNoticeHController.java +++ b/src/main/java/com/zzjee/wm/controller/WmOmNoticeHController.java @@ -1697,6 +1697,149 @@ public class WmOmNoticeHController extends BaseController { try { List list = ExcelImportUtil.importExcel(file.getInputStream(), WmNoticeImpPage.class, params); + String flag = "Y"; + String message=""; + for(WmNoticeImpPage wmt:list){ + MvGoodsEntity mvgoods = systemService.findUniqueByProperty( + MvGoodsEntity.class, "goodsCode", wmt.getGoodsId()); + if(mvgoods==null){ + flag = "N"; + message=message+wmt.getGoodsId(); + } + } + if("N".equals(flag)){ + j.setMsg(message+"不存在"); + return j; + } + List listheader = ExcelImportUtil.importExcel( + file.getInputStream(), WmNoticeImpPage.class, params); + for(int i=0;ii;k--){ + if(listheader.get(k).getImCusCode().equals(listheader.get(i).getImCusCode())) { + listheader.remove(k); + } + } + } + for(WmNoticeImpPage pageheader: listheader) { + List wmomh = systemService.findByProperty(WmOmNoticeHEntity.class, "imCusCode", pageheader.getImCusCode()); + if(wmomh!=null&&wmomh.size()>0){ + continue; + } + + List wmomNoticeIListnew = new ArrayList(); + for (WmNoticeImpPage page : list) { + if(pageheader.getImCusCode().equals(page.getImCusCode())) { + WmOmNoticeIEntity wmi = new WmOmNoticeIEntity(); + wmi.setGoodsId(page.getGoodsId()); + MvGoodsEntity mvgoods = systemService.findUniqueByProperty( + MvGoodsEntity.class, "goodsCode", wmi.getGoodsId()); + if (mvgoods != null) { + wmi.setGoodsName(mvgoods.getGoodsName()); + wmi.setGoodsUnit(mvgoods.getShlDanWei()); + } + try{ + wmi.setGoodsQua(page.getGoodsQua()); + String[] args=page.getGoodsQua().split("\\."); + wmi.setGoodsQua(args[0]); + }catch (Exception e){ + + } + +// wmi.setGoodsPrdData(billResult.getData().get(s).getDetail().get(k).getPdProdmadedate2User()); + wmi.setOtherId(page.getOtherId()); + wmi.setBinId(page.getBinId()); + if(StringUtil.isNotEmpty(page.getGoodsProData())){ + wmi.setGoodsProData(DateUtils.str2Date(page.getGoodsProData(),DateUtils.date_sdf)); + } + wmomNoticeIListnew.add(wmi); + } + } + WmOmNoticeHEntity wmOmNoticeH = new WmOmNoticeHEntity(); + Map countMap = systemService + .findOneForJdbc("SELECT count(*)+1 as count FROM wm_om_notice_h t where TO_DAYS(t.create_date) = TO_DAYS(NOW());"); + String noticeid = null; + if (countMap != null) { + noticeid = "CK" + + DateUtils.date2Str(new Date(), DateUtils.yyyyMMdd) + + "-" + + StringUtil.leftPad( + ((Long) countMap.get("count")).intValue(), 4, + '0'); + } + wmOmNoticeH.setDelvData(pageheader.getImData()); + wmOmNoticeH.setOrderTypeCode(pageheader.getOrderTypeCode()); + wmOmNoticeH.setCusCode(pageheader.getCusCode()); + wmOmNoticeH.setOmNoticeId(noticeid); + wmOmNoticeH.setOmBeizhu(pageheader.getImBeizhu()); + wmOmNoticeH.setOcusCode(pageheader.getSupCode()); + wmOmNoticeH.setDelvAddr(pageheader.getDelvAddr()); + MdCusOtherEntity mdcusother = systemService.findUniqueByProperty(MdCusOtherEntity.class, "keHuBianMa", wmOmNoticeH.getOcusCode()); + if (mdcusother != null) { + wmOmNoticeH.setOcusName(mdcusother.getZhongWenQch()); + } + wmOmNoticeH.setImCusCode(pageheader.getImCusCode()); + wmOmNoticeHService.addMain(wmOmNoticeH, wmomNoticeIListnew); + } + // + j.setMsg("文件导入成功!"); + } catch (Exception e) { + j.setMsg("文件导入失败!"); + logger.error(ExceptionUtil.getExceptionMessage(e)); + }finally{ + try { + file.getInputStream().close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return j; + } + + + /** + * 通过excel导入数据 + * @param request + * @param + * @return + */ + @RequestMapping(params = "importExcel2", method = RequestMethod.POST) + @ResponseBody + public AjaxJson importExcel2(HttpServletRequest request, HttpServletResponse response) { + AjaxJson j = new AjaxJson(); + MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; + Map fileMap = multipartRequest.getFileMap(); + for (Map.Entry entity : fileMap.entrySet()) { + MultipartFile file = entity.getValue();// 获取上传文件对象 + ImportParams params = new ImportParams(); + params.setTitleRows(2); + params.setHeadRows(1); + params.setNeedSave(true); + try { + + + List listfirst = ExcelImportUtil.importExcel(file.getInputStream(), WmOmNoticeImpPage.class, params); + List list = new ArrayList(); + + for(WmOmNoticeImpPage t:listfirst){ + WmNoticeImpPage wmNoticeImpPage = new WmNoticeImpPage(); + wmNoticeImpPage.setOrderTypeCode("11"); + wmNoticeImpPage.setImCusCode(t.getImCusCode());//三方单号 + wmNoticeImpPage.setImBeizhu(t.getImBeizhu());//备注 + try{ + wmNoticeImpPage.setGoodsId(wmUtil.getGoodsId(t.getGoodsId(),t.getGoodsUnit()).get("goodsCode")); + wmNoticeImpPage.setCusCode(wmUtil.getGoodsId(t.getGoodsId(),t.getGoodsUnit()).get("cusCode")); + }catch (Exception e){ + + } + wmNoticeImpPage.setGoodsName(t.getGoodsName());//商品名称 + wmNoticeImpPage.setGoodsQua(t.getGoodsQua());//数量 + wmNoticeImpPage.setGoodsUnit(t.getGoodsUnit());//单位 + list.add(wmNoticeImpPage); + + } +//第二类简单模板 + String flag = "Y"; String message=""; for(WmNoticeImpPage wmt:list){ @@ -1807,6 +1950,18 @@ public class WmOmNoticeHController extends BaseController { map.put(NormalExcelConstants.DATA_LIST,new ArrayList()); return NormalExcelConstants.JEECG_EXCEL_VIEW; } + /** + * 导出excel 使模板 + */ + @RequestMapping(params = "exportXlsByT2") + public String exportXlsByT2(ModelMap map) { + map.put(NormalExcelConstants.FILE_NAME,"出货通知"); + map.put(NormalExcelConstants.CLASS,WmOmNoticeImpPage.class); + map.put(NormalExcelConstants.PARAMS,new ExportParams("出货通知", "导出人:"+ ResourceUtil.getSessionUserName().getRealName(), + "导出信息")); + map.put(NormalExcelConstants.DATA_LIST,new ArrayList()); + return NormalExcelConstants.JEECG_EXCEL_VIEW; + } /** * 导入功能跳转 * @@ -1818,7 +1973,16 @@ public class WmOmNoticeHController extends BaseController { return new ModelAndView("common/upload/pub_excel_upload"); } - + /** + * 导入功能跳转 + * + * @return + */ + @RequestMapping(params = "upload2") + public ModelAndView upload2(HttpServletRequest req) { + req.setAttribute("controller_name", "wmOmNoticeHController"); + return new ModelAndView("common/upload/pub_excel_upload2"); + } @RequestMapping(method = RequestMethod.GET) @ResponseBody public List list() { diff --git a/src/main/java/com/zzjee/wm/page/WmOmNoticeImpPage.java b/src/main/java/com/zzjee/wm/page/WmOmNoticeImpPage.java new file mode 100644 index 00000000..1981c95d --- /dev/null +++ b/src/main/java/com/zzjee/wm/page/WmOmNoticeImpPage.java @@ -0,0 +1,431 @@ + +package com.zzjee.wm.page; + +import org.jeecgframework.poi.excel.annotation.Excel; + +import java.util.Date; + +/** + * @Title: Entity + * @Description: 导入 + * @author erzhongxmu + * @date 2017-09-11 15:08:34 + * @version V1.0 + * + */ +public class WmOmNoticeImpPage implements java.io.Serializable { + /**主键*/ + private String id; + /**创建人名称*/ + + private String createName; + /**创建人登录名称*/ + + private String createBy; + /**创建日期*/ + + private Date createDate; + /**更新人名称*/ + + private String updateName; + /**更新人登录名称*/ + + private String updateBy; + /**更新日期*/ + + private Date updateDate; + /**所属部门*/ + + + private String readonly; + private String wherecon; + + private String sysOrgCode; + /**所属公司*/ + + private String sysCompanyCode; + /**客户编码*/ + + private String cusCode; + /**预计到货时间*/ + + private Date imData; + /**客户订单号*/ + @Excel(name="订单编号") + private String imCusCode; + + + private String orderTypeCode; + + + + private String delvAddr; + /**进货通知单号*/ + + private String noticeId; + + private String supCode; + /**附件*/ + + private String supName; + + private String otherId; + @Excel(name="商品") + private String goodsId; + + @Excel(name="商品名称") + private String goodsName; + + /**出货数量*/ + @Excel(name="数量") + private String goodsQua; + /**出货单位*/ + @Excel(name="单位") + private String goodsUnit; + + @Excel(name="备注") + private String imBeizhu; + + private String binId; + + + + private String goodsProData; + + + /** + *方法: 取得java.lang.String + *@return: java.lang.String 主键 + */ + public String getId(){ + return this.id; + } + + /** + *方法: 设置java.lang.String + *@param: java.lang.String 主键 + */ + public void setId(String id){ + this.id = id; + } + /** + *方法: 取得java.lang.String + *@return: java.lang.String 创建人名称 + */ + public String getCreateName(){ + return this.createName; + } + + /** + *方法: 设置java.lang.String + *@param: java.lang.String 创建人名称 + */ + public void setCreateName(String createName){ + this.createName = createName; + } + /** + *方法: 取得java.lang.String + *@return: java.lang.String 创建人登录名称 + */ + public String getCreateBy(){ + return this.createBy; + } + + /** + *方法: 设置java.lang.String + *@param: java.lang.String 创建人登录名称 + */ + public void setCreateBy(String createBy){ + this.createBy = createBy; + } + /** + *方法: 取得java.util.Date + *@return: java.util.Date 创建日期 + */ + public Date getCreateDate(){ + return this.createDate; + } + + /** + *方法: 设置java.util.Date + *@param: java.util.Date 创建日期 + */ + public void setCreateDate(Date createDate){ + this.createDate = createDate; + } + /** + *方法: 取得java.lang.String + *@return: java.lang.String 更新人名称 + */ + public String getUpdateName(){ + return this.updateName; + } + + /** + *方法: 设置java.lang.String + *@param: java.lang.String 更新人名称 + */ + public void setUpdateName(String updateName){ + this.updateName = updateName; + } + /** + *方法: 取得java.lang.String + *@return: java.lang.String 更新人登录名称 + */ + public String getUpdateBy(){ + return this.updateBy; + } + + /** + *方法: 设置java.lang.String + *@param: java.lang.String 更新人登录名称 + */ + public void setUpdateBy(String updateBy){ + this.updateBy = updateBy; + } + /** + *方法: 取得java.util.Date + *@return: java.util.Date 更新日期 + */ + public Date getUpdateDate(){ + return this.updateDate; + } + + /** + *方法: 设置java.util.Date + *@param: java.util.Date 更新日期 + */ + public void setUpdateDate(Date updateDate){ + this.updateDate = updateDate; + } + /** + *方法: 取得java.lang.String + *@return: java.lang.String 所属部门 + */ + public String getSysOrgCode(){ + return this.sysOrgCode; + } + + /** + *方法: 设置java.lang.String + *@param: java.lang.String 所属部门 + */ + public void setSysOrgCode(String sysOrgCode){ + this.sysOrgCode = sysOrgCode; + } + /** + *方法: 取得java.lang.String + *@return: java.lang.String 所属公司 + */ + public String getSysCompanyCode(){ + return this.sysCompanyCode; + } + + /** + *方法: 设置java.lang.String + *@param: java.lang.String 所属公司 + */ + public void setSysCompanyCode(String sysCompanyCode){ + this.sysCompanyCode = sysCompanyCode; + } + /** + *方法: 取得java.lang.String + *@return: java.lang.String 客户编码 + */ + public String getCusCode(){ + return this.cusCode; + } + + /** + *方法: 设置java.lang.String + *@param: java.lang.String 客户编码 + */ + public void setCusCode(String cusCode){ + this.cusCode = cusCode; + } + /** + *方法: 取得java.util.Date + *@return: java.util.Date 预计到货时间 + */ + public Date getImData(){ + return this.imData; + } + + /** + *方法: 设置java.util.Date + *@param: java.util.Date 预计到货时间 + */ + public void setImData(Date imData){ + this.imData = imData; + } + /** + *方法: 取得java.lang.String + *@return: java.lang.String 客户订单号 + */ + public String getImCusCode(){ + return this.imCusCode; + } + + /** + *方法: 设置java.lang.String + *@param: java.lang.String 客户订单号 + */ + public void setImCusCode(String imCusCode){ + this.imCusCode = imCusCode; + } + /** + *方法: 取得java.lang.String + *@return: java.lang.String 司机 + */ + + /** + *方法: 取得java.lang.String + *@return: java.lang.String 订单类型 + */ + public String getOrderTypeCode(){ + return this.orderTypeCode; + } + + /** + *方法: 设置java.lang.String + *@param: java.lang.String 订单类型 + */ + public void setOrderTypeCode(String orderTypeCode){ + this.orderTypeCode = orderTypeCode; + } + /** + *方法: 取得java.lang.String + *@return: java.lang.String 月台 + */ + /** + *方法: 取得java.lang.String + *@return: java.lang.String 备注 + */ + public String getImBeizhu(){ + return this.imBeizhu; + } + + /** + *方法: 设置java.lang.String + *@param: java.lang.String 备注 + */ + public void setImBeizhu(String imBeizhu){ + this.imBeizhu = imBeizhu; + } + + + + public String getNoticeId(){ + return this.noticeId; + } + + /** + *方法: 设置java.lang.String + *@param: java.lang.String 进货通知单号 + */ + public void setNoticeId(String noticeId){ + this.noticeId = noticeId; + } + + + + + public String getReadonly() { + return readonly; + } + + public void setReadonly(String readonly) { + this.readonly = readonly; + } + + public String getWherecon() { + return wherecon; + } + + public void setWherecon(String wherecon) { + this.wherecon = wherecon; + } + + public String getSupCode() { + return supCode; + } + + public void setSupCode(String supCode) { + this.supCode = supCode; + } + + public String getSupName() { + return supName; + } + + public void setSupName(String supName) { + this.supName = supName; + } + + + public String getOtherId() { + return otherId; + } + + public void setOtherId(String otherId) { + this.otherId = otherId; + } + + public String getGoodsId() { + return goodsId; + } + + public void setGoodsId(String goodsId) { + this.goodsId = goodsId; + } + + public String getGoodsName() { + return goodsName; + } + + public void setGoodsName(String goodsName) { + this.goodsName = goodsName; + } + + public String getGoodsQua() { + return goodsQua; + } + + public void setGoodsQua(String goodsQua) { + this.goodsQua = goodsQua; + } + + public String getGoodsUnit() { + return goodsUnit; + } + + public void setGoodsUnit(String goodsUnit) { + this.goodsUnit = goodsUnit; + } + + + public String getDelvAddr() { + return delvAddr; + } + + public void setDelvAddr(String delvAddr) { + this.delvAddr = delvAddr; + } + + + public String getBinId() { + return binId; + } + + public void setBinId(String binId) { + this.binId = binId; + } + + public String getGoodsProData() { + return goodsProData; + } + + public void setGoodsProData(String goodsProData) { + this.goodsProData = goodsProData; + } +} diff --git a/src/main/java/com/zzjee/wmutil/wmUtil.java b/src/main/java/com/zzjee/wmutil/wmUtil.java index 6382ba90..9d84029c 100644 --- a/src/main/java/com/zzjee/wmutil/wmUtil.java +++ b/src/main/java/com/zzjee/wmutil/wmUtil.java @@ -18,6 +18,7 @@ import javax.imageio.stream.FileImageOutputStream; import javax.servlet.http.HttpServletRequest; import java.io.*; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; @@ -41,6 +42,41 @@ public class wmUtil { } return list; } +//通过客户商品编码,或者WMS商品编码和单位找到WMS编码 + public static Map getGoodsId(String cusgoodsid,String goodsUnit){ + Map resultmap = new HashMap<>(); + String goodsCode= null; + String cusCode= null; + SystemService systemService =ApplicationContextUtil.getContext().getBean(SystemService.class); + String tsql = "select cus_code,chailing, goods_id,goods_code,shp_bian_makh,shl_dan_wei,baseunit" + + " from mv_goods where goods_id = ? or shp_bian_makh = ? order by chailing desc"; + List> result= systemService.findForJdbc(tsql, cusgoodsid,cusgoodsid); + if(result.size() > 0) { + try{ + for(int i = 0; i < result.size(); i++){ + if(goodsUnit.equals(result.get(i).get("baseunit").toString())){ + goodsCode = result.get(i).get("goods_code").toString(); + cusCode = result.get(i).get("cus_code").toString(); + resultmap.put("goodsCode",goodsCode); + resultmap.put("cusCode",cusCode); + break; + } + if(goodsUnit.equals(result.get(i).get("shl_dan_wei").toString())){ + goodsCode = result.get(i).get("goods_id").toString(); + cusCode = result.get(i).get("cus_code").toString(); + resultmap.put("goodsCode",goodsCode); + resultmap.put("cusCode",cusCode); + break; + } + + } + + }catch (Exception e){ + + } + } + return resultmap; + } public static String getCusCode(){ SystemService systemService =ApplicationContextUtil.getContext().getBean(SystemService.class); diff --git a/src/main/webapp/webpage/com/zzjee/wm/wmOmNoticeHList.jsp b/src/main/webapp/webpage/com/zzjee/wm/wmOmNoticeHList.jsp index 9fd2ce81..6d809e59 100644 --- a/src/main/webapp/webpage/com/zzjee/wm/wmOmNoticeHList.jsp +++ b/src/main/webapp/webpage/com/zzjee/wm/wmOmNoticeHList.jsp @@ -51,6 +51,10 @@ + + + +
<%----%> @@ -148,4 +152,12 @@ function ExportXls() { function ExportXlsByT() { JeecgExcelExport("wmOmNoticeHController.do?exportXlsByT","wmOmNoticeHList"); } + //导入 + function ImportXls2() { + openuploadwin('Excel导入', 'wmOmNoticeHController.do?upload2', "wmOmNoticeHList"); + } + //模板下载 + function ExportXlsByT2() { + JeecgExcelExport("wmOmNoticeHController.do?exportXlsByT2","wmOmNoticeHList"); + } \ No newline at end of file diff --git a/src/main/webapp/webpage/common/upload/pub_excel_upload2.jsp b/src/main/webapp/webpage/common/upload/pub_excel_upload2.jsp new file mode 100644 index 00000000..b0f275d2 --- /dev/null +++ b/src/main/webapp/webpage/common/upload/pub_excel_upload2.jsp @@ -0,0 +1,17 @@ +<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<%@include file="/context/mytags.jsp"%> + + + +通用Excel导入${controller_name} + + + + +
+
+
+
+
+ +