stockbill.java 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. package restcontroller.sale.stockbill;
  2. import com.alibaba.fastjson.JSONObject;
  3. import common.Controller;
  4. import common.YosException;
  5. import common.annotation.API;
  6. import common.data.QuerySQL;
  7. import common.data.Rows;
  8. import common.data.SQLFactory;
  9. import common.data.UpdateSQL;
  10. import restcontroller.R;
  11. import common.annotation.CACHEING;
  12. @API(title = "经销商到货确认单")
  13. public class stockbill extends Controller {
  14. public stockbill(JSONObject content) throws YosException {
  15. super(content);
  16. }
  17. @API(title = "经销商到货确认单查询", apiversion = R.ID2025061311114103.v1.class)
  18. @CACHEING
  19. public String queryStockbillList() throws YosException {
  20. StringBuffer where = new StringBuffer(" 1=1 ");
  21. if (content.containsKey("where")) {
  22. JSONObject whereObject = content.getJSONObject("where");
  23. if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
  24. where.append(" and(");
  25. where.append("t1.billno like'%").append(whereObject.getString("condition")).append("%' ");
  26. where.append("or t1.outplace like'%").append(whereObject.getString("condition")).append("%' ");
  27. where.append("or t3.agentnum like'%").append(whereObject.getString("condition")).append("%' ");
  28. where.append("or t2.enterprisename like'%").append(whereObject.getString("condition")).append("%' ");
  29. where.append("or t6.depname like'%").append(whereObject.getString("condition")).append("%' ");
  30. where.append(")");
  31. }
  32. if (whereObject.containsKey("rb") && !"".equals(whereObject.getString("rb"))) {
  33. where.append(" and t1.rb ='").append(whereObject.getString("rb")).append("' ");
  34. }
  35. if (whereObject.containsKey("isreceiver") && !"".equals(whereObject.getString("isreceiver"))) {
  36. where.append(" and t1.isreceiver ='").append(whereObject.getString("isreceiver")).append("' ");
  37. }
  38. if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
  39. where.append(" and DATE_FORMAT(t1.billdate, '%Y-%m-%d') >='").append(whereObject.getString("begindate")).append("' ");
  40. }
  41. if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
  42. where.append(" and DATE_FORMAT(t1.billdate, '%Y-%m-%d') <='").append(whereObject.getString("enddate")).append("' ");
  43. }
  44. if (whereObject.containsKey("remarks") && !"".equals(whereObject.getString("remarks"))) {
  45. where.append("and t1.remarks like'%").append(whereObject.getString("remarks")).append("%' ");
  46. }
  47. }
  48. // SQLFactory sqlFactory = new SQLFactory(this, "出入库单列表查询", pageSize, pageNumber, pageSorting);
  49. // sqlFactory.addParameter("siteid", siteid);
  50. // sqlFactory.addParameter_SQL("where", where);
  51. // Rows rows = dbConnect.runSqlQuery(sqlFactory);
  52. QuerySQL querySQL = queryStockbillList(where.toString());
  53. querySQL.setPage(pageSize, pageNumber);
  54. querySQL.setOrderBy(pageSorting);
  55. Rows rows = querySQL.query();
  56. return getSucReturnObject().setData(rows).toString();
  57. }
  58. public QuerySQL queryStockbillList(String where) throws YosException {
  59. QuerySQL querySQL = SQLFactory.createQuerySQL(this, "st_stockbill","*");
  60. querySQL.setTableAlias("t1");
  61. querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t2", "t1.sys_enterpriseid = t2.sys_enterpriseid AND t1.siteid = t2.siteid",
  62. "enterprisename", "abbreviation");
  63. querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t3", "t1.sys_enterpriseid = t3.sys_enterpriseid AND t1.siteid = t3.siteid",
  64. "agentnum");
  65. querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise_contacts", "t4", "t1.rec_contactsid=t4.contactsid and t1.siteid = t4.siteid");
  66. querySQL.addJoinTable(JOINTYPE.left, "sa_accountbalance", "t5", "t5.sys_enterpriseid=t1.sys_enterpriseid and t1.siteid = t5.siteid and t5.sa_accountclassid =(select t1.sa_accountclassid from sa_accountclass t1 where t1.siteid='"+siteid+"' and t1.accountname='现金账户')",
  67. "discountamount");
  68. querySQL.addJoinTable(JOINTYPE.left, "sys_department", "t6", "t1.departmentid=t6.departmentid and t1.siteid = t6.siteid",
  69. "depno","depname");
  70. querySQL.addQueryFields("recname", "t4.name");
  71. querySQL.addQueryFields("recphonenumber", "t4.phonenumber");
  72. querySQL.addQueryFields("recaddress", "t4.address");
  73. querySQL.setWhere("t1.siteid", siteid);
  74. querySQL.setWhere("t1.status='审核' and t1.type in ('销售出库','返修出库')");
  75. querySQL.setWhere("t1.sys_enterpriseid", sys_enterpriseid);
  76. querySQL.setWhere(where);
  77. return querySQL;
  78. }
  79. @API(title = "收货确认", apiversion = R.ID2025061311223103.v1.class)
  80. public String newApiMethod() throws YosException {
  81. Long st_stockbillid = content.getLong("st_stockbillid");
  82. boolean isreceiver = content.getBooleanValue("isreceiver");
  83. Rows rows = dbConnect.runSqlQuery("select * from st_stockbill where st_stockbillid ='"
  84. + st_stockbillid + "' and siteid='" + siteid + "'");
  85. if (rows.isEmpty()) {
  86. return getErrReturnObject().setErrMsg("该出入库单不存在")
  87. .toString();
  88. } else {
  89. if (!rows.get(0).getString("status").equals("审核")) {
  90. return getErrReturnObject().setErrMsg("单号为:【" + rows.get(0).getString("billno") + "】的出入库单为非审核状态,无法进行收货确认")
  91. .toString();
  92. }
  93. }
  94. UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "st_stockbill");
  95. updateSQL.setUniqueid(st_stockbillid);
  96. updateSQL.setSiteid(siteid);
  97. updateSQL.setValue("isreceiver", isreceiver);
  98. updateSQL.setValue("receiverby", username);
  99. updateSQL.setDateValue("receiverdate");
  100. dbConnect.runSqlUpdate(updateSQL.getSQL());
  101. return getSucReturnObject().toString();
  102. }
  103. }