|
@@ -18,6 +18,7 @@ import com.palmnest.application.dto.output.GoodsOperateDto;
|
|
|
import com.palmnest.dao.estateserve.EnterprisePermissionDao;
|
|
|
import com.palmnest.model.*;
|
|
|
import com.palmnest.model.airconditioner.AirConditionerAddTime;
|
|
|
+import com.palmnest.model.airconditioner.AirConditionerAddTimeOrderExtend;
|
|
|
import com.palmnest.model.airconditioner.AirRule;
|
|
|
import com.palmnest.model.airconditioner.ProjectConfig;
|
|
|
import com.palmnest.model.estateserve.AppUser;
|
|
@@ -28,26 +29,18 @@ import com.palmnest.model.property.VirtualArchitecture;
|
|
|
import com.palmnest.service.OrganizationManager;
|
|
|
import com.palmnest.service.UserManager;
|
|
|
import com.palmnest.service.estateserve.*;
|
|
|
-import com.palmnest.service.estateserve.airconditioner.AirRuleManager;
|
|
|
-import com.palmnest.service.estateserve.airconditioner.AirRuleService;
|
|
|
-import com.palmnest.service.estateserve.airconditioner.ConditionerAddTimeManager;
|
|
|
-import com.palmnest.service.estateserve.airconditioner.ConditionerAddTimeService;
|
|
|
+import com.palmnest.service.estateserve.airconditioner.*;
|
|
|
import com.palmnest.service.redis.BaseRedisService;
|
|
|
import com.palmnest.service.virtProject.manager.VirtualAccountManager;
|
|
|
-
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import net.sf.json.JSONObject;
|
|
|
-
|
|
|
-import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
-
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.lang.reflect.InvocationTargetException;
|
|
@@ -55,14 +48,8 @@ import java.math.BigDecimal;
|
|
|
import java.math.MathContext;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.text.DecimalFormat;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.HashSet;
|
|
|
-import java.util.Iterator;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Set;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Slf4j
|
|
|
@Service("conditionerAddTimeService")
|
|
@@ -111,6 +98,8 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
|
|
|
private OrganizationManager organizationManager;
|
|
|
@Autowired
|
|
|
private EnterprisePermissionDao enterprisePermissionDao;
|
|
|
+ @Autowired
|
|
|
+ private ConditionerAddTimeOrderExtendManager conditionerAddTimeOrderExtendManager;
|
|
|
|
|
|
|
|
|
|
|
@@ -119,28 +108,24 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
|
|
|
@Override
|
|
|
public AppResultDto apply(AirConditionerAddTimeInputDto dto,
|
|
|
HttpServletRequest request) {
|
|
|
-
|
|
|
- //MathContext mc=new MathContext(2,RoundingMode.HALF_UP);
|
|
|
-
|
|
|
Integer virPermId = null;
|
|
|
-
|
|
|
try {
|
|
|
- AirConditionerAddTime repairBill = new AirConditionerAddTime();
|
|
|
- BeanUtils.copyProperties(repairBill, dto);
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 空调加时订单属性填充
|
|
|
+ */
|
|
|
+ AirConditionerAddTime airConditionerAddTime = new AirConditionerAddTime();
|
|
|
+ BeanUtils.copyProperties(airConditionerAddTime, dto);
|
|
|
if (dto.getBillFrom().equals(CodeConstants.WECHAT)) {
|
|
|
String openId = request.getParameter("openId");
|
|
|
WxUser wxUser = scWxuserManager.getScWxuserByOpenId(openId);
|
|
|
if (wxUser != null) {
|
|
|
- repairBill.setCreator(wxUser.getNickName());
|
|
|
- repairBill.setModifier(wxUser.getNickName());
|
|
|
- repairBill.setOrganizationId(wxUser.getOrganizationId());
|
|
|
- repairBill.setCreatorBillId(openId);
|
|
|
-
|
|
|
-
|
|
|
+ airConditionerAddTime.setCreator(wxUser.getNickName());
|
|
|
+ airConditionerAddTime.setModifier(wxUser.getNickName());
|
|
|
+ airConditionerAddTime.setOrganizationId(wxUser.getOrganizationId());
|
|
|
+ airConditionerAddTime.setCreatorBillId(openId);
|
|
|
AppUser appUer = appUserManager.getAppUserByWxUserAndOrg(wxUser.getId(), wxUser.getOrganizationId());
|
|
|
if(null != appUer ){
|
|
|
- repairBill.setUserId(appUer.getId());
|
|
|
+ airConditionerAddTime.setUserId(appUer.getId());
|
|
|
}
|
|
|
if (null != appUer && null != appUer.getVirPermId()) {
|
|
|
virPermId = appUer.getVirPermId().intValue();
|
|
@@ -153,70 +138,46 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
|
|
|
}
|
|
|
User user = userManager.getUserByUsername2(userName);
|
|
|
if (null != user) {
|
|
|
- repairBill.setCreator(user.getFullName() + "(空调管理员)");
|
|
|
- repairBill.setModifier(user.getFullName());
|
|
|
- //repairBill.setOrganizationId(user.get());
|
|
|
-
|
|
|
+ airConditionerAddTime.setCreator(user.getFullName() + "(空调管理员)");
|
|
|
+ airConditionerAddTime.setModifier(user.getFullName());
|
|
|
//appuser 对应项目ID
|
|
|
List<AppUserOrgnizationRelation> orgList = userManager.getAppUserOrgByUserId(Integer.parseInt(user.getId().toString()));
|
|
|
if (orgList != null && orgList.size() > 0) {
|
|
|
AppUserOrgnizationRelation orgRe = orgList.get(0);
|
|
|
if (orgRe != null) {
|
|
|
- repairBill.setOrganizationId(orgRe.getOrgId());
|
|
|
+ airConditionerAddTime.setOrganizationId(orgRe.getOrgId());
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- repairBill.setCreatorBillId(user.getId().toString());
|
|
|
-
|
|
|
+ airConditionerAddTime.setCreatorBillId(user.getId().toString());
|
|
|
}
|
|
|
}
|
|
|
+ airConditionerAddTime.setCreateTime(new Date());
|
|
|
+ airConditionerAddTime.setModifyTime(new Date());
|
|
|
|
|
|
- repairBill.setCreateTime(new Date());
|
|
|
- repairBill.setModifyTime(new Date());
|
|
|
-
|
|
|
- if (null == repairBill.getOrganizationId()) {
|
|
|
+ if (null == airConditionerAddTime.getOrganizationId()) {
|
|
|
return AppResultUtil.createErrorDto(AppConstants.ERROR_CODE, "空调加时申请失败,不能获得用户项目信息");
|
|
|
}
|
|
|
-
|
|
|
Integer priceType = 1;
|
|
|
- AirRule airRule_data = getRuleByOrgId(Long.valueOf(repairBill.getOrganizationId()));
|
|
|
+ AirRule airRule_data = getRuleByOrgId(Long.valueOf(airConditionerAddTime.getOrganizationId()));
|
|
|
if(null != airRule_data && null != airRule_data.getPriceType()){
|
|
|
priceType = airRule_data.getPriceType();
|
|
|
}
|
|
|
-
|
|
|
DecimalFormat df4 = new DecimalFormat();
|
|
|
df4.applyPattern("0.00");
|
|
|
-
|
|
|
//单价根据 应用模块空调加时+当前日期的 日期类型(工作日\ 休息日\节假日 找到规则中单价
|
|
|
BigDecimal priceHu = new BigDecimal(350);//每户
|
|
|
BigDecimal priceHour = new BigDecimal(0.15);//小时
|
|
|
-
|
|
|
//获取当前项目 每层价格 每半层价格
|
|
|
BigDecimal floorPriceHour = new BigDecimal(100); //每层多少钱/每小时
|
|
|
BigDecimal halfFloorPriceHour = new BigDecimal(50); //每半层多少钱/每小时
|
|
|
-
|
|
|
- //BigDecimal price=new BigDecimal(350);//每户
|
|
|
String priceDisplay = "每户350元/每小时";
|
|
|
- //String priceDisplay="每平米0.15元/小时";
|
|
|
-
|
|
|
-
|
|
|
//#应用模块 (1预定会议室\2空调加时
|
|
|
//#获得日期类型 过滤 日期类型(0工作日1休息日2节假日',
|
|
|
//#匹配时间段 配置的时间内
|
|
|
//#获得每户\每平米 价格
|
|
|
Integer dataType = 0;//根据api 获得
|
|
|
//String currentDateStr=DateUtils.getTime(new Date(),"yyyyMMdd");//换成申请日期的
|
|
|
- String applyTimeStr = DateUtils.getTime(repairBill.getUseStartTime(), "yyyy-MM-dd");
|
|
|
- //String jsonStr = HttpKit.get("http://api.goseek.cn/Tools/holiday?date=" + applyTimeStr, false);
|
|
|
- //Map<String, Object> jsApiMap = com.alibaba.fastjson.JSONObject.parseObject(jsonStr);
|
|
|
- /*if (null != jsApiMap && jsApiMap.containsKey("code")) {
|
|
|
- if (jsApiMap.get("code").equals(10000)) {
|
|
|
- dataType = (Integer) jsApiMap.get("data");
|
|
|
- } else {
|
|
|
- return AppResultUtil.createErrorDto(AppConstants.ERROR_CODE, "空调加时申请失败,节假日接口调用失败");
|
|
|
- }
|
|
|
- }*/
|
|
|
-
|
|
|
+ String applyTimeStr = DateUtils.getTime(airConditionerAddTime.getUseStartTime(), "yyyy-MM-dd");
|
|
|
try{
|
|
|
String jsonStr = HttpKit.holidayGet("https://timor.tech/api/holiday/info/" + applyTimeStr, false);
|
|
|
System.out.println("节假日接口调用返回===>"+jsonStr);
|
|
@@ -239,16 +200,15 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
//勾选后非节假日的周六为工作日=================================================2018.10.17
|
|
|
//如果为 true 如果get为周六且非2节假日 将 dataType设置为0工作日
|
|
|
-
|
|
|
- boolean isSaturday = DateUtils.checkIsSaturday(repairBill.getUseStartTime());
|
|
|
+ boolean isSaturday = DateUtils.checkIsSaturday(airConditionerAddTime.getUseStartTime());
|
|
|
if(isSaturday){
|
|
|
dataType = 1 ;
|
|
|
}
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 企业信息
|
|
|
+ */
|
|
|
VirtualArchitecture virtual = virtualArchManager.get(Integer.valueOf(dto.getVirtualId()));
|
|
|
if (null != virtual && virtual.getOrganizationId() != null) {
|
|
|
ProjectConfig projectConfig = projectConfigManager.getProjectConfigByOrganizationId(Long.valueOf(virtual.getOrganizationId()));
|
|
@@ -263,33 +223,25 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //勾选后非节假日的周六为工作日=================================================2018.10.17
|
|
|
-
|
|
|
-
|
|
|
- //企业结算方式(1现结2月结)
|
|
|
- if (null != virtual && virtual.getSettleType() == 1) {
|
|
|
- //return AppResultUtil.createErrorDto(AppConstants.ERROR_CODE, "该企业结算方式为现结,不能申请空调加时");
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
//提前申请时间校验=================================================2018.10.17
|
|
|
//获得当前用户对项目Id 找项目规则
|
|
|
String virtualId = dto.getVirtualId();
|
|
|
- String checkStr = checkBeforeAppApplyTime(repairBill.getUseStartTime(), Long.decode(virtualId));
|
|
|
+ String checkStr = checkBeforeAppApplyTime(airConditionerAddTime.getUseStartTime(), Long.decode(virtualId));
|
|
|
if (StringUtils.isNotEmpty(checkStr)) {
|
|
|
return AppResultUtil.createErrorDto(AppConstants.ERROR_CODE, checkStr);
|
|
|
}
|
|
|
//提前申请时间校验=================================================2018.10.17
|
|
|
-
|
|
|
-
|
|
|
Integer applicationType = 2;//应用模块(1预定会议室\2空调加时
|
|
|
Integer applicationAirAddTime = 1;
|
|
|
Date minDate = null;
|
|
|
Date maxDate = null;
|
|
|
|
|
|
- List<AirRule> airRules = airRuleManager.getAirRule(repairBill.getOrganizationId(), applicationType, applicationAirAddTime, dataType, "", "");
|
|
|
+ /**
|
|
|
+ * 项目的空调使用规则信息
|
|
|
+ */
|
|
|
+ List<AirRule> airRules = airRuleManager.getAirRule(airConditionerAddTime.getOrganizationId(), applicationType, applicationAirAddTime, dataType, "", "");
|
|
|
AirRule airRule = null;
|
|
|
- if (null == airRules || (null != airRules && airRules.size() == 0)) {
|
|
|
+ if (null == airRules || airRules.isEmpty()) {
|
|
|
return AppResultUtil.createErrorDto(AppConstants.ERROR_CODE, "空调加时申请失败,不能匹配到空调加时规则或该时段有免费的空调加时无需申请");
|
|
|
}
|
|
|
int airRulesSize = 0;
|
|
@@ -297,7 +249,7 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
|
|
|
|
|
|
Date ruleStartTime = ar.getStartTime();
|
|
|
Date ruleEndTime = ar.getEndTime();
|
|
|
- Map recodeMap = DateUtils.getIncludeTime(repairBill.getUseStartTime(), repairBill.getUseEndTime(), ruleStartTime, ruleEndTime);
|
|
|
+ Map recodeMap = DateUtils.getIncludeTime(airConditionerAddTime.getUseStartTime(), airConditionerAddTime.getUseEndTime(), ruleStartTime, ruleEndTime);
|
|
|
if (recodeMap.containsKey("minDate") && recodeMap.containsKey("maxDate")) {
|
|
|
minDate = (Date) recodeMap.get("minDate");
|
|
|
maxDate = (Date) recodeMap.get("maxDate");
|
|
@@ -315,26 +267,22 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
|
|
|
}
|
|
|
|
|
|
//面积数
|
|
|
- String applyArea = repairBill.getApplyArea();//申请面积
|
|
|
+ String applyArea = airConditionerAddTime.getApplyArea();//申请面积
|
|
|
|
|
|
- String selectRoomNames = repairBill.getRoomNames();
|
|
|
+ String selectRoomNames = airConditionerAddTime.getRoomNames();
|
|
|
|
|
|
BigDecimal calcapplyArea = BigDecimal.ZERO;//按层申请的面积
|
|
|
- String [] roomNos = repairBill.getRoomNos().split(";");
|
|
|
+ String [] roomNos = airConditionerAddTime.getRoomNos().split(";");
|
|
|
boolean areaRuleTypeCount1 = false; //有几种收费类型
|
|
|
boolean areaRuleTypeCount2 = false; //有几种收费类型
|
|
|
boolean areaRuleTypeCount4 = false; //有几种收费类型 一层起订
|
|
|
Integer calcAreaRuleType = 1; //用两种类型计算
|
|
|
//Integer priceType = 1;//单价类型(1-平米每小时、2-层(半层)每小时) --取项目的
|
|
|
- List<RoomInfo> listRoomInfos = roomInfoManager.getRoomListByRoomNos(repairBill.getRoomNos().replaceAll("[;]$", "").replace(";;",";").replace(";",","));
|
|
|
-
|
|
|
- Map floorSumAreaMap = new HashMap<Integer, BigDecimal>();//每层楼的合计申请面积
|
|
|
- Map mapIsHaveFloor = new HashMap<Integer, Boolean>();//当前楼层是有-一层起订
|
|
|
- Map mapIsHalfHaveFloor = new HashMap<Integer, Boolean>();//当前楼层是有-半层起订
|
|
|
- //Map sumFloororOrhalfFloorMap = new HashMap<Integer, Boolean>();//第层楼有多少个一层或多少个半层
|
|
|
- //Map sumFloororMap = new HashMap<Integer, BigDecimal>();//第层楼有多少个一层或多少个半层
|
|
|
- //Map sumHalfFloorMap = new HashMap<Integer, BigDecimal>();//第层楼有多少个一层或多少个半层
|
|
|
+ List<RoomInfo> listRoomInfos = roomInfoManager.getRoomListByRoomNos(airConditionerAddTime.getRoomNos().replaceAll("[;]$", "").replace(";;",";").replace(";",","));
|
|
|
|
|
|
+ Map<Integer, BigDecimal> floorSumAreaMap = new HashMap<>();//每层楼的合计申请面积
|
|
|
+ Map<Integer, Boolean> mapIsHaveFloor = new HashMap<>();//当前楼层是有-一层起订
|
|
|
+ Map<Integer, Boolean> mapIsHalfHaveFloor = new HashMap<>();//当前楼层是有-半层起订
|
|
|
|
|
|
//根据每个房间配置的是 一层还是半层起订 计算有几个一层 有几个半层起订
|
|
|
//一层中如果累计有一层了 后继房间号不累加层数或半层数
|
|
@@ -369,13 +317,7 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
|
|
|
areaRuleTypeCount4 = true;
|
|
|
calcAreaRuleType = 4; //一层起订
|
|
|
}
|
|
|
-
|
|
|
- /*if(areaRuleType ==3){//不可预定 continue
|
|
|
- continue;
|
|
|
- }*/
|
|
|
|
|
|
- //申请-每楼面积合计
|
|
|
- //if(areaRuleType == 1 || areaRuleType == 2 || areaRuleType == 4){
|
|
|
if(true){
|
|
|
if(floorSumAreaMap.containsKey(floorId)){
|
|
|
BigDecimal temp_area = (BigDecimal)floorSumAreaMap.get(floorId);
|
|
@@ -392,95 +334,20 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
|
|
|
return AppResultUtil.createErrorDto(AppConstants.ERROR_CODE, "请在空调空间数据中配置楼层面积");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- //楼层面积根据 楼层配置的来
|
|
|
- /*if(!floorSumAreaMap.containsKey(floorId)){ //没有保存时 处理
|
|
|
-
|
|
|
- FloorInfo floorInfo = floorInfoManager.get(floorId);
|
|
|
- if(null == floorInfo.getFloorArea()){
|
|
|
- return AppResultUtil.createErrorDto(AppConstants.ERROR_CODE, "请在空调空间数据中配置楼层面积");
|
|
|
- }else{
|
|
|
- floorSumAreaMap.put(floorId, floorInfo.getFloorArea());
|
|
|
- }
|
|
|
- }*/
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
if(areaRuleType ==4 && !mapIsHaveFloor.containsKey(floorId)){
|
|
|
mapIsHaveFloor.put(floorId, true);
|
|
|
}
|
|
|
if(areaRuleType ==2 && !mapIsHalfHaveFloor.containsKey(floorId)){
|
|
|
mapIsHalfHaveFloor.put(floorId, true);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /*if(sumFloororOrhalfFloorMap.containsKey(floorId)){
|
|
|
-
|
|
|
- boolean isContinueAdd = (Boolean)sumFloororOrhalfFloorMap.get(sumFloororOrhalfFloorMap);//是否可以继续添加
|
|
|
-
|
|
|
- if(isContinueAdd){
|
|
|
-
|
|
|
- BigDecimal temp_sumFloor = (BigDecimal)sumFloororMap.get(floorId);//一层合计
|
|
|
- BigDecimal temp_sumHalfFloor = (BigDecimal)sumHalfFloorMap.get(floorId);//半层合计
|
|
|
- if(null == temp_sumFloor){
|
|
|
- temp_sumFloor = BigDecimal.ZERO;
|
|
|
- }
|
|
|
- if(null == temp_sumHalfFloor){
|
|
|
- temp_sumHalfFloor = BigDecimal.ZERO;
|
|
|
- }
|
|
|
-
|
|
|
- if(areaRuleType == 2){ //2-半层起定
|
|
|
- temp_sumHalfFloor = temp_sumHalfFloor.add(BigDecimal.valueOf(0.5));
|
|
|
- if(temp_sumHalfFloor.compareTo(BigDecimal.ONE) >= 1){
|
|
|
- sumHalfFloorMap.put(floorId, BigDecimal.valueOf(2.0));
|
|
|
- sumFloororOrhalfFloorMap.put(floorId, false);
|
|
|
- }else{
|
|
|
- sumHalfFloorMap.put(floorId, temp_sumHalfFloor);//当前多个少半导
|
|
|
- }
|
|
|
- }else if(areaRuleType == 4){ //4-一层起订
|
|
|
-
|
|
|
- temp_sumFloor = temp_sumFloor.add(BigDecimal.ONE);
|
|
|
- if(temp_sumFloor.compareTo(BigDecimal.ONE) >= 1){
|
|
|
- sumFloororMap.put(floorId, BigDecimal.ONE);
|
|
|
- sumFloororOrhalfFloorMap.put(floorId, false);//true-可继续添加 false-已满不可添加
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }else{ //第一次进来
|
|
|
- sumFloororOrhalfFloorMap.put(floorId, true);
|
|
|
- if(areaRuleType == 2){ //2-半层起定
|
|
|
- sumHalfFloorMap.put(floorId, BigDecimal.valueOf(0.5));
|
|
|
- }else if(areaRuleType == 4){ //4-一层起订
|
|
|
- sumFloororMap.put(floorId, BigDecimal.ONE);
|
|
|
- sumFloororOrhalfFloorMap.put(floorId, false);
|
|
|
- }
|
|
|
- }*/
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- if(areaRuleTypeCount1 && areaRuleTypeCount2){
|
|
|
- //return AppResultUtil.createErrorDto(AppConstants.ERROR_CODE, "申请房号中暂不支持多种面积计算规则");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- //String calc_applyArea = repairBill.getApplyArea();//申请面积
|
|
|
//1-实际面积 2-半层起定 3-不可预定 4-一层起订
|
|
|
|
|
|
Integer haveFloorNum = 0;//一层的数量
|
|
|
Integer halfHaveFloorNum = 0;//半层的数量
|
|
|
applyArea = "";
|
|
|
- //applyArea = getApplyArea(floorSumAreaMap, mapIsHaveFloor,mapIsHalfHaveFloor, applyArea, haveFloorNum, calcapplyArea,halfHaveFloorNum, priceType);
|
|
|
-
|
|
|
- //method getApplyArea
|
|
|
-
|
|
|
String current_floorId = "";
|
|
|
-
|
|
|
-
|
|
|
if(priceType == 1){ //平米每小时
|
|
|
Iterator it = floorSumAreaMap.keySet().iterator();
|
|
|
while(it.hasNext()){
|
|
@@ -574,13 +441,11 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
|
|
|
applyArea = "半层*" + halfHaveFloorNum.toString();
|
|
|
}
|
|
|
}
|
|
|
- //method getApplyArea
|
|
|
-
|
|
|
|
|
|
- repairBill.setFloorId(current_floorId.replaceAll("[;]$", ""));
|
|
|
- repairBill.setApplyArea(applyArea);
|
|
|
- repairBill.setUseStartTime(minDate);
|
|
|
- repairBill.setUseEndTime(maxDate);
|
|
|
+ airConditionerAddTime.setFloorId(current_floorId.replaceAll("[;]$", ""));
|
|
|
+ airConditionerAddTime.setApplyArea(applyArea);
|
|
|
+ airConditionerAddTime.setUseStartTime(minDate);
|
|
|
+ airConditionerAddTime.setUseEndTime(maxDate);
|
|
|
priceHu = airRule.getPriceHouse();
|
|
|
priceHour = airRule.getPriceHour();
|
|
|
|
|
@@ -588,29 +453,19 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
|
|
|
halfFloorPriceHour = airRule.getHalfFloorPriceHour();//每半层多少钱/每小时
|
|
|
|
|
|
//空调加时最低申请1小时,半小时按1小时收取费用
|
|
|
- BigDecimal UseLengthTime = DateUtils.compareStringTimesToHour(repairBill.getUseStartTime(), repairBill.getUseEndTime());
|
|
|
+ BigDecimal UseLengthTime = DateUtils.compareStringTimesToHour(airConditionerAddTime.getUseStartTime(), airConditionerAddTime.getUseEndTime());
|
|
|
//if (UseLengthTime.compareTo(new BigDecimal("1")) == -1) {
|
|
|
// return AppResultUtil.createErrorDto(AppConstants.ERROR_CODE, "最低申请1小时,请重新选择时间");
|
|
|
//}
|
|
|
UseLengthTime = UseLengthTime.setScale(0, BigDecimal.ROUND_UP);//向上取整
|
|
|
|
|
|
- repairBill.setUseLengthTime(UseLengthTime);//使用时长
|
|
|
+ airConditionerAddTime.setUseLengthTime(UseLengthTime);//使用时长
|
|
|
|
|
|
//户数
|
|
|
- //int houseNo=repairBill.getRoomNos().split(";").length;//申请房号IDS(ID;ID)
|
|
|
int houseNo = 1;//申请房号IDS(ID;ID)
|
|
|
|
|
|
- //2018-6以前按每平米0.15元/每小时,2018-6后入驻按每户350元/每小时
|
|
|
- //查询企业的入驻时间 来算确定 用户还是 每平米算 (
|
|
|
- //Date virEnterDate=new Date();
|
|
|
- //Date virEnterDate = virtual.getEnterTime();
|
|
|
- //if (null == virEnterDate) {
|
|
|
- // return AppResultUtil.createErrorDto(AppConstants.ERROR_CODE, "空调加时申请失败,请设置企业入驻时间");
|
|
|
- //}
|
|
|
boolean isCalcHouse = true;//是否按面积来计算
|
|
|
- //if (virEnterDate.after(DateUtils.getDateByString(enterTime, "yyyy.MM.dd"))) {//精确到天
|
|
|
- // isCalcHouse = true;
|
|
|
- //}
|
|
|
+
|
|
|
|
|
|
BigDecimal calcFee = BigDecimal.ZERO.setScale(2);//费用
|
|
|
String freeDetail = "";//费用明细
|
|
@@ -624,7 +479,7 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
|
|
|
//费用明细:2小时*2户*每户350元/每小时=1400.00元
|
|
|
calcFee = UseLengthTime.multiply(new BigDecimal(houseNo)).multiply(priceHu).setScale(2, 4);
|
|
|
freeDetail = UseLengthTime.toPlainString() + "小时*" + houseNo + "户*" + priceDisplay;
|
|
|
- repairBill.setUseAreaOrTime(2);//使用 1面积 2 时间
|
|
|
+ airConditionerAddTime.setUseAreaOrTime(2);//使用 1面积 2 时间
|
|
|
|
|
|
|
|
|
} else {//用面积计算
|
|
@@ -641,7 +496,7 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
|
|
|
//费用明细:2小时*2平米*每平米0.15元/小时=1400.00元
|
|
|
calcFee = UseLengthTime.multiply(new BigDecimal(calc_applyArea)).multiply(priceHour).setScale(2, 4);
|
|
|
freeDetail = UseLengthTime.toPlainString() + "小时*" + calc_applyArea + "平米*" + priceDisplay;
|
|
|
- repairBill.setUseAreaOrTime(1);//使用 1面积 2 时间
|
|
|
+ airConditionerAddTime.setUseAreaOrTime(1);//使用 1面积 2 时间
|
|
|
}else if(priceType == 2){
|
|
|
|
|
|
//每层300元/小时、每半层200元/小时
|
|
@@ -670,7 +525,7 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
|
|
|
|
|
|
}
|
|
|
|
|
|
- repairBill.setPriceDisplay(priceDisplay);//单价:每户350元/每小时
|
|
|
+ airConditionerAddTime.setPriceDisplay(priceDisplay);//单价:每户350元/每小时
|
|
|
//工作日2018-09-18 07:00~21:00
|
|
|
//工作日根据时间获取
|
|
|
String dataTypeStr = "工作日";
|
|
@@ -685,46 +540,89 @@ public class ConditionerAddTimeServiceImpl implements ConditionerAddTimeService
|
|
|
//使用时间(合并显示 工作日2018-09-18 07:00~21:00
|
|
|
//使用时间(合并显示 10月25日 07:00~21:00(工作日)
|
|
|
//String UseStartTimeStr=DateUtils.getDate(repairBill.getUseStartTime(), "yyyy-MM-dd HH:mm");
|
|
|
- String UseStartTimeStr = DateUtils.getDate(repairBill.getUseStartTime(), "MM月dd日 HH:mm");
|
|
|
- String useEndTimeStr = DateUtils.getDate(repairBill.getUseEndTime(), "HH:mm");
|
|
|
- repairBill.setUseDisplayTime(UseStartTimeStr + "~" + useEndTimeStr + "(" + dataTypeStr + ")");
|
|
|
+ String UseStartTimeStr = DateUtils.getDate(airConditionerAddTime.getUseStartTime(), "MM月dd日 HH:mm");
|
|
|
+ String useEndTimeStr = DateUtils.getDate(airConditionerAddTime.getUseEndTime(), "HH:mm");
|
|
|
+ airConditionerAddTime.setUseDisplayTime(UseStartTimeStr + "~" + useEndTimeStr + "(" + dataTypeStr + ")");
|
|
|
|
|
|
- repairBill.setFreeDetail(freeDetail);//费用明细:2小时*2户*350元=1400.00元
|
|
|
- repairBill.setFreeTotal(calcFee);//费用总计:1400.00元
|
|
|
- repairBill.setMonthlyFree(calcFee);//月结费用:1400.00元
|
|
|
+ airConditionerAddTime.setFreeDetail(freeDetail);//费用明细:2小时*2户*350元=1400.00元
|
|
|
+ airConditionerAddTime.setFreeTotal(calcFee);//费用总计:1400.00元
|
|
|
+ airConditionerAddTime.setMonthlyFree(calcFee);//月结费用:1400.00元
|
|
|
|
|
|
- if(StringUtils.isEmpty(repairBill.getFloorId())){
|
|
|
+ if(StringUtils.isEmpty(airConditionerAddTime.getFloorId())){
|
|
|
if(StringUtils.isNotEmpty(virtual.getFloorIds())){
|
|
|
- repairBill.setFloorId(virtual.getFloorIds().split(";")[0]);
|
|
|
+ airConditionerAddTime.setFloorId(virtual.getFloorIds().split(";")[0]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
String code = CodeGenerateUtils.generate("KTJS");
|
|
|
- repairBill.setCode(code);
|
|
|
+ airConditionerAddTime.setCode(code);
|
|
|
|
|
|
|
|
|
String types = "5,6";//空调加时
|
|
|
- List<Map<String, Object>> list = enterprisePermissionDao.getGoodsConfig(repairBill.getOrganizationId().longValue(), types,"");
|
|
|
+ List<Map<String, Object>> list = enterprisePermissionDao.getGoodsConfig(airConditionerAddTime.getOrganizationId().longValue(), types,"");
|
|
|
if (list != null && list.size() > 0) {
|
|
|
if(null!=virPermId && virPermId.equals((Integer)list.get(0).get("roleId"))){
|
|
|
|
|
|
if(list.size() >= 2){
|
|
|
|
|
|
- repairBill.setType(Integer.parseInt(list.get(1).get("type").toString()));
|
|
|
- repairBill.setRoleId(Integer.parseInt(list.get(1).get("roleId").toString()));
|
|
|
- repairBill.setSort(Integer.parseInt(list.get(1).get("sort").toString()));
|
|
|
+ airConditionerAddTime.setType(Integer.parseInt(list.get(1).get("type").toString()));
|
|
|
+ airConditionerAddTime.setRoleId(Integer.parseInt(list.get(1).get("roleId").toString()));
|
|
|
+ airConditionerAddTime.setSort(Integer.parseInt(list.get(1).get("sort").toString()));
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
- repairBill.setType(Integer.parseInt(list.get(0).get("type").toString()));
|
|
|
- repairBill.setRoleId(Integer.parseInt(list.get(0).get("roleId").toString()));
|
|
|
- repairBill.setSort(Integer.parseInt(list.get(0).get("sort").toString()));
|
|
|
+ airConditionerAddTime.setType(Integer.parseInt(list.get(0).get("type").toString()));
|
|
|
+ airConditionerAddTime.setRoleId(Integer.parseInt(list.get(0).get("roleId").toString()));
|
|
|
+ airConditionerAddTime.setSort(Integer.parseInt(list.get(0).get("sort").toString()));
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
- repairBill.setStatus(GoodsCodeConstants.AIR_TOAUDIT);//保存
|
|
|
- AirConditionerAddTime bill = conditionerAddTimeManager.save(repairBill);
|
|
|
+ airConditionerAddTime.setStatus(GoodsCodeConstants.AIR_TOAUDIT);//保存
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 下单时保存可用的规则 修改订单时需要用
|
|
|
+ */
|
|
|
+ Map<String, Object> param = new HashMap<>();
|
|
|
+ param.put("orgId", airConditionerAddTime.getOrganizationId());
|
|
|
+ param.put("isEnabled", 1);
|
|
|
+ Page airRulePage = airRuleManager.findPageBy(param, 1, 100);
|
|
|
+ List items = airRulePage.getItems();
|
|
|
+ if (cn.superdesk.libs.common.util.CollectionUtils.isEmpty(items)) {
|
|
|
+ return AppResultUtil.createErrorDto(AppConstants.ERROR_CODE, "空调加时申请失败,没有可用规则,请联系系统管理员");
|
|
|
+ }
|
|
|
+
|
|
|
+ String allAirRulesStr = JSON.toJSONString(items);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 下单时保存所有可用房间信息 修改订单时需要用
|
|
|
+ */
|
|
|
+ List<Integer> allRoomIds = dto.getAllRoomIds();
|
|
|
+ if (cn.superdesk.libs.common.util.CollectionUtils.isEmpty(allRoomIds)) {
|
|
|
+ return AppResultUtil.createErrorDto(AppConstants.ERROR_CODE, "空调加时申请失败,没有可用房间,请联系系统管理员");
|
|
|
+ }
|
|
|
+ List<RoomInfo> allRoomInfos = roomInfoManager.getRoomListByRoomNos(
|
|
|
+ allRoomIds.stream().map(String::valueOf).collect(Collectors.joining(";"))
|
|
|
+ );
|
|
|
+ if (cn.superdesk.libs.common.util.CollectionUtils.isEmpty(allRoomInfos)) {
|
|
|
+ return AppResultUtil.createErrorDto(AppConstants.ERROR_CODE, "空调加时申请失败,没有可用房间,请联系系统管理员");
|
|
|
+ }
|
|
|
+
|
|
|
+ String allRoomInfoStr = JSON.toJSONString(allRoomInfos);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存下单时的规则和房间信息
|
|
|
+ */
|
|
|
+ conditionerAddTimeOrderExtendManager.save(
|
|
|
+ AirConditionerAddTimeOrderExtend.builder()
|
|
|
+ .code(code)
|
|
|
+ .airRules(allAirRulesStr)
|
|
|
+ .roomInfos(allRoomInfoStr)
|
|
|
+ .build()
|
|
|
+ );
|
|
|
+
|
|
|
+ AirConditionerAddTime bill = conditionerAddTimeManager.save(airConditionerAddTime);
|
|
|
|
|
|
return AppResultUtil.createSuccesDto(convert(bill));
|
|
|
|