|
|
@@ -133,62 +133,24 @@ public class quarterpricenum extends Controller {
|
|
|
@CACHEING_CLEAN(apiClass = {quarterpricenum.class})
|
|
|
public String check() throws YosException {
|
|
|
Rows rows = dbConnect.runSqlQuery("select * from sa_quarterpricenum where status='新建' and siteid='" + siteid + "'");
|
|
|
- Rows agentRows = dbConnect.runSqlQuery("select sa_agentsid,year,quarter,pricerate from sa_agents where siteid='" + siteid + "' and sa_agentsid in (select sa_agentsid from sa_quarterpricenum where status='新建' and siteid='" + siteid + "')");
|
|
|
- RowsMap agentRowsMap = agentRows.toRowsMap("sa_agentsid");
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
for (Row row : rows) {
|
|
|
- if (agentRowsMap.containsKey(row.getString("sa_agentsid"))) {
|
|
|
- if (row.getBigDecimal("pricerate").compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
- UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_quarterpricenum");
|
|
|
- updateSQL.setUniqueid(row.getLong("sa_quarterpricenumid")).setSiteid(siteid);
|
|
|
- updateSQL.setValue("ischeck", true);
|
|
|
- updateSQL.setValue("isright", false);
|
|
|
- updateSQL.setValue("result", "价格系数不能小于0");
|
|
|
- updateSQL.setValue("status", "已检验");
|
|
|
- updateSQL.setDateValue("changedate");
|
|
|
- updateSQL.setDateValue("operatedate");
|
|
|
- updateSQL.setValue("changeby", username);
|
|
|
- sqlList.add(updateSQL.getSQL());
|
|
|
- } else {
|
|
|
- if (agentRowsMap.get(row.getString("sa_agentsid")).get(0).getLong("year") == row.getLong("year") &&
|
|
|
- agentRowsMap.get(row.getString("sa_agentsid")).get(0).getLong("quarter") == row.getLong("quarter") &&
|
|
|
- agentRowsMap.get(row.getString("sa_agentsid")).get(0).getBigDecimal("pricerate").compareTo(row.getBigDecimal("pricerate")) == 0) {
|
|
|
- UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_quarterpricenum");
|
|
|
- updateSQL.setUniqueid(row.getLong("sa_quarterpricenumid")).setSiteid(siteid);
|
|
|
- updateSQL.setValue("ischeck", true);
|
|
|
- updateSQL.setValue("isright", false);
|
|
|
- updateSQL.setValue("result", "原有系数:" + (agentRowsMap.get(row.getString("sa_agentsid")).get(0).getBigDecimal("pricerate").compareTo(BigDecimal.ZERO) == 0 ? 1 : agentRowsMap.get(row.getString("sa_agentsid")).get(0).getBigDecimal("pricerate")) + " , 待导入系数:" + row.getBigDecimal("pricerate"));
|
|
|
- updateSQL.setValue("status", "已检验");
|
|
|
- updateSQL.setDateValue("changedate");
|
|
|
- updateSQL.setDateValue("operatedate");
|
|
|
- updateSQL.setValue("changeby", username);
|
|
|
- sqlList.add(updateSQL.getSQL());
|
|
|
- } else {
|
|
|
- UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_quarterpricenum");
|
|
|
- updateSQL.setUniqueid(row.getLong("sa_quarterpricenumid")).setSiteid(siteid);
|
|
|
- updateSQL.setValue("ischeck", true);
|
|
|
- updateSQL.setValue("isright", true);
|
|
|
- updateSQL.setValue("result", "原有系数:" + (agentRowsMap.get(row.getString("sa_agentsid")).get(0).getBigDecimal("pricerate").compareTo(BigDecimal.ZERO) == 0 ? 1 : agentRowsMap.get(row.getString("sa_agentsid")).get(0).getBigDecimal("pricerate")) + " , 待导入系数:" + row.getBigDecimal("pricerate"));
|
|
|
- updateSQL.setValue("status", "已检验");
|
|
|
- updateSQL.setDateValue("changedate");
|
|
|
- updateSQL.setDateValue("operatedate");
|
|
|
- updateSQL.setValue("changeby", username);
|
|
|
- sqlList.add(updateSQL.getSQL());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_quarterpricenum");
|
|
|
- updateSQL.setUniqueid(row.getLong("sa_quarterpricenumid")).setSiteid(siteid);
|
|
|
- updateSQL.setValue("ischeck", true);
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_quarterpricenum");
|
|
|
+ updateSQL.setUniqueid(row.getLong("sa_quarterpricenumid")).setSiteid(siteid);
|
|
|
+ updateSQL.setValue("ischeck", true);
|
|
|
+ updateSQL.setValue("status", "已检验");
|
|
|
+ updateSQL.setDateValue("changedate");
|
|
|
+ updateSQL.setDateValue("operatedate");
|
|
|
+ updateSQL.setValue("changeby", username);
|
|
|
+ if (row.getBigDecimal("pricerate").compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
updateSQL.setValue("isright", false);
|
|
|
- updateSQL.setValue("result", "该经销商不存在");
|
|
|
- updateSQL.setValue("status", "已检验");
|
|
|
- updateSQL.setDateValue("changedate");
|
|
|
- updateSQL.setDateValue("operatedate");
|
|
|
- updateSQL.setValue("changeby", username);
|
|
|
- sqlList.add(updateSQL.getSQL());
|
|
|
+ updateSQL.setValue("result", "价格系数不能小于0");
|
|
|
+ } else {
|
|
|
+ Rows checkrows = dbConnect.runSqlQuery("select * from sa_quarterpricenum where status='已更新' and sa_agentsid='" + row.getString("sa_agentsid") + "' and `year`='" + row.getInteger("year") + "' and quarter='" + row.getInteger("quarter") + "' and pricerate=" + row.getBigDecimal("pricerate").doubleValue() + " order by changedate desc limit 1");
|
|
|
+ updateSQL.setValue("isright", checkrows.isEmpty());
|
|
|
+ updateSQL.setValue("result", "原有系数:" + (checkrows.get(0).getBigDecimal("pricerate").compareTo(BigDecimal.ZERO) == 0 ? 1 : checkrows.get(0).getBigDecimal("pricerate")) + " , 待导入系数:" + row.getBigDecimal("pricerate"));
|
|
|
}
|
|
|
+ sqlList.add(updateSQL.getSQL());
|
|
|
}
|
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
|
return getSucReturnObject().toString();
|
|
|
@@ -200,8 +162,8 @@ public class quarterpricenum extends Controller {
|
|
|
Rows rows = dbConnect.runSqlQuery("select * from sa_quarterpricenum where status='已检验' and ischeck=1 and isright=1 and siteid='" + siteid + "'");
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
for (Row row : rows) {
|
|
|
- sqlList.add("update sa_agents set year=" + row.getLong("year") + ",quarter=" + row.getLong("quarter") + ",pricerate=" + row.getBigDecimal("pricerate") + " where sa_agentsid=" + row.getLong("sa_agentsid"));
|
|
|
- sqlList.add("update sa_quarterpricenum set status='已更新' where sa_quarterpricenumid=" + row.getLong("sa_quarterpricenumid"));
|
|
|
+ // sqlList.add("update sa_agents set year=" + row.getLong("year") + ",quarter=" + row.getLong("quarter") + ",pricerate=" + row.getBigDecimal("pricerate") + " where sa_agentsid=" + row.getLong("sa_agentsid"));
|
|
|
+ sqlList.add("update sa_quarterpricenum set status='已更新' where sa_quarterpricenumid=" + row.getLong("sa_quarterpricenumid"));
|
|
|
}
|
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
|
return getSucReturnObject().toString();
|
|
|
@@ -212,16 +174,14 @@ public class quarterpricenum extends Controller {
|
|
|
@CACHEING_CLEAN(apiClass = {quarterpricenum.class})
|
|
|
public String delete() throws YosException {
|
|
|
long sa_quarterpricenumid = content.getLongValue("sa_quarterpricenumid");
|
|
|
- Rows RowsStatus = dbConnect.runSqlQuery(
|
|
|
- "select status from sa_quarterpricenum where sa_quarterpricenumid='" + sa_quarterpricenumid + "'");
|
|
|
+ Rows RowsStatus = dbConnect.runSqlQuery("select status from sa_quarterpricenum where sa_quarterpricenumid='" + sa_quarterpricenumid + "'");
|
|
|
if (RowsStatus.isNotEmpty()) {
|
|
|
if (RowsStatus.get(0).getString("status").equals("已更新")) {
|
|
|
return getErrReturnObject().setErrMsg("已更新状态的季度价格系数无法删除").toString();
|
|
|
}
|
|
|
}
|
|
|
ArrayList<String> list = new ArrayList<>();
|
|
|
- list.add("delete from sa_quarterpricenum where siteid='" + siteid
|
|
|
- + "' and sa_quarterpricenumid=" + sa_quarterpricenumid);
|
|
|
+ list.add("delete from sa_quarterpricenum where siteid='" + siteid + "' and sa_quarterpricenumid=" + sa_quarterpricenumid);
|
|
|
|
|
|
dbConnect.runSqlUpdate(list);
|
|
|
return getSucReturnObject().toString();
|
|
|
@@ -292,9 +252,7 @@ public class quarterpricenum extends Controller {
|
|
|
String year = row.getString("year");
|
|
|
String quarter = row.getString("quarter");
|
|
|
String pricerate = row.getString("pricerate");
|
|
|
- if (StringUtils.isEmpty(agentnum)
|
|
|
- || StringUtils.isEmpty(year)
|
|
|
- || StringUtils.isEmpty(quarter) || StringUtils.isEmpty(pricerate)) {
|
|
|
+ if (StringUtils.isEmpty(agentnum) || StringUtils.isEmpty(year) || StringUtils.isEmpty(quarter) || StringUtils.isEmpty(pricerate)) {
|
|
|
iserr = true;
|
|
|
row.put("msg", "错误信息:经销商编号/年份/季度/价格系数不能为空");
|
|
|
rowserr.add(row);
|
|
|
@@ -396,8 +354,7 @@ public class quarterpricenum extends Controller {
|
|
|
return getSucReturnObject().toString();
|
|
|
}
|
|
|
|
|
|
- public XSSFSheet addSheet(ExcelFactory excelFactory, String sheetname, Rows datarows,
|
|
|
- HashMap<String, String> titlemap) {
|
|
|
+ public XSSFSheet addSheet(ExcelFactory excelFactory, String sheetname, Rows datarows, HashMap<String, String> titlemap) {
|
|
|
ArrayList<String> keylist = datarows.getFieldList();
|
|
|
XSSFSheet sheet = excelFactory.getXssfWorkbook().createSheet(sheetname);
|
|
|
XSSFWorkbook xssfFWorkbook = excelFactory.getXssfWorkbook();
|