|
@@ -4,10 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.huaxu.common.StringUtils;
|
|
import com.huaxu.common.StringUtils;
|
|
import com.huaxu.dto.*;
|
|
import com.huaxu.dto.*;
|
|
-import com.huaxu.entity.AlarmSetting;
|
|
|
|
-import com.huaxu.entity.MonthRevenueEntity;
|
|
|
|
-import com.huaxu.entity.MonthSellwaterEntity;
|
|
|
|
-import com.huaxu.entity.SceneEntity;
|
|
|
|
|
|
+import com.huaxu.entity.*;
|
|
import com.huaxu.model.AjaxMessage;
|
|
import com.huaxu.model.AjaxMessage;
|
|
import com.huaxu.model.LoginUser;
|
|
import com.huaxu.model.LoginUser;
|
|
import com.huaxu.model.Pagination;
|
|
import com.huaxu.model.Pagination;
|
|
@@ -15,6 +12,8 @@ import com.huaxu.model.ResultStatus;
|
|
import com.huaxu.service.AlarmSettingService;
|
|
import com.huaxu.service.AlarmSettingService;
|
|
import com.huaxu.service.RevenueService;
|
|
import com.huaxu.service.RevenueService;
|
|
import com.huaxu.service.SceneService;
|
|
import com.huaxu.service.SceneService;
|
|
|
|
+import com.huaxu.service.WaterPropertyService;
|
|
|
|
+import com.huaxu.util.ExcelUtil;
|
|
import com.huaxu.util.OrgInfoUtil;
|
|
import com.huaxu.util.OrgInfoUtil;
|
|
import com.huaxu.util.UserUtil;
|
|
import com.huaxu.util.UserUtil;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
@@ -26,9 +25,11 @@ import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.client.RestTemplate;
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.Calendar;
|
|
import java.util.Calendar;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 营收控制层
|
|
* 营收控制层
|
|
@@ -51,9 +52,12 @@ public class RevenueController {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private RestTemplate restTemplate;
|
|
private RestTemplate restTemplate;
|
|
- @Value("${http_pool.meterRequesturl}")
|
|
|
|
- private String meterRequestUrl;
|
|
|
|
|
|
|
|
|
|
+ @Value("${SMS.sys_excel_path}")
|
|
|
|
+ private String baseDir;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private WaterPropertyService waterPropertyService;
|
|
/**
|
|
/**
|
|
* 查询本月售水信息
|
|
* 查询本月售水信息
|
|
*
|
|
*
|
|
@@ -135,7 +139,7 @@ public class RevenueController {
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
|
monthRevenueDto.setCollectDate(sdf.parse(monthRevenueDto.getCollectDateString()));
|
|
monthRevenueDto.setCollectDate(sdf.parse(monthRevenueDto.getCollectDateString()));
|
|
monthRevenueDto.setTenantId(loginUser.getTenantId());
|
|
monthRevenueDto.setTenantId(loginUser.getTenantId());
|
|
- convertWRevenue(monthRevenueDto);
|
|
|
|
|
|
+ oneConvertWan(monthRevenueDto);
|
|
revenueService.insert(monthRevenueDto);
|
|
revenueService.insert(monthRevenueDto);
|
|
//插入售水数据
|
|
//插入售水数据
|
|
for (MonthSellwaterEntity entity : monthRevenueDto.getMonthSellList()) {
|
|
for (MonthSellwaterEntity entity : monthRevenueDto.getMonthSellList()) {
|
|
@@ -166,7 +170,7 @@ public class RevenueController {
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
//修改营收数据
|
|
//修改营收数据
|
|
monthRevenueDto.setUpdateBy(loginUser.getUsername());
|
|
monthRevenueDto.setUpdateBy(loginUser.getUsername());
|
|
- convertWRevenue(monthRevenueDto);
|
|
|
|
|
|
+ oneConvertWan(monthRevenueDto);
|
|
revenueService.updateRevenue(monthRevenueDto);
|
|
revenueService.updateRevenue(monthRevenueDto);
|
|
//修改售水数据
|
|
//修改售水数据
|
|
for (MonthSellwaterEntity entity : monthRevenueDto.getMonthSellList()) {
|
|
for (MonthSellwaterEntity entity : monthRevenueDto.getMonthSellList()) {
|
|
@@ -186,7 +190,7 @@ public class RevenueController {
|
|
* 将营收数据转换成万
|
|
* 将营收数据转换成万
|
|
*
|
|
*
|
|
*/
|
|
*/
|
|
- public void convertWRevenue(MonthRevenueDto monthRevenueDto){
|
|
|
|
|
|
+ public void oneConvertWan(MonthRevenueDto monthRevenueDto){
|
|
if(monthRevenueDto.getBigUserUsage() != null){
|
|
if(monthRevenueDto.getBigUserUsage() != null){
|
|
monthRevenueDto.setBigUserUsage(monthRevenueDto.getBigUserUsage()/10000);
|
|
monthRevenueDto.setBigUserUsage(monthRevenueDto.getBigUserUsage()/10000);
|
|
}
|
|
}
|
|
@@ -224,4 +228,93 @@ public class RevenueController {
|
|
List<MonthRevenueDto> result = revenueService.selectList(monthRevenueDto);
|
|
List<MonthRevenueDto> result = revenueService.selectList(monthRevenueDto);
|
|
return new AjaxMessage<>(ResultStatus.OK, result);
|
|
return new AjaxMessage<>(ResultStatus.OK, result);
|
|
}
|
|
}
|
|
|
|
+ /**
|
|
|
|
+ * 分页查询营收数据列表
|
|
|
|
+ *
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping(value = "selectPage", method = RequestMethod.GET)
|
|
|
|
+ @ApiOperation(value = "分页查询营收数据列表")
|
|
|
|
+ public AjaxMessage<Pagination<MonthRevenueDto>> selectPage(
|
|
|
|
+ @ApiParam(value = "页数", required = true) @RequestParam Integer pageNum,
|
|
|
|
+ @ApiParam(value = "条数", required = true) @RequestParam Integer pageSize,
|
|
|
|
+ @ApiParam(value = "公司机构id", required = true)@RequestParam Integer companyOrgId,
|
|
|
|
+ @ApiParam(value = "开始日期(yyyy-MM)", required = true)@RequestParam String startDate,
|
|
|
|
+ @ApiParam(value = "结束日期(yyyy-MM)", required = true)@RequestParam String endDate) {
|
|
|
|
+ MonthRevenueDto monthRevenueDto=new MonthRevenueDto();
|
|
|
|
+ monthRevenueDto.setCompanyOrgId(companyOrgId);
|
|
|
|
+ monthRevenueDto.setStartDate(startDate);
|
|
|
|
+ monthRevenueDto.setEndDate(endDate);
|
|
|
|
+ List<MonthRevenueDto> result = revenueService.selectList(monthRevenueDto);
|
|
|
|
+ Pagination<MonthRevenueDto> pages = new Pagination<>();
|
|
|
|
+ pages.setTotal(result.size());
|
|
|
|
+ pages.setList(result.size()>0?result.subList((pageNum-1)*pageSize,pageNum*pageSize):null);
|
|
|
|
+ return new AjaxMessage<>(ResultStatus.OK, pages);
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 导出营收数据
|
|
|
|
+ *
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping(value = "reportList", method = RequestMethod.GET)
|
|
|
|
+ @ApiOperation(value = "导出营收数据")
|
|
|
|
+ public AjaxMessage<String> reportList(
|
|
|
|
+ @ApiParam(value = "公司机构id", required = true)@RequestParam Integer companyOrgId,
|
|
|
|
+ @ApiParam(value = "开始日期(yyyy-MM)", required = true)@RequestParam String startDate,
|
|
|
|
+ @ApiParam(value = "结束日期(yyyy-MM)", required = true)@RequestParam String endDate) {
|
|
|
|
+ MonthRevenueDto monthRevenueDto=new MonthRevenueDto();
|
|
|
|
+ monthRevenueDto.setCompanyOrgId(companyOrgId);
|
|
|
|
+ monthRevenueDto.setStartDate(startDate);
|
|
|
|
+ monthRevenueDto.setEndDate(endDate);
|
|
|
|
+ List<MonthRevenueDto> result = revenueService.selectList(monthRevenueDto);
|
|
|
|
+ List<WaterPropertyEntity> waterPropertyList=waterPropertyService.select(companyOrgId);
|
|
|
|
+
|
|
|
|
+ String[] title={"NO.","时间","售水(m³):总售水","应收(元):总计","应收(元):大用户","应收(元):普通用户","实收(元):总计","实收(元):大用户","实收(元):普通用户"};
|
|
|
|
+ List<List<String>> reportTitle =new ArrayList<>();
|
|
|
|
+ for(String item : title){
|
|
|
|
+ List<String> list=new ArrayList<>();
|
|
|
|
+ if(item.contains(":")){
|
|
|
|
+ list.add(item.split(":")[0]);
|
|
|
|
+ list.add(item.split(":")[1]);
|
|
|
|
+ reportTitle.add(list);
|
|
|
|
+ if(item.contains("售水")){
|
|
|
|
+ for(WaterPropertyEntity water :waterPropertyList){
|
|
|
|
+ list=new ArrayList<>();
|
|
|
|
+ list.add(item.split(":")[0]);
|
|
|
|
+ list.add(water.getPropertyName());
|
|
|
|
+ reportTitle.add(list);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ list.add(item);
|
|
|
|
+ reportTitle.add(list);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ int no=1;
|
|
|
|
+ List<List<String>> excelResult=new ArrayList<>();
|
|
|
|
+ for(MonthRevenueDto item : result){
|
|
|
|
+ List<String> datalist=new ArrayList<>();
|
|
|
|
+ datalist.add(String.valueOf(no++));
|
|
|
|
+ datalist.add(item.getCollectDateString());
|
|
|
|
+ datalist.add(String.valueOf(item.getMeterReadingUsage()));
|
|
|
|
+ for(WaterPropertyEntity water :waterPropertyList){
|
|
|
|
+ List<MonthSellwaterEntity> sellWaterList = item.getMonthSellList().stream().filter((MonthSellwaterEntity m)
|
|
|
|
+ -> m.getPropertyId().equals(water.getId())).collect(Collectors.toList());
|
|
|
|
+ if(sellWaterList.size()>0){
|
|
|
|
+ datalist.add(sellWaterList.get(0).getWaterUsage()==null?"-":String.valueOf(sellWaterList.get(0).getWaterUsage()));
|
|
|
|
+ }else{
|
|
|
|
+ datalist.add("-");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ datalist.add(String.valueOf(item.getReceivableTotalAmount()));
|
|
|
|
+ datalist.add(String.valueOf(item.getBigUserUsage()));
|
|
|
|
+ datalist.add(String.valueOf(item.getGeneralUserUsage()));
|
|
|
|
+ datalist.add(String.valueOf(item.getReceivedTotalAmount()));
|
|
|
|
+ datalist.add(String.valueOf(item.getBigUserUsageReceived()));
|
|
|
|
+ datalist.add(String.valueOf(item.getGeneralUserUsageReceived()));
|
|
|
|
+ excelResult.add(datalist);
|
|
|
|
+ }
|
|
|
|
+ String filePath = ExcelUtil.writeSimpleExcelWithHeader(baseDir,"营收报表",reportTitle,excelResult);
|
|
|
|
+ return new AjaxMessage<>(ResultStatus.OK, filePath);
|
|
|
|
+ }
|
|
}
|
|
}
|