Эх сурвалжийг харах

【盘点按照仓库+物料汇总】

wub 1 сар өмнө
parent
commit
a9a5a1061b

+ 21 - 18
src/com/uas/erp/service/scm/impl/InventoryServiceImpl.java

@@ -24,9 +24,12 @@ public class InventoryServiceImpl implements InventoryService {
 	static final String StockTakingDetailByBatch = "insert into StockTakingDetail(std_id, std_stid, std_code,std_detno,std_prodcode,std_batchqty,std_actqty,std_price,std_purbatchqty,std_puractqty,std_prodmadedate,std_validtime,std_batchcode) "
 			+ "										select STOCKTAKINGDETAIL_SEQ.NEXTVAL,@std_stid,@std_code,rownum,ba_prodcode,ba_remain,ba_remain,ba_price,case when nvl(ba_purcrate,0)=0 then ba_remain else round(ba_remain/BA_PURCRATE,8) end,"
 			+ "										case when nvl(ba_purcrate,0)=0 then ba_remain else round(ba_remain/BA_PURCRATE,8) end,ba_date,ba_validtime,ba_code from batch where ba_whcode=? and nvl(ba_remain,0)>0";
-	static final String StockTakingDetailByDaoSuan = "insert into StockTakingDetail(std_id, std_stid, std_code,std_detno,std_prodcode,std_batchqty,std_actqty,std_price,std_purbatchqty,std_puractqty,std_prodmadedate,std_validtime,std_batchcode) "
-			+ "										select STOCKTAKINGDETAIL_SEQ.NEXTVAL,@std_stid,@std_code,rownum,ba_prodcode,baremain,baremain,ba_price,case when nvl(ba_purcrate,0)=0 then baremain else round(baremain/BA_PURCRATE,8) end,"
-			+ "										case when nvl(ba_purcrate,0)=0 then baremain else round(baremain/BA_PURCRATE,8) end,ba_date,ba_validtime,ba_code from batch_temp where ba_whcode=? and nvl(baremain,0)>0";
+//	static final String StockTakingDetailByDaoSuan = "insert into StockTakingDetail(std_id, std_stid, std_code,std_detno,std_prodcode,std_batchqty,std_actqty,std_price,std_purbatchqty,std_puractqty,std_prodmadedate,std_validtime,std_batchcode) "
+//			+ "										select STOCKTAKINGDETAIL_SEQ.NEXTVAL,@std_stid,@std_code,rownum,ba_prodcode,baremain,baremain,ba_price,case when nvl(ba_purcrate,0)=0 then baremain else round(baremain/BA_PURCRATE,8) end,"
+//			+ "										case when nvl(ba_purcrate,0)=0 then baremain else round(baremain/BA_PURCRATE,8) end,ba_date,ba_validtime,ba_code from batch_temp where ba_whcode=? and nvl(baremain,0)>0";
+	static final String StockTakingDetailByDaoSuan = "insert into StockTakingDetail(std_id, std_stid, std_code,std_detno,std_prodcode,std_batchqty,std_actqty,std_price,std_purbatchqty,std_puractqty,std_prodmadedate,std_validtime,std_batchcode) " +
+													" select STOCKTAKINGDETAIL_SEQ.NEXTVAL,@std_stid,@std_code,rownum,ba_prodcode,baremain,baremain,baprice,'','','','','' from (select ba_whcode,ba_prodcode,sum(baremain) baremain, round(sum(nvl(baremain,0)*nvl(ba_price,0))/sum(nvl(baremain,0)),8) baprice " +
+													" from batch_temp group by ba_whcode,ba_prodcode order by ba_prodcode) where ba_whcode=? and nvl(baremain,0)>0";
 	
 	@Override
 	public String inventory(String method, String whcode) {
@@ -68,13 +71,13 @@ public class InventoryServiceImpl implements InventoryService {
 
 		sql2 = sql2 + " and st_whcode in (" + sql1 + ")";
 		String dets = baseDao.getJdbcTemplate().queryForObject(sql2, String.class);
-		if (dets != null) {
-			if(inventoryIgnoreEntring){
-				errorLog.append("当前月份同一仓库已存在[在录入]的盘点单!</br>"+dets+"<hr>");
-			}else{
-				BaseUtil.showError("当前月份同一仓库已存在[在录入]的盘点单,不允许进行盘点操作!</br>"+dets+"<hr>");
-			}
-		}
+//		if (dets != null) {
+//			if(inventoryIgnoreEntring){
+//				errorLog.append("当前月份同一仓库已存在[在录入]的盘点单!</br>"+dets+"<hr>");
+//			}else{
+//				BaseUtil.showError("当前月份同一仓库已存在[在录入]的盘点单,不允许进行盘点操作!</br>"+dets+"<hr>");
+//			}
+//		}
 		String sql3 = "select wm_concat(wh_code) from WareHouse where not exists (select 1 from productwh where pw_whcode = wh_code and nvl(pw_onhand,0) > 0 ) and wh_code in ("+sql1+")";
 		if(inventoryByBatch){
 			sql3 = "select wm_concat(wh_code) from WareHouse where not exists (select 1 from batch where ba_whcode = wh_code and nvl(ba_remain,0) > 0 ) and wh_code in ("+sql1+")";
@@ -98,13 +101,13 @@ public class InventoryServiceImpl implements InventoryService {
 		}else{
 			sql1 = sql1+ " exists (select 1 from productwh where pw_whcode = wh_code and nvl(pw_onhand,0) > 0 ) ";
 		}
-		if(inventoryIgnoreEntring){//产生盘点底稿时略过已存在在录入单据的仓库
-			if(inventoryByBatchAndDaoSuan){
-				sql1 = sql1+" and not exists (select 1 from StockTaking where wh_code = st_whcode and nvl(st_statuscode,' ')='ENTERING' and to_char(st_date,'yyyymm')=to_char(to_date('"+pd_enddate+"','yyyymmdd'),'yyyymm'))";
-			}else{
-				sql1 = sql1+" and not exists (select 1 from StockTaking where wh_code = st_whcode and nvl(st_statuscode,' ')='ENTERING' and to_char(st_date,'yyyymm')=to_char(sysdate,'yyyymm'))";
-			}
-		}
+//		if(inventoryIgnoreEntring){//产生盘点底稿时略过已存在在录入单据的仓库
+//			if(inventoryByBatchAndDaoSuan){
+//				sql1 = sql1+" and not exists (select 1 from StockTaking where wh_code = st_whcode and nvl(st_statuscode,' ')='ENTERING' and to_char(st_date,'yyyymm')=to_char(to_date('"+pd_enddate+"','yyyymmdd'),'yyyymm'))";
+//			}else{
+//				sql1 = sql1+" and not exists (select 1 from StockTaking where wh_code = st_whcode and nvl(st_statuscode,' ')='ENTERING' and to_char(st_date,'yyyymm')=to_char(sysdate,'yyyymm'))";
+//			}
+//		}
 		SqlRowList rs = baseDao.queryForRowSet(sql1);
 		int j = 0;
 		while (rs.next()) {
@@ -130,7 +133,7 @@ public class InventoryServiceImpl implements InventoryService {
 				if(inventoryByBatchAndDaoSuan){
 					baseDao.execute("insert into StockTaking(st_id,st_code,st_type,st_date,st_recorder,st_indate,st_status,st_whcode,st_statuscode) values" +
 							" ("+stid+",'"+checkCode+"','"+method+"',to_date('"+pd_enddate+"','yyyymmdd'),'"+SystemSession.getUser().getEm_name()+"',to_date('"+pd_enddate+"','yyyymmdd'), " +
-							" '"+BaseUtil.getLocalMessage("ENTERING")+"','"+rs.getString("wh_code")+"','ENTERING') ");
+							" '在录入','"+rs.getString("wh_code")+"','ENTERING') ");
 //					baseDao.getJdbcTemplate().update(StockTakingByDaoSuan, stid, checkCode, method, "\'to_date('"+pd_enddate+"','yyyymmdd')\'",
 //							SystemSession.getUser().getEm_name(),"\'to_date('"+pd_enddate+"','yyyymmdd')\'",
 //							BaseUtil.getLocalMessage("ENTERING"), rs.getString("wh_code"),