|
@@ -0,0 +1,936 @@
|
|
|
+package com.bus.service.impl;
|
|
|
+
|
|
|
+import com.bus.dao.IBusMonthAssessmentDao;
|
|
|
+import com.bus.model.BusMonthAssessment;
|
|
|
+import com.bus.model.BusOrg;
|
|
|
+import com.bus.model.temp.AddWaterTemp;
|
|
|
+import com.bus.model.temp.AddWaterTempRowMap;
|
|
|
+import com.bus.model.temp.BusMonthAssessmentTemp;
|
|
|
+import com.bus.service.IBusMonthAssessmentService;
|
|
|
+import com.bus.service.IBusOrgService;
|
|
|
+import com.core.dao.IGenericDao;
|
|
|
+import com.core.service.impl.GenericServiceImpl;
|
|
|
+import com.core.util.AppUtil;
|
|
|
+import com.core.util.Page;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
+import org.springframework.jdbc.core.RowMapper;
|
|
|
+
|
|
|
+import java.sql.ResultSet;
|
|
|
+import java.sql.SQLException;
|
|
|
+import java.text.DecimalFormat;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+public class BusMonthAssessmentServiceImpl extends GenericServiceImpl<BusMonthAssessment, Long> implements IBusMonthAssessmentService{
|
|
|
+ @Autowired
|
|
|
+ private IBusMonthAssessmentDao dao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private org.springframework.jdbc.core.JdbcTemplate jdbcTemplate;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected IGenericDao<BusMonthAssessment, Long> getGenericDao() {
|
|
|
+ return this.dao;
|
|
|
+ }
|
|
|
+
|
|
|
+ private IBusOrgService busOrgService = (IBusOrgService) AppUtil.getBean("busOrgService");
|
|
|
+ Logger log = LoggerFactory.getLogger(BusMonthAssessmentServiceImpl.class);
|
|
|
+
|
|
|
+// //超计划加价水费查询
|
|
|
+// @Override
|
|
|
+// public List<Object[]> getOutOfPlanMonthList(String orgNumber, String season, Integer year) {
|
|
|
+// String sql ="SELECT * FROM sheet1$ WHERE `单位编号`='"+orgNumber+"' AND `考核季度`='"+season+"' AND `年份`='"+year+"'";
|
|
|
+// RowMapper<Object[]> rowMapper = new RowMapper<Object[]>(){
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public Object[] mapRow(ResultSet rs, int index) throws SQLException {
|
|
|
+//// ids.add(rs.getLong("assessment_id"));
|
|
|
+// Object[] object = new Object[9];
|
|
|
+// object[0] = rs.getString("单位编号");
|
|
|
+// object[1] = rs.getString("单位名称");
|
|
|
+// object[2] = rs.getString("水表号");
|
|
|
+// object[3] = rs.getString("年份");
|
|
|
+// object[4] = rs.getString("考核季度");
|
|
|
+//
|
|
|
+// object[5] = rs.getDouble("增加30%后计划用水量");
|
|
|
+// object[6] = rs.getDouble("实际用水量");
|
|
|
+// object[7] = rs.getDouble("总金额");
|
|
|
+// object[8] = rs.getDouble("超用率")*100;
|
|
|
+//
|
|
|
+// return object;
|
|
|
+// }
|
|
|
+//
|
|
|
+// };
|
|
|
+// List<Object[]> list = jdbcTemplate.query(sql, rowMapper);
|
|
|
+//
|
|
|
+// return list;
|
|
|
+// }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Object[]> getMonthAssessmentListPage(int pageNo, int pageSize, Integer orgNumber,Integer customerNumber,Integer meterNumber,
|
|
|
+ String orgName, String year, String address, String isPlanUser,
|
|
|
+ String userType,String month,Integer overWaterBegin,Integer overWaterEnd,Integer amountReceivableBegin,Integer amountReceivableEnd,Long assessmentMonId
|
|
|
+ ,String isWriteOff,Float waterPrice) {
|
|
|
+ int star = pageSize*(pageNo-1);
|
|
|
+ String sql =
|
|
|
+ " SELECT "+
|
|
|
+ " t.`assessment_mon_id`, "+
|
|
|
+ " bo.`org_id`, "+
|
|
|
+ " bo.`org_number`, "+
|
|
|
+ " bo.`org_name`, "+
|
|
|
+ " bo.`address`, "+
|
|
|
+ " bo.`year`, "+
|
|
|
+ " bo.`user_type`, "+
|
|
|
+ " bo.`is_plan_user`, "+
|
|
|
+ " t.`water_type`, "+
|
|
|
+ " t.assessment_month, "+
|
|
|
+ " t.water_planning_index, "+
|
|
|
+ " t.`is_write_off`, "+
|
|
|
+ " t.`write_off_date`, "+
|
|
|
+ " t.`mode_of_payment`, "+
|
|
|
+ " t.`water_price`, "+
|
|
|
+ " t.`paid_in_amount`, "+
|
|
|
+ " t.`remark`, "+
|
|
|
+ " t.`invoice_no`,t.`tax_pay` , "+
|
|
|
+ " CASE "+
|
|
|
+ " WHEN t.assessment_month=1 THEN (SELECT (`first_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=2 THEN (SELECT (`first_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=3 THEN (SELECT (`first_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=4 THEN (SELECT (`second_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=5 THEN (SELECT (`second_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=6 THEN (SELECT (`second_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=7 THEN (SELECT (`third_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=8 THEN (SELECT (`third_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=9 THEN (SELECT (`third_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=10 THEN (SELECT (`fourth_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=11 THEN (SELECT (`fourth_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=12 THEN (SELECT (`fourth_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " ELSE 0 END "+
|
|
|
+ " AS reply_of_water, "+
|
|
|
+ " ROUND((( "+
|
|
|
+ " SELECT bs.fine_proportion "+
|
|
|
+ " FROM base_punishment_section bps LEFT JOIN base_section bs ON bps.punishment_id=bs.punishment_id "+
|
|
|
+ " WHERE CASE "+
|
|
|
+
|
|
|
+ " WHEN bs.contain_up=1 AND bs.contain_lower=1 AND bs.section_up_limit<=(IFNULL(ROUND(((bsrm.water-t.water_planning_index)/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+ " AND (IFNULL(ROUND(((bsrm.water-t.water_planning_index)/t.water_planning_index)*100 ,2),0)) <=bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+ " WHEN bs.contain_up=1 AND bs.contain_lower=0 AND bs.section_up_limit<=(IFNULL(ROUND(((bsrm.water-t.water_planning_index)/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+ " AND (IFNULL(ROUND(((bsrm.water-t.water_planning_index)/t.water_planning_index)*100 ,2),0)) <bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+ " WHEN bs.contain_up=0 AND bs.contain_lower=1 AND bs.section_up_limit<(IFNULL(ROUND(((bsrm.water-t.water_planning_index)/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+ " AND (IFNULL(ROUND(((bsrm.water-t.water_planning_index)/t.water_planning_index)*100 ,2),0)) <=bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+ " WHEN bs.contain_up=0 AND bs.contain_lower=0 AND bs.section_up_limit<(IFNULL(ROUND(((bsrm.water-t.water_planning_index)/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+ " AND (IFNULL(ROUND(((bsrm.water-t.water_planning_index)/t.water_planning_index)*100 ,2),0)) <bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+ " ELSE IF((IFNULL(ROUND(((bsrm.water-t.water_planning_index)/t.water_planning_index)*100 ,2),0)) <bs.section_up_limit,0,bs.section_lower_limit=0) AND bps.user_type=1 AND bps.`status`='1' "+
|
|
|
+ " END "+
|
|
|
+ " )/100) "+
|
|
|
+ " *IFNULL(ROUND(bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` "+
|
|
|
+ " WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)) ,0),0) "+
|
|
|
+ " "+
|
|
|
+ " *t.water_price,1) AS amount_receivable, "+
|
|
|
+ " "+
|
|
|
+ " IFNULL(bsrm.water,0) AS usewater, "+
|
|
|
+ " IFNULL(ROUND(bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` "+
|
|
|
+ " WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)) ,0),0) AS over_water, "+
|
|
|
+ " IFNULL(ROUND((bsrm.water-t.water_planning_index)/t.water_planning_index *100 ,2),0) AS over_water_percent "+
|
|
|
+ " ,bo.code, bo.postal_address"+
|
|
|
+ //*********************************************************
|
|
|
+ ", IFNULL( ROUND( IFNULL( ROUND( bsrm.water - ( t.water_planning_index * ("+
|
|
|
+ " 1+ (SELECT MIN(`section_up_limit`) FROM `base_section` bs"+
|
|
|
+ " JOIN `base_punishment_section` bps ON bs.`punishment_id` = bps.`punishment_id`"+
|
|
|
+ " WHERE `user_type` = '1' AND `section_type` = 'month' AND `status` = 1) / 100 ) ), 0 ), 0"+
|
|
|
+ " ) - t.water_planning_index * ( (SELECT MAX(`section_up_limit`) - MIN(`section_up_limit`) "+
|
|
|
+ " FROM `base_section` bs) / 100 ), 0 ), 0) AS Interval_up,"+
|
|
|
+ "IFNULL( ROUND( t.water_planning_index * ( (SELECT MAX(`section_up_limit`) - MIN(`section_up_limit`)"+
|
|
|
+ " FROM `base_section` bs) / 100 ), 0 ), 0) AS Interval_low,"+
|
|
|
+
|
|
|
+ " ROUND(IFNULL( ROUND( IFNULL( ROUND( bsrm.water - ( t.water_planning_index * ("+
|
|
|
+ " 1+ (SELECT MIN(`section_up_limit`) FROM `base_section` bs"+
|
|
|
+ " JOIN `base_punishment_section` bps ON bs.`punishment_id` = bps.`punishment_id` "+
|
|
|
+ " WHERE `user_type` = '1' AND `section_type` = 'month' AND `status` = 1) / 100 ) ), 0 ), 0 ) -"+
|
|
|
+ " t.water_planning_index *( (SELECT MAX(`section_up_limit`) - MIN(`section_up_limit`) FROM `base_section` bs ) / 100) , 0"+
|
|
|
+ " ), 0 ) * t.water_price,1) AS money_up,"+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ "IFNULL( ROUND( t.water_planning_index * ( (SELECT MAX(`section_up_limit`) - MIN(`section_up_limit`)"+
|
|
|
+ " FROM `base_section` bs) / 100 ) * t.water_price * 0.5, 1 ), 0) AS money_low ,t.reply_of_water as increase"+
|
|
|
+ //*****************************************************
|
|
|
+ " FROM bus_month_assessment t "+
|
|
|
+
|
|
|
+ " JOIN bus_org bo ON t.org_id=bo.org_id AND bo.`import_status`='normal' "+
|
|
|
+ " JOIN "+
|
|
|
+ " ( "+
|
|
|
+ " SELECT SUM(water) AS water, "+
|
|
|
+ " `month` AS X, "+
|
|
|
+ " org_id "+
|
|
|
+ " FROM bus_meter_read_info ";
|
|
|
+ if (year != null && !year.equals(""))
|
|
|
+ {
|
|
|
+ sql +=" WHERE YEAR='" + year + "' and org_id IS NOT NULL ";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sql +=" WHERE org_id IS NOT NULL ";
|
|
|
+ }
|
|
|
+ sql +=" GROUP BY X,org_id "+
|
|
|
+ " ) bsrm ON bsrm.org_id=t.org_id AND bsrm.X=t.assessment_month ";
|
|
|
+ if (orgNumber != null&&!orgNumber.equals(""))
|
|
|
+ sql += " and bo.org_number=" + orgNumber;
|
|
|
+ if (orgName != null&&!orgName.equals(""))
|
|
|
+ sql += " and bo.org_name like '%" + orgName + "%'";
|
|
|
+ if (year != null && !year.equals(""))
|
|
|
+ sql += " and bo.`year`='" + year + "'";
|
|
|
+ if (address != null && !address.equals(""))
|
|
|
+ sql += " and bo.address='" + address + "'";
|
|
|
+ if (isPlanUser != null && !isPlanUser.equals(""))
|
|
|
+ sql += " and bo.is_plan_user='" + isPlanUser + "'";
|
|
|
+ if (userType != null && !userType.equals(""))
|
|
|
+ sql += " and bo.user_type='" + userType + "'";
|
|
|
+ if (null != customerNumber && !customerNumber.equals(""))
|
|
|
+ sql += " and bcm.customer_Number=" +customerNumber;
|
|
|
+ if (null != meterNumber && !meterNumber.equals(""))
|
|
|
+ //sql += " and bcm.meter_Number=" + meterNumber;
|
|
|
+ sql += " and bo.org_id in(select org_id from bus_customer_meter where meter_Number='"+meterNumber+"')";
|
|
|
+ if (null != month && !month.equals(""))
|
|
|
+ sql += " and t.assessment_month in (" + month +")";
|
|
|
+ if (null != isWriteOff && !isWriteOff.equals(""))
|
|
|
+ sql += " and t.`is_write_off`='" + isWriteOff +"'";
|
|
|
+
|
|
|
+ if (null != waterPrice && !waterPrice.equals(""))
|
|
|
+ sql += " and t.`water_price`=" + waterPrice +"";
|
|
|
+
|
|
|
+ if ((null != overWaterBegin && !overWaterBegin.equals(""))&&(null != overWaterEnd && !overWaterEnd.equals(""))){
|
|
|
+ sql += " and IFNULL(ROUND(bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)) ,2),0) BETWEEN " + overWaterBegin +" AND "+overWaterEnd;
|
|
|
+ }else{
|
|
|
+ sql += " and IFNULL(ROUND(bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)) ,2),0)>0";
|
|
|
+ }
|
|
|
+ if ((null != amountReceivableBegin && !amountReceivableBegin.equals(""))&&(null != amountReceivableEnd && !amountReceivableEnd.equals("")))
|
|
|
+ sql +=
|
|
|
+ " AND ( "+
|
|
|
+ " ROUND((( "+
|
|
|
+ " SELECT bs.fine_proportion "+
|
|
|
+ " FROM base_punishment_section bps LEFT JOIN base_section bs ON bps.punishment_id=bs.punishment_id "+
|
|
|
+ " WHERE CASE "+
|
|
|
+ " WHEN bs.contain_up=1 AND bs.contain_lower=1 AND bs.section_up_limit<=(IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+ " AND (IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) <=bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+ " WHEN bs.contain_up=1 AND bs.contain_lower=0 AND bs.section_up_limit<=(IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+ " AND (IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) <bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+ " WHEN bs.contain_up=0 AND bs.contain_lower=1 AND bs.section_up_limit<(IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+ " AND (IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) <=bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+ " WHEN bs.contain_up=0 AND bs.contain_lower=0 AND bs.section_up_limit<(IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+ " AND (IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) <bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+ " ELSE IF((IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) <bs.section_up_limit,0,bs.section_lower_limit=0) AND bps.user_type=1 AND bps.`status`='1' "+
|
|
|
+ " END "+
|
|
|
+ " )/100) "+
|
|
|
+ " *IFNULL(ROUND(bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` "+
|
|
|
+ " WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)) ,0),0) "+
|
|
|
+ " "+
|
|
|
+ " *t.water_price,1) "+
|
|
|
+ " ) BETWEEN " + amountReceivableBegin +" AND "+amountReceivableEnd ;
|
|
|
+ if (null != assessmentMonId && !assessmentMonId.equals(""))
|
|
|
+ sql += " and t.assessment_mon_id=" + assessmentMonId;
|
|
|
+ sql += " ORDER BY t.`org_id`,t.`assessment_month` LIMIT ?,?";
|
|
|
+ //log.debug("测试sql"+sql);
|
|
|
+ RowMapper<Object[]> rowMapper = new RowMapper<Object[]>(){
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object[] mapRow(ResultSet rs, int index) throws SQLException {
|
|
|
+// ids.add(rs.getLong("assessment_id"));
|
|
|
+ Object[] object = new Object[33];
|
|
|
+ object[0] = rs.getLong("assessment_mon_id");
|
|
|
+ object[1] = rs.getLong("org_id");
|
|
|
+ object[2] = rs.getInt("org_number");
|
|
|
+ object[3] = rs.getString("org_name");
|
|
|
+ object[4] = rs.getString("address");
|
|
|
+ object[5] = rs.getString("year");
|
|
|
+ object[6] = rs.getString("user_type");
|
|
|
+ object[7] = rs.getString("is_plan_user");
|
|
|
+ object[8] = rs.getInt("assessment_month");
|
|
|
+ object[9] = rs.getFloat("water_planning_index");
|
|
|
+ object[10] = rs.getString("is_write_off");
|
|
|
+ object[11] = rs.getDate("write_off_date");
|
|
|
+ object[12] = rs.getString("mode_of_payment");
|
|
|
+ object[13] = rs.getFloat("water_price");
|
|
|
+ object[14] = rs.getFloat("usewater");
|
|
|
+ object[15] = rs.getFloat("over_water");
|
|
|
+ object[16] = rs.getFloat("over_water_percent");
|
|
|
+ object[17] = rs.getFloat("paid_in_amount");
|
|
|
+ object[18] = rs.getFloat("amount_receivable");
|
|
|
+ object[19] = rs.getString("water_type");
|
|
|
+ object[20] = rs.getString("remark");
|
|
|
+ object[21] = rs.getString("reply_of_water");
|
|
|
+ object[22] = rs.getString("invoice_no");
|
|
|
+ object[23] = rs.getString("code");
|
|
|
+ object[24] = rs.getString("postal_address");
|
|
|
+
|
|
|
+ BusOrg org=busOrgService.get(rs.getLong("org_id"));
|
|
|
+ object[25] = org.getBusOrgMeterNumber();
|
|
|
+ object[26] = rs.getString("tax_pay");
|
|
|
+
|
|
|
+ if(rs.getInt("Interval_up")<0)
|
|
|
+ {
|
|
|
+ object[27] = rs.getFloat("over_water");
|
|
|
+ object[28] = "0";
|
|
|
+ object[29] = rs.getFloat("amount_receivable");
|
|
|
+ object[30] = "";
|
|
|
+ object[31] = rs.getFloat("amount_receivable");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ object[27] = rs.getFloat("Interval_low");
|
|
|
+ object[28] = rs.getFloat("Interval_up");
|
|
|
+ object[29] = rs.getFloat("money_up");
|
|
|
+ object[30] = rs.getFloat("money_low");
|
|
|
+ object[31] = rs.getFloat("money_up")+rs.getFloat("money_low");
|
|
|
+ }
|
|
|
+ object[32] = rs.getFloat("increase");
|
|
|
+ return object;
|
|
|
+ }
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+ List<Object[]> list = jdbcTemplate.query(sql, rowMapper,star,pageSize);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<BusMonthAssessmentTemp> getMonthAssessmentForExcel(Integer pageNo, Integer pageSize, Integer orgNumber, Integer customerNumber, Integer meterNumber,
|
|
|
+ String orgName, String year, String address, String isPlanUser,
|
|
|
+ String userType, String month, Integer overWaterBegin, Integer overWaterEnd, Integer amountReceivableBegin, Integer amountReceivableEnd, String[] assessmentMonId, String isWriteOff) {
|
|
|
+ int star = pageSize*(pageNo-1);
|
|
|
+ String sql =
|
|
|
+ " SELECT "+
|
|
|
+ " t.`assessment_mon_id`, "+
|
|
|
+ " bo.`org_id`, "+
|
|
|
+ " bo.`org_number`, "+
|
|
|
+ " bo.`org_name`, "+
|
|
|
+ " bo.`address`, "+
|
|
|
+ " bo.`year`, "+
|
|
|
+ " bo.`user_type`, "+
|
|
|
+ " bo.`is_plan_user`, "+
|
|
|
+ " t.`water_type`, "+
|
|
|
+ " t.assessment_quarter, "+
|
|
|
+ " t.water_planning_index, "+
|
|
|
+ " t.`is_write_off`, "+
|
|
|
+ " t.`write_off_date`, "+
|
|
|
+ " t.`mode_of_payment`, "+
|
|
|
+ " t.`water_price`, "+
|
|
|
+ " t.`paid_in_amount`, "+
|
|
|
+ " t.`remark`, "+
|
|
|
+ " t.`invoice_no`, "+
|
|
|
+ " CASE "+
|
|
|
+ " WHEN t.assessment_month=1 THEN (SELECT (`first_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=2 THEN (SELECT (`first_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=3 THEN (SELECT (`first_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=4 THEN (SELECT (`second_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=5 THEN (SELECT (`second_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=6 THEN (SELECT (`second_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=7 THEN (SELECT (`third_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=8 THEN (SELECT (`third_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=9 THEN (SELECT (`third_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=10 THEN (SELECT (`fourth_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=11 THEN (SELECT (`fourth_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=12 THEN (SELECT (`fourth_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " ELSE 0 END "+
|
|
|
+ " AS reply_of_water, "+
|
|
|
+ " ROUND((( "+
|
|
|
+ " SELECT bs.fine_proportion "+
|
|
|
+ " FROM base_punishment_section bps LEFT JOIN base_section bs ON bps.punishment_id=bs.punishment_id "+
|
|
|
+ " WHERE CASE "+
|
|
|
+
|
|
|
+ //" IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='quarter' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0) AS over_water_percent "+
|
|
|
+ //" IFNULL(ROUND((bsrm.water-t.water_planning_index)/t.water_planning_index *100 ,2),0) AS over_water_percent "+
|
|
|
+ // "+
|
|
|
+ " WHEN bs.contain_up=1 AND bs.contain_lower=1 AND bs.section_up_limit<=(IFNULL(ROUND(((bsrm.water-t.water_planning_index)/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+ " AND (IFNULL(ROUND(((bsrm.water-t.water_planning_index)/t.water_planning_index)*100 ,2),0)) <=bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+ " WHEN bs.contain_up=1 AND bs.contain_lower=0 AND bs.section_up_limit<=(IFNULL(ROUND(((bsrm.water-t.water_planning_index)/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+ " AND (IFNULL(ROUND(((bsrm.water-t.water_planning_index)/t.water_planning_index)*100 ,2),0)) <bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+ " WHEN bs.contain_up=0 AND bs.contain_lower=1 AND bs.section_up_limit<(IFNULL(ROUND(((bsrm.water-t.water_planning_index)/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+ " AND (IFNULL(ROUND(((bsrm.water-t.water_planning_index)/t.water_planning_index)*100 ,2),0)) <=bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+ " WHEN bs.contain_up=0 AND bs.contain_lower=0 AND bs.section_up_limit<(IFNULL(ROUND(((bsrm.water-t.water_planning_index)/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+ " AND (IFNULL(ROUND(((bsrm.water-t.water_planning_index)/t.water_planning_index)*100 ,2),0)) <bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+ " ELSE IF((IFNULL(ROUND(((bsrm.water-t.water_planning_index)/t.water_planning_index)*100 ,2),0)) <bs.section_up_limit,0,bs.section_lower_limit=0) AND bps.user_type=1 AND bps.`status`='1' "+
|
|
|
+ " END "+
|
|
|
+ " )/100) "+
|
|
|
+ " *IFNULL(ROUND(bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` "+
|
|
|
+ " WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)) ,0),0) "+
|
|
|
+ " "+
|
|
|
+ " *t.water_price,1) AS amount_receivable, "+
|
|
|
+ " "+
|
|
|
+ " IFNULL(bsrm.water,0) AS usewater, "+
|
|
|
+ " IFNULL(ROUND(bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` "+
|
|
|
+ " WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)) ,0),0) AS over_water, "+
|
|
|
+ //" IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` "+
|
|
|
+ //" WHERE `user_type`='1' AND `section_type`='quarter' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0) AS over_water_percent,bo.`code`, bo.`postal_address` "+
|
|
|
+ " IFNULL(ROUND((bsrm.water-t.water_planning_index)/t.water_planning_index *100 ,2),0) AS over_water_percent "+
|
|
|
+ " ,bo.code, bo.postal_address "+
|
|
|
+ //**********************************************************************************************************
|
|
|
+ ", IFNULL( ROUND( IFNULL( ROUND( bsrm.water - ( t.water_planning_index * ("+
|
|
|
+ " 1+ (SELECT MIN(`section_up_limit`) FROM `base_section` bs"+
|
|
|
+ " JOIN `base_punishment_section` bps ON bs.`punishment_id` = bps.`punishment_id`"+
|
|
|
+ " WHERE `user_type` = '1' AND `section_type` = 'month' AND `status` = 1) / 100 ) ), 0 ), 0"+
|
|
|
+ " ) - t.water_planning_index * ( (SELECT MAX(`section_up_limit`) - MIN(`section_up_limit`) "+
|
|
|
+ " FROM `base_section` bs) / 100 ), 0 ), 0) AS Interval_up,"+
|
|
|
+ "IFNULL( ROUND( t.water_planning_index * ( (SELECT MAX(`section_up_limit`) - MIN(`section_up_limit`)"+
|
|
|
+ " FROM `base_section` bs) / 100 ), 0 ), 0) AS Interval_low,"+
|
|
|
+
|
|
|
+ " ROUND(IFNULL( ROUND( IFNULL( ROUND( bsrm.water - ( t.water_planning_index * ("+
|
|
|
+ " 1+ (SELECT MIN(`section_up_limit`) FROM `base_section` bs"+
|
|
|
+ " JOIN `base_punishment_section` bps ON bs.`punishment_id` = bps.`punishment_id` "+
|
|
|
+ " WHERE `user_type` = '1' AND `section_type` = 'month' AND `status` = 1) / 100 ) ), 0 ), 0 ) -"+
|
|
|
+ " t.water_planning_index *( (SELECT MAX(`section_up_limit`) - MIN(`section_up_limit`) FROM `base_section` bs ) / 100) , 0"+
|
|
|
+ " ), 0 ) * t.water_price,1 ) AS money_up,"+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ "IFNULL( ROUND( t.water_planning_index * ( (SELECT MAX(`section_up_limit`) - MIN(`section_up_limit`)"+
|
|
|
+ " FROM `base_section` bs) / 100 ) * t.water_price * 0.5, 1 ), 0) AS money_low ,t.reply_of_water as increase "+
|
|
|
+ //**********************************************************************************************************
|
|
|
+ " FROM bus_month_assessment t "+
|
|
|
+ " JOIN bus_org bo ON t.org_id=bo.org_id AND bo.`import_status`='normal' "+
|
|
|
+ " JOIN "+
|
|
|
+ " ( "+
|
|
|
+ " SELECT SUM(water) AS water, "+
|
|
|
+ " `month` AS X, "+
|
|
|
+ " org_id "+
|
|
|
+ " FROM bus_meter_read_info "+
|
|
|
+ " WHERE YEAR='" + year + "' and org_id IS NOT NULL "+
|
|
|
+ " GROUP BY X,org_id "+
|
|
|
+ " ) bsrm ON bsrm.org_id=t.org_id AND bsrm.X=t.assessment_month ";
|
|
|
+ if (orgNumber != null&&!orgNumber.equals(""))
|
|
|
+ sql += " and bo.org_number=" + orgNumber;
|
|
|
+ if (orgName != null&&!orgName.equals(""))
|
|
|
+ sql += " and bo.org_name='" + orgName + "'";
|
|
|
+ if (year != null && !year.equals(""))
|
|
|
+ sql += " and bo.`year`='" + year + "'";
|
|
|
+ if (address != null && !address.equals(""))
|
|
|
+ sql += " and bo.address='" + address + "'";
|
|
|
+ if (isPlanUser != null && !isPlanUser.equals(""))
|
|
|
+ sql += " and bo.is_plan_user='" + isPlanUser + "'";
|
|
|
+ if (userType != null && !userType.equals(""))
|
|
|
+ sql += " and bo.user_type='" + userType + "'";
|
|
|
+ if (null != customerNumber && !customerNumber.equals(""))
|
|
|
+ sql += " and bcm.customer_Number=" +customerNumber;
|
|
|
+ if (null != meterNumber && !meterNumber.equals(""))
|
|
|
+ //sql += " and bcm.meter_Number=" + meterNumber;
|
|
|
+ sql += " and bo.org_id in(select org_id from bus_customer_meter where meter_Number='"+meterNumber+"')";
|
|
|
+ if (null != month && !month.equals(""))
|
|
|
+ sql += " and t.assessment_month in (" + month +")";
|
|
|
+ if (null != isWriteOff && !isWriteOff.equals(""))
|
|
|
+ sql += " and t.`is_write_off`='" + isWriteOff +"'";
|
|
|
+ if ((null != overWaterBegin && !overWaterBegin.equals(""))&&(null != overWaterEnd && !overWaterEnd.equals(""))){
|
|
|
+ sql += " and IFNULL(ROUND(bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)) ,2),0) BETWEEN " + overWaterBegin +" AND "+overWaterEnd;
|
|
|
+ }else{
|
|
|
+ sql += " and IFNULL(ROUND(bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)) ,2),0)>0";
|
|
|
+ }
|
|
|
+
|
|
|
+ String paramIds = "";
|
|
|
+ if (null != assessmentMonId && !assessmentMonId.equals("")) {
|
|
|
+ for (int i = 0; i < assessmentMonId.length; i++) {
|
|
|
+ if(i==0){
|
|
|
+ paramIds += assessmentMonId[i];
|
|
|
+ }else{
|
|
|
+ paramIds += "," + assessmentMonId[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sql += " and t.assessment_mon_id IN ("+paramIds+")";
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((null != amountReceivableBegin && !amountReceivableBegin.equals(""))&&(null != amountReceivableEnd && !amountReceivableEnd.equals("")))
|
|
|
+ sql +=
|
|
|
+ " AND ( "+
|
|
|
+ " ROUND((( "+
|
|
|
+ " SELECT bs.fine_proportion "+
|
|
|
+ " FROM base_punishment_section bps LEFT JOIN base_section bs ON bps.punishment_id=bs.punishment_id "+
|
|
|
+ " WHERE CASE "+
|
|
|
+ " WHEN bs.contain_up=1 AND bs.contain_lower=1 AND bs.section_up_limit<=(IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+ " AND (IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) <=bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+ " WHEN bs.contain_up=1 AND bs.contain_lower=0 AND bs.section_up_limit<=(IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+ " AND (IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) <bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+ " WHEN bs.contain_up=0 AND bs.contain_lower=1 AND bs.section_up_limit<(IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+ " AND (IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) <=bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+ " WHEN bs.contain_up=0 AND bs.contain_lower=0 AND bs.section_up_limit<(IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+ " AND (IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) <bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+ " ELSE IF((IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) <bs.section_up_limit,0,bs.section_lower_limit=0) AND bps.user_type=1 AND bps.`status`='1' "+
|
|
|
+ " END "+
|
|
|
+ " )/100) "+
|
|
|
+ " *IFNULL(ROUND(bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` "+
|
|
|
+ " WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)) ,0),0) "+
|
|
|
+ " "+
|
|
|
+ " *t.water_price,1) "+
|
|
|
+ " ) BETWEEN " + amountReceivableBegin +" AND "+amountReceivableEnd ;
|
|
|
+ sql += " ORDER BY t.`org_id`,t.`assessment_month` LIMIT ?,?";
|
|
|
+ RowMapper<BusMonthAssessmentTemp> rowMapper = new RowMapper<BusMonthAssessmentTemp>(){
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public BusMonthAssessmentTemp mapRow(ResultSet rs, int index) throws SQLException {
|
|
|
+ BusMonthAssessmentTemp bqat = new BusMonthAssessmentTemp();
|
|
|
+ bqat.setOrgNumber(rs.getString("org_number"));
|
|
|
+ bqat.setOrgName(rs.getString("org_name"));
|
|
|
+ bqat.setAddress(rs.getString("address"));
|
|
|
+ bqat.setYear(rs.getString("year"));
|
|
|
+ if("1".equals(rs.getString("user_type"))){
|
|
|
+ bqat.setUserType("自来水户");
|
|
|
+ }else{
|
|
|
+ bqat.setUserType("取水户");
|
|
|
+ }
|
|
|
+ if("yes".equals(rs.getString("is_plan_user"))){
|
|
|
+ bqat.setIsPlanUser("是");
|
|
|
+ }else{
|
|
|
+ bqat.setIsPlanUser("否");
|
|
|
+ }
|
|
|
+ bqat.setAssessmentMonth(rs.getInt("assessment_month"));
|
|
|
+ bqat.setWaterPlanningIndex(rs.getString("water_planning_index"));
|
|
|
+ if("yes".equals(rs.getString("is_write_off"))){
|
|
|
+ bqat.setIsWriteOff("是");
|
|
|
+ }else{
|
|
|
+ bqat.setIsWriteOff("否");
|
|
|
+ }
|
|
|
+ bqat.setWriteOffDate(rs.getDate("write_off_date"));
|
|
|
+ if("1".equals(rs.getString("mode_of_payment"))){
|
|
|
+ bqat.setModeOfPayment("现金");
|
|
|
+ }else if("2".equals(rs.getString("mode_of_payment"))){
|
|
|
+ bqat.setModeOfPayment("转账");
|
|
|
+ }else{
|
|
|
+ bqat.setModeOfPayment("");
|
|
|
+ }
|
|
|
+ DecimalFormat df = new DecimalFormat("#.0");
|
|
|
+ bqat.setWaterPrice(rs.getFloat("water_price"));
|
|
|
+ bqat.setActualUseWater(rs.getString("usewater"));
|
|
|
+ bqat.setActualClosingWater(rs.getString("over_water"));
|
|
|
+ bqat.setPaidInAmount(Float.parseFloat(df.format(rs.getFloat("paid_in_amount"))));
|
|
|
+ bqat.setAmountReceivable(rs.getString("amount_receivable"));
|
|
|
+ bqat.setWaterType(rs.getString("water_type"));
|
|
|
+ bqat.setRemark(rs.getString("remark"));
|
|
|
+ bqat.setReplyOfWater(rs.getString("reply_of_water"));
|
|
|
+ bqat.setOverWaterPercent(rs.getString("over_water_percent")+'%');
|
|
|
+ bqat.setpost(rs.getString("code"));
|
|
|
+ bqat.setpostAddress(rs.getString("postal_address"));
|
|
|
+ BusOrg org=busOrgService.get(rs.getLong("org_id"));
|
|
|
+ bqat.setmeterNumber(org.getBusOrgMeterNumber());
|
|
|
+
|
|
|
+ if(rs.getInt("Interval_up")<0)
|
|
|
+ {
|
|
|
+ bqat.setIntervallow(rs.getFloat("over_water"));
|
|
|
+ bqat.setIntervalup(Float.parseFloat("0"));
|
|
|
+ bqat.setMoneyup(rs.getFloat("amount_receivable"));
|
|
|
+ bqat.setMoneylow(Float.parseFloat("0"));
|
|
|
+ bqat.setMoneyall(rs.getFloat("amount_receivable"));
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ bqat.setIntervallow(rs.getFloat("Interval_low"));
|
|
|
+ bqat.setIntervalup(rs.getFloat("Interval_up"));
|
|
|
+ bqat.setMoneyup(Float.parseFloat(df.format(rs.getFloat("money_low"))));
|
|
|
+ bqat.setMoneylow(Float.parseFloat(df.format(rs.getFloat("money_up"))));
|
|
|
+ bqat.setMoneyall(Float.parseFloat(df.format(rs.getFloat("money_up")+rs.getFloat("money_low"))));
|
|
|
+ }
|
|
|
+ bqat.setReplyOfIncrease(rs.getFloat("increase"));
|
|
|
+ return bqat;
|
|
|
+ }
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+ List<BusMonthAssessmentTemp> list = jdbcTemplate.query(sql, rowMapper,star,pageSize);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Object[]> getMonthOverWater(Long orgId, Integer month,String year) {
|
|
|
+ String sql =
|
|
|
+ " SELECT IFNULL(SUM(bmri.`water`),0) AS over_water FROM `bus_meter_read_info` bmri "+
|
|
|
+ " WHERE bmri.`org_id`=? AND bmri.`month`=? AND bmri.`year`=? ";
|
|
|
+
|
|
|
+ RowMapper<Object[]> rowMapper = new RowMapper<Object[]>(){
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object[] mapRow(ResultSet rs, int index) throws SQLException {
|
|
|
+ Object[] object = new Object[1];
|
|
|
+ object[0] = rs.getString("over_water");
|
|
|
+ return object;
|
|
|
+ }
|
|
|
+
|
|
|
+ };
|
|
|
+ List<Object[]> list = jdbcTemplate.query(sql, rowMapper, orgId, month, year);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getTotalRows(int pageSize,Integer orgNumber,Integer customerNumber,Integer meterNumber,
|
|
|
+ String orgName, String year, String address, String isPlanUser,
|
|
|
+ String userType,String month,Integer overWaterBegin,Integer overWaterEnd,Integer amountReceivableBegin,Integer amountReceivableEnd,String isWriteOff,Float waterPrice) {
|
|
|
+ String sql =
|
|
|
+ " SELECT COUNT(*) "+
|
|
|
+ " FROM bus_month_assessment t "+
|
|
|
+ " JOIN bus_org bo ON t.org_id=bo.org_id AND bo.`import_status`='normal' "+
|
|
|
+ " JOIN "+
|
|
|
+ " ( "+
|
|
|
+ " SELECT SUM(water) AS water, "+
|
|
|
+ " `month` AS X, "+
|
|
|
+ " org_id "+
|
|
|
+ " FROM bus_meter_read_info "+
|
|
|
+ " WHERE YEAR='" + year + "' AND org_id IS NOT NULL "+
|
|
|
+ " GROUP BY X,org_id "+
|
|
|
+ " ) bsrm ON bsrm.org_id=t.org_id AND bsrm.X=t.assessment_month "+
|
|
|
+ " WHERE 1=1 " ;
|
|
|
+ if (orgNumber != null&&!orgNumber.equals(""))
|
|
|
+ sql += " and bo.org_number=" + orgNumber;
|
|
|
+ if (orgName != null&&!orgName.equals(""))
|
|
|
+ sql += " and bo.org_name like '%" + orgName + "%'";
|
|
|
+ if (year != null && !year.equals(""))
|
|
|
+ sql += " and bo.`year`='" + year + "'";
|
|
|
+ if (address != null && !address.equals(""))
|
|
|
+ sql += " and bo.address='" + address + "'";
|
|
|
+ if (isPlanUser != null && !isPlanUser.equals(""))
|
|
|
+ sql += " and bo.is_plan_user='" + isPlanUser + "'";
|
|
|
+ if (userType != null && !userType.equals(""))
|
|
|
+ sql += " and bo.user_type='" + userType + "'";
|
|
|
+ if (null != customerNumber && !customerNumber.equals(""))
|
|
|
+ sql += " and bcm.customer_Number=" +customerNumber;
|
|
|
+ if (null != meterNumber && !meterNumber.equals(""))
|
|
|
+ //sql += " and bcm.meter_Number=" + meterNumber;
|
|
|
+ sql += " and bo.org_id in(select org_id from bus_customer_meter where meter_Number='"+meterNumber+"')";
|
|
|
+ if (null != month && !month.equals(""))
|
|
|
+ sql += " and t.assessment_month in (" + month +")";
|
|
|
+ if (null != isWriteOff && !isWriteOff.equals(""))
|
|
|
+ sql += " and t.`is_write_off`='" + isWriteOff +"'";
|
|
|
+ if (null != waterPrice && !waterPrice.equals(""))
|
|
|
+ sql += " and t.`water_price`=" + waterPrice +"";
|
|
|
+
|
|
|
+ if ((null != overWaterBegin && !overWaterBegin.equals(""))&&(null != overWaterEnd && !overWaterEnd.equals(""))){
|
|
|
+ sql += " and IFNULL(ROUND(bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)) ,2),0) BETWEEN " + overWaterBegin +" AND "+overWaterEnd;
|
|
|
+ }else{
|
|
|
+ sql += " and IFNULL(ROUND(bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)) ,2),0)>0";
|
|
|
+ }
|
|
|
+ if ((null != amountReceivableBegin && !amountReceivableBegin.equals(""))&&(null != amountReceivableEnd && !amountReceivableEnd.equals("")))
|
|
|
+ sql +=
|
|
|
+ " AND ( "+
|
|
|
+ " ROUND((( "+
|
|
|
+ " SELECT bs.fine_proportion "+
|
|
|
+ " FROM base_punishment_section bps LEFT JOIN base_section bs ON bps.punishment_id=bs.punishment_id "+
|
|
|
+ " WHERE CASE "+
|
|
|
+ " WHEN bs.contain_up=1 AND bs.contain_lower=1 AND bs.section_up_limit<=(IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+ " AND (IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) <=bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+ " WHEN bs.contain_up=1 AND bs.contain_lower=0 AND bs.section_up_limit<=(IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+ " AND (IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) <bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+ " WHEN bs.contain_up=0 AND bs.contain_lower=1 AND bs.section_up_limit<(IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+ " AND (IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) <=bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+ " WHEN bs.contain_up=0 AND bs.contain_lower=0 AND bs.section_up_limit<(IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+ " AND (IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) <bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+ " ELSE IF((IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) <bs.section_up_limit,0,bs.section_lower_limit=0) AND bps.user_type=1 AND bps.`status`='1' "+
|
|
|
+ " END "+
|
|
|
+ " )/100) "+
|
|
|
+ " *IFNULL(ROUND(bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` "+
|
|
|
+ " WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)) ,0),0) "+
|
|
|
+ " "+
|
|
|
+ " *t.water_price,1) "+
|
|
|
+ " ) BETWEEN " + amountReceivableBegin +" AND "+amountReceivableEnd ;
|
|
|
+ return jdbcTemplate.queryForInt(sql);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+// @Override
|
|
|
+// public List<AddWaterTemp> getHalfYearOfAddWaterMonth(String year,
|
|
|
+// String userType, String month, String orgName, String isWriteOff) {
|
|
|
+//
|
|
|
+// /*
|
|
|
+// * modify by lhj 2021-01-18
|
|
|
+// */
|
|
|
+// String sql =
|
|
|
+// " SELECT "+
|
|
|
+// " notice.`org_id`, "+
|
|
|
+// " notice.`org_name`, "+
|
|
|
+// " notice.`year`, "+
|
|
|
+// " GROUP_CONCAT(IFNULL(notice.assessment_quarter,0)) AS quarters, "+
|
|
|
+// " GROUP_CONCAT(IFNULL(notice.water_planning_index,0)) AS planWaters, "+
|
|
|
+// " GROUP_CONCAT(IFNULL(notice.amount_receivable,'0.0')) AS amountReceivables, "+
|
|
|
+// " GROUP_CONCAT(IFNULL(notice.usewater,0)) AS useWaters, "+
|
|
|
+// " GROUP_CONCAT(IFNULL(notice.over_water,0)) AS overWaters "+
|
|
|
+// " FROM( "+
|
|
|
+// " SELECT "+
|
|
|
+// " bo.`org_id`, "+
|
|
|
+// " bo.`org_name`, "+
|
|
|
+// " bo.`year`, "+
|
|
|
+// " t.assessment_quarter, "+
|
|
|
+// " t.water_planning_index, "+
|
|
|
+// " t.`is_write_off`, "+
|
|
|
+// " ROUND((( "+
|
|
|
+// " SELECT bs.fine_proportion "+
|
|
|
+// " FROM base_punishment_section bps LEFT JOIN base_section bs ON bps.punishment_id=bs.punishment_id "+
|
|
|
+// " WHERE CASE "+
|
|
|
+// " WHEN bs.contain_up=1 AND bs.contain_lower=1 AND bs.section_up_limit<=(IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='quarter' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+// " AND (IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='quarter' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) <=bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+// " WHEN bs.contain_up=1 AND bs.contain_lower=0 AND bs.section_up_limit<=(IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='quarter' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+// " AND (IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='quarter' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) <bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+// " WHEN bs.contain_up=0 AND bs.contain_lower=1 AND bs.section_up_limit<(IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='quarter' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+// " AND (IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='quarter' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) <=bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+// " WHEN bs.contain_up=0 AND bs.contain_lower=0 AND bs.section_up_limit<(IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='quarter' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+// " AND (IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='quarter' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) <bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+// " ELSE IF((IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='quarter' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) <bs.section_up_limit,0,bs.section_lower_limit=0) AND bps.user_type=1 AND bps.`status`='1' "+
|
|
|
+// " END "+
|
|
|
+// " )/100) "+
|
|
|
+// " *IFNULL(ROUND(bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` "+
|
|
|
+// " WHERE `user_type`='1' AND `section_type`='quarter' AND `status`=1)/100)) ,0),0) "+
|
|
|
+// " "+
|
|
|
+// " *t.water_price,1) AS amount_receivable, "+
|
|
|
+// " "+
|
|
|
+// " IFNULL(bsrm.water,0) AS usewater, "+
|
|
|
+// " IFNULL(ROUND(bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` "+
|
|
|
+// " WHERE `user_type`='1' AND `section_type`='quarter' AND `status`=1)/100)) ,0),0) AS over_water "+
|
|
|
+// " FROM bus_quarterly_assessment t "+
|
|
|
+// " JOIN bus_org bo ON t.org_id=bo.org_id AND bo.import_status='normal' "+
|
|
|
+// " join "+
|
|
|
+// " ( "+
|
|
|
+// " SELECT SUM(water) AS water,MIN(`base_water_price`) AS water_price, CASE "+
|
|
|
+// " WHEN `month`=1 OR `month`=2 OR `month`=3 THEN '1' "+
|
|
|
+// " WHEN `month`=4 OR `month`=5 OR `month`=6 THEN '2' "+
|
|
|
+// " WHEN `month`=7 OR `month`=8 OR `month`=9 THEN '3' "+
|
|
|
+// " ELSE '4' END X, "+
|
|
|
+// " org_id "+
|
|
|
+// " FROM bus_meter_read_info "+
|
|
|
+// " WHERE org_id IS NOT NULL "+
|
|
|
+// " GROUP BY X,org_id "+
|
|
|
+// " ) bsrm ON bsrm.org_id=t.org_id AND bsrm.X=t.assessment_quarter "+
|
|
|
+// " AND IFNULL(ROUND(bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) "+
|
|
|
+// " FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` "+
|
|
|
+// " WHERE `user_type`='1' AND `section_type`='quarter' AND `status`=1)/100)) ,0),0)>0 "+
|
|
|
+// " ) AS notice GROUP BY notice.`org_id`,notice.`year` ";
|
|
|
+//
|
|
|
+// StringBuffer sb=new StringBuffer();
|
|
|
+// sb.append(sql);
|
|
|
+// String insertPositionBefore=") AS notice";
|
|
|
+//
|
|
|
+// if (orgName != null&&!orgName.equals("")){
|
|
|
+// sql= " and bo.org_name='"+orgName+"'";
|
|
|
+// sb.insert(sb.indexOf(insertPositionBefore), sql);
|
|
|
+// }
|
|
|
+// if (year != null && !year.equals("")){
|
|
|
+// sql = " and bo.`year`='" + year + "'";
|
|
|
+// sb.insert(sb.indexOf(insertPositionBefore), sql);
|
|
|
+// }
|
|
|
+// if (userType != null && !userType.equals("")){
|
|
|
+// sql= " and bo.user_type='" + userType + "'";
|
|
|
+// sb.insert(sb.indexOf(insertPositionBefore), sql);
|
|
|
+// }
|
|
|
+// if (null != quarter && !quarter.equals("")){
|
|
|
+// sql = " and t.assessment_quarter IN(" + quarter +")";
|
|
|
+// sb.insert(sb.indexOf(insertPositionBefore), sql);
|
|
|
+// }
|
|
|
+// if (null != isWriteOff && !isWriteOff.equals("")){
|
|
|
+// sql = " and t.`is_write_off`='" + isWriteOff +"'";
|
|
|
+// sb.insert(sb.indexOf(insertPositionBefore), sql);
|
|
|
+// }
|
|
|
+// List<AddWaterTemp> at = jdbcTemplate.query(sb.toString(),new Object[]{},new AddWaterTempRowMap());
|
|
|
+// return at;
|
|
|
+// }
|
|
|
+
|
|
|
+// @SuppressWarnings({ "unchecked", "rawtypes" })
|
|
|
+//// @Override
|
|
|
+//// public AddWaterTemp getAddWaterDetailMonth(Long assessmentId) {
|
|
|
+////
|
|
|
+//// String sql =
|
|
|
+//// " SELECT "+
|
|
|
+//// " t.`assessment_id` AS assessmentId, "+
|
|
|
+//// " bo.`org_id` AS orgId, "+
|
|
|
+//// " bo.`org_name` AS orgName, "+
|
|
|
+//// " bo.`year`, "+
|
|
|
+//// " t.assessment_quarter AS assessmentQuarter, "+
|
|
|
+//// " t.water_planning_index AS planUseWater, "+
|
|
|
+//// " t.`is_write_off` AS isWriteOff, "+
|
|
|
+//// " ROUND((( "+
|
|
|
+//// " SELECT bs.fine_proportion "+
|
|
|
+//// " FROM base_punishment_section bps LEFT JOIN base_section bs ON bps.punishment_id=bs.punishment_id "+
|
|
|
+//// " WHERE CASE "+
|
|
|
+//// " WHEN bs.contain_up=1 AND bs.contain_lower=1 AND bs.section_up_limit<=(IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='quarter' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+//// " AND (IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='quarter' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) <=bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+//// " WHEN bs.contain_up=1 AND bs.contain_lower=0 AND bs.section_up_limit<=(IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='quarter' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+//// " AND (IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='quarter' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) <bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+//// " WHEN bs.contain_up=0 AND bs.contain_lower=1 AND bs.section_up_limit<(IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='quarter' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+//// " AND (IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='quarter' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) <=bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+//// " WHEN bs.contain_up=0 AND bs.contain_lower=0 AND bs.section_up_limit<(IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='quarter' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+//// " AND (IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='quarter' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) <bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+//// " ELSE IF((IFNULL(ROUND(((bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` WHERE `user_type`='1' AND `section_type`='quarter' AND `status`=1)/100)))/t.water_planning_index)*100 ,2),0)) <bs.section_up_limit,0,bs.section_lower_limit=0) AND bps.user_type=1 AND bps.`status`='1' "+
|
|
|
+//// " END "+
|
|
|
+//// " )/100) "+
|
|
|
+//// " *IFNULL(ROUND(bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` "+
|
|
|
+//// " WHERE `user_type`='1' AND `section_type`='quarter' AND `status`=1)/100)) ,0),0) "+
|
|
|
+//// " "+
|
|
|
+//// " *t.water_price,1) AS amountReceivable, "+
|
|
|
+//// " "+
|
|
|
+//// " IFNULL(bsrm.water,0) AS actualWater, "+
|
|
|
+//// " IFNULL(ROUND(bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` "+
|
|
|
+//// " WHERE `user_type`='1' AND `section_type`='quarter' AND `status`=1)/100)) ,0),0) AS exceedUseWater "+
|
|
|
+//// " FROM bus_quarterly_assessment t "+
|
|
|
+//// " JOIN bus_org bo ON t.org_id=bo.org_id AND bo.import_status='normal' "+
|
|
|
+//// " JOIN "+
|
|
|
+//// " ( "+
|
|
|
+//// " SELECT SUM(water) AS water,MIN(`base_water_price`) AS water_price, CASE "+
|
|
|
+//// " WHEN `month`=1 OR `month`=2 OR `month`=3 THEN '1' "+
|
|
|
+//// " WHEN `month`=4 OR `month`=5 OR `month`=6 THEN '2' "+
|
|
|
+//// " WHEN `month`=7 OR `month`=8 OR `month`=9 THEN '3' "+
|
|
|
+//// " ELSE '4' END X, "+
|
|
|
+//// " org_id "+
|
|
|
+//// " FROM bus_meter_read_info "+
|
|
|
+//// " WHERE org_id IS NOT NULL "+
|
|
|
+//// " GROUP BY X,org_id "+
|
|
|
+//// " ) bsrm ON bsrm.org_id=t.org_id AND bsrm.X=t.assessment_quarter "+
|
|
|
+//// " AND IFNULL(ROUND(bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) "+
|
|
|
+//// " FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` "+
|
|
|
+//// " WHERE `user_type`='1' AND `section_type`='quarter' AND `status`=1)/100)) ,0),0)>0 AND t.`assessment_id`=? ";
|
|
|
+////
|
|
|
+////
|
|
|
+//// return (AddWaterTemp) jdbcTemplate.queryForObject(sql, new Object[]{assessmentId}, new BeanPropertyRowMapper(AddWaterTemp.class));
|
|
|
+//// }
|
|
|
+
|
|
|
+// @Override
|
|
|
+// public void delMonthAssessmentByOrgId(Long orgId) {
|
|
|
+// jdbcTemplate.update("DELETE FROM `bus_quarterly_assessment` WHERE `org_id`=?",orgId);
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public void updateWaterPrice(String year) {
|
|
|
+// jdbcTemplate.execute("CALL update_quarterly_assessment('"+year+"')");
|
|
|
+// }
|
|
|
+// //微信公众号某单位的今年取:计划用水量,实际收水量,超收水量,应缴加价水费
|
|
|
+ @Override
|
|
|
+ public List<BusMonthAssessment> getMonthAssessmentList(String orgNumber,Integer year) {
|
|
|
+
|
|
|
+ String sql =
|
|
|
+ " SELECT "+
|
|
|
+ " t.`assessment_mon_id`, "+
|
|
|
+ " bo.`org_id`, "+
|
|
|
+ " bo.`org_number`, "+
|
|
|
+ " bo.`org_name`, "+
|
|
|
+ " t.assessment_month, "+
|
|
|
+ " CASE "+
|
|
|
+ " WHEN t.assessment_month=1 THEN (SELECT (`first_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=2 THEN (SELECT (`first_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=3 THEN (SELECT (`first_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=4 THEN (SELECT (`second_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=5 THEN (SELECT (`second_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=6 THEN (SELECT (`second_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=7 THEN (SELECT (`third_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=8 THEN (SELECT (`third_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=9 THEN (SELECT (`third_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=10 THEN (SELECT (`fourth_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=11 THEN (SELECT (`fourth_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " WHEN t.assessment_month=12 THEN (SELECT (`fourth_quarter_reply`)/3 FROM `bus_annual_plan_for_water` WHERE `org_id`=bo.`org_id`) "+
|
|
|
+ " ELSE 0 END "+
|
|
|
+ " AS reply_of_water, "+
|
|
|
+ " ROUND((( "+
|
|
|
+ " SELECT bs.fine_proportion "+
|
|
|
+ " FROM base_punishment_section bps LEFT JOIN base_section bs ON bps.punishment_id=bs.punishment_id "+
|
|
|
+ " WHERE CASE "+
|
|
|
+ " WHEN bs.contain_up=1 AND bs.contain_lower=1 AND bs.section_up_limit<=(IFNULL(ROUND(((bsrm.water-t.water_planning_index)/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+ " AND (IFNULL(ROUND(((bsrm.water-t.water_planning_index)/t.water_planning_index)*100 ,2),0)) <=bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+ " WHEN bs.contain_up=1 AND bs.contain_lower=0 AND bs.section_up_limit<=(IFNULL(ROUND(((bsrm.water-t.water_planning_index)/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+ " AND (IFNULL(ROUND(((bsrm.water-t.water_planning_index)/t.water_planning_index)*100 ,2),0)) <bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+ " WHEN bs.contain_up=0 AND bs.contain_lower=1 AND bs.section_up_limit<(IFNULL(ROUND(((bsrm.water-t.water_planning_index)/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+ " AND (IFNULL(ROUND(((bsrm.water-t.water_planning_index)/t.water_planning_index)*100 ,2),0)) <=bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+ " WHEN bs.contain_up=0 AND bs.contain_lower=0 AND bs.section_up_limit<(IFNULL(ROUND(((bsrm.water-t.water_planning_index)/t.water_planning_index)*100 ,2),0)) "+
|
|
|
+ " AND (IFNULL(ROUND(((bsrm.water-t.water_planning_index)/t.water_planning_index)*100 ,2),0)) <bs.section_lower_limit THEN bs.fine_proportion "+
|
|
|
+ " ELSE IF((IFNULL(ROUND(((bsrm.water-t.water_planning_index)/t.water_planning_index)*100 ,2),0)) <bs.section_up_limit,0,bs.section_lower_limit=0) AND bps.user_type=1 AND bps.`status`='1' "+
|
|
|
+ " END "+
|
|
|
+ " )/100) "+
|
|
|
+ " *IFNULL(ROUND(bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` "+
|
|
|
+ " WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)) ,0),0) "+
|
|
|
+ " "+
|
|
|
+ " *t.water_price,1) AS amount_receivable, "+
|
|
|
+ " "+
|
|
|
+ " IFNULL(bsrm.water,0) AS usewater, "+
|
|
|
+ " IFNULL(ROUND(bsrm.water-(t.water_planning_index*(1+(SELECT MIN(`section_up_limit`) FROM `base_section` bs JOIN `base_punishment_section` bps ON bs.`punishment_id`=bps.`punishment_id` "+
|
|
|
+ " WHERE `user_type`='1' AND `section_type`='month' AND `status`=1)/100)) ,0),0) AS over_water, "+
|
|
|
+ " IFNULL(ROUND((bsrm.water-t.water_planning_index)/t.water_planning_index *100 ,2),0) AS over_water_percent "+
|
|
|
+ " ,bo.code, bo.postal_address FROM bus_month_assessment t "+
|
|
|
+ " JOIN bus_org bo ON t.org_id=bo.org_id AND bo.`import_status`='normal' "+
|
|
|
+ " JOIN "+
|
|
|
+ " ( "+
|
|
|
+ " SELECT SUM(water) AS water, "+
|
|
|
+ " `month` AS X, "+
|
|
|
+ " org_id "+
|
|
|
+ " FROM bus_meter_read_info ";
|
|
|
+ if (year != null && !year.equals(""))
|
|
|
+ {
|
|
|
+ sql +=" WHERE YEAR='" + year + "' and org_id IS NOT NULL ";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sql +=" WHERE org_id IS NOT NULL ";
|
|
|
+ }
|
|
|
+ sql +=" GROUP BY X,org_id "+
|
|
|
+ " ) bsrm ON bsrm.org_id=t.org_id AND bsrm.X=t.assessment_month ";
|
|
|
+ if (orgNumber != null&&!orgNumber.equals(""))
|
|
|
+ sql += " and bo.org_number=" + orgNumber;
|
|
|
+
|
|
|
+ if (year != null && !year.equals(""))
|
|
|
+ sql += " and bo.`year`='" + year + "'";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ sql += " ORDER BY t.`org_id`,t.`assessment_month` ";
|
|
|
+
|
|
|
+// RowMapper<Object[]> rowMapper2 = new RowMapper<Object[]>(){
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public Object[] mapRow(ResultSet rs, int index) throws SQLException {
|
|
|
+//
|
|
|
+// Object[] object = new Object[9];
|
|
|
+// object[0] = rs.getLong("assessment_id");
|
|
|
+// object[1] = rs.getLong("org_id");
|
|
|
+// object[2] = rs.getInt("org_number");
|
|
|
+// object[3] = rs.getString("org_name");
|
|
|
+// object[4] = rs.getInt("assessment_quarter");
|
|
|
+// object[5] = rs.getFloat("usewater");
|
|
|
+// object[6] = rs.getFloat("over_water");
|
|
|
+// object[7] = rs.getFloat("amount_receivable");
|
|
|
+// object[8] = rs.getString("reply_of_water");
|
|
|
+//
|
|
|
+// return object;
|
|
|
+// }
|
|
|
+//
|
|
|
+// };
|
|
|
+//
|
|
|
+// List<Object[]> list = jdbcTemplate.query(sql, rowMapper2);
|
|
|
+// return list;
|
|
|
+//
|
|
|
+
|
|
|
+
|
|
|
+ RowMapper<BusMonthAssessment> rowMapper = new RowMapper<BusMonthAssessment>(){
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public BusMonthAssessment mapRow(ResultSet rs, int index) throws SQLException {
|
|
|
+ BusMonthAssessment tmp = new BusMonthAssessment();
|
|
|
+ tmp.setAssessmentMonId(rs.getLong("assessment_mon_id"));
|
|
|
+ tmp.setAssessmentMonth(rs.getInt("assessment_month"));
|
|
|
+ tmp.setActualUseWater(rs.getFloat("usewater"));
|
|
|
+ tmp.setReplyOfWater(rs.getFloat("over_water"));
|
|
|
+ tmp.setBankAccount(getFloatRound(rs.getFloat("amount_receivable")));
|
|
|
+ tmp.setBank(rs.getString("reply_of_water"));
|
|
|
+ return tmp;
|
|
|
+ }
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+ List<BusMonthAssessment> list = jdbcTemplate.query(sql, rowMapper);
|
|
|
+ return list;
|
|
|
+
|
|
|
+ }
|
|
|
+ public static String getFloatRound(float sourceData)
|
|
|
+ {
|
|
|
+ double f1 = Math.round(sourceData * 100) * 0.01; //还原小数点后 a 位
|
|
|
+ return String.valueOf(f1);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page getAnnualPlanSelectedData(int pageNo, int pageSize, String orgName, String year) {
|
|
|
+ String hql = "select bapfw from BusAnnualPlanForWater bapfw left join bapfw.org bo where bo.importStatus='normal' AND bo.year='"+year+"' AND bapfw.isCancel='yes'";
|
|
|
+ if (null != orgName && !orgName.equals("")) {
|
|
|
+ hql += " and bo.orgName = '" + orgName + "'";
|
|
|
+ }
|
|
|
+ return dao.getPageByHql(hql, pageNo, pageSize);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|