| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- package UIM;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.util.ArrayList;
- import java.util.Iterator;
- import java.util.List;
- import java.util.Map;
- import CoreFS.SA01.CoreIComponent;
- import CoreFS.SA06.CoreReturnObject;
- /**
- * 垛位信息维护类
- *
- * @author siy
- * @date 2010-8-4
- */
- public class UIM010020 extends CoreIComponent {
- /**
- * 查询垛位信息
- *
- * @param nodeType
- * 节点类型
- * @param areaNo
- * 区域编号
- * @return CoreReturnObject
- * @throws SQLException
- */
- public CoreReturnObject queryYard(Integer nodeType, String areaNo)
- throws SQLException {
- CoreReturnObject cro = new CoreReturnObject();
- String sql = "select a.clf_no,a.clf_name,a.clf_row,a.clf_col,a.clf_fl,a.area_no,b.area_name,a.reg_id,a.reg_time,a.remark,a.coil_no "
- + "from c_tbk08_coil_yard a,c_tbk08_coil_yard_area b where a.area_no=b.area_no";
- if (2 == nodeType.intValue()) {
- sql += " and b.area_no = " + Long.parseLong(areaNo);
- } else if (1 == nodeType.intValue()) {
- int areaType = Integer.parseInt(areaNo.replaceAll("type", ""));
- sql += " and b.area_no in(select area_no from c_tbk08_coil_yard_area where area_type = "
- + areaType + ")";
- }
- sql += " order by a.clf_no";
- cro = this.getDao("KgDao").ExcuteQuery(sql);
- return cro;
- }
- /**
- * 查询区域信息树形数据
- *
- * @return CoreReturnObject
- * @throws SQLException
- */
- public CoreReturnObject quereAreaTree() throws SQLException {
- CoreReturnObject cro = new CoreReturnObject();
- String sql = "select distinct('type' || area_type) treeId,("
- + "case when area_type = 1 then '冷轧原料库' "
- + "when area_type = 2 then '冷轧中间库' "
- + "when area_type = 3 then '冷轧成品库' end) "
- + "treeName,'-1' parentId from c_tbk08_coil_yard_area union "
- + "select to_char(area_no) treeId,area_name treeName,'type' || area_type parentId "
- + "from c_tbk08_coil_yard_area";
- cro = this.getDao("KgDao").ExcuteQuery(sql);
- System.out.println(cro);
- return cro;
- }
- /**
- * 删除垛位信息
- *
- * @param yardNos
- * 垛位编号字符串(多个以‘|’分隔)
- * @return CoreReturnObject
- * @throws SQLException
- */
- public CoreReturnObject delYard(String yardNos) throws SQLException {
- String[] yardNoArray = yardNos.split("\\|");
- CoreReturnObject cro = new CoreReturnObject();
- String sql = "delete from c_tbk08_coil_yard where clf_no in (";
- for (int i = 0; i < yardNoArray.length; i++) {
- if (i < yardNoArray.length - 1) {
- sql += Long.parseLong(yardNoArray[i]) + ",";
- } else {
- sql += Long.parseLong(yardNoArray[i]);
- }
- }
- sql += ")";
- cro = this.getDao("KgDao").ExcuteNonQuery(sql);
- return cro;
- }
- /**
- * 添加垛位
- *
- * @param clfName
- * @param clfRow
- * @param clfCol
- * @param clfFl
- * @param remark
- * @param areaNo
- * @param regId
- * @return
- * @throws SQLException
- */
- public CoreReturnObject addYard(String clfName, String clfRow,
- String clfCol, String clfFl, String remark, String areaNo,
- String regId) throws SQLException {
- CoreReturnObject cro = new CoreReturnObject();
- long clfNo = this.queryMaxYardNo() + 1;
- StringBuffer sqlBuffer = new StringBuffer();
- sqlBuffer.append("insert into c_tbk08_coil_yard\n");
- sqlBuffer
- .append(" (clf_no,clf_name,clf_row,clf_col,clf_fl,area_no,reg_id,reg_time,remark)\n");
- sqlBuffer
- .append(" values(?,?,?,?,?,?,?,TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS'),?)\n");
- cro = this.getDao("KgDao").ExcuteNonQuery(
- sqlBuffer.toString(),
- new Object[] { clfNo, clfName, clfRow, clfCol, clfFl, areaNo,
- regId, remark });
- return cro;
- }
- public CoreReturnObject updateYard(String clfNo, String clfName,
- String clfRow, String clfCol, String clfFl, String remark,
- String areaNo, String regId) throws SQLException {
- CoreReturnObject cro = new CoreReturnObject();
- StringBuffer sqlBuffer = new StringBuffer();
- sqlBuffer.append("update c_tbk08_coil_yard set\n");
- sqlBuffer.append(" clf_name=?,clf_row=?,clf_col=?,clf_fl=?,\n");
- sqlBuffer.append(" area_no=?,mod_id=?,\n");
- sqlBuffer.append(" mod_time=TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS'),\n");
- sqlBuffer.append(" remark=?\n");
- sqlBuffer.append(" where clf_no = ?\n");
- cro = this.getDao("KgDao").ExcuteNonQuery(
- sqlBuffer.toString(),
- new Object[] { clfName, Integer.parseInt(clfRow, 10),
- Integer.parseInt(clfCol, 10),
- Integer.parseInt(clfFl, 10),
- Long.parseLong(areaNo, 10), regId, remark,
- Long.parseLong(clfNo, 10) });
- return cro;
- }
- public CoreReturnObject queryAreaInfo(String areaNo) throws SQLException {
- CoreReturnObject cro = new CoreReturnObject();
- StringBuffer sqlBuffer = new StringBuffer();
- sqlBuffer.append("select a.area_no,a.area_name\n");
- sqlBuffer.append(" from c_tbk08_coil_yard_area a\n");
- sqlBuffer.append(" where a.area_type = (\n");
- sqlBuffer.append(" select area_type from\n");
- sqlBuffer.append(" c_tbk08_coil_yard_area\n");
- sqlBuffer.append(" where area_no = ?)\n");
- cro = this.getDao("KgDao").ExcuteQuery(sqlBuffer.toString(),
- new Object[] { areaNo });
- return cro;
- }
- private long queryMaxYardNo(){
- String sql = "select max(CLF_NO) as clf_no from c_tbk08_coil_yard";
- long clfNo = 0;
-
- try{
- List list = this.getDao("KgDao").ExcuteQueryReturnList(sql,
- new Object[] {});// .ExcuteQuery(sql);
- Iterator it = list.iterator();
- while (it.hasNext()) {
- Map map = (Map) it.next();
- clfNo = Long.parseLong(map.get("clf_no").toString());
- }
- }
- catch(Exception e)
- {
-
- }
- return clfNo;
- }
- }
|