Heyuan 3 недель назад
Родитель
Сommit
f8ca39e76c

+ 16 - 1
src/com/kingdee/eas/custom/dormitorysystem/application/app/CheckInApplicationControllerBean.java

@@ -16,6 +16,10 @@ import com.kingdee.eas.custom.dormitorysystem.occupants.IOccupants;
 import com.kingdee.eas.custom.dormitorysystem.occupants.OccupantsFactory;
 import com.kingdee.eas.custom.dormitorysystem.occupants.OccupantsInfo;
 import com.kingdee.eas.custom.dormitorysystem.otherbasicdata.PersonDormitoryTypeInfo;
+import com.kingdee.eas.custom.dormitorysystem.waterelectricity.IWaterElectricity;
+import com.kingdee.eas.custom.dormitorysystem.waterelectricity.WaterElectricityCollection;
+import com.kingdee.eas.custom.dormitorysystem.waterelectricity.WaterElectricityFactory;
+import com.kingdee.eas.custom.dormitorysystem.waterelectricity.WaterElectricityInfo;
 import com.kingdee.eas.framework.CoreBaseInfo;
 import com.kingdee.eas.hr.affair.AffairBizException;
 import com.kingdee.eas.hr.ats.AtsUtil;
@@ -32,6 +36,7 @@ import com.kingdee.shr.base.syssetting.MSFServiceFacadeFactory;
 import com.kingdee.util.StringUtils;
 import org.apache.log4j.Logger;
 
+import java.text.SimpleDateFormat;
 import java.util.*;
 
 public class CheckInApplicationControllerBean extends AbstractCheckInApplicationControllerBean {
@@ -205,13 +210,18 @@ public class CheckInApplicationControllerBean extends AbstractCheckInApplication
         IOccupants iOccupants = OccupantsFactory.getLocalInstance(ctx);
         IRoomChangeApplicationEntry iRoomChangeApplicationEntry = RoomChangeApplicationEntryFactory.getLocalInstance(ctx);
         ICheckoutApplicationEntry iCheckoutApplicationEntry = CheckoutApplicationEntryFactory.getLocalInstance(ctx);
+        IWaterElectricity iWaterElectricity = WaterElectricityFactory.getLocalInstance(ctx);
         Set<String> occupantsIds = new HashSet<String>();
         CheckInApplicationEntryCollection entrys = info.getEntrys();
         StringBuilder errorMsg = new StringBuilder();
         Set<String> entryIds = new HashSet<String>();
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM");
         for (int i = 0; i < entrys.size(); i++) {
             CheckInApplicationEntryInfo entryInfo = entrys.get(i);
+            Date checkInDate = entryInfo.getCheckInDate();
+            Date checkoutDate = entryInfo.getCheckoutDate();
             PersonInfo person = entryInfo.getPerson();
+            String personId = person.getId().toString();
             OccupantsInfo occupants = entryInfo.getOccupants();
             String occupantsId = occupants.getId().toString();
             //检查是否有退宿流程
@@ -228,7 +238,12 @@ public class CheckInApplicationControllerBean extends AbstractCheckInApplication
                 String number = checkoutApplicationEntryInfo.getParent().getNumber();
                 errorMsg.append("员工 " + person.getName() + "已有退宿单[ " + number + " ],不能反审核!\n");
             }
-            //没有水电明细的可以反审批
+            //有水电明细的可以不可以反审批
+            String filter = "where person.id = '" + personId + "' and yearMonth >= '" + dateFormat.format(checkInDate) + "' and yearMonth <='" + dateFormat.format(checkoutDate) + "'";
+            WaterElectricityCollection waterElectricityCol = iWaterElectricity.getWaterElectricityCollection(filter);
+            if (waterElectricityCol.size() > 0) {
+                errorMsg.append("员工 " + person.getName() + " 已经产生水电明细,不能反审核!\n");
+            }
             occupantsIds.add(occupantsId);
             entryIds.add(entryInfo.getId().toString());
         }