de6e2ea7c1f5bbabdf8df8a6766656c87c753c85.svn-base 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. package UIM;
  2. import java.sql.SQLException;
  3. import java.text.SimpleDateFormat;
  4. import java.util.Calendar;
  5. import java.util.Iterator;
  6. import java.util.List;
  7. import java.util.Map;
  8. import CoreFS.SA01.CoreIComponent;
  9. import CoreFS.SA06.CoreReturnObject;
  10. /**
  11. * 库存区域信息维护类
  12. *
  13. * @author siy
  14. * @date 2010-8-4
  15. */
  16. public class UIM010010 extends CoreIComponent {
  17. /**
  18. * 查询区域信息
  19. *
  20. * @param areaType
  21. * 区域类型
  22. * @return CoreReturnObject
  23. * @throws SQLException
  24. */
  25. public CoreReturnObject queryYardArea(Integer areaType) throws SQLException {
  26. CoreReturnObject cro = new CoreReturnObject();
  27. // System.out.println("----------------------------------------");
  28. // String sql=this.getDao("KgDao").LoadSqlByDB(Sqlid);
  29. String sql = "select area_no,area_name,decode(area_type,'1','冷轧原料库'," +
  30. "'2','冷轧中间库','3','冷轧成品库') area_type,decode(h_sail,'0','否'," +
  31. "'1','是') h_sail,reg_id,reg_time,remark from c_tbk08_coil_yard_area";
  32. if (areaType.intValue() != 0) {
  33. sql += " where area_type = " + areaType.intValue();
  34. }
  35. sql += " order by area_no";
  36. cro = this.getDao("KgDao").ExcuteQuery(sql);
  37. System.out.println(cro);
  38. return cro;
  39. }
  40. /**
  41. * 新增区域
  42. * @param areaType 区域类型
  43. * @param areaName 区域名称
  44. * @param hSail 是否可用于外卖
  45. * @param remark 备注
  46. * @param userName 操作人
  47. * @return CoreReturnObject
  48. * @throws SQLException
  49. */
  50. public CoreReturnObject addArea(Integer areaType, String areaName,
  51. String hSail, String remark, String userName) throws SQLException {
  52. CoreReturnObject cro = new CoreReturnObject();
  53. long areaNo = queryMaxAreaNo() + 1;
  54. String regTime = new SimpleDateFormat("yyyyMMddHHmmss").format(Calendar
  55. .getInstance().getTime());
  56. String addSql = "insert into c_tbk08_coil_yard_area (AREA_NO,AREA_NAME,"
  57. + "AREA_TYPE,H_SAIL,REG_ID,REG_TIME,REMARK) values ("
  58. + areaNo + ",'" + areaName + "','" + areaType.intValue() + "','" + hSail + "',"
  59. + "'" + userName + "','" + regTime + "','" + remark + "')";
  60. cro = this.getDao("KgDao").ExcuteNonQuery(addSql);
  61. return cro;
  62. }
  63. /**
  64. * 修改区域
  65. * @param areaNo 区域编号
  66. * @param areaType 区域类型
  67. * @param areaName 区域名称
  68. * @param hSail 是否可用于外卖
  69. * @param remark 备注
  70. * @param userName 操作人
  71. * @return CoreReturnObject
  72. * @throws SQLException
  73. */
  74. public CoreReturnObject updateArea(Long areaNo, Integer areaType, String areaName,
  75. String hSail, String remark, String userName) throws SQLException {
  76. CoreReturnObject cro = new CoreReturnObject();
  77. String regTime = new SimpleDateFormat("yyyyMMddHHmmss").format(Calendar
  78. .getInstance().getTime());
  79. String updSql = "update c_tbk08_coil_yard_area set area_name = ?,area_type = ?," +
  80. "h_sail = ?,mod_id = ?,mod_time = ?,remark = ? where area_no = ?";
  81. cro = this.getDao("KgDao").ExcuteNonQuery(updSql,new Object[]{areaName,areaType,
  82. hSail,userName,regTime,remark,areaNo});
  83. return cro;
  84. }
  85. /**
  86. * 删除区域信息
  87. *
  88. * @param areaNos
  89. * 区域编号字符串(多个以‘|’分隔)
  90. * @return CoreReturnObject
  91. * @throws SQLException
  92. */
  93. public CoreReturnObject delArea(String areaNos) throws SQLException {
  94. String[] areaNoArray = areaNos.split("\\|");
  95. CoreReturnObject cro = new CoreReturnObject();
  96. String sql = "delete from c_tbk08_coil_yard_area where area_no in (";
  97. for (int i = 0; i < areaNoArray.length; i++) {
  98. if (i < areaNoArray.length - 1) {
  99. sql += Long.parseLong(areaNoArray[i]) + ",";
  100. } else {
  101. sql += Long.parseLong(areaNoArray[i]);
  102. }
  103. }
  104. sql += ")";
  105. cro = this.getDao("KgDao").ExcuteNonQuery(sql);
  106. return cro;
  107. }
  108. /**
  109. * 判断区域下是否存在垛位
  110. *
  111. * @param areaNo
  112. * 区域编号
  113. * @return CoreReturnObject
  114. * @throws SQLException
  115. */
  116. public CoreReturnObject hasYardInArea(Long areaNo) throws SQLException {
  117. long areaId = areaNo.longValue();
  118. CoreReturnObject cro = new CoreReturnObject();
  119. String sql = "select count(1) as count from c_tbk08_coil_yard y inner join "
  120. + "c_tbk08_coil_yard_area a on y.area_no = a.area_no and a.area_no = "
  121. + areaId;
  122. List list = this.getDao("KgDao").ExcuteQueryReturnList(sql,
  123. new Object[] {});// .ExcuteQuery(sql);
  124. int count = 0;
  125. Iterator it = list.iterator();
  126. while (it.hasNext()) {
  127. Map map = (Map) it.next();
  128. count = Integer.parseInt(map.get("count").toString());
  129. }
  130. // System.out.println(count);
  131. cro.setResult(count);
  132. return cro;
  133. }
  134. private long queryMaxAreaNo() throws SQLException {
  135. String sql = "select max(AREA_NO) as area_no from c_tbk08_coil_yard_area";
  136. List list = this.getDao("KgDao").ExcuteQueryReturnList(sql,
  137. new Object[] {});// .ExcuteQuery(sql);
  138. long areaNo = 0;
  139. Iterator it = list.iterator();
  140. while (it.hasNext()) {
  141. Map map = (Map) it.next();
  142. areaNo = Long.parseLong(map.get("area_no").toString());
  143. }
  144. return areaNo;
  145. }
  146. }