1,批量导入第二种模板

master
e 2018-09-23 22:53:14 +08:00
parent cd4e536076
commit 422d227894
5 changed files with 661 additions and 1 deletions

View File

@ -1745,6 +1745,149 @@ public class WmOmNoticeHController extends BaseController {
}
// 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<String, Object> 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<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 获取上传文件对象
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);
params.setNeedSave(true);
try {
List<WmOmNoticeImpPage> listfirst = ExcelImportUtil.importExcel(file.getInputStream(), WmOmNoticeImpPage.class, params);
List<WmNoticeImpPage> list = new ArrayList<WmNoticeImpPage>();
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){
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<WmNoticeImpPage> listheader = ExcelImportUtil.importExcel(
file.getInputStream(), WmNoticeImpPage.class, params);
for(int i=0;i<listheader.size()-1;i++){
for(int k=listheader.size()-1;k>i;k--){
if(listheader.get(k).getImCusCode().equals(listheader.get(i).getImCusCode())) {
listheader.remove(k);
}
}
}
for(WmNoticeImpPage pageheader: listheader) {
List<WmOmNoticeHEntity> wmomh = systemService.findByProperty(WmOmNoticeHEntity.class, "imCusCode", pageheader.getImCusCode());
if(wmomh!=null&&wmomh.size()>0){
continue;
}
List<WmOmNoticeIEntity> wmomNoticeIListnew = new ArrayList<WmOmNoticeIEntity>();
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());
@ -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<WmOmNoticeHEntity> list() {

View File

@ -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;
}
}

View File

@ -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<String,String> getGoodsId(String cusgoodsid,String goodsUnit){
Map<String,String> 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<Map<String, Object>> 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);

View File

@ -51,6 +51,10 @@
<t:dgToolBar title="导出" icon="icon-putout" funname="ExportXls"></t:dgToolBar>
<t:dgToolBar title="模板下载" icon="icon-putout" funname="ExportXlsByT"></t:dgToolBar>
<t:dgToolBar title="导入2" icon="icon-put" funname="ImportXls2"></t:dgToolBar>
<t:dgToolBar title="模板2下载" icon="icon-putout" funname="ExportXlsByT2"></t:dgToolBar>
</t:datagrid>
<div name="searchColums1" style="float: left; padding-left: 0px;padding-top: 5px;">
<%--<input type="text" name="batchbin" style="width: 100px; height: 30px;">--%>
@ -147,5 +151,13 @@ function ExportXls() {
//模板下载
function ExportXlsByT() {
JeecgExcelExport("wmOmNoticeHController.do?exportXlsByT","wmOmNoticeHList");
}
//导入
function ImportXls2() {
openuploadwin('Excel导入', 'wmOmNoticeHController.do?upload2', "wmOmNoticeHList");
}
//模板下载
function ExportXlsByT2() {
JeecgExcelExport("wmOmNoticeHController.do?exportXlsByT2","wmOmNoticeHList");
}
</script>

View File

@ -0,0 +1,17 @@
<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>通用Excel导入${controller_name}</title>
<t:base type="jquery,easyui,tools"></t:base>
</head>
<body style="overflow-y: hidden" scroll="no">
<t:formvalid formid="formobj" layout="div" dialog="true" beforeSubmit="upload">
<fieldset class="step">
<div class="form"><t:upload name="fiels" buttonText="选择要导入的文件" uploader="${controller_name}.do?importExcel2" extend="*.xls;*.xlsx" id="file_upload" formData="documentTitle"></t:upload></div>
<div class="form" id="filediv" style="height: 50px"></div>
</fieldset>
</t:formvalid>
</body>
</html>