Commit 89cd022b authored by 张永's avatar 张永

select 走读库

parent fecc57b5
......@@ -6,6 +6,7 @@ import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import com.aliyuncs.utils.StringUtils;
......@@ -21,6 +22,11 @@ public class ActivityServiceImpl implements ActivityService {
@Autowired
private JdbcTemplate jdbcTemplate;
@Autowired
@Qualifier("readonly")
private JdbcTemplate readJdbcTemplate;
/**
* 众筹项目列表
* <p>Title: </p>
......@@ -31,11 +37,11 @@ public class ActivityServiceImpl implements ActivityService {
*/
public List<Map<String, Object>> crowdFundingsProjectList(Map<String, Object> params, Page page) {
String orgNo = params.get("orgNO")+"";
jdbcTemplate.setDialect(new SqlServerDialect());
readJdbcTemplate.setDialect(new SqlServerDialect());
String sql = projectSql(orgNo, "");
List<Map<String,Object>> list = jdbcTemplate.limit(sql, page);
List<Map<String,Object>> list = readJdbcTemplate.limit(sql, page);
// if(list != null && list.size()>0) {
// for(Map<String,Object> map:list) {
// String projectId = map.get("ProjectID")+"";
......@@ -62,10 +68,10 @@ public class ActivityServiceImpl implements ActivityService {
public Map<String, Object> crowdFundingsProjectDetail(Map<String, Object> params) {
String projectId = params.get("projectId")+"";
String orgNo = params.get("orgNo")+"";
jdbcTemplate.setDialect(new SqlServerDialect());
readJdbcTemplate.setDialect(new SqlServerDialect());
String projectSql = projectSql(orgNo, projectId);
Map<String,Object> projectMap = jdbcTemplate.queryForMap(projectSql);
Map<String,Object> projectMap = readJdbcTemplate.queryForMap(projectSql);
String sql = "SELECT PlanID = a.nPlanID,ProjectID = a.nProjectID,PlanName = a.sPlanName, PlanSummary = a.sPlanSummary,PlanUrl = a.sUrl,AgentContractNO = a.sAgentContractNO, "
+ " GoodsID = a.nGoodsID, GoodsNO = acg.sGoodsNO,GoodsDesc = acg.sGoodsDesc,PlanStock = a.nPlanStock, PlanPrice = a.nPrice,LimitQty = a.nLimitQty, "
+ " PlanReturnDays = (select datediff(dd, dEndDate, dReturnDate) from tZHCProject p where p.nProjectID = a.nProjectID), LastUpdateTime = a.dLastUpdateTime ,SaleCount = 0 "
......@@ -73,9 +79,9 @@ public class ActivityServiceImpl implements ActivityService {
+ " WHERE a.nProjectID = ? ";
String sql0 = "select so.nPlanID, sum(so.nTotalSaleQty) nSaleQty from tSalesOrder so, tZHCPlan p where so.sB2BOrderTypeID = '3' and so.nPlanID = p.nPlanID and p.nProjectID = " + projectId + " group by so.nPlanID";
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql0);
List<Map<String, Object>> list = readJdbcTemplate.queryForList(sql0);
Map<String, Map<String, Object>> mm = Util.listToMM(list, "nPlanID");
List<Map<String,Object>> goodsList = jdbcTemplate.queryForList(sql,projectId);
List<Map<String,Object>> goodsList = readJdbcTemplate.queryForList(sql,projectId);
for(Map<String, Object> map : goodsList) {
Object PlanID = map.get("PlanID");
Map<String, Object> mmm = mm.get("" + PlanID);
......
......@@ -9,6 +9,7 @@ import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import com.egolm.common.bean.Rjx;
......@@ -27,6 +28,12 @@ public class BrandServiceImpl implements BrandService {
private static final Log logger = LogFactory.getLog(BrandServiceImpl.class);
@Autowired
private JdbcTemplate jdbcTemplate;
@Autowired
@Qualifier("readonly")
private JdbcTemplate readJdbcTemplate;
@Autowired
private UserService userService;
/*
......@@ -46,8 +53,8 @@ public class BrandServiceImpl implements BrandService {
}else {
sql +=" AND sOrgList like '%"+orgNO+"%' ";
}
jdbcTemplate.setDialect(new SqlServerDialect());
return jdbcTemplate.limit(sql, page);
readJdbcTemplate.setDialect(new SqlServerDialect());
return readJdbcTemplate.limit(sql, page);
}
@Override
......@@ -69,8 +76,8 @@ public class BrandServiceImpl implements BrandService {
+ "b.sBrandName, "
+ "b.sLogoUrl ";
String orgNo=(String) map.get("orgNo");
jdbcTemplate.setDialect(new SqlServerDialect());
return jdbcTemplate.limit(sql, page,orgNo);
readJdbcTemplate.setDialect(new SqlServerDialect());
return readJdbcTemplate.limit(sql, page,orgNo);
}
@Override
......@@ -98,7 +105,7 @@ public class BrandServiceImpl implements BrandService {
+ "ORDER BY "
+ "b.nSort desc, "
+ "b.sPinyinCode ";
return jdbcTemplate.queryForList(sql, orgNo);
return readJdbcTemplate.queryForList(sql, orgNo);
}
......
......@@ -6,6 +6,7 @@ import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONArray;
......@@ -23,6 +24,12 @@ public class CartServiceImpl implements CartService {
@Autowired
private JdbcTemplate jdbcTemplate;
@Autowired
@Qualifier("readonly")
private JdbcTemplate readJdbcTemplate;
@Autowired
private CartQueryService cartRedisService;
......@@ -117,7 +124,7 @@ public class CartServiceImpl implements CartService {
* @throws
*/
public Map<String, Object> count(String orgNo, String shopNO) {
return jdbcTemplate.queryForMap("select count(nSaleQty) totalCount , isnull(sum(nSaleQty), 0) totalSaleQty from V_Cart where sOrgNO = '" + orgNo + "' and sShopNO = '" + shopNO + "'");
return readJdbcTemplate.queryForMap("select count(nSaleQty) totalCount , isnull(sum(nSaleQty), 0) totalSaleQty from V_Cart where sOrgNO = '" + orgNo + "' and sShopNO = '" + shopNO + "'");
}
......
......@@ -4,6 +4,7 @@ import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import com.egolm.common.jdbc.JdbcTemplate;
......@@ -15,18 +16,22 @@ public class CategoryServiceImpl implements CategoryService {
@Autowired
private JdbcTemplate jdbcTemplate;
@Autowired
@Qualifier("readonly")
private JdbcTemplate readJdbcTemplate;
public List<Map<String, Object>> queryCategoryByLevel(String orgNO, String scopeTypeID, Integer level) {
if(level == null) {
level = jdbcTemplate.queryForInt("select GoodsCategoryLevel = isnull((select Convert(int,sValue1) from tSystemCtrl where sCode = 'GoodsCategoryLevel'),0)");
level = readJdbcTemplate.queryForInt("select GoodsCategoryLevel = isnull((select Convert(int,sValue1) from tSystemCtrl where sCode = 'GoodsCategoryLevel'),0)");
}
String three="select sCategoryNO, sCategoryDesc, sUpCategoryNO from tOrgCategory where sOrgNO = ? and nCategoryLevel = ? and nTag&1 = 0 order by nSort desc";
List<Map<String,Object>> list3=jdbcTemplate.queryForList(three, orgNO, level);
List<Map<String,Object>> list3=readJdbcTemplate.queryForList(three, orgNO, level);
return list3;
}
public List<Map<String, Object>> queryCategory(String orgNO, String scopeTypeID, String upCategoryNo) {
String three="select sCategoryNO, sCategoryDesc, sUpCategoryNO from tOrgCategory where sOrgNO = ? and sUpCategoryNO = ? and nTag&1 = 0 order by nSort desc";
List<Map<String,Object>> list3=jdbcTemplate.queryForList(three, orgNO, upCategoryNo);
List<Map<String,Object>> list3=readJdbcTemplate.queryForList(three, orgNO, upCategoryNo);
return list3;
}
......
......@@ -178,7 +178,7 @@ public class GoodsServiceImpl implements GoodsService {
" and a.nAgentID = ? " +
" and a.nGoodsID = ?";
int mCount = jdbcTemplate.queryForInt(mSql,agentID,goodsId);
int mCount = readJdbcTemplate.queryForInt(mSql,agentID,goodsId);
if(mCount >0 ) {
IsGoodsUnit = 1;
}
......@@ -192,10 +192,10 @@ public class GoodsServiceImpl implements GoodsService {
try {
if(isCheckAgentID) {
gSql += " and t.nAgentID = ? ";
detail = jdbcTemplate.queryForMap(gSql, custTypeId, orgNo, contractNo, goodsId,agentID);
detail = readJdbcTemplate.queryForMap(gSql, custTypeId, orgNo, contractNo, goodsId,agentID);
}else {
detail = jdbcTemplate.queryForMap(gSql, custTypeId, orgNo, contractNo, goodsId);
detail = readJdbcTemplate.queryForMap(gSql, custTypeId, orgNo, contractNo, goodsId);
}
BigDecimal nApSalePrice = (BigDecimal) detail.get("nApSalePrice");
......@@ -210,9 +210,9 @@ public class GoodsServiceImpl implements GoodsService {
List<Map<String, Object>> specList = new ArrayList<Map<String,Object>>();
if(isCheckAgentID) {
sql += " and og.nAgentID = ? ";
specList = jdbcTemplate.queryForList(sql, orgNo, contractNo, custTypeId, goodsId,agentID);
specList = readJdbcTemplate.queryForList(sql, orgNo, contractNo, custTypeId, goodsId,agentID);
}else {
specList = jdbcTemplate.queryForList(sql, orgNo, contractNo, custTypeId, goodsId);
specList = readJdbcTemplate.queryForList(sql, orgNo, contractNo, custTypeId, goodsId);
}
......@@ -264,7 +264,7 @@ public class GoodsServiceImpl implements GoodsService {
}else {
args = new Object[] {custTypeId, orgNo, contractNo, goodsId};
}
List<Map<String, Object>> promoList = jdbcTemplate.queryForList(promoSql, args);
List<Map<String, Object>> promoList = readJdbcTemplate.queryForList(promoSql, args);
detail.put("promoList", promoList);
......@@ -292,7 +292,7 @@ public class GoodsServiceImpl implements GoodsService {
" and t.nAgentID = ? " +
" order by nConvertRate";
List<Map<String,Object>> goodsUnitList = jdbcTemplate.queryForList(GoodsUnitSql,orgNo,contractNo,goodsId,agentID,orgNo,contractNo,goodsId,agentID);
List<Map<String,Object>> goodsUnitList = readJdbcTemplate.queryForList(GoodsUnitSql,orgNo,contractNo,goodsId,agentID,orgNo,contractNo,goodsId,agentID);
rjx.set("goodsUnitList", goodsUnitList);
}else {
rjx.set("goodsUnitList", null);
......@@ -334,7 +334,7 @@ public class GoodsServiceImpl implements GoodsService {
" and a.nGoodsID = ? " +
"order by sPicTypeID, nIdx " +
" ";
List<Map<String, Object>> picList1 = jdbcTemplate.queryForList(sql1, agentContractNO, goodsID, agentContractNO, goodsID);
List<Map<String, Object>> picList1 = readJdbcTemplate.queryForList(sql1, agentContractNO, goodsID, agentContractNO, goodsID);
Map<String, List<Map<String,Object>>> picML1 = Util.listToML(picList1, "sPicTypeID");
Map<String, List<Map<String, Object>>> pics = new HashMap<String, List<Map<String, Object>>>();
for(String sPicTypeID : new String[] {"1", "2", "3", "4","5"}) {
......
......@@ -16,6 +16,7 @@ import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.UncategorizedSQLException;
import org.springframework.stereotype.Service;
......@@ -48,6 +49,11 @@ public class OrderServiceImpl implements OrderService {
@Autowired
private JdbcTemplate jdbcTemplate;
@Autowired
@Qualifier("readonly")
private JdbcTemplate readJdbcTemplate;
/*
* @Autowired QiyeWxService wxService;
*/
......@@ -199,7 +205,7 @@ public class OrderServiceImpl implements OrderService {
if (orderType != null && orderType.length > 0) {
sql += " and a.sB2BOrderTypeID in (" + StringUtil.join("', '", "'", "'", "", orderType) + ")";
}
List<Map<String, Object>> orderList = jdbcTemplate.limit(sql, page);
List<Map<String, Object>> orderList = readJdbcTemplate.limit(sql, page);
if (orderList.size() > 0) {
List<String> orderIds = orderList.stream().map(o -> (String) o.get("sSalesOrderID"))
.collect(Collectors.toList());
......@@ -219,7 +225,7 @@ public class OrderServiceImpl implements OrderService {
" from tSalesOrderDtl sod left join V_GetminAgentGoodsPic agp on agp.nAgentID = sod.nAgentID and agp.nGoodsID = sod.nGoodsID and agp.sPicTypeID = 1 " +
" where sod.sSalesOrderID in (" + StringUtil.join("', '", "'", "'", orderIds) + ")";
List<Map<String, Object>> orderDtlList = jdbcTemplate.queryForList(sql2);
List<Map<String, Object>> orderDtlList = readJdbcTemplate.queryForList(sql2);
Map<String, List<Map<String, Object>>> dtlML = Util.listToML(orderDtlList, "sSalesOrderID");
for (Map<String, Object> orderMap : orderList) {
String sSalesOrderID = (String) orderMap.get("sSalesOrderID");
......@@ -255,14 +261,14 @@ public class OrderServiceImpl implements OrderService {
" from tSalesOrderSubDtl sosd left join V_GetminAgentGoodsPic agp on agp.nAgentID = sosd.nAgentID and agp.nGoodsID = sosd.nGoodsID and agp.sPicTypeID = 1" +
" where sosd.sSalesOrderID in("+StringUtil.join("', '", "'", "'", orderIds) +")";*/
List<Map<String, Object>> subList = jdbcTemplate.queryForList(sql3);
List<Map<String, Object>> subList = readJdbcTemplate.queryForList(sql3);
if (subList.size() > 0) {
List<String> subIds = subList.stream().map(o -> (String) o.get("sSubOrderID"))
.collect(Collectors.toList());
String sql4 = "select sosd.*,PromoSalePrice=CONVERT(NUMERIC(12,2),case when sosd.nSaleQty = 0 then 0 else ROUND((sosd.nSaleAmount)/sosd.nSaleQty,2) end),OriginaSaleAmount=sosd.nSaleAmount+sosd.nDisAmount,ISGift = sosd.nTag&1,"
+ " agp.sURL from tSalesOrderSubDtl sosd left join V_GetminAgentGoodsPic agp on agp.nAgentID = sosd.nAgentID and agp.nGoodsID = sosd.nGoodsID and agp.sPicTypeID = 1"
+ " where sosd.sSubOrderID in (" + StringUtil.join("', '", "'", "'", subIds) + ")";
List<Map<String, Object>> subDtlList = jdbcTemplate.queryForList(sql4);
List<Map<String, Object>> subDtlList = readJdbcTemplate.queryForList(sql4);
Map<String, List<Map<String, Object>>> subDtlML = Util.listToML(subDtlList, "sSubOrderID");
for (Map<String, Object> subMap : subList) {
String sSubOrderID = (String) subMap.get("sSubOrderID");
......@@ -284,7 +290,7 @@ public class OrderServiceImpl implements OrderService {
public String getOrderDetail(String salesOrderId) {
Map<String, Object> orderMap = null;
try {
orderMap = jdbcTemplate.queryForMap("select * from tSalesOrder where sSalesOrderID = ?", salesOrderId);
orderMap = readJdbcTemplate.queryForMap("select * from tSalesOrder where sSalesOrderID = ?", salesOrderId);
} catch (EmptyResultDataAccessException e) {
throw new XException("订单编号错误或订单不存在");
}
......@@ -329,7 +335,7 @@ public class OrderServiceImpl implements OrderService {
" and sos.nIdx = sod.nIdx \r\n" +
" and (sos.nTag&1 = sod.nTag&1 or sos.nTag&1-1 = sod.nTag&1-1) \r\n" +
"where sod.sSalesOrderID = ? ";
orderDtlList = jdbcTemplate.queryForList(sql2, salesOrderId);
orderDtlList = readJdbcTemplate.queryForList(sql2, salesOrderId);
}
Map<String, Object> payMap = new HashMap<String,Object>();
try {
......@@ -337,7 +343,7 @@ public class OrderServiceImpl implements OrderService {
+ ", create_time = replace(convert(varchar(10),dCreateDate,120),'-','') + replace(convert(varchar(10),dCreateDate,108),':','') "
+ "from tSalesOrderPay "
+ "where sSalesOrderID = ? and sOutTradeNO not like '%_D' ";
payMap = jdbcTemplate.queryForMap(sqlPay, salesOrderId);
payMap = readJdbcTemplate.queryForMap(sqlPay, salesOrderId);
payMap.put("nOrderTotalAmount", orderMap.get("nTotalSaleAmount"));
} catch (Exception e) {
}
......@@ -371,7 +377,7 @@ public class OrderServiceImpl implements OrderService {
+ " sCancelUser, " + " sSettleNO, " + " nDebtAmount, "
+ " dExpectDate = convert(varchar(10), dExpectDate, 120)"
+ " from tSalesOrderSub where sSalesOrderID = ?";
List<Map<String, Object>> subList = jdbcTemplate.queryForList(sql, salesOrderId);
List<Map<String, Object>> subList = readJdbcTemplate.queryForList(sql, salesOrderId);
if (subList.size() > 0) {
List<String> subIds = subList.stream().map(o -> (String) o.get("sSubOrderID")).collect(Collectors.toList());
String sql2 = "select sosd.*, PromoSalePrice = CONVERT(NUMERIC(12,2),ROUND((sosd.nSaleAmount)/case when sosd.nSaleQty=0 then 1 else sosd.nSaleQty end,2)), \r\n" +
......@@ -387,7 +393,7 @@ public class OrderServiceImpl implements OrderService {
" left join V_GetminAgentGoodsPic agp on agp.nAgentID = sosd.nAgentID and agp.nGoodsID = sosd.nGoodsID and agp.sPicTypeID = 1\r\n" +
"where sosd.sSubOrderID in (" + StringUtil.join("', '", "'", "'", subIds) + ")";
List<Map<String, Object>> subDtlList = jdbcTemplate.queryForList(sql2);
List<Map<String, Object>> subDtlList = readJdbcTemplate.queryForList(sql2);
Map<String, List<Map<String, Object>>> subDtlML = Util.listToML(subDtlList, "sSalesOrderID");
for (Map<String, Object> subMap : subList) {
String sSubOrderID = (String) subMap.get("sSubOrderID");
......@@ -447,19 +453,19 @@ public class OrderServiceImpl implements OrderService {
int ReturnDay = 0;
try {
String msql = "select convert(int, sValue1) FROM tSystemCtrl WHERE sCode = 'SaleReturnDays' ";
ReturnDay = jdbcTemplate.queryForInt(msql);
ReturnDay = readJdbcTemplate.queryForInt(msql);
} catch (Exception e) {
}
Map<String, Object> subOrderMap = jdbcTemplate.queryForMap("" + "select " + "sos.*, "
Map<String, Object> subOrderMap = readJdbcTemplate.queryForMap("" + "select " + "sos.*, "
+ " IsRefund = case when isnull(sos.sBindPaperNO,'') = '' then 1 when sos.nOrderStatus&17=0 then 0 when datediff(dd,dateadd(dd,1,convert(date,sos.dReceiveDate)),getdate()) >= ? then 0 else 1 end, "
+ " LeftReturnQty = isnull(d.nSendQty,0) - isnull(d.nReturnQty,0), "
+ "case when sos.nOrderStatus&145 = 144 then '16' when sos.nOrderStatus&145 = 128 then '8' when sos.nOrderStatus&145 = 0 then '4' when sos.nOrderStatus&5 = 4 then '2' else '0' end nOrderStatus, "
+ "case when sos.nOrderStatus&145 = 144 then '已完成' when sos.nOrderStatus&145 = 128 then '配送中' when sos.nOrderStatus&145 = 0 then '待发货' when sos.nOrderStatus&5 = 4 then '已审核' else '未审核' end sOrderStatusText "
+ "from tSalesOrderSub sos left join (select sSubOrderID, nSendQty = sum(nSendQty), nReturnQty = sum(nReturnQty) from tSalesOrderSubDtl where sSubOrderID = ? group by sSubOrderID) d on sos.sSubOrderID = d.sSubOrderID "
+ " where sos.sSubOrderID = ?", ReturnDay, subOrderID, subOrderID);
Map<String, Object> orderMap = jdbcTemplate.queryForMap("" + "select " + "so.*, "
Map<String, Object> orderMap = readJdbcTemplate.queryForMap("" + "select " + "so.*, "
+ "case when so.nOrderStatus&145 = 144 then '16' when so.nOrderStatus&145 = 128 then '8' when so.nOrderStatus&145 = 0 then '4' when so.nOrderStatus&5 = 4 then '2' else '0' end nOrderStatus, "
+ "case when so.nOrderStatus&145 = 144 then '已完成' when so.nOrderStatus&145 = 128 then '配送中' when so.nOrderStatus&145 = 0 then '待发货' when so.nOrderStatus&5 = 4 then '已审核' else '未审核' end sOrderStatusText "
+ "from tSalesOrder so where so.sSalesOrderID = ?", subOrderMap.get("sSalesOrderID"));
......@@ -513,12 +519,12 @@ public class OrderServiceImpl implements OrderService {
" left join tAgentContractGoods ag on sosd.sAgentContractNO = ag.sAgentContractNO and sosd.nGoodsID = ag.nGoodsID \r\n" +
"where sosd.sSubOrderID = ?";
List<Map<String, Object>> dtlList = jdbcTemplate.queryForList(sql, subOrderID);
Map<String, Object> deliver = jdbcTemplate.queryForMap(
List<Map<String, Object>> dtlList = readJdbcTemplate.queryForList(sql, subOrderID);
Map<String, Object> deliver = readJdbcTemplate.queryForMap(
"SELECT sum(a.nNum) nTotalCount, sum(a.nPrice * a.nNum) nTotalAmount FROM tSalesOrderDeliverSubDtl a where a.sSubOrderID = ?",
subOrderID);
String sql3 = "select sSubOrderID, nOrderMoney, sAocOrderID, sAocOrderNumber, nOrderNum, nPickupNum, sExpressNO, sExpressName from tSalesOrderDeliverSub where nTag&1 = 0 and sSubOrderID = ?";
List<Map<String, Object>> deliverSubList = jdbcTemplate.queryForList(sql3, subOrderID);
List<Map<String, Object>> deliverSubList = readJdbcTemplate.queryForList(sql3, subOrderID);
Map<String, Object> payMap = new HashMap<String,Object>();
......@@ -526,7 +532,7 @@ public class OrderServiceImpl implements OrderService {
String sqlPay = "select sPayTypeID, sPayType, nPayAmount, sOutTradeNO, sTransTraceNO, dPayDateTime, sStatusID = case when nTag&2=2 then '1' else '0' end, sStatus = case when nTag&2=2 then '已付款' else '未付款' end "
+ "from tSalesOrderPay "
+ "where sSalesOrderID = ? and sOutTradeNO not like '%_D' ";
payMap = jdbcTemplate.queryForMap(sqlPay, subOrderMap.get("sSalesOrderID"));
payMap = readJdbcTemplate.queryForMap(sqlPay, subOrderMap.get("sSalesOrderID"));
payMap.put("nOrderTotalAmount", orderMap.get("nTotalSaleAmount"));
} catch (Exception e) {
}
......@@ -557,16 +563,16 @@ public class OrderServiceImpl implements OrderService {
String stockSql = "select og.sWarehouseNO, og.sAgentContractNO, og.nGoodsID, og.nStockQty, og.nLockedQty from tPromoRuleGoods prg, V_OrgGoods og where prg.sAgentContractNO = og.sAgentContractNO and prg.nGoodsID = og.nGoodsID and og.sOrgNO = ? and prg.sPromoPaperNO = ? and prg.sPromoGroupNO = ?";
List<Map<String, Object>> stockList = jdbcTemplate.queryForList(stockSql, orgNo, promoPaperNO, promoGroupNO);
List<Map<String, Object>> stockList = readJdbcTemplate.queryForList(stockSql, orgNo, promoPaperNO, promoGroupNO);
Map<String, Map<String, Object>> stockMM = Util.listToMM(stockList, "_", "sAgentContractNO", "nGoodsID");
Map<String, Object> custMap = jdbcTemplate.queryForMap(
Map<String, Object> custMap = readJdbcTemplate.queryForMap(
"select c.* from tCustomer c, tShop s where c.sCustNO = s.sCustNO and s.sShopNO = ? and s.sOrgNO = ?",
shopNo, orgNo);
String sCustTypeID = (String) custMap.get("sCustTypeID");
String sCustNO = (String) custMap.get("sCustNO");
this.saveOrderBankAccount(sCustNO, bankType, bankAccount);
Map<String, Object> addrMap = jdbcTemplate.queryForMap("select * from tCustAddress where sAddrID = ?", addrId);
Map<String, Object> addrMap = readJdbcTemplate.queryForMap("select * from tCustAddress where sAddrID = ?", addrId);
List<String> address = new ArrayList<String>();
address.add((String) addrMap.get("sProvince"));
address.add((String) addrMap.get("sCity"));
......@@ -599,7 +605,7 @@ public class OrderServiceImpl implements OrderService {
+ " CASE WHEN nUseCycle&64 = 64 THEN '7' ELSE '' END LIKE '%' + convert(VARCHAR,datepart(weekday,getdate())) + '%' "
+ " AND a.sPromoPaperNO = ? " + " AND b.sPromoGroupNO = ? " + " AND c.sShopNO = ? ";
List<Map<String, Object>> goodsList = jdbcTemplate.queryForList(sql.replaceAll("\\s+", " "), promoPaperNO,
List<Map<String, Object>> goodsList = readJdbcTemplate.queryForList(sql.replaceAll("\\s+", " "), promoPaperNO,
promoGroupNO, sCustTypeID);
if (goodsList.size() == 0) {
......@@ -750,11 +756,11 @@ public class OrderServiceImpl implements OrderService {
XException.assertNotBlank(terminal, "Terminal不能为空");
BigDecimal Qty = BigDecimal.valueOf(saleQty);
Map<String, Object> custMap = jdbcTemplate.queryForMap(
Map<String, Object> custMap = readJdbcTemplate.queryForMap(
"select c.* from tCustomer c, tShop s where c.sCustNO = s.sCustNO and s.sShopNO = ?", shopNo);
String sCustNO = (String) custMap.get("sCustNO");
this.saveOrderBankAccount(sCustNO, bankType, bankAccount);
Map<String, Object> addrMap = jdbcTemplate.queryForMap("select * from tCustAddress where sAddrID = ?", addrId);
Map<String, Object> addrMap = readJdbcTemplate.queryForMap("select * from tCustAddress where sAddrID = ?", addrId);
List<String> address = new ArrayList<String>();
address.add((String) addrMap.get("sProvince"));
address.add((String) addrMap.get("sCity"));
......@@ -776,11 +782,11 @@ public class OrderServiceImpl implements OrderService {
+ " LEFT JOIN V_OrgGoods og ON og.sOrgNO = t.sOrgNO "
+ " AND og.sAgentContractNO = t.sAgentContractNO " + " AND og.nGoodsID = t.nGoodsID";
Map<String, Object> gMap = jdbcTemplate.queryForMap(sqlplan.replaceAll("\\s+", " "), planId, orgNo);
Map<String, Object> gMap = readJdbcTemplate.queryForMap(sqlplan.replaceAll("\\s+", " "), planId, orgNo);
BigDecimal nPrice = (BigDecimal) gMap.get("nPrice");
BigDecimal nTotalSaleAmount = nPrice.multiply(Qty);
BigDecimal nPlanStock = (BigDecimal) gMap.get("nPlanStock");
Map<String, Object> planSum = jdbcTemplate.queryForMap(
Map<String, Object> planSum = readJdbcTemplate.queryForMap(
"select sum(nTotalSaleQty) nOrderQty, sum(nTotalSaleAmount) nOrderAmount from tSalesOrder where nPlanID = ? and nOrderStatus&1 = 0",
planId);
BigDecimal nOrderQty = (BigDecimal) planSum.get("nOrderQty");
......@@ -865,9 +871,9 @@ public class OrderServiceImpl implements OrderService {
jdbcTemplate.save(dtl);
{
Long nProjectID = jdbcTemplate.queryForLong("select nProjectID from tZHCPlan where nPlanID = ?", planId);
Long nProjectID = readJdbcTemplate.queryForLong("select nProjectID from tZHCPlan where nPlanID = ?", planId);
String sql = "select count(so.sSalesOrderID) nSalePaperQty, isnull(sum(so.nTotalSaleQty), 0) nSaleQty, isnull(sum(so.nTotalSaleAmount), 0) nSaleAmount from tSalesOrder so, tZHCPlan p where so.sB2BOrderTypeID = '3' and so.nTag&1 = 0 and so.nPlanID = p.nPlanID and p.nProjectID = ?";
Map<String, Object> map = jdbcTemplate.queryForMap(sql, nProjectID);
Map<String, Object> map = readJdbcTemplate.queryForMap(sql, nProjectID);
Integer nSalePaperQty = ((Number) map.get("nSalePaperQty")).intValue();
BigDecimal nSaleQty = (BigDecimal) map.get("nSaleQty");
BigDecimal nSaleAmount = (BigDecimal) map.get("nSaleAmount");
......@@ -892,13 +898,13 @@ public class OrderServiceImpl implements OrderService {
XException.assertNotBlank(payTypeId, "PayTypeID不能为空");
XException.assertNotBlank(terminal, "Terminal不能为空");
Map<String, Object> custMap = jdbcTemplate.queryForMap(
Map<String, Object> custMap = readJdbcTemplate.queryForMap(
"select c.* from tCustomer c, tShop s where c.sCustNO = s.sCustNO and s.sShopNO = ?", shopNo);
String sCustTypeID = (String) custMap.get("sCustTypeID");
String sCustNO = (String) custMap.get("sCustNO");
this.saveOrderBankAccount(sCustNO, bankType, bankAccount);
BigDecimal Qty = BigDecimal.valueOf(saleQty);
Map<String, Object> addrMap = jdbcTemplate.queryForMap("select * from tCustAddress where sAddrID = ?", addrId);
Map<String, Object> addrMap = readJdbcTemplate.queryForMap("select * from tCustAddress where sAddrID = ?", addrId);
List<String> address = new ArrayList<String>();
address.add((String) addrMap.get("sProvince"));
address.add((String) addrMap.get("sCity"));
......@@ -911,7 +917,7 @@ public class OrderServiceImpl implements OrderService {
String sContacts = (String) addrMap.get("sContacts");
String gSql = "select t.*, ap.nRealSalePrice nApSalePrice from V_OrgGoods t left join tAgentCustTypePrice ap on ap.sCustTypeID = ? and ap.sAgentContractNO = t.sAgentContractNO and ap.nGoodsID = t.nGoodsID where t.sOrgNO = ? and t.sAgentContractNO = ? and t.nGoodsID = ?";
Map<String, Object> gMap = jdbcTemplate.queryForMap(gSql, sCustTypeID, orgNo, contractNo, goodsId);
Map<String, Object> gMap = readJdbcTemplate.queryForMap(gSql, sCustTypeID, orgNo, contractNo, goodsId);
BigDecimal nStockQty = (BigDecimal) gMap.get("nStockQty");
BigDecimal nLockedQty = (BigDecimal) gMap.get("nLockedQty");
BigDecimal stock = nStockQty.subtract(nLockedQty);
......@@ -1048,7 +1054,7 @@ public class OrderServiceImpl implements OrderService {
@Override
public List<Map<String, Object>> getDeliverSubDetail(String aocOrderID) {
return jdbcTemplate.queryForList("select * from tSalesOrderDeliverSubDtl where nTag&1 = 0 and sAocOrderID = ?",
return readJdbcTemplate.queryForList("select * from tSalesOrderDeliverSubDtl where nTag&1 = 0 and sAocOrderID = ?",
aocOrderID);
}
......@@ -1093,7 +1099,7 @@ public class OrderServiceImpl implements OrderService {
int saleReturnDays = 0;
try {
String dSql = "select SaleReturnDays = convert(int, sValue1) FROM tSystemCtrl WHERE sCode = 'SaleReturnDays' ";
saleReturnDays = jdbcTemplate.queryForInt(dSql);
saleReturnDays = readJdbcTemplate.queryForInt(dSql);
} catch (Exception e) {
}
......@@ -1130,7 +1136,7 @@ public class OrderServiceImpl implements OrderService {
" a.sDeliveryTypeID, a.sDeliveryType, a.sContacts, a.sMobile, a.sAddress, a.nExpressFee, " +
" a.nOrderStatus, a.nOrderStatusName, a.sOrderMemo ";
List<Map<String, Object>> orderList = jdbcTemplate.limit(sql, page);
List<Map<String, Object>> orderList = readJdbcTemplate.limit(sql, page);
sortList.addAll(orderList);
sortList.sort(new Comparator<Map<String, Object>>() {
......@@ -1184,7 +1190,7 @@ public class OrderServiceImpl implements OrderService {
+ " where a.sSubOrderID in (" + StringUtil.join("', '", "'", "'", orderIdList) + ") "
+ " order by a.nIdx";
List<Map<String, Object>> goodsList = jdbcTemplate.queryForList(detailSql);
List<Map<String, Object>> goodsList = readJdbcTemplate.queryForList(detailSql);
Map<String, List<Map<String, Object>>> gmList = Util.listToML(goodsList, "SubOrderID");
for (Map<String, Object> orderMap : orderList) {
......
......@@ -4,6 +4,7 @@ import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import com.egolm.common.StringUtil;
......@@ -17,6 +18,11 @@ public class PageServiceImpl implements PageService {
@Autowired
private JdbcTemplate jdbcTemplate;
@Autowired
@Qualifier("readonly")
private JdbcTemplate readJdbcTemplate;
/**
* 查询首页配置
* <p>Title: query</p>
......@@ -29,8 +35,8 @@ public class PageServiceImpl implements PageService {
public List<Map<String, Object>> query(Map<String, Object> params) {
String sql = "SELECT sPlatformNO platformNO,sPlatformName platformName,sLogoPath1 logoPath1 ,sLogoPath2 logoPath2,sLogoPath3 logoPath3,sThemeNO themeNO,sThemeJson themeJson,sMemo memo,dLastUpdateTime lastUpdateTime "
+ " FROM tPlatformLayout " + "WHERE nTag &1=0 ORDER BY dLastUpdateTime DESC ";
jdbcTemplate.setDialect(new SqlServerDialect());
return jdbcTemplate.queryForList(sql);
readJdbcTemplate.setDialect(new SqlServerDialect());
return readJdbcTemplate.queryForList(sql);
}
/**
......@@ -45,11 +51,11 @@ public class PageServiceImpl implements PageService {
@Override
public List<Map<String, Object>> queryIcon(Map<String, Object> params, Page page) {
String iconGroupNO = params.get("iconGroupNO")+"";
jdbcTemplate.setDialect(new SqlServerDialect());
readJdbcTemplate.setDialect(new SqlServerDialect());
String sql = " SELECT IconNO = i.sIconNO ,IconPath=i.sIconPath,DefaultTxt=i.sDefaultTxt,DefaultLinkType=i.sDefaultLinkType,DefaultLink=i.sDefaultLink "
+ " FROM tIcon i ,tIconGroup ig"
+ " WHERE i.sGroupNO = ig.sGroupNO AND ig.nTag&1=0 and ig.sGroupNO = ? ";
return jdbcTemplate.limit(sql, page, iconGroupNO);
return readJdbcTemplate.limit(sql, page, iconGroupNO);
}
/**
......@@ -67,7 +73,7 @@ public class PageServiceImpl implements PageService {
String adTypeID = params.get("adTypeID")+"";
String custNo = params.get("custNo")+"";
String AgentID = params.get("AgentID")+"";
jdbcTemplate.setDialect(new SqlServerDialect());
readJdbcTemplate.setDialect(new SqlServerDialect());
String sql = "SELECT BannerAdNO = b.sBannerAdNO, BannerAdTitle = b.sBannerAdTitle,OrgNO = b.sOrgNO,AdPostionTypeID = b.sAdPositionTypeID,AdPostionType = b.sAdPositionType,"
+ " LayoutTypeID = b.sLayoutTypeID,LayoutType = b.sLayoutType,JumpTypeID = b.sJumpTypeID,JumpType = b.sJumpType,JumpList = b.sJumpList,Idx = b.nIdx,ImagePath = b.sImagePath,"
......@@ -75,7 +81,7 @@ public class PageServiceImpl implements PageService {
+ " from tBannerAd b "
+ " WHERE b.sOrgNO = ? AND sAdPositionTypeID = ? AND b.dStartTime <=getdate() AND b.dEndTime >= getdate() AND b.nTag&2 = 2 and b.nAgentID = ? ";
return jdbcTemplate.limit(sql, page, orgNO, adTypeID,AgentID);
return readJdbcTemplate.limit(sql, page, orgNO, adTypeID,AgentID);
}
......@@ -93,16 +99,16 @@ public class PageServiceImpl implements PageService {
String orgNO = params.get("orgNO")+"";
String msgTypeID = params.get("msgTypeID")+"";
String agentID = params.get("agentID")+"";
jdbcTemplate.setDialect(new SqlServerDialect());
readJdbcTemplate.setDialect(new SqlServerDialect());
String sql = "SELECT BillBoardID = b.nBillboardID, MsgTypeID = b.sMsgTypeID,MsgType = b.sMsgType,Title = b.sTitle,Content = b.sText,Sort = b.nSort,TradeDate = b.dTradeDate"
+ " FROM tBillboard b "
+ " WHERE b.nTag&2=2 AND b.sMsgTypeID = ? and b.sOrgNO = ? ";
if(StringUtil.isNotBlank(agentID)) {
sql += " and b.nAgentID = ? ";
return jdbcTemplate.limit(sql, page, msgTypeID, orgNO,agentID);
return readJdbcTemplate.limit(sql, page, msgTypeID, orgNO,agentID);
}else {
return jdbcTemplate.limit(sql, page, msgTypeID, orgNO);
return readJdbcTemplate.limit(sql, page, msgTypeID, orgNO);
}
}
......@@ -118,18 +124,18 @@ public class PageServiceImpl implements PageService {
*/
public List<Map<String, Object>> queryFinanceProd(Map<String, Object> params, Page page) {
String orgNO = params.get("orgNO")+"";
jdbcTemplate.setDialect(new SqlServerDialect());
readJdbcTemplate.setDialect(new SqlServerDialect());
String sql = "select FinanceID = a.nFinanceID, OrgNO = a.sOrgNO, FinanceName = a.sFinanceName,AgentContractNO = a.sAgentContractNO,BannerUrl = a.sBannerUrl,LogoUrl = a.sLogoUrl,"
+ " AddressUrl = a.sAddressUrl, Introduce = a.sMemo, LastUpdateTime = a.dLastUpdateTime "
+ " from tFinanceProd a where a.nTag&2 = 2 and a.sOrgNO = ? ";
List<Map<String,Object>> list = jdbcTemplate.limit(sql, page, orgNO);
List<Map<String,Object>> list = readJdbcTemplate.limit(sql, page, orgNO);
if(list != null && list.size() >0) {
for(Map<String,Object> map:list) {
String FinanceID = map.get("FinanceID")+"";
String picSql = "select FinanceID = nFinanceID,Item = nItem, PicDesc = sPicDesc,URL = sURL from tFinanceProdPic where nFinanceID = ?";
List<Map<String,Object>> picList = jdbcTemplate.queryForList(picSql,FinanceID);
List<Map<String,Object>> picList = readJdbcTemplate.queryForList(picSql,FinanceID);
map.put("picList", picList);
}
}
......
......@@ -85,16 +85,16 @@ public class UserServiceImpl implements UserService {
}
try {
String sql = "SELECT * FROM tCustomer WHERE sCustNO = ? AND nTag&1=0";
jdbcTemplate.setDialect(new SqlServerDialect());
TCustomer tcustomer = jdbcTemplate.queryForBean(sql, TCustomer.class, custNO);
readJdbcTemplate.setDialect(new SqlServerDialect());
TCustomer tcustomer = readJdbcTemplate.queryForBean(sql, TCustomer.class, custNO);
List<TShop> shops = null;
String shopSql = "SELECT * FROM tShop WHERE nTag&1=0 and sCustNO =? ";
if(StringUtil.isNotEmpty(shopNO)) {
shopSql += " AND sShopNO = ? ";
shops = jdbcTemplate.queryForBeans(shopSql, TShop.class, custNO.trim(),shopNO.trim());
shops = readJdbcTemplate.queryForBeans(shopSql, TShop.class, custNO.trim(),shopNO.trim());
}else {
shops = jdbcTemplate.queryForBeans(shopSql, TShop.class, custNO.trim());
shops = readJdbcTemplate.queryForBeans(shopSql, TShop.class, custNO.trim());
}
tcustomer.settShops(shops);
......@@ -118,7 +118,7 @@ public class UserServiceImpl implements UserService {
public boolean checkShopExists(String custNO,String shopNO) {
try {
String sql = "SELECT count(1) FROM tShop WHERE sCustNO = ? AND sShopNO = ? AND nTag&1=0";
int i = jdbcTemplate.queryForInt(sql,custNO,shopNO);
int i = readJdbcTemplate.queryForInt(sql,custNO,shopNO);
if(i >0) {
return true;
}
......@@ -132,7 +132,7 @@ public class UserServiceImpl implements UserService {
public TCustomer getCustomer(String mobile) {
try {
String sql = "SELECT * FROM tCustomer WHERE sMobile = ? AND nTag&1=0";
return jdbcTemplate.queryForBean(sql, TCustomer.class, mobile);
return readJdbcTemplate.queryForBean(sql, TCustomer.class, mobile);
} catch (Exception e) {
e.printStackTrace();
}
......@@ -144,8 +144,8 @@ public class UserServiceImpl implements UserService {
return new TShop();
}
String sql = "SELECT * FROM tShop WHERE sShopNO = ? AND nTag&1=0";
jdbcTemplate.setDialect(new SqlServerDialect());
return jdbcTemplate.queryForBean(sql, TShop.class, shopNO);
readJdbcTemplate.setDialect(new SqlServerDialect());
return readJdbcTemplate.queryForBean(sql, TShop.class, shopNO);
}
/**
......@@ -660,7 +660,7 @@ public class UserServiceImpl implements UserService {
@Override
public Map<String, Object> queryCustomerByOpenId(String openId) {
String sql = "select c.*, m.sMobile sSalesmanMobile from tCustomer c left join tSalesman m on m.sSalesmanNO = c.sSalesmanNO1, tB2BUser u where c.sCustNO = u.sCustNO and u.sOpenID = ? and c.nTag&1 = 0 and u.nTag&1 = 0";
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql, openId);
List<Map<String, Object>> list = readJdbcTemplate.queryForList(sql, openId);
if(list.size() > 1) {
throw new XException("OpenID绑定异常");
}
......@@ -669,7 +669,7 @@ public class UserServiceImpl implements UserService {
@Override
public Map<String, Object> queryCustomerByMobile(String mobile) {
List<Map<String, Object>> list = jdbcTemplate.queryForList("select * from tCustomer where sMobile = ? or sCustNO = ? and nTag&1 = 0", mobile, mobile);
List<Map<String, Object>> list = readJdbcTemplate.queryForList("select * from tCustomer where sMobile = ? or sCustNO = ? and nTag&1 = 0", mobile, mobile);
return list.size() == 0 ? null : list.get(0);
}
......@@ -677,7 +677,7 @@ public class UserServiceImpl implements UserService {
public Map<String, Object> createCustomer(String orgNo, String openId, String mobile) {
String sSalesmanNO1 = null;
try {
sSalesmanNO1 = jdbcTemplate.queryForString("select sSalesmanNO from tOrg where sOrgNO = ?", orgNo);
sSalesmanNO1 = readJdbcTemplate.queryForString("select sSalesmanNO from tOrg where sOrgNO = ?", orgNo);
} catch (EmptyResultDataAccessException e) {
e.printStackTrace();
}
......@@ -707,7 +707,7 @@ public class UserServiceImpl implements UserService {
@Override
public List<Map<String, Object>> queryShopList(String orgNo, String custNo) {
List<Map<String, Object>> shopList = jdbcTemplate.queryForList("select s.*, m.sSalesmanName, m.sMobile sSalesmanMobile from tShop s left join tSalesman m on m.sSalesmanNO = s.sSalesmanNO1 where s.sCustNO = ? and s.sOrgNO = ? and s.nTag&1 = 0", custNo, orgNo);
List<Map<String, Object>> shopList = readJdbcTemplate.queryForList("select s.*, m.sSalesmanName, m.sMobile sSalesmanMobile from tShop s left join tSalesman m on m.sSalesmanNO = s.sSalesmanNO1 where s.sCustNO = ? and s.sOrgNO = ? and s.nTag&1 = 0", custNo, orgNo);
return shopList;
}
......@@ -763,7 +763,7 @@ public class UserServiceImpl implements UserService {
}, keyHolder);
Object key = keyHolder.getKey();
jdbcTemplate.update("update tShop set sShopNO = RIGHT('00000000'+ CAST(nShopID as varchar(8)), 8) where nShopID = ?", key);
String sShopNO = jdbcTemplate.queryForString("select sShopNO from tShop where nShopID = ?", key);
String sShopNO = readJdbcTemplate.queryForString("select sShopNO from tShop where nShopID = ?", key);
map.put("sShopNO", sShopNO);
return map;
}
......@@ -838,13 +838,13 @@ public class UserServiceImpl implements UserService {
+ "left join tOrg o on o.sOrgNO = s.sOrgNO "
+ "where "
+ "sm.sSalesmanNO = s.sSalesmanNO1 and s.sShopNO = ?";
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql, shopNo);
List<Map<String, Object>> list = readJdbcTemplate.queryForList(sql, shopNo);
return list != null && list.size() > 0 ? list.get(0) : null;
}
@Override
public Map<String, Object> getCustomerByNO(String custNo) {
return jdbcTemplate.queryForMap("select * from tCustomer where sCustNO = ?", custNo);
return readJdbcTemplate.queryForMap("select * from tCustomer where sCustNO = ?", custNo);
}
@Override
......@@ -857,7 +857,7 @@ public class UserServiceImpl implements UserService {
@Override
public List<Map<String, Object>> queryBankList(String sCustNO) {
String sql = "SELECT * FROM tCustBank where sCustNO = ? and nTag&1 = 0 order by dLastUpdateTime desc";
return jdbcTemplate.queryForList(sql, sCustNO);
return readJdbcTemplate.queryForList(sql, sCustNO);
}
@Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment