tntdc 1 gadu atpakaļ
vecāks
revīzija
904310cb5f

+ 17 - 6
adm/pom.xml

@@ -355,10 +355,15 @@
 		    <version>5.5.11</version>
 		</dependency>
 		
-  		<dependency>
-		    <groupId>log4j</groupId>
-		    <artifactId>log4j</artifactId>
-		    <version>1.2.17</version>
+		<dependency>
+		    <groupId>org.apache.logging.log4j</groupId>
+		    <artifactId>log4j-api</artifactId>
+		    <version>2.22.1</version>
+		</dependency>
+		<dependency>
+		    <groupId>org.apache.logging.log4j</groupId>
+		    <artifactId>log4j-core</artifactId>
+		    <version>2.22.1</version>
 		</dependency>
         
         <dependency>
@@ -405,7 +410,7 @@
 		<dependency>
 		  <groupId>com.deepoove</groupId>
 		  <artifactId>poi-tl</artifactId>
-		  <version>1.6.0-beta1</version>
+		  <version>1.12.2</version>
 		</dependency>
 		<dependency>
 		  <groupId>com.belerweb</groupId>
@@ -426,7 +431,7 @@
 		<dependency>
 		    <groupId>org.apache.commons</groupId>
 		    <artifactId>commons-pool2</artifactId>
-		    <version>2.0</version>
+		    <version>2.12.0</version>
 		</dependency>
 		<dependency>
 		    <groupId>redis.clients</groupId>
@@ -484,6 +489,12 @@
 			<scope>system</scope>
 			<systemPath>${project.basedir}/src/main/webapp/WEB-INF/lib/ueditor-1.1.2.jar</systemPath>
 		</dependency>
+		
+		<dependency>
+		  <groupId>commons-io</groupId>
+		  <artifactId>commons-io</artifactId>
+		  <version>2.15.1</version>
+		</dependency>
 </dependencies>
 
 	<build>

+ 15 - 95
adm/src/main/java/com/minpay/common/util/FilesUtil.java

@@ -28,10 +28,10 @@ import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.fileupload.FileItem;
-import org.apache.poi.hssf.usermodel.HSSFDateUtil;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.openxml4j.util.ZipSecureFile;
 import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.DateUtil;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
@@ -243,96 +243,12 @@ public class FilesUtil {
 		        }    
 	    	}    
 	    }   
-	    float result = count / chLength;    
 	    if (count > 0) {    
 	    	return true;    
 	    }else{    
 	    	return false;    
 	    }    
 	}
-	/**
-	 * 读取xlsx格式Execl文档,暂不支持xls格式
-	 * @param execl 文件
-	 * @param titleKey	map中存放key,与execl中每列对应
-	 * @param firstrow 读取开始行
-	 * @return
-	 * @throws InvalidFormatException
-	 * @throws IOException
-	 * @throws MINBusinessException
-	 */
-	public static List<Map<String,Object>> readExecl(FileItem execl,String[] titleKey,int firstrow) throws InvalidFormatException, IOException, MINBusinessException{
-		
-        List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
-		Workbook wb = WorkbookFactory.create(execl.getInputStream());
-		/** 得到第一个shell */  
-		Sheet sheet = wb.getSheetAt(0);
-		Row firstRow = sheet.getRow(0);
-		if(titleKey.length != firstRow.getPhysicalNumberOfCells()){
-			throw new BusinessCodeException("PBIM2800");//文件数据格式不正确
-		}
-		
-		int rownum =  sheet.getPhysicalNumberOfRows();
-		//获取最后一行的下标
-		int lastNum = sheet.getLastRowNum();
-		Log.info("物理行数 "+sheet.getLastRowNum()+" lastNum:"+lastNum);
-		int cellnum = firstRow.getLastCellNum();
-		if(cellnum>titleKey.length){
-			throw new MINBusinessException("PBIM2800");//提示数据格式不正确
-		}
-		DecimalFormat df = new DecimalFormat("#");  
-		
-		for(int i=firstrow; i<=lastNum; i++){
-			//用来判断当前行所有单元格是否为空
-			int count = 0;
-			Row row = sheet.getRow(i);
-			if(row == null){
-				continue;
-			}
-			Map<String,Object> map = new HashMap<String,Object>();
-			for(int j=0; j<titleKey.length; j++){
-				System.out.println(i+":"+j);
-				Cell cell = row.getCell(j);
-				String cellValue="";
-				if(cell != null){
-					
-					switch (cell.getCellType()){
-		                case NUMERIC: // 数字  
-		                    cellValue = df.format(cell.getNumericCellValue());  //cell.getNumericCellValue() + "";  
-		                    break;  
-		                case STRING: // 字符串  
-		                    cellValue = cell.getStringCellValue();  
-		                    break;  
-		                case BOOLEAN: // Boolean  
-		                    cellValue = cell.getBooleanCellValue() + "";  
-		                    break;  
-		                case FORMULA: // 公式  
-		                    cellValue = cell.getCellFormula() + "";  
-		                    break;  
-		                case BLANK: // 空值  
-		                    cellValue = "";  
-		                    break;  
-		                case ERROR: // 故障  
-		                    cellValue = "非法字符";  
-		                    break;  
-		                default:  
-		                    cellValue = "未知类型";  
-		                    break;  
-	                }
-				}
-				if("".equals(cellValue) || cellValue == null){
-					count ++;
-				}
-				map.put(titleKey[j], cellValue);
-			}
-			if(count != titleKey.length){
-				map.put("currentLine", i+1);
-				list.add(map);
-			}
-		}
-		
-        return list;  
-		
-	}
 		
 	/**
 	 * 读取xlsx格式Execl文档,暂不支持xls格式    简版
@@ -345,13 +261,11 @@ public class FilesUtil {
 	 * @throws MINBusinessException
 	 */
 	public static List<Map<String,Object>> readExecleasy(FileItem execl,String[] titleKey,int firstrow) throws InvalidFormatException, IOException, MINBusinessException{
-		
         List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
         ZipSecureFile.setMinInflateRatio(-1.0d);
 		Workbook wb = WorkbookFactory.create(execl.getInputStream());
-		/** 得到第一个shell */  
+		//得到第一个shell
 		Sheet sheet = wb.getSheetAt(0);
-		Row firstRow = sheet.getRow(0);
 		
 		int rownum =  sheet.getPhysicalNumberOfRows();
 		System.out.println("getContentType "+sheet.getPhysicalNumberOfRows()+" rownum:"+rownum);
@@ -359,10 +273,6 @@ public class FilesUtil {
 		if(rownum == 0){
 			throw new BusinessCodeException("PBIM2800");//提示数据格式不正确
 		}
-//		int cellnum = firstRow.getLastCellNum();
-		/*if(cellnum>titleKey.length){
-			throw new BusinessCodeException("PBIM2800");//提示数据格式不正确
-		}*/
 		DecimalFormat df = new DecimalFormat("###.####");  
 		
 		for(int i=firstrow; i<rownum; i++){
@@ -370,13 +280,12 @@ public class FilesUtil {
 			if(row != null) {
 				Map<String,Object> map = new HashMap<String,Object>();
 				for(int j=0; j<titleKey.length; j++){
-					System.out.println(i+":"+j);
 					Cell cell = row.getCell(j);
 					String cellValue="";
 					if(cell != null){
 						switch (cell.getCellType()){
 							case NUMERIC: // 数字  
-								if(HSSFDateUtil.isCellDateFormatted(cell)){
+								if(DateUtil.isCellDateFormatted(cell)){
 									//用于转化为日期格式
 									Date d = cell.getDateCellValue();
 									DateFormat formater = new SimpleDateFormat("yyyyMMdd");
@@ -408,10 +317,21 @@ public class FilesUtil {
 					}
 					map.put(titleKey[j], cellValue);
 				}
+				boolean emptyLine = true;
+				for(Map.Entry<String,Object> entry : map.entrySet()) {
+					if(entry.getValue() != null && !"".equals(entry.getValue())){
+						emptyLine = false;
+						break;
+					}
+				}
+				// 出现空行数据
+				if(emptyLine) {
+					break;
+				}
 				list.add(map);
 			}
 		}
-		 return list;  
+		 return list;
 	}
 	
 	public static void writeFile2Response(HttpServletResponse response, String filUrl) {

+ 366 - 0
adm/src/main/java/com/minpay/db/StatementInterceptor.java

@@ -0,0 +1,366 @@
+package com.minpay.db;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.Properties;
+import java.util.Stack;
+
+import org.apache.commons.lang.reflect.FieldUtils;
+import org.apache.ibatis.executor.statement.PreparedStatementHandler;
+import org.apache.ibatis.executor.statement.RoutingStatementHandler;
+import org.apache.ibatis.executor.statement.StatementHandler;
+import org.apache.ibatis.mapping.BoundSql;
+import org.apache.ibatis.mapping.MappedStatement;
+import org.apache.ibatis.plugin.Interceptor;
+import org.apache.ibatis.plugin.Intercepts;
+import org.apache.ibatis.plugin.Invocation;
+import org.apache.ibatis.plugin.Plugin;
+import org.apache.ibatis.plugin.Signature;
+import org.apache.ibatis.scripting.defaults.DefaultParameterHandler;
+import org.apache.ibatis.session.Configuration;
+import org.apache.ibatis.session.SqlSession;
+
+import com.startup.minpay.frame.exception.MINRuntimeException;
+import com.startup.minpay.frame.jdbc.MINRowBounds;
+import com.startup.minpay.frame.jdbc.MINTransaction;
+import com.startup.minpay.frame.jdbc.dialet.Dialect;
+import com.startup.minpay.util.Env;
+
+@Intercepts({
+		@Signature(type = StatementHandler.class, method = "prepare", args = { Connection.class, Integer.class }) })
+public class StatementInterceptor implements Interceptor {
+	private static final String OracleDialect = "com.startup.minpay.frame.jdbc.dialet.OracleDialect";
+	private static final String MySQLDIALECT = "com.startup.minpay.frame.jdbc.dialet.MySQLDialect";
+
+	private enum DialectType {
+		Oracle("Oracle"), MySQL("MySQL");
+		String value;
+
+		DialectType(String value) {
+			this.value = value;
+		}
+	}
+
+	public Object intercept(Invocation invocation) throws Throwable {
+		int page = 0;
+		SqlSession session = null;
+		Stack<MINTransaction> transaction = (Stack<MINTransaction>) Env.getThreadEnv("MINDatabaseSession");
+		session = ((MINTransaction) transaction.peek()).getSession();
+		Connection connection = session.getConnection();
+		Configuration config = session.getConfiguration();
+		
+		RoutingStatementHandler statement = (RoutingStatementHandler) invocation.getTarget();
+		Object o = MINReflectUtil.getFieldValue(statement, "delegate");
+		
+		BoundSql boundSql = statement.getBoundSql();
+		String sql = boundSql.getSql();
+		
+		if (o instanceof PreparedStatementHandler) {
+			PreparedStatementHandler handler = (PreparedStatementHandler) MINReflectUtil.getFieldValue(statement, "delegate");
+			Object rows = MINReflectUtil.getFieldValue(handler, "rowBounds");
+
+			if (rows instanceof MINRowBounds) {
+				MINRowBounds rowBounds = (MINRowBounds) rows;
+
+				if (rowBounds.getLimit() > 0 && rowBounds.getLimit() < Integer.MAX_VALUE) {
+					
+					String DIALECT = null;
+					try {
+						String countSql = "";
+
+						if (rowBounds.isSeparateSql()) {
+							if (rowBounds.getCountSql() != null && !"".equals(rowBounds.getCountSql())) {
+								countSql = rowBounds.getCountSql();
+							} else {
+								countSql = getCountSql(sql);
+							}
+						} else {
+							countSql = "select count(1) from (" + sql + ") b";
+//							countSql = getCountSql(sql);
+						}
+
+						Object parameterObject = handler.getParameterHandler().getParameterObject();
+
+						BoundSql b = new BoundSql(config, countSql.toString(), boundSql.getParameterMappings(),
+								parameterObject);
+						MINReflectUtil.setFieldValue(b, "metaParameters",
+								MINReflectUtil.getFieldValue(boundSql, "metaParameters"));
+						MINReflectUtil.setFieldValue(b, "additionalParameters",
+								MINReflectUtil.getFieldValue(boundSql, "additionalParameters"));
+
+						MappedStatement mappedStatement = (MappedStatement) FieldUtils.readField(handler,
+								"mappedStatement", true);
+						
+						String databaseName = connection.getMetaData().getDatabaseProductName();
+
+						if (DialectType.Oracle.value.equalsIgnoreCase(databaseName)) {
+							DIALECT = "com.startup.minpay.frame.jdbc.dialet.OracleDialect";
+						} else {
+							DIALECT = "com.startup.minpay.frame.jdbc.dialet.MySQLDialect";
+						}
+						PreparedStatement countStmt = connection.prepareStatement(countSql);
+
+						if (rowBounds.getCountSql() == null || "".equals(rowBounds.getCountSql())) {
+							DefaultParameterHandler dph = new DefaultParameterHandler(mappedStatement, parameterObject,
+									b);
+							dph.setParameters(countStmt);
+						}
+
+						ResultSet rs = countStmt.executeQuery();
+						rs.next();
+						page = rs.getInt(1);
+
+						rs.close();
+						countStmt.close();
+
+						rowBounds.setMaxRows(page);
+					} finally {
+						if (session != null) {
+							session.close();
+						}
+					}
+
+					Dialect dialect = (Dialect) Class.forName(DIALECT).newInstance();
+
+					sql = dialect.getLimitString(sql, rowBounds.getOffset(), rowBounds.getLimit());
+
+					MINReflectUtil.setFieldValue(boundSql, "sql", sql);
+				} else {
+					String countSql = getCountSql(sql);
+					if(countSql != null) {
+						Object parameterObject = handler.getParameterHandler().getParameterObject();
+	
+						BoundSql b = new BoundSql(config, countSql, boundSql.getParameterMappings(),
+								parameterObject);
+						MINReflectUtil.setFieldValue(b, "metaParameters",
+								MINReflectUtil.getFieldValue(boundSql, "metaParameters"));
+						MINReflectUtil.setFieldValue(b, "additionalParameters",
+								MINReflectUtil.getFieldValue(boundSql, "additionalParameters"));
+	
+						MappedStatement mappedStatement = (MappedStatement) FieldUtils.readField(handler,
+								"mappedStatement", true);
+						
+						PreparedStatement countStmt = connection.prepareStatement(countSql);
+	
+						DefaultParameterHandler dph = new DefaultParameterHandler(mappedStatement, parameterObject,
+								b);
+						dph.setParameters(countStmt);
+						
+						ResultSet rs = countStmt.executeQuery();
+						while (rs.next()){
+							page = rs.getInt(1);
+						}
+						countStmt.close();
+						session.close();
+					}
+				}
+			} else {
+				String countSql = getCountSql(sql);
+				if(countSql != null) {
+					Object parameterObject = handler.getParameterHandler().getParameterObject();
+
+					BoundSql b = new BoundSql(config, countSql, boundSql.getParameterMappings(),
+							parameterObject);
+					MINReflectUtil.setFieldValue(b, "metaParameters",
+							MINReflectUtil.getFieldValue(boundSql, "metaParameters"));
+					MINReflectUtil.setFieldValue(b, "additionalParameters",
+							MINReflectUtil.getFieldValue(boundSql, "additionalParameters"));
+
+					MappedStatement mappedStatement = (MappedStatement) FieldUtils.readField(handler,
+							"mappedStatement", true);
+					
+					PreparedStatement countStmt = connection.prepareStatement(countSql);
+
+					DefaultParameterHandler dph = new DefaultParameterHandler(mappedStatement, parameterObject, b);
+					dph.setParameters(countStmt);
+					
+					ResultSet rs = countStmt.executeQuery();
+					while (rs.next()){
+						page = rs.getInt(1);
+					}
+					countStmt.close();
+					session.close();
+				}
+			}
+		}
+		System.out.println("page====>:" + page);
+		return invocation.proceed();
+	}
+
+	private String getCountSql(String sql) {
+		sql = sql.toLowerCase();
+		if(!sql.trim().startsWith("select") || sql.contains("count(") || !sql.contains("from")){
+			return null;
+		}
+		String countSql = sql.substring(sql.toLowerCase().indexOf("select") + 6);
+		countSql = countSql.toLowerCase();
+		int sumStatIndex = 6;
+		int startIndex = 0;
+
+		for (int i = 0; i < 15;) {
+
+			startIndex = countSql.indexOf("from");
+			if (startIndex == -1) {
+				break;
+			}
+			sumStatIndex = sumStatIndex + startIndex + 4;
+
+			String nowSql = countSql.substring(0, startIndex);
+
+			if (nowSql.indexOf("select") != -1) {
+				countSql = sql.substring(sumStatIndex);
+
+				i++;
+			}
+
+			break;
+		}
+		String retcountSql = sql.substring(sumStatIndex);
+		retcountSql = "select count(1) from ".concat(retcountSql);
+
+		if (sql.toUpperCase().lastIndexOf("GROUP BY") != -1) {
+			countSql = "select count(1) from (" + countSql + ") tt";
+		}
+		
+		System.out.println("" + retcountSql);
+
+		return retcountSql;
+	}
+
+	public Object plugin(Object target) {
+		return Plugin.wrap(target, this);
+	}
+
+	public void setProperties(Properties properties) {
+	}
+
+	static class MINReflectUtil {
+		protected static Object operate(Object obj, String fieldName, Object fieldVal, String type) {
+			Object ret = null;
+
+			try {
+				Class<? extends Object> classType = (Class) obj.getClass();
+
+				Field[] fields = classType.getDeclaredFields();
+				for (int i = 0; i < fields.length; i++) {
+					Field field = fields[i];
+					if (field.getName().equals(fieldName)) {
+
+						String firstLetter = fieldName.substring(0, 1).toUpperCase();
+						if ("set".equals(type)) {
+							String setMethodName = "set" + firstLetter + fieldName.substring(1);
+							Method setMethod = classType.getMethod(setMethodName, new Class[] { field.getType() });
+							ret = setMethod.invoke(obj, new Object[] { fieldVal });
+						}
+						if ("get".equals(type)) {
+							String getMethodName = "get" + firstLetter + fieldName.substring(1);
+							Method getMethod = classType.getMethod(getMethodName, new Class[0]);
+							ret = getMethod.invoke(obj, new Object[0]);
+						}
+						return ret;
+					}
+				}
+			} catch (Exception e) {
+				throw new MINRuntimeException(e);
+			}
+			return ret;
+		}
+
+		public static Object getVal(Object obj, String fieldName) {
+			return operate(obj, fieldName, null, "get");
+		}
+
+		public static void setVal(Object obj, String fieldName, Object fieldVal) {
+			operate(obj, fieldName, fieldVal, "set");
+		}
+
+		private static Method getDeclaredMethod(Object object, String methodName, Class[] parameterTypes) {
+			for (Class<?> superClass = object.getClass(); superClass != Object.class; superClass = superClass
+					.getSuperclass()) {
+
+				try {
+					return superClass.getDeclaredMethod(methodName, parameterTypes);
+				} catch (NoSuchMethodException noSuchMethodException) {
+				}
+			}
+
+			return null;
+		}
+
+		private static void makeAccessible(Field field) {
+			if (!Modifier.isPublic(field.getModifiers())) {
+				field.setAccessible(true);
+			}
+		}
+
+		private static Field getDeclaredField(Object object, String filedName) {
+			for (Class<?> superClass = object.getClass(); superClass != Object.class; superClass = superClass
+					.getSuperclass()) {
+				try {
+					return superClass.getDeclaredField(filedName);
+				} catch (NoSuchFieldException noSuchFieldException) {
+				}
+			}
+
+			return null;
+		}
+
+		public static Object invokeMethod(Object object, String methodName, Class[] parameterTypes, Object[] parameters)
+				throws InvocationTargetException {
+			Method method = getDeclaredMethod(object, methodName, parameterTypes);
+
+			if (method == null) {
+				throw new IllegalArgumentException(
+						"Could not find method [" + methodName + "] on target [" + object + "]");
+			}
+
+			method.setAccessible(true);
+
+			try {
+				return method.invoke(object, parameters);
+			} catch (IllegalAccessException illegalAccessException) {
+
+				return null;
+			}
+		}
+
+		public static void setFieldValue(Object object, String fieldName, Object value) {
+			Field field = getDeclaredField(object, fieldName);
+
+			if (field == null) {
+				throw new IllegalArgumentException(
+						"Could not find field [" + fieldName + "] on target [" + object + "]");
+			}
+			makeAccessible(field);
+
+			try {
+				field.set(object, value);
+			} catch (IllegalAccessException e) {
+				e.printStackTrace();
+			}
+		}
+
+		public static Object getFieldValue(Object object, String fieldName) {
+			Field field = getDeclaredField(object, fieldName);
+			if (field == null) {
+				throw new IllegalArgumentException(
+						"Could not find field [" + fieldName + "] on target [" + object + "]");
+			}
+			makeAccessible(field);
+
+			Object result = null;
+			try {
+				result = field.get(object);
+			} catch (IllegalAccessException e) {
+				e.printStackTrace();
+			}
+
+			return result;
+		}
+	}
+}

+ 2 - 1
adm/src/main/java/com/minpay/db/table/own/mapper/TotalShipManageMapper.java

@@ -14,5 +14,6 @@ public interface TotalShipManageMapper extends IMINMybatisEntityMapper {
 	/**查询发运量
 	 * @param rows */
 	List<Map<String,String>> queryTotalShipHejiment(Map<String, String> m, MINRowBounds rows);
-	
+	/**查询发运总重量 */
+	Map<String, String> queryTotalShipHejimentWeight(Map<String, String> m);
 }

+ 2 - 7
adm/src/main/java/com/minpay/guomao/giveoutmanage/StockOfGiveOutManageAction.java

@@ -17,8 +17,6 @@ import com.minpay.common.util.CommonUtil;
 import com.minpay.common.util.DateUtil;
 import com.minpay.common.util.FilesUtil;
 import com.minpay.db.table.mapper.ApGiveOutMapper;
-import com.minpay.db.table.mapper.ApWarehouseDetailMapper;
-import com.minpay.db.table.mapper.ApWarehouseStockMapper;
 import com.minpay.db.table.mapper.PubAppparMapper;
 import com.minpay.db.table.model.ApGiveOut;
 import com.minpay.db.table.model.ApGiveOutExample;
@@ -142,8 +140,8 @@ public class StockOfGiveOutManageAction implements IMINAction {
 			throw new BusinessCodeException("JINM0501");//文件格式不对,请下载模板后上传
 		}
 		// 获取表格信息
-			String[] titleKey = new String[]{"address","caseNo","carNumber","weight"};
-			list = FilesUtil.readExecleasy(fileItem, titleKey, 2);
+		String[] titleKey = new String[]{"address","caseNo","carNumber","weight"};
+		list = FilesUtil.readExecleasy(fileItem, titleKey, 2);
 		
 		if (list.size() == 0) {
 			throw new BusinessCodeException("JINM0502");//无数据,请添加数据
@@ -181,11 +179,8 @@ public class StockOfGiveOutManageAction implements IMINAction {
 						d.setModifyUser(u.getId());//修改人
 						Service.lookup(IGuoMaoWareDetailService.class).updateWareDetail(d, null);
 					}
-					
 				}
 			}
-			
-			
 		}
 		
 		res.set(IMINBusinessConstant.F_PAGING_LAY, list);

+ 5 - 4
adm/src/main/java/com/minpay/guomao/giveoutmanage/TotalShipManageAction.java

@@ -1,6 +1,5 @@
 package com.minpay.guomao.giveoutmanage;
 
-import java.io.OutputStream;
 import java.lang.reflect.InvocationTargetException;
 import java.util.HashMap;
 import java.util.List;
@@ -8,13 +7,10 @@ import java.util.Map;
 
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-
 import com.minpay.common.bean.User;
 import com.minpay.common.constant.Constant;
 import com.minpay.common.format.IFormatService;
 import com.minpay.common.util.ToExcelUtil;
-import com.minpay.common.util.ToExcelUtil2;
 import com.minpay.db.table.own.mapper.TotalShipManageMapper;
 import com.startup.minpay.frame.business.IMINAction;
 import com.startup.minpay.frame.business.res.MINActionResult;
@@ -93,10 +89,15 @@ public class TotalShipManageAction implements IMINAction {
 		
 		List<Map<String,String>> resList = Service.lookup(IMINDataBaseService.class).getMybatisMapper(TotalShipManageMapper.class)
 							.queryTotalShipHejiment(map, rows);
+		
+		Map<String, String> weightMap = Service.lookup(IMINDataBaseService.class).getMybatisMapper(TotalShipManageMapper.class)
+		.queryTotalShipHejimentWeight(map);
+		
 		resList = new MINCopyFormat("{region:'regionDesc',contractType:'contractTypeDesc'}").format(resList);
 		resList = Service.lookup(IFormatService.class).formatEnum(resList,"{regionDesc:'PB_REGION',contractTypeDesc:'ACI_CONTRACT_TYPE'}");
 		res.set(IMINBusinessConstant.F_PAGING_LAY, resList);
 		res.set(IMINBusinessConstant.F_PAGING_COUNT, rows.getCount());
+		res.set("totalWeight", weightMap.get("totalWeight"));
 		return res;
 	}
 	

+ 1 - 1
adm/src/main/java/com/minpay/guomao/invoicemanage/ScanInvoice4NewAction.java

@@ -786,7 +786,7 @@ public class ScanInvoice4NewAction implements IMINAction {
 		ApLvInvoice LvInvoice = Service.lookup(IMINDataBaseService.class).selectByPrimaryKey(ApLvInvoiceMapper.class, fpNo);
 		
 		ApInvoiceDetailExample invoiceDetailExample = new ApInvoiceDetailExample();
-		invoiceDetailExample.createCriteria().andInvoiceLvIdEqualTo(fpNo);
+		invoiceDetailExample.createCriteria().andInvoiceLvIdEqualTo(fpNo).andStateNotEqualTo("01");
 		// 查询detail发票上的商品信息
 		List<ApInvoiceDetail> invoiceDetailList = Service.lookup(IMINDataBaseService.class).selectByExample(ApInvoiceDetailMapper.class, invoiceDetailExample);
 		

+ 63 - 1
adm/src/main/java/com/minpay/guomao/stockManage/SettleManageAction.java

@@ -21,8 +21,10 @@ import com.minpay.common.util.CommonUtil;
 import com.minpay.common.util.DateUtil;
 import com.minpay.common.util.ListUtil;
 import com.minpay.common.util.ToExcelUtil;
-import com.minpay.common.util.ToExcelUtil2;
+import com.minpay.db.table.mapper.ApInvoiceDetailMapper;
 import com.minpay.db.table.mapper.ApWarehouseInfMapper;
+import com.minpay.db.table.model.ApInvoiceDetail;
+import com.minpay.db.table.model.ApInvoiceDetailExample;
 import com.minpay.db.table.model.ApWarehouseInf;
 import com.minpay.db.table.model.OwnApWarehouseInfExample;
 import com.minpay.db.table.own.mapper.InvoiceManageMapper;
@@ -238,7 +240,67 @@ public class SettleManageAction implements IMINAction {
 		list = Service.lookup(IFormatService.class).formatDate(list, "payDate");
 		list = new MINCopyFormat("{type:'typeDesc'}").format(list);
 		list = Service.lookup(IFormatService.class).formatEnum(list, "{typeDesc:'INVOICE_TYPE'}");
+		
+		// 增加明细数据
+		if(list.size() > 0) {
+			List<String> invoiceIdList = CommonUtil.getIdFromList(list, "invoiceId");
+			ApInvoiceDetailExample invoiceDetailExample = new ApInvoiceDetailExample();
+			invoiceDetailExample.createCriteria().andInvoiceLvIdIn(invoiceIdList).andStateNotEqualTo("01");
+			invoiceDetailExample.setOrderByClause("AID_INVOICE_LV_ID, AID_ID");
+			// 查询detail发票上的商品信息
+			List<ApInvoiceDetail> invoiceDetailList = Service.lookup(IMINDataBaseService.class).selectByExample(ApInvoiceDetailMapper.class, invoiceDetailExample);
+			for(int i = 0; i < list.size(); i ++) {
+				String invoiceId = list.get(i).get("invoiceId");
+				String d_invoiceNo = list.get(i).get("invoiceNo");
+				boolean same = false;
+				for(int j = 0; j < invoiceDetailList.size(); j ++) {
+					if(same && !invoiceId.equals(invoiceDetailList.get(j).getInvoiceLvId())) {
+						break;
+					}
+					if(invoiceId.equals(invoiceDetailList.get(j).getInvoiceLvId())) {
+						// 第一条
+						if(!same) {
+							Map<String, String> data = list.get(i);
+							if(CommonUtil.isEmpty(invoiceDetailList.get(j).getNumber())) {
+								data.put("d_number", d_invoiceNo);
+							} else {
+								data.put("d_number", invoiceDetailList.get(j).getNumber());
+							}
+							data.put("d_name", invoiceDetailList.get(j).getName());
+							data.put("d_unit", invoiceDetailList.get(j).getUnit());
+							data.put("d_weight", invoiceDetailList.get(j).getWeight());
+							data.put("d_price", invoiceDetailList.get(j).getPrice());
+							data.put("d_taxRate", invoiceDetailList.get(j).getTaxRate());
+							data.put("d_amount", invoiceDetailList.get(j).getAmount());
+							data.put("d_tax", invoiceDetailList.get(j).getTax());
+							data.put("d_specification", invoiceDetailList.get(j).getSpecification());
+						} else {
+							Map<String, String> data = new HashMap<>();
+							if(CommonUtil.isEmpty(invoiceDetailList.get(j).getNumber())) {
+								data.put("d_number", d_invoiceNo);
+							} else {
+								data.put("d_number", invoiceDetailList.get(j).getNumber());
+							}
+							data.put("d_name", invoiceDetailList.get(j).getName());
+							data.put("d_unit", invoiceDetailList.get(j).getUnit());
+							data.put("d_weight", invoiceDetailList.get(j).getWeight());
+							data.put("d_price", invoiceDetailList.get(j).getPrice());
+							data.put("d_taxRate", invoiceDetailList.get(j).getTaxRate());
+							data.put("d_amount", invoiceDetailList.get(j).getAmount());
+							data.put("d_tax", invoiceDetailList.get(j).getTax());
+							data.put("d_specification", invoiceDetailList.get(j).getSpecification());
+							data.put("invoiceId", invoiceId);
+							list.add(++ i, data);
+						}
+						same = true;
+					}
+				}
+			}
+		}
+		
+		//String exportExcel = "发票日期#date,发票号码#invoiceNo,发票代码#invoiceCode,不含税金额(元)#amount,合计税额#tax,价税合计#totalPrice,购买方#buyer,销售方#seller,上传时间#createTime";
 		String exportExcel = "发票日期#date,发票号码#invoiceNo,发票代码#invoiceCode,不含税金额(元)#amount,合计税额#tax,价税合计#totalPrice,购买方#buyer,销售方#seller,上传时间#createTime";
+		exportExcel += ",发票编号#d_number,货物/服务名称#d_name,单位#d_unit,重量#d_weight,单价(元)#d_price,税率(%)#d_taxRate,不含税金额(元)#d_amount,税额(元)#d_tax,规格#d_specification";
 		String[] excelHeader = exportExcel.split(",");
 		try {
 			ToExcelUtil.download(response,reportName, excelHeader, list);

+ 25 - 22
adm/src/main/java/com/minpay/guomao/templateexport/action/TemplateExportAction.java

@@ -18,11 +18,14 @@ import org.apache.poi.xwpf.usermodel.XWPFTable;
 import org.apache.poi.xwpf.usermodel.XWPFTableCell;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.STMerge;
 
-import com.deepoove.poi.NiceXWPFDocument;
+//import com.deepoove.poi.NiceXWPFDocument;
 import com.deepoove.poi.XWPFTemplate;
-import com.deepoove.poi.data.MiniTableRenderData;
+import com.deepoove.poi.data.MergeCellRule;
+import com.deepoove.poi.data.MergeCellRule.Grid;
+//import com.deepoove.poi.data.MiniTableRenderData;
 import com.deepoove.poi.data.RowRenderData;
-import com.deepoove.poi.data.TextRenderData;
+import com.deepoove.poi.data.Rows;
+import com.deepoove.poi.data.Tables;
 import com.minpay.common.bean.User;
 import com.minpay.common.format.IFormatService;
 import com.minpay.common.service.IDownloadService;
@@ -161,6 +164,7 @@ public class TemplateExportAction implements IMINAction {
 				list.get(i).put("url", modeklist.get(0).get("url"));
 				String path = MINRequest.getSession().getServletContext().getRealPath("/web");
 				strm = Service.lookup(IDownloadService.class).donwLoad(modeklist.get(0).get("url").replace("106.37.170.219:10001", "127.0.0.1"), path);
+				//strm = Service.lookup(IDownloadService.class).donwLoad(modeklist.get(0).get("url"), path);
 	    	}
 		}
 		//
@@ -348,9 +352,10 @@ public class TemplateExportAction implements IMINAction {
 		
 		zhongzhiTime = DateUtil.getDifferentTimeByMinute(zhongzhiTime, 0, DateUtil.ZH_DATE_FORMAT_DB);
 		String zhongzhi = zhongzhiTime;
-        RowRenderData header = RowRenderData.build(new TextRenderData("品牌"), new TextRenderData( "规格"), new TextRenderData( "仓库"), new TextRenderData( "数量(吨)"), new TextRenderData( "含税单价(元/吨)"), new TextRenderData( "含税总金额(元)"));
-        List<RowRenderData> datas = new ArrayList<RowRenderData>();
-        
+//        RowRenderData header = RowRenderData.build(new TextRenderData("品牌"), new TextRenderData( "规格"), new TextRenderData( "仓库"), new TextRenderData( "数量(吨)"), new TextRenderData( "含税单价(元/吨)"), new TextRenderData( "含税总金额(元)"));
+		RowRenderData header = Rows.of("品牌", "规格", "仓库", "数量(吨)", "含税单价(元/吨)", "含税总金额(元)").create();
+		List<RowRenderData> datas = new ArrayList<RowRenderData>();
+		datas.add(header);
         
         if (!CommonUtil.isYHL(branchId)) {
         	allweight = "0";
@@ -360,11 +365,11 @@ public class TemplateExportAction implements IMINAction {
     		if(!CommonUtil.isYHL(branchId)){
     			allweight = CommonUtil.add(allweight, CommonUtil.objToString(newlist.get(i).get("reaWeight")),4);
     			allamt = CommonUtil.add(allamt, CommonUtil.multiply(CommonUtil.objToString(newlist.get(i).get("reaWeight")),CommonUtil.objToString(newlist.get(i).get("sjPrice"))),2);
-    			RowRenderData rowDto = RowRenderData.build(CommonUtil.objToString(newlist.get(i).get("abfName")), CommonUtil.objToString(newlist.get(i).get("value")), CommonUtil.objToString(newlist.get(i).get("warehouseName")), CommonUtil.objToString(newlist.get(i).get("reaWeight")),CommonUtil.objToString(newlist.get(i).get("sjPrice")), CommonUtil.multiply(CommonUtil.objToString(newlist.get(i).get("reaWeight")),CommonUtil.objToString(newlist.get(i).get("sjPrice")),2));
-	        	datas.add(rowDto);
+    			RowRenderData rowDto = Rows.of(CommonUtil.objToString(newlist.get(i).get("abfName")), CommonUtil.objToString(newlist.get(i).get("value")), CommonUtil.objToString(newlist.get(i).get("warehouseName")), CommonUtil.objToString(newlist.get(i).get("reaWeight")),CommonUtil.objToString(newlist.get(i).get("sjPrice")), CommonUtil.multiply(CommonUtil.objToString(newlist.get(i).get("reaWeight")),CommonUtil.objToString(newlist.get(i).get("sjPrice")), 2)).create();
+    			datas.add(rowDto);
     		}else{
-    			RowRenderData rowDto = RowRenderData.build(CommonUtil.objToString(newlist.get(i).get("abfName")), CommonUtil.objToString(newlist.get(i).get("value")), CommonUtil.objToString(newlist.get(i).get("warehouseName")), CommonUtil.objToString(newlist.get(i).get("weight")),CommonUtil.objToString(newlist.get(i).get("price")), CommonUtil.multiply(CommonUtil.objToString(newlist.get(i).get("weight")),CommonUtil.objToString(newlist.get(i).get("price"))));
-	        	datas.add(rowDto);
+    			RowRenderData rowDto = Rows.of(CommonUtil.objToString(newlist.get(i).get("abfName")), CommonUtil.objToString(newlist.get(i).get("value")), CommonUtil.objToString(newlist.get(i).get("warehouseName")), CommonUtil.objToString(newlist.get(i).get("weight")),CommonUtil.objToString(newlist.get(i).get("price")), CommonUtil.multiply(CommonUtil.objToString(newlist.get(i).get("weight")),CommonUtil.objToString(newlist.get(i).get("price")))).create();
+    			datas.add(rowDto);
     		}
         
     	}
@@ -457,13 +462,19 @@ public class TemplateExportAction implements IMINAction {
 		        
 		        // 增加合计行
 		        if(!CommonUtil.isYHL(branchId)){
-		        	RowRenderData lastRenderData = RowRenderData.build("合计", "", "", weightAll, CommonUtil.divide(amtAll, weightAll, 2), amtAll);
+		        	RowRenderData lastRenderData = Rows.of("合计", "", "", weightAll, CommonUtil.divide(amtAll, weightAll, 2), amtAll).create();
 			        datas.add(lastRenderData);
-			        RowRenderData lastRenderData2 = RowRenderData.build("合计人民币金额(大写):"+chineseNb+" ,税率 13%,不含税总金额:"+CommonUtil.divide(amtAll, "1.13", 2)+"元。", "", "", "", "", "");
+			        RowRenderData lastRenderData2 = Rows.of("合计人民币金额(大写):"+chineseNb+" ,税率 13%,不含税总金额:"+CommonUtil.divide(amtAll, "1.13", 2)+"元。", "", "", "", "", "").create();
 			        datas.add(lastRenderData2);
 		        }
-		        MiniTableRenderData table = new MiniTableRenderData(header, datas);
-		        put("table", table);// 产品表格信息
+		        if(!CommonUtil.isYHL(branchId)) {
+		        	// 合并合计与最后一行数据,合计规则未两个单元格之间合并
+		        	MergeCellRule rule = MergeCellRule.builder().map(Grid.of(datas.size()-2, 0), Grid.of(datas.size()-2, 2)).map(Grid.of(datas.size()-1, 0), Grid.of(datas.size()-1, 5)).build();
+		        	put("table", Tables.of(datas.toArray(new RowRenderData[datas.size()])).mergeRule(rule).create());// 产品表格信息
+		        } else {
+		        	put("table", Tables.create(datas.toArray(new RowRenderData[datas.size()])));// 产品表格信息
+		        }
+		        
 		        Date date = new Date();
 		        SimpleDateFormat sb = new SimpleDateFormat("yyyy年/MM月/dd日");
 		        put("payDate", sb.format(date));//支付日期
@@ -492,14 +503,6 @@ public class TemplateExportAction implements IMINAction {
 		        
 		}});
 		
-		// 合并合计单元格
-		if(!CommonUtil.isYHL(branchId)) {
-			NiceXWPFDocument xwpfDocument = template.getXWPFDocument();
-			XWPFTable table = xwpfDocument.getTableArray(1);
-			mergeCellsHorizontal(table, table.getRows().size() - 2, 0, 2);
-			mergeCellsHorizontal(table, table.getRows().size() - 1, 0, 5);
-		}
-		
 		response.setContentType("multipart/form-data"); 
 	    String formFileName = new String(name.getBytes("UTF-8"), "ISO-8859-1");
 	    if (CommonUtil.isEmpty(formFileName)) {

+ 41 - 0
adm/src/main/resources/com/minpay/db/table/own/mapper/TotalShipManageMapper.xml

@@ -106,4 +106,45 @@
 		group by g.AGO_FH_DATE,com.ACI_NAME,pro.API_NAME,spec.ASR_VALUE,brand.ABF_NAME,g.AGO_SETTLEMENT_PRICE,g.AGO_CONTRACT_MONTH,warehouse.AWI_REGION,g.AGO_STATION,g.AGO_CONSIGNEE,g.AGO_FY_WAY
 		order by g.AGO_FH_DATE
 	</select>
+	<select id="queryTotalShipHejimentWeight" resultType="hashmap" parameterType="java.util.Map">
+		select 
+			cast(round(sum(AGO_WEIGHT), 4) as char) 'totalWeight'
+		from 
+			ap_give_out g
+		left join ap_contract_inf c
+			on g.AGO_CONTRACT_ID = c.ACI_ID
+		left join ap_company_inf com
+			on com.ACI_ID = c.ACI_SELLER_ID
+		left join ap_product_spec_rel spec
+			on g.AGO_SPCL = spec.ASR_SPEC_NO
+		left join ap_product_inf pro
+			on pro.API_ID = spec.ASR_PRODUCT_ID
+		left join ap_brand_inf brand
+			on brand.ABF_ID = g.AGO_BRAND
+		left join ap_warehouse_inf warehouse
+			on warehouse.AWI_ID = g.AGO_WAREINF_ID
+		WHERE g.AGO_STATE != '01'
+		and g.AGO_BRANCH_ID = #{branchId,jdbcType=VARCHAR}
+		<if test="fayunDate != null and fayunDate != ''">
+			and substring(g.AGO_FH_DATE, 1, 8) between substring(#{fayunDate,jdbcType=VARCHAR}, 1, 8) and substring(#{fayunDate,jdbcType=VARCHAR}, 12, 20)
+		</if>
+		<if test="consignee != null and consignee != ''">
+			and g.AGO_CONSIGNEE like concat('%', #{consignee,jdbcType=VARCHAR}, '%')
+		</if>
+		<if test="forwardingUnit != null and forwardingUnit != ''">
+			and com.ACI_NAME like concat('%', #{forwardingUnit,jdbcType=VARCHAR}, '%')
+		</if>
+		<if test="station != null and station != ''">
+			and g.AGO_STATION like concat('%', #{station,jdbcType=VARCHAR}, '%')
+		</if>
+		<if test="station != null and station != ''">
+			and g.AGO_STATION like concat('%', #{station,jdbcType=VARCHAR}, '%')
+		</if>
+		<if test="contranctMonth != null and contranctMonth != ''">
+			and g.AGO_CONTRACT_MONTH = #{contranctMonth,jdbcType=VARCHAR}
+		</if>
+		<if test="region != null and region != ''">
+			and warehouse.AWI_REGION = #{region,jdbcType=VARCHAR}
+		</if>
+	</select>
 </mapper>

+ 2 - 1
adm/src/main/webapp/WEB-INF/mybatisConfigure.xml

@@ -14,7 +14,8 @@ PUBLIC "-//ibatis.apache.org//DTD Config 3.0//EN"
 	</settings>
 	<plugins>
 		<plugin interceptor="com.startup.minpay.frame.jdbc.interceptor.MINResultSetInterceptor" />
-		<plugin interceptor="com.startup.minpay.frame.jdbc.interceptor.MINStatementInterceptor" />
+		<!-- <plugin interceptor="com.startup.minpay.frame.jdbc.interceptor.MINStatementInterceptor" /> -->
+		<plugin interceptor="com.minpay.db.StatementInterceptor" />
 		<!--<plugin interceptor="com.github.pagehelper.PageInterceptor">
 			&lt;!&ndash; 分页参数合理化, 当页码数 < 0 时, 显示第一页.   当页码数 > 总页码数时, 显示最后一页  &ndash;&gt;
 			<property name="reasonable" value="true"/>

+ 2 - 2
adm/src/main/webapp/admin/giveOutManage/giveoutManage.html

@@ -156,8 +156,8 @@
   				<button class="layui-btn left-bnt1 in-b"   id="printGiveOut">结算单打印
   				</button>
   				
- 				<button class="layui-btn left-bnt1 in-b"   id="updatePrice">修改结算价
-  				</button>
+ 				<!-- <button class="layui-btn left-bnt1 in-b"   id="updatePrice">修改结算价
+  				</button> -->
   				
   				<button class="layui-btn left-bnt1 in-b" id="closeOprate" status = "on">
 					<i class="layui-icon">&#xe602;</i> 操作栏靠右

+ 1 - 1
adm/src/main/webapp/admin/orderManage/someOutPrintCd.html

@@ -193,7 +193,7 @@
 						} else {
 							caeDesc = "";
 						}
-						$('#jianjie1').html(riqi+"月合同执行量"+tableData[tableData.length - 1].weight+"吨,已" + dongzuo + "金额"+tableData[tableData.length - 1].totalPriceI+"元,实际结算金额"+tableData[tableData.length - 1].totalPriceII+"元, "+caeDesc+"卖方于"+riqi+"月26日前开具当月全额增值税发票。");
+						$('#jianjie1').html(riqi+"月合同执行量"+tableData[tableData.length - 1].detailWeight+"吨,已" + dongzuo + "金额"+tableData[tableData.length - 1].totalPriceI+"元,实际结算金额"+tableData[tableData.length - 1].totalPriceII+"元, "+caeDesc+"卖方于"+riqi+"月26日前开具当月全额增值税发票。");
 					}
 				});
 				table.on('edit(tableFilter)', function(obj){ //注:edit是固定事件名,test是table原始容器的属性 lay-filter="对应的值"

+ 9 - 8
adm/src/main/webapp/admin/stockManage/totalShipment.html

@@ -49,9 +49,15 @@
 	  </form>
 	</div>
 	<div class="order-select back-border" id="content" style="display: block;">
-		<div class="layui-inline" id="allStockDiv">
+		<div class="layui-inline">
 			<label class="f12-gray4">选中行发运总重量:</label>
 			<div class="layui-input-inline">
+				<input type="text" class="layui-input" id="chooseTotalWeight" name="chooseTotalWeight" value = "0" style="border:none;color: red" disabled="disabled" class="search-select">
+			</div>
+		</div>
+		<div class="layui-inline">
+			<label class="f12-gray4">发运总重量:</label>
+			<div class="layui-input-inline">
 				<input type="text" class="layui-input" id="totalWeight" name="totalWeight" value = "0" style="border:none;color: red" disabled="disabled" class="search-select">
 			</div>
 		</div>
@@ -114,12 +120,7 @@
 				       ,{field: 'fyWay', title: '发运方式', width:"10%"}
 		    ]]
 		    ,done: function(res, curr, count){
-		        //如果是异步请求数据方式,res即为你接口返回的信息。
-		        console.log(res);
-		        //得到当前页码
-		        console.log(curr); 
-		        //得到数据总量
-		        console.log(count);
+		        $("#totalWeight").val(res.totalWeight);
 		      }
 		    ,even: true //开启隔行背景
 		  });
@@ -130,7 +131,7 @@
 			  for (var i = 0; i < checkData.length; i ++) {
 				  checkWeight = accAdd(checkWeight,isEmpty(checkData[i].weight)?0:checkData[i].weight,4);
 			  }
-			  $("#totalWeight").val(checkWeight);
+			  $("#chooseTotalWeight").val(checkWeight);
 		});
 		$('.demoTableOne .layui-btn').on('click', function(){
 		  	var type = $(this).data('type');