hu hace 6 meses
padre
commit
9e3dea9b1f

+ 36 - 2
src/custom/beans/stockbill/bills/BasicBill.java

@@ -6,9 +6,12 @@ import common.UserInfo;
 import common.YosException;
 import common.data.*;
 import common.data.db.DBConnect;
+import org.apache.commons.lang.StringUtils;
 
 import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.HashMap;
 
 public abstract class BasicBill {
@@ -80,16 +83,20 @@ public abstract class BasicBill {
         通用校验
          */
         if (ischeck) {
+            if(StringUtils.isBlank(period)){
+                 period = getPeriod(true,billRow.getDate("billdate"));
+                 dbConnect.runSqlUpdate("update st_stockbill set period='"+period+"' where st_stockbillid="+st_stockbillid);
+            }
             if (!status.equals("新建")) {
                 throw new YosException("单号为:【" + billno + "】的出入库单为非新建状态,无法审核");
             }
             RowsMap rowsMap = dbConnect.runSqlQuery("select CONCAT(year, '-',LPAD(month, 2, '0')) period,isclose from st_period").toRowsMap("period");
             if (rowsMap.containsKey(period)) {
                 if (rowsMap.get(period).toRowsMap("isclose").containsKey("1")) {
-                    throw new YosException("原单据会计期间已关闭,不可调整");
+                    throw new YosException("原单据会计期间已关闭,不可审核");
                 }
             } else {
-                throw new YosException("原单据会计期间未生成,不可调整");
+                throw new YosException("原单据会计期间未生成,不可审核");
             }
             if (itemRows.isEmpty()) {
                 throw new YosException("表体为空");
@@ -115,9 +122,21 @@ public abstract class BasicBill {
                 }
             }
         } else {
+            if(StringUtils.isBlank(period)){
+                period = getPeriod(true,billRow.getDate("billdate"));
+                dbConnect.runSqlUpdate("update st_stockbill set period='"+period+"' where st_stockbillid="+st_stockbillid);
+            }
             if (!status.equals("审核")) {
                 throw new YosException("单号为:【" + billno + "】的出入库单为非审核状态,无法反审核");
             }
+            RowsMap rowsMap = dbConnect.runSqlQuery("select CONCAT(year, '-',LPAD(month, 2, '0')) period,isclose from st_period").toRowsMap("period");
+            if (rowsMap.containsKey(period)) {
+                if (rowsMap.get(period).toRowsMap("isclose").containsKey("1")) {
+                    throw new YosException("原单据会计期间已关闭,不可反审核");
+                }
+            } else {
+                throw new YosException("单据日期所属会计期间未生成,不可反审核");
+            }
         }
     }
 
@@ -287,6 +306,21 @@ public abstract class BasicBill {
         codeRows = dbConnect.runSqlQuery("select t1.* from st_stockbill_items_sku t1 where t1.st_stockbillid ='" + st_stockbillid + "'");
     }
 
+    public String getPeriod(boolean isjudge , Date date) throws YosException {
+
+        String preioddate = new SimpleDateFormat("yyyy-MM-dd").format(date);
+        Rows rows =dbConnect.runSqlQuery("select CONCAT_WS('-', year, LPAD(month, 2, '0')) period from st_period where begdate<='"+preioddate+"' and enddate>='"+preioddate+"'");
+        if (rows.size() != 1) {
+            if(isjudge){
+                throw new YosException("单据日期所属会计期间未生成");
+            }else{
+                return "null";
+            }
+        } else {
+            return rows.get(0).getString("period");
+        }
+    }
+
 
     public abstract boolean isInStock(boolean fischeck);
 

+ 9 - 1
src/custom/restcontroller/webmanage/sale/order/Order.java

@@ -1621,6 +1621,9 @@ public class Order extends Controller {
         Rows rowsdetailsGrade = dbConnect.runSqlQuery("select sum(t1.qty) qty,t2.grade from sa_orderitems t1 " +
                 "left join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid " +
                 " where t1.sa_orderid=" + sa_orderid+" group by t2.grade");
+        Rows rowsGrade = dbConnect.runSqlQuery("select t1.rowno,t2.itemno,t2.itemname,t2.grade from sa_orderitems t1 " +
+                "left join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid " +
+                " where t1.sa_orderid=" + sa_orderid);
         Rows gradeQtyRows=dbConnect.runSqlQuery("select grade,sum(qty) qty from (select grade,t2.qty from st_stockbill t1 inner join st_stockbill_items t2 on t1.st_stockbillid=t2.st_stockbillid inner join plm_item t3 on t2.itemid=t3.itemid where t1.status='审核' and t1.type='销售出库' and t1.sys_enterpriseid='"+row.getLong("sys_enterpriseid")+"' and YEAR(t1.billdate) = YEAR(CURDATE())\n" +
                 "union all\n" +
                 "select grade,t2.qty  from sa_order t1 inner join sa_orderitems t2 on t1.sa_orderid=t2.sa_orderid inner join plm_item t3 on t2.itemid=t3.itemid where t1.status in('提交','审核') and t2.isclose=0 and t1.sys_enterpriseid='"+row.getLong("sys_enterpriseid")+"' and YEAR(t1.billdate) = YEAR(CURDATE())) t group by grade");
@@ -1646,7 +1649,12 @@ public class Order extends Controller {
 
                 }
                 if((gradeqty.add(qty)).compareTo((sumqty.add(sumqty_current)).multiply(rate).divide(BigDecimal.valueOf(100)))>0){
-                    return getErrReturnObject().setErrMsg(grade+"等级的商品总数超过本年提货比例上限").toString();
+                    for(Row rowdetail:rowsGrade){
+                        if(grade.equals(rowdetail.getString("grade"))){
+                            return getErrReturnObject().setErrMsg("行号"+rowdetail.getString("rowno")+",商品"+rowdetail.getString("itemno")+"超过年度提货比例").toString();
+                        }
+                    }
+
                 }
 
             }

+ 1 - 1
src/custom/restcontroller/webmanage/sale/sendrepair/sendrepair.java

@@ -78,7 +78,7 @@ public class sendrepair extends Controller {
         UpdateSQLdetail.setValue("duty", content.getStringValue("duty"));
         UpdateSQLdetail.setValue("reason", content.getStringValue("reason"));
         UpdateSQLdetail.setValue("demand", content.getStringValue("demand"));
-        UpdateSQLdetail.setValue("remarks",  content.getStringValue("remarks"));
+        UpdateSQLdetail.setValue("remarks",  content.getStringValue("remarksdetail"));
         UpdateSQLdetail.setValue("disposition", content.getStringValue("disposition"));
         UpdateSQLdetail.setValue("idearemarks", content.getStringValue("idearemarks"));
         UpdateSQLdetail.setValue("agentcost", content.getBigDecimal("agentcost"));

+ 8 - 4
src/custom/restcontroller/webmanage/sale/stockbill/stockbill.java

@@ -95,10 +95,10 @@ public class stockbill extends Controller {
             insertSQL.setValue("remarks", remarks);
             if (StringUtils.isBlank(billdate)) {
                 insertSQL.setDateValue("billdate");
-                insertSQL.setValue("period",getPeriod(new Date()));
+                insertSQL.setValue("period",getPeriod(false,new Date()));
             } else {
                 insertSQL.setValue("billdate", billdate);
-                insertSQL.setValue("period",getPeriod(content.getDate("billdate")));
+                insertSQL.setValue("period",getPeriod(false,content.getDate("billdate")));
             }
             if (type.equals("销售出库")) {
                 insertSQL.setValue("billno", createBillCode("stockbill"));
@@ -1205,12 +1205,16 @@ public class stockbill extends Controller {
         int size = a.size();
         return (String[]) a.toArray(new String[size]);
     }
-    public String getPeriod(Date date) throws YosException {
+    public String getPeriod(boolean isjudge ,Date date) throws YosException {
 
         String preioddate = new SimpleDateFormat("yyyy-MM-dd").format(date);
         Rows rows =dbConnect.runSqlQuery("select CONCAT_WS('-', year, LPAD(month, 2, '0')) period from st_period where begdate<='"+preioddate+"' and enddate>='"+preioddate+"'");
         if (rows.size() != 1) {
-            throw new YosException("该单据日期不存在对应的会计期间");
+            if(isjudge){
+                throw new YosException("单据日期所属会计期间未生成");
+            }else{
+                return "null";
+            }
         } else {
             return rows.get(0).getString("period");
         }

+ 1 - 0
src/custom/restcontroller/webmanage/sale/stockbill/stockbillitems.java

@@ -172,6 +172,7 @@ public class stockbillitems extends Controller {
                 insertSQL.setValue("rowno", maxid + i + 1);
                 insertSQL.setValue("st_stockbillid", st_stockbillid);
                 insertSQL.setValue("sa_orderitemsid", iteminfo.getLong("sa_orderitemsid"));
+                insertSQL.setValue("stockid", iteminfo.getLongValue("stockid"));
                 insertSQL.setValue("itemid", iteminfo.getStringValue("itemid"));
                 insertSQL.setValue("sa_orderid", iteminfo.getStringValue("sa_orderid"));
                 insertSQL.setValue("qty", iteminfo.getStringValue("qty"));