Browse Source

wms代码提交

guq 7 years ago
parent
commit
a6ef236d05
26 changed files with 4814 additions and 0 deletions
  1. 25 0
      eis-wms/.gitignore
  2. 80 0
      eis-wms/pom.xml
  3. 12 0
      eis-wms/src/main/java/com/uas/eiswms/EisWmsApplication.java
  4. 51 0
      eis-wms/src/main/java/com/uas/eiswms/aop/ExceptionHandlerAdvice.java
  5. 59 0
      eis-wms/src/main/java/com/uas/eiswms/controller/BasicDataController.java
  6. 21 0
      eis-wms/src/main/java/com/uas/eiswms/controller/LoginController.java
  7. 51 0
      eis-wms/src/main/java/com/uas/eiswms/controller/ProdIOController.java
  8. 518 0
      eis-wms/src/main/java/com/uas/eiswms/dao/BaseDao.java
  9. 31 0
      eis-wms/src/main/java/com/uas/eiswms/dao/ProdInOutDao.java
  10. 36 0
      eis-wms/src/main/java/com/uas/eiswms/dao/RowConvert.java
  11. 438 0
      eis-wms/src/main/java/com/uas/eiswms/model/SqlRowList.java
  12. 21 0
      eis-wms/src/main/java/com/uas/eiswms/service/BasicDataService.java
  13. 89 0
      eis-wms/src/main/java/com/uas/eiswms/service/LoginService.java
  14. 11 0
      eis-wms/src/main/java/com/uas/eiswms/service/ProdIOService.java
  15. 280 0
      eis-wms/src/main/java/com/uas/eiswms/service/SaleClashService.java
  16. 199 0
      eis-wms/src/main/java/com/uas/eiswms/service/impl/BasicDataServiceImpl.java
  17. 1442 0
      eis-wms/src/main/java/com/uas/eiswms/service/impl/ProdIOServiceImpl.java
  18. 133 0
      eis-wms/src/main/java/com/uas/eiswms/util/BaseUtil.java
  19. 128 0
      eis-wms/src/main/java/com/uas/eiswms/util/Constant.java
  20. 584 0
      eis-wms/src/main/java/com/uas/eiswms/util/DateUtil.java
  21. 93 0
      eis-wms/src/main/java/com/uas/eiswms/util/JsonUtil.java
  22. 109 0
      eis-wms/src/main/java/com/uas/eiswms/util/MasterManager.java
  23. 267 0
      eis-wms/src/main/java/com/uas/eiswms/util/NumberUtil.java
  24. 88 0
      eis-wms/src/main/java/com/uas/eiswms/util/StringUtils.java
  25. 4 0
      eis-wms/src/main/resources/application.properties
  26. 44 0
      eis-wms/src/main/resources/logback.xml

+ 25 - 0
eis-wms/.gitignore

@@ -0,0 +1,25 @@
+/target/
+!.mvn/wrapper/maven-wrapper.jar
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/build/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/

+ 80 - 0
eis-wms/pom.xml

@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+
+	<groupId>com.uas</groupId>
+	<artifactId>eis-wms</artifactId>
+	<version>0.0.1-SNAPSHOT</version>
+	<packaging>jar</packaging>
+
+	<name>eis-wms</name>
+	<description>Demo project for Spring Boot</description>
+
+	<parent>
+		<groupId>org.springframework.boot</groupId>
+		<artifactId>spring-boot-starter-parent</artifactId>
+		<version>2.0.4.RELEASE</version>
+		<relativePath/> <!-- lookup parent from repository -->
+	</parent>
+
+	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+		<java.version>1.8</java.version>
+	</properties>
+
+	<dependencies>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-web</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-jdbc</artifactId>
+			<version>5.0.8.RELEASE</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-test</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>com.alibaba</groupId>
+			<artifactId>druid</artifactId>
+			<version>1.0.26</version>
+		</dependency>
+		<dependency>
+			<groupId>net.sf.json-lib</groupId>
+			<artifactId>json-lib</artifactId>
+			<version>2.4</version>
+			<classifier>jdk15</classifier>
+		</dependency>
+		<dependency>
+			<groupId>net.sf.flexjson</groupId>
+			<artifactId>flexjson</artifactId>
+			<version>2.1</version>
+		</dependency>
+		<dependency>
+			<groupId>com.oracle</groupId>
+			<artifactId>ojdbc6</artifactId>
+			<version>11.2.0</version>
+		</dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.15</version>
+        </dependency>
+    </dependencies>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.springframework.boot</groupId>
+				<artifactId>spring-boot-maven-plugin</artifactId>
+			</plugin>
+		</plugins>
+	</build>
+
+
+</project>

+ 12 - 0
eis-wms/src/main/java/com/uas/eiswms/EisWmsApplication.java

@@ -0,0 +1,12 @@
+package com.uas.eiswms;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class EisWmsApplication {
+
+	public static void main(String[] args) {
+		SpringApplication.run(EisWmsApplication.class, args);
+	}
+}

+ 51 - 0
eis-wms/src/main/java/com/uas/eiswms/aop/ExceptionHandlerAdvice.java

@@ -0,0 +1,51 @@
+package com.uas.eiswms.aop;
+
+import org.apache.catalina.connector.ClientAbortException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+
+
+@ControllerAdvice
+public class ExceptionHandlerAdvice {
+    private static Logger logger = LoggerFactory.getLogger(ExceptionHandlerAdvice.class);
+
+    /**
+     * 处理已捕获异常,明确传达给客户端错误码、错误信息
+     *
+     * @param e
+     * @return
+     */
+    @ExceptionHandler(Throwable.class)
+    public ResponseEntity<ModelMap> handleError(Throwable e) {
+        if(e instanceof ClientAbortException){
+            logger.error(e.getMessage());
+        }else{
+            logger.error("", e);
+        }
+        ModelMap map = new ModelMap();
+        map.put("success", false);
+        map.put("message", e.getMessage());
+        map.put("detailedMessage", getDetailedMessage(e));
+        HttpHeaders headers = new HttpHeaders();
+        headers.add("Content-Type", "application/json; charset=utf-8");
+        return new ResponseEntity<ModelMap>(map, headers, HttpStatus.INTERNAL_SERVER_ERROR);
+    }
+
+    public  String getDetailedMessage(Throwable e) {
+        StringBuilder sb = new StringBuilder(e.toString());
+        StackTraceElement[] stackTraceElements = e.getStackTrace();
+        for (StackTraceElement stackTraceElement : stackTraceElements) {
+            sb.append("\n\t").append(stackTraceElement.toString());
+        }
+        if (e.getCause() != null) {
+            sb.append("\nCaused by: ").append(getDetailedMessage(e.getCause()));
+        }
+        return sb.toString();
+    }
+}

+ 59 - 0
eis-wms/src/main/java/com/uas/eiswms/controller/BasicDataController.java

@@ -0,0 +1,59 @@
+
+package com.uas.eiswms.controller;
+
+import com.uas.eiswms.dao.BaseDao;
+import com.uas.eiswms.service.BasicDataService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.http.HttpServletRequest;
+import java.util.Map;
+
+
+/**
+ * @ClassName BasicDataController
+ * @Description 基础资料Controller
+ * @Author jinxing.chen
+ * @Date 2018/8/22 18:47
+ * @Version 1.o
+ */
+
+@RestController
+@RequestMapping("/XKN")
+public class BasicDataController {
+
+    @Autowired
+    private BasicDataService basicDataService;
+    @Autowired
+    private BaseDao baseDao;
+
+    @PostMapping(value = "/basic/getProduct.action")
+    public Map<String, Object> postProductToXKN(String master, String formDate, String userName, String passWord, String token) {
+//        token 177491659cf02f9c9b98e7be1e16d447
+        baseDao.setJdbcTemplate(master);
+        return basicDataService.postProductToXKN(formDate, userName, passWord, token);
+    }
+
+    @PostMapping(value = "/basic/getCustomer.action")
+    public Map<String, Object> postCustomerToXKN(String master, String formDate, String userName, String passWord, String token){
+        baseDao.setJdbcTemplate(master);
+        return basicDataService.postCustomerToXKN(formDate, userName, passWord, token);
+    }
+
+    @PostMapping(value = "/basic/getVendor.action")
+    public Map<String, Object> postVendorToXKN(String master, String formDate, String userName, String passWord, String token){
+        baseDao.setJdbcTemplate(master);
+        return basicDataService.postVendorToXKN(formDate, userName, passWord, token);
+    }
+
+    @PostMapping(value = "/basic/getWarehouse.action")
+    public Map<String, Object> postWareHouseToXKN(String master,String formDate, String userName, String passWord, String token){
+        baseDao.setJdbcTemplate(master);
+        return basicDataService.postWareHouseToXKN(formDate, userName, passWord, token);
+    }
+
+}
+

+ 21 - 0
eis-wms/src/main/java/com/uas/eiswms/controller/LoginController.java

@@ -0,0 +1,21 @@
+package com.uas.eiswms.controller;
+
+import com.uas.eiswms.service.LoginService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Map;
+
+@RestController
+@RequestMapping("/XKN")
+public class LoginController {
+    @Autowired
+    private LoginService loginService;
+
+    @PostMapping(value = "/wms2uas/login.action")
+    public Map<String, Object> login(String userName, String passWord) {
+        return loginService.login(userName, passWord);
+    }
+}

+ 51 - 0
eis-wms/src/main/java/com/uas/eiswms/controller/ProdIOController.java

@@ -0,0 +1,51 @@
+package com.uas.eiswms.controller;
+
+import com.sun.xml.internal.rngom.parse.host.Base;
+import com.uas.eiswms.dao.BaseDao;
+import com.uas.eiswms.service.ProdIOService;
+import com.uas.eiswms.util.BaseUtil;
+import com.uas.eiswms.util.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping("/XKN")
+public class ProdIOController {
+
+    @Autowired
+    private ProdIOService prodIOService;
+    @Autowired
+    private BaseDao baseDao;
+
+    @RequestMapping("/porductio/post.action")
+    public Map<String, Object> post(String master, String data, String token, Long timestamp, String sign){
+        Map<String, Object> map = new HashMap<String, Object>();
+        if(StringUtils.isEmpty(data)) {
+            BaseUtil.showError("空数据,请检查后进行请求!");
+        }
+        baseDao.setJdbcTemplate(master);
+        prodIOService.prePost(data);
+        map.put("success", true);
+        return map;
+    }
+
+    @RequestMapping("/productio/getBill.action")
+    public Map<String, Object> getBill(String master, String pi_class, String lastUpdateTime, String condition,
+         String token, Long timestamp, String sign) {
+        baseDao.setJdbcTemplate(master);
+       return prodIOService.getBill(pi_class, lastUpdateTime, condition);
+    }
+
+    @RequestMapping("/productio/test.action")
+    public Map<String, Object> test(String master, String pi_class, String lastUpdateTime, String condition,
+                                       String token, Long timestamp, String sign) {
+        System.out.println("进入");
+        return prodIOService.test(pi_class, lastUpdateTime, condition, master);
+    }
+
+}

+ 518 - 0
eis-wms/src/main/java/com/uas/eiswms/dao/BaseDao.java

@@ -0,0 +1,518 @@
+package com.uas.eiswms.dao;
+
+
+
+
+import com.alibaba.druid.pool.DruidDataSource;
+import com.sun.xml.internal.rngom.parse.host.Base;
+import com.uas.eiswms.model.SqlRowList;
+import com.uas.eiswms.util.BaseUtil;
+
+import com.uas.eiswms.util.Constant;
+import com.uas.eiswms.util.DateUtil;
+import com.uas.eiswms.util.MasterManager;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
+import org.springframework.dao.DataAccessException;
+import org.springframework.jdbc.core.CallableStatementCallback;
+import org.springframework.jdbc.core.CallableStatementCreator;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.support.rowset.SqlRowSet;
+import org.springframework.lang.Nullable;
+import org.springframework.stereotype.Repository;
+
+import javax.sql.DataSource;
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.util.*;
+
+@Repository("baseDao")
+public class BaseDao {
+
+	static final String CREATE_SEQ = "CREATE SEQUENCE ?" + // 创建序列
+			" MINVALUE 1 MAXVALUE 99999999999 INCREMENT BY 1 START WITH 3000 CACHE 20 NOORDER NOCYCLE ";
+
+	private JdbcTemplate jdbcTemplate;
+
+	public void setJdbcTemplate(String master){
+		DataSource dataSource = MasterManager.getDataSource(master);
+		if (dataSource == null){
+			BaseUtil.showError("数据源不存在");
+		}
+		if (this.jdbcTemplate == null) {
+			this.jdbcTemplate = new JdbcTemplate(dataSource);
+		} else {
+			this.jdbcTemplate.setDataSource(dataSource);
+		}
+	}
+
+	/*public DataSource getDataSource(String master) {
+		DruidDataSource dataSource = new DruidDataSource();
+		System.out.println(env.getProperty("spring.datasource."+master+".url"));
+		System.out.println(env.getProperty("spring.datasource."+master+".username"));
+		System.out.println(env.getProperty("spring.datasource."+master+".password"));
+		System.out.println(env.getProperty("spring.datasource."+master+".driver-class-name"));
+		dataSource.setUrl(env.getProperty("spring.datasource."+master+".url"));
+		dataSource.setUsername(env.getProperty("spring.datasource."+master+".username"));//用户名
+		dataSource.setPassword(env.getProperty("spring.datasource."+master+".password"));//密码
+		dataSource.setDriverClassName(env.getProperty("spring.datasource."+master+".driver-class-name"));
+		dataSource.setInitialSize(2);//初始化时建立物理连接的个数
+		dataSource.setMaxActive(20);//最大连接池数量
+		dataSource.setMinIdle(0);//最小连接池数量
+		dataSource.setMaxWait(60000);//获取连接时最大等待时间,单位毫秒。
+		dataSource.setValidationQuery("SELECT 1 FROM DUAL");//用来检测连接是否有效的sql
+		dataSource.setTestOnBorrow(false);//申请连接时执行validationQuery检测连接是否有效
+		dataSource.setTestWhileIdle(true);//建议配置为true,不影响性能,并且保证安全性。
+		dataSource.setPoolPreparedStatements(false);//是否缓存preparedStatement,也就是PSCache
+		dataSource.setDefaultAutoCommit(true);
+		return dataSource;
+	}*/
+
+	/**
+	 * 查询结果集
+	 *
+	 * @param sql
+	 *            查询语句
+	 */
+	public int getCount(String sql, Object...args) {
+		SqlRowSet rowSet = jdbcTemplate.queryForRowSet(sql, args);
+		if (rowSet.next()) {
+			return rowSet.getInt(1);
+		}
+		return 0;
+	}
+
+	public void execute(List<String> sqls) {
+		if (sqls.size() > 0) {
+			StringBuffer sb = new StringBuffer("begin ");
+			for (String sql : sqls) {
+				sb.append("execute immediate '").append(sql.replace("'", "''")).append("';");
+			}
+			sb.append("end;");
+			jdbcTemplate.execute(sb.toString());
+		}
+	}
+
+	public void execute(String sql) {
+		jdbcTemplate.execute(sql);
+	}
+
+	public String callProcedure(final String procedureName, final Object...args) {
+		try {
+			return jdbcTemplate.execute(new CallableStatementCreator() {
+
+				@Override
+				public CallableStatement createCallableStatement(Connection connection) throws SQLException {
+					StringBuffer storedProcName = new StringBuffer("{call ");
+					int i = 0;
+					storedProcName.append(procedureName + "(");
+					for (i = 0; i < args.length; i++) {
+						if (storedProcName.toString().contains("?")) {
+							storedProcName.append(",");
+						}
+						storedProcName.append("?");
+					}
+					if (storedProcName.toString().contains("?")) {
+						storedProcName.append(",");
+					}
+					storedProcName.append("?");
+					storedProcName.append(")}");
+					CallableStatement cs = connection.prepareCall(storedProcName.toString());
+					for (i = 0; i < args.length; i++) {
+						cs.setObject(i + 1, args[i]);
+					}
+					cs.registerOutParameter(args.length + 1, java.sql.Types.VARCHAR);
+					return cs;
+				}
+			}, new CallableStatementCallback<String>() {
+				@Nullable
+				@Override
+				public String doInCallableStatement(CallableStatement cs) throws SQLException, DataAccessException {
+					cs.execute();
+					return cs.getString(args.length + 1);
+				}
+			});
+		}catch (Exception e){
+			throw new RuntimeException(e.getMessage());
+		}
+	}
+
+	public synchronized String sGetMaxNumber(String myTable, int thisType) {
+		return callProcedure("Sp_GetMaxNumber", new Object[] { myTable, thisType });
+	}
+
+	public int getSeq(String seq) {
+		SqlRowSet rowSet = jdbcTemplate.queryForRowSet("select " + seq + ".nextval from dual");
+		if (rowSet.next()) {
+			return rowSet.getInt(1);
+		}
+		return 0;
+	}
+
+	public Object[] getFieldsDataByCondition(String table,String[] fields, String condition) {
+		StringBuffer sql = new StringBuffer("select ");
+		sql.append(BaseUtil.parseArray2Str(fields, ","));
+		sql.append(" from " + table + " where " + condition);
+		List<Map<String, Object>> list = jdbcTemplate.queryForList(sql.toString());
+		Iterator<Map<String, Object>> iter = list.iterator();
+		int length = fields.length;
+		Object[] results = new Object[length];
+		Object value = null;
+		if (iter.hasNext()) {
+			Map<String, Object> m = iter.next();
+			for (int i = 0; i < length; i++) {
+				String upperField = fields[i].toUpperCase();
+				if (upperField.indexOf(" AS ") > 0) {
+					upperField = upperField.split(" AS ")[1].trim();
+				}
+				value = m.get(upperField);
+				if (value != null && value.getClass().getSimpleName().toUpperCase().equals("TIMESTAMP")) {
+					Timestamp time = (Timestamp) value;
+					try {
+						value = BaseUtil.parseDateToString(new Date(time.getTime()), "yyyy-MM-dd HH:mm:ss");
+					} catch (Exception e) {
+						e.printStackTrace();
+					}
+				}
+				results[i] = value;
+			}
+			return results;
+		}
+		return null;
+	}
+
+	/**
+	 * 一个字段,多条结果
+	 *
+	 * @param tableName
+	 *            对应要查询的表
+	 * @param field
+	 *            要查询的字段
+	 * @param condition
+	 *            查询条件
+	 * @return field对应的数据
+	 */
+	public List<Object> getFieldDatasByCondition(String tableName, String field, String condition) {
+		StringBuffer sb = new StringBuffer("SELECT ");
+		sb.append(field);
+		sb.append(" FROM ");
+		sb.append(tableName);
+		sb.append(((condition == null || "".equals(condition)) ? "" : (" WHERE " + condition)));
+		SqlRowSet srs = jdbcTemplate.queryForRowSet(sb.toString());
+		List<Object> list = new ArrayList<Object>();
+		while (srs.next()) {
+			list.add(srs.getObject(1));
+		}
+		return list;
+	}
+
+	/**
+	 * 一个字段,一条结果
+	 *
+	 * @param tableName
+	 *            对应要查询的表
+	 * @param field
+	 *            要查询的字段
+	 * @param condition
+	 *            查询条件
+	 * @return field对应的数据
+	 */
+	public Object getFieldDataByCondition(String tableName, String field, String condition) {
+		StringBuffer sql = new StringBuffer("SELECT ");
+		sql.append(field);
+		sql.append(" FROM ");
+		sql.append(tableName);
+		sql.append(" WHERE ");
+		sql.append(condition);
+		SqlRowSet srs = jdbcTemplate.queryForRowSet(sql.toString());
+		if (srs.next()) {
+			return srs.getObject(1);
+		} else {
+			return null;
+		}
+	}
+
+	/**
+	 * 多个字段,多条结果
+	 *
+	 * @param tableName
+	 *            对应要查询的表
+	 * @param fields
+	 *            要查询的字段集合
+	 * @param condition
+	 *            查询条件
+	 * @return fields对应的数据
+	 */
+	public List<Object[]> getFieldsDatasByCondition(String tableName, String[] fields, String condition) {
+		StringBuffer sql = new StringBuffer("SELECT ");
+		sql.append(BaseUtil.parseArray2Str(fields, ","));
+		sql.append(" FROM ");
+		sql.append(tableName);
+		sql.append(" WHERE ");
+		sql.append(condition);
+		List<Map<String, Object>> list = jdbcTemplate.queryForList(sql.toString());
+		Iterator<Map<String, Object>> iter = list.iterator();
+		List<Object[]> datas = new ArrayList<Object[]>();
+		Object value = null;
+		Map<String, Object> m = null;
+		Object[] results = null;
+		int length = fields.length;
+		while (iter.hasNext()) {
+			results = new Object[length];
+			m = iter.next();
+			for (int i = 0; i < length; i++) {
+				value = m.get(fields[i].toUpperCase());
+				if (value != null && value.getClass().getSimpleName().toUpperCase().equals("TIMESTAMP")) {
+					Timestamp time = (Timestamp) value;
+					try {
+						value = BaseUtil.parseDateToString(new Date(time.getTime()), "yyyy-MM-dd HH:mm:ss");
+					} catch (Exception e) {
+						e.printStackTrace();
+					}
+				}
+				results[i] = value;
+			}
+			datas.add(results);
+		}
+		return datas;
+	}
+
+	public synchronized boolean execute(String sql, Object... objs) {
+		try {
+			jdbcTemplate.update(sql, objs);
+			return true;
+		} catch (Exception e) {
+			BaseUtil.showError(e.getMessage());
+			return false;
+		}
+	}
+
+	public boolean isDBSetting(String caller, String code) {
+		Integer i = jdbcTemplate.queryForObject("select count(1) from configs where caller='" + caller + "' and code='" + code + "'",
+				Integer.class);
+		if (i >0) {
+			return true;
+		} else
+			return false;
+	}
+
+	public JdbcTemplate getJdbcTemplate() {
+		return jdbcTemplate;
+	}
+
+	public boolean isProdIn(String caller) {
+		int count = getCount("select count(1) from documentsetup where ds_table='" + caller + "' and ds_inorout in ('IN','-OUT')");
+		if (count > 0) {
+			return true;
+		}else return false;
+	}
+
+	public boolean isDBSetting(String inOverNow) {
+		return isDBSetting("sys", inOverNow);
+	}
+
+	/**
+	 * 查询结果集
+	 *
+	 * @param sql
+	 *            查询语句
+	 * @param arg
+	 *            参数
+	 */
+	public SqlRowList queryForRowSet(String sql, Object arg) {
+		SqlRowList rs = new SqlRowList();
+		rs.setResultList(getJdbcTemplate().queryForList(sql, arg));
+		return rs;
+	}
+
+
+	/**
+	 * 查询结果集
+	 *
+	 * @param sql
+	 *            查询语句
+	 */
+	public SqlRowList queryForRowSet(String sql) {
+		SqlRowList rs = new SqlRowList();
+		rs.setResultList(getJdbcTemplate().queryForList(sql));
+		return rs;
+	}
+
+	public Object getBatchcode(String caller) {
+		if (isProdIn(caller)) {
+			return callProcedure("utl_rseq", "BatchCode", "/yyMMdd/5");
+		}
+		return null;
+
+	}
+
+	public String getDBSetting(String caller, String code) {
+		Object data = getFieldDataByCondition("configs", "data", "caller='" + caller + "' and code='" + code + "'");
+		if (data != null) {
+			return data.toString();
+		}
+		return null;
+	}
+
+	public String getDBSetting(String defaultCurrency) {
+		return getDBSetting("sys", defaultCurrency);
+	}
+
+	public boolean checkIf(String tableName, String condition) {
+		int i = 0;
+		StringBuffer sql = new StringBuffer("SELECT count(1) FROM ");
+		sql.append(tableName);
+		sql.append(" WHERE ");
+		sql.append(condition);
+		SqlRowList srs = queryForRowSet(sql.toString());
+		if (srs.next()) {
+			 i = srs.getInt(1);
+		}
+		if (i > 0)return true;
+		else return false;
+	}
+
+	public double getSummaryByField(String summaryField, String tablename, String condition) {
+		SqlRowList rs = queryForRowSet("SELECT sum(nvl(" + summaryField + ",0)) FROM " + tablename + " WHERE " + condition);
+		if (rs.next()) {
+			return rs.getGeneralDouble(1, 6);
+		}
+		return 0.0;
+	}
+
+	/**
+	 * 根据物料中的有效期天数更新有效期止
+	 */
+	public void getEndDate(String caller, Object id) {
+		SqlRowList rs = queryForRowSet("select ds_inorout from DOCUMENTSETUP where ds_table=?", caller);
+		if (rs.next()) {
+			String Code = rs.getObject("ds_inorout").toString();
+			if (Code.equals("IN") || Code.equals("-OUT")) {
+				execute("update prodiodetail set pd_replydate=pd_prodmadedate + (select nvl(pr_validdays,0) from product where  pd_prodcode=pr_code) where pd_piid=? and pd_prodmadedate is not null",
+						id);
+			}
+		}
+	}
+
+	/**
+	 * 查询结果集
+	 *
+	 * @param sql
+	 *            查询语句
+	 * @param args
+	 *            参数
+	 */
+	public SqlRowList queryForRowSet(String sql, Object... args) {
+		SqlRowList rs = new SqlRowList();
+		rs.setResultList(getJdbcTemplate().queryForList(sql, args));
+		return rs;
+	}
+
+	public void updateByCondition(String tableName, String update, String condition) {
+		StringBuffer sb = new StringBuffer("UPDATE ");
+		sb.append(tableName);
+		sb.append(" SET ");
+		sb.append(update);
+		sb.append(" WHERE ");
+		sb.append(condition);
+		execute(sb.toString());
+	}
+
+		/**
+		 * 调用存储过程 无返回值
+		 *
+		 * @param procedureName
+		 *            存储过程名称
+		 * @param args
+		 *            参数
+		 */
+		public void procedure(String procedureName, Object[] args) {
+			StringBuffer sql = new StringBuffer("{call ").append(procedureName).append("(");
+			for (int i = 0; i < args.length; i++) {
+				if (i > 0) {
+					sql.append(",");
+				}
+				sql.append("?");
+			}
+			sql.append(")}");
+			getJdbcTemplate().update(sql.toString(), args);
+		}
+
+	public boolean isOut(String caller) {
+		int count = getCount("select count(1) from documentsetup where ds_table='" + caller + "' and ds_inorout in ('-IN','OUT')");
+		if (count > 0) {
+			return true;
+		}else return false;
+	}
+
+	/**
+	 * 修改单据为已审核(包括审核人+审核日期)
+	 *
+	 * @param tableName
+	 * @param condition
+	 * @param statusField
+	 * @param statusCodeField
+	 * @param auditdateField
+	 * @param auditorField
+	 */
+	public void audit(String tableName, String condition, String statusField, String statusCodeField, String auditdateField,
+					  String auditorField, String name) {
+		updateByCondition(tableName, statusCodeField + "='AUDITED'," + statusField + "='已审核',"
+				+ auditdateField + "=" + DateUtil.parseDateToOracleString(Constant.YMD_HMS, new Date()) + "," + auditorField + "='"
+				+name+"'", condition);
+	}
+
+	public int getSeqId(String seq) {
+		try {
+		/*	if ("true".equals(BaseUtil.getXmlSetting("group"))) {
+				boolean isBase = checkIf("basedataset", "upper(bds_sequence)=upper('" + seq + "') and nvl(bds_editable,0)=1");
+				if (isBase) {
+					// 集团版基础资料(客户,供应商...)统一到资料中心取号
+					String dataCenter = BaseUtil.getXmlSetting("dataSob");
+					seq = dataCenter + "." + seq;
+				}
+			}*/
+			String sql = "select " + seq + ".nextval from dual";
+			SqlRowList rs = queryForRowSet(sql);
+			if (rs.next()) {
+				return rs.getInt(1);
+			} else {// 如果不存在就创建序列
+				int count = getCountByCondition("user_sequences", "Sequence_Name='" + seq.toUpperCase() + "'");
+				if (count == 0)
+					getJdbcTemplate().execute(CREATE_SEQ.replace("?", seq));
+				return getSeqId(seq);
+			}
+		} catch (Exception e) {
+			int count = getCountByCondition("user_sequences", "Sequence_Name='" + seq.toUpperCase() + "'");
+			if (count == 0)
+				getJdbcTemplate().execute(CREATE_SEQ.replace("?", seq));
+			return getSeqId(seq);
+		}
+	}
+
+	/**
+	 * @param tableName
+	 *            对应要查询的表
+	 * @param condition
+	 *            查询条件
+	 * @return Count
+	 */
+	public int getCountByCondition(String tableName, String condition) {
+		StringBuffer sql = new StringBuffer("SELECT count(1) FROM ");
+		sql.append(tableName);
+		sql.append(" WHERE ");
+		sql.append(condition);
+		SqlRowList srs = queryForRowSet(sql.toString());
+		if (srs.next()) {
+			return srs.getInt(1);
+		} else {
+			try {
+				throw new Exception("Condition:" + condition + " is wrong!");
+			} catch (Exception e) {
+				return -1;
+			}
+		}
+	}
+}

+ 31 - 0
eis-wms/src/main/java/com/uas/eiswms/dao/ProdInOutDao.java

@@ -0,0 +1,31 @@
+package com.uas.eiswms.dao;
+
+import com.uas.eiswms.model.SqlRowList;
+import com.uas.eiswms.service.impl.ProdIOServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class ProdInOutDao extends BaseDao{
+    @Autowired
+    private ProdIOServiceImpl prodIOService;
+
+    public String turnProdIO(int id) {
+        String dets = null;
+        SqlRowList rs = queryForRowSet("select pi_relativeplace,pi_class from prodinout where pi_id=?", id);
+        if (rs.next()) {
+            SqlRowList rs1 = queryForRowSet(
+                    "select pi_id from prodinout where pi_inoutno=? and pi_class in ('拨入单','销售拨入单') and nvl(PI_UNAUTOPOSTIN,0)=0",
+                    rs.getString("pi_relativeplace"));
+            if (rs1.next()) {
+                if (dets == null) {
+                    if ("拨出单".equals(rs.getString("pi_class"))) {
+                        prodIOService.post(rs1.getInt("pi_id"), "ProdInOut!AppropriationIn");
+                    }
+                }
+            }
+        }
+        return dets;
+    }
+
+}

+ 36 - 0
eis-wms/src/main/java/com/uas/eiswms/dao/RowConvert.java

@@ -0,0 +1,36 @@
+package com.uas.eiswms.dao;
+
+import org.springframework.util.NumberUtils;
+
+public class RowConvert<T>{
+
+	private Class<T> requiredType;
+
+	public RowConvert(Class<T> requiredType) {
+		this.requiredType = requiredType;
+	}
+
+	@SuppressWarnings("unchecked")
+	protected Object convertValueToRequiredType(Object value, @SuppressWarnings("rawtypes") Class requiredType) {
+		if (String.class.equals(requiredType)) {
+			return value.toString();
+		}
+		if (Number.class.isAssignableFrom(requiredType)) {
+			if (value instanceof Number) {
+				return NumberUtils.convertNumberToTargetClass((Number) value, requiredType);
+			}
+			return NumberUtils.parseNumber(value.toString(), requiredType);
+		}
+		throw new IllegalArgumentException(
+				"Value [" + value + "] is of type [" + value.getClass().getName() +
+						"] and cannot be converted to required type [" + requiredType.getName() + "]");
+	}
+
+	@SuppressWarnings("unchecked")
+	public T convert(Object value) {
+		if (value != null && this.requiredType != null && !this.requiredType.isInstance(value)) {
+			return (T) convertValueToRequiredType(value, this.requiredType);
+		}
+		return (T) value;
+	}
+}

+ 438 - 0
eis-wms/src/main/java/com/uas/eiswms/model/SqlRowList.java

@@ -0,0 +1,438 @@
+package com.uas.eiswms.model;
+
+import java.math.BigDecimal;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.uas.eiswms.dao.RowConvert;
+import com.uas.eiswms.util.Constant;
+import com.uas.eiswms.util.DateUtil;
+import com.uas.eiswms.util.NumberUtil;
+import net.sf.json.JSONObject;
+
+
+/**
+ * org.springframework.jdbc.support.rowset.SqlRowSet有jdk版本问题
+ * 
+ * @author yingp 2013-1-10 11:50:08
+ */
+public class SqlRowList {
+
+	private List<Map<String, Object>> resultList;// 结果集
+	private Iterator<Map<String, Object>> iterator;
+	private Map<String, Object> currentMap;// 当前Map
+	private int currentIndex = -1;// 当前index,从0开始
+	private List<String> keys;// 字段名集
+
+	public SqlRowList() {
+		this.resultList = new ArrayList<Map<String, Object>>();
+	}
+
+	public List<Map<String, Object>> getResultList() {
+		return resultList;
+	}
+
+	public int size() {
+		return getResultList().size();
+	}
+
+	public void setResultList(List<Map<String, Object>> resultList) {
+		this.resultList = resultList;
+	}
+
+	public Map<String, Object> getCurrentMap() {
+		return currentMap;
+	}
+
+	public void setCurrentMap(Map<String, Object> currentMap) {
+		this.currentMap = currentMap;
+	}
+
+	public int getCurrentIndex() {
+		return currentIndex;
+	}
+
+	public void setCurrentIndex(int currentIndex) {
+		this.currentIndex = currentIndex;
+	}
+
+	public List<String> getKeys() {
+		if (this.keys == null) {
+			this.keys = new ArrayList<String>();
+			if (this.resultList != null) {
+				Iterator<Map<String, Object>> iterator = resultList.iterator();
+				if (iterator.hasNext()) {
+					Map<String, Object> map = iterator.next();
+					Iterator<String> fields = map.keySet().iterator();
+					while (fields.hasNext()) {
+						this.keys.add(fields.next());
+					}
+				}
+			}
+		}
+		return keys;
+	}
+
+	public void setKeys(List<String> keys) {
+		this.keys = keys;
+	}
+
+	/**
+	 * 取ResultSet的第index条Map
+	 * 
+	 * @param index
+	 * @return
+	 */
+	public Map<String, Object> getAt(int index) {
+		if (this.resultList != null) {
+			Iterator<Map<String, Object>> iterator = resultList.iterator();
+			Map<String, Object> map = null;
+			int idx = 0;
+			while (iterator.hasNext() && (map = iterator.next()) != null) {
+				if (index == idx)
+					return map;
+				idx++;
+			}
+		}
+		return null;
+	}
+
+	public <T> List<T> queryForList(String field, Class<T> requiredType) {
+		if (this.resultList != null) {
+			Iterator<Map<String, Object>> iterator = resultList.iterator();
+			Map<String, Object> map = null;
+			List<T> list = new ArrayList<T>();
+			RowConvert<T> convert = new RowConvert<T>(requiredType);
+			field = field.toUpperCase();
+			while (iterator.hasNext() && (map = iterator.next()) != null) {
+				Object result = map.get(field);
+				if (result != null) {
+					list.add(convert.convert(result));
+				}
+			}
+			return list;
+		}
+		return null;
+	}
+
+	public <T> Set<T> queryForSet(String field, Class<T> requiredType) {
+		if (this.resultList != null) {
+			Iterator<Map<String, Object>> iterator = resultList.iterator();
+			Map<String, Object> map = null;
+			Set<T> set = new java.util.HashSet<T>();
+			RowConvert<T> convert = new RowConvert<T>(requiredType);
+			field = field.toUpperCase();
+			while (iterator.hasNext() && (map = iterator.next()) != null) {
+				Object result = map.get(field);
+				if (result != null) {
+					set.add(convert.convert(result));
+				}
+			}
+			return set;
+		}
+		return null;
+	}
+
+	public boolean hasNext() {
+		if (this.resultList != null) {
+			if (this.iterator == null) {
+				this.iterator = resultList.iterator();
+			}
+			if (this.iterator.hasNext()) {
+				return true;
+			}
+		}
+		return false;
+	}
+
+	public boolean next(int count) {
+		for (int i = 0; i < count; i++) {
+			if (!next())
+				return false;
+		}
+		return true;
+	}
+
+	public boolean next() {
+		if (this.resultList != null) {
+			if (this.iterator == null) {
+				this.iterator = resultList.iterator();
+				this.currentIndex = -1;
+			}
+			if (this.iterator.hasNext()) {
+				this.currentMap = iterator.next();
+				this.currentIndex += 1;
+				if (this.keys == null) {
+					this.keys = new ArrayList<String>();
+					Iterator<String> fields = currentMap.keySet().iterator();
+					while (fields.hasNext()) {
+						this.keys.add(fields.next());
+					}
+				}
+				return true;
+			}
+		}
+		return false;
+	}
+
+	public int getInt(int index) {
+		Object obj = getObject(index);
+		return obj == null ? -1 : Integer.parseInt(obj.toString());
+	}
+
+	public int getInt(String field) {
+		Object obj = getObject(field);
+		return obj == null ? -1 : Integer.parseInt(obj.toString());
+	}
+
+	public int getGeneralInt(int index) {
+		Object obj = getObject(index);
+		return obj == null ? 0 : Integer.parseInt(obj.toString());
+	}
+
+	public int getGeneralInt(String field) {
+		Object obj = getObject(field);
+		return obj == null ? 0 : Integer.parseInt(obj.toString());
+	}
+
+	public float getFloat(int index) {
+		Object obj = getObject(index);
+		return obj == null ? -1 : Float.parseFloat(obj.toString());
+	}
+
+	public float getFloat(String field) {
+		Object obj = getObject(field);
+		return obj == null ? -1 : Float.parseFloat(obj.toString());
+	}
+
+	public float getGeneralFloat(int index) {
+		Object obj = getObject(index);
+		return obj == null ? 0 : Float.parseFloat(obj.toString());
+	}
+
+	public float getGeneralFloat(String field) {
+		Object obj = getObject(field);
+		return obj == null ? 0 : Float.parseFloat(obj.toString());
+	}
+
+	public double getDouble(int index) {
+		Object obj = getObject(index);
+		return obj == null ? -1 : Double.parseDouble(obj.toString());
+	}
+
+	public double getDouble(String field) {
+		Object obj = getObject(field);
+		return obj == null ? -1 : Double.parseDouble(obj.toString());
+	}
+
+	public BigDecimal getBigDecimal(int index) {
+		Object obj = getObject(index);
+		return obj == null ? null : BigDecimal.valueOf(Double.parseDouble(obj.toString()));
+	}
+
+	public BigDecimal getBigDecimal(String field) {
+		Object obj = getObject(field);
+		return obj == null ? null : BigDecimal.valueOf(Double.parseDouble(obj.toString()));
+	}
+
+	public double getGeneralDouble(int index) {
+		Object obj = getObject(index);
+		return obj == null ? 0 : Double.parseDouble(obj.toString());
+	}
+
+	/**
+	 * @param index
+	 * @param sub
+	 *            保留小数位数
+	 * @return
+	 */
+	public double getGeneralDouble(int index, int sub) {
+		return NumberUtil.formatDouble(getGeneralDouble(index), sub);
+	}
+
+	public double getGeneralDouble(String field) {
+		Object obj = getObject(field);
+		return obj == null || String.valueOf(obj).trim().equals("") ? 0 : Double.parseDouble(String.valueOf(obj).trim());
+	}
+
+	/**
+	 * @param field
+	 * @param sub
+	 *            保留小数位数
+	 * @return
+	 */
+	public double getGeneralDouble(String field, int sub) {
+		return NumberUtil.formatDouble(getGeneralDouble(field), sub);
+	}
+
+	public BigDecimal getGeneralBigDecimal(int index) {
+		Object obj = getObject(index);
+		return obj == null ? new BigDecimal(0) : BigDecimal.valueOf(Double.parseDouble(obj.toString()));
+	}
+
+	public BigDecimal getGeneralBigDecimal(String field) {
+		Object obj = getObject(field);
+		return obj == null ? new BigDecimal(0) : BigDecimal.valueOf(Double.parseDouble(obj.toString()));
+	}
+
+	public long getLong(int index) {
+		Object obj = getObject(index);
+		return obj == null ? -1 : Long.parseLong(obj.toString());
+	}
+
+	public long getLong(String field) {
+		Object obj = getObject(field);
+		return obj == null ? -1 : Long.parseLong(obj.toString());
+	}
+
+	public long getGeneralLong(int index) {
+		Object obj = getObject(index);
+		return obj == null ? 0 : Long.parseLong(obj.toString());
+	}
+
+	public long getGeneralLong(String field) {
+		Object obj = getObject(field);
+		return obj == null ? 0 : Long.parseLong(obj.toString());
+	}
+
+	public String getString(int index) {
+		Object obj = getObject(index);
+		return obj == null ? null : obj.toString();
+	}
+
+	public String getString(String field) {
+		Object obj = getObject(field);
+		return obj == null ? null : obj.toString();
+	}
+
+	public String getGeneralString(int index) {
+		Object obj = getObject(index);
+		return obj == null ? "" : obj.toString();
+	}
+
+	public String getGeneralString(String field) {
+		Object obj = getObject(field);
+		return obj == null ? "" : obj.toString();
+	}
+
+	public Object getObject(int index) {
+		if (this.iterator == null || this.currentMap == null || this.keys == null || index <= 0 || index > this.keys.size()) {
+			return null;
+		}
+		return this.currentMap.get(this.keys.get(index - 1));
+	}
+
+	public Object getObject(String field) {
+		if (this.iterator == null || this.currentMap == null) {
+			return null;
+		}
+		return this.currentMap.get(field.toUpperCase());
+	}
+
+	/**
+	 * currentMap的JSON格式
+	 */
+	public JSONObject getJSONObject() {
+		if (this.iterator == null || this.currentMap == null) {
+			return null;
+		}
+		JSONObject json = new JSONObject();
+		Object value = null;
+		for (String k : this.keys) {
+			value = parseValue(this.getObject(k));
+			json.put(k, value);
+		}
+		return json;
+	}
+
+	public static Object parseValue(Object value) {
+		if (value != null) {
+			// 以字符串格式表示时间
+			if ("TIMESTAMP".equals(value.getClass().getSimpleName().toUpperCase())) {
+				Timestamp time = (Timestamp) value;
+				value = DateUtil.parseDateToString(new Date(time.getTime()), Constant.YMD_HMS);
+			}
+			// 科学计数法改为js处理
+		}
+		return value;
+	}
+
+	/**
+	 * currentMap的JSONString格式
+	 */
+	public String getJSON() {
+		if (this.iterator == null || this.currentMap == null) {
+			return null;
+		}
+		return getJSONObject().toString();
+	}
+
+	public Date getDate(int index) {
+		Object obj = getObject(index);
+		return obj == null ? null : (Date) obj;
+	}
+
+	public Date getDate(String field) {
+		Object obj = getObject(field);
+		return obj == null ? null : (Date) obj;
+	}
+
+	public Timestamp getTimestamp(int index) {
+		Object obj = getObject(index);
+		return obj == null ? null : (Timestamp) obj;
+	}
+
+	public Timestamp getTimestamp(String field) {
+		Object obj = getObject(field);
+		return obj == null ? null : (Timestamp) obj;
+	}
+
+	public String getGeneralTimestamp(int index, String format) {
+		Timestamp time = getTimestamp(index);
+		if (time != null)
+			return DateUtil.parseDateToString(new Date(time.getTime()), format);
+		return "";
+	}
+
+	public String getGeneralTimestamp(int index) {
+		return getGeneralTimestamp(index, Constant.YMD_HMS);
+	}
+
+	public String getGeneralTimestamp(String field, String format) {
+		Timestamp time = getTimestamp(field);
+		if (time != null)
+			return DateUtil.parseDateToString(new Date(time.getTime()), format);
+		return "";
+	}
+
+	public String getGeneralTimestamp(String field) {
+		return getGeneralTimestamp(field, Constant.YMD_HMS);
+	}
+
+	public double getSummary(String field) {
+		if (hasNext()) {
+			Iterator<Map<String, Object>> iterator = resultList.iterator();
+			Map<String, Object> map = null;
+			double sum = 0;
+			Object obj = null;
+			while ((map = iterator.next()) != null) {
+				obj = map.get(field.toUpperCase());
+				sum += obj == null ? 0 : Double.parseDouble(obj.toString());
+			}
+			return sum;
+		}
+		return 0;
+	}
+
+	public double getSummary(int index) {
+		if (index <= 0 || index > this.getKeys().size()) {
+			return 0;
+		}
+		return getSummary(this.keys.get(index - 1));
+	}
+}

+ 21 - 0
eis-wms/src/main/java/com/uas/eiswms/service/BasicDataService.java

@@ -0,0 +1,21 @@
+
+package com.uas.eiswms.service;
+
+import java.util.Map;
+
+
+/**
+ * @ClassName BasicDataService
+ * @Description 基础资料接口
+ * @Author jinxing.chen
+ * @Date 2018/8/22 18:53
+ * @Version 1.o
+ */
+
+public interface BasicDataService {
+    Map<String,Object> postProductToXKN(String formDate, String userName, String passWord, String token);
+    Map<String,Object> postCustomerToXKN(String formDate, String userName, String passWord, String token);
+    Map<String,Object> postVendorToXKN(String formDate, String userName, String passWord, String token);
+    Map<String,Object> postWareHouseToXKN(String formDate, String userName, String passWord, String token);
+}
+

+ 89 - 0
eis-wms/src/main/java/com/uas/eiswms/service/LoginService.java

@@ -0,0 +1,89 @@
+package com.uas.eiswms.service;
+
+import com.uas.eiswms.dao.BaseDao;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.DigestUtils;
+import org.springframework.util.StringUtils;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.http.HttpServletRequest;
+import java.nio.charset.Charset;
+import java.util.*;
+
+@Service
+public class LoginService {
+
+    @Autowired
+    private BaseDao baseDao;
+
+    public Map<String, Object> login(String userName, String passWord) {
+        Map<String, Object> resultMap = new HashMap<String, Object>();
+        if (StringUtils.isEmpty(userName)) {
+            resultMap.put("code", "0001");
+            resultMap.put("resMsg", "用户名不能为空");
+            return resultMap;
+        }
+        if (StringUtils.isEmpty(passWord)) {
+            resultMap.put("code", "0001");
+            resultMap.put("resMsg", "密码不能为空");
+            return resultMap;
+        }
+        int count = baseDao.getCount("select count(1) from UserDataInfo where udi_username='" + userName + "' and udi_password='" + passWord + "'");
+        if (count < 1) {
+            resultMap.put("code", "0001");
+            resultMap.put("resMsg", "用户名或密码不正确");
+            return resultMap;
+        }
+        String token = UUID.randomUUID().toString().replace("-", "");
+        baseDao.updateByCondition("UserDataInfo", "udi_token = '" + token + "',udi_updatetime = sysdate", "udi_username = '" + userName + "' and udi_password= '" + passWord + "'");
+        resultMap.put("token", token);
+        resultMap.put("code", "0000");
+        resultMap.put("resMsg", "请求成功");
+        return resultMap;
+    }
+
+    public String checkSign(Map<String, Object> paramsMap, String sign) {
+        String token = paramsMap.get("token").toString();
+        int count = baseDao.getCount("select count(1) from UserDataInfo where udi_token='" + token + "'");
+        if (count < 1) {
+            //token 不正确
+            return "01";
+        }
+        int isExpireTime = baseDao.getCount("select count(1) from UserDataInfo where udi_token='" + token + "' and (sysdate-udi_updatetime)*24 < 1");
+        if (isExpireTime < 1) {
+            //token已经失效
+            return "02";
+        }
+        Set<String> keysSet = paramsMap.keySet();
+        Object[] keys = keysSet.toArray();
+        Arrays.sort(keys);
+        StringBuffer temp = new StringBuffer();
+        boolean first = true;
+        for (Object key : keys) {
+            if (first) {
+                first = false;
+            } else {
+                temp.append("&");
+            }
+            temp.append(key).append("=");
+            Object value = paramsMap.get(key);
+            String valueString = "";
+            if (null != value) {
+                valueString = String.valueOf(value);
+                temp.append(valueString);
+
+            }
+        }
+        //若字符中存在中文,则一定要指定编码类型
+        String signStr = DigestUtils.md5DigestAsHex(temp.toString().getBytes(Charset.forName("UTF-8"))).toUpperCase();
+        System.out.println("签名----》" + signStr);
+        //MD5Util.getMD5(temp.toString()).toUpperCase();
+        if (!signStr.equals(sign)) {
+            //签名不正确
+            return "03";
+        }
+        //签名正确
+        return "00";
+    }
+}

+ 11 - 0
eis-wms/src/main/java/com/uas/eiswms/service/ProdIOService.java

@@ -0,0 +1,11 @@
+package com.uas.eiswms.service;
+
+import java.util.Map;
+
+public interface ProdIOService {
+    String prePost(String data);
+
+    Map<String, Object> getBill(String pi_class, String lastUpdateTime, String condition);
+
+    Map<String,Object> test(String pi_class, String lastUpdateTime, String condition, String master);
+}

+ 280 - 0
eis-wms/src/main/java/com/uas/eiswms/service/SaleClashService.java

@@ -0,0 +1,280 @@
+package com.uas.eiswms.service;
+
+import com.uas.eiswms.dao.BaseDao;
+import com.uas.eiswms.model.SqlRowList;
+import com.uas.eiswms.util.BaseUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service("saleClashService")
+public class SaleClashService {
+
+    @Autowired
+    private BaseDao baseDao;
+
+    public void createSaleClash(Integer fromid, String fromcaller) {
+        String SqlStr = "", clashcode = "", canclash = "", othercondition = "";
+        double thisqty = 0, needclashqty = 0, clashedqty = 0;
+        int csid = 0, detno = 0;
+        String prodcode = "", ordercode = "", fromcode = "", fromwhere = "";
+        String clashoption = "", saleclashkind = "";
+        SqlRowList rs0;
+        if (fromcaller.equalsIgnoreCase("ProdInOut")) {
+            fromwhere = baseDao.getFieldDataByCondition("ProdInOut", "pi_class", "pi_id=" + fromid).toString();
+        } else if (fromcaller.equalsIgnoreCase("Sale") || fromcaller.equals("销售单")) {
+            fromwhere = "销售单";
+        } else {
+            return;
+        }
+        // 先更新呆冲销的明细已冲销数为0
+        SqlStr = "update saleforecastDetail set sd_stepqty=0 where sd_id in (select sd_id from saleforecastDetail ,saleforecast   where sd_sfid=sf_id and sf_statuscode='AUDITED' and NVL(sd_statuscode,' ')<>'FINISH' and sd_qty>0)  ";
+        baseDao.execute(SqlStr);
+        // 获取冲销来源单据
+        if (fromwhere.equals("出货单")) {
+            SqlStr = "select pd_id as sourcedetid,pd_inoutno as fromcode,pd_outqty+nvl(pd_beipinoutqty,0) as qty,pd_prodcode as prodcode,pd_ordercode as ordercode,pd_pdno as pdno,sd_forecastcode as sfcode,sd_forecastdetno as sfdetno from Prodiodetail left join saledetail on sd_code=pd_ordercode and sd_detno=pd_orderdetno where pd_piid='"
+                    + fromid + "' ";
+        } else if (fromwhere.equals("销售单")) {
+            SqlStr = "select sd_id as sourcedetid,sd_code as fromcode,sd_qty as qty,sd_prodcode as prodcode,sa_code as ordercode,sd_detno as pdno,sd_forecastcode as sfcode,sd_forecastdetno as sfdetno,sa_custcode,sa_sellercode from saledetail,sale where sa_id=sd_said and sd_said='"
+                    + fromid + "' ";
+        } else if (fromwhere.equals("完工入库单") || fromwhere.equals("委外验收单") || fromwhere.equals("委外验退单")) {
+            SqlStr = "select pd_id as sourcedetid,pd_inoutno as fromcode,NVL(pd_inqty,0)+NVL(pd_outqty,0) as qty,pd_prodcode as prodcode,pd_ordercode as ordercode,pd_pdno as pdno,ma_salecode,ma_saledetno from Prodiodetail,warehouse,make,makekind where pd_piid='"
+                    + fromid
+                    + "' and pd_whcode=wh_code and NVL(wh_ifclash,0)<>0  and ma_code=pd_ordercode and ma_kind=mk_name and NVL(mk_clashsale,0)<>0 ";
+            // 判断是否存在需要完工入库冲销的预测
+            rs0 = baseDao.queryForRowSet("select sf_code from saleforecastkind where sf_clashoption='完工冲销' or sf_clashoption='FINISH' ");
+            if (!rs0.hasNext()) {
+                // 不需要完工冲销
+                return;
+            }
+        } else if (fromwhere.equals("销售拨出单")) {
+            SqlStr = "select pd_id as sourcedetid,pd_inoutno as fromcode,pd_outqty+nvl(pd_beipinoutqty,0) as qty,pd_prodcode as prodcode,pd_plancode as ordercode,pd_pdno as pdno,pd_plancode as sfcode,pd_forecastdetno as sfdetno from Prodiodetail where  pd_piid='"
+                    + fromid + "' and  NVL(pd_plancode,' ')<>' ' and pd_forecastdetno>0 ";
+        } else if (fromwhere.equals("其它出库单")) {
+            SqlStr = "select pd_id as sourcedetid,pd_inoutno as fromcode,pd_outqty+nvl(pd_beipinoutqty,0) as qty,pd_prodcode as prodcode,pd_plancode as ordercode,pd_pdno as pdno,pd_plancode as sfcode,pd_forecastdetno as sfdetno from Prodiodetail where  pd_piid='"
+                    + fromid + "' and  NVL(pd_plancode,' ')<>' ' and pd_forecastdetno>0 ";
+        } else {
+            return;
+        }
+        detno = 1;
+        SqlRowList rs = baseDao.queryForRowSet(SqlStr);
+        while (rs.next()) {
+            fromcode = rs.getString("fromcode");
+            clashoption = "";
+            saleclashkind = "";
+            othercondition = "";
+            clashedqty = 0;
+            needclashqty = rs.getDouble("qty");
+            prodcode = rs.getString("prodcode");
+            ordercode = rs.getString("ordercode");
+            // 判断此行记录是否需要冲销
+            canclash = "N";
+            if (fromwhere.equals("销售单") || fromwhere.equals("出货单")) {
+                if(fromwhere.equals("出货单") && baseDao.isDBSetting("ProdInOut!Sale", "clashSaleForecastByProduct")){
+                    saleclashkind="PRODUCT";
+                    clashoption = "SEND";
+                }else{
+                    SqlStr = "SELECT * from sale left join salekind on (sa_kind=sk_name or sa_kind=sk_code) where sa_code='" + ordercode + "' ";
+                    SqlRowList rs2 = baseDao.queryForRowSet(SqlStr);
+                    if (rs2.next()) {
+                        saleclashkind = rs2.getString("sk_clashfor");
+                        clashoption = rs2.getString("sk_clashoption");
+                        othercondition = rs2.getString("sk_clashkind");
+                    } else {
+                        // 未设置类型,不冲销
+                        continue;
+                    }
+                }
+            } else if (fromwhere.equals("完工入库单") || fromwhere.equals("委外验收单") || fromwhere.equals("委外验退单")) {
+                saleclashkind = "PRODUCT";
+                clashoption = "FINISH";
+            } else if (fromwhere.equals("销售拨出单") || fromwhere.equals("其它出库单")) {
+                saleclashkind = "单号冲销";
+                clashoption = "SEND";
+            }
+            if (saleclashkind == null || clashoption == null) {
+                // 未设置类型,不冲销
+                continue;
+            }
+            if (fromwhere.equals("销售单")) {
+                if (clashoption.equals("订单冲销") || clashoption.equalsIgnoreCase("SALE")) {
+                    canclash = "Y";
+                }
+            } else if (fromwhere.equals("出货单")) {
+                if (clashoption.equals("发货冲销") || clashoption.equalsIgnoreCase("SEND")) {
+                    canclash = "Y";
+                }
+            }
+            if (fromwhere.equals("完工入库单") || fromwhere.equals("委外验收单") || fromwhere.equals("委外验退单") || fromwhere.equals("销售拨出单")
+                    || fromwhere.equals("其它出库单")) {
+                canclash = "Y";
+            }
+            if (canclash.equals("N")) {
+                // 不冲销
+                continue;
+            }
+            SqlStr = "";
+            if (saleclashkind.equalsIgnoreCase("sale") || saleclashkind.equals("单号冲销")) {
+                SqlStr = "SELECT saleforecastDetail.*,saleforecast.* from saleforecastDetail left join saleforecast on sd_sfid=sf_id left join saleforecastkind on (saleforecast.sf_kind=saleforecastkind.sf_name or saleforecast.sf_kind=saleforecastkind.sf_code) where saleforecast.sf_code='"
+                        + rs.getString("sfcode") + "' and sd_detno=" + rs.getInt("sfdetno");
+            } else if (saleclashkind.equalsIgnoreCase("product") || saleclashkind.equals("料号冲销")) {
+                // 按物料号冲销
+                SqlStr = "SELECT saleforecastDetail.*,saleforecast.* from saleforecastDetail left join saleforecast on sd_sfid=sf_id left join saleforecastkind on (saleforecast.sf_kind=saleforecastkind.sf_name or saleforecast.sf_kind=saleforecastkind.sf_code) where sd_prodcode='"
+                        + prodcode + "' ";
+                if (fromwhere.equals("完工入库单") || fromwhere.equals("委外验收单")) {
+                    SqlStr = "SELECT case when saleforecast.sf_code='"
+                            + rs.getString("ma_salecode")
+                            + "' and sd_detno="
+                            + rs.getInt("ma_saledetno")
+                            + " then 1 else 2 end sortid,saleforecastDetail.*,saleforecast.* from saleforecastDetail left join saleforecast on sd_sfid=sf_id left join saleforecastkind on (saleforecast.sf_kind=saleforecastkind.sf_name or saleforecast.sf_kind=saleforecastkind.sf_code) where sd_prodcode='"
+                            + prodcode + "' ";
+                }
+                if (fromwhere.equals("销售单") && othercondition != null && othercondition.equals("客户匹配")) {
+                    SqlStr = SqlStr + " and (case when NVL(saleforecastDetail.sd_custcode,' ')<>' ' then saleforecastDetail.sd_custcode else sf_custcode end)='" + rs.getString("sa_custcode") + "' ";
+                } else if (fromwhere.equals("销售单") && othercondition != null && othercondition.equals("业务员")){
+                    SqlStr = SqlStr + " and (case when nvl(saleforecastDetail.sd_sellercode,' ')<>' ' then saleforecastDetail.sd_sellercode else sf_sellercode end)='"+ rs.getString("sa_sellercode")+"' ";
+                }
+            } else {
+                // 不冲销
+                continue;
+            }
+            if (clashoption.equals("订单冲销") || clashoption.equalsIgnoreCase("SALE")) {
+                SqlStr = SqlStr + " and sf_clashoption in ('SALE','订单冲销') ";
+            } else if (clashoption.equals("发货冲销") || clashoption.equalsIgnoreCase("SEND")) {
+                SqlStr = SqlStr + " and sf_clashoption in ('SEND','发货冲销') ";
+            } else if (clashoption.equals("完工冲销") || clashoption.equalsIgnoreCase("FINISH")) {
+                SqlStr = SqlStr + " and sf_clashoption in ('FINISH','完工冲销') ";
+            }
+            if (saleclashkind.equalsIgnoreCase("product") || saleclashkind.equals("料号冲销")) {
+                SqlStr = SqlStr + " and trunc(sd_enddate)>=trunc(sysdate) ";// 只冲销有效的预测,@update 20170224 截止日期等于今日的也可冲销,与存储过程中的计算一致
+            }
+            if (fromwhere.equals("委外验退单")) {
+                SqlStr = " SELECT saleforecastDetail.*,saleforecast.*,scd_id,NVL(scd_clashqty,0)scd_clashqty,NVL(scd_cancelqty,0)scd_cancelqty,scd_id from saleclashdetail left join saleclash on scd_scid=sc_id left join saleforecast on scd_ordercode=sf_code left join saleforecastdetail on sd_sfid=sf_id  where sc_source='委外验收单' and scd_fromcode='"
+                        + rs.getString("ordercode")
+                        + "' and scd_clashqty>0 and scd_clashqty-NVL(scd_cancelqty,0)>0 and sc_statuscode='AUDITED' and sd_clashsaleqty>0 ";
+            }
+            if (fromwhere.equals("完工入库单") || fromwhere.equals("委外验收单")) {
+                if (baseDao.isDBSetting("SaleForecast", "mappingSaleForecast")) {
+                    SqlStr = SqlStr
+                            + " and saleforecast.sf_code='"
+                            + rs.getString("ma_salecode")
+                            + "' and saleforecastdetail.sd_detno="
+                            + rs.getInt("ma_saledetno")
+                            + " and saleforecast.sf_statuscode='AUDITED' and sd_qty-nvl(sd_stepqty,0)>0 order by sortid,sd_needdate asc,sd_detno asc";
+                } else {
+                    SqlStr = SqlStr
+                            + " and saleforecast.sf_statuscode='AUDITED' and sd_qty-nvl(sd_stepqty,0)>0 order by sortid,sd_needdate asc,sd_detno asc";
+                }
+            } else if (fromwhere.equals("委外验退单")) {
+                // 委外验退条件特殊,上面已加
+            } else {
+                SqlStr = SqlStr
+                        + " and saleforecast.sf_statuscode='AUDITED' and NVL(sd_statuscode,' ')<>'FINISH' and sd_qty-nvl(sd_stepqty,0)>0 order by sd_needdate asc,sd_detno asc";
+            }
+
+            if ("Y".equals(canclash) && !SqlStr.equals("")) {
+                SqlRowList rs2 = baseDao.queryForRowSet(SqlStr);
+                while (rs2.next() && clashedqty < needclashqty) {
+                    double remain = rs2.getDouble("sd_qty") - rs2.getDouble("sd_stepqty");
+                    int cancelsourceid = 0;
+                    if (fromwhere.equals("委外验退单")) {
+                        remain = (rs2.getDouble("scd_clashqty") - rs2.getDouble("scd_cancelqty"));// 拿冲销数反冲减预测
+                        cancelsourceid = rs2.getInt("scd_id");
+                        if (remain <= 0) {
+                            continue;
+                        }
+                    }
+                    thisqty = remain > needclashqty - clashedqty ? needclashqty - clashedqty : remain;
+                    if (clashcode == "") {
+                        clashcode = baseDao.sGetMaxNumber("SaleClash", 2);
+                        csid = baseDao.getSeqId("SALECLASH_SEQ");
+                        SqlStr = "insert into SaleClash(sc_id,sc_code,sc_date,sc_status,sc_statuscode,sc_recorder,sc_source,sc_sourceid,sc_sourcecode)values("
+                                + csid
+                                + ",'"
+                                + clashcode
+                                + "',sysdate,'"
+                                + "已提交"
+                                + "','COMMITED','"
+                                + "wms" + "','" + fromwhere + "'," + fromid + ",'" + fromcode + "')   ";
+                        baseDao.execute(SqlStr);
+                    }
+                    SqlStr = "insert into SaleClashDetail(scd_id,scd_scid,scd_detno,scd_prodcode,scd_clashqty,scd_ordercode,scd_orderdetno,scd_sourcedetid,scd_fromcode,scd_cancelid)values("
+                            + "SALECLASHDETAIL_SEQ.NEXTVAL,"
+                            + csid
+                            + ",'"
+                            + detno
+                            + "','"
+                            + prodcode
+                            + "','"
+                            + thisqty
+                            + "','"
+                            + rs2.getString("sf_code")
+                            + "','"
+                            + rs2.getInt("sd_detno")
+                            + "',"
+                            + rs.getInt("sourcedetid")
+                            + ",'"
+                            + rs.getString("ordercode") + "'," + cancelsourceid + ")";
+                    baseDao.execute(SqlStr);
+                    if (fromwhere.equals("委外验退单")) {
+                        SqlStr = "UPDATE SaleClashDetail set scd_cancelqty=nvl(scd_cancelqty,0)+" + thisqty + " where scd_id="
+                                + rs2.getInt("scd_id") + " ";
+                        baseDao.execute(SqlStr);
+                    }
+                    SqlStr = "UPDATE saleforecastDetail set sd_stepqty=nvl(sd_stepqty,0)+(" + thisqty + ") where sd_id="
+                            + rs2.getInt("sd_id") + " ";
+                    baseDao.execute(SqlStr);
+                    detno = detno + 1;
+                    clashedqty = clashedqty + thisqty;
+                }
+            }
+        }
+        if (fromwhere.equals("委外验退单") && csid > 0) {
+            SqlStr = "UPDATE SaleClashDetail set scd_clashqty=0-scd_clashqty  where scd_scid=" + csid + " ";
+            baseDao.execute(SqlStr);
+        }
+        if (!"".equals(clashcode)) {
+            // 审核冲销单
+            auditSaleClash(csid, "SaleClash");
+        }
+    }
+
+    public void auditSaleClash(int sc_id, String caller) {
+        // 只能对状态为[已提交]的订单进行审核操作!
+        Object status = baseDao.getFieldDataByCondition("SaleClash", "sc_statuscode", "sc_id=" + sc_id);
+        if (!"COMMITED".equals(status)) {
+            BaseUtil.showError("只能对状态为[已提交]的订单进行审核操作!");
+        }
+        String dets = baseDao
+                .getJdbcTemplate()
+                .queryForObject(
+                        "select WM_CONCAT('预测单号:'||sf_code||',行号:'||sd_detno) from (select sf_code,sd_detno from SaleForecast left join SaleForecastDetail on sf_id=sd_sfid where  (nvl(sd_statuscode,' ')<>'AUDITED' and not(sd_statuscode='COMMITED' and sf_statuscode='AUDITED')) and (sf_code,sd_detno) in (select scd_ordercode,scd_orderdetno from SaleClashDetail where scd_scid=?))",
+                        String.class, sc_id);
+        if (dets != null) {
+            BaseUtil.showError("预测单号+预测行号状态不等于已审核,不允许已审核!" + dets);
+        }
+        // 执行审核前的其它逻辑
+       // handlerService.handler(caller, "audit", "before", new Object[] { sc_id });
+        // 执行审核操作
+        baseDao.audit("SaleClash", "sc_id=" + sc_id, "sc_status", "sc_statuscode", "sc_auditdate", "sc_auditman", "wms");
+        Object source = baseDao.getFieldDataByCondition("SaleClash", "sc_source", "sc_id=" + sc_id);
+        // 冲销数量记录在预测单中
+        SqlRowList rs = baseDao
+                .queryForRowSet(
+                        "select scd_ordercode,scd_orderdetno,sum(scd_clashqty) scd_clashqty from SaleClashDetail where scd_scid=? group by scd_ordercode,scd_orderdetno",
+                        sc_id);
+        while (rs.next()) {
+            baseDao.updateByCondition("SaleForecastDetail", "sd_qty=sd_qty-(" + rs.getDouble("scd_clashqty")
+                    + "),sd_clashsaleqty=nvl(sd_clashsaleqty,0)+" + rs.getDouble("scd_clashqty"), "sd_detno=" + rs.getInt("scd_orderdetno")
+                    + " AND sd_sfid=(SELECT sf_id FROM SaleForecast WHERE sf_code='" + rs.getString("scd_ordercode") + "')");
+            if (source != null && source.equals("销售单") && rs.getGeneralDouble("scd_clashqty") > 0) {
+                baseDao.updateByCondition("SaleForecastDetail", "sd_yqty=(case when NVL(sd_yqty,0)-(" + rs.getDouble("scd_clashqty")
+                        + ")<0 then 0 else sd_yqty-(" + rs.getDouble("scd_clashqty") + ") end)", "sd_detno=" + rs.getInt("scd_orderdetno")
+                        + " AND sd_sfid=(SELECT sf_id FROM SaleForecast WHERE sf_code='" + rs.getString("scd_ordercode") + "')");
+            }
+        }
+        // 记录操作
+      //  baseDao.logger.audit(caller, "sc_id", sc_id);
+        // 执行审核后的其它逻辑
+       // handlerService.handler(caller, "audit", "after", new Object[] { sc_id });
+    }
+}

+ 199 - 0
eis-wms/src/main/java/com/uas/eiswms/service/impl/BasicDataServiceImpl.java

@@ -0,0 +1,199 @@
+package com.uas.eiswms.service.impl;
+
+import com.uas.eiswms.dao.BaseDao;
+import com.uas.eiswms.service.BasicDataService;
+import com.uas.eiswms.service.LoginService;
+import com.uas.eiswms.util.BaseUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.support.rowset.SqlRowSet;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @ClassName BasicDataServiceImpl
+ * @Description 基础资料实现类
+ * @Author jinxing.chen
+ * @Date 2018/8/22 19:02
+ * @Version 1.o
+ */
+@Service
+public class BasicDataServiceImpl implements BasicDataService {
+
+    @Autowired
+    BaseDao baseDao;
+
+    @Autowired
+    LoginService loginService;
+
+    @Override
+    public Map<String, Object> postProductToXKN(String formDate, String token, String sign, String timestamp) {
+        Map<String, Object> judgeMapData = new HashMap<String, Object>();
+        judgeMapData = BaseUtil.judgeIsNull(formDate, token);
+        if (judgeMapData != null) {
+            return judgeMapData;
+        }
+        Map<String, Object> postMapData = new HashMap<String, Object>();
+        Map<String, Object> paramMap = new HashMap<String, Object>();
+        paramMap.put("formDate", formDate);
+        paramMap.put("token", token);
+        paramMap.put("timestamp", timestamp);
+        String checkResult = loginService.checkSign(paramMap, sign);
+        if ("01".equals(checkResult)) {
+            postMapData.put("success", false);
+            postMapData.put("result", "token错误");
+            return postMapData;
+        }
+        if ("02".equals(checkResult)) {
+            postMapData.put("success", false);
+            postMapData.put("result", "token已失效");
+            return postMapData;
+        }
+        if ("03".equals(checkResult)) {
+            postMapData.put("success", false);
+            postMapData.put("result", "sign签名不正确");
+            return postMapData;
+        }
+        if ("00".equals(checkResult)) {
+            System.out.println("select * from Product where pr_status = '已审核' and pr_updatetime_user > TO_DATE('" + formDate + "', 'YYYY-MM-DD')");
+            SqlRowSet sqlRowSet = baseDao.getJdbcTemplate().queryForRowSet("select * from Product where pr_status = '已审核' and pr_updatetime_user > TO_DATE('" + formDate + "', 'YYYY-MM-DD')");
+            SqlRowSet formField = baseDao.getJdbcTemplate().queryForRowSet("select fd_field from form left join formdetail on fo_id=fd_foid where fo_caller='Product'");
+            List<Map<String, Object>> dataList = BaseUtil.getDataList(sqlRowSet, formField);
+            postMapData.put("success", true);
+            postMapData.put("result", dataList);
+            return postMapData;
+        }
+        postMapData.put("success", false);
+        postMapData.put("result", "未知错误");
+        return postMapData;
+    }
+
+    @Override
+    public Map<String, Object> postCustomerToXKN(String formDate, String token, String sign, String timestamp) {
+        Map<String, Object> judgeMapData = new HashMap<String, Object>();
+        judgeMapData = BaseUtil.judgeIsNull(formDate, token);
+        if (judgeMapData != null) {
+            return judgeMapData;
+        }
+        Map<String, Object> postMapData = new HashMap<String, Object>();
+        Map<String, Object> paramMap = new HashMap<String, Object>();
+        paramMap.put("formDate", formDate);
+        paramMap.put("token", token);
+        paramMap.put("timestamp", timestamp);
+        String checkResult = loginService.checkSign(paramMap, sign);
+        if ("01".equals(checkResult)) {
+            postMapData.put("success", false);
+            postMapData.put("result", "token错误");
+            return postMapData;
+        }
+        if ("02".equals(checkResult)) {
+            postMapData.put("success", false);
+            postMapData.put("result", "token已失效");
+            return postMapData;
+        }
+        if ("03".equals(checkResult)) {
+            postMapData.put("success", false);
+            postMapData.put("result", "sign签名不正确");
+            return postMapData;
+        }
+        if ("00".equals(checkResult)) {
+            System.out.println("select * from Customer where cu_auditstatus = '已审核' and cu_updatetime_user > TO_DATE('" + formDate + "', 'YYYY-MM-DD')");
+            SqlRowSet sqlRowSet = baseDao.getJdbcTemplate().queryForRowSet("select * from Customer where cu_auditstatus = '已审核' and cu_updatetime_user > TO_DATE('" + formDate + "', 'YYYY-MM-DD')");
+            SqlRowSet formField = baseDao.getJdbcTemplate().queryForRowSet("select fd_field from form left join formdetail on fo_id=fd_foid where fo_caller='Customer!Base'");
+            List<Map<String, Object>> dataList = BaseUtil.getDataList(sqlRowSet, formField);
+            postMapData.put("success", true);
+            postMapData.put("result", dataList);
+            return postMapData;
+        }
+        postMapData.put("success", false);
+        postMapData.put("result", "未知错误");
+        return postMapData;
+    }
+
+    @Override
+    public Map<String, Object> postVendorToXKN(String formDate, String token, String sign, String timestamp) {
+        Map<String, Object> judgeMapData = new HashMap<String, Object>();
+        judgeMapData = BaseUtil.judgeIsNull(formDate, token);
+        if (judgeMapData != null) {
+            return judgeMapData;
+        }
+        Map<String, Object> postMapData = new HashMap<String, Object>();
+        Map<String, Object> paramMap = new HashMap<String, Object>();
+        paramMap.put("formDate", formDate);
+        paramMap.put("token", token);
+        paramMap.put("timestamp", timestamp);
+        String checkResult = loginService.checkSign(paramMap, sign);
+        if ("01".equals(checkResult)) {
+            postMapData.put("success", false);
+            postMapData.put("result", "token错误");
+            return postMapData;
+        }
+        if ("02".equals(checkResult)) {
+            postMapData.put("success", false);
+            postMapData.put("result", "token已失效");
+            return postMapData;
+        }
+        if ("03".equals(checkResult)) {
+            postMapData.put("success", false);
+            postMapData.put("result", "sign签名不正确");
+            return postMapData;
+        }
+        if ("00".equals(checkResult)) {
+            System.out.println("select * from Vendor where ve_auditstatus = '已审核' and ve_updatetime_user > TO_DATE('" + formDate + "', 'YYYY-MM-DD')");
+            SqlRowSet sqlRowSet = baseDao.getJdbcTemplate().queryForRowSet("select * from Vendor where ve_auditstatus = '已审核' and ve_updatetime_user > TO_DATE('" + formDate + "', 'YYYY-MM-DD')");
+            SqlRowSet formField = baseDao.getJdbcTemplate().queryForRowSet("select fd_field from form left join formdetail on fo_id=fd_foid where fo_caller='Vendor'");
+            List<Map<String, Object>> dataList = BaseUtil.getDataList(sqlRowSet, formField);
+            postMapData.put("success", true);
+            postMapData.put("result", dataList);
+            return postMapData;
+        }
+        postMapData.put("success", false);
+        postMapData.put("result", "未知错误");
+        return postMapData;
+    }
+
+    @Override
+    public Map<String, Object> postWareHouseToXKN(String formDate, String token, String sign, String timestamp) {
+        Map<String, Object> judgeMapData = new HashMap<String, Object>();
+        judgeMapData = BaseUtil.judgeIsNull(formDate, token);
+        if (judgeMapData != null) {
+            return judgeMapData;
+        }
+        Map<String, Object> postMapData = new HashMap<String, Object>();
+        Map<String, Object> paramMap = new HashMap<String, Object>();
+        paramMap.put("formDate", formDate);
+        paramMap.put("token", token);
+        paramMap.put("timestamp", timestamp);
+        String checkResult = loginService.checkSign(paramMap, sign);
+        if ("01".equals(checkResult)) {
+            postMapData.put("success", false);
+            postMapData.put("result", "token错误");
+            return postMapData;
+        }
+        if ("02".equals(checkResult)) {
+            postMapData.put("success", false);
+            postMapData.put("result", "token已失效");
+            return postMapData;
+        }
+        if ("03".equals(checkResult)) {
+            postMapData.put("success", false);
+            postMapData.put("result", "sign签名不正确");
+            return postMapData;
+        }
+        if ("00".equals(checkResult)) {
+            System.out.println("select * from Warehouse where wh_status = '已审核' and wh_updatetime_user > TO_DATE('" + formDate + "', 'YYYY-MM-DD')");
+            SqlRowSet sqlRowSet = baseDao.getJdbcTemplate().queryForRowSet("select * from Warehouse where wh_status = '已审核' and wh_updatetime_user > TO_DATE('" + formDate + "', 'YYYY-MM-DD')");
+            SqlRowSet formField = baseDao.getJdbcTemplate().queryForRowSet("select fd_field from form left join formdetail on fo_id=fd_foid where fo_caller='Warehouse'");
+            List<Map<String, Object>> dataList = BaseUtil.getDataList(sqlRowSet, formField);
+            postMapData.put("success", true);
+          //  postMapData.put("result", dataList);
+            return postMapData;
+        }
+        postMapData.put("success", false);
+        postMapData.put("result", "未知错误");
+        return postMapData;
+    }
+
+}

+ 1442 - 0
eis-wms/src/main/java/com/uas/eiswms/service/impl/ProdIOServiceImpl.java

@@ -0,0 +1,1442 @@
+package com.uas.eiswms.service.impl;
+
+
+import com.uas.eiswms.dao.BaseDao;
+import com.uas.eiswms.dao.ProdInOutDao;
+import com.uas.eiswms.model.SqlRowList;
+import com.uas.eiswms.service.ProdIOService;
+import com.uas.eiswms.service.SaleClashService;
+import com.uas.eiswms.util.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.support.rowset.SqlRowSet;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+
+@Service
+public class ProdIOServiceImpl implements ProdIOService{
+
+    private Logger logger = LoggerFactory.getLogger(ProdIOServiceImpl.class);
+
+    @Autowired
+    private BaseDao baseDao;
+    @Autowired
+    private SaleClashService saleClashService;
+    @Autowired
+    private ProdInOutDao prodInOutDao;
+
+    @Override
+    public Map<String,Object> test(String pi_class, String lastUpdateTime, String condition, String master){
+        Map<String, Object> map = new HashMap<String, Object>();
+         map.put("success",true);
+        return map;
+    }
+
+    @Override
+    public Map<String, Object> getBill(String pi_class, String lastUpdateTime, String condition) {
+        Map<String, Object> map = new HashMap<String, Object>();
+        if (StringUtils.isEmpty(pi_class) || StringUtils.isEmpty(lastUpdateTime)) {
+            map.put("success", false);
+            map.put("msg", "单据类型或者参数为空");
+            return map;
+        }
+        String caller = class2caller(pi_class);
+        String con= StringUtils.isEmpty(condition) ? "1=1" : condition.replaceAll("'", "''");
+        List<Object> mainFields = baseDao.getFieldDatasByCondition("form left join formdetail on fo_id=fd_foid", "fd_field",
+                "fo_caller='" + caller + "' and (upper(fd_field) like upper('pi_%') or upper(fd_field) like upper('prodinout%pi_%') ) order by fd_detno");
+        List<Object> detailFileds = baseDao.getFieldDatasByCondition("detailgrid", "dg_field", "dg_caller='"+ caller +"' and " +
+                "(upper(dg_field) like upper('pd_%') or upper(dg_field) like upper('prodiodetail.%pd_%')) order by DG_SEQUENCE");
+        if (mainFields != null && detailFileds != null) {
+            String mainStr = List2Str(mainFields);
+            String gridStr = List2Str(detailFileds);
+            List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
+            //获取主表信息
+            List<Map<String, Object>> list = baseDao.getJdbcTemplate().queryForList("select " + mainStr +
+                    " from prodinout where pi_class=? and pi_lastupdatetime_user>to_date('"+ lastUpdateTime +"','yyyy-mm-dd') and " + con + " order by pi_id", pi_class);
+            List<Map<String, Object>> maps = BaseUtil.parseListDate(list);
+            if (maps != null) {
+                for (Map<String, Object> m : maps) {
+                    Object pi_id = m.get("pi_id");
+                    if (!StringUtils.isEmpty(pi_id)) {
+                        //从表信息
+                        List<Map<String, Object>> details = baseDao.getJdbcTemplate().queryForList("select " + gridStr + " from prodiodetail where pd_piid=?", pi_id);
+                        m.put("detail", BaseUtil.parseListDate(details));
+                        data.add(m);
+                    }
+                }
+            }
+            map.put("success", true);
+            map.put("data", data);
+        }
+        return map;
+    }
+
+    @Override
+    public String prePost(String data) {
+        List<Map<Object, Object>> maps = JsonUtil.toMapList(data);
+        if (maps.size() == 0) {
+            BaseUtil.showError("数据为空");
+        }
+        Object pi_id = maps.get(0).get("pi_id");
+        Object pi_class = maps.get(0).get("pi_class");
+        logger.info("过账前数据检测......");
+        String caller = class2caller(pi_class);
+        //检测传入数据字段是否存在,过账数量是否小于等于原数量
+        checkNecessaryFieldAndQty(caller, maps);
+        return post(Integer.valueOf(pi_id.toString()), caller);
+    }
+
+    private void checkNecessaryFieldAndQty(String caller, List<Map<Object, Object>> maps) {
+        boolean in = baseDao.isProdIn(caller);
+        Double qty = 0.0;
+        List<String> sqls = new ArrayList<String>();
+        for (Map<Object,Object> m : maps) {
+            if (StringUtils.isEmpty(m.get("pi_id")) || StringUtils.isEmpty(m.get("pi_inoutno")) || StringUtils.isEmpty(m.get("pd_pdno"))) {
+                BaseUtil.showError("必填项未传入,行号:" + m.get("pd_pdno"));
+            }
+            Object pd_prodmadedate = m.get("pd_prodmadedate");//生产日期
+            Object pd_replydate = m.get("pd_replydate");//有效期
+            String qtyField = in ? "pd_inqty" : "pd_outqty";
+            qty = m.get(qtyField) == null ? 0.0 : Double.parseDouble(m.get(qtyField).toString());
+            Object realQty = baseDao.getFieldDataByCondition("prodiodetail", qtyField, "pd_piid=" + m.get("pi_id") +
+                    "and pd_pdno=" + m.get("pd_pdno"));
+            if (realQty == null || (qty - Double.valueOf(realQty.toString()) > 0)) {
+                BaseUtil.showError("单据:" + m.get("pi_class") + " :" + m.get("pi_inoutno") + " 明细行:" + m.get("pd_pdno") + " 过账数量:" + qty + " 超出原明细数量:" + realQty);
+            }
+            if (in) {
+                if (pd_prodmadedate == null && pd_replydate == null) {
+                    BaseUtil.showError("单据:" + m.get("pi_class") + " : " + m.get("pi_inoutno") + "生产日期与有效期不存在,禁止过账");
+                }
+                if (DateUtil.compareToday(pd_prodmadedate) || DateUtil.compareToday(pd_replydate)) {
+                    BaseUtil.showError("单据:" + m.get("pi_inoutno") + "生产日期与有效期不能大于当天!");
+                }
+                sqls.add("update prodiodetail set " + qtyField + "=" + qty + ",pd_prodmadedate=" + (pd_prodmadedate == null ? "pd_prodmadedate" : "to_date('" + pd_prodmadedate + "','yyyy-mm-dd')") +
+                        ",pd_replydate=" + (pd_replydate == null ? "pd_replydate" : "to_date('" + pd_replydate + "','yyyy-mm-dd')") +
+                        " where pd_piid=" + m.get("pi_id") +" and pd_pdno=" + m.get("pd_pdno"));
+            } else {
+                sqls.add("update prodiodetail set " + qtyField + "=" + qty + " where pd_piid=" + m.get("pi_id") +" and pd_pdno=" + m.get("pd_pdno"));
+            }
+        }
+
+    }
+
+    public String post(int pi_id, String caller) {
+        logger.info("过账初始化..............");
+        StringBuffer result = new StringBuffer();
+        try {
+            baseDao.execute("select pi_id from prodinout where pi_id=? for update", pi_id);
+        } catch (Exception e) {
+            System.out.println(e.getMessage());
+            BaseUtil.showError("当前单据有其他人正在操作");
+        }
+        baseDao.execute("update prodiodetail set pd_prodcode=upper(pd_prodcode) where nvl(pd_prodcode,' ')<>' ' and pd_piid="+pi_id);
+        // 只能对状态为[未过账]的单据进行过账操作!
+        Object[] status = baseDao.getFieldsDataByCondition("ProdInOut", new String[] { "pi_statuscode", "pi_invostatuscode", "pi_date",
+                "pi_class", "pi_recordman", "pi_inoutno" }, "pi_id=" + pi_id);
+        if (status[0].equals("POSTED")) {
+            BaseUtil.showError("只能对未过账的" + status[3] + "[" + status[5] + "]进行过账操作!");
+        }
+        //送货单号不一致不允许提交
+        if ("ProdInOut!PurcCheckin".equals(caller) || "ProdInOut!DefectIn".equals(caller)) {
+            if (baseDao.isDBSetting("VerifyApplyDetail!Deal", "turnByDeliver")) {
+                checkSendCode(pi_id);
+            }
+        }
+        // 明细中如果有属于物料等级属于库存不可用的,就提示这些物料当前等级库存不可用
+        SqlRowSet rowList = baseDao.getJdbcTemplate()
+                .queryForRowSet(
+                        "select wm_concat(pd_prodcode)  prodcode from (select distinct pd_prodcode from prodiodetail "
+                                + "left join product on pd_prodcode=pr_code left join productlevel on pr_level=pl_levcode where pd_piid=? and pl_id>0 "
+                                + "and pl_isuseable=0 ) where rownum<=20", pi_id);
+        if (rowList.next()) {
+            if (rowList.getString("prodcode") != null) {
+                BaseUtil.showError("这些物料当前等级库存不可用,物料编号:" + rowList.getString("prodcode"));
+            }
+        }
+        baseDao.execute("update prodinout set (pi_whcode,pi_whname)=(select pd_whcode,pd_whname from prodiodetail where pd_piid=pi_id and nvl(pd_whcode,' ')<>' ' and rownum<2) where pi_id="
+                + pi_id + " and nvl(pi_whcode,' ')= ' '");
+        if (!status[1].equals("AUDITED")) {
+            BaseUtil.showError(status[3] + "[" + status[5] + "]未审核,不允许过账!");
+        }
+        String dets = baseDao
+                .getJdbcTemplate()
+                .queryForObject(
+                        "select wm_concat(distinct pi_class||'['||pi_inoutno||']') from prodinout left join prodiodetail a on pi_id=pd_piid where exists (select 1 from prodiodetail B WHERE B.PD_IOID=A.PD_ID AND B.PD_PIID=?) AND Pi_STATUSCODE='UNPOST'",
+                        String.class, pi_id);
+        if (dets != null) {
+            BaseUtil.showError("来源的" + dets + "未过账,本单据不允许过账!");
+        }
+        // 无来源订单不能直接过账
+        if (baseDao.isDBSetting(caller, "isWuPO")) {
+            int count = baseDao
+                    .getCount("select count(*) from ProdIODetail where (pd_ordercode is null or pd_orderdetno is null) and  pd_piid="
+                            + pi_id);
+            if (!status[1].equals("AUDITED") && count != 0) {
+                BaseUtil.showError("无来源订单审核后才能过账");
+            }
+        }
+        boolean isProdIn = baseDao.isProdIn(caller);
+        if (isProdIn) {
+            //检测入库单明细生产日期是否大于系统时间
+            inOverNow(caller, pi_id);
+            SqlRowSet rs = null;
+            // 入库类单据:如果pd_location为空,默认等于物料资料里的仓位pr_location
+            baseDao.execute(
+                    "update prodiodetail set pd_location=(select pr_location from product where pr_code=pd_prodcode) where pd_piid=? and nvl(pd_location,' ')=' '",
+                    pi_id);
+
+            rs = baseDao.getJdbcTemplate().queryForRowSet("SELECT pd_id FROM ProdioDetail where pd_piid=? and nvl(pd_batchcode,' ')=' '", pi_id);
+            while (rs.next()) {
+                baseDao.execute("update prodiodetail set pd_batchcode=? where pd_id=?", baseDao.getBatchcode(caller), rs.getInt("pd_id"));
+            }
+
+            // 入库单有生成条码但条码对应的物料或数量或批次号与明细行不一致则不允许过账
+            rs = baseDao.getJdbcTemplate()
+                    .queryForRowSet(
+                            "select wm_concat(pd_pdno)no,count(1)cn from prodiodetail left join (select sum(bi_inqty)inqty,bi_pdno,max(bi_prodcode)bi_prodcode,max(bi_batchcode)bi_batchcode from barcodeio"
+                                    + " where bi_piid=? group by bi_pdno) on bi_pdno=pd_pdno where pd_piid=? and pd_inqty>0 and inqty>0 "
+                                    + " and (nvl(inqty,0)<>pd_inqty or bi_prodcode<>pd_prodcode or bi_batchcode<>pd_batchcode) and rownum<30",
+                            pi_id, pi_id);
+            if (rs.next() && rs.getInt("cn") > 0) {
+                BaseUtil.showError("条码与明细行中的物料或数量或批次号不一致,不允许过账,请先清除不一致条码!行号:" + rs.getString("no"));
+            }
+        } else {
+            SqlRowList rs = null;
+            rs = baseDao
+                    .queryForRowSet(
+                            "SELECT pd_id,ba_purcrate FROM ProdioDetail,batch where pd_batchid=ba_id and pd_piid=? and nvl(pd_batchid,0)<>0 and nvl(pd_outqty,0)>0",
+                            pi_id);
+            while (rs.next()) {
+                if (rs.getGeneralDouble("ba_purcrate") != 0) {
+                    baseDao.execute("update prodiodetail set pd_purcoutqty=round(nvl(pd_outqty,0)/" + rs.getGeneralDouble("ba_purcrate")
+                            + ",8) where pd_id=" + rs.getObject("pd_id"));
+                } else {
+                    baseDao.execute("update prodiodetail set pd_purcoutqty=nvl(pd_outqty,0) where pd_id=" + rs.getObject("pd_id"));
+                }
+            }
+
+        }
+        useDefaultTax(caller, pi_id);
+        allowZeroTax(caller, pi_id);
+        checkFreezeMonth(caller, status[2]);
+        checkCloseMonth(status[2]);
+        checkCommit(caller, pi_id);
+        checkBatch(caller, pi_id);
+        copcheck(pi_id, caller);
+        factorycheck(pi_id, caller);
+        //根据物料中的有效期天数更新有效期止
+        baseDao.getEndDate(caller, pi_id);
+        String res = null;
+        // 平台生成的销售订单转出货单过账必须等于销售订单明细序号和数量
+        if ("ProdInOut!Sale".equals(caller)) {
+            SqlRowList rs = baseDao
+                    .queryForRowSet(
+                            "select distinct sa_code,sum(pd_outqty) out_qty,pd_orderdetno from prodiodetail left join sale on sa_code=pd_ordercode where sa_ordertype='B2C' and nvl(sa_b2ccode,' ')<>' ' and pd_piid=? group by sa_code,pd_orderdetno",
+                            pi_id);
+            while (rs.next()) {
+                rs = baseDao
+                        .queryForRowSet(
+                                "select distinct pd_ordercode pd_ordercode from prodiodetail where pd_piid=? and (pd_orderdetno not in (select sd_detno from saledetail where sd_code=?))"
+                                        + " OR "
+                                        + rs.getDouble("out_qty")
+                                        + " <>(select sd_qty from saledetail where sd_code=? and sd_detno=?) and  pd_ordercode =?", pi_id,
+                                rs.getString("sa_code"), rs.getString("sa_code"), rs.getString("pd_orderdetno"), rs.getString("sa_code"));
+                if (rs.next()) {
+                    BaseUtil.showError("通过优软商城平台生成的发货单必须一次性发货,销售单号[" + rs.getString("pd_ordercode") + "]");
+                }
+                // 维护物流公司和物流单号
+                Object[] obs = baseDao.getFieldsDataByCondition("prodinout", new String[] { "pi_logisticscompany", "pi_logisticscode" },
+                        "pi_id=" + pi_id);
+                if (obs[0] == null || obs[1] == null) {
+                    BaseUtil.showError("请维护出货单的物流公司和物料单号信息!");
+                }
+            }
+        }
+        if ("ProdInOut!PurcCheckin".equals(caller)) {// 采购验收单根据采购单号、序号,更新入库销售单号、序号
+            baseDao.execute(
+                    "update prodiodetail set (pd_salecode,pd_saledetno,pd_topmothercode)=(select d.pd_salecode,d.pd_saledetno,d.pd_topmothercode from purchase left join purchasedetail d on pu_id=pd_puid where "
+                            + " pd_ordercode=pu_code and pd_orderdetno=pd_detno) where pd_piid=?", pi_id);
+        }
+        // 调用过账存储过程前后都掉用一次gettotal方法,解决出入库单税率与发票不一致
+        getTotal(pi_id, caller);
+        // 执行过账操作
+        Object[] objs = baseDao.getFieldsDataByCondition("ProdInOut", new String[] { "pi_class", "pi_inoutno" }, "pi_id=" + pi_id);
+        baseDao.procedure("SP_GetCostPrice", new Object[] { objs[0].toString(), objs[1].toString() });
+        res = baseDao.callProcedure("Sp_SplitProdOut",
+                new Object[] { objs[0].toString(), objs[1].toString(), String.valueOf("wms") });
+
+        if (res != null && !res.trim().equals("")) {
+            // 重新添加提示限制信息
+            result.append(res + "  " + objs[0].toString() + objs[1].toString() + ",过账失败");
+            return result.toString();
+        }
+        // @add 20170614 抓取批次号成功之后更新出库单据的备料状态
+        updatePdaStatus(caller, pi_id);
+        if (baseDao.isDBSetting(caller, "ifBatchCodeNotChange") && baseDao.isDBSetting(caller, "autoPostIn")) {
+            // 拨出单过帐后产生的拨入单批号不变,同一物料同仓库不能同时入两次相同的批号
+            SqlRowList rs1 = baseDao
+                    .queryForRowSet("select  count(1)n, wm_concat(pd_pdno)detno from (select pd_batchcode,pd_inwhcode,pd_prodcode,min(pd_pdno)pd_pdno,count(1)c from  ProdIODetail where pd_piid="
+                            + pi_id + " and pd_batchcode<>' ' group by pd_batchcode,pd_inwhcode,pd_prodcode ) where c> 1");
+            if (rs1.next()) {
+                if (rs1.getInt("n") > 0) {
+                    BaseUtil.showError("拨出单过帐后产生的拨入单批号不变,同一物料同拨入仓库批号不能相同!行号:" + rs1.getString("detno"));
+                }
+            }
+        }
+        checkBatchRemain(pi_id);
+        // 存储过程
+        res = baseDao.callProcedure("Sp_CommitProdInout",
+                new Object[] { objs[0].toString(), objs[1].toString(), String.valueOf("wms") });
+        if (res != null && !res.trim().equals("")) {
+            BaseUtil.showError(res);
+        }
+        if (baseDao.isDBSetting("autoCreateApBill")) {
+            if ("采购验收单".equals(status[3]) || "采购验退单".equals(status[3]) || "委外验收单".equals(status[3]) || "委外验退单".equals(status[3])
+                    || "用品验收单".equals(status[3]) || "用品验退单".equals(status[3])) {
+                dets = baseDao.getJdbcTemplate().queryForObject("select wm_concat(ab_code) from apbill where ab_source=? and ab_statuscode<>'POSTED'",
+                        String.class, status[5]);
+                if (dets != null) {
+                    BaseUtil.showError("发票" + dets + "未过账成功,请手工过账!");
+                }
+            }
+        }
+        if (baseDao.isDBSetting("autoCreateArBill")) {
+            if ("出货单".equals(status[3]) || "销售退货单".equals(status[3])) {
+                dets = baseDao.getJdbcTemplate().queryForObject(
+                        "select wm_concat(ab_code) from arbill where AB_SOURCECODE=? and ab_statuscode<>'POSTED'", String.class,
+                        status[5]);
+                if (dets != null) {
+                    BaseUtil.showError("发票" + dets + "未过账成功,请手工过账!");
+                }
+            }
+        getTotal(pi_id, caller);
+        baseDao.updateByCondition("ProdInOut", "pi_statuscode='POSTED',pi_status='已过帐'," +
+                "pi_inoutman='wms',pi_date1=sysdate,pi_sendstatus='待上传'", "pi_id=" + pi_id);
+
+        }
+        // 出库类单据过账时,根据批号抓取batch.ba_vendorrate到prodiodetail.pd_vendorrate
+        if (!baseDao.isProdIn(caller)) {
+            baseDao.execute("update prodiodetail set pd_vendorrate=(select ba_vendorrate from batch where ba_code=pd_batchcode"
+                    + " and ba_whcode =pd_whcode and ba_prodcode=pd_prodcode ) where pd_piid=" + pi_id + " and nvl(pd_vendorrate,0)=0");
+        }
+        logger.info("过账完成");
+        saleClashService.createSaleClash(pi_id, "ProdInOut");
+        if ("ProdInOut!AppropriationOut".equals(caller) || "ProdInOut!SaleAppropriationOut".equals(caller)) {
+            dets = null;
+            if (baseDao.isDBSetting(caller, "autoPostIn")) {
+                // 过账销售拨入单
+                dets = prodInOutDao.turnProdIO(pi_id);
+                logger.info("成功转拨出单,原单据id: " + pi_id);
+                //过账失败提醒
+                boolean showTurnProdIOError = baseDao.checkIf("ProdInOut",
+                        "pi_class='拨入单' and pi_statuscode='UNPOST' and pi_inoutno=(select pi_relativeplace from ProdInOut where pi_class='拨出单' and pi_id="+pi_id+")");
+                if(showTurnProdIOError) {
+                    result.append("您的拨出单:" + pi_id + "自动过账失败;");
+                }
+            }
+            if (dets != null) {
+                result.append("拨入单明细行仓库对应的仓管员与当前过账人不一致,不允许进行当前操作!行号:" + dets + ";");
+                //BaseUtil.appendError("拨入单明细行仓库对应的仓管员与当前过账人不一致,不允许进行当前操作!行号:" + dets);
+            }
+        }
+        if ("ProdInOut!AppropriationOut".equals(caller)) {
+            SqlRowList rs3 = baseDao
+                    .queryForRowSet(
+                            "select b.pi_id pi_id,a.pi_relativeplace pi_relativeplace from prodinout a left join prodinout  b on a.pi_relativeplace=b.pi_inoutno where a.pi_id=? and b.pi_class='拨入单'",
+                            pi_id);
+            if (rs3.next()) {
+               /* BaseUtil.showErrorOnSuccess("拨出单过账成功!系统产生的拨入单号:<a href=\"javascript:openUrl('jsps/scm/reserve/prodInOut.jsp?formCondition=pi_idIS"
+                        + rs3.getInt("pi_id")
+                        + "&gridCondition=pd_piidIS"
+                        + rs3.getInt("pi_id")
+                        + "&whoami=ProdInOut!AppropriationIn')\">"
+                        + rs3.getString("pi_relativeplace") + "</a>&nbsp;");*/
+                result.append("拨出单过账成功!系统产生的拨入单号:" + rs3.getString("pi_relativeplace"));
+                return result.toString();
+            }
+        }
+        if ("ProdInOut!PurcCheckin".equals(caller)) {// 采购验收单过账根据采购单+采购单序号更新pd_vendorrate
+            // ba_vendorrate
+            SqlRowList pdRowList = baseDao
+                    .queryForRowSet("select pd_id,nvl(pd_batchid,0) pd_batchid,nvl(pd_ordercode,' ') pd_ordercode,nvl(pd_orderdetno,0) pd_orderdetno from prodiodetail where pd_piid="
+                            + pi_id);
+            while (pdRowList.next()) {
+                baseDao.execute("update prodiodetail set pd_vendorrate=(select pd_vendorrate from purchasedetail where pd_code='"
+                        + pdRowList.getObject("pd_ordercode") + "' and pd_detno='" + pdRowList.getObject("pd_orderdetno")
+                        + "') where pd_id=" + pdRowList.getObject("pd_id"));
+                baseDao.execute("update batch set ba_vendorrate=(select pd_vendorrate from purchasedetail where pd_code='"
+                        + pdRowList.getObject("pd_ordercode") + "' and pd_detno='" + pdRowList.getObject("pd_orderdetno")
+                        + "') where ba_id=" + pdRowList.getObject("pd_batchid"));
+            }
+        }
+        // 2017-08-30 重新根据pdno更新批号仓库属性
+        if (isProdIn) {
+            baseDao.execute(
+                    "update barcodeio set (bi_batchcode,bi_batchid,bi_whcode)=(select pd_batchcode,pd_batchid,pd_whcode from prodiodetail where bi_piid=pd_piid and pd_pdno=bi_pdno) where bi_piid=? and nvl(bi_status,0)=0",
+                    pi_id);
+            baseDao.execute(
+                    "update batch set ba_hasbarcode=-1 where ba_id in (select pd_batchid from prodiodetail "
+                            + " where pd_piid=?) and NVL(ba_hasbarcode,0)=0 and ba_id in (select bi_batchid from barcodeio where bi_inqty>0 and bi_status=0) ",
+                    pi_id);
+        }
+        /**
+         * @author wsy
+         *         其它入库单:如果选择了采购单号、采购序号后,提交、审核的时候要判断采购单号+采购序号+物料编号是否一致,不一致限制提交
+         *         、审核
+         */
+        if ("ProdInOut!OtherIn".equals(caller)) {
+            baseDao.execute("update purchasedetail set pd_beipinacceptqty=(nvl((select sum(nvl(pd_purcinqty,0)) from prodiodetail where pd_piclass='其它入库单' and pd_ordercode=pd_code and pd_orderdetno=pd_detno and pd_status=99),0))where (pd_code,pd_detno) in (select pd_ordercode,pd_orderdetno from prodiodetail where pd_piid="
+                    + pi_id + " and pd_piclass='其它入库单')");
+        }
+        return result.toString();
+    }
+
+    private void checkBatchRemain(Object pi_id) {
+        int count = baseDao.getCount("select count(1) from documentsetup where ds_name=(select pi_class from prodinout " + "where pi_id="
+                + pi_id + ") and (ds_inorout = '-IN' or ds_inorout = 'OUT')");
+        if (count > 0) {
+            String pdnos1 = baseDao.getJdbcTemplate().queryForObject(
+                    "select WMSYS.WM_CONCAT(pd_pdno) from (select pd_pdno  from prodiodetail left join batch on"
+                            + " pd_batchcode=ba_code and ba_whcode = pd_whcode and ba_prodcode = pd_prodcode "
+                            + "where pd_piid=? and ba_code is null order by pd_pdno) where rownum<20", String.class, pi_id);
+            String pdnos2 = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select WMSYS.WM_CONCAT(pd_pdno) from (select WMSYS.WM_CONCAT(pd_pdno) pd_pdno,max(pd_batchcode),"
+                                    + "sum(pd_outqty),max(ba_remain),max(ba_code) from prodiodetail left join batch on pd_batchcode=ba_code and "
+                                    + "ba_whcode = pd_whcode and ba_prodcode = pd_prodcode where pd_piid=? group by pd_batchcode,pd_prodcode,pd_whcode"
+                                    + "  having sum(pd_outqty)>max(ba_remain) ) where rownum<20", String.class, pi_id);
+            if (pdnos1 != null || pdnos2 != null) {
+                String error1 = pdnos1 == null ? "" : "找不到您所指的批号,请修改批号或点击【重置批号】再过账!行号是:" + pdnos1 + "<br>";
+                String error2 = pdnos2 == null ? "" : "批号的库存数小于出库数量,请修改批号或点击【重置批号】再过账!行号是:" + pdnos2 + "<br>";
+                BaseUtil.showError(error1 + error2);
+            }
+        }
+    }
+
+    private void getTotal(Object pi_id, String caller) {
+        baseDao.execute("update prodiodetail set pd_purcinqty=nvl(pd_inqty,0) where pd_piid=" + pi_id
+                + " and exists (select 1 from product where pd_prodcode=pr_code and nvl(pr_purcunit,pr_unit)=pr_unit) ");
+        baseDao.execute("update prodiodetail set pd_purcoutqty=nvl(pd_outqty,0) where pd_piid=" + pi_id
+                + " and exists (select 1 from product where pd_prodcode=pr_code and nvl(pr_purcunit,pr_unit)=pr_unit)");
+
+        baseDao.execute("update prodiodetail set pd_purcinqty=pd_inqty/(select case when nvl(pr_purcrate,0)<>0 then pr_purcrate else 1 end from product where pr_code=pd_prodcode) where pd_piid="
+                + pi_id + " and nvl(pd_purcinqty,0)=0");
+
+        if ("ProdInOut!PurcCheckin".equals(caller) || "ProdInOut!PurcCheckout".equals(caller)) {
+           // 采购
+            baseDao.updateByCondition("ProdIODetail",
+                    "pd_orderprice=nvl((select pd_price from PurchaseDetail where pd_code=pd_ordercode and pd_pdno=pd_orderdetno),0)",
+                    "pd_piid=" + pi_id + " and nvl(pd_orderprice,0)=0");
+            // 强制取采购单明细表中的对应的税率
+            baseDao.execute(
+                    "update ProdIODetail set pd_taxrate=(select nvl(pd_rate,0) from PurchaseDetail where pd_code=pd_ordercode and pd_pdno=pd_orderdetno) where  pd_ordercode is not null and  pd_piid=?",
+                    pi_id);
+            baseDao.execute("update ProdIODetail set pd_ordertotal=round(pd_orderprice*(case when nvl(pd_purcinqty,0)+nvl(pd_purcoutqty,0)=0 then nvl(pd_inqty,0)+nvl(pd_outqty,0) else nvl(pd_purcinqty,0)+nvl(pd_purcoutqty,0) end),2) where pd_piid="
+                    + pi_id);
+            baseDao.execute("update ProdIODetail set pd_taxtotal=round(pd_orderprice*(case when nvl(pd_purcinqty,0)+nvl(pd_purcoutqty,0)=0 then nvl(pd_inqty,0)+nvl(pd_outqty,0) else nvl(pd_purcinqty,0)+nvl(pd_purcoutqty,0) end)*nvl(pd_taxrate,0)/(100+nvl(pd_taxrate,0)),2),pd_nettotal=round(pd_orderprice*(case when nvl(pd_purcinqty,0)+nvl(pd_purcoutqty,0)=0 then nvl(pd_inqty,0)+nvl(pd_outqty,0) else nvl(pd_purcinqty,0)+nvl(pd_purcoutqty,0) end)/(1+nvl(pd_taxrate,0)/100),2) where pd_piid="
+                    + pi_id);
+            baseDao.updateByCondition("ProdIODetail", " pd_total=round(nvl(pd_price,0)*(nvl(pd_inqty,0)+nvl(pd_outqty,0)),2)", "pd_piid="
+                    + pi_id);
+            baseDao.updateByCondition("ProdInOut",
+                    "pi_total = round(nvl((SELECT sum(round(pd_ordertotal,2)) FROM ProdIODetail WHERE pd_piid=pi_id),0),2)", "pi_id="
+                            + pi_id);
+            baseDao.updateByCondition("ProdInOut", "pi_totalupper=L2U(nvl(pi_total,0))", "pi_id=" + pi_id);
+        } else if ("ProdInOut!Sale".equals(caller) || "ProdInOut!SaleReturn".equals(caller)) {
+            baseDao.updateByCondition(
+                    "ProdIODetail",
+                    "pd_ordertotal=round(nvl(pd_sendprice,0)*(case when nvl(pd_purcinqty,0)+nvl(pd_purcoutqty,0)=0 then nvl(pd_inqty,0)+nvl(pd_outqty,0) else nvl(pd_purcinqty,0)+nvl(pd_purcoutqty,0) end),2),pd_total=round(nvl(pd_price,0)*(nvl(pd_inqty,0)+nvl(pd_outqty,0)),2)",
+                    "pd_piid=" + pi_id);
+            baseDao.updateByCondition(
+                    "ProdIODetail",
+                    "pd_netprice=round(pd_sendprice/(1+pd_taxrate/100),8),pd_nettotal=round(pd_sendprice*(case when nvl(pd_purcinqty,0)+nvl(pd_purcoutqty,0)=0 then nvl(pd_inqty,0)+nvl(pd_outqty,0) else nvl(pd_purcinqty,0)+nvl(pd_purcoutqty,0) end)/(1+nvl(pd_taxrate,0)/100),2)",
+                    "pd_piid=" + pi_id);
+            baseDao.updateByCondition("ProdInOut",
+                    "pi_total=round(nvl((SELECT sum(round(pd_ordertotal,2)) FROM ProdIODetail WHERE pd_piid=pi_id),0),2)", "pi_id=" + pi_id);
+            baseDao.execute("update prodiodetail set pd_customprice=pd_sendprice, pd_taxamount=pd_ordertotal "
+                    + "where pd_piclass in ('出货单','销售退货单') and pd_piid=? and nvl(pd_customprice,0)=0", pi_id);
+            baseDao.updateByCondition("ProdInOut", "pi_totalupper=L2U(nvl(pi_total,0))", "pi_id=" + pi_id);
+            // 成品标准成本,用于报价毛利润统计
+            baseDao.execute("UPDATE product set pr_cost=nvl((select price from ( select qd_prodcode,round(qd_factprice*qu_rate,2) price,"
+                    + "     row_number() over(partition by qd_prodcode order by qu_auditdate desc) rn from  quotation,quotationdetail  "
+                    + "where qu_id=qd_quid and qu_statuscode='AUDITED') t1 where rn=1 and qd_prodcode=pr_code),0) "
+                    + "where nvl(pr_cost,0)=0 and pr_code in (select pd_prodcode from prodiodetail where pd_piid=?)", pi_id);
+            baseDao.execute("UPDATE prodiodetail SET pd_showprice=nvl((select pr_cost from product where pd_prodcode=pr_code),0)"
+                    + "WHERE  pd_piid=?", pi_id);
+        } else {
+            baseDao.updateByCondition("ProdIODetail", "pd_total=round(nvl(pd_price,0)*(nvl(pd_inqty,0)+nvl(pd_outqty,0)),2)", "pd_piid="
+                    + pi_id);
+            baseDao.updateByCondition(
+                    "ProdInOut",
+                    "pi_total=(SELECT sum(round(nvl(pd_price,0)*(nvl(pd_inqty,0)+nvl(pd_outqty,0)),2)) FROM ProdIODetail WHERE pd_piid=pi_id)",
+                    "pi_id=" + pi_id);
+            baseDao.updateByCondition("ProdInOut", "pi_totalupper=L2U(nvl(pi_total,0))", "pi_id=" + pi_id);
+        }
+        if ("ProdInOut!Sale".equals(caller) || "ProdInOut!SaleReturn".equals(caller) || "ProdInOut!AppropriationOut".equals(caller)
+                || "ProdInOut!OtherOut".equals(caller) || "ProdInOut!ExchangeOut".equals(caller)) {
+            Object cardcode = baseDao.getFieldDataByCondition("ProdInOut", "pi_cardcode", "pi_id=" + pi_id);
+            baseDao.execute("update prodiodetail set (PD_CUSTPRODCODE,PD_CUSTPRODSPEC,pd_custproddetail)=(select max(pc_custprodcode),max(pc_custprodspec),max(pc_custproddetail) from ProductCustomer left join Product on pc_prodid=pr_id left join customer on pc_custid=cu_id where cu_code='"
+                    + cardcode
+                    + "' and pd_prodcode=pr_code) where pd_piid="
+                    + pi_id
+                    + " and nvl(pd_custprodcode,' ')=' ' and nvl(pd_custprodspec,' ')=' ' and pd_piclass in ('销售退货单', '出货单', '其它出库单', '拨出单', '换货出库单')");
+        }
+        // 入库类单据:如果pd_location为空,默认等于物料资料里的仓位pr_location
+        if (baseDao.isProdIn(caller)) {
+            baseDao.execute(
+                    "update prodiodetail set pd_location=(select pr_location from product where pr_code=pd_prodcode) where pd_piid=? and nvl(pd_location,' ')=' '",
+                    pi_id);
+        }
+    }
+
+    private String class2caller(Object pi_class) {
+        if(StringUtils.isEmpty(pi_class)) {
+            BaseUtil.showError("单据类型为空,请指定真确的单据类型!");
+        }
+        switch (pi_class.toString()) {
+            case "出货单":
+                return "ProdInOut!Sale";
+            case "采购验收单":
+                return "ProdInOut!PurcCheckin";
+            case "采购验退单":
+                return "ProdInOut!PurcCheckout";
+            case "销售退货单":
+                return "ProdInOut!SaleReturn";
+            case "拨出单":
+                return "ProdInOut!AppropriationOut";
+            case "其它入库单":
+                return "ProdInOut!OtherIn";
+            case "其它出库单":
+                return "ProdInOut!OtherOut";
+            case "其它采购出库单":
+                return "ProdInOut!OtherPurcOut";
+            case "其它采购入库单":
+                return "ProdInOut!OtherPurcIn";
+            default:
+                return "";
+        }
+    }
+
+    private void copcheck(Object pi_id, String caller) {
+        if (baseDao.isDBSetting("CopCheck")) {
+            // 出入库单:明细行采购单所属公司与当前单所属公司必须一致,可在提交、打印、审核、过账等操作前配置
+            String dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat(pd_pdno) from ProdIODetail left join ProdInOut on pd_piid=pi_id left join Purchase on pd_ordercode=pu_code where pi_id=? and nvl(pu_cop,' ')<>nvl(pi_cop,' ') and nvl(pd_ordercode,' ')<>' ' "
+                                    + " and pd_piclass in ('采购验收单','采购验退单')", String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("明细行采购单所属公司与当前单所属公司不一致,不允许进行当前操作!行号:" + dets);
+            }
+            // 出入库单:明细行销售单所属公司与当前单所属公司必须一致,可在提交、打印、审核、过账等操作前配置
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat(pd_pdno) from ProdIODetail left join ProdInOut on pd_piid=pi_id left join Sale on pd_ordercode=sa_code where pi_id=? and nvl(sa_cop,' ')<>nvl(pi_cop,' ') and nvl(pd_ordercode,' ')<>' ' "
+                                    + "and pd_piclass in ('出货单','销售退货单','销售拨出单','销售拨入单')", String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("明细行销售单所属公司与当前单所属公司不一致,不允许进行当前操作!行号:" + dets);
+            }
+            // 出货单:来源单所属公司与当前单所属公司不一致,不允许进行当前操作
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat(pd_pdno) from ProdIODetail left join ProdInOut on pd_piid=pi_id left join Sendnotify on pd_snid=sn_id where pi_id=? and nvl(sn_cop,' ')<>nvl(pi_cop,' ') and nvl(pd_snid,0)<>0 ",
+                            String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("明细来源通知单所属公司与当前单所属公司不一致,不允许进行当前操作!行号:" + dets);
+            }
+            // 出入库单:明细行制造单所属公司与当前单所属公司必须一致,可在提交、打印、审核、过账等操作前配置
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat(pd_pdno) from ProdIODetail left join ProdInOut on pd_piid=pi_id left join Make on pd_ordercode=ma_code where pi_id=? and nvl(ma_cop,' ')<>nvl(pi_cop,' ') and nvl(pd_ordercode,' ')<>' ' "
+                                    + "and pd_piclass in  ('生产领料单','生产退料单','生产补料单','完工入库单','拆件入库单')", String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("明细行制造单所属公司与当前单所属公司不一致,不允许进行当前操作!行号:" + dets);
+            }
+            // 出入库单:明细行委外单所属公司与当前单所属公司必须一致,可在提交、打印、审核、过账等操作前配置
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat(pd_pdno) from ProdIODetail left join ProdInOut on pd_piid=pi_id left join Make on pd_ordercode=ma_code where pi_id=? and nvl(ma_cop,' ')<>nvl(pi_cop,' ') and nvl(pd_ordercode,' ')<>' ' "
+                                    + "and pd_piclass in ('委外验收单','委外验退单','委外领料单','委外退料单','委外补料单')", String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("明细行委外单所属公司与当前单所属公司不一致,不允许进行当前操作!行号:" + dets);
+            }
+            if ("ProdInOut!SaleAppropriationOut".equals(caller) || "ProdInOut!OtherOut".equals(caller)
+                    || "ProdInOut!AppropriationOut".equals(caller)) {
+                dets = baseDao
+                        .getJdbcTemplate()
+                        .queryForObject(
+                                "select wm_concat(pd_pdno) from ProdIODetail left join ProdInOut on pd_piid=pi_id left join SaleForecast on pd_plancode=sf_code where pi_id=? and nvl(sf_cop,' ')<>nvl(pi_cop,' ') and nvl(pd_plancode,' ')<>' ' "
+                                        + "and pd_piclass in  ('销售拨出单','其它出库单')", String.class, pi_id);
+                if (dets != null) {
+                    BaseUtil.showError("明细行销售预测单所属公司与当前单所属公司不一致,不允许进行当前操作!行号:" + dets);
+                }
+                dets = baseDao
+                        .getJdbcTemplate()
+                        .queryForObject(
+                                "select wm_concat(pd_pdno) from ProdIODetail left join prodinout on pd_piid=pi_id left join Warehouse on pd_inwhcode=wh_code where pi_id=? and pi_class in ('销售拨出单','拨出单') and nvl(pi_cop,' ')<>nvl(wh_cop,' ')",
+                                String.class, pi_id);
+                if (dets != null) {
+                    BaseUtil.showError("单据所属公司和明细行拨入仓库的所属公司不一致,不允许进行当前操作!行号:" + dets);
+                }
+            }
+            // 出入库单限制界面的所属公司和仓库的所属公司必须一致,可在提交、打印、审核、过账等操作前配置
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat(pd_pdno) from ProdIODetail left join prodinout on pd_piid=pi_id left join Warehouse on pd_whcode=wh_code where nvl(pi_cop,' ')<>nvl(wh_cop,' ') and pi_id=? and pi_class not in ('成本调整单')",
+                            String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("单据所属公司和明细行仓库的所属公司不一致,不允许进行当前操作!行号:" + dets);
+            }
+        }
+    }
+
+    private void checkBatch(String caller, Object pi_id) {
+        if (baseDao.isProdIn(caller)) {
+            // 入库单据,同一物料同仓库不能同时入两次相同的批号
+            SqlRowList rs = baseDao
+                    .queryForRowSet("select  count(1)n, wm_concat(pd_piclass||'['||pd_inoutno||']行号['||pd_pdno||']')detno from (select pd_batchcode,pd_whcode,pd_prodcode,min(pd_pdno)pd_pdno,min(pd_inoutno)pd_inoutno,min(pd_piclass)pd_piclass,count(1)c from  ProdIODetail where pd_piid="
+                            + pi_id + " and pd_batchcode<>' ' group by pd_batchcode,pd_whcode,pd_prodcode ) where c> 1");
+            if (rs.next()) {
+                if (rs.getInt("n") > 0) {
+                    BaseUtil.showError("同一物料同仓库不能同时入两次相同的批号!" + rs.getString("detno"));
+                }
+            }
+            rs = baseDao
+                    .queryForRowSet("select count(1) n,wm_concat(pd_piclass||'['||pd_inoutno||']行号['||pd_pdno||']')detno "
+                            + "from (select pd_piclass,pd_inoutno,pd_pdno from ProdIODetail where pd_piid="
+                            + pi_id
+                            + " and pd_batchcode is not null and exists (select 1 from batch where ba_code=pd_batchcode and ba_prodcode=pd_prodcode "
+                            + "and ba_whcode=pd_whcode and (nvl(ba_remain,0)<>0 or nvl(ba_inqty,0)<>0))) where rownum<30");
+            if (rs.next()) {
+                if (rs.getInt("n") > 0) {
+                    BaseUtil.showError("批号已存在,不能重复入库!" + rs.getString("detno"));
+                }
+            }
+        }
+    }
+
+    private void checkCommit(String caller, Object pi_id) {
+
+        if (!caller.equals("ProdInOut!AppropriationOut") && !caller.equals("ProdInOut!AppropriationIn")) {
+            baseDao.execute("update prodiodetail set pd_whcode=(select pi_whcode from prodinout where pd_piid=pi_id) where pd_piid="
+                    + pi_id + " and NVL(pd_whcode,' ')=' '");
+        }
+        if (caller.equals("ProdInOut!Make!Return") || caller.equals("ProdInOut!OutsideReturn")) {
+            baseDao.execute("update prodiodetail a set pd_prodmadedate=(select min(ba_date) from prodiodetail b left join batch on b.pd_batchid=ba_id where a.pd_ordercode=b.pd_ordercode and a.pd_prodcode=b.pd_prodcode and nvl(b.pd_batchcode,' ')<>' ' and ((b.pd_piclass ='生产领料单' and a.pd_piclass='生产退料单') or (b.pd_piclass ='委外领料单' and a.pd_piclass='委外退料单'))) where pd_piid="
+                    + pi_id + " and pd_prodmadedate is null");
+        } else {
+            baseDao.execute("update prodiodetail set pd_prodmadedate=(select pi_date from prodinout where pd_piid=pi_id) where pd_piid="
+                    + pi_id + " and pd_prodmadedate is null");
+        }
+        if ("ProdInOut!CostChange".equals(caller)) {
+            baseDao.execute(
+                    "update prodiodetail set (pd_orderqty,pd_orderprice)=(select ba_remain,ba_price from batch where ba_code=pd_batchcode and pd_prodcode=ba_prodcode and ba_whcode=pd_whcode) where pd_piid=?",
+                    pi_id);
+            baseDao.execute(
+                    "update prodiodetail set pd_total=round(nvl(pd_orderqty,0)*(nvl(pd_price,0)-nvl(pd_orderprice,0)),2) where pd_piid=?",
+                    pi_id);
+        }
+        baseDao.execute("update prodiodetail set pd_qctype=(select ve_class from qua_verifyapplydetail left join qua_verifyapplydetaildet on ved_veid=ve_id where pd_qcid=ved_id) where pd_piid="
+                + pi_id + " and nvl(pd_qcid,0)<>0");
+        String dets = baseDao
+                .getJdbcTemplate()
+                .queryForObject(
+                        "select wm_concat(pd_piclass||'['||pd_inoutno||']行号['||pd_pdno||']') from ProdIODetail left  join product on pr_code=pd_prodcode  where pd_piid=? and NVL(pr_statuscode,' ')<>'AUDITED'",
+                        String.class, pi_id);
+        if (dets != null) {
+            BaseUtil.showError("明细行物料不存在或者状态不等于已审核,不允许进行当前操作!" + dets);
+        }
+        dets = baseDao
+                .getJdbcTemplate()
+                .queryForObject(
+                        "select wm_concat(pd_piclass||'['||pd_inoutno||']行号['||pd_pdno||']') from ProdIODetail where pd_piid=? and nvl(pd_whcode,' ')=' '",
+                        String.class, pi_id);
+        if (dets != null) {
+            BaseUtil.showError("明细行仓库为空,不允许进行当前操作!" + dets);
+        }
+        /**
+         * 限制当仓库编号不为空时,明细行仓库至少有一行与主记录一致;为空则不判断
+         */
+
+		/*
+		 * 暂不启用该逻辑限制 int c = baseDao.getCountByCondition(
+		 * "ProdInOut left join ProdIODetail on pi_id=pd_piid", "pi_id=" + pi_id
+		 * +
+		 * " and ((NVL(pd_whcode,' ')=nvl(pi_whcode,' ') AND pi_whcode IS NOT NULL) or pi_whcode is null )"
+		 * ); if (c < 1) { BaseUtil.showError("无一明细仓库与主表仓库一致,不允许进行当前操作!"); }
+		 */
+        if (!caller.equals("ProdInOut!StockProfit") && !caller.equals("ProdInOut!StockLoss")) {
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat(pd_pdno) from ProdIODetail inner join Prodinout on pd_piid=pi_id left join product on pr_code=pd_prodcode where "
+                                    + "pd_piid=? and round(pd_outqty+pd_inqty,0)<>pd_outqty+pd_inqty and pd_status=0 and NVL(pr_precision,0)=0  and NVL(pr_groupcode,' ')<>'用品' ",
+                            String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("计算精度是0的物料不能以小数出入库!行号:" + dets);
+            }
+        }
+        if (baseDao.isDBSetting("warehouseCheck") || baseDao.isDBSetting(caller, "warehouseCheck")) {
+            // 出入库单主记录与明细行仓库必须一致
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat(pd_piclass||'['||pd_inoutno||']行号['||pd_pdno||']') from ProdIODetail left join ProdInOut on pd_piid=pi_id where pi_id=? and (nvl(pi_whcode,' ')<>nvl(pd_whcode,' ') or nvl(pi_purpose,' ')<>nvl(pd_inwhcode,' '))",
+                            String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("明细行仓库与当前单主表仓库不一致,不允许进行当前操作!" + dets);
+            }
+        }
+        dets = baseDao
+                .getJdbcTemplate()
+                .queryForObject(
+                        "select wmsys.wm_concat(pd_piclass||':'||pd_inoutno||',行:'||pd_pdno||',仓库:'||pd_whcode) from prodiodetail left join warehouse on wh_code=pd_whcode where pd_piid=? and nvl(pd_whcode,' ')<>' ' and nvl(wh_statuscode,' ')='DISABLE'",
+                        String.class, pi_id);
+        if (dets != null) {
+            BaseUtil.showError("仓库已禁用,不允许进行当前操作!" + dets);
+        }
+        dets = baseDao
+                .getJdbcTemplate()
+                .queryForObject(
+                        "select wmsys.wm_concat(pd_piclass||':'||pd_inoutno||',行:'||pd_pdno||',仓库:'||pd_whcode) from prodiodetail left join warehouse on wh_code=pd_whcode where pd_piid=? and nvl(pd_whcode,' ')<>' ' and pd_whcode not in (select wh_code from warehouse)",
+                        String.class, pi_id);
+        if (dets != null) {
+            BaseUtil.showError("仓库不存在,不允许进行当前操作!" + dets);
+        }
+        String maxprice = baseDao.getDBSetting(caller, "maxPrice");
+        if (maxprice != null) {
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wmsys.wm_concat(pd_piclass||':'||pd_inoutno||',行:'||pd_pdno||',单价:'||pd_price) from prodiodetail where pd_piid=? and nvl(pd_price,0)>?",
+                            String.class, pi_id, maxprice);
+            if (dets != null) {
+                BaseUtil.showError("单价超过设置上限,不允许进行当前操作!" + dets);
+            }
+        }
+        if ("ProdInOut!Picking".equals(caller) || "ProdInOut!Make!Give".equals(caller) || "ProdInOut!Make!Return".equals(caller)
+                || "ProdInOut!OutsidePicking".equals(caller) || "ProdInOut!OutsideReturn".equals(caller)
+                || "ProdInOut!OSMake!Give".equals(caller) || "ProdInOut!Make!In".equals(caller)
+                || "ProdInOut!PartitionStockIn".equals(caller) || "ProdInOut!OutsideCheckIn".equals(caller)
+                || "ProdInOut!OutesideCheckReturn".equals(caller)) {
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat(pd_pdno) from ProdIODetail where pd_piid=? and pd_piclass in ('生产领料单','生产补料单','生产退料单','委外领料单','委外退料单','委外补料单') and not exists (select 1 from make left join makematerial on ma_id=mm_maid where pd_ordercode=ma_code and pd_orderdetno=mm_detno)",
+                            String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("工单+序号不存在,不允许进行当前操作!行号:" + dets);
+            }
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat(pd_pdno) from ProdIODetail left join Prodinout on pd_piid=pi_id left join make on ma_code=pd_ordercode where "
+                                    + "pd_piid=? and nvl(pi_cardcode,' ')<>nvl(ma_vendcode,' ') and pd_piclass in ('委外退料单','委外验退单','委外领料单') "
+                                    + "and nvl(pd_ordercode,' ')<>' ' and not exists (select 1 from makecraft where mc_code=pd_jobcode and mc_tasktype='工序委外单')",
+                            String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("明细委外单委外商与单据委外商不一致,不允许进行当前操作!行号:" + dets);
+            }
+
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat(pd_pdno) from ProdIODetail where nvl(pd_jobcode,' ')<>' ' and not exists (select 1 from makecraft where pd_jobcode=mc_code "
+                                    + "and mc_tasktype='工序委外单') and pd_piclass in ('委外退料单','委外验退单','委外领料单') and pd_piid=?", String.class,
+                            pi_id);
+            if (dets != null) {
+                BaseUtil.showError("明细工序委外单不存在,不允许进行当前操作!行号:" + dets);
+            }
+
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat(pd_pdno) from ProdIODetail left join Prodinout on pd_piid=pi_id left join makecraft on mc_code=pd_jobcode where "
+                                    + "pd_piid=? and nvl(pi_cardcode,' ')<>nvl(mc_vendcode,' ') and pd_piclass in ('委外退料单','委外验退单','委外领料单') "
+                                    + "and nvl(pd_ordercode,' ')<>' ' and exists (select 1 from makecraft where mc_code=pd_jobcode and mc_tasktype='工序委外单') ",
+                            String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("委外商与工序委外单委外商不一致,不允许进行当前操作!行号:" + dets);
+            }
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat('工单:'||pd_ordercode||'序号:'||pd_orderdetno) from (select pd_ordercode,pd_orderdetno,sum(pd_inqty) pd_inqty,max(mm_yqty)mm_yqty,max(mm_gqty)mm_gqty from ProdIODetail left join make on ma_code=pd_ordercode left join makematerial on ma_id=mm_maid and mm_detno=pd_orderdetno where pd_piid=? and pd_piclass='拆件入库单'  group by pd_ordercode,pd_orderdetno)A where mm_yqty+pd_inqty>mm_gqty and mm_gqty>0 ",
+                            String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("拆件入库数不能大于工单允许可拆件入库数!" + dets);
+            }
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat('行号:'||pd_pdno||'工单:'||pd_ordercode) from ProdIODetail left join make on ma_code=pd_ordercode  left join makekind ON mk_name=ma_kind where pd_piid=? and pd_piclass='拆件入库单'  and  mk_type='S'",
+                            String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("拆件单明细中存在制造单的类型是标准!" + dets);
+            }
+
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat(pd_pdno) from prodinout left join  ProdIODetail  on pd_piid=pi_id  left join make on ma_code=pd_ordercode  where  pd_piid=? and NVL(ma_statuscode,' ')<>'AUDITED' and pi_statuscode='UNPOST' and pd_piclass in ('完工入库单','拆件入库单','委外验收单','生产领料单','生产补料单','生产退料单','委外领料单','委外退料单','委外补料单') and nvl(pd_ordercode,' ')<>' ' ",
+                            String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("工单不存在或者状态不等于已审核,不允许进行当前操作!行号:" + dets);
+            }
+
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat(pd_pdno) from ProdIODetail left join Prodinout on pd_piid=pi_id left join make on ma_code=pd_ordercode  left join MakeKind on mk_name=ma_kind "
+                                    + "where pd_piid=? and nvl(pd_whcode,' ')<>' ' and nvl(mk_whcodes,' ')<>' ' and pd_whcode not in (select column_value from table(parsestring(mk_whcodes,'#'))) "
+                                    + "and pd_piclass in ('完工入库单','委外验收单') and nvl(pd_ordercode,' ')<>' ' and nvl(ProdIODetail.pd_status,0)=0",
+                            String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("明细仓库与工单类型允许入库仓库不一致,不允许进行当前操作!行号:" + dets);
+            }
+        }
+        if ("ProdInOut!OutesideCheckReturn".equals(caller)) {
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat(pd_pdno) from ProdIODetail where pd_piid=? and pd_piclass in ('委外验退单') and not exists (select 1 from make where pd_ordercode=ma_code and pd_prodcode=ma_prodcode) "
+                                    + "and not exists (select 1 from makecraft where pd_jobcode=mc_code and mc_tasktype='工序委外单' and pd_prodcode=mc_prodcode)",
+                            String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("委外单+物料编号不存在,不允许进行当前操作!行号:" + dets);
+            }
+
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat(pd_pdno) from ProdIODetail left join Prodinout on pd_piid=pi_id left join Make on ma_code=pd_ordercode where pd_piid=? and nvl(pi_currency,' ')<>nvl(ma_currency,' ')"
+                                    + " and not exists (select 1 from makecraft where pd_jobcode=mc_code and mc_tasktype='工序委外单')"
+                                    + " and pd_piclass in ('委外验退单') and nvl(pd_ordercode,' ')<>' '", String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("明细委外单与单据币别不一致,不允许进行当前操作!行号:" + dets);
+            }
+
+            dets = baseDao.getJdbcTemplate().queryForObject(
+                    "select wm_concat(pd_pdno) from ProdIODetail left join Prodinout on pd_piid=pi_id left join MakeCraft on mc_makecode=pd_ordercode "
+                            + " and mc_code =pd_jobcode where pd_piid=? and nvl(pi_currency,' ')<>nvl(mc_currency,' ')"
+                            + " and exists (select 1 from makecraft where pd_jobcode=mc_code and mc_tasktype='工序委外单')"
+                            + " and pd_piclass in ('委外验退单') and nvl(pd_ordercode,' ')<>' '", String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("明细委外单与单据币别不一致,不允许进行当前操作!行号:" + dets);
+            }
+        }
+        if ("ProdInOut!PurcCheckin".equals(caller) || "ProdInOut!PurcCheckout".equals(caller) || "ProdInOut!DefectIn".equals(caller)
+                || "ProdInOut!DefectOut".equals(caller)) {
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat(pi_inoutno) from ProdInOut where pi_id=? and pi_class in ('采购验收单','采购验退单') and (pi_cardcode,pi_title) not in (select ve_code,ve_name from vendor)",
+                            String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("单据中供应商编号,供应商名称在供应商资料中不存在!");
+            }
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat(pi_inoutno) from ProdInOut where pi_id=? and pi_class in ('采购验收单','采购验退单') and (pi_receivecode,pi_receivename) not in (select ve_code,ve_name from vendor)",
+                            String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("单据中应付供应商编号,应付供应商名称在供应商资料中不存在!");
+            }
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat(pd_pdno) from ProdIODetail where pd_piid=?"
+                                    + " and pd_piclass in ('采购验收单','采购验退单') and nvl(pd_ordercode,' ')<>' ' and  not exists (select pd_code,pd_pdno from purchasedetail where pd_code=ProdIODetail.pd_ordercode and pd_pdno=ProdIODetail.pd_orderdetno)",
+                            String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("采购单号+采购序号不存在,不允许进行当前操作!行号:" + dets);
+            }
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat(pd_pdno) from ProdIODetail where pd_piid=?"
+                                    + " and  not exists(select pd_code,pd_pdno from purchasedetail p  where p.pd_prodcode=ProdIODetail.pd_prodcode and p.pd_code=ProdIODetail.pd_ordercode and  p.pd_pdno=ProdIODetail.pd_orderdetno ) and pd_piclass in ('采购验收单','采购验退单') and nvl(pd_ordercode,' ')<>' ' ",
+                            String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("采购单号+采购序号不存在,不允许进行当前操作!行号:" + dets);
+            }
+            dets = baseDao.getJdbcTemplate().queryForObject(
+                    "select wm_concat(pd_pdno) from ProdIODetail left join PurchaseDetail on pd_ordercode=pd_code and pd_orderdetno=pd_pdno where "
+                            + "pd_piid=? and nvl(pd_mrpstatuscode,' ') in ('FREEZE','FINISH') and pd_piclass in ('采购验收单','采购验退单') "
+                            + "and nvl(pd_ordercode,' ')<>' '", String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("采购单明细已冻结或者已结案,不允许进行当前操作!行号:" + dets);
+            }
+            dets = baseDao.getJdbcTemplate().queryForObject(
+                    "select wm_concat(pd_pdno) from ProdIODetail left join PurchaseDetail on pd_ordercode=pd_code and pd_orderdetno=pd_pdno where "
+                            + "pd_piid=? and nvl(pd_mrpstatuscode,' ') in ('FREEZE','FINISH') and pd_piclass in ('不良品入库单','不良品出库单') "
+                            + "and nvl(pd_ordercode,' ')<>' ' and nvl(pd_qctype,' ')='采购检验单'", String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("采购单明细已冻结或者已结案,不允许进行当前操作!行号:" + dets);
+            }
+            dets = baseDao.getJdbcTemplate().queryForObject(
+                    "select wm_concat(pd_pdno) from ProdIODetail left join Make on pd_ordercode=ma_code where "
+                            + "pd_piid=? and nvl(ma_statuscode,' ') in ('FREEZE','FINISH') and pd_piclass in ('不良品入库单','不良品出库单') "
+                            + "and nvl(pd_ordercode,' ')<>' ' and nvl(pd_qctype,' ')='委外检验单'", String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("明细行委外单已冻结或者已结案,不允许进行当前操作!行号:" + dets);
+            }
+            if (!baseDao.isDBSetting(caller, "noLimitVendor")) {
+                dets = baseDao.getJdbcTemplate().queryForObject(
+                        "select wm_concat(pd_pdno) from ProdIODetail left join Prodinout on pd_piid=pi_id left join Purchase on pu_code=pd_ordercode where "
+                                + "pd_piid=? and nvl(pi_cardcode,' ')<>nvl(pu_vendcode,' ') and pd_piclass in ('采购验收单','采购验退单') "
+                                + "and nvl(pd_ordercode,' ')<>' '", String.class, pi_id);
+                if (dets != null) {
+                    BaseUtil.showError("明细采购单与单据供应商不一致,不允许进行当前操作!行号:" + dets);
+                }
+            }
+            if (!baseDao.isDBSetting(caller, "allowARCust")) {
+                dets = baseDao
+                        .getJdbcTemplate()
+                        .queryForObject(
+                                "select wm_concat(pd_pdno) from ProdIODetail left join Prodinout on pd_piid=pi_id left join Purchase on pu_code=pd_ordercode where "
+                                        + "pd_piid=? and nvl(pi_receivecode,' ')<>nvl(pu_receivecode,' ') and pd_piclass in ('采购验收单','采购验退单') and nvl(pd_ordercode,' ')<>' '",
+                                String.class, pi_id);
+                if (dets != null) {
+                    BaseUtil.showError("明细采购单与单据应付供应商不一致,不允许进行当前操作!行号:" + dets);
+                }
+                dets = baseDao
+                        .getJdbcTemplate()
+                        .queryForObject(
+                                "select wm_concat(pd_pdno) from ProdIODetail left join Prodinout on pd_piid=pi_id left join Purchase on pu_code=pd_ordercode where pd_piid=? and nvl(pi_currency,' ')<>nvl(pu_currency,' ')"
+                                        + " and pd_piclass in ('采购验收单','采购验退单') and nvl(pd_ordercode,' ')<>' '", String.class, pi_id);
+                if (dets != null) {
+                    BaseUtil.showError("明细采购单与单据币别不一致,不允许进行当前操作!行号:" + dets);
+                }
+            }
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat('行号:'||pd_pdno||'收料合格数量:'||ved_okqty) from ProdIODetail left join QUA_VerifyApplyDetailDet on pd_qcid=ved_id where pd_piid=? and nvl(pd_qcid,0)<>0 and nvl(pd_inqty,0)>nvl(ved_okqty,0) and pd_piclass in ('采购验收单')",
+                            String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("明细行入库数量大于收料合格数量!" + dets);
+            }
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat('行号:'||pd_pdno||'收料不合格数量:'||ved_ngqty) from ProdIODetail left join QUA_VerifyApplyDetailDet on pd_qcid=ved_id where pd_piid=? and nvl(pd_qcid,0)<>0 and nvl(pd_inqty,0)>nvl(ved_ngqty,0) and pd_piclass in ('不良品入库单')",
+                            String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("明细行入库数量大于收料不合格数量!" + dets);
+            }
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat(pd_pdno) from ProdIODetail left join Prodinout on pd_piid=pi_id left join Purchase on pu_code=pd_ordercode left join purchasekind on pk_name=pu_kind "
+                                    + "where pd_piid=? and nvl(pd_whcode,' ')<>' ' and nvl(pk_whcodes,' ')<>' ' and pd_whcode not in (select column_value from table(parsestring(pk_whcodes,'#'))) "
+                                    + "and pd_piclass in ('采购验收单') and nvl(pd_ordercode,' ')<>' '", String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("明细仓库与采购单类型允许入仓库不一致,不允许进行当前操作!行号:" + dets);
+            }
+            if ("ProdInOut!PurcCheckin".equals(caller)) {
+                dets = baseDao
+                        .getJdbcTemplate()
+                        .queryForObject(
+                                "select wm_concat(pd_pdno) from ProdIODetail left join PurchaseDetail on PurchaseDetail.pd_code=ProdIODetail.pd_ordercode and PurchaseDetail.pd_pdno=ProdIODetail.pd_orderdetno "
+                                        + "where pd_piid=? and nvl(PurchaseDetail.pd_yqty,0)>nvl(PurchaseDetail.pd_qty,0)-nvl(PurchaseDetail.pd_frozenqty,0) "
+                                        + "and pd_piclass in ('采购验收单') and nvl(ProdIODetail.pd_ordercode,' ')<>' '", String.class, pi_id);
+                if (dets != null) {
+                    BaseUtil.showError("明细采购订单已转数大于采购订单数量-已冻结数量,不允许进行当前操作!行号:" + dets);
+                }
+            }
+        }
+        if ("ProdInOut!SaleBorrow".equals(caller) || "ProdInOut!OtherPurcIn".equals(caller)) {
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat(pd_piclass||'['||pd_inoutno||']行号['||pd_pdno||']') from ProdIODetail left join Prodinout on pd_piid=pi_id left join BorrowCargoType on bt_name=pi_outtype "
+                                    + "where pd_piid=? and nvl(pd_whcode,' ')<>' ' and nvl(bt_whcodes,' ')<>' ' and pd_whcode not in (select column_value from table(parsestring(bt_whcodes,'#'))) "
+                                    + "and pd_piclass in ('借货出货单','其它采购入库单')", String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("明细仓库与借货类型允许出入仓库不一致,不允许进行当前操作!" + dets);
+            }
+        }
+        if ("ProdInOut!Sale".equals(caller) || "ProdInOut!SaleReturn".equals(caller) || "ProdInOut!OtherOut".equals(caller)
+                || "ProdInOut!ExchangeOut".equals(caller) || "ProdInOut!SaleAppropriationOut".equals(caller)) {
+            if (baseDao.isDBSetting(caller, "allowDifProd")) {
+                dets = baseDao
+                        .getJdbcTemplate()
+                        .queryForObject(
+                                "select wm_concat(pd_pdno) from ProdIODetail where pd_piid=? and not exists(select sd_code,sd_detno from saledetail where sd_code=pd_ordercode and sd_detno=pd_orderdetno and sd_statuscode='AUDITED')"
+                                        + " and pd_piclass in ('出货单','销售退货单','其它出库单','换货出库单','销售拨出单') and nvl(pd_ordercode,' ')<>' ' and nvl(pd_ioid,0)=0",
+                                String.class, pi_id);
+                if (dets != null) {
+                    BaseUtil.showError("销售单号+销售序号不存在或者状态不等于已审核,不允许进行当前操作!行号:" + dets);
+                }
+            } else if (baseDao.isDBSetting(caller, "SaleWithProdRelation")) {
+                dets = baseDao
+                        .getJdbcTemplate()
+                        .queryForObject(
+                                "select wm_concat(pd_pdno) from ProdIODetail where pd_piid=? and "
+                                        + "not exists (select sd_code,sd_detno from saledetail left join ProdRelation on (sd_prodcode=prr_soncode or (nvl(prr_ifonewa,0)=0 and sd_prodcode=prr_repcode)) "
+                                        + "where sd_code=pd_ordercode and sd_detno=pd_orderdetno and (nvl(sd_prodcode,' ')=nvl(pd_prodcode,' ') or nvl(prr_repcode ,' ')=nvl(pd_prodcode,' ') or nvl(prr_soncode ,' ')=nvl(pd_prodcode,' ')))"
+                                        + "	and pd_piclass in ('出货单','销售退货单','其它出库单','换货出库单','销售拨出单') and nvl(pd_ordercode,' ')<>' ' and nvl(pd_ioid,0)=0",
+                                String.class, pi_id);
+                if (dets != null) {
+                    BaseUtil.showError("销售单号+销售序号+物料编号不存在或者状态不等于已审核,不允许进行当前操作!行号:" + dets);
+                }
+            } else {
+                dets = baseDao
+                        .getJdbcTemplate()
+                        .queryForObject(
+                                "select wm_concat(pd_pdno) from ProdIODetail where pd_piid=? and not exists(select sd_code,sd_detno from saledetail where sd_prodcode=pd_prodcode and sd_code=pd_ordercode and sd_detno=pd_orderdetno )"
+                                        + " and pd_piclass in ('出货单','销售退货单','其它出库单','换货出库单','销售拨出单') and nvl(pd_ordercode,' ')<>' ' and nvl(pd_ioid,0)=0",
+                                String.class, pi_id);
+                if (dets != null) {
+                    BaseUtil.showError("销售单号+销售序号+物料编号不存在,不允许进行当前操作!行号:" + dets);
+                }
+            }
+            if (baseDao.isDBSetting("useMachineNo")) {
+                dets = baseDao
+                        .getJdbcTemplate()
+                        .queryForObject(
+                                "select wm_concat('物料'||pd_prodcode||'总数量'||qty||'已采集数'||yqty) from (SELECT pd_piid, pd_prodcode, pd_inoutno, nvl(sum(nvl(pd_inqty,0)+nvl(pd_outqty,0)),0) qty from prodiodetail where pd_piid=? group by pd_piid,pd_inoutno,pd_prodcode) left join (select pim_piid,pim_prodcode,count(1) yqty from prodiomac group by pim_piid,pim_prodcode) on pim_piid=pd_piid and pim_prodcode=pd_prodcode where nvl(qty,0)<>nvl(yqty,0) and nvl(yqty,0)<>0",
+                                String.class, pi_id);
+                if (dets != null) {
+                    BaseUtil.showError("单据+物料数量跟机器号数量不一致,不允许进行当前操作!行号:" + dets);
+                }
+            }
+            if (!(baseDao.isDBSetting("ProdInOut!Sale", "custatus"))) {
+                if (baseDao.isDBSetting("Sale", "zeroOutWhenHung")) {// 客户挂起时,订单单价为0不限制出货
+                    dets = baseDao
+                            .getJdbcTemplate()
+                            .queryForObject(
+                                    "select wm_concat(pi_cardcode) from ProdInOut left join customer on pi_cardcode=cu_code where pi_id = ? and pi_class in ('出货单') "
+                                            + "and cu_status='挂起' and not exists (select 1 from prodiodetail left join saledetail on pd_ordercode=sd_code and pd_orderdetno=sd_detno"
+                                            + " where pd_piid=pi_id and nvl(pd_ordercode,' ')<>' ' and nvl(sd_price,0)=0)", String.class,
+                                    pi_id);
+                    if (dets != null) {
+                        BaseUtil.showError("客户资料状态为挂起,且订单单价不为0,不允许进行当前操作!客户号:" + dets);
+                    }
+                } else {
+                    dets = baseDao
+                            .getJdbcTemplate()
+                            .queryForObject(
+                                    "select wm_concat(pi_cardcode) from ProdInOut left join customer on pi_cardcode=cu_code where pi_id = ? and pi_class in ('出货单','其它出库单','换货出库单','销售拨出单') and cu_status='挂起'",
+                                    String.class, pi_id);
+                    if (dets != null) {
+                        BaseUtil.showError("客户资料状态为挂起,不允许进行当前操作!客户号:" + dets);
+                    }
+                }
+
+            }
+            if (!baseDao.isDBSetting(caller, "allowARCust")) {
+                dets = baseDao
+                        .getJdbcTemplate()
+                        .queryForObject(
+                                "select wm_concat(pd_pdno) from ProdIODetail left join Prodinout on pd_piid=pi_id left join Sale on sa_code=pd_ordercode where pd_piid=? and nvl(pi_cardcode,' ')<>nvl(sa_custcode,' ')"
+                                        + " and pd_piclass in ('出货单','销售退货单','其它出库单','换货出库单','销售拨出单') and nvl(pd_ordercode,' ')<>' ' and nvl(pd_ioid,0)=0",
+                                String.class, pi_id);
+                if (dets != null) {
+                    BaseUtil.showError("明细销售单与单据客户不一致,不允许进行当前操作!行号:" + dets);
+                }
+                dets = baseDao
+                        .getJdbcTemplate()
+                        .queryForObject(
+                                "select wm_concat(pd_pdno) from ProdIODetail left join Prodinout on pd_piid=pi_id left join Sale on sa_code=pd_ordercode where pd_piid=? and nvl(pi_arcode,' ')<>nvl(sa_apcustcode,' ')"
+                                        + " and pd_piclass in ('出货单','销售退货单') and nvl(pd_ordercode,' ')<>' '", String.class, pi_id);
+                if (dets != null) {
+                    BaseUtil.showError("明细销售单与单据应收客户不一致,不允许进行当前操作!行号:" + dets);
+                }
+                dets = baseDao
+                        .getJdbcTemplate()
+                        .queryForObject(
+                                "select wm_concat(pd_pdno) from ProdIODetail left join Prodinout on pd_piid=pi_id left join Sale on sa_code=pd_ordercode where pd_piid=? and nvl(pi_currency,' ')<>nvl(sa_currency,' ')"
+                                        + " and pd_piclass in ('出货单','销售退货单') and nvl(pd_ordercode,' ')<>' '", String.class, pi_id);
+                if (dets != null) {
+                    BaseUtil.showError("明细销售单与单据币别不一致,不允许进行当前操作!行号:" + dets);
+                }
+            }
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat(pi_inoutno) from ProdInOut where pi_id=? and pi_class in ('出货单','销售退货单') and (pi_cardcode,pi_title) not in (select cu_code,cu_name from customer)",
+                            String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("单据中客户编号,客户名称在客户资料中不存在!");
+            }
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat(pi_inoutno) from ProdInOut where pi_id=? and pi_class in ('出货单','销售退货单') and (pi_arcode,pi_arname) not in (select cu_code,cu_name from customer)",
+                            String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("单据中应收客户编号,应收客户名称在客户资料中不存在!");
+            }
+            // 销售退货单:退货数量,如退货数量+其它未过账的退货单数量大于销售订单出货数
+            /**
+             * 需考虑状态
+             */
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat(pd_pdno) from ProdIODetail b left join SaleDetail on sd_code=pd_ordercode and sd_detno=pd_orderdetno where pd_piid=? and pd_status<99 and pd_piclass='销售退货单' and nvl(pd_ordercode,' ')<>' ' and nvl(pd_inqty,0) + (select nvl(sum(nvl(a.pd_inqty,0)),0) from ProdIODetail a where a.pd_piclass='销售退货单' and a.pd_status<99 and a.pd_ordercode=b.pd_ordercode and a.pd_orderdetno=b.pd_orderdetno and a.pd_id <> b.pd_id) > nvl(sd_sendqty,0)",
+                            String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("本次退货数+其它退货数合计大于订单的已发货数量,不允许进行当前操作!行号:" + dets);
+            }
+            if ("ProdInOut!SaleAppropriationOut".equals(caller) || "ProdInOut!OtherOut".equals(caller)) {
+                dets = baseDao
+                        .getJdbcTemplate()
+                        .queryForObject(
+                                "select wm_concat(pd_piclass||'['||pd_inoutno||']行号['||pd_pdno||']') from ProdIODetail where pd_piid=? and (pd_plancode,pd_forecastdetno) not in (select sd_code, sd_detno from saleforecastdetail,saleforecast where sf_id=sd_sfid and sf_code=pd_plancode and sd_detno=pd_forecastdetno and sd_statuscode='AUDITED') and nvl(pd_plancode,' ')<>' '",
+                                String.class, pi_id);
+                if (dets != null) {
+                    BaseUtil.showError("明细行预测单号+预测序号不存在或者状态不等于已审核,不允许进行当前操作!!" + dets);
+                }
+                dets = baseDao
+                        .getJdbcTemplate()
+                        .queryForObject(
+                                "select wm_concat(pd_piclass||'['||pd_inoutno||']行号['||pd_pdno||']') from ProdIODetail where pd_piid=? and (pd_plancode,pd_forecastdetno) in (select sd_code, sd_detno from saleforecastdetail where nvl(sd_qty,0)=0) and nvl(pd_plancode,' ')<>' '",
+                                String.class, pi_id);
+                if (dets != null) {
+                    BaseUtil.showError("明细行预测单号+预测序号预测数量等于0,不允许进行当前操作!" + dets);
+                }
+                dets = baseDao
+                        .getJdbcTemplate()
+                        .queryForObject(
+                                "select wm_concat(pd_piclass||'['||pd_inoutno||']行号['||pd_pdno||']') from ProdIODetail left join SaleDetail on pd_ordercode=sd_code and pd_orderdetno=sd_detno where pd_piid=? and pd_piclass in ('销售拨出单','其它出库单') and nvl(pd_outqty+pd_inqty,0)>nvl(sd_qty,0)-nvl(sd_yqty,0) and nvl(pd_ordercode,' ')<>' ' and nvl(pd_ioid,0)=0 and nvl(pd_snid,0)=0",
+                                String.class, pi_id);
+                if (dets != null) {
+                    BaseUtil.showError("明细行销售单号+销售序号数量大于订单未发货数,不允许进行当前操作!" + dets);
+                }
+                dets = baseDao
+                        .getJdbcTemplate()
+                        .queryForObject(
+                                "select wm_concat(pd_piclass||'['||pd_inoutno||']行号['||pd_pdno||']') from ProdIODetail where pd_piid=? and pd_piclass='销售拨出单' and pd_plancode not in (select a.sf_code from saleforecast a left join saleforecastkind b on (a.sf_kind=b.sf_name or a.sf_kind=b.sf_code) where a.sf_code=pd_plancode and sf_clashoption in ('SEND','发货冲销')) and nvl(pd_plancode,' ')<>' '",
+                                String.class, pi_id);
+                if (dets != null) {
+                    BaseUtil.showError("预测单录入错误,该预测类型不属于发货冲销!" + dets);
+                }
+            }
+        }
+        if ("ProdInOut!AppropriationOut".equals(caller) || "ProdInOut!AppropriationIn".equals(caller)
+                || "ProdInOut!SaleAppropriationOut".equals(caller) || "ProdInOut!SaleAppropriationIn".equals(caller)) {
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat(pd_pdno) from ProdIODetail,warehouse w1,warehouse w2 where pd_piid=? and pd_whcode=w1.wh_code and pd_inwhcode=w2.wh_code and nvl(w1.wh_nocost,0)<>nvl(w2.wh_nocost,0)",
+                            String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("有值和无值仓之间不能相互调拨!行号:" + dets);
+            }
+        }
+        SqlRowList rs = baseDao.queryForRowSet("select * from prodiodetail where pd_piid=?", pi_id);
+        StringBuffer sb = new StringBuffer();
+        while (rs.next()) {
+            int pdid = rs.getInt("pd_id");
+            int ioid = rs.getGeneralInt("pd_ioid");
+            double tqty = rs.getGeneralDouble("pd_inqty") + rs.getGeneralDouble("pd_outqty");
+            double yqty = 0.0;
+            if (ioid > 0) {
+                yqty = baseDao.getSummaryByField("Prodiodetail", "nvl(pd_outqty,0) + nvl(pd_inqty,0)", "pd_ioid=" + ioid + " and pd_id<>"
+                        + pdid);
+                Object[] source = baseDao.getFieldsDataByCondition("Prodiodetail", new String[] { "nvl(pd_outqty,0)", "nvl(pd_inqty,0)",
+                        "pd_piclass", "pd_inoutno" }, "pd_id=" + ioid);
+                if (source != null) {
+                    if (yqty + tqty > Double.parseDouble(source[0].toString()) + Double.parseDouble(source[1].toString())) {
+                        sb.append("行号:" + rs.getInt("pd_pdno") + ",数量:" + tqty + ",无法转出." + source[2] + "[" + source[3] + "]已转数量:" + yqty
+                                + ",本次数量:" + tqty + "<hr/>");
+                    }
+                }
+            }
+        }
+        if (sb.length() > 0) {
+            BaseUtil.showError(sb.toString());
+        }
+        // 保税信息判断
+        if (baseDao.isDBSetting("ioWHBondedCheck")) {
+            if ("ProdInOut!PurcCheckin".equals(caller) || "ProdInOut!PurcCheckout".equals(caller)) {
+                dets = baseDao
+                        .getJdbcTemplate()
+                        .queryForObject(
+                                "select wm_concat(pd_pdno) from ProdIODetail left join Prodinout on pd_piid=pi_id left join PurchaseDetail on pd_code=pd_ordercode and pd_pdno=pd_orderdetno left join warehouse on ProdIODetail.pd_whcode=wh_code where pd_piid=? and nvl(PurchaseDetail.pd_bonded,0)<>nvl(wh_bonded,0)"
+                                        + " and pd_piclass in ('采购验收单','采购验退单') and nvl(pd_ordercode,' ')<>' '", String.class, pi_id);
+                if (dets != null) {
+                    BaseUtil.showError("采购单的保税属性与仓库的保税属性不一致,不允许进行当前操作!行号:" + dets);
+                }
+            }
+            if ("ProdInOut!OutesideCheckReturn".equals(caller) || "ProdInOut!OutsideCheckIn".equals(caller)) {
+                dets = baseDao
+                        .getJdbcTemplate()
+                        .queryForObject(
+                                "select wm_concat(pd_pdno) from ProdIODetail left join Prodinout on pd_piid=pi_id left join Make on ma_code=pd_ordercode left join warehouse on pd_whcode=wh_code where pd_piid=? and nvl(ma_bonded,0)<>nvl(wh_bonded,0)"
+                                        + " and pd_piclass in ('委外验退单','委外验收单') and nvl(pd_ordercode,' ')<>' '", String.class, pi_id);
+                if (dets != null) {
+                    BaseUtil.showError("委外单的保税属性与仓库的保税属性不一致,不允许进行当前操作!行号:" + dets);
+                }
+            }
+            if ("ProdInOut!Make!In".equals(caller) || "ProdInOut!PartitionStockIn".equals(caller)) {
+                dets = baseDao
+                        .getJdbcTemplate()
+                        .queryForObject(
+                                "select wm_concat(pd_pdno) from ProdIODetail left join Prodinout on pd_piid=pi_id left join Make on ma_code=pd_ordercode left join warehouse on pd_whcode=wh_code where pd_piid=? and nvl(ma_bonded,0)<>nvl(wh_bonded,0)"
+                                        + " and pd_piclass in ('完工入库单','拆件入库单') and nvl(pd_ordercode,' ')<>' '", String.class, pi_id);
+                if (dets != null) {
+                    BaseUtil.showError("工单的保税属性与仓库的保税属性不一致,不允许进行当前操作!行号:" + dets);
+                }
+            }
+            if ("ProdInOut!Make!Give".equals(caller) || "ProdInOut!Make!Return".equals(caller) || "ProdInOut!Picking".equals(caller)
+                    || "ProdInOut!OSMake!Give".equals(caller) || "ProdInOut!OutsideReturn".equals(caller)
+                    || "ProdInOut!OutsidePicking".equals(caller)) {
+                dets = baseDao
+                        .getJdbcTemplate()
+                        .queryForObject(
+                                "select wm_concat(pd_piclass||'['||pd_inoutno||']行号['||pd_pdno||']') from ProdIODetail left join Prodinout on pd_piid=pi_id left join Make on ma_code=pd_ordercode left join warehouse on pd_whcode=wh_code where pd_piid=? and nvl(ma_bonded,0)=0 and nvl(wh_bonded,0)<>0"
+                                        + " and pd_piclass in ('委外补料单','委外退料单','委外领料单') and nvl(pd_ordercode,' ')<>' '", String.class,
+                                pi_id);
+                if (dets != null) {
+                    BaseUtil.showError("委外单保税属性是非保税,不能发生仓库保税属性是保税的单据!" + dets);
+                }
+                dets = baseDao
+                        .getJdbcTemplate()
+                        .queryForObject(
+                                "select wm_concat(pd_piclass||'['||pd_inoutno||']行号['||pd_pdno||']') from ProdIODetail left join Prodinout on pd_piid=pi_id left join Make on ma_code=pd_ordercode left join warehouse on pd_whcode=wh_code where pd_piid=? and nvl(ma_bonded,0)=0 and nvl(wh_bonded,0)<>0"
+                                        + " and pd_piclass in ('生产补料单','生产退料单','生产领料单') and nvl(pd_ordercode,' ')<>' '", String.class,
+                                pi_id);
+                if (dets != null) {
+                    BaseUtil.showError("工单保税属性是非保税,不能发生仓库保税属性是保税的单据!" + dets);
+                }
+            }
+            if ("ProdInOut!SaleAppropriationOut".equals(caller) || "ProdInOut!AppropriationOut".equals(caller)) {
+                dets = baseDao
+                        .getJdbcTemplate()
+                        .queryForObject(
+                                "select wm_concat(pd_piclass||'['||pd_inoutno||']行号['||pd_pdno||']') from ProdIODetail left join Prodinout on pd_piid=pi_id left join warehouse a on a.wh_code=pd_whcode left join warehouse b on b.wh_code=pd_inwhcode where pd_piid=? and nvl(a.wh_bonded,0)<>nvl(b.wh_bonded,0)"
+                                        + " and pd_piclass in ('拨出单','销售拨出单') and nvl(pd_whcode,' ')<>' ' and nvl(pd_inwhcode,' ')<>' '",
+                                String.class, pi_id);
+                if (dets != null) {
+                    BaseUtil.showError("拨出仓库与拨入仓库仓库的保税属性不一致,不能进行当前操作!" + dets);
+                }
+            }
+        }
+
+        // @add20180605 Q:2018050126 最后一张完工入库单或者委外验收单,提交、审核、过账之前限制,不允许存在未过账
+        // 领、退、补单据,未审核的报废单,未过账的委外验退单
+        if (("ProdInOut!OutsideCheckIn".equals(caller) || "ProdInOut!Make!In".equals(caller))
+                && baseDao.isDBSetting(caller, "checkRelBillsStatus")) {
+            // 判断哪些工单是最后一张完工入库单
+            rs = baseDao
+                    .queryForRowSet(
+                            "select pd_ordercode,pd_pdno from (select pd_ordercode,sum(pd_inqty)inqty,wm_concat(pd_pdno)pd_pdno from prodiodetail  where "
+                                    + "pd_piid=? and pd_piclass in('完工入库单','委外验收单') group by pd_ordercode) A left join make on ma_code=A.pd_ordercode "
+                                    + "where nvl(ma_madeqty,0)+inqty>=ma_qty", pi_id);
+            String errors = null;
+            while (rs.next()) {
+                dets = baseDao
+                        .getJdbcTemplate()
+                        .queryForObject(
+                                "select wm_concat(pi_class||':'||pi_inoutno) from prodiodetail,ProdInOut WHERE pd_piid=pi_id AND pi_id<>? and pd_ordercode = ? AND pi_statuscode = 'UNPOST' AND pd_status=0 AND (pd_piclass LIKE '生产%' OR pd_piclass LIKE '委外%' OR pd_piclass LIKE '完工%') and rownum<15",
+                                String.class, pi_id, rs.getString("pd_ordercode"));
+                if (dets != null) {
+                    errors = "行号:" + rs.getString("pd_pdno") + ",工单:" + rs.getString("pd_ordercode") + "存在关联未过账单据!" + dets;
+                }
+                dets = baseDao
+                        .getJdbcTemplate()
+                        .queryForObject(
+                                "SELECT wm_concat(ms_code) FROM MakeScrapdetail,MakeScrap WHERE md_msid=ms_id AND md_mmcode=? AND ms_statuscode in ('ENTERING','COMMITED') AND nvl(md_status,0)=0",
+                                String.class, rs.getString("pd_ordercode"));
+                if (dets != null) {
+                    if (errors != null) {
+                        errors += "<br>未审核的报废单:" + dets;
+                    } else {
+                        errors = "行号:" + rs.getString("pd_pdno") + ",工单:" + rs.getString("pd_ordercode") + "存在关联未审核的报废单:" + dets;
+                    }
+                }
+                if (errors != null && !"".equals(errors)) {
+                    BaseUtil.showError(errors);
+                }
+            }
+        }
+    }
+
+    private void checkCloseMonth(Object pidate) {
+        boolean bool = baseDao.checkIf("PeriodsDetail", "pd_code='MONTH-P' and pd_status=99 and pd_pdno=to_char(to_date('" + pidate
+                + "','yyyy-mm-dd hh24:mi:ss'), 'yyyymm')");
+        if (bool) {
+            BaseUtil.showError("单据日期所属期间已结账,不允许进行当前操作!");
+        }
+    }
+
+    private void checkFreezeMonth(String caller, Object pidate) {
+        if (!"ProdInOut!CostChange".equals(caller)) {
+            String freeze = baseDao.getDBSetting("freezeMonth");
+            if (freeze != null && !freeze.equals("")) {
+                if (Integer.parseInt(freeze) == DateUtil.getYearmonth(pidate.toString())) {
+                    BaseUtil.showError("单据日期所属期间已冻结,不允许进行当前操作!");
+                }
+            }
+        }
+    }
+
+    private void allowZeroTax(String caller, Object pi_id) {
+        String currency = baseDao.getDBSetting("defaultCurrency");
+        boolean allowZeroTax = baseDao.isDBSetting(caller, "allowZeroTax");
+        if ("ProdInOut!Sale".equals(caller) || "ProdInOut!SaleReturn".equals(caller)) {
+            allowZeroTax = baseDao.isDBSetting("Sale", "allowZeroTax");
+        }
+        if ("ProdInOut!PurcCheckin".equals(caller) || "ProdInOut!PurcCheckout".equals(caller)) {
+            allowZeroTax = baseDao.isDBSetting("Purchase", "allowZeroTax");
+        }
+        if ("ProdInOut!OutsideCheckIn".equals(caller) || "ProdInOut!OutesideCheckReturn".equals(caller)) {
+            allowZeroTax = baseDao.isDBSetting("Make", "allowZeroTax");
+        }
+        if (!allowZeroTax) {
+            String dets = baseDao.getJdbcTemplate().queryForObject(
+                    "select WM_CONCAT(pd_pdno) from ProdIODetail left join ProdInOut on pd_piid=pi_id where nvl(pd_taxrate,0)=0 and pi_currency='"
+                            + currency + "' and pi_id=?", String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("本位币税率为0,不允许进行当前操作!行号:" + dets);
+            }
+        }
+    }
+
+    // 税率强制等于币别表的默认税率
+    private void useDefaultTax(String caller, Object pi_id) {
+        if (baseDao.isDBSetting(caller, "useDefaultTax")) {
+            baseDao.execute("update ProdIODetail set pd_taxrate=(select cr_taxrate from currencys left join ProdInOut on pi_currency=cr_name and cr_statuscode='CANUSE' where pd_piid=pi_id)"
+                    + " where pd_piid=" + pi_id);
+        }
+        String defaultTax = baseDao.getDBSetting(caller, "defaultTax");
+        if (defaultTax != null) {
+            // 税率强制等于币别表的默认税率
+            if ("1".equals(defaultTax)) {
+                baseDao.execute("update ProdIODetail set pd_taxrate=(select cr_taxrate from currencys left join ProdInOut on pi_currency=cr_name and cr_statuscode='CANUSE' where pd_piid=pi_id)"
+                        + " where pd_piid=" + pi_id);
+            }
+            // 税率强制等于供应商资料的默认税率
+            if ("2".equals(defaultTax)) {
+                if ("ProdInOut!PurcCheckin".equals(caller) || "ProdInOut!PurcCheckout".equals(caller)
+                        || "ProdInOut!OutsideCheckIn".equals(caller) || "ProdInOut!OutesideCheckReturn".equals(caller)) {
+                    baseDao.execute("update ProdIODetail set pd_taxrate=(select nvl(ve_taxrate,0) from Vendor left join ProdInOut on pi_cardcode=ve_code and ve_auditstatuscode='AUDITED' where pi_id=pd_piid)"
+                            + " where pd_piid=" + pi_id);
+                }
+                if ("ProdInOut!SaleReturn".equals(caller) || "ProdInOut!Sale".equals(caller)) {
+                    baseDao.execute("update ProdIODetail set pd_taxrate=(select nvl(cu_taxrate,0) from Customer left join ProdInOut on pi_cardcode=cu_code and cu_auditstatuscode='AUDITED' where pi_id=pd_piid)"
+                            + " where pd_piid=" + pi_id);
+                }
+            }
+        }
+    }
+
+    public void checkSendCode(Object pi_id) {
+        SqlRowSet rs = baseDao.getJdbcTemplate().queryForRowSet("select pd_pdno from prodinout left join prodiodetail on pi_id=pd_piid left join VerifyApply on va_code=pd_vacode where pi_id="
+                + pi_id + " and nvl(pi_sendcode,' ')<>nvl(va_sendcode,' ')");
+        if (rs.next()) {
+            BaseUtil.showError("行号:" + rs.getInt("pd_pdno") + "送货单号不一致,不允许操作");
+        }
+    }
+
+    private void inOverNow(String caller,Object id){
+        if (baseDao.isDBSetting("inOverNow") && baseDao.isProdIn(caller) ) {
+            String dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat(PD_PDNO) from   ProdIODetail left join ProdInOut on pd_piid = pi_id "
+                                    + " where  pi_id = ? and  pd_prodmadedate is not null and to_char(pd_prodmadedate,'yyyy-mm') > to_char(sysdate,'yyyy-mm') ",
+                            String.class, id);
+            if (dets != null) {
+                BaseUtil.showError("行:"+dets+",明细生产日期不能大于系统日期所在年月!");
+            }
+        }
+    }
+
+    private void factorycheck(Object pi_id, String caller) {
+        if (baseDao.isDBSetting("MpsDesk", "mrpSeparateFactory")) {
+            // 采购验收单、采购验退单:明细行采购单所属工厂与仓库的所属工厂不一致,,不允许进行当前操作
+            String dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat(pd_pdno) from ProdIODetail left join PurchaseDetail on ProdIODetail.pd_ordercode=PurchaseDetail.pd_code and ProdIODetail.pd_orderdetno=PurchaseDetail.pd_pdno left join Warehouse on ProdIODetail.pd_whcode=wh_code left join product on ProdIODetail.pd_prodcode=pr_code where pd_piid=? and nvl(PR_ISGROUPPURC,0)=0 and nvl(PurchaseDetail.pd_factory,' ')<>nvl(wh_factory,' ') and nvl(ProdIODetail.pd_ordercode,' ')<>' ' "
+                                    + " and pd_piclass in ('采购验收单','采购验退单')", String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("明细行采购单所属工厂与仓库的所属工厂不一致,不允许进行当前操作!行号:" + dets);
+            }
+            // 生产领料单、退料单、补料单:明细行制造单所属工厂与仓库的所属工厂不一致,不允许进行当前操作
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat(pd_pdno) from ProdIODetail left join Make on pd_ordercode=ma_code left join Warehouse on pd_whcode=wh_code left join product on ProdIODetail.pd_prodcode=pr_code where pd_piid=? and nvl(PR_ISGROUPPURC,0)=0 and nvl(ma_factory,' ')<>nvl(wh_factory,' ') and nvl(pd_ordercode,' ')<>' ' "
+                                    + "and pd_piclass in  ('生产领料单','生产退料单','生产补料单')", String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("明细行制造单所属工厂与仓库的所属工厂不一致,不允许进行当前操作!行号:" + dets);
+            }
+            // 委外领料单、退料单、补料单:明细行委外单所属工厂与仓库的所属工厂不一致,不允许进行当前操作
+            dets = baseDao
+                    .getJdbcTemplate()
+                    .queryForObject(
+                            "select wm_concat(pd_pdno) from ProdIODetail left join Make on pd_ordercode=ma_code left join Warehouse on pd_whcode=wh_code left join product on ProdIODetail.pd_prodcode=pr_code where pd_piid=? and nvl(PR_ISGROUPPURC,0)=0 and nvl(ma_factory,' ')<>nvl(wh_factory,' ') and nvl(pd_ordercode,' ')<>' ' "
+                                    + "and pd_piclass in ('委外领料单','委外退料单','委外补料单')", String.class, pi_id);
+            if (dets != null) {
+                BaseUtil.showError("明细行委外单所属工厂与仓库的所属工厂不一致,不允许进行当前操作!行号:" + dets);
+            }
+        }
+    }
+    
+    // @add 20170524 出库类型的单据,保存,更新,获取批号之后更新备料状态
+    private void updatePdaStatus(String caller, Object pi_id) {
+        Boolean bo = baseDao.isDBSetting("BarCodeSetting", "BarRelevancyBatch");
+        if(!bo){
+            if (baseDao.isOut(caller)) { // 出库类型
+                // 如果所有的明细都没有条码则更新为空
+                SqlRowList rs = baseDao.queryForRowSet("select count(1)cn from prodiodetail where pd_piid=? and nvl(pd_batchcode,' ')<>' '",
+                        pi_id);
+                if (rs.next() && rs.getInt("cn") == 0) {
+                    baseDao.execute("update prodinout set pi_pdastatus='' where pi_id=? and nvl(pi_pdastatus,' ')<>' '", pi_id);
+                } else {
+                    rs = baseDao.queryForRowSet("select count(1)cn from barcodeio where bi_piid=? and bi_outqty>0", pi_id);
+                    if (rs.next() && rs.getInt("cn") > 0) { // 有一行以上备料记录则是备料中
+                        baseDao.execute("update prodinout set pi_pdastatus ='备料中' where pi_id=?", pi_id);
+                        rs = baseDao
+                                .queryForRowSet(
+                                        "select count(1) cn from (select pd_prodcode,pd_whcode,sum(pd_outqty)qty from prodiodetail left join batch on pd_batchid=ba_id "
+                                                + " where pd_piid=? and ba_hasbarcode<>0 group by pd_prodcode,pd_whcode)A left join (select bi_prodcode,bi_whcode,sum(bi_outqty)qty "
+                                                + " from barcodeio where bi_piid=? group by bi_prodcode,bi_whcode)B on (pd_prodcode=bi_prodcode and pd_whcode=bi_whcode) where A.qty>NVL(B.qty,0)",
+                                        pi_id, pi_id);
+                        if (rs.next() && rs.getInt("cn") == 0) {
+                            baseDao.execute("update prodinout set pi_pdastatus ='已备料' where pi_id=?", pi_id);
+                        }
+                    } else {
+                        // --存在有条码的批号则更新成未备料
+                        baseDao.execute(
+                                "update prodinout set pi_pdastatus ='未备料' where pi_id=?  and exists(select 1 from prodiodetail,batch where pd_piid=? and pd_batchid=ba_id and ba_hasbarcode<>0)",
+                                pi_id, pi_id);
+                        // --所有批号都无条码则更新成无条码
+                        baseDao.execute(
+                                "update prodinout set pi_pdastatus ='无条码' where pi_id=? and not exists(select 1 from prodiodetail left join batch on ba_id=pd_batchid where pd_piid=?  and ba_hasbarcode=-1)",
+                                pi_id, pi_id);
+                    }
+                }
+            }
+        }
+    }
+
+    private String List2Str(List<Object> list){
+        StringBuffer sb = new StringBuffer();
+        for (Object field : list) {
+            if (field != null) {
+                //处理字段前带有表名以及最后多了一个空格的字段
+                String f = field.toString().trim();
+                int i = f.lastIndexOf(" ");
+                sb.append(f.substring(i + 1) + ",");
+            }
+        }
+        if (sb.length()>1)
+        return sb.substring(0, sb.length()-1);
+        else return null;
+    }
+}

+ 133 - 0
eis-wms/src/main/java/com/uas/eiswms/util/BaseUtil.java

@@ -0,0 +1,133 @@
+package com.uas.eiswms.util;
+
+import org.springframework.jdbc.support.rowset.SqlRowSet;
+import org.springframework.util.StringUtils;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.UnsupportedEncodingException;
+import java.net.URL;
+import java.net.URLDecoder;
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+public class BaseUtil {
+    /**
+     * 数组转化成字符串, null和空字符自动去掉
+     *
+     * @param arr
+     *            待转化数组
+     * @param ch
+     *            分割符
+     */
+    public static String parseArray2Str(Object[] arr, String ch) {
+        StringBuffer sb = new StringBuffer();
+        for (Object s : arr) {
+            if (s != null && !s.toString().trim().equals("")) {
+                sb.append(s);
+                sb.append(ch);
+            }
+        }
+        if (sb.length() > 0 && ch.length() > 0) {
+            return sb.substring(0, sb.lastIndexOf(ch));
+        }
+        return sb.toString();
+    }
+
+    public static String parseDateToString(Date date, String f) {
+        if (f == null) {
+            f = "yyyy-MM-dd";
+        }
+        SimpleDateFormat sdf = new SimpleDateFormat(f);
+        if (date == null) {
+            date = new Date();
+        }
+        return sdf.format(date);
+    }
+
+    public static Date parseStringToDate(Object date, String f) {
+        if (f == null) {
+            f = "yyyy-MM-dd";
+        }
+        SimpleDateFormat sdf = new SimpleDateFormat(f);
+        if (date == null) {
+            return new Date();
+        }
+        try {
+            return sdf.parse(date.toString());
+        } catch (ParseException e) {
+            return new Date();
+        }
+    }
+
+    public static void showError(String msg) {
+        throw  new RuntimeException(msg);
+    }
+
+    public static Map<String, Object> parseMapDate(Map<String,Object> map) {
+        Map<String, Object> data = new HashMap<String, Object>();
+        Set<String> keys = map.keySet();
+        System.out.println(keys.size());
+        Object value = null;
+        for (String key : keys) {
+            value = map.get(key);
+            if (value != null && value.getClass().getSimpleName().toUpperCase().equals("TIMESTAMP")) {
+                Timestamp time = (Timestamp) value;
+                try {
+                    value = DateUtil.parseDateToString(new Date(time.getTime()), Constant.YMD_HMS);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+            data.put(key.toLowerCase(), value);
+        }
+        return data;
+    }
+
+    public static List<Map<String, Object>> parseListDate(List<Map<String, Object>> maps) {
+        List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
+        for(Map<String, Object> m : maps){
+            data.add(parseMapDate(m));
+        }
+        return data;
+    }
+
+    public static File getFile(String name) throws FileNotFoundException, UnsupportedEncodingException {
+        URL resource = BaseUtil.class.getClassLoader().getResource(name);
+        if (resource == null) {
+            throw new FileNotFoundException("文件不存在");
+        }
+        return new File(URLDecoder.decode(resource.getFile(), "UTF-8"));
+    }
+
+    public static Map<String, Object> judgeIsNull(String formDate, String token) {
+        Map<String, Object> postMapData = new HashMap<String, Object>();
+        if (org.springframework.util.StringUtils.isEmpty(formDate)) {
+            postMapData.put("success", false);
+            postMapData.put("result", "formDate不能为空");
+            return postMapData;
+        }
+        if (StringUtils.isEmpty(token)) {
+            postMapData.put("success", false);
+            postMapData.put("result", "token不能为空");
+            return postMapData;
+        }
+        return null;
+    }
+
+    public static List<Map<String, Object>> getDataList(SqlRowSet sqlRowSet, SqlRowSet formField) {
+        List<Map<String, Object>> dataList = new LinkedList<Map<String, Object>>();
+        while (sqlRowSet.next()) {
+            Map<String, Object> dataMap = new HashMap<String, Object>();
+            while (formField.next()) {
+                String formFieldStr = formField.getString("fd_field");
+                dataMap.put(formFieldStr, sqlRowSet.getString(formFieldStr));
+            }
+            formField.beforeFirst();
+            dataList.add(dataMap);
+        }
+        return dataList;
+    }
+}

+ 128 - 0
eis-wms/src/main/java/com/uas/eiswms/util/Constant.java

@@ -0,0 +1,128 @@
+package com.uas.eiswms.util;
+
+/**
+ * 系统常量
+ * 
+ * @author yingp
+ * 
+ */
+public class Constant {
+
+	// 日期格式
+
+	public final static String YM = "yyyy-MM";
+
+	public final static String ym = "yyyyMM";
+
+	public final static String YMD = "yyyy-MM-dd";
+
+	public final static String YMD_HM = "yyyy-MM-dd HH:mm";
+
+	public final static String YMD_HMS = "yyyy-MM-dd HH:mm:ss";
+
+	public final static String ORACLE_YMD = "yyyy-MM-dd";
+
+	public final static String ORACLE_YMD_HMS = "yyyy-MM-dd HH24:mi:ss";
+
+	public static final String REGEXP_MOBILE = "^[1|8][3-8]\\d{9}$|^([6|9])\\d{7}$|^[0][9]\\d{8}$|^[6]([8|6])\\d{5}$|^(886|0)[9]\\d{8}$";
+
+	public static final String REGEXP_EMAIL = "^([\\w-])+(\\.\\w+)*@([\\w-])+((\\.\\w{2,3}){1,3})$";
+
+	/**
+	 * 求和
+	 * */
+	public final static String SUMMARY_SUM = "sum";
+
+	/**
+	 * 最大值
+	 * */
+	public final static String SUMMARY_MAX = "max";
+	/**
+	 * 最小值
+	 * */
+	public final static String SUMMARY_MIN = "min";
+	/**
+	 * 平均值
+	 * */
+	public final static String SUMMARY_AVERAGE = "average";
+
+	/**
+	 * 是
+	 */
+	public static final short YES = 1;
+	/**
+	 * 是
+	 */
+	public static final short yes = -1;
+	/**
+	 * 是
+	 */
+	public static final String TRUE = "T";
+	/**
+	 * 否
+	 */
+	public static final short NO = 0;
+	/**
+	 * 否
+	 */
+	public static final String FALSE = "F";
+
+	public static final int ORACLE_MAX_TABLE_SIZE = 999;
+
+	/**
+	 * 优软云
+	 * */
+	public static final String UAS_CLOUD = "CLOUD";
+
+	/**
+	 * 类型--"是否"字段
+	 */
+	public static final String TYPE_YN = "yn";
+
+	/**
+	 * 类型--"下拉框"
+	 */
+	public static final String TYPE_COMBO = "combo";
+
+	/**
+	 * 正则表达式:数字
+	 */
+	public static final String REG_NUM = "^-?[0-9]+(.[0-9]+)?";
+
+	/**
+	 * 正则表达式:日期
+	 */
+	public static final String REG_DATE = "\\d{2,4}-\\d{1,2}-\\d{1,2}";
+
+	/**
+	 * 正则表达式:时间
+	 */
+	public static final String REG_DATETIME = "\\d{2,4}-\\d{1,2}-\\d{1,2} \\d{1,2}:\\d{1,2}:\\d{1,2}";
+
+	/**
+	 * excel导出阈值
+	 */
+	public static final int EXCEL_LG_SIZE = 5000;
+
+	/**
+	 * excel导出最大条数
+	 */
+	public static final int EXCEL_MAX_SIZE = 100000;
+
+	/**
+	 * 正则表达式:ipv4
+	 */
+	public static final String REG_IPV4 = "((?:(?:25[0-5]|2[0-4]\\d|((1\\d{2})|([1-9]?\\d)))\\.){3}(?:25[0-5]|2[0-4]\\d|((1\\d{2})|([1-9]?\\d))))";
+	
+	/**
+	 * 临时表名称
+	 */
+	public static final String TEMP_TABLE_NAME = "TEMP_TABLE";
+
+	/**
+	 * 云顶对接app_key和app_secrect
+	 */
+	public static final String yundingAppKey = "uruan-udc";
+	public static final String yundingAppSecret = "uas123456";
+
+}

+ 584 - 0
eis-wms/src/main/java/com/uas/eiswms/util/DateUtil.java

@@ -0,0 +1,584 @@
+package com.uas.eiswms.util;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+public class DateUtil {
+	static final SimpleDateFormat ym = new SimpleDateFormat("yyyyMM");
+	static final SimpleDateFormat YM = new SimpleDateFormat("yyyy-MM");
+	static final SimpleDateFormat YMD = new SimpleDateFormat("yyyy-MM-dd");
+	static final SimpleDateFormat YMD_HMS = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+	public static String format(Date date, String f) {
+		if (date == null) {
+			date = new Date();
+		}
+		if (f == null) {
+			return YMD.format(date);
+		}
+		SimpleDateFormat sdf = new SimpleDateFormat(f);
+		return sdf.format(date);
+	}
+
+	public static String format(java.sql.Date date, String f) {
+		if (date == null) {
+			return currentDateString(f);
+		} else {
+			if (f == null) {
+				return YMD.format(date);
+			}
+			SimpleDateFormat sdf = new SimpleDateFormat(f);
+			return sdf.format(date);
+		}
+	}
+
+	public static Date parse(String date, String f) {
+		if (date == null) {
+			return new Date();
+		}
+		if (f == null) {
+			try {
+				return date.contains(" ") ? YMD_HMS.parse(date) : YMD.parse(date);
+			} catch (ParseException e) {
+				return new Date();
+			}
+		}
+		SimpleDateFormat sdf = new SimpleDateFormat(f);
+		try {
+			return sdf.parse(date);
+		} catch (ParseException e) {
+			return new Date();
+		}
+	}
+
+	/**
+	 * 获取日期年份
+	 * 
+	 * @param date
+	 * @return
+	 * @throws ParseException
+	 */
+	public static int getYear(String date) throws ParseException {
+		date = date == null ? format(null, null) : date;
+		Calendar calendar = Calendar.getInstance();
+		calendar.setTime(YMD.parse(date));
+		return calendar.get(Calendar.YEAR);
+	}
+
+	/**
+	 * 获取日期年份
+	 * 
+	 * @param date
+	 * @return
+	 * @throws ParseException
+	 */
+	public static int getYear(Date date) throws ParseException {
+		date = date == null ? parse(null, null) : date;
+		Calendar calendar = Calendar.getInstance();
+		calendar.setTime(date);
+		return calendar.get(Calendar.YEAR);
+	}
+
+	/**
+	 * 获取日期月份
+	 * 
+	 * @param date
+	 * @return
+	 * @throws ParseException
+	 */
+	public static int getMonth(String date) throws ParseException {
+		date = date == null ? format(null, null) : date;
+		Calendar calendar = Calendar.getInstance();
+		calendar.setTime(YMD.parse(date));
+		return (calendar.get(Calendar.MONTH) + 1);
+	}
+
+	/**
+	 * 获取日期月份
+	 * 
+	 * @param date
+	 * @return
+	 * @throws ParseException
+	 */
+	public static int getMonth(Date date) throws ParseException {
+		date = date == null ? parse(null, null) : date;
+		Calendar calendar = Calendar.getInstance();
+		calendar.setTime(date);
+		return (calendar.get(Calendar.MONTH) + 1);
+	}
+
+	/**
+	 * 获取日期号
+	 * 
+	 * @param date
+	 * @return
+	 * @throws ParseException
+	 */
+	public static int getDay(String date) throws ParseException {
+		date = date == null ? format(null, null) : date;
+		Calendar calendar = Calendar.getInstance();
+		calendar.setTime(YMD.parse(date));
+		return calendar.get(Calendar.DAY_OF_MONTH);
+	}
+
+	/**
+	 * 获取日期号
+	 * 
+	 * @param date
+	 * @return
+	 * @throws ParseException
+	 */
+	public static int getDay(Date date) throws ParseException {
+		date = date == null ? parse(null, null) : date;
+		Calendar calendar = Calendar.getInstance();
+		calendar.setTime(date);
+		return calendar.get(Calendar.DAY_OF_MONTH);
+	}
+
+	/**
+	 * 获取日期前一年日期
+	 * 
+	 * @param date
+	 * @return
+	 * @throws ParseException
+	 */
+	public static String getLastYearDay(String date) throws ParseException {
+		date = date == null ? format(null, null) : date;
+		Calendar calendar = Calendar.getInstance();
+		try {
+			calendar.setTime(YMD.parse(date));
+		} catch (ParseException e) {
+			calendar.setTime(new Date());
+		}
+		calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - 1);
+		return YMD.format(calendar.getTime());
+
+	}
+
+	/**
+	 * 获取月份起始日期
+	 * 
+	 * @param date
+	 * @return
+	 * @throws ParseException
+	 */
+	public static String getMinMonthDate(String date) {
+		date = date == null ? format(null, null) : date;
+		Calendar calendar = Calendar.getInstance();
+		try {
+			calendar.setTime(YMD.parse(date));
+		} catch (ParseException e) {
+			calendar.setTime(new Date());
+		}
+		calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
+		return YMD.format(calendar.getTime());
+	}
+
+	/**
+	 * 获取月份起始日期
+	 * 
+	 * @param date
+	 * @return
+	 * @throws ParseException
+	 */
+	public static String getMinMonthDate(Date date) {
+		date = date == null ? parse(null, null) : date;
+		Calendar calendar = Calendar.getInstance();
+		calendar.setTime(date);
+		calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
+		return YMD.format(calendar.getTime());
+	}
+
+	/**
+	 * 获取月份最后日期
+	 * 
+	 * @param date
+	 * @return
+	 * @throws ParseException
+	 */
+	public static String getMaxMonthDate(String date) {
+		date = date == null ? format(null, null) : date;
+		Calendar calendar = Calendar.getInstance();
+		try {
+			calendar.setTime(YMD.parse(date));
+		} catch (ParseException e) {
+			calendar.setTime(new Date());
+		}
+		calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
+		return YMD.format(calendar.getTime());
+	}
+
+	/**
+	 * 获取月份最后日期
+	 * 
+	 * @param date
+	 * @return
+	 * @throws ParseException
+	 */
+	public static String getMaxMonthDate(Date date) {
+		date = date == null ? parse(null, null) : date;
+		Calendar calendar = Calendar.getInstance();
+		calendar.setTime(date);
+		calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
+		return YMD.format(calendar.getTime());
+	}
+
+	/**
+	 * 当前时间
+	 * 
+	 * @return <h3>String</h3>
+	 */
+	public static String getCurrentDate() {
+		return format(new Date(), null);
+	}
+
+	/**
+	 * 截取指定日期的年月
+	 * 
+	 * @param date
+	 * @return
+	 */
+	public static Integer getYearmonth(Date date) {
+		if (date == null) {
+			date = new Date();
+		}
+		return Integer.parseInt(ym.format(date));
+	}
+
+	/**
+	 * 截取指定日期的年月
+	 * 
+	 * @param date
+	 * @return
+	 */
+	public static Integer getYearmonth(String date) {
+		return Integer.parseInt(ym.format(parse(date, null)));
+	}
+
+	/**
+	 * 获取当前年月
+	 * 
+	 * @return
+	 */
+	public static Integer getYearmonth() {
+		return Integer.parseInt(ym.format(new Date()));
+	}
+
+	public static int compare(String date1, String date2) {
+		try {
+			Date dt1 = YMD.parse(date1);
+			Date dt2 = YMD.parse(date2);
+			if (dt1.getTime() > dt2.getTime()) {
+				return 1;
+			} else if (dt1.getTime() < dt2.getTime()) {
+				return -1;
+			} else {
+				return 0;
+			}
+		} catch (Exception exception) {
+			exception.printStackTrace();
+		}
+		return 0;
+	}
+
+	public static boolean compareToday(Object d1) {
+		try {
+			if (d1 == null) {
+				return false;
+			}
+			Date dt1 = YMD.parse(d1.toString());
+			Date dt2 = new Date();
+			if (dt1.getTime() > dt2.getTime()) {
+				return true;
+			} else {
+				return false;
+			}
+		} catch (Exception exception) {
+			exception.printStackTrace();
+		}
+		return false;
+	}
+
+	/**
+	 * 获取特定日期是星期几
+	 * 
+	 * @return
+	 */
+	public static String getWeekDay(String DateStr) {
+		SimpleDateFormat formatYMD = new SimpleDateFormat("yyyy-MM-dd");// formatYMD表示的是yyyy-MM-dd格式
+		SimpleDateFormat formatD = new SimpleDateFormat("E");// "E"表示"day in week"
+		Date d = null;
+		String weekDay = "";
+		try {
+			d = formatYMD.parse(DateStr);// 将String 转换为符合格式的日期
+			weekDay = formatD.format(d);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		// System.out.println("日期:"+DateStr+" : "+weekDay);
+		return weekDay;
+	}
+
+	public static int getWeekDay1(String DateStr) {// 返回日期对应数字
+		SimpleDateFormat formatYMD = new SimpleDateFormat("yyyy-MM-dd");// formatYMD表示的是yyyy-MM-dd格式
+		Date d = null;
+		int weekDay = 0;
+		try {
+			d = formatYMD.parse(DateStr);// 将String 转换为符合格式的日期
+			Calendar calendar = Calendar.getInstance();
+			calendar.setTime(d);
+			weekDay = calendar.get(Calendar.DAY_OF_WEEK) - 1;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return weekDay;
+	}
+
+	/**
+	 * 获取特定时间段内有哪几日
+	 * 
+	 * @return
+	 */
+	public static List<Object> findDates(String start_time, String end_time) throws ParseException {
+		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
+		Date date1 = df.parse(start_time);
+		Date date2 = df.parse(end_time);
+		int s = (int) ((date2.getTime() - date1.getTime()) / (24 * 60 * 60 * 1000));
+		List<Object> objects = new ArrayList<Object>();
+		String value = "";
+		if (s + 1 > 0) {
+			for (int i = 0; i <= s; i++) {
+				long todayDate = date1.getTime() + (long) i * 24 * 60 * 60 * 1000;
+				Date tmDate = new Date(todayDate);
+				value = new SimpleDateFormat("yyyy-MM-dd").format(tmDate);
+				objects.add(value);
+			}
+		}
+		return objects;
+	}
+
+	/**
+	 * 获取特定时间段内有多少天
+	 * 
+	 * @return
+	 */
+	public static int countDates(String start_time, String end_time) throws ParseException {
+		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
+		Date date1 = df.parse(start_time);
+		Date date2 = df.parse(end_time);
+		int s = (int) ((date2.getTime() - date1.getTime()) / (24 * 60 * 60 * 1000));
+		return s;
+	}
+
+	/**
+	 * 日期转化成oracle格式to_date('2012-12-12', 'yyyy-MM-dd')
+	 * 
+	 * @param format
+	 *            format type,for example: 'yyyy-MM-dd', 'yyyy-MM-dd HH:mm:ss'
+	 * @param date
+	 *            date{type=java.util.Date}
+	 */
+	public static String parseDateToOracleString(String format, Date date) {
+		if (format == null) {
+			format = Constant.YMD;
+		}
+		SimpleDateFormat sdf = new SimpleDateFormat(format);
+		if (date == null) {
+			date = new Date();
+		}
+		if (Constant.YMD_HMS.toUpperCase().equals(format.toUpperCase())) {
+			format = Constant.ORACLE_YMD_HMS;
+		} else {
+			format = Constant.ORACLE_YMD;
+		}
+		return "to_date('" + sdf.format(date) + "','" + format + "')";
+	}
+
+	/**
+	 * 日期转化成oracle格式to_date('2012-12-12', 'yyyy-MM-dd')
+	 * 
+	 * @param format
+	 *            format type,for example: 'yyyy-MM-dd', 'yyyy-MM-dd HH:mm:ss'
+	 * @param dateString
+	 *            date{type=string}
+	 */
+	public static String parseDateToOracleString(String format, String dateString) {
+		if (format == null) {
+			format = Constant.YMD;
+		}
+		if (dateString == null || "".equals(dateString) || "null".equals(dateString)) {
+			SimpleDateFormat sdf = new SimpleDateFormat(format);
+			dateString = sdf.format(new Date());
+		}
+		if (Constant.YMD_HMS.toUpperCase().equals(format.toUpperCase())) {
+			format = Constant.ORACLE_YMD_HMS;
+		} else {
+			format = Constant.ORACLE_YMD;
+		}
+		return "to_date('" + dateString + "','" + format + "')";
+	}
+
+	/**
+	 * Date转化成字符串格式
+	 * 
+	 * @param f
+	 *            format格式;若为空,则默认为yyyy-MM-dd
+	 */
+	public static String parseDateToString(Date date, String f) {
+		if (f == null) {
+			f = Constant.YMD;
+		}
+		SimpleDateFormat sdf = new SimpleDateFormat(f);
+		if (date == null) {
+			date = new Date();
+		}
+		return sdf.format(date);
+	}
+
+	/**
+	 * 形如{2012-12-21}或{2012-12-21 12:12:12}字符串格式的日期转化成java.util.Date类型
+	 * 
+	 * @param date
+	 *            string日期;若为空或格式错误,则返回当前时间
+	 * @param f
+	 *            format格式;若为空,则默认为yyyy-MM-dd
+	 * @return java.util.Date类型日期
+	 */
+	public static Date parseStringToDate(String date, String f) {
+		if (f == null) {
+			f = Constant.YMD;
+		}
+		SimpleDateFormat sdf = new SimpleDateFormat(f);
+		if (date == null) {
+			return new Date();
+		}
+		try {
+			return sdf.parse(date);
+		} catch (ParseException e) {
+			return new Date();
+		}
+	}
+
+	/**
+	 * 当前时间的字符串格式
+	 * 
+	 * @param f
+	 *            format格式;若为空,则默认为yyyy-MM-dd
+	 */
+	public static String currentDateString(String f) {
+		if (f == null) {
+			f = Constant.YMD;
+		}
+		SimpleDateFormat sdf = new SimpleDateFormat(f);
+		return sdf.format(new Date());
+	}
+
+	/**
+	 * 借贷合同月份处理
+	 */
+	public static int getMonthSpace(Date date1, Date date2) throws ParseException {
+		int iMonth = 0;
+		int flag = 0;
+		try {
+			Calendar objCalendarDate1 = Calendar.getInstance();
+			objCalendarDate1.setTime(date1);
+
+			Calendar objCalendarDate2 = Calendar.getInstance();
+			objCalendarDate2.setTime(date2);
+
+			if (objCalendarDate2.equals(objCalendarDate1))
+				return 0;
+			if (objCalendarDate1.after(objCalendarDate2)) {
+				Calendar temp = objCalendarDate1;
+				objCalendarDate1 = objCalendarDate2;
+				objCalendarDate2 = temp;
+			}
+			if (objCalendarDate2.get(Calendar.DAY_OF_MONTH) > objCalendarDate1.get(Calendar.DAY_OF_MONTH))
+				flag = 1;
+
+			if (objCalendarDate2.get(Calendar.YEAR) > objCalendarDate1.get(Calendar.YEAR)) {
+				iMonth = ((objCalendarDate2.get(Calendar.YEAR) - objCalendarDate1.get(Calendar.YEAR)) * 12
+						+ objCalendarDate2.get(Calendar.MONTH) + flag)
+						- objCalendarDate1.get(Calendar.MONTH);
+			} else {
+				iMonth = objCalendarDate2.get(Calendar.MONTH) + flag - objCalendarDate1.get(Calendar.MONTH);
+			}
+
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return iMonth;
+	}
+
+	/**
+	 * 月份往前或往后n天
+	 */
+	public static Date overDate(Date date, int num) {
+		date = date == null ? new Date() : date;
+		Calendar calendar = new GregorianCalendar();
+		calendar.setTime(date);
+		calendar.add(Calendar.DATE, num);
+		date = calendar.getTime();
+		return date;
+	}
+
+	/**
+	 * 月份加减
+	 * 
+	 * @param date
+	 * @param increase
+	 * @return
+	 */
+	public static Integer addMonth(Date date, int increase) {
+		if (date == null)
+			date = new Date();
+		Calendar calendar = new GregorianCalendar();
+		calendar.setTime(date);
+		calendar.add(Calendar.MONTH, increase);
+		return getYearmonth(calendar.getTime());
+	}
+
+	/**
+	 * 月份加减
+	 * 
+	 * @param month
+	 * @param increase
+	 * @return
+	 */
+	public static Integer addMonth(Integer month, int increase) {
+		Calendar calendar = new GregorianCalendar();
+		try {
+			calendar.setTime(ym.parse(String.valueOf(month)));
+		} catch (ParseException e) {
+			e.printStackTrace();
+		}
+		calendar.add(Calendar.MONTH, increase);
+		return getYearmonth(calendar.getTime());
+	}
+
+	/**
+	 * 时间添加小时数
+	 * */
+	public static Date addHours(Date date, float hours) {
+		Calendar ca = Calendar.getInstance();
+		ca.setTime(date);
+		ca.add(Calendar.MINUTE, (int) (hours * 60));
+		return ca.getTime();
+	}
+
+	/**
+	 * 判断日期是否合法
+	 */
+	public static boolean isValidDate(String dateString, String f) {
+		SimpleDateFormat sdf = new SimpleDateFormat(f);
+		sdf.setLenient(false);
+		try {
+			sdf.parse(dateString);
+		} catch (ParseException e) {
+			e.printStackTrace();
+			return false;
+		}
+		return true;
+	}
+}

+ 93 - 0
eis-wms/src/main/java/com/uas/eiswms/util/JsonUtil.java

@@ -0,0 +1,93 @@
+package com.uas.eiswms.util;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class JsonUtil {
+
+
+    static final String Unicode_Pattern = "(\\\\u(\\p{XDigit}{4}))";
+
+    public static String decodeUnicode(String jsonStr) {
+        if (jsonStr != null) {
+            // unicode格式的转化成汉字
+            Pattern pattern = Pattern.compile(Unicode_Pattern);
+            Matcher matcher = pattern.matcher(jsonStr);
+            char ch;
+            while (matcher.find()) {
+                ch = (char) Integer.parseInt(matcher.group(2), 16);
+                jsonStr = jsonStr.replace(matcher.group(1), ch + "");
+            }
+        }
+        return jsonStr;
+    }
+
+    public static Map<Object, Object> toMap(String jsonStr) {
+        jsonStr = decodeUnicode(jsonStr);
+        if (jsonStr.indexOf("{") > -1 && jsonStr.indexOf("}") > -1){
+            jsonStr = jsonStr.substring(jsonStr.indexOf("{") + 1, jsonStr.lastIndexOf("}"));
+            String[] strs;
+            if(jsonStr.indexOf("\",\"")>0) strs = jsonStr.split(",\"");
+            else  strs = jsonStr.split(","); //字段名前没有引号的jsonStr ,类似bom校验:{bo_version:"V1.0",bo_mothercode:"BS00012",bo_ispast:"否",}
+            String field = null;
+            String value = null;
+            Map<Object, Object> map = new HashMap<Object, Object>();
+            for (String str : strs) {
+                if (str.indexOf(":") > 0) {
+                    field = str.substring(0, str.indexOf(":"));
+                    if (field != null) {
+                        if (field.startsWith("\"")) {
+                            field = field.substring(1, field.length());
+                        }
+                        if (field.endsWith("\"")) {
+                            field = field.substring(0, field.lastIndexOf("\""));
+                        }
+                    }
+                    value = str.substring(str.indexOf(":") + 1);
+                    if (value != null) {
+                        if (value.startsWith("\"")) {
+                            value = value.substring(1, value.length());
+                        }
+                        if (value.endsWith("\"")) {
+                            value = value.substring(0, value.lastIndexOf("\""));
+                        }
+                    }
+                    map.put(field, value);
+                }
+            }
+            return map;
+        }
+        return null;
+    }
+
+    public static List<Map<Object, Object>> toMapList(String jsonStr) {
+        if (jsonStr != null) {
+            if (!jsonStr.startsWith("[")) {
+                jsonStr = "[" + jsonStr + "]";
+            }
+            if (jsonStr.startsWith("[")) {
+                jsonStr = jsonStr.substring(1, jsonStr.length());
+            }
+            if (jsonStr.endsWith("]")) {
+                jsonStr = jsonStr.substring(0, jsonStr.lastIndexOf("]"));
+            }
+            List<Map<Object, Object>> list = new ArrayList<Map<Object, Object>>();
+            if (jsonStr.indexOf("},") > -1) {
+                String[] js = jsonStr.split("},");
+                for (String j : js) {
+                    if (!j.endsWith("}"))
+                        j = j + "}";
+                    list.add(toMap(j));
+                }
+            } else if (jsonStr.indexOf("{") > -1 && jsonStr.indexOf("}") > -1) {
+                list.add(toMap(jsonStr));
+            }
+            return list;
+        }
+        return null;
+    }
+
+}

+ 109 - 0
eis-wms/src/main/java/com/uas/eiswms/util/MasterManager.java

@@ -0,0 +1,109 @@
+package com.uas.eiswms.util;
+
+import com.alibaba.druid.pool.DruidDataSource;
+import com.alibaba.fastjson.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.sql.SQLException;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+public class MasterManager {
+    /**
+     * 数据源
+     */
+    private static Map<String, DruidDataSource> dataSources = new ConcurrentHashMap<>();
+
+    /**
+     * 账套
+     */
+    private static Set<String> masters = new HashSet<>();
+
+    private static final String DATACONFIG = "{\"UAS_DEV\":{\"password\":\"select!#%*(\",\"driverClassName\":\"oracle.jdbc.driver.OracleDriver\",\"url\":\"jdbc:oracle:thin:@192.168.253.6:1521:orcl\",\"username\":\"UAS_DEV\"},\"UAS\":{\"password\":\"select!#%*(\",\"driverClassName\":\"oracle.jdbc.driver.OracleDriver\",\"url\":\"jdbc:oracle:thin:@192.168.253.6:1521:orcl\",\"username\":\"UAS\"},\"XKN_TEST\":{\"password\":\"select!#%*(\",\"driverClassName\":\"oracle.jdbc.driver.OracleDriver\",\"url\":\"jdbc:oracle:thin:@127.0.0.1:1521:orcl\",\"username\":\"XKN_TEST\"}}";
+    private static Logger logger = LoggerFactory.getLogger(MasterManager.class);
+
+    static {
+        init();
+    }
+
+    /**
+     * 初始化所有数据源
+     */
+    public static void init() {
+        clear();
+        logger.info("数据源初始化......");
+        // 从配置中获取数据源信息
+    /*    File propertyFile = new File("application.properties");
+        if (!propertyFile.exists()) {
+            try {
+                logger.warn("配置文件再次读取......");
+                propertyFile = BaseUtil.getFile("application.properties");
+                if (!propertyFile.exists() && !propertyFile.isFile()) {
+                    BaseUtil.showError("读取配置文件失败");
+                }
+            }catch (Exception e){
+                logger.warn("配置文件读取失败......");
+                e.printStackTrace();
+            }
+
+        }
+        Properties properties = new Properties();
+        try {
+            properties.load(new FileInputStream(propertyFile));
+        } catch (IOException e) {
+            BaseUtil.showError("读取配置文件失败");
+            e.printStackTrace();
+        }*/
+       // String datasourceConfig = properties.getProperty("datasourceConfig");
+       // String datasourceConfig = "{\"UAS_DEV\":{\"password\":\"select!#%*(\",\"driverClassName\":\"oracle.jdbc.driver.OracleDriver\",\"url\":\"jdbc:oracle:thin:@192.168.253.6:1521:orcl\",\"username\":\"UAS_DEV\"},\"UAS\":{\"password\":\"select!#%*(\",\"driverClassName\":\"oracle.jdbc.driver.OracleDriver\",\"url\":\"jdbc:oracle:thin:@192.168.253.6:1521:orcl\",\"username\":\"UAS\"},\"XKN_TEST\":{\"password\":\"select!#%*(\",\"driverClassName\":\"oracle.jdbc.driver.OracleDriver\",\"url\":\"jdbc:oracle:thin:@127.0.0.1:1521:orcl\",\"username\":\"XKN_TEST\"}}";
+        JSONObject jsonObject = JSONObject.parseObject(DATACONFIG);
+        Set<Map.Entry<String, Object>> entrySet = jsonObject.entrySet();
+        for (Map.Entry<String, Object> entry : entrySet) {
+            JSONObject object = JSONObject.parseObject(entry.getValue().toString());
+            DruidDataSource dataSource = JSONObject.parseObject(entry.getValue().toString(), DruidDataSource.class);
+            dataSources.put(entry.getKey().toUpperCase(), dataSource);
+            masters.add(entry.getKey().toUpperCase());
+        }
+    }
+
+    /**
+     * 清除旧的数据源
+     */
+    private static void clear(){
+        Set<Map.Entry<String, DruidDataSource>> entrySet = dataSources.entrySet();
+        for(Map.Entry<String, DruidDataSource> entry : entrySet){
+            DruidDataSource dataSource = entry.getValue();
+            try {
+                dataSource.close();
+            } catch (Exception e) {
+                logger.error("数据源关闭失败", e);
+            }
+        }
+        dataSources = new ConcurrentHashMap<>();
+    }
+
+    /**
+     * 获取账套对应的数据源
+     *
+     * @param userName
+     *            账套名称
+     *            用于识别B2B、B2C账套的环境(dev、test、prod)
+     * @return 数据源
+     * @throws SQLException
+     */
+    public static DruidDataSource getDataSource(String userName) {
+        if (StringUtils.isEmpty(userName)) {
+            return null;
+        }
+        userName = userName.toUpperCase();
+        DruidDataSource dataSource = dataSources.get(userName);
+        if (dataSource == null) {
+            BaseUtil.showError("数据源为空,请检查账套名称是否正确");
+        }
+        return dataSource;
+    }
+}

+ 267 - 0
eis-wms/src/main/java/com/uas/eiswms/util/NumberUtil.java

@@ -0,0 +1,267 @@
+package com.uas.eiswms.util;
+
+import java.math.BigDecimal;
+import java.text.DecimalFormat;
+
+/**
+ * 数值处理工具
+ * 
+ * @author yingp
+ * 
+ */
+public class NumberUtil {
+
+	/**
+	 * 是否为空、0
+	 * 
+	 * @param numberObj
+	 * @return
+	 */
+	public static boolean isEmpty(Object numberObj) {
+		try {
+			return numberObj == null || "0".equals(String.valueOf(numberObj)) || Integer.parseInt(numberObj.toString()) == 0;
+		} catch (Exception e) {
+			return false;
+		}
+	}
+
+	/**
+	 * format double类型
+	 * 
+	 * @param number
+	 *            需要format的数据
+	 * @param f
+	 *            保留f位的小数
+	 * @return format之后的double类型的数据
+	 */
+	public static double formatDouble(double number, int f) {
+		if (f > 0) {
+			BigDecimal b = new BigDecimal(Double.toString(number));
+			BigDecimal one = new BigDecimal("1");
+			return b.divide(one, f, BigDecimal.ROUND_HALF_UP).doubleValue();
+		} else {
+			return Math.floor(number);
+		}
+	}
+
+	/**
+	 * format double类型
+	 * 
+	 * @param number
+	 *            需要format的数据
+	 * @param f
+	 *            保留f位的小数
+	 * @return format之后的double类型的数据
+	 */
+	public static double formatDouble(String number, int f) {
+		double n = Double.parseDouble(number);
+		if (f > 0) {
+			BigDecimal b = new BigDecimal(number);
+			BigDecimal one = new BigDecimal("1");
+			return b.divide(one, f, BigDecimal.ROUND_HALF_UP).doubleValue();
+		} else {
+			return Math.floor(n);
+		}
+	}
+
+	/**
+	 * 浮点型转成BigDecimal
+	 * 
+	 * @param number
+	 * @return
+	 */
+	public static String parseBigDecimal(double number) {
+		int scale = BigDecimal.valueOf(number).scale();
+		if (scale == -1) {
+			scale = 0;
+		}
+		return String.valueOf(BigDecimal.valueOf(number).setScale(scale, BigDecimal.ROUND_HALF_UP));
+	}
+
+	/**
+	 * 数字格式化
+	 * 
+	 * @param number
+	 * @param f
+	 * @return
+	 */
+	public static String formatNumber(Object number, int f) {
+		if ("0".equals(String.valueOf(number)))
+			return "0";
+		if (number instanceof String)
+			number = Double.parseDouble(number.toString());
+		DecimalFormat df = (DecimalFormat) DecimalFormat.getInstance();
+		df.setGroupingSize(3);
+		int len = number.toString().length();
+		if (number.toString().indexOf(".") > 0)
+			len = number.toString().indexOf(".");
+		String pattern = len > 3 ? "0,000" : "0";
+		for (int i = 0; i < f; i++) {
+			if (i == 0)
+				pattern += ".";
+			pattern += "0";
+		}
+		df.applyPattern(pattern);
+		try {
+			return df.format(number);
+		} catch (Exception e) {
+			return null;
+		}
+	}
+
+	/**
+	 * 设置小数点保留位数
+	 * */
+	public static float subFloat(float f, int length) {
+		String fStr = String.valueOf(f);
+		int i = fStr.indexOf(".");
+		String returnStr = null;
+		if (fStr.length() > i + 1 + length) {
+			returnStr = fStr.substring(0, i + 1 + length);
+		} else
+			returnStr = fStr;
+		float returnf = (Float.valueOf(returnStr)).floatValue();
+		return returnf;
+	}
+
+	/**
+	 * int数组转化成Integer数组
+	 */
+	public static Integer[] toIntegerArray(int[] arr) {
+		int n = arr.length;
+		Integer[] iarr = new Integer[n];
+		for (int i = 0; i < n; i++) {
+			iarr[i] = new Integer(arr[i]);
+		}
+		return iarr;
+	}
+
+	public static Number nvl(Number number, Number ifNullNumber) {
+		return number == null ? ifNullNumber : number;
+	}
+
+	public static int compare(Double paramDouble1, Double paramDouble2) {
+		if (paramDouble1 == null)
+			paramDouble1 = 0.0;
+		if (paramDouble2 == null)
+			paramDouble2 = 0.0;
+		return Double.compare(paramDouble1, paramDouble2);
+	}
+
+	/**
+	 * Double型加法运算
+	 * 
+	 * @param d1
+	 *            第一个加数
+	 * @param ds
+	 *            若干个加数
+	 * @return 相加的结果
+	 * @author suntg
+	 */
+	public static double add(Double d1, Double... ds) {
+		BigDecimal bd = new BigDecimal(Double.toString(d1));
+		for (Double d : ds) {
+			bd = bd.add(new BigDecimal(Double.toString(d)));
+		}
+		return bd.doubleValue();
+	}
+
+	/**
+	 * Double型加法运算
+	 * 
+
+	 * @return 相加的结果
+	 * @author suntg
+	 */
+	public static double add(String ds1, String... dss) {
+		BigDecimal bd = new BigDecimal(ds1);
+		for (String ds : dss) {
+			bd = bd.add(new BigDecimal(ds));
+		}
+		return bd.doubleValue();
+	}
+
+	/**
+	 * Double型减法运算
+	 * 
+	 * @param d1
+	 *            被减数
+	 * @param d2
+	 *            减数
+	 * @return 运算结果
+	 * @author suntg
+	 */
+	public static double sub(Double d1, Double d2) {
+		BigDecimal b1 = new BigDecimal(Double.toString(d1));
+		BigDecimal b2 = new BigDecimal(Double.toString(d2));
+		return b1.subtract(b2).doubleValue();
+	}
+
+	/**
+	 * Double 型乘法运算
+	 * 
+	 * @param d1
+	 *            第一个乘数
+	 * @param d2
+	 *            第二个乘数
+	 * @return 运算结果
+	 * @author suntg
+	 */
+	public static double mul(Double d1, Double d2) {
+		BigDecimal b1 = new BigDecimal(Double.toString(d1));
+		BigDecimal b2 = new BigDecimal(Double.toString(d2));
+		return b1.multiply(b2).doubleValue();
+	}
+
+	/**
+	 * Double 型除法运算
+	 * 
+	 * @param d1
+	 *            被除数
+	 * @param d2
+	 *            除数
+	 * @param scale
+	 *            小数点四舍五入精度
+	 * @return 运算结果
+	 * @author suntg
+	 */
+	public static double div(Double d1, Double d2, int scale) {
+		if (scale < 0) {
+			throw new IllegalArgumentException("四舍五入精度必须大于0");
+		}
+		if (d2.doubleValue() == 0) {
+			throw new IllegalArgumentException("被除数不能为0");
+		}
+		BigDecimal b1 = new BigDecimal(Double.toString(d1));
+		BigDecimal b2 = new BigDecimal(Double.toString(d2));
+		return b1.divide(b2, scale, BigDecimal.ROUND_HALF_UP).doubleValue();
+	}
+
+	/**
+	 * 默认小数点四舍五入精度为6的Double型除法运算
+	 * 
+	 * @param d1
+	 *            被除数
+	 * @param d2
+	 *            除数
+	 * @return 运算结果
+	 * @author suntg
+	 */
+	public static double div(Double d1, Double d2) {
+		return div(d1, d2, 6);
+	}
+
+	/**
+	 * 比较浮点型数值
+	 * 
+	 * @param paramDouble1
+	 * @param paramDouble2
+	 * @param paramInt
+	 *            精度
+	 * @return
+	 */
+	public static int compare(double paramDouble1, double paramDouble2, int paramInt) {
+		return Double.compare(formatDouble(paramDouble1, paramInt), formatDouble(paramDouble2, paramInt));
+	}
+
+}

+ 88 - 0
eis-wms/src/main/java/com/uas/eiswms/util/StringUtils.java

@@ -0,0 +1,88 @@
+package com.uas.eiswms.util;
+
+public class StringUtils {
+
+    public static boolean isEmpty(Object str) {
+        return (str == null || !hasText(str.toString()));
+    }
+
+    /**
+     * Check that the given {@code CharSequence} is neither {@code null} nor
+     * of length 0.
+     * <p>Note: this method returns {@code true} for a {@code CharSequence}
+     * that purely consists of whitespace.
+     * <p><pre class="code">
+     * StringUtils.hasLength(null) = false
+     * StringUtils.hasLength("") = false
+     * StringUtils.hasLength(" ") = true
+     * StringUtils.hasLength("Hello") = true
+     * </pre>
+     *
+     * @param str the {@code CharSequence} to check (may be {@code null})
+     * @return {@code true} if the {@code CharSequence} is not {@code null} and has length
+     * @see #hasText(String)
+     */
+    public static boolean hasLength(CharSequence str) {
+        return (str != null && str.length() > 0);
+    }
+
+    /**
+     * Check that the given {@code String} is neither {@code null} nor of length 0.
+     * <p>Note: this method returns {@code true} for a {@code String} that
+     * purely consists of whitespace.
+     *
+     * @param str the {@code String} to check (may be {@code null})
+     * @return {@code true} if the {@code String} is not {@code null} and has length
+     * @see #hasLength(CharSequence)
+     * @see #hasText(String)
+     */
+    public static boolean hasLength(String str) {
+        return hasLength((CharSequence) str);
+    }
+
+    /**
+     * Check whether the given {@code CharSequence} contains actual <em>text</em>.
+     * <p>More specifically, this method returns {@code true} if the
+     * {@code CharSequence} is not {@code null}, its length is greater than
+     * 0, and it contains at least one non-whitespace character.
+     * <p><pre class="code">
+     * StringUtils.hasText(null) = false
+     * StringUtils.hasText("") = false
+     * StringUtils.hasText(" ") = false
+     * StringUtils.hasText("12345") = true
+     * StringUtils.hasText(" 12345 ") = true
+     * </pre>
+     *
+     * @param str the {@code CharSequence} to check (may be {@code null})
+     * @return {@code true} if the {@code CharSequence} is not {@code null},
+     * its length is greater than 0, and it does not contain whitespace only
+     * @see Character#isWhitespace
+     */
+    public static boolean hasText(CharSequence str) {
+        if (!hasLength(str)) {
+            return false;
+        }
+        int strLen = str.length();
+        for (int i = 0; i < strLen; i++) {
+            if (!Character.isWhitespace(str.charAt(i))) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Check whether the given {@code String} contains actual <em>text</em>.
+     * <p>More specifically, this method returns {@code true} if the
+     * {@code String} is not {@code null}, its length is greater than 0,
+     * and it contains at least one non-whitespace character.
+     *
+     * @param str the {@code String} to check (may be {@code null})
+     * @return {@code true} if the {@code String} is not {@code null}, its
+     * length is greater than 0, and it does not contain whitespace only
+     * @see #hasText(CharSequence)
+     */
+    public static boolean hasText(String str) {
+        return hasText((CharSequence) str);
+    }
+}

+ 4 - 0
eis-wms/src/main/resources/application.properties

@@ -0,0 +1,4 @@
+server.port=8673
+
+datasourceConfig={"UAS_DEV"\:{"password"\:"select!#%*(","driverClassName"\:"oracle.jdbc.driver.OracleDriver","url"\:"jdbc\:oracle\:thin\:@192.168.253.6\:1521\:orcl","username"\:"UAS_DEV"},"UAS"\:{"password"\:"select\!\#%*(","driverClassName"\:"oracle.jdbc.driver.OracleDriver","url"\:"jdbc\:oracle\:thin\:@192.168.253.6\:1521\:orcl","username"\:"UAS"},\
+  "XKN_TEST"\:{"password"\:"select\!\#%*(","driverClassName"\:"oracle.jdbc.driver.OracleDriver","url"\:"jdbc\:oracle\:thin\:@127.0.0.1\:1521\:orcl","username"\:"XKN_TEST"}}

+ 44 - 0
eis-wms/src/main/resources/logback.xml

@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+	<appender name="FILE"
+		class="ch.qos.logback.core.rolling.RollingFileAppender">
+		<File>logs/log.log</File>
+		<encoder>
+			<pattern>
+				%date{yyyy-MM-dd HH:mm:ss:SSS} [%relative ms] %-5level [%50.50(%logger{36}.%method:%line)] ---- %msg%n
+			</pattern>
+			<charset>UTF-8</charset> <!-- 此处设置字符集 -->
+		</encoder>
+		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+			<!-- daily rollover -->
+			<FileNamePattern>logs/log.%d{yyyy-MM-dd}.log</FileNamePattern>
+			<!-- keep 10 days' worth of history -->
+			<maxHistory>10</maxHistory>
+		</rollingPolicy>
+		<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+			<level>INFO</level>
+		</filter>
+	</appender>
+
+	<!-- Console output -->
+	<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+		<!-- encoder defaults to ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
+		<encoder>
+			<pattern>
+				%date{yyyy-MM-dd HH:mm:ss:SSS} [%relative ms] %-5level [%50.50(%logger{36}.%method:%line)] ---- %msg%n
+			</pattern>
+			<charset>UTF-8</charset> <!-- 此处设置字符集 -->
+		</encoder>
+		<!-- Only log level WARN and above -->
+		<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+			<level>INFO</level>
+		</filter>
+	</appender>
+
+	<!-- Enable FILE and STDOUT appenders for all log messages. By default, 
+		only log at level INFO and above. -->
+	<root level="INFO">
+		<appender-ref ref="FILE" />
+		<appender-ref ref="STDOUT" />
+	</root>
+</configuration>