| @@ -13,6 +13,7 @@ import com.iformall.domain.po.WxEnergyMeterChild; | |||||
| import com.iformall.domain.po.WxEnergyMeterReading; | import com.iformall.domain.po.WxEnergyMeterReading; | ||||
| import com.iformall.domain.po.WxEnergyMeterShopFloor; | import com.iformall.domain.po.WxEnergyMeterShopFloor; | ||||
| import com.iformall.domain.po.WxEnergyReadingCalcute; | import com.iformall.domain.po.WxEnergyReadingCalcute; | ||||
| import com.iformall.domain.po.WxEnergyReadingCalcuteResult; | |||||
| import com.iformall.domain.po.WxMallFloor; | import com.iformall.domain.po.WxMallFloor; | ||||
| import com.iformall.domain.po.WxShop; | import com.iformall.domain.po.WxShop; | ||||
| import com.iformall.domain.po.WxUserDataRule; | import com.iformall.domain.po.WxUserDataRule; | ||||
| @@ -579,7 +580,7 @@ public class WxEnergyController extends BaseController { | |||||
| //得到当前用户ID | //得到当前用户ID | ||||
| MallUserInfo user = getUser(); | MallUserInfo user = getUser(); | ||||
| //request.getParameter("timeId"); | //request.getParameter("timeId"); | ||||
| wxEnergyService.importReadingCalcute(mFile, user, request, response); | |||||
| wxEnergyService.importReading(mFile, user, request, response); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("importReading error.",e); | logger.error("importReading error.",e); | ||||
| throw new MallinkException(Result.ERROR,e.getMessage()); | throw new MallinkException(Result.ERROR,e.getMessage()); | ||||
| @@ -639,40 +640,41 @@ public class WxEnergyController extends BaseController { | |||||
| return new ResultData(wxEnergyService.getReadingCalcuteShopNumber(record)); | return new ResultData(wxEnergyService.getReadingCalcuteShopNumber(record)); | ||||
| } | } | ||||
| @ApiOperation("科目抄表计算数据分页列表接口") | |||||
| @GetMapping("readingCalcuteResultList") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true), | |||||
| }) | |||||
| public ResultData readingCalcuteResultList(@ModelAttribute WxEnergyReadingCalcuteResult record, Integer pageNum, Integer pageSize) { | |||||
| record.updateTenantInfo(getTenantInfo()); | |||||
| record.setSortColumns(BaseEntity.SortField.CreateTime_DESC); | |||||
| PageInfo<WxEnergyReadingCalcuteResult> page = wxEnergyService.readingCalcuteResultListAsPage(record, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("科目抄表计算记录导出") | @ApiOperation("科目抄表计算记录导出") | ||||
| @GetMapping("readingCalcuteExport") | @GetMapping("readingCalcuteExport") | ||||
| public void readingCalcuteExport(@ModelAttribute WxEnergyReadingCalcute record, HttpServletRequest request, HttpServletResponse response) { | 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(value = "/importReadingCalcute", consumes = "multipart/*") | |||||
| public void importReadingCalcute(@RequestParam("file") MultipartFile mFile,HttpServletRequest request, HttpServletResponse response) { | |||||
| try { | |||||
| //得到当前用户ID | |||||
| MallUserInfo user = getUser(); | |||||
| wxEnergyService.importReadingCalcute(mFile, user, request, response); | |||||
| } catch (Exception e) { | |||||
| logger.error("importReading error.",e); | |||||
| throw new MallinkException(Result.ERROR,e.getMessage()); | |||||
| } | |||||
| // record.updateTenantInfo(getTenantInfo()); | |||||
| // WxEnergyReadingCalcute wrc = wxEnergyService.getReadingCalcuteById(record); | |||||
| // if (null == wrc) { | |||||
| // return; | |||||
| // } | |||||
| // wxEnergyService.exportReadingCalcute(wrc, request, response); | |||||
| } | } | ||||
| @ApiOperation("计算") | @ApiOperation("计算") | ||||
| @PostMapping("calcute") | @PostMapping("calcute") | ||||
| public ResultData calcute(@RequestBody WxEnergyReadingCalcute record) { | 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); | |||||
| // 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; | |||||
| } | } | ||||
| @PostMapping("calcuteIsDel") | @PostMapping("calcuteIsDel") | ||||
| @@ -1330,9 +1330,10 @@ CREATE TABLE `wx_energy_reading_calcute_result` ( | |||||
| `calcute_id` bigint(20) NOT NULL COMMENT '费用计算ID', | `calcute_id` bigint(20) NOT NULL COMMENT '费用计算ID', | ||||
| `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_calcute_id` bigint(20) NOT NULL COMMENT '费用标准编号', | |||||
| `fees_shop_id` bigint(20) NOT NULL COMMENT '店铺科目编号', | |||||
| `meter_id` bigint(20) DEFAULT 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 '所属年月', | |||||
| 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`) | ||||
| @@ -1344,3 +1345,4 @@ CREATE TABLE `wx_energy_reading_calcute_result` ( | |||||
| @@ -6,6 +6,7 @@ import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.enums.EnumYesOrNo; | import com.iformall.enums.EnumYesOrNo; | ||||
| import com.iformall.utils.DateUtils; | import com.iformall.utils.DateUtils; | ||||
| import cn.afterturn.easypoi.excel.annotation.Excel; | |||||
| import lombok.Data; | import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
| import lombok.ToString; | import lombok.ToString; | ||||
| @@ -28,30 +29,49 @@ public class WxEnergyReadingCalcuteResult extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="id",name="id") | @io.swagger.annotations.ApiModelProperty(value="id",name="id") | ||||
| private Long 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") | @io.swagger.annotations.ApiModelProperty(value="createTime",name="createTime") | ||||
| private Date createTime; | private Date createTime; | ||||
| @io.swagger.annotations.ApiModelProperty(value="updateTime",name="updateTime") | @io.swagger.annotations.ApiModelProperty(value="updateTime",name="updateTime") | ||||
| private Date updateTime; | private Date updateTime; | ||||
| @Excel(name = "计算ID", width = 20, orderNum = "1") | |||||
| @io.swagger.annotations.ApiModelProperty(value="计算ID",name="calcuteId") | @io.swagger.annotations.ApiModelProperty(value="计算ID",name="calcuteId") | ||||
| private Long calcuteId; | private Long calcuteId; | ||||
| @Excel(name = "所属年月", width = 20, orderNum = "2") | |||||
| @io.swagger.annotations.ApiModelProperty(value="所属年月",name="period") | |||||
| private String period; | |||||
| @io.swagger.annotations.ApiModelProperty(value="店铺ID",name="shopId") | @io.swagger.annotations.ApiModelProperty(value="店铺ID",name="shopId") | ||||
| private Long shopId; | private Long shopId; | ||||
| @Excel(name = "店铺号", width = 20, orderNum = "3") | |||||
| @TableField(exist = false) | |||||
| private String shopName; | |||||
| @Excel(name = "楼栋", width = 20, orderNum = "4") | |||||
| @TableField(exist = false) | |||||
| private String buildingName; | |||||
| @Excel(name = "楼层", width = 20, orderNum = "5") | |||||
| @TableField(exist = false) | |||||
| private String floorName; | |||||
| @io.swagger.annotations.ApiModelProperty(value="科目ID",name="feesId") | @io.swagger.annotations.ApiModelProperty(value="科目ID",name="feesId") | ||||
| private Long feesId; | private Long feesId; | ||||
| @Excel(name = "科目", width = 20, orderNum = "6") | |||||
| @TableField(exist = false) | |||||
| private String feesName; | |||||
| @io.swagger.annotations.ApiModelProperty(value="费用标准ID",name="feesCalcuteId") | @io.swagger.annotations.ApiModelProperty(value="费用标准ID",name="feesCalcuteId") | ||||
| private Long feesCalcuteId; | |||||
| private Long feesShopId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="表ID",name="meterId") | @io.swagger.annotations.ApiModelProperty(value="表ID",name="meterId") | ||||
| private Long meterId; | private Long meterId; | ||||
| @Excel(name = "表号", width = 20, orderNum = "7") | |||||
| @TableField(exist = false) | |||||
| private String meterName; | |||||
| @io.swagger.annotations.ApiModelProperty(value="抄表数据ID",name="readingId") | |||||
| private Long readingId; | |||||
| @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; | ||||
| @@ -16,4 +16,6 @@ public interface WxEnergyReadingCalcuteResultMapper extends CommonMapper<WxEnerg | |||||
| WxEnergyReadingCalcuteResult selectById(@Param("id")Long id,@Param("tenantId")String tenantId); | WxEnergyReadingCalcuteResult selectById(@Param("id")Long id,@Param("tenantId")String tenantId); | ||||
| void insertResults(@Param("tenantId")String tenantId, @Param("list")List<WxEnergyReadingCalcuteResult> resultList); | |||||
| } | } | ||||
| @@ -58,7 +58,7 @@ public interface WxEnergyService { | |||||
| List<Long> getFeesIdList(WxEnergyFees record); | List<Long> getFeesIdList(WxEnergyFees record); | ||||
| //计算标砖 | //计算标砖 | ||||
| List<Map> getFeesCalcuteComponentList(WxEnergyFeesShop record); | |||||
| List<Map<String,String>> getFeesCalcuteComponentList(WxEnergyFeesShop record); | |||||
| void createFeesShop(WxEnergyFeesShop record); | void createFeesShop(WxEnergyFeesShop record); | ||||
| void deleteFeesShop(WxEnergyFeesShop record); | void deleteFeesShop(WxEnergyFeesShop record); | ||||
| WxEnergyFeesShop getShopFeesCalcute(Long id,String tenantId); | WxEnergyFeesShop getShopFeesCalcute(Long id,String tenantId); | ||||
| @@ -78,11 +78,11 @@ public interface WxEnergyService { | |||||
| //抄表科目计算数据 | //抄表科目计算数据 | ||||
| PageInfo<WxEnergyReadingCalcute> readingCalcuteListAsPage(WxEnergyReadingCalcute record, Integer pageIndex, Integer pageSize); | PageInfo<WxEnergyReadingCalcute> readingCalcuteListAsPage(WxEnergyReadingCalcute record, Integer pageIndex, Integer pageSize); | ||||
| void saveOrUpdateReadingCalcute(WxEnergyReadingCalcute record,MallUserInfo userInfo); | void saveOrUpdateReadingCalcute(WxEnergyReadingCalcute record,MallUserInfo userInfo); | ||||
| WxEnergyReadingCalcute getReadingCalcuteById(WxEnergyReadingCalcute record); | |||||
| PageInfo<WxEnergyReadingCalcuteResult> readingCalcuteResultListAsPage(WxEnergyReadingCalcuteResult record, Integer pageIndex, Integer pageSize); | |||||
| void exportReadingCalcute(WxEnergyReadingCalcute record,HttpServletRequest request, HttpServletResponse response); | void exportReadingCalcute(WxEnergyReadingCalcute record,HttpServletRequest request, HttpServletResponse response); | ||||
| void importReadingCalcute(MultipartFile mFile, MallUserInfo user, HttpServletRequest request, HttpServletResponse response); | |||||
| Integer calcuteReading(WxEnergyReadingCalcute record, MallUserInfo user); | Integer calcuteReading(WxEnergyReadingCalcute record, MallUserInfo user); | ||||
| void setReadingCalcuteIsDel(WxEnergyReadingCalcute record); | void setReadingCalcuteIsDel(WxEnergyReadingCalcute record); | ||||
| List<String> getReadingCalcuteShopNumber(WxEnergyReadingCalcute record); | List<String> getReadingCalcuteShopNumber(WxEnergyReadingCalcute record); | ||||
| } | } | ||||
| @@ -1,67 +1,36 @@ | |||||
| package com.iformall.service.helper; | package com.iformall.service.helper; | ||||
| import java.math.BigDecimal; | |||||
| import java.math.RoundingMode; | |||||
| import java.text.SimpleDateFormat; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| 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; | ||||
| import org.apache.commons.collections4.CollectionUtils; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.joda.time.DateTime; | |||||
| import org.joda.time.Months; | |||||
| import org.joda.time.format.DateTimeFormat; | |||||
| import org.joda.time.format.DateTimeFormatter; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import com.alibaba.fastjson.JSONArray; | |||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.iformall.domain.dto.NeedPayDTO; | |||||
| import com.iformall.domain.po.WxEnergyFees; | |||||
| import com.iformall.domain.po.WxEnergyFeesShop; | |||||
| import com.iformall.domain.po.WxEnergyFeesTime; | |||||
| import com.iformall.domain.po.WxEnergyMeter; | import com.iformall.domain.po.WxEnergyMeter; | ||||
| import com.iformall.domain.po.WxPropertyContract; | |||||
| import com.iformall.domain.po.WxRentContract; | |||||
| import com.iformall.domain.vo.WxBillFeesStandardsListVo; | |||||
| import com.iformall.enums.EnumContractReceivePeriodUnit; | |||||
| import com.iformall.enums.EnumFeesStandardsCalcuteUnit; | |||||
| import com.iformall.enums.EnumPriceUnit; | |||||
| import com.iformall.enums.EnumRentContractAdjustPeriod; | |||||
| import com.iformall.enums.EnumRentContractAdjustRatioWay; | |||||
| import com.iformall.enums.EnumRentContractRentInputWay; | |||||
| import com.iformall.enums.EnumRentContractType; | |||||
| import com.iformall.enums.EnumRentDayPriceCalcute; | |||||
| import com.iformall.enums.EnumYesOrNo; | |||||
| import com.iformall.service.impl.WxRentContractServiceImpl; | |||||
| import com.iformall.utils.Constant; | |||||
| import com.iformall.utils.DateUtils; | |||||
| public class WxEnergyHelper { | public class WxEnergyHelper { | ||||
| public static List<Map> generateCalcuteComponent() { | |||||
| public static List<Map<String,String>> generateCalcuteComponent() { | |||||
| //公共表,公摊总表,当前楼栋面积,当前楼层面积,总面积,店铺公摊系数 | //公共表,公摊总表,当前楼栋面积,当前楼层面积,总面积,店铺公摊系数 | ||||
| List<Map> retList = new ArrayList<Map>(); | |||||
| List<Map<String,String>> retList = new ArrayList<Map<String,String>>(); | |||||
| Map currentBuildingArea = new HashMap(); | |||||
| Map<String,String> currentBuildingArea = new HashMap<String,String>(); | |||||
| currentBuildingArea.put("name", "店铺所属楼栋总计租面积"); | currentBuildingArea.put("name", "店铺所属楼栋总计租面积"); | ||||
| currentBuildingArea.put("value", "{#currentBuildingArea#}"); | currentBuildingArea.put("value", "{#currentBuildingArea#}"); | ||||
| retList.add(currentBuildingArea); | retList.add(currentBuildingArea); | ||||
| Map currentFloorArea = new HashMap(); | |||||
| Map<String,String> currentFloorArea = new HashMap<String,String>(); | |||||
| currentFloorArea.put("name", "店铺所属楼层总计租面积"); | currentFloorArea.put("name", "店铺所属楼层总计租面积"); | ||||
| currentFloorArea.put("value", "{#currentFloorArea#}"); | currentFloorArea.put("value", "{#currentFloorArea#}"); | ||||
| retList.add(currentFloorArea); | retList.add(currentFloorArea); | ||||
| Map totalArea = new HashMap(); | |||||
| Map<String,String> totalArea = new HashMap<String,String>(); | |||||
| totalArea.put("name", "商场总计租面积"); | totalArea.put("name", "商场总计租面积"); | ||||
| totalArea.put("value", "{#totalArea#}"); | totalArea.put("value", "{#totalArea#}"); | ||||
| retList.add(totalArea); | retList.add(totalArea); | ||||
| Map calcuteRax = new HashMap(); | |||||
| Map<String,String> calcuteRax = new HashMap<String,String>(); | |||||
| calcuteRax.put("name", "公摊系数"); | calcuteRax.put("name", "公摊系数"); | ||||
| calcuteRax.put("value", "{#calcuteRax#}"); | calcuteRax.put("value", "{#calcuteRax#}"); | ||||
| retList.add(calcuteRax); | retList.add(calcuteRax); | ||||
| @@ -69,11 +38,17 @@ public class WxEnergyHelper { | |||||
| return retList; | return retList; | ||||
| } | } | ||||
| public static Map generateMeterComponent(WxEnergyMeter meter) { | |||||
| Map m = new HashMap(); | |||||
| public static Map<String,String> generateMeterComponent(WxEnergyMeter meter) { | |||||
| 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"; | |||||
| } | |||||
| } | } | ||||
| @@ -179,7 +179,7 @@ public class WxEnergyServiceImpl implements WxEnergyService { | |||||
| List<Long> buildindIds = record.getBuildingIds(); | List<Long> buildindIds = record.getBuildingIds(); | ||||
| FloorBuildingIdDTO dto = getFloorBuildingIds(record, floorIds, buildindIds); | FloorBuildingIdDTO dto = getFloorBuildingIds(record, floorIds, buildindIds); | ||||
| record.setType(dto.getType().getCode()); | record.setType(dto.getType().getCode()); | ||||
| aliasIds = record.getIds(); | |||||
| aliasIds = dto.getIds(); | |||||
| if (null == aliasIds || aliasIds.size() <= 0 ) { | if (null == aliasIds || aliasIds.size() <= 0 ) { | ||||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请选择有效的楼层楼座"); | throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请选择有效的楼层楼座"); | ||||
| } | } | ||||
| @@ -507,8 +507,8 @@ public class WxEnergyServiceImpl implements WxEnergyService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public List<Map> getFeesCalcuteComponentList(WxEnergyFeesShop record) { | |||||
| List<Map> retList = WxEnergyHelper.generateCalcuteComponent(); | |||||
| public List<Map<String,String>> getFeesCalcuteComponentList(WxEnergyFeesShop record) { | |||||
| List<Map<String,String>> retList = WxEnergyHelper.generateCalcuteComponent(); | |||||
| //公共表,公摊总表,当前楼栋面积,当前楼层面积,总面积,店铺公摊系数 | //公共表,公摊总表,当前楼栋面积,当前楼层面积,总面积,店铺公摊系数 | ||||
| WxEnergyMeter mq = new WxEnergyMeter(); | WxEnergyMeter mq = new WxEnergyMeter(); | ||||
| mq.updateTenantInfo(record); | mq.updateTenantInfo(record); | ||||
| @@ -819,8 +819,6 @@ public class WxEnergyServiceImpl implements WxEnergyService { | |||||
| Integer pageSize) { | Integer pageSize) { | ||||
| PageInfo<WxEnergyReadingCalcute> page = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxEnergyReadingCalcuteMapper.findList(record)); | PageInfo<WxEnergyReadingCalcute> page = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxEnergyReadingCalcuteMapper.findList(record)); | ||||
| if (null != page && null != page.getList()) { | if (null != page && null != page.getList()) { | ||||
| WxEnergyFeesTime tq = new WxEnergyFeesTime(); | |||||
| tq.updateTenantInfo(record); | |||||
| WxEnergyFees fq = new WxEnergyFees(); | WxEnergyFees fq = new WxEnergyFees(); | ||||
| fq.updateTenantInfo(record); | fq.updateTenantInfo(record); | ||||
| Map<Long, WxEnergyFees> fessMap = this.getFeesMap(fq); | Map<Long, WxEnergyFees> fessMap = this.getFeesMap(fq); | ||||
| @@ -856,17 +854,13 @@ public class WxEnergyServiceImpl implements WxEnergyService { | |||||
| record.setShopSize(record.getShopIds().size()); | record.setShopSize(record.getShopIds().size()); | ||||
| record.setShop(JSON.toJSONString(record.getShopIds())); | record.setShop(JSON.toJSONString(record.getShopIds())); | ||||
| try { | try { | ||||
| // wxEnergyReadingCalcuteMapper.insert(record); | |||||
| // WxEnergyFees fees = this.getFeesById(record.getFeesId(),record.getTenantId()); | |||||
| // if (fees.getIsPublic() == EnumYesOrNo.YES.getCode()) { | |||||
| // | |||||
| // }else { | |||||
| // for (int i = 0 ; i < record.getShopIds().size() ; i ++) { | |||||
| // Long shopId = record.getShopIds().get(i); | |||||
| // WxEnergyReadingCalcuteResult cs = generateCalcuteResult(); | |||||
| // wxEnergyReadingCalcuteResultMapper.insert(cs); | |||||
| // } | |||||
| // } | |||||
| wxEnergyReadingCalcuteMapper.insert(record); | |||||
| 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); | |||||
| } | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("保存租赁账单失败,e:" + e.getMessage()); | logger.error("保存租赁账单失败,e:" + e.getMessage()); | ||||
| @@ -880,55 +874,141 @@ public class WxEnergyServiceImpl implements WxEnergyService { | |||||
| } | } | ||||
| } | } | ||||
| public void generateUserTypeCalcuteResult(WxEnergyFees fees,WxEnergyReadingCalcute record,List<Long> shopIds) { | |||||
| // for (int i = 0 ; i < shopIds.size(); i ++) { | |||||
| // Long shopId= shopIds.get(i); | |||||
| // //根据店铺,所属年月去查询时间区间.根据店铺,时间区间去查对应的抄表数据,根据表来计算总和 | |||||
| // WxEnergyFeesTimeShop sq = new WxEnergyFeesTimeShop(); | |||||
| // sq.updateTenantInfo(record); | |||||
| // sq.setShopId(shopId); | |||||
| // List<Long> timeIds = wxEnergyFeesTimeShopMapper.findTimeIdList(sq); | |||||
| // if (null == timeIds || timeIds.size() <= 0 ) { | |||||
| // return; | |||||
| // } | |||||
| // //一个年月,一个店铺应该只有一个周期 | |||||
| // WxEnergyFeesTime tq = new WxEnergyFeesTime(); | |||||
| // tq.updateTenantInfo(record); | |||||
| // tq.setIds(timeIds); | |||||
| // tq.setPeriod(record.getPeriod()); | |||||
| // List<WxEnergyFeesTime> timelist = wxEnergyFeesTimeMapper.findList(tq); | |||||
| // if (null == timelist || timelist.size() <= 0 ) { | |||||
| // return; | |||||
| // } | |||||
| // WxEnergyFeesTime time = timelist.get(0); | |||||
| // | |||||
| // //根据店铺查询计费标准 | |||||
| // WxEnergyFeesShop csq = new WxEnergyFeesShop(); | |||||
| // csq.updateTenantInfo(record); | |||||
| // csq.setShopId(shopId); | |||||
| // wxEnergyFeesCalcuteShopMapper.findCalcuteIdList(); | |||||
| // | |||||
| // //根据店铺去查询表 | |||||
| // WxEnergyMeter mq = new WxEnergyMeter(); | |||||
| // mq.updateTenantInfo(record); | |||||
| // mq.setType(fees.getType()); | |||||
| // mq.setPhysicsType(EnumEnergyMeterPhysicsType.USER.getCode()); | |||||
| // List<WxEnergyMeter> meterList = wxEnergyMeterMapper.findList(mq); | |||||
| // | |||||
| // WxEnergyReadingCalcuteResult cs = new WxEnergyReadingCalcuteResult(); | |||||
| // cs.updateTenantInfo(record); | |||||
| // cs.setId(idWorker.nextId()); | |||||
| // cs.setCalcuteId(record.getId()); | |||||
| // cs.setShopId(shopId); | |||||
| // cs.setCreateTime(date); | |||||
| // cs.setUpdateTime(date); | |||||
| // } | |||||
| public void generateCalcuteResult(WxEnergyFees fees,WxEnergyReadingCalcute record,List<Long> shopIds,EnumEnergyMeterPhysicsType type) { | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| List<WxEnergyReadingCalcuteResult> resultList = new ArrayList<WxEnergyReadingCalcuteResult>(); | |||||
| for (int i = 0 ; i < shopIds.size(); i ++) { | |||||
| Long shopId= shopIds.get(i); | |||||
| //根据店铺,所属年月去查询时间区间.根据店铺,时间区间去查对应的抄表数据,根据表来计算总和 | |||||
| WxEnergyFeesTimeShop sq = new WxEnergyFeesTimeShop(); | |||||
| sq.updateTenantInfo(record); | |||||
| sq.setShopId(shopId); | |||||
| List<Long> timeIds = wxEnergyFeesTimeShopMapper.findTimeIdList(sq); | |||||
| if (null == timeIds || timeIds.size() <= 0 ) { | |||||
| return; | |||||
| } | |||||
| //一个年月,一个店铺应该只有一个周期 | |||||
| WxEnergyFeesTime tq = new WxEnergyFeesTime(); | |||||
| tq.updateTenantInfo(record); | |||||
| tq.setIds(timeIds); | |||||
| tq.setPeriod(record.getPeriod()); | |||||
| List<WxEnergyFeesTime> timelist = wxEnergyFeesTimeMapper.findList(tq); | |||||
| if (null == timelist || timelist.size() <= 0 ) { | |||||
| return; | |||||
| } | |||||
| WxEnergyFeesTime time = timelist.get(0); | |||||
| //根据店铺查询绑定的科目 | |||||
| WxEnergyFeesShop csq = new WxEnergyFeesShop(); | |||||
| csq.updateTenantInfo(record); | |||||
| csq.setShopId(shopId); | |||||
| List<WxEnergyFeesShop> shopFeesList = wxEnergyFeesShopMapper.findList(csq); | |||||
| if (null == shopFeesList || shopFeesList.size() <= 0 ) { | |||||
| 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 ++) { | |||||
| 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); | |||||
| } | |||||
| } | |||||
| } | |||||
| if (resultList.size() > 0 ) { | |||||
| wxEnergyReadingCalcuteResultMapper.insertResults(record.getTenantId(),resultList); | |||||
| } | |||||
| } | } | ||||
| @Override | @Override | ||||
| public WxEnergyReadingCalcute getReadingCalcuteById(WxEnergyReadingCalcute record) { | |||||
| return wxEnergyReadingCalcuteMapper.selectById(record.getId(), record.getTenantId()); | |||||
| } | |||||
| public PageInfo<WxEnergyReadingCalcuteResult> readingCalcuteResultListAsPage(WxEnergyReadingCalcuteResult record, Integer pageIndex, | |||||
| Integer pageSize) { | |||||
| PageInfo<WxEnergyReadingCalcuteResult> page = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxEnergyReadingCalcuteResultMapper.findList(record)); | |||||
| if (null != page && null != page.getList()) { | |||||
| WxEnergyFees fq = new WxEnergyFees(); | |||||
| fq.updateTenantInfo(record); | |||||
| Map<Long, WxEnergyFees> fessMap = this.getFeesMap(fq); | |||||
| Map<Long, String> floorMap = wxMallFloorService.getFloorMap(record); | |||||
| Map<Long, String> buildingMap = wxMallBuildingService.getBuildingMap(record); | |||||
| List<Long> meterIdList = new ArrayList<Long>(); | |||||
| List<Long> shopIdList = new ArrayList<Long>(); | |||||
| for (int i = 0 ; i < page.getList().size(); i++) { | |||||
| WxEnergyReadingCalcuteResult c = page.getList().get(i); | |||||
| if (null != fessMap) { | |||||
| WxEnergyFees fees = fessMap.get(c.getFeesId()); | |||||
| if (null != fees) { | |||||
| c.setFeesName(fees.getName()); | |||||
| } | |||||
| } | |||||
| if (null != c.getMeterId()) { | |||||
| meterIdList.add(c.getMeterId()); | |||||
| } | |||||
| 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; | |||||
| 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++) { | |||||
| 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()) { | |||||
| 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 | @Override | ||||
| public void exportReadingCalcute(WxEnergyReadingCalcute record, HttpServletRequest request, HttpServletResponse response) { | public void exportReadingCalcute(WxEnergyReadingCalcute record, HttpServletRequest request, HttpServletResponse response) { | ||||
| @@ -1053,63 +1133,6 @@ public class WxEnergyServiceImpl implements WxEnergyService { | |||||
| } | } | ||||
| @Override | |||||
| public void importReadingCalcute(MultipartFile mFile, MallUserInfo user, HttpServletRequest request, | |||||
| HttpServletResponse response) { | |||||
| // File file = handlerImportFile(mFile,"energyReading"); | |||||
| // // 需要验证 | |||||
| // Map<String,String> excelTitle = WxEnergyMeterReading.generateExcelTitle(); | |||||
| // String[] needFields = new String[excelTitle.size()]; | |||||
| // int index = 0; | |||||
| // for (Iterator<String> it = excelTitle.keySet().iterator(); it.hasNext();) { | |||||
| // String fi = excelTitle.get(it.next()); | |||||
| // needFields[index] = fi; | |||||
| // index = index + 1; | |||||
| // } | |||||
| // ExcelImportResult<Map> datalist = handleImportFile(file,Map.class,needFields,needFields,new ReadingExcelHandler()); | |||||
| // if (null == datalist) { | |||||
| // return ; | |||||
| // } | |||||
| // | |||||
| // List<Map> successList = datalist.getList(); | |||||
| // if(successList.size() > 0) { | |||||
| // boolean allSuccess = true; | |||||
| // String cuteId = (String)successList.get(0).get("编码"); | |||||
| // try { | |||||
| // successList.parallelStream().forEach(reading -> { | |||||
| // String id = (String) reading.get("抄表数据编码"); | |||||
| // WxEnergyMeterReading r = new WxEnergyMeterReading(); | |||||
| // r.updateTenantInfo(user); | |||||
| // r.setId(Long.parseLong(id)); | |||||
| // r.setPrice((String)reading.get("单价(*)")); | |||||
| // r.setCurNumber((String)reading.get("本次抄表数")); | |||||
| // r.setUpdateBy(user.getId()); | |||||
| // r.setUpdateByName(user.getName()); | |||||
| // r.setUpdateTime(new Date()); | |||||
| // wxEnergyMeterReadingMapper.updateById(r); | |||||
| // }); | |||||
| // } catch (Exception e) { | |||||
| // logger.error("导入模板失败:"+e.getMessage(),e); | |||||
| // allSuccess = false; | |||||
| // } | |||||
| // if (StringUtils.isNotBlank(cuteId)) { | |||||
| // WxEnergyReadingCalcute c= new WxEnergyReadingCalcute(); | |||||
| // c.updateTenantInfo(user); | |||||
| // c.setId(Long.parseLong(cuteId)); | |||||
| // c.setIsImported(EnumYesOrNo.YES.getCode()); | |||||
| // c.setUpdateTime(new Date()); | |||||
| // c.setUpdateBy(user.getId()); | |||||
| // c.setUpdateByName(user.getName()); | |||||
| // if (allSuccess) { | |||||
| // c.setImportSuccess(EnumYesOrNo.YES.getCode()); | |||||
| // }else { | |||||
| // c.setImportSuccess(EnumYesOrNo.NO.getCode()); | |||||
| // } | |||||
| // wxEnergyReadingCalcuteMapper.updateById(c); | |||||
| // } | |||||
| // | |||||
| // } | |||||
| } | |||||
| private Map<Long,String> getFloorBuildingMoney(WxEnergyMeterReading reading,boolean isFloor) { | private Map<Long,String> getFloorBuildingMoney(WxEnergyMeterReading reading,boolean isFloor) { | ||||
| // List<Map> list = null; | // List<Map> list = null; | ||||
| @@ -1338,11 +1361,11 @@ public class WxEnergyServiceImpl implements WxEnergyService { | |||||
| @Override | @Override | ||||
| public void setReadingCalcuteIsDel(WxEnergyReadingCalcute record) { | public void setReadingCalcuteIsDel(WxEnergyReadingCalcute record) { | ||||
| WxEnergyReadingCalcute calcute = this.getReadingCalcuteById(record); | |||||
| if (null == calcute) { | |||||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "记录未查询到"); | |||||
| } | |||||
| wxEnergyReadingCalcuteMapper.setIsDel(record.getId(), record.getTenantId(), record.getIsDel()); | |||||
| // WxEnergyReadingCalcute calcute = this.getReadingCalcuteById(record); | |||||
| // if (null == calcute) { | |||||
| // throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "记录未查询到"); | |||||
| // } | |||||
| // wxEnergyReadingCalcuteMapper.setIsDel(record.getId(), record.getTenantId(), record.getIsDel()); | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -10,14 +10,14 @@ | |||||
| <result column="calcute_id" jdbcType="BIGINT" property="calcuteId"/> | <result column="calcute_id" jdbcType="BIGINT" property="calcuteId"/> | ||||
| <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_calcute_id" jdbcType="BIGINT" property="feesCalcuteId"/> | |||||
| <result column="fees_shop_id" jdbcType="BIGINT" property="feesShopId"/> | |||||
| <result column="meter_id" jdbcType="BIGINT" property="meterId"/> | <result column="meter_id" jdbcType="BIGINT" property="meterId"/> | ||||
| <result column="reading_id" jdbcType="BIGINT" property="readingId"/> | |||||
| <result column="money" jdbcType="VARCHAR" property="money" /> | <result column="money" jdbcType="VARCHAR" property="money" /> | ||||
| <result column="period" jdbcType="VARCHAR" property="period" /> | |||||
| </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_calcute_id`,`meter_id`,`reading_id`,`money` | |||||
| `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`calcute_id`,`shop_id`,`fees_id`,`fees_shop_id`,`meter_id`,`money`,`period` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -29,12 +29,14 @@ | |||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | <if test=" null != parentTenantId and '' != parentTenantId"> | ||||
| and `parent_tenant_id` = #{parentTenantId} | and `parent_tenant_id` = #{parentTenantId} | ||||
| </if> | </if> | ||||
| <if test=" null != period and '' != period"> | |||||
| and `period` = #{period} | |||||
| </if> | |||||
| <if test=" null != calcuteId ">and `calcute_id` = #{calcuteId}</if> | <if test=" null != calcuteId ">and `calcute_id` = #{calcuteId}</if> | ||||
| <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 != feesCalcuteId ">and `fees_calcute_id` = #{feesCalcuteId}</if> | |||||
| <if test=" null != feesShopId ">and `fees_shop_id` = #{feesShopId}</if> | |||||
| <if test=" null != meterId ">and `meter_id` = #{meterId}</if> | <if test=" null != meterId ">and `meter_id` = #{meterId}</if> | ||||
| <if test=" null != readingId ">and `reading_id` = #{readingId}</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=")"> | ||||
| @@ -63,5 +65,18 @@ | |||||
| <include refid="dynamicWhereConditions"/> | <include refid="dynamicWhereConditions"/> | ||||
| </select> | </select> | ||||
| <insert id="insertResults" parameterType="HashMap"> | |||||
| INSERT INTO wx_energy_reading_calcute_result ( | |||||
| <include refid="allColumns"/> | |||||
| ) | |||||
| VALUES | |||||
| <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.meterId},#{item.money},#{item.period} | |||||
| ) | |||||
| </foreach> | |||||
| </insert> | |||||
| </mapper> | </mapper> | ||||