|
|
@@ -1557,159 +1557,7 @@ public class Contract extends Controller {
|
|
|
}
|
|
|
|
|
|
|
|
|
- @API(title = "复制", apiversion = R.ID20240102135104.v1.class)
|
|
|
- @CACHEING_CLEAN(apiversions = {R.ID20221219141702.v1.class, R.ID20221121195102.class, R.ID20221121201502.class, R.ID20221122165302.class, R.ID20221223102102.class, R.ID20220930103501.class, R.ID20221121195102.class})
|
|
|
- public String copy() throws YosException {
|
|
|
- Long copyContractid = content.getLong("sa_contractid");
|
|
|
- Rows contractRows = dbConnect.runSqlQuery("select * from sa_contract where siteid='" + siteid + "' and sa_contractid=" + copyContractid);
|
|
|
- if (contractRows.isEmpty()) {
|
|
|
- return getReturnObject().setCode("0205", new String[0]).toString();//无效合同
|
|
|
-
|
|
|
- }
|
|
|
- Row contractRow = contractRows.get(0);
|
|
|
- ArrayList<String> sqlList = new ArrayList<>();
|
|
|
- String type = contractRow.getString("type");
|
|
|
- long sys_enterpriseid = contractRow.getLong("sys_enterpriseid");
|
|
|
-// if (type.equals("居间")) {
|
|
|
-// return getReturnObject().setCode("0208", new String[0]).toString();//当前项目合同已存在居间协议
|
|
|
-// }
|
|
|
- long sa_contractid = createTableID("sa_contract");
|
|
|
- String billno = createBillCode("contractbill");
|
|
|
- sqlList.addAll(DataTeam.createTeamSQL(this, "sa_contract", sa_contractid, userid));
|
|
|
- sqlList.addAll(DataTeam.createTeamMemberSql(this, "sa_contract", sa_contractid, userid));
|
|
|
-
|
|
|
- SQLFactory sqlFactory = new SQLFactory(this, "合同-新增");
|
|
|
-
|
|
|
- sqlFactory.addParameter("sa_brandid", contractRow.getString("sa_brandid"));
|
|
|
- sqlFactory.addParameter("tradefield", contractRow.getString("tradefield"));
|
|
|
- sqlFactory.addParameter("siteid", siteid);
|
|
|
- sqlFactory.addParameter("userid", userid);
|
|
|
- sqlFactory.addParameter("username", username);
|
|
|
- sqlFactory.addParameter("departmentid", departmentid);
|
|
|
- sqlFactory.addParameter("sa_contractid", sa_contractid);
|
|
|
- //工程项目表ID
|
|
|
- sqlFactory.addParameter("sa_projectid", contractRow.getLong("sa_projectid"));
|
|
|
- //合同编号
|
|
|
- sqlFactory.addParameter("billno", billno);
|
|
|
- //合同类型(项目、框架、居间、工具借用)
|
|
|
- sqlFactory.addParameter("type", type);
|
|
|
- //生效日期
|
|
|
- sqlFactory.addParameter("begdate", contractRow.getString("begdate"));
|
|
|
- //截止日期
|
|
|
- sqlFactory.addParameter("enddate", contractRow.getString("enddate"));
|
|
|
- //sys_enterpriseid
|
|
|
- sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
|
|
|
- //折扣率
|
|
|
- sqlFactory.addParameter("discountrate", contractRow.getBigDecimal("discountrate"));
|
|
|
- //销售人员hrid,业务员hrid
|
|
|
- sqlFactory.addParameter("saler_hrid", contractRow.getLong("saler_hrid"));
|
|
|
- //签约时间
|
|
|
- sqlFactory.addParameter("signdate", contractRow.getString("signdate"));
|
|
|
- //signby
|
|
|
- sqlFactory.addParameter("signby", contractRow.getString("signby"));
|
|
|
- //计算方式
|
|
|
- sqlFactory.addParameter("calculatemodel", contractRow.getInteger("calculatemodel"));
|
|
|
- //订单金额比例
|
|
|
- sqlFactory.addParameter("orderratio", contractRow.getBigDecimal("orderratio"));
|
|
|
- //产品折扣
|
|
|
- sqlFactory.addParameter("productdiscount", contractRow.getBigDecimal("productdiscount"));
|
|
|
- //备注说明
|
|
|
- sqlFactory.addParameter("remarks", contractRow.getString("remarks"));
|
|
|
- //标题
|
|
|
- sqlFactory.addParameter("title", contractRow.getString("title"));
|
|
|
- //合同类型明细
|
|
|
- sqlFactory.addParameter("typemx", contractRow.getString("typemx"));
|
|
|
- //归属合同ID,关联合同ID
|
|
|
- sqlFactory.addParameter("ascription_contractid", contractRow.getLong("ascription_contractid"));
|
|
|
- //收货联系人信息
|
|
|
- sqlFactory.addParameter("rec_contactsid", contractRow.getLong("rec_contactsid"));
|
|
|
- //付款方式
|
|
|
- sqlFactory.addParameter("paytype", contractRow.getString("paytype"));
|
|
|
- //发货提醒天数
|
|
|
- sqlFactory.addParameter("reminddays", contractRow.getLong("reminddays"));
|
|
|
- sqlList.add(sqlFactory.getSQL());
|
|
|
- sqlList.add(DataContrlLog.createLog(this, "sa_contract", sa_contractid, "新建", "新建合同" + billno).getSQL());
|
|
|
-
|
|
|
- Rows itemsaleclassRows = dbConnect.runSqlQuery("select * from sa_contract_itemsaleclass where siteid='" + siteid + "' and sa_contractid=" + copyContractid);
|
|
|
- for (Row itemsaleclassRow : itemsaleclassRows) {
|
|
|
- sqlFactory = new SQLFactory(this, "合同-营销类别价格协议-新增");
|
|
|
- Long sa_contract_itemsaleclassid = createTableID("sa_contract_itemsaleclass");
|
|
|
- sqlFactory.addParameter("siteid", siteid);
|
|
|
- sqlFactory.addParameter("userid", userid);
|
|
|
- sqlFactory.addParameter("username", username);
|
|
|
- sqlFactory.addParameter("sa_contract_itemsaleclassid", sa_contract_itemsaleclassid);
|
|
|
- sqlFactory.addParameter("sa_contractid", sa_contractid);
|
|
|
- sqlFactory.addParameter("itemclassid", itemsaleclassRow.getLong("itemclassid"));
|
|
|
- sqlFactory.addParameter("discountrate", itemsaleclassRow.getBigDecimal("discountrate"));
|
|
|
- sqlFactory.addParameter("remarks", itemsaleclassRow.getString("remarks"));
|
|
|
- sqlList.add(sqlFactory.getSQL());
|
|
|
- }
|
|
|
|
|
|
- Rows itemRows = dbConnect.runSqlQuery("select t1.*,t2.orderminqty from sa_contract_items t1 left join plm_item t2 on t1.siteid=t2.siteid and t1.itemid=t2.itemid where t1.siteid='" + siteid + "' and t1.sa_contractid=" + copyContractid);
|
|
|
- for (Row itemRow : itemRows) {
|
|
|
- BigDecimal qty = itemRow.getBigDecimal("qty");
|
|
|
- BigDecimal orderminqty = itemRow.getBigDecimal("orderminqty");
|
|
|
- sqlFactory = new SQLFactory(this, "合同商品价格协议表");
|
|
|
- sqlFactory.addParameter("siteid", siteid);
|
|
|
- sqlFactory.addParameter("username", username);
|
|
|
- sqlFactory.addParameter("userid", userid);
|
|
|
- sqlFactory.addParameter("sa_contract_itemsid", createTableID("sa_contract_items"));
|
|
|
- sqlFactory.addParameter("sa_contractid", sa_contractid);
|
|
|
- sqlFactory.addParameter("itemid", itemRow.getLong("itemid"));
|
|
|
- sqlFactory.addParameter("price", itemRow.getBigDecimal("price"));
|
|
|
- sqlFactory.addParameter("type", itemRow.getString("type"));
|
|
|
- sqlFactory.addParameter("discountrate", itemRow.getBigDecimal("discountrate"));
|
|
|
- sqlFactory.addParameter("qty", qty.compareTo(orderminqty) > 0 ? qty : orderminqty);
|
|
|
- sqlFactory.addParameter("marketprice", itemRow.getBigDecimal("marketprice"));
|
|
|
- sqlList.add(sqlFactory.getSQL());
|
|
|
- }
|
|
|
-
|
|
|
- if (type.equals("框架") || type.equals("直销")) {
|
|
|
- Rows targetbillRows = dbConnect.runSqlQuery("select distinct t1.sa_salestargetbillid,t1.targettype,t1.year,t1.status,t1.sys_enterpriseid,t1.tradefield from sa_salestargetbill t1 inner join sa_salestarget t2 on t1.siteid=t2.siteid and t1.sa_salestargetbillid=t2.sa_salestargetbillid where t1.siteid='" + siteid + "' and t2.sys_enterpriseid=" + sys_enterpriseid + " and t2.targettype='企业目标' and t2.sa_contractid=" + copyContractid);
|
|
|
- for (Row targetbillRow : targetbillRows) {
|
|
|
- Long sa_salestargetbillid = createTableID("sa_salestargetbill");
|
|
|
- sqlFactory = new SQLFactory(this, "创建新年度");
|
|
|
- sqlFactory.addParameter("siteid", siteid);
|
|
|
- sqlFactory.addParameter("sa_salestargetbillid", sa_salestargetbillid);
|
|
|
- sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
|
|
|
- sqlFactory.addParameter("username", username);
|
|
|
- sqlFactory.addParameter("userid", userid);
|
|
|
- sqlFactory.addParameter("year", targetbillRow.getString("year"));
|
|
|
- sqlFactory.addParameter("targettype", "企业目标");
|
|
|
- sqlFactory.addParameter("tradefield", targetbillRow.getString("tradefield"));
|
|
|
- sqlList.add(sqlFactory.getSQL());
|
|
|
-
|
|
|
- SQLFactory saleFactory = new SQLFactory(this, "企业范围新增");
|
|
|
- saleFactory.addParameter("siteid", siteid);
|
|
|
- saleFactory.addParameter("sa_salestargethrid", createTableID("sa_salestargethr"));
|
|
|
- saleFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
|
|
|
- saleFactory.addParameter("sa_salestargetbillid", sa_salestargetbillid);
|
|
|
- sqlList.add(saleFactory.getSQL());
|
|
|
-
|
|
|
- Rows targetRows = dbConnect.runSqlQuery("select * from sa_salestarget where sa_salestargetbillid=" + targetbillRow.getLong("sa_salestargetbillid") + " and siteid='" + siteid + "' AND sys_enterpriseid=" + sys_enterpriseid + " and sa_contractid=" + copyContractid + " and targettype='企业目标'");
|
|
|
- for (Row targetRow : targetRows) {
|
|
|
- SQLFactory targetFactory = new SQLFactory(this, "企业-目标明细新增");
|
|
|
- targetFactory.addParameter("siteid", siteid);
|
|
|
- targetFactory.addParameter("sa_salestargetid", createTableID("sa_salestarget"));
|
|
|
- targetFactory.addParameter("type", targetRow.getString("type"));
|
|
|
- targetFactory.addParameter("point", targetRow.getString("point"));
|
|
|
- targetFactory.addParameter("targettype", "企业目标");
|
|
|
- targetFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
|
|
|
- targetFactory.addParameter("sa_salestargetbillid", sa_salestargetbillid);
|
|
|
- targetFactory.addParameter("year", targetRow.getString("year"));
|
|
|
- targetFactory.addParameter("sa_contractid", sa_contractid);
|
|
|
- targetFactory.addParameter("createby", username);
|
|
|
- targetFactory.addParameter("target_l", targetRow.getBigDecimal("target_l"));
|
|
|
- targetFactory.addParameter("target_h", targetRow.getBigDecimal("target_h"));
|
|
|
- targetFactory.addParameter("tradefield", targetRow.getString("tradefield"));
|
|
|
- sqlList.add(targetFactory.getSQL());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- dbConnect.runSqlUpdate(sqlList);
|
|
|
- content.put("sa_contractid", sa_contractid);
|
|
|
- return new Contract2( content).detail();
|
|
|
- }
|
|
|
|
|
|
@API(title = "批量修改类型", apiversion = R.ID20240110154404.v1.class)
|
|
|
@CACHEING_CLEAN(apiversions = {R.ID20221219141702.v1.class, R.ID20221121195102.class, R.ID20221121201502.class, R.ID20221122165302.class, R.ID20230221151903.v1.class})
|