| @@ -401,6 +401,39 @@ public class WxEnergyController extends BaseController { | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("计费标准记录导出") | |||
| @GetMapping("feesShopExport") | |||
| public void feesShopExport(@ModelAttribute WxEnergyFeesShop record, HttpServletRequest request, HttpServletResponse response) { | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| record.setSortColumns(BaseEntity.SortField.CreateTime_DESC); | |||
| if (StringUtils.isNotBlank(record.getFeesIdsStr())) { | |||
| String[] fss = record.getFeesIdsStr().split(","); | |||
| if (null != fss && fss.length > 0 ) { | |||
| List<Long> feesIdList = new ArrayList<Long>(); | |||
| for (int i = 0 ; i < fss.length ; i ++) { | |||
| feesIdList.add(Long.parseLong(fss[i])); | |||
| } | |||
| record.setFeesIds(feesIdList); | |||
| } | |||
| } | |||
| wxEnergyService.exportFeesShop(record, request, response); | |||
| } | |||
| @ApiOperation("科目抄表计算记录导入") | |||
| @PostMapping(value = "/importFeesShop", consumes = "multipart/*") | |||
| public void importFeesShop(@RequestParam("file") MultipartFile mFile,HttpServletRequest request, HttpServletResponse response) { | |||
| try { | |||
| //得到当前用户ID | |||
| MallUserInfo user = getUser(); | |||
| //request.getParameter("timeId"); | |||
| wxEnergyService.importReading(mFile, user, request, response); | |||
| } catch (Exception e) { | |||
| logger.error("importReading error.",e); | |||
| throw new MallinkException(Result.ERROR,e.getMessage()); | |||
| } | |||
| } | |||
| @ApiOperation("费用区间所属年月") | |||
| @GetMapping("periodList") | |||
| public ResultData periodList() { | |||
| @@ -665,6 +698,16 @@ public class WxEnergyController extends BaseController { | |||
| public ResultData readingCalcuteResultList(@ModelAttribute WxEnergyReadingCalcuteResult record, Integer pageNum, Integer pageSize) { | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| record.setSortColumns(BaseEntity.SortField.CreateTime_DESC); | |||
| if(StringUtils.isNotBlank(record.getFeesIdsStr())) { | |||
| String[] shids = record.getFeesIdsStr().split(","); | |||
| if (null != shids ) { | |||
| List<Long> sids = new ArrayList<Long>(); | |||
| for (int i = 0 ; i < shids.length ; i ++) { | |||
| sids.add(Long.parseLong(shids[i])); | |||
| } | |||
| record.setFeesIds(sids); | |||
| } | |||
| } | |||
| PageInfo<WxEnergyReadingCalcuteResult> page = wxEnergyService.readingCalcuteResultListAsPage(record, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @@ -7,6 +7,7 @@ import com.iformall.enums.EnumEnergyMeterPhysicsType; | |||
| import com.iformall.enums.EnumEnergyMeterType; | |||
| import com.iformall.enums.EnumRentShopType; | |||
| import cn.afterturn.easypoi.excel.annotation.Excel; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| @@ -23,9 +24,11 @@ public class WxEnergyFeesShop extends TenantEntity { | |||
| private static final long serialVersionUID = 7009117540201976664L; | |||
| @Excel(name = "ID", width = 20, orderNum = "1") | |||
| @io.swagger.annotations.ApiModelProperty(value="id",name="id") | |||
| private Long id; | |||
| @Excel(name = "创建时间", format = "yyyy-MM-dd HH:mm:ss", width = 20, orderNum = "13") | |||
| @io.swagger.annotations.ApiModelProperty(value="createTime",name="createTime") | |||
| private Date createTime; | |||
| @@ -34,15 +37,30 @@ public class WxEnergyFeesShop extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="科目编号",name="feesId") | |||
| private Long feesId; | |||
| @Excel(name = "科目", width = 20, orderNum = "2") | |||
| @TableField(exist = false) | |||
| private String feesName; | |||
| @Excel(name = "是否公摊", replace = {"是公摊_1", "不是公摊_0"}, width = 20, orderNum = "8") | |||
| @io.swagger.annotations.ApiModelProperty(value = "是否公摊", name = "isPublic") | |||
| private Integer isPublic; | |||
| @Excel(name = "单价", width = 20, orderNum = "7") | |||
| @io.swagger.annotations.ApiModelProperty(value = "单价", name = "price") | |||
| private String price; | |||
| @Excel(name = "店铺ID", width = 20, orderNum = "3") | |||
| @io.swagger.annotations.ApiModelProperty(value = "店铺编号", name = "shopId") | |||
| private Long shopId; | |||
| @Excel(name = "店铺号", width = 20, orderNum = "4") | |||
| @TableField(exist = false) | |||
| private String shopName; | |||
| @Excel(name = "楼栋", width = 20, orderNum = "5") | |||
| @TableField(exist = false) | |||
| private String buildingName; | |||
| @Excel(name = "楼层", width = 20, orderNum = "6") | |||
| @TableField(exist = false) | |||
| private String floorName; | |||
| @io.swagger.annotations.ApiModelProperty(value = "公摊计算公司", name = "formula") | |||
| private String formula; | |||
| @@ -68,8 +86,7 @@ public class WxEnergyFeesShop extends TenantEntity { | |||
| @TableField(exist = false) | |||
| private List<Long> shopIds; | |||
| @TableField(exist = false) | |||
| private String feesName; | |||
| @TableField(exist = false) | |||
| private String feesIdsStr; | |||
| private List<Long> feesIds; | |||
| @@ -77,6 +77,9 @@ public class WxEnergyMeter extends TenantEntity { | |||
| return null; | |||
| } | |||
| @io.swagger.annotations.ApiModelProperty(value = "是否参与计费", name = "hasFee") | |||
| private Integer hasFee; | |||
| @TableField(exist = false) | |||
| private String treeType="meter"; | |||
| @TableField(exist = false) | |||
| @@ -64,6 +64,9 @@ public class WxEnergyReadingCalcuteResult extends TenantEntity { | |||
| @TableField(exist = false) | |||
| private String feesName; | |||
| @io.swagger.annotations.ApiModelProperty(value="科目单价",name="feesPrice") | |||
| private String feesPrice; | |||
| @io.swagger.annotations.ApiModelProperty(value="费用标准ID",name="feesCalcuteId") | |||
| private Long feesShopId; | |||
| @@ -77,6 +80,10 @@ public class WxEnergyReadingCalcuteResult extends TenantEntity { | |||
| @TableField(exist = false) | |||
| private List<Long> shopIds; | |||
| @TableField(exist = false) | |||
| private List<Long> feesIds; | |||
| @TableField(exist = false) | |||
| private String feesIdsStr; | |||
| public WxAllBill generateBill(WxEnergyReadingCalcute calcute,WxMerchant merchant,WxShop shop,MallUserInfo user,String needPay,String detail,String remark) { | |||
| WxAllBill daily = new WxAllBill(); | |||
| @@ -149,6 +149,9 @@ public class WxShop extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value = "租金单位", name = "rentUnit") | |||
| private Integer rentUnit; | |||
| @io.swagger.annotations.ApiModelProperty(value = "租金单位", name = "rentUnit") | |||
| private String pulicRate; | |||
| @io.swagger.annotations.ApiModelProperty(value = "树里面的类型", name = "treeType") | |||
| @TableField(exist = false) | |||
| private String treeType = "shop"; | |||
| @@ -64,6 +64,8 @@ public interface WxEnergyService { | |||
| WxEnergyFeesShop getFeesShop(Long id,String tenantId); | |||
| void updateFeesShop(WxEnergyFeesShop record); | |||
| PageInfo<WxEnergyFeesShop> feesShopListAsPage(WxEnergyFeesShop record, Integer pageIndex, Integer pageSize); | |||
| void exportFeesShop(WxEnergyFeesShop record,HttpServletRequest request, HttpServletResponse response); | |||
| void importFeesShop(MultipartFile mFile, MallUserInfo user, HttpServletRequest request, HttpServletResponse response); | |||
| //抄表数据 | |||
| PageInfo<WxEnergyMeterReading> readingListAsPage(WxEnergyMeterReading record, Integer pageIndex, Integer pageSize); | |||
| @@ -132,7 +132,11 @@ public class WxEnergyHelper { | |||
| } | |||
| } | |||
| formula = formula.replaceAll("#totalArea#", totalArea.toPlainString()); | |||
| formula = formula.replaceAll("#shopPublicRax#", shop.getBuildArea()); | |||
| if (StringUtils.isBlank(shop.getPulicRate())) { | |||
| formula = formula.replaceAll("#shopPublicRax#", "0"); | |||
| }else { | |||
| formula = formula.replaceAll("#shopPublicRax#", shop.getPulicRate()); | |||
| } | |||
| return formula; | |||
| } | |||
| @@ -195,7 +199,7 @@ public class WxEnergyHelper { | |||
| } | |||
| 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 new BigDecimal(FormulaParser.evaluate(formula)).multiply(new BigDecimal(shopfee.getPrice())).setScale(2,BigDecimal.ROUND_HALF_UP).toPlainString(); | |||
| } | |||
| return "0"; | |||
| }else { | |||
| @@ -629,6 +629,9 @@ public class WxEnergyServiceImpl implements WxEnergyService { | |||
| fq.updateTenantInfo(record); | |||
| fq.setIsDel(EnumYesOrNo.NO.getCode()); | |||
| Map<Long, WxEnergyFees> feesMap = this.getFeesMap(fq); | |||
| Map<Long, String> floorMap = wxMallFloorService.getFloorMap(record); | |||
| Map<Long, String> buildingMap = wxMallBuildingService.getBuildingMap(record); | |||
| List<Long> shopIdList = new ArrayList<Long>(); | |||
| for (int i = 0 ; i < page.getList().size() ; i++) { | |||
| WxEnergyFeesShop fs = page.getList().get(i); | |||
| if (null != feesMap && null != fs.getFeesId()) { | |||
| @@ -637,11 +640,71 @@ public class WxEnergyServiceImpl implements WxEnergyService { | |||
| fs.setFeesName(fee.getName()); | |||
| } | |||
| } | |||
| shopIdList.add(fs.getShopId()); | |||
| } | |||
| Map<Long, WxShop> shopMap = null; | |||
| if (shopIdList.size() > 0 ) { | |||
| WxShop sq = new WxShop(); | |||
| sq.updateTenantInfo(record); | |||
| sq.setIds(shopIdList); | |||
| shopMap = wxShopService.findShopMap(sq); | |||
| } | |||
| for (int i = 0 ; i < page.getList().size(); i++) { | |||
| WxEnergyFeesShop c = page.getList().get(i); | |||
| if (null != shopMap && null != c.getShopId()) { | |||
| WxShop s = shopMap.get(c.getShopId()); | |||
| if (null != s) { | |||
| c.setShopName(s.getShopNumber()); | |||
| if (null != floorMap) { | |||
| c.setFloorName(floorMap.get(s.getFloor())); | |||
| } | |||
| if (null != buildingMap) { | |||
| c.setBuildingName(buildingMap.get(s.getBuilding())); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| return page; | |||
| } | |||
| @Override | |||
| public void exportFeesShop(WxEnergyFeesShop record, HttpServletRequest request, HttpServletResponse response) { | |||
| PageInfo<WxEnergyFeesShop> page = feesShopListAsPage(record, 1, 10000); | |||
| excelService.exportExcel(page.getList(), null, "计算标准", WxEnergyFeesShop.class, "计算标准.xlsx", response, false); | |||
| } | |||
| @Override | |||
| public void importFeesShop(MultipartFile mFile, MallUserInfo user, HttpServletRequest request, | |||
| HttpServletResponse response) { | |||
| File file = handlerImportFile(mFile,"energyFeesShopImport"); | |||
| // 需要验证 | |||
| String[] needFields = new String[]{"ID", "科目","店铺ID", "单价"}; | |||
| String[] allFields = new String[] {"ID","科目","店铺ID","店铺号","楼栋","楼层","单价","是否公摊","创建时间"}; | |||
| ExcelImportResult<WxEnergyFeesShop> datalist = handleImportFile(file,WxEnergyFeesShop.class,allFields,needFields,new ReadingExcelHandler()); | |||
| if (null == datalist) { | |||
| return ; | |||
| } | |||
| List<WxEnergyFeesShop> successList = datalist.getList(); | |||
| if(successList.size() > 0) { | |||
| boolean allSuccess = true; | |||
| try { | |||
| successList.parallelStream().forEach(reading -> { | |||
| WxEnergyFeesShop r = new WxEnergyFeesShop(); | |||
| r.updateTenantInfo(user); | |||
| r.setId(reading.getId()); | |||
| r.setPrice(reading.getPrice()); | |||
| r.setUpdateTime(new Date()); | |||
| wxEnergyFeesShopMapper.updateById(r); | |||
| }); | |||
| } catch (Exception e) { | |||
| logger.error("导入模板失败:"+e.getMessage(),e); | |||
| allSuccess = false; | |||
| } | |||
| } | |||
| } | |||
| @Override | |||
| public List<Long> getAdvanceSetoffFeesids(WxEnergyFeesSetoff setoff) { | |||
| return wxEnergyFeesSetoffMapper.findFeesIdList(setoff); | |||
| @@ -956,6 +1019,7 @@ public class WxEnergyServiceImpl implements WxEnergyService { | |||
| mq.updateTenantInfo(record); | |||
| mq.setType(fees.getType()); | |||
| mq.setPhysicsType(EnumEnergyMeterPhysicsType.USER.getCode()); | |||
| mq.setHasFee(EnumYesOrNo.YES.getCode()); | |||
| List<Long> meterList = wxEnergyMeterMapper.findIdList(mq); | |||
| //查询公摊表 | |||
| Map<Long,List<Long>> summaryMeterMap = null; | |||
| @@ -1024,6 +1088,7 @@ public class WxEnergyServiceImpl implements WxEnergyService { | |||
| cs.setCreateTime(new Date()); | |||
| cs.setUpdateTime(new Date()); | |||
| cs.setFeesId(shopfee.getFeesId()); | |||
| cs.setFeesPrice(shopfee.getPrice()); | |||
| cs.setFeesShopId(shopfee.getId()); | |||
| StringBuffer sb = new StringBuffer(); | |||
| cs.setMoney(wxEnergyHelper.calcuteMoney(sb,totalArea,shop,time, fees, shopfee,meterList,summaryMeterMap,buildingAreaMap,floorAreaMap)); | |||
| @@ -13,10 +13,11 @@ | |||
| <result column="rate" jdbcType="VARCHAR" property="rate"/> | |||
| <result column="physics_type" jdbcType="INTEGER" property="physicsType"/> | |||
| <result column="shop_type" jdbcType="INTEGER" property="shopType"/> | |||
| <result column="has_fee" jdbcType="INTEGER" property="hasFee"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`is_del`,`name`,`type`,`rate`,`physics_type`,`shop_type` | |||
| `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`is_del`,`name`,`type`,`rate`,`physics_type`,`shop_type`,`has_fee` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -34,6 +35,7 @@ | |||
| <if test=" null != shopType ">and `shop_type` = #{shopType}</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 != hasFee ">and `has_fee` = #{hasFee}</if> | |||
| <if test=" null != physicsTypeList "> | |||
| and physics_type in | |||
| <foreach collection="physicsTypeList" index="index" item="ptidItem" open="(" separator="," close=")"> | |||
| @@ -10,6 +10,7 @@ | |||
| <result column="calcute_id" jdbcType="BIGINT" property="calcuteId"/> | |||
| <result column="shop_id" jdbcType="BIGINT" property="shopId"/> | |||
| <result column="fees_id" jdbcType="BIGINT" property="feesId"/> | |||
| <result column="fees_price" jdbcType="VARCHAR" property="feesPrice" /> | |||
| <result column="fees_shop_id" jdbcType="BIGINT" property="feesShopId"/> | |||
| <result column="money" jdbcType="VARCHAR" property="money" /> | |||
| <result column="period" jdbcType="VARCHAR" property="period" /> | |||
| @@ -17,7 +18,7 @@ | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`calcute_id`,`shop_id`,`fees_id`,`fees_shop_id`,`money`,`period`,`money_deail` | |||
| `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`calcute_id`,`shop_id`,`fees_id`,`fees_price`,`fees_shop_id`,`money`,`period`,`money_deail` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -36,6 +37,12 @@ | |||
| <if test=" null != shopId ">and `shop_id` = #{shopId}</if> | |||
| <if test=" null != feesId ">and `fees_id` = #{feesId}</if> | |||
| <if test=" null != feesShopId ">and `fees_shop_id` = #{feesShopId}</if> | |||
| <if test=" null != feesIds "> | |||
| and fees_id in | |||
| <foreach collection="feesIds" index="index" item="feidItem" open="(" separator="," close=")"> | |||
| #{feidItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| @@ -72,7 +79,7 @@ | |||
| <foreach collection="list" item="item" index="index" separator=","> | |||
| ( | |||
| #{item.id},#{item.tenantId},#{item.parentTenantId},#{item.createTime},#{item.updateTime},#{item.calcuteId}, | |||
| #{item.shopId},#{item.feesId},#{item.feesShopId},#{item.money},#{item.period},#{item.moneyDeail} | |||
| #{item.shopId},#{item.feesId},#{item.feesPrice},#{item.feesShopId},#{item.money},#{item.period},#{item.moneyDeail} | |||
| ) | |||
| </foreach> | |||
| </insert> | |||
| @@ -33,13 +33,13 @@ | |||
| <result column="rent" property="rent"/> | |||
| <result column="rent_unit" property="rentUnit"/> | |||
| <result column="business_id" property="businessId"/> | |||
| <result column="pulic_rate" jdbcType="VARCHAR" property="pulicRate"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`parent_tenant_id`,`shop_number`,`build_area`,`operation_area`,`building`,`floor`,`status`,`x`,`y`,`sid`,`addr`, | |||
| `baidu_poi`,`longitude`,`latitude`,`create_date`,`update_date`,`img_url`,`manager`,`manager_phone`, | |||
| `type`,`point_type`,`comments`,`is_del`,DATEDIFF(now(),create_date) freeDay,rent,rent_unit,business_id | |||
| `type`,`point_type`,`comments`,`is_del`,DATEDIFF(now(),create_date) freeDay,rent,rent_unit,business_id,pulic_rate | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||