| @@ -51,6 +51,7 @@ import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.Calendar; | import java.util.Calendar; | ||||
| import java.util.Date; | |||||
| import java.util.HashMap; | import java.util.HashMap; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| @@ -206,6 +207,7 @@ public class WxEnergyController extends BaseController { | |||||
| WxEnergyMeter meter = list.get(i); | WxEnergyMeter meter = list.get(i); | ||||
| WxShop s = new WxShop(); | WxShop s = new WxShop(); | ||||
| s.setId(meter.getId()); | s.setId(meter.getId()); | ||||
| s.setTreeType(meter.getTreeType()); | |||||
| s.setShopNumber(meter.getName()); | s.setShopNumber(meter.getName()); | ||||
| s.setTreeParentId(record.getFloor()); | s.setTreeParentId(record.getFloor()); | ||||
| s.setTreeParentType("floor"); | s.setTreeParentType("floor"); | ||||
| @@ -280,7 +282,7 @@ public class WxEnergyController extends BaseController { | |||||
| } | } | ||||
| return new ResultData(list); | return new ResultData(list); | ||||
| } | } | ||||
| return new ResultData(); | |||||
| return new ResultData(new ArrayList<WxEnergyMeter>()); | |||||
| } | } | ||||
| @ApiOperation("用户能源表新增修改") | @ApiOperation("用户能源表新增修改") | ||||
| @@ -324,7 +326,7 @@ public class WxEnergyController extends BaseController { | |||||
| @ApiOperation("用户能源表新增修改") | @ApiOperation("用户能源表新增修改") | ||||
| @PostMapping("deleteChildMeter") | @PostMapping("deleteChildMeter") | ||||
| public ResultData deleteChildMeter(@RequestBody WxEnergyMeterChild record) { | |||||
| public ResultData deleteChildMeter(@RequestBody WxEnergyMeter record) { | |||||
| record.updateTenantInfo(getTenantInfo()); | record.updateTenantInfo(getTenantInfo()); | ||||
| if (null == record.getId()) { | if (null == record.getId()) { | ||||
| return new ResultData(Result.ERROR,"请选择一个关联"); | return new ResultData(Result.ERROR,"请选择一个关联"); | ||||
| @@ -367,7 +369,7 @@ public class WxEnergyController extends BaseController { | |||||
| @GetMapping("feesShopComponentList") | @GetMapping("feesShopComponentList") | ||||
| public ResultData shopFeesList(@ModelAttribute WxEnergyFeesShop record) { | public ResultData shopFeesList(@ModelAttribute WxEnergyFeesShop record) { | ||||
| record.updateTenantInfo(getTenantInfo()); | record.updateTenantInfo(getTenantInfo()); | ||||
| return new ResultData(wxEnergyService.getFeesCalcuteComponentList(record)); | |||||
| return new ResultData(wxEnergyService.getFeesShopComponentList(record)); | |||||
| } | } | ||||
| @ApiOperation("计费标准新增修改") | @ApiOperation("计费标准新增修改") | ||||
| @@ -389,13 +391,13 @@ public class WxEnergyController extends BaseController { | |||||
| @GetMapping("feesShopDetail") | @GetMapping("feesShopDetail") | ||||
| public ResultData feesShopDetail(@ModelAttribute WxEnergyFeesShop record) { | public ResultData feesShopDetail(@ModelAttribute WxEnergyFeesShop record) { | ||||
| record.updateTenantInfo(getTenantInfo()); | record.updateTenantInfo(getTenantInfo()); | ||||
| return new ResultData(wxEnergyService.getShopFeesCalcute(record.getId(),record.getTenantId())); | |||||
| return new ResultData(wxEnergyService.getFeesShop(record.getId(),record.getTenantId())); | |||||
| } | } | ||||
| @ApiOperation("店铺修改计费标准") | @ApiOperation("店铺修改计费标准") | ||||
| @PostMapping("updateFeesShop") | @PostMapping("updateFeesShop") | ||||
| public ResultData updateFeesShop(@RequestBody WxEnergyFeesShop record) { | public ResultData updateFeesShop(@RequestBody WxEnergyFeesShop record) { | ||||
| wxEnergyService.saveOrUpdateShopFeesCalcute(record); | |||||
| wxEnergyService.updateFeesShop(record); | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @@ -429,7 +431,10 @@ public class WxEnergyController extends BaseController { | |||||
| @ApiOperation("费用区间自动时间") | @ApiOperation("费用区间自动时间") | ||||
| @GetMapping("periodAutoTimes") | @GetMapping("periodAutoTimes") | ||||
| public ResultData periodAutoTimes(@ModelAttribute WxEnergyFeesTime record) { | public ResultData periodAutoTimes(@ModelAttribute WxEnergyFeesTime record) { | ||||
| return new ResultData(); | |||||
| Map retMap = new HashMap(); | |||||
| retMap.put("startTime", new Date()); | |||||
| retMap.put("endTime", new Date()); | |||||
| return new ResultData(retMap); | |||||
| } | } | ||||
| @ApiOperation("费用区间列表") | @ApiOperation("费用区间列表") | ||||
| @@ -606,6 +611,17 @@ public class WxEnergyController extends BaseController { | |||||
| @PostMapping("createReadingCalcute") | @PostMapping("createReadingCalcute") | ||||
| public ResultData createReadingCalcute(@RequestBody WxEnergyReadingCalcute record) { | public ResultData createReadingCalcute(@RequestBody WxEnergyReadingCalcute record) { | ||||
| record.updateTenantInfo(getTenantInfo()); | record.updateTenantInfo(getTenantInfo()); | ||||
| //如果已经存在则不允许 | |||||
| WxEnergyReadingCalcute rcq = new WxEnergyReadingCalcute(); | |||||
| rcq.updateTenantInfo(record); | |||||
| rcq.setPeriod(record.getPeriod()); | |||||
| rcq.setFeesId(record.getFeesId()); | |||||
| rcq.setIsDel(EnumYesOrNo.NO.getCode()); | |||||
| rcq.setShopIds(record.getShopIds()); | |||||
| List<WxEnergyReadingCalcute> rcList = wxEnergyService.findCalcuteList(rcq); | |||||
| if (null != rcList && rcList.size() > 0 ) { | |||||
| return new ResultData(Result.ERROR,"已存在重复数据"); | |||||
| } | |||||
| wxEnergyService.saveOrUpdateReadingCalcute(record,this.getUser()); | wxEnergyService.saveOrUpdateReadingCalcute(record,this.getUser()); | ||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @@ -654,27 +670,18 @@ public class WxEnergyController extends BaseController { | |||||
| } | } | ||||
| @ApiOperation("科目抄表计算记录导出") | @ApiOperation("科目抄表计算记录导出") | ||||
| @GetMapping("readingCalcuteExport") | |||||
| public void readingCalcuteExport(@ModelAttribute WxEnergyReadingCalcute record, HttpServletRequest request, HttpServletResponse response) { | |||||
| // record.updateTenantInfo(getTenantInfo()); | |||||
| // WxEnergyReadingCalcute wrc = wxEnergyService.getReadingCalcuteById(record); | |||||
| // if (null == wrc) { | |||||
| // return; | |||||
| // } | |||||
| // wxEnergyService.exportReadingCalcute(wrc, request, response); | |||||
| } | |||||
| @ApiOperation("计算") | |||||
| @PostMapping("calcute") | |||||
| public ResultData calcute(@RequestBody WxEnergyReadingCalcute record) { | |||||
| // record.updateTenantInfo(getTenantInfo()); | |||||
| // WxEnergyReadingCalcute wrc = wxEnergyService.getReadingCalcuteById(record); | |||||
| // if (null == wrc) { | |||||
| // return new ResultData(Result.ERROR,"id错误"); | |||||
| // } | |||||
| // Integer number = wxEnergyService.calcuteReading(wrc, getUser()); | |||||
| // return new ResultData(number); | |||||
| return null; | |||||
| @GetMapping("readingCalcuteResultExport") | |||||
| public void readingCalcuteResultExport(@ModelAttribute WxEnergyReadingCalcuteResult record, HttpServletRequest request, HttpServletResponse response) { | |||||
| record.updateTenantInfo(getTenantInfo()); | |||||
| wxEnergyService.exportReadingCalcuteResult(record, request, response); | |||||
| } | |||||
| @ApiOperation("生成账单") | |||||
| @PostMapping("createBill") | |||||
| public ResultData createBill(@RequestBody WxEnergyReadingCalcute record) { | |||||
| record.updateTenantInfo(getTenantInfo()); | |||||
| wxEnergyService.createBill(record, getUser()); | |||||
| return new ResultData(); | |||||
| } | } | ||||
| @PostMapping("calcuteIsDel") | @PostMapping("calcuteIsDel") | ||||
| @@ -675,42 +675,6 @@ CREATE TABLE `wx_energy_fees_time_shop` ( | |||||
| KEY `T_P_S` (`tenant_id`,`shop_id`,`period`) | KEY `T_P_S` (`tenant_id`,`shop_id`,`period`) | ||||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='能耗表'; | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='能耗表'; | ||||
| CREATE TABLE `wx_energy_reading_calcute_shop` ( | |||||
| `id` bigint(20) NOT NULL COMMENT '主键ID', | |||||
| `tenant_id` varchar(5) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '租户ID', | |||||
| `parent_tenant_id` varchar(5) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '父租户ID', | |||||
| `create_time` timestamp NULL DEFAULT NULL, | |||||
| `update_time` timestamp NULL DEFAULT NULL, | |||||
| `calcute_id` bigint(20) NOT NULL COMMENT '费用计算ID', | |||||
| `shop_id` bigint(20) NOT NULL COMMENT '店铺ID', | |||||
| PRIMARY KEY (`id`), | |||||
| UNIQUE KEY `id_UNIQUE` (`id`), | |||||
| UNIQUE KEY `T_T_F` (`tenant_id`,`calcute_id`,`shop_id`) | |||||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='能耗表抄表'; | |||||
| drop TABLE wx_energy_reading_calcute; | |||||
| CREATE TABLE `wx_energy_reading_calcute` ( | |||||
| `id` bigint(20) NOT NULL COMMENT '主键ID', | |||||
| `tenant_id` varchar(5) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '租户ID', | |||||
| `parent_tenant_id` varchar(5) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '父租户ID', | |||||
| `create_time` timestamp NULL DEFAULT NULL, | |||||
| `update_time` timestamp NULL DEFAULT NULL, | |||||
| `create_by` bigint(20) DEFAULT NULL, | |||||
| `create_by_name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, | |||||
| `update_by` bigint(20) DEFAULT NULL, | |||||
| `update_by_name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, | |||||
| `remark` varchar(300) COLLATE utf8mb4_unicode_ci DEFAULT NULL, | |||||
| `period` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '所属年月', | |||||
| `fees_id` bigint(20) NOT NULL COMMENT '科目ID', | |||||
| `is_calcuted` int(1) NOT NULL DEFAULT '0' COMMENT '是否已计算过', | |||||
| `calcute_success` int(1) DEFAULT '0' COMMENT '计算是否成功', | |||||
| `is_del` int(1) NOT NULL DEFAULT '0' COMMENT '是否已删除', | |||||
| `shop_size` int(6) NOT NULL DEFAULT '0' COMMENT '店铺数量', | |||||
| PRIMARY KEY (`id`), | |||||
| UNIQUE KEY `id_UNIQUE` (`id`), | |||||
| UNIQUE KEY `T_P_F` (`tenant_id`,`period`,`fees_id`) | |||||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='能耗表抄表'; | |||||
| alter table wx_energy_meter_reading_0 add column building_name varchar(100) comment '所属楼栋,有可能会是多个'; | alter table wx_energy_meter_reading_0 add column building_name varchar(100) comment '所属楼栋,有可能会是多个'; | ||||
| alter table wx_energy_meter_reading_1 add column building_name varchar(100) comment '所属楼栋,有可能会是多个'; | alter table wx_energy_meter_reading_1 add column building_name varchar(100) comment '所属楼栋,有可能会是多个'; | ||||
| @@ -1320,6 +1284,29 @@ alter table wx_energy_fees_97 add column is_public int(1) not null default | |||||
| alter table wx_energy_fees_98 add column is_public int(1) not null default 0 comment '是否公摊'; | alter table wx_energy_fees_98 add column is_public int(1) not null default 0 comment '是否公摊'; | ||||
| alter table wx_energy_fees_99 add column is_public int(1) not null default 0 comment '是否公摊'; | alter table wx_energy_fees_99 add column is_public int(1) not null default 0 comment '是否公摊'; | ||||
| drop TABLE wx_energy_reading_calcute; | |||||
| CREATE TABLE `wx_energy_reading_calcute` ( | |||||
| `id` bigint(20) NOT NULL COMMENT '主键ID', | |||||
| `tenant_id` varchar(5) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '租户ID', | |||||
| `parent_tenant_id` varchar(5) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '父租户ID', | |||||
| `create_time` timestamp NULL DEFAULT NULL, | |||||
| `update_time` timestamp NULL DEFAULT NULL, | |||||
| `create_by` bigint(20) DEFAULT NULL, | |||||
| `create_by_name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, | |||||
| `update_by` bigint(20) DEFAULT NULL, | |||||
| `update_by_name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, | |||||
| `remark` varchar(300) COLLATE utf8mb4_unicode_ci DEFAULT NULL, | |||||
| `period` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '所属年月', | |||||
| `fees_id` bigint(20) NOT NULL COMMENT '科目ID', | |||||
| `is_calcuted` int(1) NOT NULL DEFAULT '0' COMMENT '是否已计算过', | |||||
| `is_del` int(1) NOT NULL DEFAULT '0' COMMENT '是否已删除', | |||||
| `shop_size` int(6) NOT NULL DEFAULT '0' COMMENT '店铺数量', | |||||
| `shop` text COLLATE utf8mb4_unicode_ci COMMENT '店铺编号', | |||||
| PRIMARY KEY (`id`), | |||||
| UNIQUE KEY `id_UNIQUE` (`id`), | |||||
| UNIQUE KEY `T_P_F` (`tenant_id`,`period`,`fees_id`) | |||||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='能耗表抄表'; | |||||
| CREATE TABLE `wx_energy_reading_calcute_result` ( | CREATE TABLE `wx_energy_reading_calcute_result` ( | ||||
| `id` bigint(20) NOT NULL COMMENT '主键ID', | `id` bigint(20) NOT NULL COMMENT '主键ID', | ||||
| @@ -1331,9 +1318,9 @@ CREATE TABLE `wx_energy_reading_calcute_result` ( | |||||
| `shop_id` bigint(20) NOT NULL COMMENT '店铺ID', | `shop_id` bigint(20) NOT NULL COMMENT '店铺ID', | ||||
| `fees_id` bigint(20) NOT NULL COMMENT '科目编号', | `fees_id` bigint(20) NOT NULL COMMENT '科目编号', | ||||
| `fees_shop_id` bigint(20) NOT NULL COMMENT '店铺科目编号', | `fees_shop_id` bigint(20) NOT NULL COMMENT '店铺科目编号', | ||||
| `meter_id` bigint(20) DEFAULT NULL COMMENT '表编号', | |||||
| `money` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '金额', | `money` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '金额', | ||||
| `period` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '所属年月', | `period` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '所属年月', | ||||
| `money_deail` varchar(300) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '详细说明', | |||||
| PRIMARY KEY (`id`), | PRIMARY KEY (`id`), | ||||
| UNIQUE KEY `id_UNIQUE` (`id`), | UNIQUE KEY `id_UNIQUE` (`id`), | ||||
| UNIQUE KEY `T_T_F` (`tenant_id`,`calcute_id`,`shop_id`) | UNIQUE KEY `T_T_F` (`tenant_id`,`calcute_id`,`shop_id`) | ||||
| @@ -15,7 +15,9 @@ import com.iformall.domain.po.WxAllBill; | |||||
| import com.iformall.domain.po.WxBillAction; | import com.iformall.domain.po.WxBillAction; | ||||
| import com.iformall.domain.po.WxCouponOrder; | import com.iformall.domain.po.WxCouponOrder; | ||||
| import com.iformall.domain.po.WxEnergyFeesTime; | import com.iformall.domain.po.WxEnergyFeesTime; | ||||
| import com.iformall.domain.po.WxEnergyMeter; | |||||
| import com.iformall.domain.po.WxEnergyMeterReading; | import com.iformall.domain.po.WxEnergyMeterReading; | ||||
| import com.iformall.domain.po.WxEnergyMeterShopFloor; | |||||
| import com.iformall.domain.po.WxFlowModel; | import com.iformall.domain.po.WxFlowModel; | ||||
| import com.iformall.domain.po.WxMallBuilding; | import com.iformall.domain.po.WxMallBuilding; | ||||
| import com.iformall.domain.po.WxMerchant; | import com.iformall.domain.po.WxMerchant; | ||||
| @@ -34,6 +36,7 @@ import com.iformall.enums.EnumBillOweOrNearType; | |||||
| import com.iformall.enums.EnumBillUpdateType; | import com.iformall.enums.EnumBillUpdateType; | ||||
| import com.iformall.enums.EnumCouponOrderStatus; | import com.iformall.enums.EnumCouponOrderStatus; | ||||
| import com.iformall.enums.EnumCouponType; | import com.iformall.enums.EnumCouponType; | ||||
| import com.iformall.enums.EnumEnergyMeterShopFloorType; | |||||
| import com.iformall.enums.EnumEnergyMeterType; | import com.iformall.enums.EnumEnergyMeterType; | ||||
| import com.iformall.enums.EnumFilterSettle; | import com.iformall.enums.EnumFilterSettle; | ||||
| import com.iformall.enums.EnumFlowKey; | import com.iformall.enums.EnumFlowKey; | ||||
| @@ -379,13 +382,46 @@ public class WxMallAdminController extends BaseController { | |||||
| } | } | ||||
| @ApiOperation("抄表数据分页列表接口") | @ApiOperation("抄表数据分页列表接口") | ||||
| @GetMapping("readingList") | |||||
| @GetMapping("shopMeterList") | |||||
| public ResultData shopMeterList(@ModelAttribute WxEnergyMeter record) { | |||||
| record.setIsDel(EnumYesOrNo.NO.getCode()); | |||||
| setQueryDataRule(record); | |||||
| WxEnergyMeterShopFloor sfq = new WxEnergyMeterShopFloor(); | |||||
| sfq.updateTenantInfo(record); | |||||
| sfq.setType(EnumEnergyMeterShopFloorType.SHOP.getCode()); | |||||
| if (StringUtils.isNotBlank(record.getShopNumber())) { | |||||
| WxShop sq = new WxShop(); | |||||
| sq.updateTenantInfo(record); | |||||
| sq.setShopNumber(record.getShopNumber()); | |||||
| List<Long> sids = wxShopService.getShopIds(sq); | |||||
| if (null == sids || sids.size() <= 0 ) { | |||||
| return new ResultData(); | |||||
| } | |||||
| sfq.setAliseIdList(sids); | |||||
| } | |||||
| sfq.setAliseId(record.getShopId()); | |||||
| List<Long> mids = wxEnergyService.getMeterIdList(sfq); | |||||
| if (null == mids || mids.size() <= 0 ) { | |||||
| return new ResultData(); | |||||
| } | |||||
| record.setIds(mids); | |||||
| record.setSortColumns(BaseEntity.SortField.CreateTime_DESC); | |||||
| PageInfo<WxEnergyMeter> page = wxEnergyService.meterListAsPage(record, 1, 1000); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("抄表数据分页列表接口") | |||||
| @GetMapping("preShopReadingList") | |||||
| public ResultData readingList(@ModelAttribute WxEnergyMeterReading record) { | public ResultData readingList(@ModelAttribute WxEnergyMeterReading record) { | ||||
| record.setIsDel(EnumYesOrNo.NO.getCode()); | record.setIsDel(EnumYesOrNo.NO.getCode()); | ||||
| setQueryDataRule(record); | setQueryDataRule(record); | ||||
| record.setSortColumns(BaseEntity.SortField.CreateTime_DESC); | record.setSortColumns(BaseEntity.SortField.CreateTime_DESC); | ||||
| PageInfo<WxEnergyMeterReading> page = wxEnergyService.readingListAsPage(record, 1, 1000); | PageInfo<WxEnergyMeterReading> page = wxEnergyService.readingListAsPage(record, 1, 1000); | ||||
| return new ResultData(page); | |||||
| if (null != page && null != page.getList() && page.getList().size() > 0 ) { | |||||
| return new ResultData(page.getList().get(0)); | |||||
| } | |||||
| return new ResultData(); | |||||
| } | } | ||||
| //能源抄表费用 | //能源抄表费用 | ||||
| @@ -435,6 +435,13 @@ public class BaseMyBatisConfiguration { | |||||
| wxAllBillSharding.setRule(EnumShardingRule.HASH.getCode()); | wxAllBillSharding.setRule(EnumShardingRule.HASH.getCode()); | ||||
| shardingList.add(wxAllBillSharding); | shardingList.add(wxAllBillSharding); | ||||
| ShardingSphere wxEnergyReadingCalcuteResultSharding = new ShardingSphere(); | |||||
| wxEnergyReadingCalcuteResultSharding.setColumn("tenant_id"); | |||||
| wxEnergyReadingCalcuteResultSharding.setTableName("wx_energy_reading_calcute_result"); | |||||
| wxEnergyReadingCalcuteResultSharding.setCount(100); | |||||
| wxEnergyReadingCalcuteResultSharding.setRule(EnumShardingRule.HASH.getCode()); | |||||
| shardingList.add(wxEnergyReadingCalcuteResultSharding); | |||||
| //初始化 | //初始化 | ||||
| shardingSpherePlugin.setShardingSpheres(shardingList); | shardingSpherePlugin.setShardingSpheres(shardingList); | ||||
| Properties properties = new Properties(); | Properties properties = new Properties(); | ||||
| @@ -260,7 +260,7 @@ public class WxAllBill extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value = "能源抄表计算ID", name = "energyReadingCalcuteId") | @io.swagger.annotations.ApiModelProperty(value = "能源抄表计算ID", name = "energyReadingCalcuteId") | ||||
| private Long energyReadingCalcuteId; | private Long energyReadingCalcuteId; | ||||
| @io.swagger.annotations.ApiModelProperty(value = "能源抄表ID", name = "energyReadingId") | |||||
| @io.swagger.annotations.ApiModelProperty(value = "WxEnergyReadingCalcuteResult的id", name = "energyReadingId") | |||||
| private Long energyReadingId; | private Long energyReadingId; | ||||
| @io.swagger.annotations.ApiModelProperty(value = "账单额外生成来源EnumBillExtraCreateFrom", name = "extraCreateFrom") | @io.swagger.annotations.ApiModelProperty(value = "账单额外生成来源EnumBillExtraCreateFrom", name = "extraCreateFrom") | ||||
| @@ -46,9 +46,14 @@ public class WxEnergyFeesShop extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value = "公摊计算公司", name = "formula") | @io.swagger.annotations.ApiModelProperty(value = "公摊计算公司", name = "formula") | ||||
| private String formula; | private String formula; | ||||
| @io.swagger.annotations.ApiModelProperty(value = "公摊计算公式数组字符串", name = "formula") | |||||
| private String formulaListStr; | |||||
| @TableField(exist = false) | |||||
| private List<String> formulaList; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "公摊计算公司", name = "formulaContent") | @io.swagger.annotations.ApiModelProperty(value = "公摊计算公司", name = "formulaContent") | ||||
| private String formulaContent; | private String formulaContent; | ||||
| @TableField(exist = false) | |||||
| private List<String> formulaContentList; | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private String treeType="feesShop"; | private String treeType="feesShop"; | ||||
| @@ -64,8 +69,6 @@ public class WxEnergyFeesShop extends TenantEntity { | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private List<Long> shopIds; | private List<Long> shopIds; | ||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private List<Long> calcuteIds; | |||||
| @TableField(exist = false) | |||||
| private String feesName; | private String feesName; | ||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private String feesIdsStr; | private String feesIdsStr; | ||||
| @@ -83,7 +83,6 @@ public class WxEnergyMeter extends TenantEntity { | |||||
| private Long treeParentId; | private Long treeParentId; | ||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private String treeParentType; | private String treeParentType; | ||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private Long aliasId; | private Long aliasId; | ||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| @@ -95,6 +94,8 @@ public class WxEnergyMeter extends TenantEntity { | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private Long shopId; | private Long shopId; | ||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private String shopNumber; | |||||
| @TableField(exist = false) | |||||
| private List<Integer> physicsTypeList; | private List<Integer> physicsTypeList; | ||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private Integer isRealMeter; | private Integer isRealMeter; | ||||
| @@ -102,4 +103,5 @@ public class WxEnergyMeter extends TenantEntity { | |||||
| private Integer isValid; | private Integer isValid; | ||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private Integer hasShop; | private Integer hasShop; | ||||
| } | } | ||||
| @@ -118,6 +118,8 @@ public class WxEnergyMeterReading extends TenantEntity { | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private List<Long> shopIds; | private List<Long> shopIds; | ||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private List<Long> meterIds; | |||||
| @TableField(exist = false) | |||||
| private String shopIdsStr; | private String shopIdsStr; | ||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private Long timeId; | private Long timeId; | ||||
| @@ -154,56 +156,4 @@ public class WxEnergyMeterReading extends TenantEntity { | |||||
| return excelObject; | return excelObject; | ||||
| } | } | ||||
| private WxAllBill generateBill(WxEnergyReadingCalcute calcute,WxMerchant merchant,MallUserInfo user,String needPay,String detail,String remark) { | |||||
| WxAllBill daily = new WxAllBill(); | |||||
| // final IdWorker idWorker = IdWorker.get(); | |||||
| // daily.setId(idWorker.nextId()); | |||||
| // daily.updateTenantInfo(this); | |||||
| // daily.setMerchantId(merchant.getId()); | |||||
| // daily.setRentShopType(merchant.getType()); | |||||
| // daily.setCreatetime(new Date()); | |||||
| // daily.setCreateBy(user.getId()); | |||||
| // daily.setCreateByName(user.getName()); | |||||
| // daily.setUpdateBy(user.getId()); | |||||
| // daily.setUpdateByName(user.getName()); | |||||
| // daily.setUpdatetime(new Date()); | |||||
| // daily.setReceivePay(needPay); | |||||
| // daily.setNeedPay(needPay); | |||||
| // daily.setPay("0"); | |||||
| // daily.setStarttime(this.startTime); | |||||
| // daily.setEndtime(this.endTime); | |||||
| // daily.setOwe(needPay); | |||||
| // daily.setShopId(this.shopId); | |||||
| // daily.setShopNumber(this.shopNumber); | |||||
| // daily.setBillType(EnumBillAllType.DAILY.getCode()); | |||||
| // daily.setEnergyFeesId(calcute.getFeesId()); | |||||
| // daily.setPriceDetail(detail); | |||||
| // daily.setServiceChargePay("0"); | |||||
| // daily.setBillRemark(remark); | |||||
| // daily.setIsPreview(EnumYesOrNo.NO.getCode()); | |||||
| // daily.setEnergyReadingCalcuteId(calcute.getId()); | |||||
| // daily.setEnergyReadingId(id); | |||||
| return daily; | |||||
| } | |||||
| public WxAllBill generateUserBill(WxEnergyReadingCalcute calcute,WxMerchant merchant,MallUserInfo user,WxEnergyMeter meter) { | |||||
| // BigDecimal dx = new BigDecimal(this.curNumber).subtract(new BigDecimal(this.preNumber)); | |||||
| // BigDecimal needPay = new BigDecimal(this.price).multiply(dx).divide(new BigDecimal(meter.getRate())).setScale(2,RoundingMode.HALF_UP); | |||||
| // if (needPay.compareTo(new BigDecimal(0)) <= 0 ) { | |||||
| // return null; | |||||
| // } | |||||
| // String detail = "单价:"+this.price+",上次读数:"+this.preNumber+",本次读数:"+this.curNumber+",读数差:"+dx.toPlainString()+",表倍率:"+meter.getRate()+",费用:"+needPay.toPlainString(); | |||||
| // return generateBill(calcute,merchant, user, needPay.toPlainString(), detail, "抄表计算自动生成"); | |||||
| return null; | |||||
| } | |||||
| public WxAllBill generatePublicBill(WxEnergyReadingCalcute calcute,WxMerchant merchant,MallUserInfo user,String needPay) { | |||||
| // if (new BigDecimal(needPay).compareTo(new BigDecimal(0)) <= 0 ) { | |||||
| // return null; | |||||
| // } | |||||
| // String detail = "单价:"+this.price+",费用:"+needPay; | |||||
| // return generateBill(calcute,merchant, user, needPay, detail, "抄表计算自动生成公摊"); | |||||
| return null; | |||||
| } | |||||
| } | } | ||||
| @@ -49,6 +49,8 @@ public class WxEnergyMeterShopFloor extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value = "关联的编号", name = "aliseId") | @io.swagger.annotations.ApiModelProperty(value = "关联的编号", name = "aliseId") | ||||
| private Long aliseId; | private Long aliseId; | ||||
| @TableField(exist = false) | |||||
| private List<Long> aliseIdList; | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private List<Long> shopIds; | private List<Long> shopIds; | ||||
| @@ -59,21 +59,9 @@ public class WxEnergyReadingCalcute extends TenantEntity { | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private String feesPhysicsTypeName; | private String feesPhysicsTypeName; | ||||
| @io.swagger.annotations.ApiModelProperty(value = "isCalcuted", name = "isCalcuted") | |||||
| @io.swagger.annotations.ApiModelProperty(value = "是否已生成账单", name = "isCalcuted") | |||||
| private Integer isCalcuted; | private Integer isCalcuted; | ||||
| @io.swagger.annotations.ApiModelProperty(value = "importSuccess", name = "importSuccess") | |||||
| private Integer calcuteSuccess; | |||||
| @TableField(exist = false) | |||||
| private String calcuteSuccessName; | |||||
| private String getCalcuteSuccessName() { | |||||
| if (null != calcuteSuccess && calcuteSuccess.intValue() == EnumYesOrNo.YES.getCode().intValue()) { | |||||
| return "成功"; | |||||
| }else { | |||||
| return "未完成计算"; | |||||
| } | |||||
| } | |||||
| @io.swagger.annotations.ApiModelProperty(value = "是否删除", name = "isDel") | @io.swagger.annotations.ApiModelProperty(value = "是否删除", name = "isDel") | ||||
| private Integer isDel; | private Integer isDel; | ||||
| @@ -2,7 +2,9 @@ package com.iformall.domain.po; | |||||
| import com.baomidou.mybatisplus.annotation.TableField; | import com.baomidou.mybatisplus.annotation.TableField; | ||||
| import com.baomidou.mybatisplus.annotation.TableName; | import com.baomidou.mybatisplus.annotation.TableName; | ||||
| import com.iformall.common.IdWorker; | |||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.enums.EnumBillAllType; | |||||
| import com.iformall.enums.EnumYesOrNo; | import com.iformall.enums.EnumYesOrNo; | ||||
| import com.iformall.utils.DateUtils; | import com.iformall.utils.DateUtils; | ||||
| @@ -65,17 +67,47 @@ public class WxEnergyReadingCalcuteResult extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="费用标准ID",name="feesCalcuteId") | @io.swagger.annotations.ApiModelProperty(value="费用标准ID",name="feesCalcuteId") | ||||
| private Long feesShopId; | private Long feesShopId; | ||||
| @io.swagger.annotations.ApiModelProperty(value="表ID",name="meterId") | |||||
| private Long meterId; | |||||
| @Excel(name = "表号", width = 20, orderNum = "7") | |||||
| @TableField(exist = false) | |||||
| private String meterName; | |||||
| @Excel(name = "金额", width = 20, orderNum = "8") | @Excel(name = "金额", width = 20, orderNum = "8") | ||||
| @io.swagger.annotations.ApiModelProperty(value="金额",name="money") | @io.swagger.annotations.ApiModelProperty(value="金额",name="money") | ||||
| private String money; | private String money; | ||||
| @Excel(name = "详细说明", width = 20, orderNum = "8") | |||||
| @io.swagger.annotations.ApiModelProperty(value="详细说明",name="moneyDeail") | |||||
| private String moneyDeail; | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private List<Long> shopIds; | private List<Long> shopIds; | ||||
| public WxAllBill generateBill(WxEnergyReadingCalcute calcute,WxMerchant merchant,WxShop shop,MallUserInfo user,String needPay,String detail,String remark) { | |||||
| WxAllBill daily = new WxAllBill(); | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| daily.setId(idWorker.nextId()); | |||||
| daily.updateTenantInfo(this); | |||||
| daily.setMerchantId(merchant.getId()); | |||||
| daily.setRentShopType(merchant.getType()); | |||||
| daily.setCreatetime(new Date()); | |||||
| daily.setCreateBy(user.getId()); | |||||
| daily.setCreateByName(user.getName()); | |||||
| daily.setUpdateBy(user.getId()); | |||||
| daily.setUpdateByName(user.getName()); | |||||
| daily.setUpdatetime(new Date()); | |||||
| daily.setReceivePay(needPay); | |||||
| daily.setNeedPay(needPay); | |||||
| daily.setPay("0"); | |||||
| daily.setStarttime(DateUtils.getDayBegin(new Date())); | |||||
| daily.setEndtime(DateUtils.getDayEnd(new Date())); | |||||
| daily.setOwe(needPay); | |||||
| daily.setShopId(this.shopId); | |||||
| daily.setShopNumber(shop.getShopNumber()); | |||||
| daily.setBillType(EnumBillAllType.DAILY.getCode()); | |||||
| daily.setEnergyFeesId(calcute.getFeesId()); | |||||
| daily.setPriceDetail(detail); | |||||
| daily.setServiceChargePay("0"); | |||||
| daily.setBillRemark(remark); | |||||
| daily.setIsPreview(EnumYesOrNo.NO.getCode()); | |||||
| daily.setEnergyReadingCalcuteId(calcute.getId()); | |||||
| daily.setEnergyReadingId(id); | |||||
| return daily; | |||||
| } | |||||
| } | } | ||||
| @@ -116,7 +116,7 @@ public class WxShop extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="管理人电话",name="managerPhone") | @io.swagger.annotations.ApiModelProperty(value="管理人电话",name="managerPhone") | ||||
| private String managerPhone; | private String managerPhone; | ||||
| @io.swagger.annotations.ApiModelProperty(value = "类型", name = "type") | |||||
| @io.swagger.annotations.ApiModelProperty(value = "类型EnumRentShopType", name = "type") | |||||
| private Integer type; | private Integer type; | ||||
| @@ -10,7 +10,8 @@ public enum EnumRentContractAdjustRatioWay { | |||||
| RATIO(1, "按比例"), | RATIO(1, "按比例"), | ||||
| MONEY(2, "按金额"), | MONEY(2, "按金额"), | ||||
| CUSTOM(3, "固定金额"), | CUSTOM(3, "固定金额"), | ||||
| FIX_RATIO(4, "固定比率"); | |||||
| FIX_RATIO(4, "固定比率"), | |||||
| FIX_UNIT_PRICE(5, "固定单价"); | |||||
| public static EnumRentContractAdjustRatioWay getEnum(Integer code) { | public static EnumRentContractAdjustRatioWay getEnum(Integer code) { | ||||
| for (EnumRentContractAdjustRatioWay value : values()) { | for (EnumRentContractAdjustRatioWay value : values()) { | ||||
| @@ -10,6 +10,8 @@ import java.util.List; | |||||
| public interface WxEnergyMeterMapper extends CommonMapper<WxEnergyMeter, Long> { | public interface WxEnergyMeterMapper extends CommonMapper<WxEnergyMeter, Long> { | ||||
| List<WxEnergyMeter> findList(WxEnergyMeter wxBillRent); | List<WxEnergyMeter> findList(WxEnergyMeter wxBillRent); | ||||
| List<Long> findIdList(WxEnergyMeter wxBillRent); | |||||
| WxEnergyMeter selectById(@Param("id")Long id,@Param("tenantId")String tenantId); | WxEnergyMeter selectById(@Param("id")Long id,@Param("tenantId")String tenantId); | ||||
| @@ -4,6 +4,8 @@ import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.po.WxEnergyMeterReading; | import com.iformall.domain.po.WxEnergyMeterReading; | ||||
| import org.apache.ibatis.annotations.Param; | import org.apache.ibatis.annotations.Param; | ||||
| import java.math.BigDecimal; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| @@ -16,4 +18,6 @@ public interface WxEnergyMeterReadingMapper extends CommonMapper<WxEnergyMeterRe | |||||
| WxEnergyMeterReading selectById(@Param("id")Long id,@Param("tenantId")String tenantId); | WxEnergyMeterReading selectById(@Param("id")Long id,@Param("tenantId")String tenantId); | ||||
| void setIsDel(@Param("id")Long id,@Param("tenantId")String tenantId,@Param("isDel")Integer isDel); | void setIsDel(@Param("id")Long id,@Param("tenantId")String tenantId,@Param("isDel")Integer isDel); | ||||
| BigDecimal findNumberSum(WxEnergyMeterReading wxBillRent); | |||||
| } | } | ||||
| @@ -33,7 +33,7 @@ public interface WxEnergyService { | |||||
| void createMeterAlias(WxEnergyMeterShopFloor record); | void createMeterAlias(WxEnergyMeterShopFloor record); | ||||
| void createChildMeterAlias(WxEnergyMeterChild record); | void createChildMeterAlias(WxEnergyMeterChild record); | ||||
| void deleteMeterAlias(WxEnergyMeterShopFloor record); | void deleteMeterAlias(WxEnergyMeterShopFloor record); | ||||
| void deleteChildMeterAlias(WxEnergyMeterChild record); | |||||
| void deleteChildMeterAlias(WxEnergyMeter record); | |||||
| void updateMeterIsDel(WxEnergyMeter record); | void updateMeterIsDel(WxEnergyMeter record); | ||||
| Map<Long,WxEnergyMeter> getMeterMap(WxEnergyMeter record); | Map<Long,WxEnergyMeter> getMeterMap(WxEnergyMeter record); | ||||
| List<Long> getMeterIdList(WxEnergyMeterShopFloor record); | List<Long> getMeterIdList(WxEnergyMeterShopFloor record); | ||||
| @@ -58,11 +58,11 @@ public interface WxEnergyService { | |||||
| List<Long> getFeesIdList(WxEnergyFees record); | List<Long> getFeesIdList(WxEnergyFees record); | ||||
| //计算标砖 | //计算标砖 | ||||
| List<Map<String,String>> getFeesCalcuteComponentList(WxEnergyFeesShop record); | |||||
| List<Map<String,String>> getFeesShopComponentList(WxEnergyFeesShop record); | |||||
| void createFeesShop(WxEnergyFeesShop record); | void createFeesShop(WxEnergyFeesShop record); | ||||
| void deleteFeesShop(WxEnergyFeesShop record); | void deleteFeesShop(WxEnergyFeesShop record); | ||||
| WxEnergyFeesShop getShopFeesCalcute(Long id,String tenantId); | |||||
| void saveOrUpdateShopFeesCalcute(WxEnergyFeesShop record); | |||||
| WxEnergyFeesShop getFeesShop(Long id,String tenantId); | |||||
| void updateFeesShop(WxEnergyFeesShop record); | |||||
| PageInfo<WxEnergyFeesShop> feesShopListAsPage(WxEnergyFeesShop record, Integer pageIndex, Integer pageSize); | PageInfo<WxEnergyFeesShop> feesShopListAsPage(WxEnergyFeesShop record, Integer pageIndex, Integer pageSize); | ||||
| //抄表数据 | //抄表数据 | ||||
| @@ -77,10 +77,11 @@ public interface WxEnergyService { | |||||
| //抄表科目计算数据 | //抄表科目计算数据 | ||||
| PageInfo<WxEnergyReadingCalcute> readingCalcuteListAsPage(WxEnergyReadingCalcute record, Integer pageIndex, Integer pageSize); | PageInfo<WxEnergyReadingCalcute> readingCalcuteListAsPage(WxEnergyReadingCalcute record, Integer pageIndex, Integer pageSize); | ||||
| List<WxEnergyReadingCalcute> findCalcuteList(WxEnergyReadingCalcute record); | |||||
| void saveOrUpdateReadingCalcute(WxEnergyReadingCalcute record,MallUserInfo userInfo); | void saveOrUpdateReadingCalcute(WxEnergyReadingCalcute record,MallUserInfo userInfo); | ||||
| PageInfo<WxEnergyReadingCalcuteResult> readingCalcuteResultListAsPage(WxEnergyReadingCalcuteResult record, Integer pageIndex, Integer pageSize); | PageInfo<WxEnergyReadingCalcuteResult> readingCalcuteResultListAsPage(WxEnergyReadingCalcuteResult record, Integer pageIndex, Integer pageSize); | ||||
| void exportReadingCalcute(WxEnergyReadingCalcute record,HttpServletRequest request, HttpServletResponse response); | |||||
| Integer calcuteReading(WxEnergyReadingCalcute record, MallUserInfo user); | |||||
| void exportReadingCalcuteResult(WxEnergyReadingCalcuteResult record,HttpServletRequest request, HttpServletResponse response); | |||||
| void createBill(WxEnergyReadingCalcute record, MallUserInfo user); | |||||
| void setReadingCalcuteIsDel(WxEnergyReadingCalcute record); | void setReadingCalcuteIsDel(WxEnergyReadingCalcute record); | ||||
| List<String> getReadingCalcuteShopNumber(WxEnergyReadingCalcute record); | List<String> getReadingCalcuteShopNumber(WxEnergyReadingCalcute record); | ||||
| @@ -55,6 +55,8 @@ public interface WxMallBuildingService { | |||||
| void deleteById(Long id); | void deleteById(Long id); | ||||
| ResultData getBuildingList(TenantEntity tenantEntity); | ResultData getBuildingList(TenantEntity tenantEntity); | ||||
| List<WxMallBuilding> getBuildingList1(TenantEntity tenantEntity); | |||||
| ResultData getBuildingFloorList(WxMallBuilding wxMallBuilding,MallUserInfo mallUser); | ResultData getBuildingFloorList(WxMallBuilding wxMallBuilding,MallUserInfo mallUser); | ||||
| @@ -45,6 +45,8 @@ public interface WxMallFloorService { | |||||
| ResultData getFloorList(TenantEntity tenantEntity, Long buildingId); | ResultData getFloorList(TenantEntity tenantEntity, Long buildingId); | ||||
| List<WxMallFloor> getBudingFloorList(TenantEntity tenantEntity, Long buildingId); | |||||
| List<Long> getFloorIdList(WxMallFloor record); | List<Long> getFloorIdList(WxMallFloor record); | ||||
| void deleteByBuildingId(Long buildingId); | void deleteByBuildingId(Long buildingId); | ||||
| @@ -360,12 +360,16 @@ public class WxBillAllHelper { | |||||
| * 那是之前的账单,不处理。 | * 那是之前的账单,不处理。 | ||||
| * @param merchant | * @param merchant | ||||
| */ | */ | ||||
| public boolean billEndCalcute(Integer decimalSize,Date endTime,WxAllBill bill,WxBillAction action, boolean isAllReturn) { | |||||
| public boolean billEndCalcute(Integer decimalSize,Date endTime,WxAllBill bill,WxBillAction action) { | |||||
| String endTimeStr = DateUtils.date2String(endTime,DateUtils.DATE_TIME_PATTERN); | String endTimeStr = DateUtils.date2String(endTime,DateUtils.DATE_TIME_PATTERN); | ||||
| boolean isUpdate = false; | boolean isUpdate = false; | ||||
| action.setBillId(bill.getId()); | action.setBillId(bill.getId()); | ||||
| action.setBillType(bill.getBillType()); | action.setBillType(bill.getBillType()); | ||||
| String oldReceivePay = bill.getReceivePay(); | String oldReceivePay = bill.getReceivePay(); | ||||
| boolean isAllReturn = false; | |||||
| if (EnumBillAllType.getEnum(bill.getBillType()).isDeposit()) { | |||||
| isAllReturn = true; | |||||
| } | |||||
| //如果账单的开始时间在结束时间之后,已经支付了的要退回。 | //如果账单的开始时间在结束时间之后,已经支付了的要退回。 | ||||
| if (!bill.getStarttime().before(endTime)) { | if (!bill.getStarttime().before(endTime)) { | ||||
| bill.setReceivePay("0"); | bill.setReceivePay("0"); | ||||
| @@ -1,54 +1,223 @@ | |||||
| package com.iformall.service.helper; | package com.iformall.service.helper; | ||||
| import java.math.BigDecimal; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.HashMap; | import java.util.HashMap; | ||||
| import java.util.Iterator; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.context.annotation.Lazy; | |||||
| import org.springframework.stereotype.Service; | |||||
| import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; | |||||
| import com.iformall.domain.po.WxEnergyFees; | |||||
| import com.iformall.domain.po.WxEnergyFeesShop; | import com.iformall.domain.po.WxEnergyFeesShop; | ||||
| import com.iformall.domain.po.WxEnergyFeesTime; | import com.iformall.domain.po.WxEnergyFeesTime; | ||||
| import com.iformall.domain.po.WxEnergyMeter; | import com.iformall.domain.po.WxEnergyMeter; | ||||
| import com.iformall.domain.po.WxEnergyMeterReading; | |||||
| import com.iformall.domain.po.WxMallBuilding; | |||||
| import com.iformall.domain.po.WxMallFloor; | |||||
| import com.iformall.domain.po.WxShop; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.enums.EnumEnergyMeterPhysicsType; | |||||
| import com.iformall.enums.EnumYesOrNo; | |||||
| import com.iformall.mapper.WxEnergyMeterMapper; | |||||
| import com.iformall.mapper.WxEnergyMeterReadingMapper; | |||||
| import com.iformall.service.WxMallBuildingService; | |||||
| import com.iformall.service.WxMallFloorService; | |||||
| import com.iformall.utils.FormulaParser; | |||||
| import com.iformall.utils.PlaceholderExtractorWithPrefixAndSuffix; | |||||
| @Service | |||||
| public class WxEnergyHelper { | public class WxEnergyHelper { | ||||
| @Autowired | |||||
| WxEnergyMeterReadingMapper wxEnergyMeterReadingMapper; | |||||
| @Autowired | |||||
| WxEnergyMeterMapper wxEnergyMeterMapper; | |||||
| @Lazy | |||||
| @Autowired | |||||
| private WxMallBuildingService wxMallBuildingService; | |||||
| @Lazy | |||||
| @Autowired | |||||
| WxMallFloorService wxMallFloorService; | |||||
| public static List<Map<String,String>> generateCalcuteComponent() { | |||||
| public List<Map<String,String>> generateCalcuteComponent(TenantEntity tenantEntity) { | |||||
| //公共表,公摊总表,当前楼栋面积,当前楼层面积,总面积,店铺公摊系数 | //公共表,公摊总表,当前楼栋面积,当前楼层面积,总面积,店铺公摊系数 | ||||
| List<Map<String,String>> retList = new ArrayList<Map<String,String>>(); | List<Map<String,String>> retList = new ArrayList<Map<String,String>>(); | ||||
| Map<String,String> currentBuildingArea = new HashMap<String,String>(); | |||||
| currentBuildingArea.put("name", "店铺所属楼栋总计租面积"); | |||||
| currentBuildingArea.put("value", "{#currentBuildingArea#}"); | |||||
| retList.add(currentBuildingArea); | |||||
| Map<String,String> currentFloorArea = new HashMap<String,String>(); | |||||
| currentFloorArea.put("name", "店铺所属楼层总计租面积"); | |||||
| currentFloorArea.put("value", "{#currentFloorArea#}"); | |||||
| retList.add(currentFloorArea); | |||||
| Map<String,String> totalArea = new HashMap<String,String>(); | |||||
| totalArea.put("name", "商场总计租面积"); | |||||
| totalArea.put("value", "{#totalArea#}"); | |||||
| retList.add(totalArea); | |||||
| List<WxMallBuilding> buildingList = wxMallBuildingService.getBuildingList1(tenantEntity); | |||||
| if (null != buildingList && buildingList.size() > 0 ) { | |||||
| for (int i = 0 ; i < buildingList.size(); i++) { | |||||
| WxMallBuilding mb = buildingList.get(i); | |||||
| addComponent(retList, "楼栋("+mb.getBuildingName()+")面积", "{#buildingArea_"+mb.getId()+"#}"); | |||||
| List<WxMallFloor> floorList = wxMallFloorService.getBudingFloorList(tenantEntity, mb.getId()); | |||||
| if (null != floorList && floorList.size() > 0 ) { | |||||
| for (int j = 0 ; j < floorList.size(); j++ ) { | |||||
| WxMallFloor floor = floorList.get(j); | |||||
| addComponent(retList, "楼层("+mb.getBuildingName()+floor.getFloorName()+")面积", "{#floorArea_"+floor.getId()+"#}"); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| addComponent(retList, "商场总计租面积", "{#totalArea#}"); | |||||
| addComponent(retList, "店铺公摊系数", "{#shopPublicRax#}"); | |||||
| return retList; | |||||
| } | |||||
| private void addComponent(List<Map<String,String>> retList, String name, String value) { | |||||
| Map<String,String> calcuteRax = new HashMap<String,String>(); | Map<String,String> calcuteRax = new HashMap<String,String>(); | ||||
| calcuteRax.put("name", "公摊系数"); | |||||
| calcuteRax.put("value", "{#calcuteRax#}"); | |||||
| calcuteRax.put("name", name); | |||||
| calcuteRax.put("value", value); | |||||
| retList.add(calcuteRax); | retList.add(calcuteRax); | ||||
| return retList; | |||||
| } | } | ||||
| public static Map<String,String> generateMeterComponent(WxEnergyMeter meter) { | |||||
| public Map<String,String> generateMeterComponent(WxEnergyMeter meter) { | |||||
| Map<String,String> m = new HashMap<String,String>(); | Map<String,String> m = new HashMap<String,String>(); | ||||
| m.put("name", meter.getName()); | m.put("name", meter.getName()); | ||||
| m.put("value", "{#meter_"+meter.getId()+"#}"); | m.put("value", "{#meter_"+meter.getId()+"#}"); | ||||
| return m; | return m; | ||||
| } | } | ||||
| public static String calcuteMoney(WxEnergyFeesTime time,WxEnergyMeter meter,WxEnergyFeesShop shopfee) { | |||||
| return "0"; | |||||
| private String replaceFormulaData(String formula,BigDecimal totalArea,WxShop shop,Map<Long,BigDecimal> buildingAreaMap, | |||||
| Map<Long, BigDecimal> floorAreaMap,Map<Long,BigDecimal> meterNumberMap) { | |||||
| if (StringUtils.isBlank(formula)) { | |||||
| return null; | |||||
| } | |||||
| List<String> buildingAreaList = PlaceholderExtractorWithPrefixAndSuffix.extractPlaceholders(formula, "#buildingArea_", "#"); | |||||
| List<String> floorAreaList = PlaceholderExtractorWithPrefixAndSuffix.extractPlaceholders(formula, "#floorArea_", "#"); | |||||
| List<String> meterList = PlaceholderExtractorWithPrefixAndSuffix.extractPlaceholders(formula, "#meter_", "#"); | |||||
| formula = formula.replaceAll("\\{.*?\\}", ""); | |||||
| if (null != buildingAreaMap && null != buildingAreaList && buildingAreaList.size() > 0 ) { | |||||
| for (int i = 0 ; i < buildingAreaList.size(); i ++) { | |||||
| String buildArea = buildingAreaList.get(i); | |||||
| String[] bs = buildArea.split("_"); | |||||
| if (null != bs && bs.length > 1) { | |||||
| BigDecimal buildingArea = buildingAreaMap.get(Long.parseLong(bs[1])); | |||||
| if (null != buildingArea) { | |||||
| formula = formula.replaceAll("#buildingArea_"+Long.parseLong(bs[1])+"#", buildingArea.toPlainString()); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| if (null != floorAreaMap && null != floorAreaList && floorAreaList.size() > 0 ) { | |||||
| for (int i = 0 ; i < floorAreaList.size(); i ++) { | |||||
| String floorArea = floorAreaList.get(i); | |||||
| String[] bs = floorArea.split("_"); | |||||
| if (null != bs && bs.length > 1) { | |||||
| BigDecimal floorarea = floorAreaMap.get(Long.parseLong(bs[1])); | |||||
| if (null != floorarea) { | |||||
| formula = formula.replaceAll("#floorArea_"+Long.parseLong(bs[1])+"#", floorarea.toPlainString()); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| if (null != meterNumberMap && null != meterList && meterList.size() > 0 ) { | |||||
| for (int i = 0 ; i < meterList.size(); i ++) { | |||||
| String meter = meterList.get(i); | |||||
| String[] bs = meter.split("_"); | |||||
| if (null != bs && bs.length > 1) { | |||||
| BigDecimal mu = meterNumberMap.get(Long.parseLong(bs[1])); | |||||
| if (null != mu ) { | |||||
| formula = formula.replaceAll("#meter_"+Long.parseLong(bs[1])+"#", mu.toPlainString()); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| formula = formula.replaceAll("#totalArea#", totalArea.toPlainString()); | |||||
| formula = formula.replaceAll("#shopPublicRax#", shop.getBuildArea()); | |||||
| return formula; | |||||
| } | |||||
| public void testCalcute(String formula) { | |||||
| if (StringUtils.isBlank(formula)) { | |||||
| return ; | |||||
| } | |||||
| List<String> buildingAreaList = PlaceholderExtractorWithPrefixAndSuffix.extractPlaceholders(formula, "#", "#"); | |||||
| formula = formula.replaceAll("\\{.*?\\}", ""); | |||||
| if (null != buildingAreaList && buildingAreaList.size() > 0 ) { | |||||
| for (int i = 0 ; i < buildingAreaList.size(); i ++) { | |||||
| String floorArea = buildingAreaList.get(i); | |||||
| String relpaceFloorArea = floorArea.replaceAll("\\{.*?\\}", ""); | |||||
| formula = formula.replaceAll(relpaceFloorArea, "1"); | |||||
| } | |||||
| } | |||||
| FormulaParser.evaluate(formula); | |||||
| } | } | ||||
| /** | |||||
| * 计算金额 | |||||
| * 1. 如果是用户表: | |||||
| * 根据店铺所有表的总度数 * 科目单价计算费用 | |||||
| * | |||||
| * 2. 如果是公摊: | |||||
| * 根据科目公式进行计算。 | |||||
| * | |||||
| * @param sb | |||||
| * @param time | |||||
| * @param meterList | |||||
| * @param shopfee | |||||
| * @return | |||||
| */ | |||||
| public String calcuteMoney(StringBuffer sb,BigDecimal totalArea,WxShop shop,WxEnergyFeesTime time,WxEnergyFees fees, WxEnergyFeesShop shopfee, | |||||
| List<Long> userMeterList,Map<Long,List<Long>> summaryMeterMap,Map<Long,BigDecimal> buildingAreaMap,Map<Long, BigDecimal> floorAreaMap) { | |||||
| if (StringUtils.isBlank(shopfee.getPrice())) { | |||||
| return "0"; | |||||
| } | |||||
| if (shopfee.getIsPublic() == EnumYesOrNo.YES.getCode()) { | |||||
| //替代占位符为真实数据 | |||||
| //公摊总表数据,根据公摊总表下的公共表来查询所有的读数 | |||||
| Map<Long,BigDecimal> meterNumberMap = null; | |||||
| if (null != summaryMeterMap) { | |||||
| meterNumberMap = new HashMap<Long,BigDecimal>(); | |||||
| for (Iterator<Long> it = summaryMeterMap.keySet().iterator(); it.hasNext();) { | |||||
| Long sumaryMeterId = it.next(); | |||||
| List<Long> childmids = summaryMeterMap.get(sumaryMeterId); | |||||
| //查询子表的总读数 | |||||
| WxEnergyMeterReading mrq = new WxEnergyMeterReading(); | |||||
| mrq.updateTenantInfo(shopfee); | |||||
| mrq.setMeterIds(childmids); | |||||
| mrq.setStartTime(time.getStartTime()); | |||||
| mrq.setEndTime(time.getEndTime()); | |||||
| BigDecimal totalNumber = wxEnergyMeterReadingMapper.findNumberSum(mrq); | |||||
| if (null == totalNumber || totalNumber.compareTo(new BigDecimal(0)) <= 0 ) { | |||||
| totalNumber = new BigDecimal(0); | |||||
| } | |||||
| meterNumberMap.put(sumaryMeterId, totalNumber); | |||||
| } | |||||
| } | |||||
| String formula = replaceFormulaData(shopfee.getFormula(),totalArea,shop,buildingAreaMap,floorAreaMap,meterNumberMap); | |||||
| if (null != formula) { | |||||
| return new BigDecimal(FormulaParser.evaluate(formula)).setScale(2,BigDecimal.ROUND_HALF_UP).toPlainString(); | |||||
| } | |||||
| return "0"; | |||||
| }else { | |||||
| if (null == userMeterList || userMeterList.size() <= 0 ) { | |||||
| return "0"; | |||||
| } | |||||
| //根据表,区间的开始日期,结束日期来查询抄表数据。 | |||||
| WxEnergyMeterReading mrq = new WxEnergyMeterReading(); | |||||
| mrq.updateTenantInfo(shopfee); | |||||
| mrq.setMeterIds(userMeterList); | |||||
| mrq.setStartTime(time.getStartTime()); | |||||
| mrq.setEndTime(time.getEndTime()); | |||||
| BigDecimal totalNumber = wxEnergyMeterReadingMapper.findNumberSum(mrq); | |||||
| if (null == totalNumber || totalNumber.compareTo(new BigDecimal(0)) <= 0 ) { | |||||
| return "0"; | |||||
| } | |||||
| sb.append("表总度数"+totalNumber.toPlainString()+",单价:"+shopfee.getPrice()); | |||||
| return totalNumber.multiply(new BigDecimal(shopfee.getPrice())).setScale(2,BigDecimal.ROUND_HALF_UP).toPlainString(); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -80,7 +80,7 @@ public class WxRentContractHelper { | |||||
| priceArr[i] = new BigDecimal(priceStr).multiply(new BigDecimal(rentArea)).setScale(Constant.default_long_decimal_size, RoundingMode.HALF_UP).toPlainString(); | priceArr[i] = new BigDecimal(priceStr).multiply(new BigDecimal(rentArea)).setScale(Constant.default_long_decimal_size, RoundingMode.HALF_UP).toPlainString(); | ||||
| } | } | ||||
| List<String[]> priceList = computeRatioByShop(Constant.default_long_decimal_size,rentInfoArray,wxRentContract.getBussinessManagementFeeRatioWay(),priceArr,feeRatioField); | |||||
| List<String[]> priceList = computeRatioByShop(Constant.default_long_decimal_size,rentInfoArray,wxRentContract.getBussinessManagementFeeRatioWay(),priceArr,feeRatioField,wxRentContract.getRentArea()); | |||||
| if (null != priceList) { | if (null != priceList) { | ||||
| return calcuteRatioByPart(priceList, feeRatioField); | return calcuteRatioByPart(priceList, feeRatioField); | ||||
| }else { | }else { | ||||
| @@ -95,7 +95,7 @@ public class WxRentContractHelper { | |||||
| rentArea = "0"; | rentArea = "0"; | ||||
| } | } | ||||
| String ratioFirstYearPrice = new BigDecimal(fee).multiply(new BigDecimal(rentArea)).setScale(Constant.default_long_decimal_size, RoundingMode.HALF_UP).toPlainString(); | String ratioFirstYearPrice = new BigDecimal(fee).multiply(new BigDecimal(rentArea)).setScale(Constant.default_long_decimal_size, RoundingMode.HALF_UP).toPlainString(); | ||||
| return calcuteRatioByJoin(Constant.default_long_decimal_size,ratioWay, ratio, ratioFirstYearPrice); | |||||
| return calcuteRatioByJoin(Constant.default_long_decimal_size,ratioWay, ratio, ratioFirstYearPrice,wxRentContract.getRentArea()); | |||||
| } | } | ||||
| } | } | ||||
| return null; | return null; | ||||
| @@ -125,6 +125,10 @@ public class WxRentContractHelper { | |||||
| for (int i = 1; i < size; i++) { | for (int i = 1; i < size; i++) { | ||||
| priceArr[i] = new BigDecimal(integers.get(i)).divide(new BigDecimal(100)).setScale(Constant.default_long_decimal_size, RoundingMode.HALF_UP).toPlainString(); | priceArr[i] = new BigDecimal(integers.get(i)).divide(new BigDecimal(100)).setScale(Constant.default_long_decimal_size, RoundingMode.HALF_UP).toPlainString(); | ||||
| } | } | ||||
| }else if (wxPropertyContract.getAdjustRatioWay().equals(EnumRentContractAdjustRatioWay.FIX_UNIT_PRICE.getCode())){ | |||||
| for (int i = 1; i < size; i++) { | |||||
| priceArr[i] = new BigDecimal(integers.get(i)).multiply(new BigDecimal(wxPropertyContract.getRentArea())).divide(new BigDecimal(100)).setScale(Constant.default_long_decimal_size, RoundingMode.HALF_UP).toPlainString(); | |||||
| } | |||||
| }else { | }else { | ||||
| for (int i = 1; i < size; i++) { | for (int i = 1; i < size; i++) { | ||||
| priceArr[i] = wxPropertyContract.getPrice(); | priceArr[i] = wxPropertyContract.getPrice(); | ||||
| @@ -175,7 +179,7 @@ public class WxRentContractHelper { | |||||
| } | } | ||||
| priceArr[i] = priceStr; | priceArr[i] = priceStr; | ||||
| } | } | ||||
| return computeRatioByShop(Constant.default_long_decimal_size,rentInfoArray,wxRentContract.getAdjustRatioWay(),priceArr,"adjustRatio"); | |||||
| return computeRatioByShop(Constant.default_long_decimal_size,rentInfoArray,wxRentContract.getAdjustRatioWay(),priceArr,"adjustRatio",wxRentContract.getRentArea()); | |||||
| } | } | ||||
| //计算每年租金基数值(合铺录入),具体计算在合同创建时,会根据合同的PriceUnit来根据此基数来计算 | //计算每年租金基数值(合铺录入),具体计算在合同创建时,会根据合同的PriceUnit来根据此基数来计算 | ||||
| @@ -259,6 +263,16 @@ public class WxRentContractHelper { | |||||
| } | } | ||||
| } | } | ||||
| }else if (adjustRatioWay.equals(EnumRentContractAdjustRatioWay.FIX_UNIT_PRICE.getCode())){ | |||||
| for (int i = 1; i < size; i++) { | |||||
| String _update = ""; | |||||
| if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { | |||||
| _update = new BigDecimal(revenueYears.get(i)).multiply(new BigDecimal(wxRentContract.getRentArea())).toPlainString(); | |||||
| }else { | |||||
| _update = new BigDecimal(integers.get(i)).multiply(new BigDecimal(wxRentContract.getRentArea())).toPlainString(); | |||||
| } | |||||
| priceArrs[i] = new BigDecimal(_update).setScale(Constant.default_long_decimal_size, RoundingMode.HALF_UP).toPlainString(); | |||||
| } | |||||
| } | } | ||||
| if (isCalcuted) { | if (isCalcuted) { | ||||
| //租金和联营取高 | //租金和联营取高 | ||||
| @@ -321,13 +335,17 @@ public class WxRentContractHelper { | |||||
| } | } | ||||
| revenuePriceArrs[i] = _p.toPlainString(); | revenuePriceArrs[i] = _p.toPlainString(); | ||||
| } | } | ||||
| }else if (wxRentContract.getRevenueRatioWay().equals(EnumRentContractAdjustRatioWay.FIX_UNIT_PRICE.getCode())){ | |||||
| for (int i = 1; i < size; i++) { | |||||
| revenuePriceArrs[i] = new BigDecimal(revenueYears.get(i)).multiply(new BigDecimal(wxRentContract.getRevenue())).toPlainString(); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| return revenuePriceArrs; | return revenuePriceArrs; | ||||
| } | } | ||||
| //合铺计算某项计费 | //合铺计算某项计费 | ||||
| private static String[] calcuteRatioByJoin(Integer decimalSize,Integer ratioWay,String ratio,String ratioFirstYearPrice) { | |||||
| private static String[] calcuteRatioByJoin(Integer decimalSize,Integer ratioWay,String ratio,String ratioFirstYearPrice,String rentArea) { | |||||
| List<Integer> integers = JSONArray.parseArray(ratio, Integer.class); | List<Integer> integers = JSONArray.parseArray(ratio, Integer.class); | ||||
| integers.add(0, 0); | integers.add(0, 0); | ||||
| int size = integers.size(); | int size = integers.size(); | ||||
| @@ -355,6 +373,10 @@ public class WxRentContractHelper { | |||||
| BigDecimal _p = priceD.multiply(new BigDecimal(integers.get(i))).divide(new BigDecimal(100)); | BigDecimal _p = priceD.multiply(new BigDecimal(integers.get(i))).divide(new BigDecimal(100)); | ||||
| priceArrs[i] = _p.setScale(decimalSize, RoundingMode.HALF_UP).toPlainString(); | priceArrs[i] = _p.setScale(decimalSize, RoundingMode.HALF_UP).toPlainString(); | ||||
| } | } | ||||
| }else if (ratioWay.equals(EnumRentContractAdjustRatioWay.FIX_RATIO.getCode())){ | |||||
| for (int i = 1; i < size; i++) { | |||||
| priceArrs[i] = new BigDecimal(integers.get(i)).multiply(new BigDecimal(rentArea)).setScale(decimalSize, RoundingMode.HALF_UP).toPlainString(); | |||||
| } | |||||
| } | } | ||||
| return priceArrs; | return priceArrs; | ||||
| } | } | ||||
| @@ -376,20 +398,20 @@ public class WxRentContractHelper { | |||||
| } | } | ||||
| //计算某项金额,每年-每个店铺金额 | //计算某项金额,每年-每个店铺金额 | ||||
| public static List<String[]> computeRatioByShop(Integer decimalSize,JSONArray rentInfoArray, Integer ratioWayType,String[] firstYearPrces,String ratioKey) { | |||||
| public static List<String[]> computeRatioByShop(Integer decimalSize,JSONArray rentInfoArray, Integer ratioWayType,String[] firstYearPrces,String ratioKey,String rentArea) { | |||||
| List<String[]> priceList = new ArrayList<>(); | List<String[]> priceList = new ArrayList<>(); | ||||
| priceList.add(firstYearPrces); //每个店铺每月租金 | priceList.add(firstYearPrces); //每个店铺每月租金 | ||||
| //大于一年 | //大于一年 | ||||
| JSONObject rentInfoObject = rentInfoArray.getJSONObject(0); | JSONObject rentInfoObject = rentInfoArray.getJSONObject(0); | ||||
| JSONArray adjustRatio = rentInfoObject.getJSONArray(ratioKey);//[100,200] | JSONArray adjustRatio = rentInfoObject.getJSONArray(ratioKey);//[100,200] | ||||
| if (null != adjustRatio) { | if (null != adjustRatio) { | ||||
| return computeRatioFromRentInfo(decimalSize,priceList, rentInfoArray, ratioWayType, adjustRatio.size(), ratioKey); | |||||
| return computeRatioFromRentInfo(decimalSize,priceList, rentInfoArray, ratioWayType, adjustRatio.size(), ratioKey,rentArea); | |||||
| } | } | ||||
| return null; | return null; | ||||
| } | } | ||||
| //计算年调整后的某项计费 | //计算年调整后的某项计费 | ||||
| private static List<String[]> computeRatioFromRentInfo(Integer decimalSize,List<String[]> priceList,JSONArray rentInfoArray, Integer ratioWayType,int ratioYears,String ratioKey ) { | |||||
| private static List<String[]> computeRatioFromRentInfo(Integer decimalSize,List<String[]> priceList,JSONArray rentInfoArray, Integer ratioWayType,int ratioYears,String ratioKey,String rentArea ) { | |||||
| //循环多年的调整比例,如3年。[10,20,30] | //循环多年的调整比例,如3年。[10,20,30] | ||||
| for (int i = 0; i < ratioYears; i++) { | for (int i = 0; i < ratioYears; i++) { | ||||
| String[] priceArrs = new String[rentInfoArray.size()]; | String[] priceArrs = new String[rentInfoArray.size()]; | ||||
| @@ -410,6 +432,9 @@ public class WxRentContractHelper { | |||||
| }else if (ratioWayType.equals(EnumRentContractAdjustRatioWay.FIX_RATIO.getCode())) { | }else if (ratioWayType.equals(EnumRentContractAdjustRatioWay.FIX_RATIO.getCode())) { | ||||
| BigDecimal price = new BigDecimal(priceList.get(i)[j]).multiply(new BigDecimal(adjustRatio.getString(i)).divide(new BigDecimal(100))); | BigDecimal price = new BigDecimal(priceList.get(i)[j]).multiply(new BigDecimal(adjustRatio.getString(i)).divide(new BigDecimal(100))); | ||||
| priceArrs[j] = price.setScale(decimalSize, RoundingMode.HALF_UP).toPlainString(); | priceArrs[j] = price.setScale(decimalSize, RoundingMode.HALF_UP).toPlainString(); | ||||
| }else if (ratioWayType.equals(EnumRentContractAdjustRatioWay.FIX_UNIT_PRICE.getCode())) { | |||||
| BigDecimal price = new BigDecimal(adjustRatio.getString(i)).multiply(new BigDecimal(100)); | |||||
| priceArrs[j] = price.multiply(new BigDecimal(rentArea)).setScale(decimalSize, RoundingMode.HALF_UP).toPlainString(); | |||||
| } | } | ||||
| } | } | ||||
| priceList.add(priceArrs); | priceList.add(priceArrs); | ||||
| @@ -562,7 +562,7 @@ public class WxAllBillServiceImpl extends WxBillBaseService implements WxAllBill | |||||
| for (int i = 0 ; i < brList.size() ; i ++ ) { | for (int i = 0 ; i < brList.size() ; i ++ ) { | ||||
| WxAllBill brent = brList.get(i); | WxAllBill brent = brList.get(i); | ||||
| WxBillAction action = new WxBillAction(); | WxBillAction action = new WxBillAction(); | ||||
| boolean isUpdate = wxBillAllHelper.billEndCalcute(rentContract.getDecimalSize(),rentContract.getEndContractTime(), brent, action, false); | |||||
| boolean isUpdate = wxBillAllHelper.billEndCalcute(rentContract.getDecimalSize(),rentContract.getEndContractTime(), brent, action); | |||||
| if (isUpdate) { | if (isUpdate) { | ||||
| realRentList.add(brent); | realRentList.add(brent); | ||||
| actionList.add(action); | actionList.add(action); | ||||
| @@ -603,7 +603,7 @@ public class WxAllBillServiceImpl extends WxBillBaseService implements WxAllBill | |||||
| for (int i = 0 ; i < brList.size() ; i ++ ) { | for (int i = 0 ; i < brList.size() ; i ++ ) { | ||||
| WxAllBill brent = brList.get(i); | WxAllBill brent = brList.get(i); | ||||
| WxBillAction action = new WxBillAction(); | WxBillAction action = new WxBillAction(); | ||||
| boolean isUpdate = wxBillAllHelper.billEndCalcute(propertyContract.getDecimalSize() ,propertyContract.getEndContractTime(), brent, action, false); | |||||
| boolean isUpdate = wxBillAllHelper.billEndCalcute(propertyContract.getDecimalSize() ,propertyContract.getEndContractTime(), brent, action); | |||||
| if (isUpdate) { | if (isUpdate) { | ||||
| realRentList.add(brent); | realRentList.add(brent); | ||||
| actionList.add(action); | actionList.add(action); | ||||
| @@ -642,7 +642,7 @@ public class WxAllBillServiceImpl extends WxBillBaseService implements WxAllBill | |||||
| for (int i = 0 ; i < brList.size() ; i ++ ) { | for (int i = 0 ; i < brList.size() ; i ++ ) { | ||||
| WxAllBill brent = brList.get(i); | WxAllBill brent = brList.get(i); | ||||
| WxBillAction action = new WxBillAction(); | WxBillAction action = new WxBillAction(); | ||||
| boolean isUpdate = wxBillAllHelper.billEndCalcute(2,current, brent, action, false); | |||||
| boolean isUpdate = wxBillAllHelper.billEndCalcute(2,current, brent, action); | |||||
| if (isUpdate) { | if (isUpdate) { | ||||
| realRentList.add(brent); | realRentList.add(brent); | ||||
| actionList.add(action); | actionList.add(action); | ||||
| @@ -802,7 +802,10 @@ public class WxAllBillServiceImpl extends WxBillBaseService implements WxAllBill | |||||
| @Override | @Override | ||||
| public void exportBill(HttpServletRequest request, HttpServletResponse response, WxAllBill wxBillRent) { | public void exportBill(HttpServletRequest request, HttpServletResponse response, WxAllBill wxBillRent) { | ||||
| String billName = wxBillRent.getRentShopType().equals(EnumRentShopType.SHOP.getCode()) ? "商铺租金账单" : "多经点位租金账单"; | |||||
| String billName = "账单"; | |||||
| if (null != wxBillRent.getRentShopType()) { | |||||
| billName = wxBillRent.getRentShopType().equals(EnumRentShopType.SHOP.getCode()) ? "商铺租金账单" : "多经点位租金账单"; | |||||
| } | |||||
| PageInfo<WxAllBill> billRentList = listAsPage(wxBillRent,1,10000); | PageInfo<WxAllBill> billRentList = listAsPage(wxBillRent,1,10000); | ||||
| List<WxAllBill> datalist = new ArrayList<WxAllBill>(); | List<WxAllBill> datalist = new ArrayList<WxAllBill>(); | ||||
| if (null != billRentList && null != billRentList.getList()) { | if (null != billRentList && null != billRentList.getList()) { | ||||
| @@ -13,6 +13,7 @@ import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.dto.FloorBuildingIdDTO; | import com.iformall.domain.dto.FloorBuildingIdDTO; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.domain.vo.WxMerchantBillVo; | |||||
| import com.iformall.enums.EnumBillAllType; | import com.iformall.enums.EnumBillAllType; | ||||
| import com.iformall.enums.EnumEnergyMeterPhysicsType; | import com.iformall.enums.EnumEnergyMeterPhysicsType; | ||||
| import com.iformall.enums.EnumEnergyMeterShopFloorType; | import com.iformall.enums.EnumEnergyMeterShopFloorType; | ||||
| @@ -74,6 +75,8 @@ public class WxEnergyServiceImpl implements WxEnergyService { | |||||
| WxEnergyReadingCalcuteMapper wxEnergyReadingCalcuteMapper; | WxEnergyReadingCalcuteMapper wxEnergyReadingCalcuteMapper; | ||||
| @Autowired | @Autowired | ||||
| WxEnergyReadingCalcuteResultMapper wxEnergyReadingCalcuteResultMapper; | WxEnergyReadingCalcuteResultMapper wxEnergyReadingCalcuteResultMapper; | ||||
| @Autowired | |||||
| WxEnergyHelper wxEnergyHelper; | |||||
| @Lazy | @Lazy | ||||
| @Autowired | @Autowired | ||||
| @@ -231,8 +234,30 @@ public class WxEnergyServiceImpl implements WxEnergyService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void deleteChildMeterAlias(WxEnergyMeterChild record) { | |||||
| wxEnergyMeterChildMapper.deleteByCondition(record); | |||||
| public void deleteChildMeterAlias(WxEnergyMeter record) { | |||||
| if (record.getTreeParentType().equals("building")) { | |||||
| WxEnergyMeterShopFloor sf = new WxEnergyMeterShopFloor(); | |||||
| sf.updateTenantInfo(record); | |||||
| sf.setType(EnumEnergyMeterShopFloorType.BUILDING.getCode()); | |||||
| sf.setAliseId(record.getTreeParentId()); | |||||
| sf.setMeterId(record.getId()); | |||||
| wxEnergyMeterShopFloorMapper.deleteByConditon(sf); | |||||
| }if (record.getTreeParentType().equals("floor")) { | |||||
| WxEnergyMeterShopFloor sf = new WxEnergyMeterShopFloor(); | |||||
| sf.updateTenantInfo(record); | |||||
| sf.setType(EnumEnergyMeterShopFloorType.FLOOR.getCode()); | |||||
| sf.setAliseId(record.getTreeParentId()); | |||||
| sf.setMeterId(record.getId()); | |||||
| wxEnergyMeterShopFloorMapper.deleteByConditon(sf); | |||||
| }if (record.getTreeParentType().equals("meter")) { | |||||
| WxEnergyMeterChild sf = new WxEnergyMeterChild(); | |||||
| sf.updateTenantInfo(record); | |||||
| sf.setParentMeterId(record.getTreeParentId()); | |||||
| sf.setChildMeterId(record.getId()); | |||||
| wxEnergyMeterChildMapper.deleteByCondition(sf); | |||||
| } | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -507,20 +532,20 @@ public class WxEnergyServiceImpl implements WxEnergyService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public List<Map<String,String>> getFeesCalcuteComponentList(WxEnergyFeesShop record) { | |||||
| List<Map<String,String>> retList = WxEnergyHelper.generateCalcuteComponent(); | |||||
| public List<Map<String,String>> getFeesShopComponentList(WxEnergyFeesShop record) { | |||||
| List<Map<String,String>> retList = wxEnergyHelper.generateCalcuteComponent(record); | |||||
| //公共表,公摊总表,当前楼栋面积,当前楼层面积,总面积,店铺公摊系数 | //公共表,公摊总表,当前楼栋面积,当前楼层面积,总面积,店铺公摊系数 | ||||
| WxEnergyMeter mq = new WxEnergyMeter(); | WxEnergyMeter mq = new WxEnergyMeter(); | ||||
| mq.updateTenantInfo(record); | mq.updateTenantInfo(record); | ||||
| List<Integer> ptylist = new ArrayList<Integer>(); | List<Integer> ptylist = new ArrayList<Integer>(); | ||||
| ptylist.add(EnumEnergyMeterPhysicsType.PUBLIC.getCode()); | |||||
| //ptylist.add(EnumEnergyMeterPhysicsType.PUBLIC.getCode()); | |||||
| ptylist.add(EnumEnergyMeterPhysicsType.SUMMARY.getCode()); | ptylist.add(EnumEnergyMeterPhysicsType.SUMMARY.getCode()); | ||||
| mq.setPhysicsTypeList(ptylist); | mq.setPhysicsTypeList(ptylist); | ||||
| PageInfo<WxEnergyMeter> page = this.meterListAsPage(mq,1,1000); | PageInfo<WxEnergyMeter> page = this.meterListAsPage(mq,1,1000); | ||||
| if (null != page && null != page.getList() ) { | if (null != page && null != page.getList() ) { | ||||
| for (int i = 0 ; i < page.getList().size() ; i ++) { | for (int i = 0 ; i < page.getList().size() ; i ++) { | ||||
| WxEnergyMeter meter = page.getList().get(i); | WxEnergyMeter meter = page.getList().get(i); | ||||
| retList.add(WxEnergyHelper.generateMeterComponent(meter)); | |||||
| retList.add(wxEnergyHelper.generateMeterComponent(meter)); | |||||
| } | } | ||||
| } | } | ||||
| return retList; | return retList; | ||||
| @@ -534,21 +559,29 @@ public class WxEnergyServiceImpl implements WxEnergyService { | |||||
| WxEnergyFees fees = this.getFeesById(record.getFeesId(),record.getTenantId()); | WxEnergyFees fees = this.getFeesById(record.getFeesId(),record.getTenantId()); | ||||
| for (int i = 0 ; i < record.getShopIds().size(); i ++) { | for (int i = 0 ; i < record.getShopIds().size(); i ++) { | ||||
| Long shopId = record.getShopIds().get(i); | Long shopId = record.getShopIds().get(i); | ||||
| for (int j = 0 ; j < record.getCalcuteIds().size(); j ++) { | |||||
| Long calcuteId = record.getCalcuteIds().get(j); | |||||
| WxEnergyFeesShop msf = new WxEnergyFeesShop(); | |||||
| msf.updateTenantInfo(record); | |||||
| msf.setId(idWorker.nextId()); | |||||
| msf.setCreateTime(date); | |||||
| msf.setUpdateTime(date); | |||||
| msf.setShopId(shopId); | |||||
| msf.setIsPublic(fees.getIsPublic()); | |||||
| msf.setFeesId(fees.getId()); | |||||
| msf.setPrice(fees.getPrice()); | |||||
| msf.setFormula(record.getFormula()); | |||||
| msf.setFormulaContent(record.getFormulaContent()); | |||||
| wxEnergyFeesShopMapper.insert(msf); | |||||
| } | |||||
| WxEnergyFeesShop msf = new WxEnergyFeesShop(); | |||||
| msf.updateTenantInfo(record); | |||||
| msf.setId(idWorker.nextId()); | |||||
| msf.setCreateTime(date); | |||||
| msf.setUpdateTime(date); | |||||
| msf.setShopId(shopId); | |||||
| msf.setIsPublic(fees.getIsPublic()); | |||||
| msf.setFeesId(fees.getId()); | |||||
| msf.setPrice(fees.getPrice()); | |||||
| if (fees.getIsPublic() == EnumYesOrNo.YES.getCode()) { | |||||
| if (null == record.getFormulaList() || record.getFormulaList().size() <= 0 || StringUtils.isBlank(record.getFormula())) { | |||||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请设置公式"); | |||||
| } | |||||
| } | |||||
| if (null != record.getFormulaContentList() && record.getFormulaContentList().size() > 0 ) { | |||||
| msf.setFormulaContent(JSON.toJSONString(record.getFormulaContentList())); | |||||
| } | |||||
| if (null != record.getFormulaList() && record.getFormulaList().size() > 0 ) { | |||||
| msf.setFormulaListStr(JSON.toJSONString(record.getFormulaList())); | |||||
| } | |||||
| msf.setFormula(record.getFormula()); | |||||
| wxEnergyHelper.testCalcute(record.getFormula()); | |||||
| wxEnergyFeesShopMapper.insert(msf); | |||||
| } | } | ||||
| } | } | ||||
| @@ -558,23 +591,34 @@ public class WxEnergyServiceImpl implements WxEnergyService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public WxEnergyFeesShop getShopFeesCalcute(Long id,String tenantId) { | |||||
| return wxEnergyFeesShopMapper.selectById(id,tenantId); | |||||
| public WxEnergyFeesShop getFeesShop(Long id,String tenantId) { | |||||
| WxEnergyFeesShop fs = wxEnergyFeesShopMapper.selectById(id,tenantId); | |||||
| if (StringUtils.isNotBlank(fs.getFormulaContent())) { | |||||
| fs.setFormulaContentList(JSON.parseArray(fs.getFormulaContent(), String.class)); | |||||
| } | |||||
| if (StringUtils.isNotBlank(fs.getFormulaListStr())) { | |||||
| fs.setFormulaList(JSON.parseArray(fs.getFormulaListStr(), String.class)); | |||||
| } | |||||
| return fs; | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void saveOrUpdateShopFeesCalcute(WxEnergyFeesShop record) { | |||||
| public void updateFeesShop(WxEnergyFeesShop record) { | |||||
| Date date = new Date(); | Date date = new Date(); | ||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| if (record.getId() == null) { | |||||
| record.setId(idWorker.nextId()); | |||||
| record.setCreateTime(date); | |||||
| record.setUpdateTime(date); | |||||
| wxEnergyFeesShopMapper.insert(record); | |||||
| }else { | |||||
| record.setUpdateTime(date); | |||||
| wxEnergyFeesShopMapper.updateById(record); | |||||
| } | |||||
| record.setUpdateTime(date); | |||||
| if (record.getIsPublic() == EnumYesOrNo.YES.getCode()) { | |||||
| if (null == record.getFormulaList() || record.getFormulaList().size() <= 0 || StringUtils.isBlank(record.getFormula())) { | |||||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请设置公式"); | |||||
| } | |||||
| } | |||||
| if (null != record.getFormulaContentList() && record.getFormulaContentList().size() > 0 ) { | |||||
| record.setFormulaContent(JSON.toJSONString(record.getFormulaContentList())); | |||||
| } | |||||
| if (null != record.getFormulaList() && record.getFormulaList().size() > 0 ) { | |||||
| record.setFormulaListStr(JSON.toJSONString(record.getFormulaList())); | |||||
| } | |||||
| wxEnergyHelper.testCalcute(record.getFormula()); | |||||
| wxEnergyFeesShopMapper.updateById(record); | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -835,7 +879,13 @@ public class WxEnergyServiceImpl implements WxEnergyService { | |||||
| } | } | ||||
| return page; | return page; | ||||
| } | } | ||||
| @Override | |||||
| public List<WxEnergyReadingCalcute> findCalcuteList(WxEnergyReadingCalcute record) { | |||||
| return wxEnergyReadingCalcuteMapper.findList(record); | |||||
| } | |||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||||
| @Override | @Override | ||||
| public void saveOrUpdateReadingCalcute(WxEnergyReadingCalcute record, MallUserInfo userInfo) { | public void saveOrUpdateReadingCalcute(WxEnergyReadingCalcute record, MallUserInfo userInfo) { | ||||
| Date date = new Date(); | Date date = new Date(); | ||||
| @@ -856,12 +906,7 @@ public class WxEnergyServiceImpl implements WxEnergyService { | |||||
| try { | try { | ||||
| wxEnergyReadingCalcuteMapper.insert(record); | wxEnergyReadingCalcuteMapper.insert(record); | ||||
| WxEnergyFees fees = this.getFeesById(record.getFeesId(),record.getTenantId()); | WxEnergyFees fees = this.getFeesById(record.getFeesId(),record.getTenantId()); | ||||
| if (fees.getIsPublic() == EnumYesOrNo.YES.getCode()) { | |||||
| generateCalcuteResult(fees, record, record.getShopIds(), EnumEnergyMeterPhysicsType.PUBLIC); | |||||
| }else { | |||||
| generateCalcuteResult(fees, record, record.getShopIds(), EnumEnergyMeterPhysicsType.USER); | |||||
| } | |||||
| generateCalcuteResult(fees, record, record.getShopIds()); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("保存租赁账单失败,e:" + e.getMessage()); | logger.error("保存租赁账单失败,e:" + e.getMessage()); | ||||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | ||||
| @@ -874,11 +919,72 @@ public class WxEnergyServiceImpl implements WxEnergyService { | |||||
| } | } | ||||
| } | } | ||||
| public void generateCalcuteResult(WxEnergyFees fees,WxEnergyReadingCalcute record,List<Long> shopIds,EnumEnergyMeterPhysicsType type) { | |||||
| public void generateCalcuteResult(WxEnergyFees fees,WxEnergyReadingCalcute record,List<Long> shopIds) { | |||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| WxShop shq = new WxShop(); | |||||
| shq.updateTenantInfo(record); | |||||
| shq.setIds(shopIds); | |||||
| Map<Long, WxShop> shopMap = wxShopService.findShopMap(shq); | |||||
| // 总共面积 | |||||
| BigDecimal totalArea = new BigDecimal(0); | |||||
| // 楼栋的面积 | |||||
| Map<Long,BigDecimal> buildingAreaMap = null; | |||||
| //楼层 | |||||
| Map<Long, BigDecimal> floorAreaMap = null; | |||||
| WxMallFloor fq = new WxMallFloor(); | |||||
| fq.updateTenantInfo(record); | |||||
| List<WxMallFloor> floorList = wxMallFloorService.getBudingFloorList(fq, null); | |||||
| if (null != floorList && floorList.size() > 0 ) { | |||||
| floorAreaMap = new HashMap<Long, BigDecimal>(); | |||||
| buildingAreaMap = new HashMap<Long, BigDecimal>(); | |||||
| for (int i = 0 ; i < floorList.size() ; i ++) { | |||||
| WxMallFloor floor = floorList.get(i); | |||||
| if (null != floor.getOperatingArea()) { | |||||
| floorAreaMap.put(floor.getId(), floor.getOperatingArea()); | |||||
| BigDecimal bud = buildingAreaMap.get(floor.getBuildingId()); | |||||
| if (null == bud) { | |||||
| bud = new BigDecimal(0); | |||||
| } | |||||
| bud = bud.add(floor.getOperatingArea()); | |||||
| buildingAreaMap.put(floor.getBuildingId(), bud); | |||||
| totalArea = totalArea.add(floor.getOperatingArea()); | |||||
| } | |||||
| } | |||||
| } | |||||
| //用户表 | |||||
| WxEnergyMeter mq = new WxEnergyMeter(); | |||||
| mq.updateTenantInfo(record); | |||||
| mq.setType(fees.getType()); | |||||
| mq.setPhysicsType(EnumEnergyMeterPhysicsType.USER.getCode()); | |||||
| List<Long> meterList = wxEnergyMeterMapper.findIdList(mq); | |||||
| //查询公摊表 | |||||
| Map<Long,List<Long>> summaryMeterMap = null; | |||||
| if (fees.getIsPublic() == EnumYesOrNo.YES.getCode()) { | |||||
| WxEnergyMeter sumq = new WxEnergyMeter(); | |||||
| sumq.updateTenantInfo(record); | |||||
| sumq.setType(fees.getType()); | |||||
| sumq.setPhysicsType(EnumEnergyMeterPhysicsType.SUMMARY.getCode()); | |||||
| List<WxEnergyMeter> sumeterList = wxEnergyMeterMapper.findList(mq); | |||||
| if (null != sumeterList && sumeterList.size() > 0 ) { | |||||
| summaryMeterMap = new HashMap<Long,List<Long>>(); | |||||
| for (int i = 0 ; i < meterList.size(); i ++) { | |||||
| WxEnergyMeter summaryMeter = sumeterList.get(i); | |||||
| //查询总表下的子表 | |||||
| WxEnergyMeterChild mcq = new WxEnergyMeterChild(); | |||||
| mcq.updateTenantInfo(record); | |||||
| mcq.setParentMeterId(summaryMeter.getId()); | |||||
| List<Long> childMeterIds = wxEnergyMeterChildMapper.findChildMeterIdList(mcq); | |||||
| if (null != childMeterIds && childMeterIds.size() > 0 ) { | |||||
| summaryMeterMap.put(summaryMeter.getId(), childMeterIds); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| List<WxEnergyReadingCalcuteResult> resultList = new ArrayList<WxEnergyReadingCalcuteResult>(); | List<WxEnergyReadingCalcuteResult> resultList = new ArrayList<WxEnergyReadingCalcuteResult>(); | ||||
| for (int i = 0 ; i < shopIds.size(); i ++) { | for (int i = 0 ; i < shopIds.size(); i ++) { | ||||
| Long shopId= shopIds.get(i); | Long shopId= shopIds.get(i); | ||||
| WxShop shop = shopMap.get(shopId); | |||||
| //根据店铺,所属年月去查询时间区间.根据店铺,时间区间去查对应的抄表数据,根据表来计算总和 | //根据店铺,所属年月去查询时间区间.根据店铺,时间区间去查对应的抄表数据,根据表来计算总和 | ||||
| WxEnergyFeesTimeShop sq = new WxEnergyFeesTimeShop(); | WxEnergyFeesTimeShop sq = new WxEnergyFeesTimeShop(); | ||||
| sq.updateTenantInfo(record); | sq.updateTenantInfo(record); | ||||
| @@ -907,36 +1013,23 @@ public class WxEnergyServiceImpl implements WxEnergyService { | |||||
| return; | return; | ||||
| } | } | ||||
| //根据店铺去查询表 | |||||
| WxEnergyMeter mq = new WxEnergyMeter(); | |||||
| mq.updateTenantInfo(record); | |||||
| mq.setType(fees.getType()); | |||||
| mq.setPhysicsType(type.getCode()); | |||||
| List<WxEnergyMeter> meterList = wxEnergyMeterMapper.findList(mq); | |||||
| if (null == meterList || meterList.size() <= 0 ) { | |||||
| return; | |||||
| } | |||||
| //循环店铺科目, | //循环店铺科目, | ||||
| for (int j = 0 ; j < shopFeesList.size() ; j ++) { | for (int j = 0 ; j < shopFeesList.size() ; j ++) { | ||||
| WxEnergyFeesShop shopfee = shopFeesList.get(j); | WxEnergyFeesShop shopfee = shopFeesList.get(j); | ||||
| //查询每一个表的抄表数据,求和 | |||||
| for (int k = 0 ; k < meterList.size() ; k++) { | |||||
| WxEnergyReadingCalcuteResult cs = new WxEnergyReadingCalcuteResult(); | |||||
| cs.updateTenantInfo(record); | |||||
| cs.setId(idWorker.nextId()); | |||||
| cs.setCalcuteId(record.getId()); | |||||
| cs.setShopId(shopId); | |||||
| cs.setCreateTime(new Date()); | |||||
| cs.setUpdateTime(new Date()); | |||||
| cs.setFeesId(shopfee.getFeesId()); | |||||
| cs.setFeesShopId(shopfee.getId()); | |||||
| WxEnergyMeter meter = meterList.get(k); | |||||
| cs.setMeterId(meter.getId()); | |||||
| cs.setMoney(WxEnergyHelper.calcuteMoney(time, meter, shopfee)); | |||||
| cs.setPeriod(record.getPeriod()); | |||||
| resultList.add(cs); | |||||
| } | |||||
| WxEnergyReadingCalcuteResult cs = new WxEnergyReadingCalcuteResult(); | |||||
| cs.updateTenantInfo(record); | |||||
| cs.setId(idWorker.nextId()); | |||||
| cs.setCalcuteId(record.getId()); | |||||
| cs.setShopId(shopId); | |||||
| cs.setCreateTime(new Date()); | |||||
| cs.setUpdateTime(new Date()); | |||||
| cs.setFeesId(shopfee.getFeesId()); | |||||
| cs.setFeesShopId(shopfee.getId()); | |||||
| StringBuffer sb = new StringBuffer(); | |||||
| cs.setMoney(wxEnergyHelper.calcuteMoney(sb,totalArea,shop,time, fees, shopfee,meterList,summaryMeterMap,buildingAreaMap,floorAreaMap)); | |||||
| cs.setPeriod(record.getPeriod()); | |||||
| cs.setMoney(sb.toString()); | |||||
| resultList.add(cs); | |||||
| } | } | ||||
| } | } | ||||
| if (resultList.size() > 0 ) { | if (resultList.size() > 0 ) { | ||||
| @@ -954,7 +1047,6 @@ public class WxEnergyServiceImpl implements WxEnergyService { | |||||
| Map<Long, WxEnergyFees> fessMap = this.getFeesMap(fq); | Map<Long, WxEnergyFees> fessMap = this.getFeesMap(fq); | ||||
| Map<Long, String> floorMap = wxMallFloorService.getFloorMap(record); | Map<Long, String> floorMap = wxMallFloorService.getFloorMap(record); | ||||
| Map<Long, String> buildingMap = wxMallBuildingService.getBuildingMap(record); | Map<Long, String> buildingMap = wxMallBuildingService.getBuildingMap(record); | ||||
| List<Long> meterIdList = new ArrayList<Long>(); | |||||
| List<Long> shopIdList = new ArrayList<Long>(); | List<Long> shopIdList = new ArrayList<Long>(); | ||||
| for (int i = 0 ; i < page.getList().size(); i++) { | for (int i = 0 ; i < page.getList().size(); i++) { | ||||
| WxEnergyReadingCalcuteResult c = page.getList().get(i); | WxEnergyReadingCalcuteResult c = page.getList().get(i); | ||||
| @@ -964,19 +1056,8 @@ public class WxEnergyServiceImpl implements WxEnergyService { | |||||
| c.setFeesName(fees.getName()); | c.setFeesName(fees.getName()); | ||||
| } | } | ||||
| } | } | ||||
| if (null != c.getMeterId()) { | |||||
| meterIdList.add(c.getMeterId()); | |||||
| } | |||||
| shopIdList.add(c.getShopId()); | shopIdList.add(c.getShopId()); | ||||
| } | } | ||||
| Map<Long, WxEnergyMeter> meterMap = null; | |||||
| if (meterIdList.size() > 0 ) { | |||||
| WxEnergyMeter mq = new WxEnergyMeter(); | |||||
| mq.updateTenantInfo(record); | |||||
| mq.setIds(meterIdList); | |||||
| meterMap = this.getMeterMap(mq); | |||||
| } | |||||
| Map<Long, WxShop> shopMap = null; | Map<Long, WxShop> shopMap = null; | ||||
| if (shopIdList.size() > 0 ) { | if (shopIdList.size() > 0 ) { | ||||
| WxShop sq = new WxShop(); | WxShop sq = new WxShop(); | ||||
| @@ -986,12 +1067,6 @@ public class WxEnergyServiceImpl implements WxEnergyService { | |||||
| } | } | ||||
| for (int i = 0 ; i < page.getList().size(); i++) { | for (int i = 0 ; i < page.getList().size(); i++) { | ||||
| WxEnergyReadingCalcuteResult c = page.getList().get(i); | WxEnergyReadingCalcuteResult c = page.getList().get(i); | ||||
| if (null != meterMap && null != c.getMeterId()) { | |||||
| WxEnergyMeter m = meterMap.get(c.getMeterId()); | |||||
| if (null != m) { | |||||
| c.setMeterName(m.getName()); | |||||
| } | |||||
| } | |||||
| if (null != shopMap && null != c.getShopId()) { | if (null != shopMap && null != c.getShopId()) { | ||||
| WxShop s = shopMap.get(c.getShopId()); | WxShop s = shopMap.get(c.getShopId()); | ||||
| if (null != s) { | if (null != s) { | ||||
| @@ -1011,38 +1086,9 @@ public class WxEnergyServiceImpl implements WxEnergyService { | |||||
| @Override | @Override | ||||
| public void exportReadingCalcute(WxEnergyReadingCalcute record, HttpServletRequest request, HttpServletResponse response) { | |||||
| // WxEnergyFeesTime tq = new WxEnergyFeesTime(); | |||||
| // tq.updateTenantInfo(record); | |||||
| // tq.setId(record.getTimeId()); | |||||
| // WxEnergyFeesTime time = this.getFeesTimeById(tq); | |||||
| // if (null == time) { | |||||
| // return; | |||||
| // } | |||||
| // | |||||
| // WxEnergyFees fq = new WxEnergyFees(); | |||||
| // fq.updateTenantInfo(record); | |||||
| // fq.setId(record.getFeesId()); | |||||
| // WxEnergyFees fees = this.getFeesById(fq); | |||||
| // if (null == fees) { | |||||
| // return; | |||||
| // } | |||||
| // | |||||
| // Map<Long, String> buildingMap = wxMallBuildingService.getBuildingMap(record); | |||||
| // Map<Long, String> floorMap = wxMallFloorService.getFloorMap(record); | |||||
| // | |||||
| // List<Map<String,Object>> execlList = new ArrayList<Map<String,Object>>(); | |||||
| // WxEnergyMeterReading rq = new WxEnergyMeterReading(); | |||||
| // rq.updateTenantInfo(record); | |||||
| // //rq.setTimeId(tq.getId()); | |||||
| // PageInfo<WxEnergyMeterReading> page = this.readingListAsPage(rq, 1, 10000); | |||||
| // if (null != page && null != page.getList()) { | |||||
| // for (int i = 0 ; i < page.getList().size(); i++) { | |||||
| // WxEnergyMeterReading r = page.getList().get(i); | |||||
| // execlList.add(r.generateExcelData(buildingMap, floorMap, time, fees, record)); | |||||
| // } | |||||
| // } | |||||
| // excelService.exportExcel(WxEnergyMeterReading.generateExcelTitle(),execlList, "科目抄表_"+time.getName()+"_"+fees.getName()+".xlsx","sheet1", response); | |||||
| public void exportReadingCalcuteResult(WxEnergyReadingCalcuteResult record, HttpServletRequest request, HttpServletResponse response) { | |||||
| PageInfo<WxEnergyReadingCalcuteResult> page = readingCalcuteResultListAsPage(record, 1, 10000); | |||||
| excelService.exportExcel(page.getList(), null, "能源计算结果", WxEnergyReadingCalcuteResult.class, "能源计算结果.xlsx", response, false); | |||||
| } | } | ||||
| private File handlerImportFile(MultipartFile mFile,String fileNamePre) { | private File handlerImportFile(MultipartFile mFile,String fileNamePre) { | ||||
| @@ -1134,229 +1180,62 @@ public class WxEnergyServiceImpl implements WxEnergyService { | |||||
| } | } | ||||
| private Map<Long,String> getFloorBuildingMoney(WxEnergyMeterReading reading,boolean isFloor) { | |||||
| // List<Map> list = null; | |||||
| // if (isFloor) { | |||||
| // list = wxEnergyMeterReadingMapper.findFloorSumMoney(reading); | |||||
| // }else { | |||||
| // wxEnergyMeterReadingMapper.findBuildingSumMoney(reading); | |||||
| // } | |||||
| // | |||||
| // if (null != list && list.size() > 0 ) { | |||||
| // Map<Long, String> buildinMap = new HashMap<Long, String>(); | |||||
| // for (int i = 0 ; i < list.size() ; i++) { | |||||
| // Map bup = list.get(i); | |||||
| // BigDecimal are = (BigDecimal)bup.get("money"); | |||||
| // if (null != are) { | |||||
| // buildinMap.put((Long)bup.get("building_id"), are.toPlainString()); | |||||
| // }else { | |||||
| // buildinMap.put((Long)bup.get("building_id"), "0"); | |||||
| // } | |||||
| // | |||||
| // } | |||||
| // return buildinMap; | |||||
| // } | |||||
| return null; | |||||
| } | |||||
| @Override | @Override | ||||
| public Integer calcuteReading(WxEnergyReadingCalcute record, MallUserInfo user) { | |||||
| // //根据科目,区间,计算生成账单。 | |||||
| // WxEnergyMeterReading reading = new WxEnergyMeterReading(); | |||||
| // reading.updateTenantInfo(record); | |||||
| // reading.setTimeId(record.getTimeId()); | |||||
| // reading.setIsDel(EnumYesOrNo.NO.getCode()); | |||||
| // reading.setIsPublic(EnumYesOrNo.NO.getCode()); | |||||
| // | |||||
| // WxEnergyFees fq = new WxEnergyFees(); | |||||
| // fq.updateTenantInfo(record); | |||||
| // fq.setIsDel(EnumYesOrNo.NO.getCode()); | |||||
| // fq.setId(record.getFeesId()); | |||||
| // WxEnergyFees fees = this.getFeesById(fq); | |||||
| // if (null == fees) { | |||||
| // throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"科目未查询到。"); | |||||
| // } | |||||
| // | |||||
| // WxEnergyFeesTime tq = new WxEnergyFeesTime(); | |||||
| // tq.updateTenantInfo(record); | |||||
| // tq.setId(record.getTimeId()); | |||||
| // WxEnergyFeesTime time = this.getFeesTimeById(tq); | |||||
| // if (null == time) { | |||||
| // throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"区间未查询到。"); | |||||
| // } | |||||
| // | |||||
| // if (fees.getType().intValue() != time.getType().intValue()) { | |||||
| // throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"科目和区间的表类型不匹配。"); | |||||
| // } | |||||
| // | |||||
| // reading.setMeterType(time.getType()); | |||||
| // | |||||
| // //用户表列表 | |||||
| // List<WxEnergyMeterReading> readingList = wxEnergyMeterReadingMapper.findList(reading); | |||||
| // if (null != readingList && readingList.size() > 0 ) { | |||||
| // | |||||
| // WxShop sq = new WxShop(); | |||||
| // sq.updateTenantInfo(record); | |||||
| // Map<Long, WxMerchant> shopMerchantMap = wxMerchantService.getShopMerchantMap(sq); | |||||
| // Map<Long, WxShop> shopMap = wxShopService.findShopMap(sq); | |||||
| // | |||||
| // WxEnergyMeter mq = new WxEnergyMeter(); | |||||
| // mq.updateTenantInfo(record); | |||||
| // mq.setIsDel(EnumYesOrNo.NO.getCode()); | |||||
| // Map<Long, WxEnergyMeter> meterMap = this.getMeterMap(mq); | |||||
| // if (null == meterMap) { | |||||
| // throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"能源表未查询到。"); | |||||
| // } | |||||
| // | |||||
| // String publicTotalArea = "0"; | |||||
| // BigDecimal publicTotalMoney = new BigDecimal(0); | |||||
| // BigDecimal b0 = new BigDecimal(0); | |||||
| // Map<Long,String> buildingFloorMoney = null; | |||||
| // Map<Long,String> buildingFloorArea = null; | |||||
| // if (fees.getPublicCalcute().intValue() == EnumEnergyPublicCalcuteRule.ALL.getCode().intValue()) { | |||||
| // //全部就查询所有公共表的费用 | |||||
| // reading.setIsPublic(EnumYesOrNo.YES.getCode()); | |||||
| // String publicMoney = wxEnergyMeterReadingMapper.findAllSumMoney(reading); | |||||
| // if (StringUtils.isNotBlank(publicMoney)) { | |||||
| // publicTotalMoney = new BigDecimal(publicMoney); | |||||
| // } | |||||
| // //公摊总面积 | |||||
| // WxMallFloor mf = new WxMallFloor(); | |||||
| // mf.updateTenantInfo(record); | |||||
| // publicTotalArea = wxMallFloorService.getAllPublicAreaSum(mf); | |||||
| // if (StringUtils.isBlank(publicTotalArea)) { | |||||
| // throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"楼层可用面积未配置。"); | |||||
| // } | |||||
| // BigDecimal areaDecimal = new BigDecimal(publicTotalArea); | |||||
| // if (areaDecimal.compareTo(new BigDecimal(0)) <= 0 ) { | |||||
| // throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"楼层可用面积未配置。"); | |||||
| // } | |||||
| // }else if (fees.getPublicCalcute().intValue() == EnumEnergyPublicCalcuteRule.BUILDING.getCode().intValue()) { | |||||
| // //如果是按楼栋计算,则要把每个楼栋的金额都要算出来 | |||||
| // reading.setIsPublic(EnumYesOrNo.YES.getCode()); | |||||
| // buildingFloorMoney = getFloorBuildingMoney(reading,false); | |||||
| // //各楼座总面积 | |||||
| // WxMallFloor mf = new WxMallFloor(); | |||||
| // mf.updateTenantInfo(record); | |||||
| // buildingFloorArea = wxMallFloorService.getBuildingPublicAreaSum(mf); | |||||
| // if (null == buildingFloorArea) { | |||||
| // throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"楼层可用面积未配置。"); | |||||
| // } | |||||
| // }else if (fees.getPublicCalcute().intValue() == EnumEnergyPublicCalcuteRule.FLOOR.getCode().intValue()) { | |||||
| // //查询各楼层的费用 | |||||
| // reading.setIsPublic(EnumYesOrNo.YES.getCode()); | |||||
| // buildingFloorMoney = getFloorBuildingMoney(reading,true); | |||||
| // //各楼层面积 | |||||
| // //各楼座总面积 | |||||
| // WxMallFloor mf = new WxMallFloor(); | |||||
| // mf.updateTenantInfo(record); | |||||
| // buildingFloorArea = wxMallFloorService.getFloorPublicAreaSum(mf); | |||||
| // if (null == buildingFloorArea) { | |||||
| // throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"楼层可用面积未配置。"); | |||||
| // } | |||||
| // } | |||||
| // | |||||
| // List<WxAllBill> billList = new ArrayList<WxAllBill>(); | |||||
| // for (int i = 0 ; i< readingList.size() ; i ++) { | |||||
| // WxEnergyMeterReading mr = readingList.get(i); | |||||
| // //用户表账单 | |||||
| // WxMerchant merchant = shopMerchantMap.get(mr.getShopId()); | |||||
| // if (null == merchant) { | |||||
| // throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"铺位["+mr.getShopNumber()+"]未找到出租商户"); | |||||
| // } | |||||
| // WxEnergyMeter meter = meterMap.get(mr.getMeterId()); | |||||
| // if (null == meter) { | |||||
| // throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"表["+mr.getMeterName()+"]不存在"); | |||||
| // } | |||||
| // WxShop shop = shopMap.get(mr.getShopId()); | |||||
| // WxAllBill userBill = mr.generateUserBill(record, merchant, user, meter); | |||||
| // userBill.setEnergyFeesId(fees.getId()); | |||||
| // if (null != userBill) { | |||||
| // billList.add(userBill); | |||||
| // } | |||||
| // /* | |||||
| // * 总表(分摊账单) | |||||
| // * 如果科目是根据总面积公摊,则根据总面积计算 | |||||
| // * 如果科目是根据楼栋公摊,则根据当前记录的楼栋面积计算 | |||||
| // * 如果科目是根据楼层公摊,则根据当前记录的楼层面积计算 | |||||
| // */ | |||||
| // WxAllBill publicBill = null; | |||||
| // if (fees.getPublicCalcute().intValue() == EnumEnergyPublicCalcuteRule.ALL.getCode().intValue()) { | |||||
| // if (publicTotalMoney.compareTo(b0) > 0 ) { | |||||
| // String needPay = publicTotalMoney.multiply(new BigDecimal(shop.getRentArea())).divide(new BigDecimal(publicTotalArea)).setScale(2,RoundingMode.HALF_UP).toPlainString(); | |||||
| // publicBill = mr.generatePublicBill(record, merchant, user, needPay); | |||||
| // } | |||||
| // }else if (fees.getPublicCalcute().intValue() == EnumEnergyPublicCalcuteRule.BUILDING.getCode().intValue()) { | |||||
| // String buildingArea = buildingFloorArea.get(mr.getBuildingId()); | |||||
| // if (StringUtils.isBlank(buildingArea) || new BigDecimal(buildingArea).compareTo(new BigDecimal(0)) <= 0 ) { | |||||
| // throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"楼层可用面积未配置完全。"); | |||||
| // } | |||||
| // BigDecimal buildingMoney = new BigDecimal(0); | |||||
| // if (null != buildingFloorMoney ) { | |||||
| // String bMoney = buildingFloorMoney.get(mr.getBuildingId()); | |||||
| // if (StringUtils.isNotBlank(bMoney)) { | |||||
| // buildingMoney = new BigDecimal(bMoney); | |||||
| // } | |||||
| // } | |||||
| // if (buildingMoney.compareTo(b0) > 0 ) { | |||||
| // String needPay = buildingMoney.multiply(new BigDecimal(shop.getRentArea())).divide(new BigDecimal(buildingArea)).setScale(2,RoundingMode.HALF_UP).toPlainString(); | |||||
| // publicBill = mr.generatePublicBill(record, merchant, user, needPay); | |||||
| // } | |||||
| // }else if (fees.getPublicCalcute().intValue() == EnumEnergyPublicCalcuteRule.FLOOR.getCode().intValue()) { | |||||
| // String floorArea = buildingFloorArea.get(mr.getFloorId()); | |||||
| // if (StringUtils.isBlank(floorArea) || new BigDecimal(floorArea).compareTo(new BigDecimal(0)) <= 0 ) { | |||||
| // throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"楼层可用面积未配置完全。"); | |||||
| // } | |||||
| // | |||||
| // BigDecimal floorMoney = new BigDecimal(0); | |||||
| // if (null != buildingFloorMoney ) { | |||||
| // String fMoney = buildingFloorMoney.get(mr.getFloorId()); | |||||
| // if (StringUtils.isNotBlank(fMoney)) { | |||||
| // floorMoney = new BigDecimal(fMoney); | |||||
| // } | |||||
| // } | |||||
| // if (floorMoney.compareTo(b0) > 0 ) { | |||||
| // String needPay = floorMoney.multiply(new BigDecimal(shop.getRentArea())).divide(new BigDecimal(floorArea)).setScale(2,RoundingMode.HALF_UP).toPlainString(); | |||||
| // publicBill = mr.generatePublicBill(record, merchant, user, needPay); | |||||
| // } | |||||
| // } | |||||
| // | |||||
| // if (null != publicBill) { | |||||
| // publicBill.setEnergyFeesId(fees.getId()); | |||||
| // billList.add(publicBill); | |||||
| // } | |||||
| // } | |||||
| // boolean allSuccess = true; | |||||
| // if (billList.size() > 0 ) { | |||||
| // try { | |||||
| // //先把之前的未付的账单全部删除掉,已支付的账单先不处理 | |||||
| // WxAllBill delDaily = new WxAllBill(); | |||||
| // delDaily.updateTenantInfo(record); | |||||
| // delDaily.setEnergyReadingCalcuteId(record.getId()); | |||||
| // wxAllBillService.deleteEnergyReadingBills(delDaily); | |||||
| // wxAllBillService.insertBills(record.getTenantId(), billList); | |||||
| // }catch(Exception e) { | |||||
| // logger.error("insert bills error.",e); | |||||
| // allSuccess = false; | |||||
| // } | |||||
| // WxEnergyReadingCalcute c = new WxEnergyReadingCalcute(); | |||||
| // c.updateTenantInfo(record); | |||||
| // c.setId(record.getId()); | |||||
| // c.setIsCalcuted(EnumYesOrNo.YES.getCode()); | |||||
| // c.setUpdateTime(new Date()); | |||||
| // c.setUpdateBy(user.getId()); | |||||
| // c.setUpdateByName(user.getName()); | |||||
| // c.setRemark(record.getRemark()); | |||||
| // if (allSuccess) { | |||||
| // c.setCalcuteSuccess(EnumYesOrNo.YES.getCode()); | |||||
| // }else { | |||||
| // c.setCalcuteSuccess(EnumYesOrNo.NO.getCode()); | |||||
| // } | |||||
| // wxEnergyReadingCalcuteMapper.updateById(c); | |||||
| // return billList.size(); | |||||
| // } | |||||
| // } | |||||
| return 0; | |||||
| public void createBill(WxEnergyReadingCalcute record, MallUserInfo user) { | |||||
| WxEnergyReadingCalcute calcute = wxEnergyReadingCalcuteMapper.selectById(record.getId(), record.getTenantId()); | |||||
| WxEnergyReadingCalcuteResult crq = new WxEnergyReadingCalcuteResult(); | |||||
| crq.updateTenantInfo(record); | |||||
| crq.setCalcuteId(calcute.getId()); | |||||
| List<Long> shopIdList = wxEnergyReadingCalcuteResultMapper.findShopIdList(crq); | |||||
| Map<Long, WxShop> shopMap = null; | |||||
| Map<Long, WxMerchant> merchantMap = null; | |||||
| if (shopIdList.size() > 0 ) { | |||||
| WxShop sq = new WxShop(); | |||||
| sq.updateTenantInfo(record); | |||||
| sq.setIds(shopIdList); | |||||
| shopMap = wxShopService.findShopMap(sq); | |||||
| merchantMap = wxMerchantService.getShopMerchantMap(sq); | |||||
| } | |||||
| List<WxEnergyReadingCalcuteResult> resultList = wxEnergyReadingCalcuteResultMapper.findList(crq); | |||||
| if (null != resultList && resultList.size() > 0 ) { | |||||
| List<WxAllBill> billList = new ArrayList<WxAllBill>(); | |||||
| for (int i = 0 ; i < resultList.size(); i++) { | |||||
| WxEnergyReadingCalcuteResult result = resultList.get(i); | |||||
| WxShop shop = null; | |||||
| if (null != shopMap) { | |||||
| shop = shopMap.get(result.getShopId()); | |||||
| } | |||||
| WxMerchant merchant = null; | |||||
| if (null != merchantMap) { | |||||
| merchant = merchantMap.get(result.getShopId()); | |||||
| } | |||||
| WxAllBill bill = result.generateBill(calcute, merchant, shop, user, result.getMoney(), result.getMoneyDeail(), "能源计算自动生成"); | |||||
| billList.add(bill); | |||||
| } | |||||
| try { | |||||
| //先把之前的未付的账单全部删除掉,已支付的账单先不处理 | |||||
| WxAllBill delDaily = new WxAllBill(); | |||||
| delDaily.updateTenantInfo(record); | |||||
| delDaily.setEnergyReadingCalcuteId(record.getId()); | |||||
| wxAllBillService.deleteEnergyReadingBills(delDaily); | |||||
| wxAllBillService.insertBills(record.getTenantId(), billList); | |||||
| }catch(Exception e) { | |||||
| logger.error("insert bills error.",e); | |||||
| } | |||||
| WxEnergyReadingCalcute c = new WxEnergyReadingCalcute(); | |||||
| c.updateTenantInfo(record); | |||||
| c.setId(record.getId()); | |||||
| c.setIsCalcuted(EnumYesOrNo.YES.getCode()); | |||||
| c.setUpdateTime(new Date()); | |||||
| c.setUpdateBy(user.getId()); | |||||
| c.setUpdateByName(user.getName()); | |||||
| c.setRemark(record.getRemark()); | |||||
| wxEnergyReadingCalcuteMapper.updateById(c); | |||||
| } | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -113,10 +113,15 @@ public class WxMallBuildingServiceImpl implements WxMallBuildingService { | |||||
| @Override | @Override | ||||
| public ResultData getBuildingList(TenantEntity tenantEntity) { | public ResultData getBuildingList(TenantEntity tenantEntity) { | ||||
| return new ResultData(getBuildingList1(tenantEntity)); | |||||
| } | |||||
| @Override | |||||
| public List<WxMallBuilding> getBuildingList1(TenantEntity tenantEntity) { | |||||
| WxMallBuilding wxMallBuilding = new WxMallBuilding(); | WxMallBuilding wxMallBuilding = new WxMallBuilding(); | ||||
| wxMallBuilding.updateTenantInfo(tenantEntity); | wxMallBuilding.updateTenantInfo(tenantEntity); | ||||
| List<WxMallBuilding> list = wxMallBuildingMapper.findList(wxMallBuilding); | List<WxMallBuilding> list = wxMallBuildingMapper.findList(wxMallBuilding); | ||||
| return new ResultData(list); | |||||
| return list; | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -70,6 +70,15 @@ public class WxMallFloorServiceImpl implements WxMallFloorService { | |||||
| return new ResultData(list); | return new ResultData(list); | ||||
| } | } | ||||
| @Override | |||||
| public List<WxMallFloor> getBudingFloorList(TenantEntity tenantEntity, Long buildingId) { | |||||
| WxMallFloor wxMallFloor = new WxMallFloor(); | |||||
| wxMallFloor.updateTenantInfo(tenantEntity); | |||||
| wxMallFloor.setBuildingId(buildingId); | |||||
| List<WxMallFloor> list = wxMallFloorMapper.findList(wxMallFloor); | |||||
| return list; | |||||
| } | |||||
| @Override | @Override | ||||
| public List<Long> getFloorIdList(WxMallFloor record) { | public List<Long> getFloorIdList(WxMallFloor record) { | ||||
| return wxMallFloorMapper.getFloorIds(record); | return wxMallFloorMapper.getFloorIds(record); | ||||
| @@ -0,0 +1,76 @@ | |||||
| package com.iformall.utils; | |||||
| import java.util.Stack; | |||||
| public class FormulaParser { | |||||
| public static double evaluate(String formula) { | |||||
| Stack<Double> values = new Stack<>(); | |||||
| Stack<Character> operators = new Stack<>(); | |||||
| for (int i = 0; i < formula.length(); i++) { | |||||
| char c = formula.charAt(i); | |||||
| if (Character.isDigit(c) || c == '.') { | |||||
| StringBuilder numBuilder = new StringBuilder(); | |||||
| while (i < formula.length() && (Character.isDigit(formula.charAt(i)) || formula.charAt(i) == '.')) { | |||||
| numBuilder.append(formula.charAt(i)); | |||||
| i++; | |||||
| } | |||||
| i--; | |||||
| values.push(Double.parseDouble(numBuilder.toString())); | |||||
| } else if (c == '(') { | |||||
| operators.push(c); | |||||
| } else if (c == ')') { | |||||
| while (operators.peek()!= '(') { | |||||
| performOperation(values, operators); | |||||
| } | |||||
| operators.pop(); | |||||
| } else if (c == '+' || c == '-') { | |||||
| while (!operators.isEmpty() && (operators.peek() == '*' || operators.peek() == '/')) { | |||||
| performOperation(values, operators); | |||||
| } | |||||
| operators.push(c); | |||||
| } else if (c == '*' || c == '/') { | |||||
| operators.push(c); | |||||
| } | |||||
| } | |||||
| while (!operators.isEmpty()) { | |||||
| performOperation(values, operators); | |||||
| } | |||||
| return values.pop(); | |||||
| } | |||||
| public static void performOperation(Stack<Double> values, Stack<Character> operators) { | |||||
| double num2 = values.pop(); | |||||
| double num1 = values.pop(); | |||||
| char op = operators.pop(); | |||||
| switch (op) { | |||||
| case '+': | |||||
| values.push(num1 + num2); | |||||
| break; | |||||
| case '-': | |||||
| values.push(num1 - num2); | |||||
| break; | |||||
| case '*': | |||||
| values.push(num1 * num2); | |||||
| break; | |||||
| case '/': | |||||
| if (num2!= 0) { | |||||
| values.push(num1 / num2); | |||||
| } else { | |||||
| throw new ArithmeticException("除数不能为 0"); | |||||
| } | |||||
| break; | |||||
| } | |||||
| } | |||||
| public static void main(String[] args) { | |||||
| String formula = "((2 + 3.2) * 4.1 / 3 - 5.6/2) / 2"; | |||||
| double result = evaluate(formula); | |||||
| System.out.println("结果: " + result); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,32 @@ | |||||
| package com.iformall.utils; | |||||
| import java.util.ArrayList; | |||||
| import java.util.List; | |||||
| import java.util.regex.Matcher; | |||||
| import java.util.regex.Pattern; | |||||
| public class PlaceholderExtractorWithPrefixAndSuffix { | |||||
| public static List<String> extractPlaceholders(String text, String prefix, String suffix) { | |||||
| List<String> placeholders = new ArrayList<>(); | |||||
| String pattern = "\\{" + prefix + "[^}]*" + suffix + "\\}"; | |||||
| Pattern regex = Pattern.compile(pattern); | |||||
| Matcher matcher = regex.matcher(text); | |||||
| while (matcher.find()) { | |||||
| placeholders.add(matcher.group()); | |||||
| } | |||||
| return placeholders; | |||||
| } | |||||
| public static void main(String[] args) { | |||||
| String text = "This is a {prefix_value_suffix} and another {prefix_another_suffix}."; | |||||
| String prefix = "prefix"; | |||||
| String suffix = "_suffix"; | |||||
| List<String> extractedPlaceholders = extractPlaceholders(text, prefix, suffix); | |||||
| for (String placeholder : extractedPlaceholders) { | |||||
| System.out.println(placeholder); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -10,13 +10,14 @@ | |||||
| <result column="price" jdbcType="VARCHAR" property="price"/> | <result column="price" jdbcType="VARCHAR" property="price"/> | ||||
| <result column="is_public" jdbcType="INTEGER" property="isPublic"/> | <result column="is_public" jdbcType="INTEGER" property="isPublic"/> | ||||
| <result column="formula" jdbcType="VARCHAR" property="formula"/> | <result column="formula" jdbcType="VARCHAR" property="formula"/> | ||||
| <result column="formula_list_str" jdbcType="VARCHAR" property="formulaListStr"/> | |||||
| <result column="formula_content" jdbcType="VARCHAR" property="formulaContent"/> | <result column="formula_content" jdbcType="VARCHAR" property="formulaContent"/> | ||||
| <result column="shop_id" jdbcType="BIGINT" property="shopId"/> | <result column="shop_id" jdbcType="BIGINT" property="shopId"/> | ||||
| <result column="fees_id" jdbcType="BIGINT" property="feesId"/> | <result column="fees_id" jdbcType="BIGINT" property="feesId"/> | ||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`price`,`is_public`,`formula`,`formula_content`,`shop_id`,`fees_id` | |||||
| `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`price`,`is_public`,`formula`,`formula_list_str`,`formula_content`,`shop_id`,`fees_id` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -33,6 +33,7 @@ | |||||
| <if test=" null != physicsType ">and `physics_type` = #{physicsType}</if> | <if test=" null != physicsType ">and `physics_type` = #{physicsType}</if> | ||||
| <if test=" null != shopType ">and `shop_type` = #{shopType}</if> | <if test=" null != shopType ">and `shop_type` = #{shopType}</if> | ||||
| <if test=" null != name and '' != name ">and name like concat('%', #{name},'%')</if> | <if test=" null != name and '' != name ">and name like concat('%', #{name},'%')</if> | ||||
| <if test=" null != isRealMeter ">and `physics_type` in (1,2) </if> | |||||
| <if test=" null != physicsTypeList "> | <if test=" null != physicsTypeList "> | ||||
| and physics_type in | and physics_type in | ||||
| <foreach collection="physicsTypeList" index="index" item="ptidItem" open="(" separator="," close=")"> | <foreach collection="physicsTypeList" index="index" item="ptidItem" open="(" separator="," close=")"> | ||||
| @@ -55,6 +56,12 @@ | |||||
| <include refid="dynamicWhereConditions"/> | <include refid="dynamicWhereConditions"/> | ||||
| </select> | </select> | ||||
| <select id="findIdList" parameterType="com.iformall.domain.po.WxEnergyMeter" resultType="Long"> | |||||
| select id | |||||
| from wx_energy_meter | |||||
| <include refid="dynamicWhereConditions"/> | |||||
| </select> | |||||
| <select id="selectById" parameterType="HashMap" resultMap="BaseResultMap"> | <select id="selectById" parameterType="HashMap" resultMap="BaseResultMap"> | ||||
| select | select | ||||
| <include refid="allColumns"/> | <include refid="allColumns"/> | ||||
| @@ -49,6 +49,12 @@ | |||||
| <if test=" null != meterName and '' != meterName ">and meter_name like concat('%', #{meterName},'%')</if> | <if test=" null != meterName and '' != meterName ">and meter_name like concat('%', #{meterName},'%')</if> | ||||
| <if test=" null != isDel ">and `is_del` = #{isDel}</if> | <if test=" null != isDel ">and `is_del` = #{isDel}</if> | ||||
| <if test=" null != createByName and '' != createByName ">and create_by_name like concat('%', #{createByName},'%')</if> | <if test=" null != createByName and '' != createByName ">and create_by_name like concat('%', #{createByName},'%')</if> | ||||
| <if test=" null != meterIds "> | |||||
| and meter_id in | |||||
| <foreach collection="meterIds" index="index" item="midItem" open="(" separator="," close=")"> | |||||
| #{midItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != shopIds "> | <if test=" null != shopIds "> | ||||
| and shop_id in | and shop_id in | ||||
| <foreach collection="shopIds" index="index" item="sidItem" open="(" separator="," close=")"> | <foreach collection="shopIds" index="index" item="sidItem" open="(" separator="," close=")"> | ||||
| @@ -80,6 +86,12 @@ | |||||
| <update id = "setIsDel" parameterType="HashMap"> | <update id = "setIsDel" parameterType="HashMap"> | ||||
| update wx_energy_meter_reading set is_del = #{isDel} where id = #{id} and `tenant_id` = #{tenantId} | update wx_energy_meter_reading set is_del = #{isDel} where id = #{id} and `tenant_id` = #{tenantId} | ||||
| </update> | </update> | ||||
| <select id="findNumberSum" parameterType="com.iformall.domain.po.WxEnergyMeterReading" resultType="decimal"> | |||||
| select sum(CAST(ifnull(cur_number,'0') AS DECIMAL(20,4)) - CAST(ifnull(pre_number,'0') AS DECIMAL(20,4))) total_number | |||||
| from wx_energy_meter_reading | |||||
| <include refid="dynamicWhereConditions"/> | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||
| @@ -28,6 +28,12 @@ | |||||
| <if test=" null != type ">and `type` = #{type}</if> | <if test=" null != type ">and `type` = #{type}</if> | ||||
| <if test=" null != meterId ">and `meter_id` = #{meterId}</if> | <if test=" null != meterId ">and `meter_id` = #{meterId}</if> | ||||
| <if test=" null != aliseId ">and `alise_id` = #{aliseId}</if> | <if test=" null != aliseId ">and `alise_id` = #{aliseId}</if> | ||||
| <if test=" null != aliseIdList "> | |||||
| and alise_id in | |||||
| <foreach collection="aliseIdList" index="index" item="aidItem" open="(" separator="," close=")"> | |||||
| #{aidItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != typeList "> | <if test=" null != typeList "> | ||||
| and type in | and type in | ||||
| <foreach collection="typeList" index="index" item="tidItem" open="(" separator="," close=")"> | <foreach collection="typeList" index="index" item="tidItem" open="(" separator="," close=")"> | ||||
| @@ -15,7 +15,6 @@ | |||||
| <result column="period" jdbcType="VARCHAR" property="period"/> | <result column="period" jdbcType="VARCHAR" property="period"/> | ||||
| <result column="fees_id" jdbcType="BIGINT" property="feesId"/> | <result column="fees_id" jdbcType="BIGINT" property="feesId"/> | ||||
| <result column="is_calcuted" jdbcType="INTEGER" property="isCalcuted"/> | <result column="is_calcuted" jdbcType="INTEGER" property="isCalcuted"/> | ||||
| <result column="calcute_success" jdbcType="INTEGER" property="calcuteSuccess"/> | |||||
| <result column="is_del" jdbcType="INTEGER" property="isDel"/> | <result column="is_del" jdbcType="INTEGER" property="isDel"/> | ||||
| <result column="shop_size" jdbcType="INTEGER" property="shopSize"/> | <result column="shop_size" jdbcType="INTEGER" property="shopSize"/> | ||||
| <result column="shop" jdbcType="VARCHAR" property="shop"/> | <result column="shop" jdbcType="VARCHAR" property="shop"/> | ||||
| @@ -23,7 +22,7 @@ | |||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`create_by`,`create_by_name`, | `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`create_by`,`create_by_name`, | ||||
| `update_by`,`update_by_name`,`remark`,`period`,`fees_id`,`is_calcuted`,`calcute_success`,`is_del`,`shop_size`,`shop` | |||||
| `update_by`,`update_by_name`,`remark`,`period`,`fees_id`,`is_calcuted`,`is_del`,`shop_size`,`shop` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -41,7 +40,6 @@ | |||||
| <if test=" null != createBy ">and `create_by` = #{createBy}</if> | <if test=" null != createBy ">and `create_by` = #{createBy}</if> | ||||
| <if test=" null != feesId ">and `fees_id` = #{feesId}</if> | <if test=" null != feesId ">and `fees_id` = #{feesId}</if> | ||||
| <if test=" null != isCalcuted ">and `is_calcuted` = #{isCalcuted}</if> | <if test=" null != isCalcuted ">and `is_calcuted` = #{isCalcuted}</if> | ||||
| <if test=" null != calcuteSuccess ">and `calcute_success` = #{calcuteSuccess}</if> | |||||
| <if test=" null != isDel ">and `is_del` = #{isDel}</if> | <if test=" null != isDel ">and `is_del` = #{isDel}</if> | ||||
| <if test=" null != feesIds "> | <if test=" null != feesIds "> | ||||
| and fees_id in | and fees_id in | ||||
| @@ -11,13 +11,13 @@ | |||||
| <result column="shop_id" jdbcType="BIGINT" property="shopId"/> | <result column="shop_id" jdbcType="BIGINT" property="shopId"/> | ||||
| <result column="fees_id" jdbcType="BIGINT" property="feesId"/> | <result column="fees_id" jdbcType="BIGINT" property="feesId"/> | ||||
| <result column="fees_shop_id" jdbcType="BIGINT" property="feesShopId"/> | <result column="fees_shop_id" jdbcType="BIGINT" property="feesShopId"/> | ||||
| <result column="meter_id" jdbcType="BIGINT" property="meterId"/> | |||||
| <result column="money" jdbcType="VARCHAR" property="money" /> | <result column="money" jdbcType="VARCHAR" property="money" /> | ||||
| <result column="period" jdbcType="VARCHAR" property="period" /> | <result column="period" jdbcType="VARCHAR" property="period" /> | ||||
| <result column="money_deail" jdbcType="VARCHAR" property="moneyDeail" /> | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`calcute_id`,`shop_id`,`fees_id`,`fees_shop_id`,`meter_id`,`money`,`period` | |||||
| `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`calcute_id`,`shop_id`,`fees_id`,`fees_shop_id`,`money`,`period`,`money_deail` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -36,7 +36,6 @@ | |||||
| <if test=" null != shopId ">and `shop_id` = #{shopId}</if> | <if test=" null != shopId ">and `shop_id` = #{shopId}</if> | ||||
| <if test=" null != feesId ">and `fees_id` = #{feesId}</if> | <if test=" null != feesId ">and `fees_id` = #{feesId}</if> | ||||
| <if test=" null != feesShopId ">and `fees_shop_id` = #{feesShopId}</if> | <if test=" null != feesShopId ">and `fees_shop_id` = #{feesShopId}</if> | ||||
| <if test=" null != meterId ">and `meter_id` = #{meterId}</if> | |||||
| <if test=" null != ids "> | <if test=" null != ids "> | ||||
| and id in | and id in | ||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | ||||
| @@ -73,7 +72,7 @@ | |||||
| <foreach collection="list" item="item" index="index" separator=","> | <foreach collection="list" item="item" index="index" separator=","> | ||||
| ( | ( | ||||
| #{item.id},#{item.tenantId},#{item.parentTenantId},#{item.createTime},#{item.updateTime},#{item.calcuteId}, | #{item.id},#{item.tenantId},#{item.parentTenantId},#{item.createTime},#{item.updateTime},#{item.calcuteId}, | ||||
| #{item.shopId},#{item.feesId},#{item.feesShopId},#{item.meterId},#{item.money},#{item.period} | |||||
| #{item.shopId},#{item.feesId},#{item.feesShopId},#{item.money},#{item.period},#{item.moneyDeail} | |||||
| ) | ) | ||||
| </foreach> | </foreach> | ||||
| </insert> | </insert> | ||||