|
|
@@ -5,6 +5,7 @@ import com.google.common.collect.Sets;
|
|
|
import com.kingdee.bos.BOSException;
|
|
|
import com.kingdee.bos.Context;
|
|
|
import com.kingdee.bos.framework.ejb.EJBFactory;
|
|
|
+import com.kingdee.eas.custom.dormitorysystem.waterelectricity.WaterElectricityInfo;
|
|
|
import com.kingdee.eas.framework.CoreBillBaseInfo;
|
|
|
import com.kingdee.eas.hr.base.HRBillStateEnum;
|
|
|
import com.kingdee.eas.util.app.DbUtil;
|
|
|
@@ -52,7 +53,7 @@ public abstract class WaterElectricityBatchListHandler extends CommonBatchListHa
|
|
|
this.successMessage = successMessage;
|
|
|
}
|
|
|
/**
|
|
|
- * 计算水电费用
|
|
|
+ * 璁$畻姘寸數璐圭敤
|
|
|
*
|
|
|
* @param waterElectricityInfo
|
|
|
* @param map
|
|
|
@@ -61,21 +62,21 @@ public abstract class WaterElectricityBatchListHandler extends CommonBatchListHa
|
|
|
*/
|
|
|
protected CoreBillBaseInfo calculateWaterElectricity(CoreBillBaseInfo waterElectricityInfo, Map<String, Object> map,
|
|
|
Map<String, Object> occupants) {
|
|
|
- BigDecimal waterprice = (BigDecimal) map.get("waterprice");//水费单价
|
|
|
- BigDecimal electricityprice = (BigDecimal) map.get("electricityprice");//电费单价
|
|
|
+ BigDecimal waterprice = (BigDecimal) map.get("waterprice");//姘磋垂鍗曚环
|
|
|
+ BigDecimal electricityprice = (BigDecimal) map.get("electricityprice");//鐢佃垂鍗曚环
|
|
|
BigDecimal curMonthWater = (BigDecimal) map.get("curMonthWater");
|
|
|
BigDecimal curMonthElecDegrees = (BigDecimal) map.get("curMonthElecDegrees");
|
|
|
|
|
|
LocalDate startPeriodDate = (LocalDate) map.get("startPeriodDate");
|
|
|
LocalDate endPeriodDate = (LocalDate) map.get("endPeriodDate");
|
|
|
|
|
|
- Date checkInDate = (Date) map.get("checkInDate");//入住日期
|
|
|
+ Date checkInDate = (Date) map.get("checkInDate");//鍏ヤ綇鏃ユ湡
|
|
|
|
|
|
- Date checkOutDate = (Date) map.get("checkOutDate");//离宿日期
|
|
|
+ Date checkOutDate = (Date) map.get("checkOutDate");//绂诲�鏃ユ湡
|
|
|
|
|
|
waterElectricityInfo.put("waterTotalCost",(waterprice.multiply(curMonthWater)));
|
|
|
waterElectricityInfo.put("electricityTotalCost",(electricityprice.multiply(curMonthElecDegrees)));
|
|
|
- //处理当月入住天数
|
|
|
+ //澶勭悊褰撴湀鍏ヤ綇澶╂暟
|
|
|
LocalDate checkInDateLocal = (new Date(checkInDate.getTime())).toInstant()
|
|
|
.atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
checkInDateLocal = (checkInDateLocal.compareTo(startPeriodDate) > 0 ? checkInDateLocal : startPeriodDate);
|
|
|
@@ -88,16 +89,16 @@ public abstract class WaterElectricityBatchListHandler extends CommonBatchListHa
|
|
|
BigDecimal days = new BigDecimal((long) occupants.get("days"));
|
|
|
waterElectricityInfo.put("allMonthDays",(days));
|
|
|
waterElectricityInfo.put("monthDays",(new BigDecimal(daysBetween)));
|
|
|
- //? 当月水费:宿舍用水总费用/宿舍内所有人员当月总入住天数*该人员当前宿舍的入住天数;
|
|
|
+ //? 褰撴湀姘磋垂锛氬�鑸嶇敤姘存€昏垂鐢�/瀹胯垗鍐呮墍鏈変汉鍛樺綋鏈堟€诲叆浣忓ぉ鏁�*璇ヤ汉鍛樺綋鍓嶅�鑸嶇殑鍏ヤ綇澶╂暟锛�
|
|
|
BigDecimal monthWaterAmount = waterElectricityInfo.getBigDecimal("waterTotalCost")
|
|
|
.divide(days, BigDecimal.ROUND_HALF_UP, BigDecimal.ROUND_HALF_UP)
|
|
|
.multiply(waterElectricityInfo.getBigDecimal("MonthDays"));
|
|
|
- waterElectricityInfo.put("monthWaterAmount",monthWaterAmount);
|
|
|
- //? 当月电费:宿舍用电总费用/宿舍内所有人员当月总入住天数*该人员当前宿舍的入住天数;
|
|
|
+ waterElectricityInfo.put("monthWaterAmount",monthWaterAmount.setScale(2,BigDecimal.ROUND_HALF_UP));
|
|
|
+ //? 褰撴湀鐢佃垂锛氬�鑸嶇敤鐢垫€昏垂鐢�/瀹胯垗鍐呮墍鏈変汉鍛樺綋鏈堟€诲叆浣忓ぉ鏁�*璇ヤ汉鍛樺綋鍓嶅�鑸嶇殑鍏ヤ綇澶╂暟锛�
|
|
|
BigDecimal monthElectricityAmount = waterElectricityInfo.getBigDecimal("ElectricityTotalCost")
|
|
|
.divide(days, BigDecimal.ROUND_HALF_UP, BigDecimal.ROUND_HALF_UP)
|
|
|
.multiply(waterElectricityInfo.getBigDecimal("MonthDays"));
|
|
|
- waterElectricityInfo.put("monthElectricityAmount",monthElectricityAmount);
|
|
|
+ waterElectricityInfo.put("monthElectricityAmount",monthElectricityAmount.setScale(2,BigDecimal.ROUND_HALF_UP));
|
|
|
return waterElectricityInfo;
|
|
|
}
|
|
|
public static String convertListToString(Object[] array) {
|
|
|
@@ -123,16 +124,16 @@ public abstract class WaterElectricityBatchListHandler extends CommonBatchListHa
|
|
|
billids.removeAll(sess);
|
|
|
request.setAttribute("billId", convertListToString(sess.toArray()));
|
|
|
if (null != errs && (!errs.isEmpty())) {
|
|
|
- this.addBatchMessageTips(errs, "为锁定状态不能更新", batchMessageTipsHeader);
|
|
|
+ this.addBatchMessageTips(errs, "涓洪攣瀹氱姸鎬佷笉鑳芥洿鏂�", batchMessageTipsHeader);
|
|
|
}
|
|
|
billids.removeAll(errs);
|
|
|
if (null != billids && (!billids.isEmpty())) {
|
|
|
- this.addBatchMessageTips(errs, "为锁定状态不能更新", batchMessageTipsHeader);
|
|
|
+ this.addBatchMessageTips(errs, "涓洪攣瀹氱姸鎬佷笉鑳芥洿鏂�", batchMessageTipsHeader);
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
- * 获取当前宿舍的总入住天数
|
|
|
- * 宿舍内所有人员当月总入住天数
|
|
|
+ * 鑾峰彇褰撳墠瀹胯垗鐨勬€诲叆浣忓ぉ鏁�
|
|
|
+ * 瀹胯垗鍐呮墍鏈変汉鍛樺綋鏈堟€诲叆浣忓ぉ鏁�
|
|
|
*
|
|
|
* @param ctx
|
|
|
* @param dormitorys
|
|
|
@@ -146,12 +147,12 @@ public abstract class WaterElectricityBatchListHandler extends CommonBatchListHa
|
|
|
Collection<String> dormitorys, LocalDate startPeriodDate, LocalDate endPeriodDate
|
|
|
) throws BOSException, SQLException {
|
|
|
|
|
|
- //获取开始时间,结束时间
|
|
|
+ //鑾峰彇寮€濮嬫椂闂达紝缁撴潫鏃堕棿
|
|
|
String startPeriodDateStr = startPeriodDate.format(DateTimeFormatter.ISO_LOCAL_DATE);
|
|
|
String endPeriodDateStr = endPeriodDate.format(DateTimeFormatter.ISO_LOCAL_DATE);
|
|
|
|
|
|
Map<String, Map<String, Object>> occupantsMap = Maps.newHashMap();
|
|
|
- //处理当月入住天数
|
|
|
+ //澶勭悊褰撴湀鍏ヤ綇澶╂暟
|
|
|
StringBuilder selCunt = new StringBuilder();
|
|
|
selCunt.append(" select CFDormitoryID,CFPersonPositionID,CFCheckOutDate,CFCheckInDate from CT_OCC_Occupants ");
|
|
|
selCunt.append(" where to_char(CFCheckOutDate ,'yyyy-MM-dd') >= '" + startPeriodDateStr + "' ");
|
|
|
@@ -188,7 +189,7 @@ public abstract class WaterElectricityBatchListHandler extends CommonBatchListHa
|
|
|
return occupantsMap;
|
|
|
}
|
|
|
/**
|
|
|
- * 锁定
|
|
|
+ * 閿佸畾
|
|
|
*
|
|
|
* @param request
|
|
|
* @param response
|
|
|
@@ -218,7 +219,7 @@ public abstract class WaterElectricityBatchListHandler extends CommonBatchListHa
|
|
|
while (rs.next()) {
|
|
|
String id = rs.getString("fid");
|
|
|
errs.add(id);
|
|
|
- this.addBatchMessageTip(id, "已经锁定,不能再次锁定。", batchMessageTipsHeader);
|
|
|
+ this.addBatchMessageTip(id, "宸茬粡閿佸畾锛屼笉鑳藉啀娆¢攣瀹氥€�", batchMessageTipsHeader);
|
|
|
}
|
|
|
sess.removeAll(errs);
|
|
|
for (String id : sess) {
|
|
|
@@ -228,6 +229,17 @@ public abstract class WaterElectricityBatchListHandler extends CommonBatchListHa
|
|
|
throwables.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
+ }else {
|
|
|
+ StringBuilder sel2 = new StringBuilder();
|
|
|
+ sel2.append("select fid from CT_WOE_WaterElectricity where CFStutas!='Lock' ");
|
|
|
+ Set<String> errs = Sets.newHashSet();
|
|
|
+ Set<String> sess = Sets.newHashSet();
|
|
|
+ IRowSet rs = DbUtil.executeQuery(ctx, sel2.toString());
|
|
|
+ while (rs.next()) {
|
|
|
+ String id = rs.getString("fid");
|
|
|
+ this.updateStutas(ctx, "enable", id);
|
|
|
+ sess.add(id);
|
|
|
+ }
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
@@ -235,7 +247,7 @@ public abstract class WaterElectricityBatchListHandler extends CommonBatchListHa
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 解锁
|
|
|
+ * 瑙i攣
|
|
|
*
|
|
|
* @param request
|
|
|
* @param response
|
|
|
@@ -265,7 +277,7 @@ public abstract class WaterElectricityBatchListHandler extends CommonBatchListHa
|
|
|
while (rs.next()) {
|
|
|
String id = rs.getString("fid");
|
|
|
errs.add(id);
|
|
|
- this.addBatchMessageTip(id, "薪资数据已经锁定,不能解锁。", batchMessageTipsHeader);
|
|
|
+ this.addBatchMessageTip(id, "钖�祫鏁版嵁宸茬粡閿佸畾锛屼笉鑳借В閿併€�", batchMessageTipsHeader);
|
|
|
}
|
|
|
sess.removeAll(errs);
|
|
|
for (String id : sess) {
|
|
|
@@ -275,6 +287,17 @@ public abstract class WaterElectricityBatchListHandler extends CommonBatchListHa
|
|
|
throwables.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
+ }else {
|
|
|
+ StringBuilder sel2 = new StringBuilder();
|
|
|
+ sel2.append("select fid from CT_WOE_WaterElectricity where FBillState not in (2,3,4) ");
|
|
|
+ Set<String> errs = Sets.newHashSet();
|
|
|
+ Set<String> sess = Sets.newHashSet();
|
|
|
+ IRowSet rs = DbUtil.executeQuery(ctx, sel2.toString());
|
|
|
+ while (rs.next()) {
|
|
|
+ String id = rs.getString("fid");
|
|
|
+ this.updateStutas(ctx, "disable", id);
|
|
|
+ sess.add(id);
|
|
|
+ }
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
@@ -313,7 +336,7 @@ public abstract class WaterElectricityBatchListHandler extends CommonBatchListHa
|
|
|
conn = EJBFactory.getQueryConnection(ctx);
|
|
|
state = conn.createStatement();
|
|
|
if ("enable".equals(math)) {
|
|
|
- //锁定
|
|
|
+ //閿佸畾
|
|
|
state.execute("update "+this.getTableName()+" set CFStutas='Lock' where fid='" + uuid + "'");
|
|
|
|
|
|
} else if ("disable".equals(math)) {
|