作者 kgy

代码整理

正在显示 36 个修改的文件 包含 1968 行增加1684 行删除
... ... @@ -142,21 +142,11 @@
<artifactId>beetl</artifactId>
<version>3.1.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-typehandlers-jsr310</artifactId>
<version>1.0.2</version>
</dependency>
<!-- 分页助手启动器 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
<version>2.1.1</version>
<scope>runtime</scope>
</dependency>
</dependencies>
... ...
... ... @@ -41,17 +41,21 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<!-- SpringBoot 拦截器 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<!--单元测试-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<!--redis-->
<!--安全校验-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<!-- mysql驱动 -->
<dependency>
<groupId>mysql</groupId>
... ... @@ -73,10 +77,6 @@
<artifactId>java-jwt</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<!-- hutool util -->
<dependency>
<groupId>cn.hutool</groupId>
... ...
... ... @@ -23,8 +23,6 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@EnableAsync
@MapperScan("com.synthesize_energy.item.mapper")
@SpringBootApplication
@EnableTransactionManagement
@EnableCaching //开启缓存
public class SynthesizeEnergyApiApplication {
public static void main(String[] args) {
... ...
package com.synthesize_energy.item.cache;
/**
* @author kgy0809@163.com
* @version 1.0
* @date 2020/7/20 11:02
* @description 缓存
*/
public interface Cache {
<T> T get(String key, Class<T> clazz);
void put(String key, Object value);
void remove(String key);
}
... ... @@ -6,6 +6,7 @@ import com.synthesize_energy.common.domain.BusinessException;
import com.synthesize_energy.common.domain.CommonErrorCode;
import com.synthesize_energy.item.entity.User;
import com.synthesize_energy.item.utils.JwtUtil;
import com.synthesize_energy.item.utils.UserContext;
import com.synthesize_energy.item.web.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -28,7 +29,6 @@ public class AuthenticationInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object object) {
log.info("-------------------- 方法进入 -----------------------");
String token = httpServletRequest.getHeader("token");// 从 http 请求头中取出 token
// 如果不是映射到方法直接通过
if (!(object instanceof HandlerMethod)) {
... ... @@ -37,28 +37,24 @@ public class AuthenticationInterceptor implements HandlerInterceptor {
// 执行认证
if (token == null) {
log.info("-------------------- token 为空 -----------------------");
throw new BusinessException(CommonErrorCode.E_999990);
}
// 获取 token 中的 user id
String userId;
try {
userId = JWT.decode(token).getAudience().get(0);
log.info("-------------------- 用户登录 -----------------------",userId);
} catch (JWTDecodeException j) {
log.info("-------------------- token 被串改 发生错误 -----------------------");
throw new BusinessException(CommonErrorCode.E_999993);
}
User user = userService.getById(userId);
if (user == null) {
log.info("-------------------- 用户为空 -----------------------",user,userId);
throw new BusinessException(CommonErrorCode.E_999993);
}else {
} else {
UserContext.set(user);
/**
* 查看是否被禁用
*/
if ("2".equals(user.getState())){
log.info("-------------------- 用户被禁用 -----------------------",user,userId);
if ("2".equals(user.getState())) {
throw new BusinessException(CommonErrorCode.E_999994);
}
/**
... ... @@ -69,7 +65,6 @@ public class AuthenticationInterceptor implements HandlerInterceptor {
}
// 验证 token
if (!JwtUtil.verity(token)) {
log.info("-------------------- token失效了 -----------------------",user,userId);
throw new BusinessException(CommonErrorCode.E_999993);
}
return true;
... ... @@ -86,5 +81,7 @@ public class AuthenticationInterceptor implements HandlerInterceptor {
public void afterCompletion(HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse,
Object o, Exception e) throws Exception {
UserContext.remove();
log.warn("方法执行完毕 ThreadLocal 进行销毁");
}
}
\ No newline at end of file
... ...
... ... @@ -17,7 +17,7 @@ public class CorsFilter implements Filter {
res.addHeader("Access-Control-Allow-Credentials", "true");
res.addHeader("Access-Control-Allow-Origin", "*");
res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
res.addHeader("Access-Control-Allow-Headers", "Content-Type,X-CAF-Authorization-Token,sessionToken,X-TOKEN");
res.addHeader("Access-Control-Allow-Headers", "Content-Type,X-CAF-Authorization-Token,sessionToken,X-TOKEN,token");
if (((HttpServletRequest) request).getMethod().equals("OPTIONS")) {
response.getWriter().println("ok");
return;
... ...
... ... @@ -6,13 +6,6 @@ import org.springframework.context.annotation.Configuration;
@Configuration
public class MybatisPlusConfig {
/**
* mybatis-plus SQL执行效率插件【生产环境可以关闭】
*/
/* @Bean
public PerformanceInterceptor performanceInterceptor() {
return new PerformanceInterceptor();
}*/
/**
* 分页插件
... ...
package com.synthesize_energy.item.event;
import com.synthesize_energy.item.entity.Synthesize_no_2_1;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.List;
/**
* @author kgy
* @version 1.0
* @date 2020/10/27 11:26
*/
@Data
@AllArgsConstructor
public class No2_1SaveEvent {
private List<Synthesize_no_2_1> synthesize_no_2_1s;
}
... ...
package com.synthesize_energy.item.listener;
import com.synthesize_energy.item.entity.Synthesize_no_2_1;
import com.synthesize_energy.item.entity.Synthesize_no_2_1New;
import com.synthesize_energy.item.event.No2_1SaveEvent;
import com.synthesize_energy.item.web.service.Synthesize_no_2_6Service;
import lombok.AllArgsConstructor;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* @author kgy
* @version 1.0
* @date 2020/10/27 11:25
*/
@Component("defaultNo2_1SaveListener")
@AllArgsConstructor
public class No2_1SaveListener {
private final Synthesize_no_2_6Service synthesize_no_2_6Service;
@EventListener(No2_1SaveEvent.class)
public void defaultNo2_1SaveListener(No2_1SaveEvent event) {
List<Synthesize_no_2_1> synthesize_no_2_1s = event.getSynthesize_no_2_1s();
/**
* 对数据进行判断
*/
for (Synthesize_no_2_1 synthesize_no_2_1 : synthesize_no_2_1s) {
Map<String, Object> buildingTypeToIndex = synthesize_no_2_6Service.getBuildingTypeToIndex(synthesize_no_2_1.getBuildingTypeId(), synthesize_no_2_1.getPid());
if (Objects.isNull(synthesize_no_2_1.getDesignElectricLoadIndex())) {
synthesize_no_2_1.setDesignElectricLoadIndex(Double.valueOf(buildingTypeToIndex.get("designElectricLoadIndex").toString()));
}
if (Objects.isNull(synthesize_no_2_1.getDesignHeatLoadIndex())) {
synthesize_no_2_1.setDesignHeatLoadIndex(Double.valueOf(buildingTypeToIndex.get("designHeatLoadIndex").toString()));
}
if (Objects.isNull(synthesize_no_2_1.getDesignCoolingLoadIndex())) {
synthesize_no_2_1.setDesignCoolingLoadIndex(Double.valueOf(buildingTypeToIndex.get("designCoolingLoadIndex").toString()));
}
if (Objects.isNull(synthesize_no_2_1.getHotWaterQuota())) {
synthesize_no_2_1.setHotWaterQuota(Double.valueOf(buildingTypeToIndex.get("hotWaterQuota").toString()));
}
}
}
}
... ...
package com.synthesize_energy.item.utils;
import com.synthesize_energy.item.entity.User;
import org.springframework.util.Assert;
/**
* @author kgy0809@163.com
* @version 1.0
* @date 2020/7/27 10:38
* @description 使用线程上下文在线程内共享用户信息
*/
public class UserContext {
/**
* 把构造函数私有化,外部不能new
*/
private UserContext() {
}
private static final ThreadLocal<User> context = new ThreadLocal<User>();
/**
* 存放用户信息
*
* @param user
*/
public static void set(User user) {
context.set(user);
}
/**
* 获取用户信息
*
* @return
*/
public static User get() {
User user = context.get();
Assert.notNull(user,"请先去登录授权");
return user;
}
/**
* 清除当前线程内引用,防止内存泄漏
*/
public static void remove() {
context.remove();
}
}
... ...
... ... @@ -21,7 +21,6 @@ import javax.servlet.http.HttpServletResponse;
@Slf4j
public class GlobalExceptionHandler {
private final static Logger LOGGER = LoggerFactory.getLogger(GlobalExceptionHandler.class);
@ExceptionHandler(value = Exception.class)
@ResponseBody
... ...
... ... @@ -5,11 +5,13 @@ import com.synthesize_energy.common.domain.PageVO;
import com.synthesize_energy.common.domain.RestResponse;
import com.synthesize_energy.item.entity.Synthesize_no_1;
import com.synthesize_energy.item.utils.JwtUtil;
import com.synthesize_energy.item.utils.UserContext;
import com.synthesize_energy.item.web.service.No_1Service;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
... ... @@ -27,12 +29,10 @@ import java.util.List;
@RestController
@RequestMapping("index")
@Api(value = "首页信息接口查询", tags = "首页信息接口查询")
@AllArgsConstructor
public class IndexController {
@Autowired
private No_1Service no_1Service;
@Autowired
private HttpServletRequest request;
private final No_1Service no_1Service;
@PostMapping
@ApiOperation(value = "未立项查询", notes = "未立项查询")
... ... @@ -48,10 +48,7 @@ public class IndexController {
@RequestParam(value = "type", required = false, defaultValue = "1") String type,
@RequestParam(value = "name", required = false) String name
) {
String userId = JwtUtil.getUserId(request.getHeader("token"));
IPage<Synthesize_no_1> page1 = no_1Service.queryByList(page, rows, name, userId, type);
if (StringUtils.isEmpty(page1))
return new PageVO<>();
IPage<Synthesize_no_1> page1 = no_1Service.queryByList(page, rows, name, type);
return new PageVO<>(page1.getRecords(), page1.getTotal(), page, rows);
}
... ... @@ -65,7 +62,7 @@ public class IndexController {
@RequestParam("type") String type,
@RequestParam("ids") String ids
) {
no_1Service.settingType(type, ids, JwtUtil.getUserId(request.getHeader("token")));
no_1Service.settingType(type, ids);
return RestResponse.success("设置成功");
}
... ...
package com.synthesize_energy.item.web.controller;
import com.google.common.collect.Lists;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.synthesize_energy.common.domain.BusinessException;
import com.synthesize_energy.common.domain.CommonErrorCode;
import com.synthesize_energy.common.domain.PageVO;
import com.synthesize_energy.common.domain.RestResponse;
import com.synthesize_energy.item.dto.ElectrovalenceDto;
import com.synthesize_energy.item.dto.Electrovalence_1Dto;
import com.synthesize_energy.item.dto.No_3_1Dto;
import com.synthesize_energy.item.entity.*;
import com.synthesize_energy.item.mapper.*;
import com.synthesize_energy.item.utils.JwtUtil;
import com.synthesize_energy.item.web.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
/**
... ... @@ -36,40 +25,14 @@ import java.util.*;
@RestController
@RequestMapping("informationBase")
@Api(value = "信息库接口", tags = "信息库接口")
@AllArgsConstructor
public class InformationBase {
@Autowired
private No_1Service no_1Service;
@Autowired
private HttpServletRequest request;
@Autowired
private Synthesize_no_1ImgMapper synthesize_no_1ImgMapper;
@Autowired
private Synthesize_no_2_1Service synthesize_no_2_1Service;
@Autowired
private Synthesize_no_2_2Service synthesize_no_2_2Service;
@Autowired
private Synthesize_no_2_3Service synthesize_no_2_3Service;
@Autowired
private Synthesize_no_2_4Service synthesize_no_2_4Service;
@Autowired
private Synthesize_no_2_5Service synthesize_no_2_5Service;
@Autowired
private Synthesize_no_2_6Service synthesize_no_2_6Service;
@Autowired
private Synthesize_no_3_6Service synthesize_no_3_6Service;
@Autowired
private CityDictService cityDictService;
@Autowired
private ElectrovalenceMapper electrovalenceMapper;
@Autowired
private EnergySourcesMapper energySourcesMapper;
@Autowired
private ProvinceDictMapper provinceDictMapper;
@Autowired
private ProjectService projectService;
@Autowired
private InformationBaseService informationBaseService;
private final ProjectService projectService;
private final InformationBaseService informationBaseService;
private final UploadService uploadService;
@PostMapping("query/case")
@ApiOperation(value = "典型案例查询", notes = "典型案例查询", response = Synthesize_no_1.class)
... ... @@ -78,16 +41,12 @@ public class InformationBase {
@ApiImplicitParam(name = "rows", required = true, value = "10", dataType = "int"),
@ApiImplicitParam(name = "name", required = false, value = "搜索关键字", dataType = "String")
})
public PageVO<Synthesize_no_1> queryCase(
public PageVO<Synthesize_no_1> typicalCaseQuery(
@RequestParam("page") Integer page,
@RequestParam("rows") Integer rows,
@RequestParam(value = "name", required = false) String name
) {
IPage<Synthesize_no_1> iPage = no_1Service.page(new Page<>(page, rows), new QueryWrapper<Synthesize_no_1>()
.lambda()
.eq(Synthesize_no_1::getModelCase, "1")
.like(!StringUtils.isEmpty(name), Synthesize_no_1::getProjectName, name)
.orderByDesc(Synthesize_no_1::getTime));
IPage<Synthesize_no_1> iPage = informationBaseService.typicalCaseQuery(page, rows, name);
return new PageVO<>(iPage.getRecords(), iPage.getTotal(), page, rows);
}
... ... @@ -101,83 +60,17 @@ public class InformationBase {
@RequestParam("id") String id,
@RequestParam("image") String image
) {
Synthesize_no_1 synthesize_no_1 = no_1Service.getById(id);
synthesize_no_1.setImageUrl(image);
no_1Service.updateById(synthesize_no_1);
uploadService.typicalCaseUploadImage(id, image);
return RestResponse.success("上传成功");
}
@Autowired
private CalculateLoadMapper calculateLoadMapper;
@GetMapping("copy/project/{ids}")
@ApiOperation(value = "复制典型案例到自己项目", notes = "复制典型案例到自己项目")
@ApiImplicitParams({
@ApiImplicitParam(name = "ids", required = true, value = "复制项目的ids字符串拼接", dataType = "String")
})
public RestResponse<String> copyProject(@PathVariable("ids") String ids) {
String[] split = ids.split(",");
for (String s : split) {
Synthesize_no_1 synthesize_no_1 = no_1Service.getById(s);
synthesize_no_1.setId(null);
synthesize_no_1.setTime(new Date());
synthesize_no_1.setNewTime(new Date());
synthesize_no_1.setType("1");
synthesize_no_1.setUserId(JwtUtil.getUserId(request.getHeader("token")));
synthesize_no_1.setDeleteState("3");
synthesize_no_1.setModelCase(null);
no_1Service.save(synthesize_no_1);
Synthesize_no_1Img synthesize_no_1Img = synthesize_no_1ImgMapper.selectById(s);
if (!StringUtils.isEmpty(synthesize_no_1Img)) {
synthesize_no_1Img.setId(synthesize_no_1.getId());
synthesize_no_1ImgMapper.insert(synthesize_no_1Img);
}
List<Synthesize_no_2_1> list = synthesize_no_2_1Service.list(new QueryWrapper<Synthesize_no_2_1>().lambda().eq(Synthesize_no_2_1::getPid, s));
if (!list.isEmpty()) {
for (Synthesize_no_2_1 synthesize_no_2_1 : list) {
CalculateLoad calculateLoad = calculateLoadMapper.selectById(synthesize_no_2_1.getId());
synthesize_no_2_1.setId(null);
synthesize_no_2_1.setPid(synthesize_no_1.getId());
synthesize_no_2_1Service.save(synthesize_no_2_1);
if (!StringUtils.isEmpty(calculateLoad)){
calculateLoad.setId(synthesize_no_2_1.getId());
calculateLoad.setCid(synthesize_no_1.getId());
calculateLoadMapper.insert(calculateLoad);
}
}
}
Synthesize_no_2_2 synthesize_no_2_2 = synthesize_no_2_2Service.getById(s);
if (!StringUtils.isEmpty(synthesize_no_2_2)) {
synthesize_no_2_2.setId(synthesize_no_1.getId());
synthesize_no_2_2Service.save(synthesize_no_2_2);
}
Synthesize_no_2_3 synthesize_no_2_3 = synthesize_no_2_3Service.getById(s);
if (!StringUtils.isEmpty(synthesize_no_2_3)) {
synthesize_no_2_3.setId(synthesize_no_1.getId());
synthesize_no_2_3Service.save(synthesize_no_2_3);
}
Synthesize_no_2_4 synthesize_no_2_4 = synthesize_no_2_4Service.getById(s);
if (!StringUtils.isEmpty(synthesize_no_2_4)) {
synthesize_no_2_4.setId(synthesize_no_1.getId());
synthesize_no_2_4Service.save(synthesize_no_2_4);
}
Synthesize_no_2_5 synthesize_no_2_5 = synthesize_no_2_5Service.getById(s);
if (!StringUtils.isEmpty(synthesize_no_2_5)) {
synthesize_no_2_5.setId(synthesize_no_1.getId());
synthesize_no_2_5Service.save(synthesize_no_2_5);
}
Synthesize_no_2_6 synthesize_no_2_6 = synthesize_no_2_6Service.getById(s);
if (!StringUtils.isEmpty(synthesize_no_2_6)) {
synthesize_no_2_6.setId(synthesize_no_1.getId());
synthesize_no_2_6Service.save(synthesize_no_2_6);
}
Synthesize_no_3_6 synthesize_no_3_6 = synthesize_no_3_6Service.getById(s);
if (!StringUtils.isEmpty(synthesize_no_3_6)) {
synthesize_no_3_6.setId(synthesize_no_1.getId());
synthesize_no_3_6Service.save(synthesize_no_3_6);
}
}
informationBaseService.copyProject(ids);
return RestResponse.success("复制成功");
}
... ... @@ -191,111 +84,7 @@ public class InformationBase {
@PathVariable("site") String site,
@PathVariable("buildingType") String buildingType
) {
CityDict dict = cityDictService.getOne(new QueryWrapper<CityDict>().lambda().eq(CityDict::getName, site));
if (StringUtils.isEmpty(dict)) {
throw new BusinessException(CommonErrorCode.E_100101);
}
Integer[] array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
Electrovalence electrovalence = electrovalenceMapper.selectById(dict.getId());
ElectrovalenceDto electrovalenceDto = new ElectrovalenceDto();
List<Electrovalence_1Dto> list = new ArrayList<>();
Electrovalence_1Dto electrovalence_1Dto = null;
for (Integer integer : array) {
if ("住宅".equals(buildingType) || "托幼".equals(buildingType) || "学校".equals(buildingType)) {
switch (integer) {
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 23:
case 24:
electrovalence_1Dto = new Electrovalence_1Dto();
electrovalence_1Dto.setNum(integer);
electrovalence_1Dto.setPrice(electrovalence.getNo3());
list.add(electrovalence_1Dto);
break;
case 7:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
electrovalence_1Dto = new Electrovalence_1Dto();
electrovalence_1Dto.setNum(integer);
electrovalence_1Dto.setPrice(electrovalence.getNo2());
list.add(electrovalence_1Dto);
break;
case 8:
case 9:
case 10:
case 18:
case 19:
case 20:
case 21:
case 22:
electrovalence_1Dto = new Electrovalence_1Dto();
electrovalence_1Dto.setNum(integer);
electrovalence_1Dto.setPrice(electrovalence.getNo1());
list.add(electrovalence_1Dto);
break;
default:
break;
}
} else {
switch (integer) {
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 23:
case 24:
electrovalence_1Dto = new Electrovalence_1Dto();
electrovalence_1Dto.setNum(integer);
electrovalence_1Dto.setPrice(electrovalence.getNo33());
list.add(electrovalence_1Dto);
break;
case 7:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
electrovalence_1Dto = new Electrovalence_1Dto();
electrovalence_1Dto.setNum(integer);
electrovalence_1Dto.setPrice(electrovalence.getNo22());
list.add(electrovalence_1Dto);
break;
case 8:
case 9:
case 10:
case 18:
case 19:
case 20:
case 21:
case 22:
electrovalence_1Dto = new Electrovalence_1Dto();
electrovalence_1Dto.setNum(integer);
electrovalence_1Dto.setPrice(electrovalence.getNo11());
list.add(electrovalence_1Dto);
break;
default:
break;
}
}
}
electrovalenceDto.setList(list);
EnergySources energySources = energySourcesMapper.selectById(dict.getId());
electrovalenceDto.setNaturalGas(energySources.getNo2());
electrovalenceDto.setRunningWater(energySources.getNo1());
return RestResponse.success(electrovalenceDto);
return RestResponse.success(informationBaseService.queryEconomicCondition(site, buildingType));
}
@GetMapping("query/naturalResources/{site}")
... ... @@ -312,31 +101,15 @@ public class InformationBase {
@GetMapping("query/city")
@ApiOperation(value = "省市联动查询", notes = "省市联动查询")
public RestResponse<List<ProvinceDict>> queryCity() {
List<ProvinceDict> list = new ArrayList<>();
for (ProvinceDict provinceDict : provinceDictMapper.selectList(new QueryWrapper<>())) {
ProvinceDict provinceDict1 = new ProvinceDict();
List<CityDict> cityDicts = cityDictService.list(new QueryWrapper<CityDict>().lambda().eq(CityDict::getSId, provinceDict.getId()));
provinceDict1.setId(provinceDict.getId());
provinceDict1.setName(provinceDict.getName());
provinceDict1.setList(cityDicts);
list.add(provinceDict1);
}
return RestResponse.success(list);
return RestResponse.success(informationBaseService.queryCity());
}
/**
* @param id
* @return
*/
@GetMapping("query/typical/{id}")
@ApiOperation(value = "---------典型案例-----------基础信息 查询", notes = "---------典型案例-----------基础信息 查询", response = No_3_1Dto.class)
@ApiImplicitParams({
@ApiImplicitParam(name = "id", required = true, value = "no_1项目信息保存返回的ID", dataType = "String"),
})
public RestResponse<No_3_1Dto> no3_1GetType
(
@PathVariable("id") String id
) {
public RestResponse<No_3_1Dto> no3_1GetType(@PathVariable("id") String id) {
return RestResponse.success(projectService.no3_1GetType(id));
}
... ...
package com.synthesize_energy.item.web.controller;
import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.synthesize_energy.common.domain.RestResponse;
import com.synthesize_energy.item.entity.User;
import com.synthesize_energy.item.utils.JwtUtil;
import com.synthesize_energy.item.web.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
/**
... ... @@ -26,10 +20,10 @@ import java.util.Map;
@RequestMapping("login")
@Slf4j
@Api(value = "登录接口", tags = "登录接口")
public class UserController {
@AllArgsConstructor
public class LoginController {
@Autowired
private UserService userService;
private final UserService userService;
@PostMapping
@ApiOperation(value = "登录", notes = "登录")
... ... @@ -37,14 +31,11 @@ public class UserController {
@ApiImplicitParam(name = "phone", required = true, value = "登录手机号", dataType = "String"),
@ApiImplicitParam(name = "code", required = true, value = "验证码", dataType = "String")
})
public RestResponse<Map<String,Object>> login(
public RestResponse<Map<String, Object>> login(
@RequestParam("phone") String phone,
@RequestParam("code") String code,
HttpServletResponse response
@RequestParam("code") String code
) {
return RestResponse.success(userService.login(phone,code,response));
return RestResponse.success(userService.login(phone, code));
}
}
... ...
... ... @@ -10,11 +10,10 @@ import com.synthesize_energy.common.domain.RestResponse;
import com.synthesize_energy.item.entity.*;
import com.synthesize_energy.item.mapper.*;
import com.synthesize_energy.item.utils.JwtUtil;
import com.synthesize_energy.item.utils.UserContext;
import com.synthesize_energy.item.web.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.*;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
... ... @@ -32,40 +31,18 @@ import java.util.List;
@RestController
@RequestMapping("my")
@Api(value = "我的接口查询", tags = "我的接口查询")
@AllArgsConstructor
public class MyController {
@Autowired
private HttpServletRequest request;
@Autowired
private MyService myService;
@Autowired
private CompanyDataMapper companyDataMapper;
@Autowired
private MyNatureMapper myNatureMapper;
@Autowired
private Synthesize_no_1ClientNameService synthesize_no_1ClientNameService;
@Autowired
private UserService userService;
@Autowired
private No_1Service no_1Service;
@Autowired
private Synthesize_no_1ImgMapper synthesize_no_1ImgMapper;
@Autowired
private Synthesize_no_2_1Service synthesize_no_2_1Service;
@Autowired
private Synthesize_no_2_2Service synthesize_no_2_2Service;
@Autowired
private Synthesize_no_2_3Service synthesize_no_2_3Service;
@Autowired
private Synthesize_no_2_4Service synthesize_no_2_4Service;
@Autowired
private Synthesize_no_2_5Service synthesize_no_2_5Service;
@Autowired
private Synthesize_no_2_6Service synthesize_no_2_6Service;
@Autowired
private UserMapper userMapper;
@Autowired
private MyIndustryMapper myIndustryMapper;
private final MyService myService;
private final CompanyDataMapper companyDataMapper;
private final MyNatureMapper myNatureMapper;
private final Synthesize_no_1ClientNameService synthesize_no_1ClientNameService;
private final Synthesize_no_1ClientNameMapper synthesize_no_1ClientNameMapper;
@PostMapping("found")
@ApiOperation(value = "创建账号", notes = "创建账号")
... ... @@ -85,14 +62,7 @@ public class MyController {
@RequestParam("phone") String phone,
@RequestParam(value = "id", required = false) String id
) {
if (StringUtils.isEmpty(id)) {
List<User> list = userService.list(new QueryWrapper<User>().lambda().eq(User::getPhone, phone));
if (!list.isEmpty()) {
throw new BusinessException(CommonErrorCode.E_999995);
}
}
String userId = JwtUtil.getUserId(request.getHeader("token"));
myService.foundAccountNumber(userId, type, name, companyId, department, phone, id);
myService.foundAccountNumber(type, name, companyId, department, phone, id);
return RestResponse.success("创建成功");
}
... ... @@ -102,10 +72,7 @@ public class MyController {
@ApiImplicitParam(name = "id", required = true, value = "回显id", dataType = "String")
})
public RestResponse<User> getFoundById(@PathVariable("id") String id) {
User user = userService.getById(id);
CompanyData companyData = companyDataMapper.selectById(id);
user.setCompanyId(companyData.getName());
return RestResponse.success(user);
return RestResponse.success(myService.getFoundById(id));
}
@PostMapping("company")
... ... @@ -126,8 +93,7 @@ public class MyController {
@RequestParam("rows") Integer rows,
@RequestParam(value = "name", required = false) String name
) {
String userId = JwtUtil.getUserId(request.getHeader("token"));
IPage<User> userIPage = myService.queryUser(userId, page, rows, name);
IPage<User> userIPage = myService.queryUser(page, rows, name);
return new PageVO<>(userIPage.getRecords(), userIPage.getTotal(), page, rows);
}
... ... @@ -170,15 +136,7 @@ public class MyController {
@PostMapping("creation")
@ApiOperation(value = "创建用户", notes = "创建用户")
public RestResponse<String> creationUser(Synthesize_no_1ClientName synthesize_no_1ClientName) {
if (StringUtils.isEmpty(synthesize_no_1ClientName.getId())) {
synthesize_no_1ClientName.setUserId(JwtUtil.getUserId(request.getHeader("token")));
synthesize_no_1ClientName.setTime(new Date());
synthesize_no_1ClientName.setNewTime(synthesize_no_1ClientName.getName());
synthesize_no_1ClientName.setDeleteState("0");
} else {
synthesize_no_1ClientName.setNewTime(synthesize_no_1ClientName.getName());
}
synthesize_no_1ClientNameService.saveOrUpdate(synthesize_no_1ClientName);
myService.creationUser(synthesize_no_1ClientName);
return RestResponse.success("创建成功");
}
... ... @@ -192,26 +150,7 @@ public class MyController {
@RequestParam("id") String id,
@RequestParam("type") String type
) {
String[] split = id.split(",");
for (String s : split) {
Synthesize_no_1ClientName synthesize_no_1ClientName = synthesize_no_1ClientNameService.getById(s);
switch (type) {
case "1":
synthesize_no_1ClientName.setType("1");
synthesize_no_1ClientName.setNewTime("11111");
break;
case "2":
synthesize_no_1ClientName.setType(null);
synthesize_no_1ClientName.setNewTime(synthesize_no_1ClientName.getName());
break;
case "3":
synthesize_no_1ClientName.setDeleteState("1");
break;
default:
break;
}
synthesize_no_1ClientNameService.updateById(synthesize_no_1ClientName);
}
myService.settingClient(id, type);
return RestResponse.success("设置成功");
}
... ... @@ -225,16 +164,10 @@ public class MyController {
@PathVariable("id") String id,
@PathVariable("type") String type
) {
Synthesize_no_1ClientName synthesize_no_1ClientName = new Synthesize_no_1ClientName();
synthesize_no_1ClientName.setId(id);
synthesize_no_1ClientName.setCollectState(type);
synthesize_no_1ClientNameService.updateById(synthesize_no_1ClientName);
myService.settingCollect(id, type);
return RestResponse.success("设置成功");
}
@Autowired
private Synthesize_no_1ClientNameMapper synthesize_no_1ClientNameMapper;
@GetMapping("query/client")
@ApiOperation(value = "查询客户", notes = "查询客户", response = Synthesize_no_1ClientName.class)
@ApiImplicitParams({
... ... @@ -248,23 +181,7 @@ public class MyController {
@RequestParam(value = "rows", required = true) Integer rows
) {
/* for (Synthesize_no_1ClientName synthesize_no_1ClientName : synthesize_no_1ClientNameService.list(new QueryWrapper<Synthesize_no_1ClientName>()
.lambda()
.eq(Synthesize_no_1ClientName::getType, "1")
.ne(Synthesize_no_1ClientName::getDeleteState,"1")
.eq(Synthesize_no_1ClientName::getUserId, JwtUtil.getUserId(request.getHeader("token"))))) {
synthesize_no_1ClientName.setNewTime(new Date());
synthesize_no_1ClientNameService.updateById(synthesize_no_1ClientName);
}*/
Page<Synthesize_no_1ClientName> namePage = new Page<>(page, rows);
/* IPage<Synthesize_no_1ClientName> iPage = synthesize_no_1ClientNameService.page(namePage, new QueryWrapper<Synthesize_no_1ClientName>()
.lambda()
.eq(Synthesize_no_1ClientName::getUserId, JwtUtil.getUserId(request.getHeader("token")))
.ne(Synthesize_no_1ClientName::getDeleteState,"1")
.like(!StringUtils.isEmpty(name), Synthesize_no_1ClientName::getName, name)
.orderByDesc(Synthesize_no_1ClientName::getNewTime));*/
IPage<Synthesize_no_1ClientName> iPage = synthesize_no_1ClientNameMapper.queryByIdPage(namePage, JwtUtil.getUserId(request.getHeader("token")), name);
IPage<Synthesize_no_1ClientName> iPage = synthesize_no_1ClientNameMapper.queryByIdPage(new Page<>(page, rows), UserContext.get().getId(), name);
return new PageVO<>(iPage.getRecords(), iPage.getTotal(), page, rows);
}
... ... @@ -287,79 +204,7 @@ public class MyController {
@PathVariable("id") String id,
@PathVariable("type") String type
) {
Synthesize_no_1 no_1 = no_1Service.getById(id);
if ("1".equals(type)) {
no_1.setId(null);
no_1.setClientName(null);
no_1.setProjectSite(null);
no_1.setProjectSiteAll(null);
no_1.setProjectContact(null);
no_1.setProjectPhone(null);
no_1.setTime(new Date());
no_1.setNewTime(new Date());
no_1.setPtState(null);
no_1.setType(null);
no_1.setUserId(null);
no_1.setAdminState(null);
no_1.setSuperAdminState(null);
no_1.setDeleteState(null);
no_1.setModelCase("2");
no_1Service.save(no_1);
Synthesize_no_1 no_1_1 = no_1Service.getById(id);
no_1_1.setModelCaseId(no_1.getId());
no_1_1.setModelCase("1");
no_1Service.updateById(no_1_1);
Synthesize_no_1Img synthesize_no_1Img = synthesize_no_1ImgMapper.selectById(id);
if (!StringUtils.isEmpty(synthesize_no_1Img)) {
synthesize_no_1Img.setId(no_1.getId());
synthesize_no_1ImgMapper.insert(synthesize_no_1Img);
}
List<Synthesize_no_2_1> list = synthesize_no_2_1Service.list(new QueryWrapper<Synthesize_no_2_1>().lambda().eq(Synthesize_no_2_1::getPid, id));
if (!list.isEmpty()) {
for (Synthesize_no_2_1 synthesize_no_2_1 : list) {
synthesize_no_2_1.setId(null);
synthesize_no_2_1.setPid(no_1.getId());
synthesize_no_2_1Service.save(synthesize_no_2_1);
}
}
Synthesize_no_2_2 synthesize_no_2_2 = synthesize_no_2_2Service.getById(id);
if (!StringUtils.isEmpty(synthesize_no_2_2)) {
synthesize_no_2_2.setId(no_1.getId());
synthesize_no_2_2Service.save(synthesize_no_2_2);
}
Synthesize_no_2_3 synthesize_no_2_3 = synthesize_no_2_3Service.getById(id);
if (!StringUtils.isEmpty(synthesize_no_2_3)) {
synthesize_no_2_3.setId(no_1.getId());
synthesize_no_2_3Service.save(synthesize_no_2_3);
}
Synthesize_no_2_4 synthesize_no_2_4 = synthesize_no_2_4Service.getById(id);
if (!StringUtils.isEmpty(synthesize_no_2_4)) {
synthesize_no_2_4.setId(no_1.getId());
synthesize_no_2_4Service.save(synthesize_no_2_4);
}
Synthesize_no_2_5 synthesize_no_2_5 = synthesize_no_2_5Service.getById(id);
if (!StringUtils.isEmpty(synthesize_no_2_5)) {
synthesize_no_2_5.setId(no_1.getId());
synthesize_no_2_5Service.save(synthesize_no_2_5);
}
Synthesize_no_2_6 synthesize_no_2_6 = synthesize_no_2_6Service.getById(id);
if (!StringUtils.isEmpty(synthesize_no_2_6)) {
synthesize_no_2_6.setId(no_1.getId());
synthesize_no_2_6Service.save(synthesize_no_2_6);
}
} else if ("2".equals(type)) {
no_1Service.removeById(no_1.getModelCaseId());
synthesize_no_1ImgMapper.deleteById(no_1.getModelCaseId());
synthesize_no_2_1Service.remove(new QueryWrapper<Synthesize_no_2_1>().lambda().eq(Synthesize_no_2_1::getPid, no_1.getModelCaseId()));
synthesize_no_2_2Service.removeById(no_1.getModelCaseId());
synthesize_no_2_3Service.removeById(no_1.getModelCaseId());
synthesize_no_2_4Service.removeById(no_1.getModelCaseId());
synthesize_no_2_5Service.removeById(no_1.getModelCaseId());
synthesize_no_2_6Service.removeById(no_1.getModelCaseId());
no_1.setModelCaseId(null);
no_1.setModelCase(null);
no_1Service.updateById(no_1);
}
myService.settingModelCase(id, type);
return RestResponse.success("设置成功");
}
... ... @@ -370,20 +215,7 @@ public class MyController {
@ApiImplicitParam(name = "type", required = true, value = "1未立项2立项", dataType = "String"),
})
public RestResponse<String> settingProject(@PathVariable("id") String id, @PathVariable("type") String type) {
Synthesize_no_1 synthesize_no_1 = no_1Service.getById(id);
if ("1".equals(type)) {
/**
* 未立项
*/
synthesize_no_1.setType("1");
no_1Service.updateById(synthesize_no_1);
} else if ("2".equals(type)) {
/**
* 立项
*/
synthesize_no_1.setType("2");
no_1Service.updateById(synthesize_no_1);
}
myService.settingProject(id, type);
return RestResponse.success("设置成功");
}
... ... @@ -400,10 +232,7 @@ public class MyController {
@RequestParam(value = "rows", required = true) Integer rows
) {
IPage<Synthesize_no_1> page1 = no_1Service.page(new Page<>(page, rows), new QueryWrapper<Synthesize_no_1>().lambda().eq(Synthesize_no_1::getDeleteState, "1").like(!StringUtils.isEmpty(name), Synthesize_no_1::getProjectName, name));
for (Synthesize_no_1 record : page1.getRecords()) {
record.setUserId(userService.getById(record.getUserId()).getName());
}
IPage<Synthesize_no_1> page1 = myService.queryRecycle(name, page, rows);
return new PageVO<>(page1.getRecords(), page1.getTotal(), page, rows);
}
... ... @@ -417,25 +246,7 @@ public class MyController {
@PathVariable("ids") String ids,
@PathVariable("type") String type
) {
String[] split = ids.split(",");
for (String s : split) {
Synthesize_no_1 synthesize_no_1 = no_1Service.getById(s);
if ("1".equals(type)) {
/**
* 恢复
*/
synthesize_no_1.setId(s);
synthesize_no_1.setDeleteState("3");
no_1Service.updateById(synthesize_no_1);
} else if ("2".equals(type)) {
/**
* 彻底删除
*/
synthesize_no_1.setId(s);
synthesize_no_1.setDeleteState("2");
no_1Service.updateById(synthesize_no_1);
}
}
myService.deleteRecycle(ids, type);
return RestResponse.success("操作成功");
}
... ... @@ -453,151 +264,10 @@ public class MyController {
@RequestParam("page") Integer page,
@RequestParam("rows") Integer rows
) {
String token = request.getHeader("token");
User user = userService.getById(JwtUtil.getUserId(token));
if ("1".equals(user.getStatus())) {
/**
* 查看自己的项目
*/
for (Synthesize_no_1 synthesize_no_1 : no_1Service.list(new QueryWrapper<Synthesize_no_1>()
.lambda()
.eq(Synthesize_no_1::getPtState, "1")
.eq(Synthesize_no_1::getUserId, user.getId())
.eq(Synthesize_no_1::getDeleteState, "3"))) {
synthesize_no_1.setNewTime(new Date());
no_1Service.updateById(synthesize_no_1);
}
IPage<Synthesize_no_1> iPage = no_1Service.page(new Page<>(page, rows), new QueryWrapper<Synthesize_no_1>()
.lambda()
.eq(Synthesize_no_1::getUserId, user.getId())
.eq(Synthesize_no_1::getDeleteState, "3")
.like(!StringUtils.isEmpty(name), Synthesize_no_1::getProjectName, name)
.orderByDesc(Synthesize_no_1::getNewTime));
for (Synthesize_no_1 record : iPage.getRecords()) {
record.setUserId(user.getName());
}
return new PageVO<>(iPage.getRecords(), iPage.getTotal(), page, rows);
} else if ("2".equals(user.getStatus())) {
/**
* 管理员 外加 自己部分的所有项目
*/
for (Synthesize_no_1 synthesize_no_1 : no_1Service.list(new QueryWrapper<Synthesize_no_1>()
.lambda()
.eq(Synthesize_no_1::getAdminState, "1")
.eq(Synthesize_no_1::getUserId, user.getId())
.eq(Synthesize_no_1::getDeleteState, "3"))) {
synthesize_no_1.setNewTime(new Date());
no_1Service.updateById(synthesize_no_1);
}
List<User> users = userMapper.selectList(new QueryWrapper<User>().lambda().eq(User::getCompanyId, user.getCompanyId()));
List<String> list2 = new ArrayList<>();
for (User user1 : users) {
list2.add(user1.getId());
}
IPage<Synthesize_no_1> iPage = no_1Service.page(new Page<>(page, rows), new QueryWrapper<Synthesize_no_1>()
.lambda()
.eq(Synthesize_no_1::getDeleteState, "3")
.in(Synthesize_no_1::getUserId, list2)
.like(!StringUtils.isEmpty(name), Synthesize_no_1::getProjectName, name)
.orderByDesc(Synthesize_no_1::getNewTime));
for (Synthesize_no_1 record : iPage.getRecords()) {
User user1 = userMapper.selectById(record.getUserId());
if (!user.getId().equals(user1.getId())) {
record.setFlag(false);
}
record.setUserId(user1.getName());
}
return new PageVO<>(iPage.getRecords(), iPage.getTotal(), page, rows);
} else if ("3".equals(user.getStatus())) {
/**
* 自己项目跟别人的项目
*/
for (Synthesize_no_1 synthesize_no_1 : no_1Service.list(new QueryWrapper<Synthesize_no_1>()
.lambda()
.eq(Synthesize_no_1::getSuperAdminState, "1")
.eq(Synthesize_no_1::getType, "1")
.eq(Synthesize_no_1::getDeleteState, "3"))) {
synthesize_no_1.setNewTime(new Date());
no_1Service.updateById(synthesize_no_1);
}
if ("1".equals(type)) {
/**
* 查询全部
*/
IPage<Synthesize_no_1> iPage = no_1Service.page(new Page<>(page, rows), new QueryWrapper<Synthesize_no_1>()
.lambda()
.eq(Synthesize_no_1::getDeleteState, "3")
.like(!StringUtils.isEmpty(name), Synthesize_no_1::getProjectName, name)
.orderByDesc(Synthesize_no_1::getNewTime));
if (!iPage.getRecords().isEmpty()) {
for (Synthesize_no_1 record : iPage.getRecords()) {
User user1 = userMapper.selectById(record.getUserId());
if (!user.getId().equals(user1.getId())) {
record.setFlag(false);
}
record.setUserId(user1.getName());
}
}
return new PageVO<>(iPage.getRecords(), iPage.getTotal(), page, rows);
} else if ("2".equals(type)) {
/**
* 查询自己的
*/
IPage<Synthesize_no_1> iPage = no_1Service.page(new Page<>(page, rows), new QueryWrapper<Synthesize_no_1>()
.lambda()
.eq(Synthesize_no_1::getDeleteState, "3")
.eq(Synthesize_no_1::getUserId, user.getId())
.like(!StringUtils.isEmpty(name), Synthesize_no_1::getProjectName, name)
.orderByDesc(Synthesize_no_1::getNewTime));
if (!iPage.getRecords().isEmpty()) {
for (Synthesize_no_1 record : iPage.getRecords()) {
User user1 = userMapper.selectById(record.getUserId());
if (!user.getId().equals(user1.getId())) {
record.setFlag(false);
}
record.setUserId(user1.getName());
}
}
return new PageVO<>(iPage.getRecords(), iPage.getTotal(), page, rows);
} else {
/**
* 查询 部门的
*/
List<User> users = userMapper.selectList(new QueryWrapper<User>()
.lambda()
.eq(User::getCompanyId, type));
List<String> list2 = new ArrayList<>();
if (!users.isEmpty()) {
for (User user1 : users) {
list2.add(user1.getId());
}
}
if (!list2.isEmpty()) {
IPage<Synthesize_no_1> iPage = no_1Service.page(new Page<>(page, rows), new QueryWrapper<Synthesize_no_1>()
.lambda()
.eq(Synthesize_no_1::getDeleteState, "3")
.in(Synthesize_no_1::getUserId, list2)
.like(!StringUtils.isEmpty(name), Synthesize_no_1::getProjectName, name)
.orderByDesc(Synthesize_no_1::getNewTime));
if (!iPage.getRecords().isEmpty()) {
for (Synthesize_no_1 record : iPage.getRecords()) {
User user1 = userMapper.selectById(record.getUserId());
if (!user.getId().equals(user1.getId())) {
record.setFlag(false);
}
record.setUserId(user1.getName());
}
}
return new PageVO<>(iPage.getRecords(), iPage.getTotal(), page, rows);
}
}
}
return new PageVO<>();
IPage<Synthesize_no_1> iPage = myService.queryProject(name, type, page, rows);
return new PageVO<>(iPage.getRecords(), iPage.getTotal(), page, rows);
}
@Autowired
private CalculateLoadMapper calculateLoadMapper;
@PostMapping("setting/copy/project")
@ApiOperation(value = "我的项目 置顶取消置顶复制删除", notes = "我的项目 置顶取消置顶复制删除")
@ApiImplicitParams({
... ... @@ -608,140 +278,10 @@ public class MyController {
@RequestParam("type") String type,
@RequestParam("ids") String ids
) {
String[] split = ids.split(",");
User user = userService.getById(JwtUtil.getUserId(request.getHeader("token")));
for (String s : split) {
Synthesize_no_1 synthesize_no_1 = no_1Service.getById(s);
if ("1".equals(type)) {
/**
* 1置顶
*/
if ("1".equals(user.getStatus())) {
/**
* 普通用户置顶
*/
synthesize_no_1.setId(s);
synthesize_no_1.setPtState("1");
no_1Service.updateById(synthesize_no_1);
} else if ("2".equals(user.getStatus())) {
/**
* 管理员置顶
*/
synthesize_no_1.setId(s);
synthesize_no_1.setAdminState("1");
no_1Service.updateById(synthesize_no_1);
} else if ("3".equals(user.getStatus())) {
/**
* super管理员置顶
*/
synthesize_no_1.setId(s);
synthesize_no_1.setSuperAdminState("1");
no_1Service.updateById(synthesize_no_1);
}
} else if ("2".equals(type)) {
/**
* 2取消置顶
*/
if ("1".equals(user.getStatus())) {
/**
* 普通用户取消置顶
*/
synthesize_no_1.setId(s);
synthesize_no_1.setPtState(null);
no_1Service.updateById(synthesize_no_1);
} else if ("2".equals(user.getStatus())) {
/**
* 管理员取消置顶
*/
synthesize_no_1.setId(s);
synthesize_no_1.setAdminState(null);
no_1Service.updateById(synthesize_no_1);
} else if ("3".equals(user.getStatus())) {
/**
* super管理员取消置顶
*/
synthesize_no_1.setId(s);
synthesize_no_1.setSuperAdminState(null);
no_1Service.updateById(synthesize_no_1);
}
} else if ("3".equals(type)) {
/**
* 3复制
*/
synthesize_no_1.setId(null);
/* synthesize_no_1.setClientName(null);
synthesize_no_1.setProjectSite(null);
synthesize_no_1.setProjectSiteAll(null);
synthesize_no_1.setProjectContact(null);
synthesize_no_1.setProjectPhone(null);*/
synthesize_no_1.setTime(new Date());
synthesize_no_1.setNewTime(new Date());
synthesize_no_1.setType("1");
synthesize_no_1.setUserId(user.getId());
/* synthesize_no_1.setPtState(null);
synthesize_no_1.setAdminState(null);
synthesize_no_1.setSuperAdminState(null);*/
synthesize_no_1.setDeleteState("3");
no_1Service.save(synthesize_no_1);
Synthesize_no_1Img synthesize_no_1Img = synthesize_no_1ImgMapper.selectById(s);
if (!StringUtils.isEmpty(synthesize_no_1Img)) {
synthesize_no_1Img.setId(synthesize_no_1.getId());
synthesize_no_1ImgMapper.insert(synthesize_no_1Img);
}
List<Synthesize_no_2_1> list = synthesize_no_2_1Service.list(new QueryWrapper<Synthesize_no_2_1>().lambda().eq(Synthesize_no_2_1::getPid, s));
if (!list.isEmpty()) {
for (Synthesize_no_2_1 synthesize_no_2_1 : list) {
CalculateLoad calculateLoad = calculateLoadMapper.selectById(synthesize_no_2_1.getId());
synthesize_no_2_1.setId(null);
synthesize_no_2_1.setPid(synthesize_no_1.getId());
synthesize_no_2_1Service.save(synthesize_no_2_1);
if (!StringUtils.isEmpty(calculateLoad)) {
calculateLoad.setId(synthesize_no_2_1.getId());
calculateLoad.setCid(synthesize_no_1.getId());
calculateLoadMapper.insert(calculateLoad);
}
}
}
Synthesize_no_2_2 synthesize_no_2_2 = synthesize_no_2_2Service.getById(s);
if (!StringUtils.isEmpty(synthesize_no_2_2)) {
synthesize_no_2_2.setId(synthesize_no_1.getId());
synthesize_no_2_2Service.save(synthesize_no_2_2);
}
Synthesize_no_2_3 synthesize_no_2_3 = synthesize_no_2_3Service.getById(s);
if (!StringUtils.isEmpty(synthesize_no_2_3)) {
synthesize_no_2_3.setId(synthesize_no_1.getId());
synthesize_no_2_3Service.save(synthesize_no_2_3);
}
Synthesize_no_2_4 synthesize_no_2_4 = synthesize_no_2_4Service.getById(s);
if (!StringUtils.isEmpty(synthesize_no_2_4)) {
synthesize_no_2_4.setId(synthesize_no_1.getId());
synthesize_no_2_4Service.save(synthesize_no_2_4);
}
Synthesize_no_2_5 synthesize_no_2_5 = synthesize_no_2_5Service.getById(s);
if (!StringUtils.isEmpty(synthesize_no_2_5)) {
synthesize_no_2_5.setId(synthesize_no_1.getId());
synthesize_no_2_5Service.save(synthesize_no_2_5);
}
Synthesize_no_2_6 synthesize_no_2_6 = synthesize_no_2_6Service.getById(s);
if (!StringUtils.isEmpty(synthesize_no_2_6)) {
synthesize_no_2_6.setId(synthesize_no_1.getId());
synthesize_no_2_6Service.save(synthesize_no_2_6);
}
} else if ("4".equals(type)) {
/**
* 4删除
*/
synthesize_no_1.setId(s);
synthesize_no_1.setDeleteState("1");
no_1Service.updateById(synthesize_no_1);
}
}
myService.settingProjectCopy(type, ids);
return RestResponse.success("设置成功");
}
@Autowired
private SortMapper sortMapper;
@GetMapping("setUp/building/{id}/{type}")
@ApiOperation(value = "管理员设置建筑", notes = "管理员设置建筑")
@ApiImplicitParams({
... ... @@ -752,34 +292,14 @@ public class MyController {
@PathVariable("type") Boolean type,
@PathVariable("id") Integer id
) {
if (!type) {
Sort sort = new Sort();
sort.setId(id);
sort.setState("1");
sortMapper.updateById(sort);
} else {
Sort sort = new Sort();
sort.setId(id);
sort.setState("2");
sortMapper.updateById(sort);
}
myService.setUpBuilding(type, id);
return RestResponse.success("设置成功");
}
@GetMapping("admin/query/building")
@ApiOperation(value = "管理员查询建筑", notes = "管理员查询建筑")
public RestResponse<List<Sort>> updateNo2_1getType() {
QueryWrapper<Sort> objectQueryWrapper = new QueryWrapper<>();
objectQueryWrapper.lambda().ne(Sort::getPid, "0");
List<Sort> sorts = sortMapper.selectList(objectQueryWrapper);
for (Sort sort : sorts) {
if ("1".equals(sort.getState())) {
sort.setFlag(false);
} else {
sort.setFlag(true);
}
}
return RestResponse.success(sorts);
return RestResponse.success(myService.updateNo2_1getType());
}
@GetMapping("query/user/{id}")
... ... @@ -788,8 +308,6 @@ public class MyController {
@ApiImplicitParam(name = "id", required = true, value = "需要修改用户的ID", dataType = "String")
})
public RestResponse<User> queryUserById(@PathVariable("id") String id) {
User service = userService.getById(id);
service.setCompanyName(companyDataMapper.selectById(service.getCompanyId()).getName());
return RestResponse.success(service);
return RestResponse.success(myService.queryUserById(id));
}
}
... ...
package com.synthesize_energy.item.web.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.synthesize_energy.common.domain.BusinessException;
import com.synthesize_energy.common.domain.CommonErrorCode;
import com.synthesize_energy.common.domain.RestResponse;
import com.synthesize_energy.item.dto.*;
import com.synthesize_energy.item.entity.*;
import com.synthesize_energy.item.mapper.*;
import com.synthesize_energy.item.utils.JwtUtil;
import com.synthesize_energy.item.vo.CalculateLoadVo;
import com.synthesize_energy.item.vo.EnergyEquipmentVo;
import com.synthesize_energy.item.web.service.*;
import io.swagger.annotations.*;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
/**
... ... @@ -34,52 +24,26 @@ import java.util.*;
@RequestMapping("project")
@Api(value = "项目接口", tags = "项目接口")
@Slf4j
@AllArgsConstructor
public class ProjectController {
@Autowired
private ProjectService projectService;
@Autowired
private No_1Service no_1Service;
@Autowired
private HttpServletRequest request;
@Autowired
private Synthesize_no_1ClientNameService synthesize_no_1ClientNameService;
@Autowired
private Synthesize_no_1ImgService synthesize_no_1ImgService;
@Autowired
private Synthesize_no_2_1Service synthesize_no_2_1Service;
@Autowired
private SortMapper sortMapper;
@Autowired
private Synthesize_no_2_2Service synthesize_no_2_2Service;
@Autowired
private Synthesize_no_2_3Service synthesize_no_2_3Service;
@Autowired
private Synthesize_no_2_4Service synthesize_no_2_4Service;
@Autowired
private Synthesize_no_2_5Service synthesize_no_2_5Service;
@Autowired
private Synthesize_no_2_6Service synthesize_no_2_6Service;
@Autowired
private CityDictService cityDictService;
@Autowired
private HotWaterDataMapper hotWaterDataMapper;
@Autowired
private ColdWaterDataMapper coldWaterDataMapper;
@Autowired
private CalculateLoadService calculateLoadService;
@Autowired
private Synthesize_no_3_6Service synthesize_no_3_6Service;
@Autowired
private HotLoadDataMapper hotLoadDataMapper;
@Autowired
private CpvAndCfmDataService cpvAndCfmDataService;
@Autowired
private EnergySourcesMapper energySourcesMapper;
@Autowired
private ElectrovalenceMapper electrovalenceMapper;
@Autowired
private HeatIngDataMapper heatIngDataMapper;
private final ProjectService projectService;
private final No_1Service no_1Service;
private final Synthesize_no_1ImgService synthesize_no_1ImgService;
private final SortMapper sortMapper;
private final Synthesize_no_2_2Service synthesize_no_2_2Service;
private final Synthesize_no_2_4Service synthesize_no_2_4Service;
private final Synthesize_no_2_5Service synthesize_no_2_5Service;
private final Synthesize_no_2_6Service synthesize_no_2_6Service;
private final CalculateLoadService calculateLoadService;
@PostMapping("getBuildingTypeToIndex")
@ApiOperation(value = "获取根据建筑类型换取指标")
... ... @@ -87,125 +51,22 @@ public class ProjectController {
@RequestParam("buildingTypeId") @ApiParam(value = "建筑类型ID", name = "buildingTypeId") String buildingTypeId,
@RequestParam("projectId") @ApiParam(value = "项目ID", name = "projectId") String projectId
) {
Map<String,Object> map = synthesize_no_2_6Service.getBuildingTypeToIndex(buildingTypeId,projectId);
Map<String, Object> map = synthesize_no_2_6Service.getBuildingTypeToIndex(buildingTypeId, projectId);
return RestResponse.success(map);
}
@GetMapping("getHeatingDays/{id}")
@ApiOperation(value = "获取供热天数")
public RestResponse<?> getHeatingDays(
@PathVariable("id") @ApiParam(value = "id", name = "项目ID") String id
) {
Synthesize_no_1 synthesize_no_1 = no_1Service.getById(id);
Assert.notNull(synthesize_no_1, "请先保存项目信息!");
CityDict dict = cityDictService.getOne(new QueryWrapper<CityDict>().lambda().eq(CityDict::getName, synthesize_no_1.getProjectSite()));//城市
HeatIngData heatIngData = heatIngDataMapper.selectById(dict.getId());
return RestResponse.success(heatIngData.getNo3());
return RestResponse.success(no_1Service.getHeatingDays(id));
}
@PostMapping("no_1")
@ApiOperation(value = "no_1项目信息", notes = "no_1项目信息")
public RestResponse<String> no1Save(Synthesize_no_1 synthesize_no_1) {
if (org.springframework.util.StringUtils.isEmpty(synthesize_no_1.getId())) {
synthesize_no_1.setType("1");
synthesize_no_1.setTime(new Date());
synthesize_no_1.setDeleteState("3");
synthesize_no_1.setCountState("0");
synthesize_no_1.setUserId(JwtUtil.getUserId(request.getHeader("token")));
synthesize_no_1.setNewTime(new Date());
synthesize_no_1.setFlagCalculate("2");
} else {
/**
* 修改 对条件设置的参数修正 热水定额 冷水初始温度 修改
*/
Synthesize_no_1 synthesizeNo1 = no_1Service.getById(synthesize_no_1.getId());
/**
* 判断 两次选择的地区是否一样 不一样就行修改取最新
*/
if (!synthesize_no_1.getProjectSite().equals(synthesizeNo1.getProjectSite())) {
CityDict dict = cityDictService.getOne(new QueryWrapper<CityDict>().lambda().eq(CityDict::getName, synthesize_no_1.getProjectSite()));//城市
HeatIngData heatIngData = heatIngDataMapper.selectById(dict.getId());
/**
* 在次判断 synthesize_no_2_1 是否存在
*/
List<Synthesize_no_2_1> synthesize_no_2_1s = synthesize_no_2_1Service.list(new LambdaQueryWrapper<Synthesize_no_2_1>().eq(Synthesize_no_2_1::getPid, synthesize_no_1.getId()));
if (!synthesize_no_2_1s.isEmpty()) {
for (Synthesize_no_2_1 synthesize_no_2_1 : synthesize_no_2_1s) {
/**
* 修改供热天数
*/
synthesize_no_2_1.setHeatDay(Double.valueOf(heatIngData.getNo3()));
synthesize_no_2_1Service.updateById(synthesize_no_2_1);
}
}
}
if (StringUtils.isNotEmpty(synthesize_no_1.getProjectSite())) {
String site = synthesize_no_1.getProjectSite();
Synthesize_no_2_6 byId = synthesize_no_2_6Service.getById(synthesize_no_1.getId());
if (org.springframework.util.StringUtils.isEmpty(byId)) {
byId = synthesize_no_2_6Service.getById("1");
}
CityDict cityDict = cityDictService.getOne(new QueryWrapper<CityDict>().lambda().eq(CityDict::getName, site));
List<Synthesize_no_2_1> synthesize_no_2_1s = synthesize_no_2_1Service.list(new QueryWrapper<Synthesize_no_2_1>().lambda().eq(Synthesize_no_2_1::getPid, synthesize_no_1.getId()));//建筑
double electricity = 0.0;
double tall = 0.0;
double flat = 0.0;
double floor = 0.0;
if (!synthesize_no_2_1s.isEmpty()) {
for (int i = 0; i < synthesize_no_2_1s.size(); i++) {
Sort sort = sortMapper.selectById(synthesize_no_2_1s.get(i).getBuildingTypeId());
if (!org.springframework.util.StringUtils.isEmpty(sort)) {
String zd_name = "no_" + sort.getId();
CalculateLoad calculateLoad = calculateLoadService.getById(synthesize_no_2_1s.get(i).getId());
Electrovalence electrovalence = electrovalenceMapper.selectById(cityDict.getId());
if ("住宅".equals(sort.getName()) || "托幼".equals(sort.getName()) || "学校".equals(sort.getName())) {
tall += electrovalence.getNo1();
flat += electrovalence.getNo2();
floor += electrovalence.getNo3();
} else {
tall += electrovalence.getNo11();
flat += electrovalence.getNo22();
floor += electrovalence.getNo33();
}
if (!org.springframework.util.StringUtils.isEmpty(calculateLoad)) {
if (calculateLoad.getNo4().equals(calculateLoad.getNo44())) {
electricity += hotWaterDataMapper.queryName(zd_name, cityDict.getId());
} else {
/**
* 年总需热水总量(调整值)*1000/(人数*365*0.9)
*
*/
electricity += calculateLoad.getNo44() * 1000 / (synthesize_no_2_1s.get(i).getWaterPersonNum() * 365 * 0.9);
}
}
}
}
}
byId.setId(synthesize_no_1.getId());
byId.setNo50(electricity);// 热水定额
byId.setNo51(Double.valueOf(coldWaterDataMapper.selectById(cityDict.getId()).getNo1()));// 冷水初始温度
byId.setNo54(cpvAndCfmDataService.getById(cityDict.getId()).getNo7()); // 太阳能保证率
byId.setNo115(cpvAndCfmDataService.getById(cityDict.getId()).getNo6()); // 年平均太阳辐照量
byId.setNo122(cpvAndCfmDataService.getById(cityDict.getId()).getNo2()); // 太阳辐照度
byId.setNo123(cpvAndCfmDataService.getById(cityDict.getId()).getNo3());//年总光伏利用小时数
byId.setNo124(cpvAndCfmDataService.getById(cityDict.getId()).getNo5()); // 年总风机利用小时数
byId.setNo125(tall); // 高峰电价
byId.setNo126(flat); // 平时电价
byId.setNo127(floor); // 低谷电价
byId.setNo128(energySourcesMapper.selectById(cityDict.getId()).getNo2()); // 天然气价格
byId.setNo129(energySourcesMapper.selectById(cityDict.getId()).getNo1()); // 自来水价格
synthesize_no_1.setType(synthesizeNo1.getType());
synthesize_no_1.setDeleteState(synthesizeNo1.getDeleteState());
synthesize_no_1.setCountState(synthesizeNo1.getCountState());
synthesize_no_1.setUserId(synthesizeNo1.getUserId());
synthesize_no_1.setPtState(synthesizeNo1.getPtState());
synthesize_no_1.setAdminState(synthesizeNo1.getAdminState());
synthesize_no_1.setSuperAdminState(synthesizeNo1.getAdminState());
synthesize_no_2_6Service.saveOrUpdate(byId);
}
}
return RestResponse.success(no_1Service.saveOrUpdate(synthesize_no_1) ? synthesize_no_1.getId() : "保存失败");
return RestResponse.success(projectService.no1Save(synthesize_no_1));
}
@GetMapping("no_1")
... ... @@ -216,20 +77,7 @@ public class ProjectController {
public RestResponse<List<ClientNameDto>> no1getName(
@RequestParam("name") String name
) {
String userId = JwtUtil.getUserId(request.getHeader("token"));
QueryWrapper<Synthesize_no_1ClientName> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(Synthesize_no_1ClientName::getUserId, userId).ne(Synthesize_no_1ClientName::getDeleteState, "1")
.orderByDesc(Synthesize_no_1ClientName::getNewTime);
queryWrapper.like(StringUtils.isNotBlank(name), "name", name);
List<Synthesize_no_1ClientName> list = synthesize_no_1ClientNameService.list(queryWrapper);
List<ClientNameDto> names = new ArrayList<>();
for (Synthesize_no_1ClientName synthesize_no_1ClientName : list) {
ClientNameDto clientNameDto = new ClientNameDto();
clientNameDto.setId(synthesize_no_1ClientName.getId());
clientNameDto.setName(synthesize_no_1ClientName.getName());
names.add(clientNameDto);
}
return RestResponse.success(names);
return RestResponse.success(projectService.no1getName(name));
}
@PostMapping("no_1/img")
... ... @@ -238,10 +86,7 @@ public class ProjectController {
return RestResponse.success(synthesize_no_1ImgService.saveOrUpdate(synthesize_no_1Img));
}
/**
* @param synthesize_no_2_1
* @return
*/
@PostMapping("no_2_1")
@ApiOperation(value = "no_2_1建筑信息新增", notes = "no_2_1建筑信息新增", response = Synthesize_no_2_1.class)
@ApiImplicitParams({
... ... @@ -281,13 +126,9 @@ public class ProjectController {
@GetMapping("no_2_1/type")
@ApiOperation(value = "no_2_1建筑类型查询", notes = "no_2_1建筑类型查询")
public RestResponse<List<Sort>> no2_1getType() {
QueryWrapper<Sort> objectQueryWrapper = new QueryWrapper<>();
objectQueryWrapper.lambda().eq(Sort::getPid, "0").eq(Sort::getState, "2");
List<Sort> sorts = sortMapper.selectList(objectQueryWrapper);
List<Sort> sorts = sortMapper.selectList(new LambdaQueryWrapper<Sort>().eq(Sort::getPid, "0").eq(Sort::getState, "2"));
for (Sort sort : sorts) {
QueryWrapper<Sort> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(Sort::getPid, sort.getId()).eq(Sort::getState, "2");
sort.setSorts(sortMapper.selectList(queryWrapper));
sort.setSorts(sortMapper.selectList(new LambdaQueryWrapper<Sort>().eq(Sort::getPid, sort.getId()).eq(Sort::getState, "2")));
}
return RestResponse.success(sorts);
}
... ... @@ -295,10 +136,7 @@ public class ProjectController {
@GetMapping("no_2_1/new/type")
@ApiOperation(value = "----修改之后----no_2_1建筑类型查询", notes = "no_2_1建筑类型查询")
public RestResponse<List<Sort>> updateNo2_1getType() {
QueryWrapper<Sort> objectQueryWrapper = new QueryWrapper<>();
objectQueryWrapper.lambda().ne(Sort::getPid, "0").eq(Sort::getState, "2");
List<Sort> sorts = sortMapper.selectList(objectQueryWrapper);
return RestResponse.success(sorts);
return RestResponse.success(sortMapper.selectList(new LambdaQueryWrapper<Sort>().ne(Sort::getPid, "0").eq(Sort::getState, "2")));
}
@PostMapping("no_2_2")
... ... @@ -320,173 +158,7 @@ public class ProjectController {
ColdMsgDto coldMsgDto,
HotWaterDto hotWaterDto
) {
/**
* 光伏可利用面积 风电装机容量
*/
Synthesize_no_2_4 synthesize_no_2_4 = new Synthesize_no_2_4();
synthesize_no_2_4.setId(synthesize_no_2_3.getId());
synthesize_no_2_4.setPhotovoltaicArea(photovoltaicArea);
synthesize_no_2_4.setWindAh(windAh);
synthesize_no_2_4Service.saveOrUpdate(synthesize_no_2_4);
Synthesize_no_1 synthesize_no_1 = no_1Service.getById(synthesize_no_2_3.getId());
List<Synthesize_no_2_1> synthesize_no_2_1List = synthesize_no_2_1Service.list(new QueryWrapper<Synthesize_no_2_1>().lambda().eq(Synthesize_no_2_1::getPid, synthesize_no_1.getId()));
String[] split = synthesize_no_1.getEnergyType().split(",");
for (String s : split) {
if ("2".equals(s)) {
/**
* 供热比例计算
*/
double hotPercentage = hotMsgDto.getHotA() + hotMsgDto.getHotB() + hotMsgDto.getHotC() + hotMsgDto.getHotD() + hotMsgDto.getHotE();
if (hotPercentage != 100) {
throw new BusinessException(CommonErrorCode.E_99999);
}
/**
* 计算 蓄热时间
* @description 0<蓄热时间 < 年供热量 * 1 0 0 0 / ( 供热面积 * 设计热负荷 ) / 1 3 0
*/
Double annualHeatSupply = 0.0; // 年供热量
Double heatingArea = 0.0; // 供热面积
Double designHeatLoad = 0.0; // 设计热负荷
Assert.notEmpty(synthesize_no_2_1List, "建筑类型出错了!");
for (Synthesize_no_2_1 synthesize_no_2_ : synthesize_no_2_1List) {
CalculateLoad calculateLoad = calculateLoadService.getById(synthesize_no_2_.getId());
annualHeatSupply += calculateLoad.getNo22();
heatingArea += synthesize_no_2_.getHeatArea();
CityDict dict = cityDictService.getOne(new QueryWrapper<CityDict>().lambda().eq(CityDict::getName, synthesize_no_1.getProjectSite()));//城市
Sort sort = sortMapper.selectById(synthesize_no_2_.getBuildingTypeId());
Assert.notNull(synthesize_no_2_.getHeatEnd(), "末端形式选择出错了");
String zd_name = "no_" + sort.getId();
if ("1".equals(synthesize_no_2_.getHeatEnd())) {
/**
* 散热器 数据库里面的值
*/
designHeatLoad += (double) hotLoadDataMapper.queryName(zd_name, dict.getId());
} else if ("2".equals(synthesize_no_2_.getHeatEnd())) {
/**
* 地暖
* * 0.9
*/
designHeatLoad += hotLoadDataMapper.queryName(zd_name, dict.getId()) * 0.9;
} else if ("3".equals(synthesize_no_2_.getHeatEnd())) {
/**
* 等级盘管
* * 2
*/
designHeatLoad += (double) (hotLoadDataMapper.queryName(zd_name, dict.getId()) * 2);
}
}
double v = annualHeatSupply * 1000 / (heatingArea * designHeatLoad) / 130;
log.info("蓄热时间 范围 v {}", v);
if (Double.isNaN(v)) {
v = 0;
}
Assert.notNull(hotMsgDto.getHotF(), "蓄热出错");
if (hotMsgDto.getHotF() < 0 || hotMsgDto.getHotF() > v) {
throw new IllegalArgumentException("蓄热时间填写错误,范围应该在0 - " + v);
}
/**
* 蓄热做一个限制,出水温度不能低于进水温度
*/
Synthesize_no_2_6 synthesize_no_2_6 = synthesize_no_2_6Service.getById(synthesize_no_2_3.getId());
if (org.springframework.util.StringUtils.isEmpty(synthesize_no_2_6)) {
Synthesize_no_2_6 synthesize_no_2_61 = synthesize_no_2_6Service.getById("1");
if (synthesize_no_2_61.getNo52() <= hotMsgDto.getHotG()) {
throw new IllegalArgumentException("供热温度填写有误,范围不得大于等于" + synthesize_no_2_61.getNo52());
}
} else {
if (synthesize_no_2_6.getNo52() <= hotMsgDto.getHotG()) {
throw new IllegalArgumentException("供热温度填写有误,范围不得大于等于" + synthesize_no_2_6.getNo52());
}
}
} else if ("3".equals(s)) {
/**
* 供冷比例计算
*/
double coldPercentage = coldMsgDto.getColdA() + coldMsgDto.getColdB() + coldMsgDto.getColdC() + coldMsgDto.getColdD();
if (coldPercentage != 100) {
throw new BusinessException(CommonErrorCode.E_99999);
}
/**
* 计算 蓄冷时间
* @description 0<蓄冷时间 < 年供冷量 * 1 0 0 0 / ( 供冷面积 * 设计冷负荷 ) / 1 5 0
*/
Double annualCoolingCapacity = 0.0; // 年供热量
Double coolingArea = 0.0; // 供热面积
Double designCoolingLoad = 0.0; // 设计热负荷
Assert.notEmpty(synthesize_no_2_1List, "建筑类型出错了!");
for (Synthesize_no_2_1 synthesize_no_2_ : synthesize_no_2_1List) {
CalculateLoad calculateLoad = calculateLoadService.getById(synthesize_no_2_.getId());
annualCoolingCapacity += calculateLoad.getNo22();
coolingArea += synthesize_no_2_.getHeatArea();
CityDict dict = cityDictService.getOne(new QueryWrapper<CityDict>().lambda().eq(CityDict::getName, synthesize_no_1.getProjectSite()));//城市
Sort sort = sortMapper.selectById(synthesize_no_2_.getBuildingTypeId());
Assert.notNull(synthesize_no_2_.getHeatEnd(), "末端形式选择出错了");
String zd_name = "no_" + sort.getId();
if ("1".equals(synthesize_no_2_.getHeatEnd())) {
/**
* 散热器 数据库里面的值
*/
designCoolingLoad += (double) hotLoadDataMapper.queryName(zd_name, dict.getId());
} else if ("2".equals(synthesize_no_2_.getHeatEnd())) {
/**
* 地暖
* * 0.9
*/
designCoolingLoad += hotLoadDataMapper.queryName(zd_name, dict.getId()) * 0.9;
} else if ("3".equals(synthesize_no_2_.getHeatEnd())) {
/**
* 等级盘管
* * 2
*/
designCoolingLoad += (double) (hotLoadDataMapper.queryName(zd_name, dict.getId()) * 2);
}
}
double v = annualCoolingCapacity * 1000 / (coolingArea * designCoolingLoad) / 150;
log.info("蓄冷时间 范围 v {}", v);
if (Double.isNaN(v)) {
v = 0;
}
Assert.notNull(coldMsgDto.getColdE(), "蓄冷时间出错");
if (coldMsgDto.getColdE() < 0 || coldMsgDto.getColdE() > v) {
throw new IllegalArgumentException("蓄冷时间填写错误,范围应该在0 - " + v);
}
/**
* 蓄冷这做一个限制,供冷温度不能高于冷水温度
*/
Synthesize_no_2_6 synthesize_no_2_6 = synthesize_no_2_6Service.getById(synthesize_no_2_3.getId());
String site = synthesize_no_1.getProjectSite();
CityDict cityDict = cityDictService.getOne(new QueryWrapper<CityDict>().lambda().eq(CityDict::getName, site));
Integer no1 = coldWaterDataMapper.selectById(cityDict.getId()).getNo1();
if (org.springframework.util.StringUtils.isEmpty(synthesize_no_2_6)) {
if (no1 <= coldMsgDto.getColdF()) {
throw new IllegalArgumentException("供冷温度填写有误,范围不得大于等于" + no1);
}
} else {
if (org.springframework.util.StringUtils.isEmpty(coldMsgDto.getColdF())) {
coldMsgDto.setColdF(0.0);
}
if (synthesize_no_2_6.getNo51() <= coldMsgDto.getColdF()) {
throw new IllegalArgumentException("供冷温度填写有误,范围不得大于等于" + synthesize_no_2_6.getNo51());
}
}
} else if ("4".equals(s)) {
/**
* 热水比例计算
*/
double hotWaterRatio = hotWaterDto.getHotWaterA() + hotWaterDto.getHotWaterB() + hotWaterDto.getHotWaterC();
if (hotWaterRatio != 100) {
throw new BusinessException(CommonErrorCode.E_99999);
}
}
}
String s1 = JSON.toJSONString(hotMsgDto);
String s2 = JSON.toJSONString(coldMsgDto);
String s3 = JSON.toJSONString(hotWaterDto);
synthesize_no_2_3.setHotMsg(s1);
synthesize_no_2_3.setColdMsg(s2);
synthesize_no_2_3.setHotWaterMsg(s3);
return RestResponse.success(synthesize_no_2_3Service.saveOrUpdate(synthesize_no_2_3));
return RestResponse.success(projectService.no2_3Save(synthesize_no_2_3,photovoltaicArea,windAh,hotMsgDto,coldMsgDto,hotWaterDto));
}
@PostMapping("no_2_4")
... ... @@ -522,64 +194,7 @@ public class ProjectController {
@ApiImplicitParam(name = "id", required = true, value = "no_1项目信息保存返回的ID", dataType = "String"),
})
public RestResponse<Boolean> no2_6ResetType(@PathVariable("id") String id) {
Synthesize_no_2_6 byId = synthesize_no_2_6Service.getById("1");
/**
* 修改 对条件设置的参数修正 热水定额 冷水初始温度 修改
*/
Synthesize_no_1 synthesize_no_1 = no_1Service.getById(id);
if (StringUtils.isNotEmpty(synthesize_no_1.getProjectSite())) {
String site = synthesize_no_1.getProjectSite();
CityDict cityDict = cityDictService.getOne(new QueryWrapper<CityDict>().lambda().eq(CityDict::getName, site));
List<Synthesize_no_2_1> synthesize_no_2_1s = synthesize_no_2_1Service.list(new QueryWrapper<Synthesize_no_2_1>().lambda().eq(Synthesize_no_2_1::getPid, synthesize_no_1.getId()));//建筑
double electricity = 0.0;
double tall = 0.0;
double flat = 0.0;
double floor = 0.0;
if (!synthesize_no_2_1s.isEmpty()) {
for (Synthesize_no_2_1 synthesize_no_2_11 : synthesize_no_2_1s) {
if (StringUtils.isNotEmpty(synthesize_no_2_11.getBuildingTypeId())) {
Sort sort = sortMapper.selectById(synthesize_no_2_11.getBuildingTypeId());
String zd_name = "no_" + sort.getId();
CalculateLoad calculateLoad = calculateLoadService.getOne(new QueryWrapper<CalculateLoad>().lambda().eq(CalculateLoad::getCid, synthesize_no_1.getId()).eq(CalculateLoad::getAid, sort.getId()));
Electrovalence electrovalence = electrovalenceMapper.selectById(cityDict.getId());
if ("住宅".equals(sort.getName()) || "托幼".equals(sort.getName()) || "学校".equals(sort.getName())) {
tall += electrovalence.getNo1();
flat += electrovalence.getNo2();
floor += electrovalence.getNo3();
} else {
tall += electrovalence.getNo11();
flat += electrovalence.getNo22();
floor += electrovalence.getNo33();
}
if (!org.springframework.util.StringUtils.isEmpty(calculateLoad)) {
if (calculateLoad.getNo4().equals(calculateLoad.getNo44())) {
electricity += hotWaterDataMapper.queryName(zd_name, cityDict.getId());
} else {
/**
* 年总需热水总量(调整值)*1000/(人数*365*0.9)
*/
electricity += calculateLoad.getNo44() * 1000 / (synthesize_no_2_11.getWaterPersonNum() * 365 * 0.9);
}
}
/*electricity += hotWaterDataMapper.queryName(zd_name, cityDict.getId());*/
}
}
}
byId.setNo50(electricity);
byId.setNo51(Double.valueOf(coldWaterDataMapper.selectById(cityDict.getId()).getNo1()));// 冷水初始温度
byId.setNo54(cpvAndCfmDataService.getById(cityDict.getId()).getNo7()); // 太阳能保证率
byId.setNo115(cpvAndCfmDataService.getById(cityDict.getId()).getNo6()); // 年平均太阳辐照量
byId.setNo122(cpvAndCfmDataService.getById(cityDict.getId()).getNo2()); // 太阳辐照度
byId.setNo123(cpvAndCfmDataService.getById(cityDict.getId()).getNo3());//年总光伏利用小时数
byId.setNo124(cpvAndCfmDataService.getById(cityDict.getId()).getNo5()); // 年总风机利用小时数
byId.setNo125(tall); // 高峰电价
byId.setNo126(flat); // 平时电价
byId.setNo127(floor); // 低谷电价
byId.setNo128(energySourcesMapper.selectById(cityDict.getId()).getNo2()); // 天然气价格
byId.setNo129(energySourcesMapper.selectById(cityDict.getId()).getNo1()); // 自来水价格
byId.setId(id);
}
return RestResponse.success(synthesize_no_2_6Service.updateById(byId));
return RestResponse.success(projectService.no2_6ResetType(id));
}
/**
... ... @@ -611,190 +226,8 @@ public class ProjectController {
ColdMsgDto coldMsgDto,
HotWaterDto hotWaterDto
) {
if (StringUtils.isNotEmpty(synthesize_no_1Img.getId())) {
synthesize_no_1ImgService.saveOrUpdate(synthesize_no_1Img);
}
/**
* 建筑类型保存
*/
projectService.no2_1Save(synthesize_no_2_1, electricityAh);
Synthesize_no_1 synthesize_no_1 = no_1Service.getById(id);
String projectType = synthesize_no_1.getProjectType();
if ("2".equals(projectType))
synthesize_no_2_2Service.saveOrUpdate(synthesize_no_2_2);
if (!org.springframework.util.StringUtils.isEmpty(synthesize_no_2_3.getId())) {
List<Synthesize_no_2_1> synthesize_no_2_1List = synthesize_no_2_1Service.list(new QueryWrapper<Synthesize_no_2_1>().lambda().eq(Synthesize_no_2_1::getPid, synthesize_no_1.getId()));
String[] split = synthesize_no_1.getEnergyType().split(",");
for (String s : split) {
if ("2".equals(s)) {
/**
* 供热比例计算
*/
double hotPercentage = hotMsgDto.getHotA() + hotMsgDto.getHotB() + hotMsgDto.getHotC() + hotMsgDto.getHotD() + hotMsgDto.getHotE();
if (hotPercentage != 100) {
throw new BusinessException(CommonErrorCode.E_99999);
}
/**
* 计算 蓄热时间
* @description 0<蓄热时间 < 年供热量 * 1 0 0 0 / ( 供热面积 * 设计热负荷 ) / 1 3 0
*/
Double annualHeatSupply = 0.0; // 年供热量
Double heatingArea = 0.0; // 供热面积
Double designHeatLoad = 0.0; // 设计热负荷
Assert.notEmpty(synthesize_no_2_1List, "建筑类型出错了!");
for (Synthesize_no_2_1 synthesize_no_2_ : synthesize_no_2_1List) {
CalculateLoad calculateLoad = calculateLoadService.getById(synthesize_no_2_.getId());
annualHeatSupply += calculateLoad.getNo22();
heatingArea += synthesize_no_2_.getHeatArea();
CityDict dict = cityDictService.getOne(new QueryWrapper<CityDict>().lambda().eq(CityDict::getName, synthesize_no_1.getProjectSite()));//城市
Sort sort = sortMapper.selectById(synthesize_no_2_.getBuildingTypeId());
Assert.notNull(synthesize_no_2_.getHeatEnd(), "末端形式选择出错了");
String zd_name = "no_" + sort.getId();
if ("1".equals(synthesize_no_2_.getHeatEnd())) {
/**
* 散热器 数据库里面的值
*/
designHeatLoad += (double) hotLoadDataMapper.queryName(zd_name, dict.getId());
} else if ("2".equals(synthesize_no_2_.getHeatEnd())) {
/**
* 地暖
* * 0.9
*/
designHeatLoad += hotLoadDataMapper.queryName(zd_name, dict.getId()) * 0.9;
} else if ("3".equals(synthesize_no_2_.getHeatEnd())) {
/**
* 等级盘管
* * 2
*/
designHeatLoad += (double) (hotLoadDataMapper.queryName(zd_name, dict.getId()) * 2);
}
}
double v = annualHeatSupply * 1000 / (heatingArea * designHeatLoad) / 130;
log.info("蓄热时间范围 V {}", v);
if (Double.isNaN(v)) {
v = 0;
}
Assert.notNull(hotMsgDto.getHotF(), "蓄热出错");
if (hotMsgDto.getHotF() < 0 || hotMsgDto.getHotF() > v) {
throw new IllegalArgumentException("蓄热时间填写错误,范围应该在0 - " + v);
}
/**
* 蓄热做一个限制,出水温度不能低于进水温度
*/
Synthesize_no_2_6 synthesize_no_2_6 = synthesize_no_2_6Service.getById(synthesize_no_2_3.getId());
if (org.springframework.util.StringUtils.isEmpty(synthesize_no_2_6)) {
Synthesize_no_2_6 synthesize_no_2_61 = synthesize_no_2_6Service.getById("1");
if (synthesize_no_2_61.getNo52() <= hotMsgDto.getHotG()) {
throw new IllegalArgumentException("供热温度填写有误,范围不得大于等于" + synthesize_no_2_61.getNo52());
}
} else {
if (synthesize_no_2_6.getNo52() <= hotMsgDto.getHotG()) {
throw new IllegalArgumentException("供热温度填写有误,范围不得大于等于" + synthesize_no_2_6.getNo52());
}
}
} else if ("3".equals(s)) {
/**
* 供冷比例计算
*/
double coldPercentage = coldMsgDto.getColdA() + coldMsgDto.getColdB() + coldMsgDto.getColdC() + coldMsgDto.getColdD();
if (coldPercentage != 100) {
throw new BusinessException(CommonErrorCode.E_99999);
}
/**
* 计算 蓄冷时间
* @description 0<蓄冷时间 < 年供冷量 * 1 0 0 0 / ( 供冷面积 * 设计冷负荷 ) / 1 5 0
*/
Double annualCoolingCapacity = 0.0; // 年供热量
Double coolingArea = 0.0; // 供热面积
Double designCoolingLoad = 0.0; // 设计热负荷
Assert.notEmpty(synthesize_no_2_1List, "建筑类型出错了!");
for (Synthesize_no_2_1 synthesize_no_2_ : synthesize_no_2_1List) {
CalculateLoad calculateLoad = calculateLoadService.getById(synthesize_no_2_.getId());
annualCoolingCapacity += calculateLoad.getNo22();
coolingArea += synthesize_no_2_.getHeatArea();
CityDict dict = cityDictService.getOne(new QueryWrapper<CityDict>().lambda().eq(CityDict::getName, synthesize_no_1.getProjectSite()));//城市
Sort sort = sortMapper.selectById(synthesize_no_2_.getBuildingTypeId());
Assert.notNull(synthesize_no_2_.getHeatEnd(), "末端形式选择出错了");
String zd_name = "no_" + sort.getId();
if ("1".equals(synthesize_no_2_.getHeatEnd())) {
/**
* 散热器 数据库里面的值
*/
designCoolingLoad += (double) hotLoadDataMapper.queryName(zd_name, dict.getId());
} else if ("2".equals(synthesize_no_2_.getHeatEnd())) {
/**
* 地暖
* * 0.9
*/
designCoolingLoad += hotLoadDataMapper.queryName(zd_name, dict.getId()) * 0.9;
} else if ("3".equals(synthesize_no_2_.getHeatEnd())) {
/**
* 等级盘管
* * 2
*/
designCoolingLoad += (double) (hotLoadDataMapper.queryName(zd_name, dict.getId()) * 2);
}
}
double v = annualCoolingCapacity * 1000 / (coolingArea * designCoolingLoad) / 150;
log.info("蓄冷时间范围 V {}", v);
if (Double.isNaN(v)) {
v = 0;
}
Assert.notNull(coldMsgDto.getColdE(), "蓄冷时间出错");
if (coldMsgDto.getColdE() < 0 || coldMsgDto.getColdE() > v) {
throw new IllegalArgumentException("蓄冷时间填写错误,范围应该在0 - " + v);
}
/**
* 蓄冷这做一个限制,供冷温度不能高于冷水温度
*/
Synthesize_no_2_6 synthesize_no_2_6 = synthesize_no_2_6Service.getById(synthesize_no_2_3.getId());
String site = synthesize_no_1.getProjectSite();
CityDict cityDict = cityDictService.getOne(new QueryWrapper<CityDict>().lambda().eq(CityDict::getName, site));
Integer no1 = coldWaterDataMapper.selectById(cityDict.getId()).getNo1();
if (org.springframework.util.StringUtils.isEmpty(synthesize_no_2_6)) {
if (no1 <= coldMsgDto.getColdF()) {
throw new IllegalArgumentException("供冷温度填写有误,范围不得大于等于" + no1);
}
} else {
if (org.springframework.util.StringUtils.isEmpty(coldMsgDto.getColdF())) {
coldMsgDto.setColdF(0.0);
}
if (synthesize_no_2_6.getNo51() <= coldMsgDto.getColdF()) {
throw new IllegalArgumentException("供冷温度填写有误,范围不得大于等于" + synthesize_no_2_6.getNo51());
}
}
} else if ("4".equals(s)) {
/**
* 热水比例计算
*/
double hotWaterRatio = hotWaterDto.getHotWaterA() + hotWaterDto.getHotWaterB() + hotWaterDto.getHotWaterC();
if (hotWaterRatio != 100) {
throw new BusinessException(CommonErrorCode.E_99999);
}
}
}
String s1 = JSON.toJSONString(hotMsgDto);
String s2 = JSON.toJSONString(coldMsgDto);
String s3 = JSON.toJSONString(hotWaterDto);
synthesize_no_2_3.setHotMsg(s1);
synthesize_no_2_3.setColdMsg(s2);
synthesize_no_2_3.setHotWaterMsg(s3);
synthesize_no_2_3Service.saveOrUpdate(synthesize_no_2_3);
if (org.springframework.util.StringUtils.isEmpty(synthesize_no_2_4Service.getById(synthesize_no_2_3.getId()))) {
Synthesize_no_2_4 synthesize_no_2_4 = new Synthesize_no_2_4();
synthesize_no_2_4.setId(synthesize_no_2_3.getId());
synthesize_no_2_4.setWindAh(windAh);
synthesize_no_2_4.setPhotovoltaicArea(photovoltaicArea);
synthesize_no_2_4Service.saveOrUpdate(synthesize_no_2_4);
} else {
Synthesize_no_2_4 synthesize_no_2_4 = synthesize_no_2_4Service.getById(synthesize_no_2_3.getId());
synthesize_no_2_4.setWindAh(windAh);
synthesize_no_2_4.setPhotovoltaicArea(photovoltaicArea);
synthesize_no_2_4Service.saveOrUpdate(synthesize_no_2_4);
}
}
if (!org.springframework.util.StringUtils.isEmpty(synthesize_no_2_5.getId()))
synthesize_no_2_5Service.saveOrUpdate(synthesize_no_2_5);
projectService.no3_1GetTypeSave(id, synthesize_no_2_1, synthesize_no_1Img, synthesize_no_2_2, synthesize_no_2_3
, electricityAh, photovoltaicArea, windAh, synthesize_no_2_5, hotMsgDto, coldMsgDto, hotWaterDto);
return RestResponse.success(projectService.no3_1GetType(id));
}
... ... @@ -822,7 +255,6 @@ public class ProjectController {
@ApiImplicitParam(name = "id", required = true, value = "no_1项目信息保存返回的ID", dataType = "String"),
})
public RestResponse<Map<String, Object>> no_3_6GetList(@PathVariable("id") String id) {
return RestResponse.success(projectService.no_3_6GetList(id));
}
... ... @@ -860,130 +292,8 @@ public class ProjectController {
ColdMsgDto coldMsgDto,
HotWaterDto hotWaterDto
) {
if (org.springframework.util.StringUtils.isEmpty(synthesize_no_1.getId())) {
if (StringUtils.isNotEmpty(synthesize_no_1.getProjectSite())) {
synthesize_no_1.setType("1");
synthesize_no_1.setTime(new Date());
synthesize_no_1.setDeleteState("3");
synthesize_no_1.setCountState("0");
synthesize_no_1.setUserId(JwtUtil.getUserId(request.getHeader("token")));
synthesize_no_1.setNewTime(new Date());
} /*else {
synthesize_no_1.setType("1");
synthesize_no_1.setTime(new Date());
synthesize_no_1.setDeleteState("3");
synthesize_no_1.setCountState("0");
synthesize_no_1.setUserId(JwtUtil.getUserId(request.getHeader("token")));
synthesize_no_1.setNewTime(new Date());
}*/
} else {
/**
* 修改 对条件设置的参数修正 热水定额 冷水初始温度 修改
*/
Synthesize_no_1 synthesizeNo1 = no_1Service.getById(synthesize_no_1.getId());
if (StringUtils.isNotEmpty(synthesize_no_1.getProjectSite())) {
String site = synthesize_no_1.getProjectSite();
Synthesize_no_2_6 byId = synthesize_no_2_6Service.getById(synthesize_no_1.getId());
if (org.springframework.util.StringUtils.isEmpty(byId)) {
byId = synthesize_no_2_6Service.getById("1");
}
CityDict cityDict = cityDictService.getOne(new QueryWrapper<CityDict>().lambda().eq(CityDict::getName, site));
List<Synthesize_no_2_1> synthesize_no_2_1s = synthesize_no_2_1Service.list(new QueryWrapper<Synthesize_no_2_1>().lambda().eq(Synthesize_no_2_1::getPid, synthesize_no_1.getId()));//建筑
double electricity = 0.0;
double tall = 0.0;
double flat = 0.0;
double floor = 0.0;
if (!synthesize_no_2_1s.isEmpty()) {
for (Synthesize_no_2_1 synthesize_no_2_11 : synthesize_no_2_1s) {
if (StringUtils.isNotEmpty(synthesize_no_2_11.getBuildingTypeId())) {
Sort sort = sortMapper.selectById(synthesize_no_2_11.getBuildingTypeId());
String zd_name = "no_" + sort.getId();
CalculateLoad calculateLoad = calculateLoadService.getById(synthesize_no_2_11.getId());
Electrovalence electrovalence = electrovalenceMapper.selectById(cityDict.getId());
if ("住宅".equals(sort.getName()) || "托幼".equals(sort.getName()) || "学校".equals(sort.getName())) {
tall += electrovalence.getNo1();
flat += electrovalence.getNo2();
floor += electrovalence.getNo3();
} else {
tall += electrovalence.getNo11();
flat += electrovalence.getNo22();
floor += electrovalence.getNo33();
}
if (!org.springframework.util.StringUtils.isEmpty(calculateLoad)) {
if (calculateLoad.getNo4().equals(calculateLoad.getNo44())) {
electricity += hotWaterDataMapper.queryName(zd_name, cityDict.getId());
} else {
/**
* 年总需热水总量(调整值)*1000/(人数*365*0.9)
*/
electricity += calculateLoad.getNo44() * 1000 / (synthesize_no_2_11.getWaterPersonNum() * 365 * 0.9);
}
}
/*electricity += hotWaterDataMapper.queryName(zd_name, cityDict.getId());*/
}
}
}
if (!synthesizeNo1.getProjectSite().equals(synthesize_no_1.getProjectSite())) {
byId.setId(synthesize_no_1.getId());
byId.setNo50(electricity);
byId.setNo51(Double.valueOf(coldWaterDataMapper.selectById(cityDict.getId()).getNo1()));
byId.setNo54(cpvAndCfmDataService.getById(cityDict.getId()).getNo7()); // 太阳能保证率
byId.setNo115(cpvAndCfmDataService.getById(cityDict.getId()).getNo6()); // 年平均太阳辐照量
byId.setNo122(cpvAndCfmDataService.getById(cityDict.getId()).getNo2()); // 太阳辐照度
byId.setNo123(cpvAndCfmDataService.getById(cityDict.getId()).getNo3());//年总光伏利用小时数
byId.setNo124(cpvAndCfmDataService.getById(cityDict.getId()).getNo5()); // 年总风机利用小时数
byId.setNo128(energySourcesMapper.selectById(cityDict.getId()).getNo2()); // 天然气价格
byId.setNo129(energySourcesMapper.selectById(cityDict.getId()).getNo1()); // 自来水价格
byId.setNo125(tall); // 高峰电价
byId.setNo126(flat); // 平时电价
byId.setNo127(floor); // 低谷电价
synthesize_no_2_6Service.saveOrUpdate(byId);
}
synthesize_no_1.setType(synthesizeNo1.getType());
synthesize_no_1.setDeleteState(synthesizeNo1.getDeleteState());
synthesize_no_1.setCountState(synthesizeNo1.getCountState());
synthesize_no_1.setUserId(synthesizeNo1.getUserId());
synthesize_no_1.setPtState(synthesizeNo1.getPtState());
synthesize_no_1.setAdminState(synthesizeNo1.getAdminState());
synthesize_no_1.setSuperAdminState(synthesizeNo1.getAdminState());
}
}
no_1Service.saveOrUpdate(synthesize_no_1);
if (StringUtils.isNotEmpty(synthesize_no_1.getId())) {
synthesize_no_1ImgService.saveOrUpdate(synthesize_no_1Img);
}
/**
* 建筑类型保存
*/
if (StringUtils.isNotEmpty(synthesize_no_2_1))
projectService.no2_1Save(synthesize_no_2_1, electricityAh);
if (!org.springframework.util.StringUtils.isEmpty(synthesize_no_2_2.getId())) {
synthesize_no_2_2Service.saveOrUpdate(synthesize_no_2_2);
}
if (!org.springframework.util.StringUtils.isEmpty(synthesize_no_2_3.getId())) {
String s1 = JSON.toJSONString(hotMsgDto);
String s2 = JSON.toJSONString(coldMsgDto);
String s3 = JSON.toJSONString(hotWaterDto);
synthesize_no_2_3.setHotMsg(s1);
synthesize_no_2_3.setColdMsg(s2);
synthesize_no_2_3.setHotWaterMsg(s3);
synthesize_no_2_3Service.saveOrUpdate(synthesize_no_2_3);
if (org.springframework.util.StringUtils.isEmpty(synthesize_no_2_4Service.getById(synthesize_no_2_3.getId()))) {
Synthesize_no_2_4 synthesize_no_2_4 = new Synthesize_no_2_4();
synthesize_no_2_4.setId(synthesize_no_2_3.getId());
synthesize_no_2_4.setWindAh(windAh);
synthesize_no_2_4.setPhotovoltaicArea(photovoltaicArea);
synthesize_no_2_4Service.saveOrUpdate(synthesize_no_2_4);
} else {
Synthesize_no_2_4 synthesize_no_2_4 = synthesize_no_2_4Service.getById(synthesize_no_2_3.getId());
synthesize_no_2_4.setWindAh(windAh);
synthesize_no_2_4.setPhotovoltaicArea(photovoltaicArea);
synthesize_no_2_4Service.saveOrUpdate(synthesize_no_2_4);
}
}
if (!org.springframework.util.StringUtils.isEmpty(synthesize_no_2_5.getId()))
synthesize_no_2_5Service.saveOrUpdate(synthesize_no_2_5);
projectService.saveProject(synthesize_no_1, synthesize_no_2_1, electricityAh, photovoltaicArea, windAh,
synthesize_no_1Img, synthesize_no_2_2, synthesize_no_2_3, synthesize_no_2_5, hotMsgDto, coldMsgDto, hotWaterDto);
return RestResponse.success("保存成功");
}
... ...
... ... @@ -4,7 +4,9 @@ import com.synthesize_energy.common.domain.RestResponse;
import com.synthesize_energy.item.entity.SmsCode;
import com.synthesize_energy.item.mapper.SmsCodeMapper;
import com.synthesize_energy.item.utils.SendCodeUtils;
import com.synthesize_energy.item.web.service.SmsCodeService;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
... ... @@ -20,27 +22,16 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("sms")
@Api(value = "发送短信接口", tags = "发送短信接口")
@AllArgsConstructor
public class SmsController {
@Autowired
private SmsCodeMapper smsCodeMapper;
private final SmsCodeService smsCodeService;
@GetMapping("/{phone}")
public RestResponse<String> sendCode(@PathVariable("phone")String phone){
String code = new SendCodeUtils(phone).sendSms();
if (StringUtils.isEmpty(smsCodeMapper.selectById(phone))){
SmsCode smsCode = new SmsCode();
smsCode.setTel(phone);
smsCode.setCode(code);
smsCode.setId(phone);
smsCodeMapper.insert(smsCode);
}else {
SmsCode smsCode = new SmsCode();
smsCode.setTel(phone);
smsCode.setCode(code);
smsCode.setId(phone);
smsCodeMapper.updateById(smsCode);
}
public RestResponse<String> sendCode(
@PathVariable("phone") String phone
) {
smsCodeService.sendCode(phone);
return RestResponse.success("发送成功");
}
}
... ...
... ... @@ -3,9 +3,12 @@ package com.synthesize_energy.item.web.controller;
import com.synthesize_energy.common.domain.RestResponse;
import com.synthesize_energy.item.utils.FileNameUtil;
import com.synthesize_energy.item.utils.FileUploadUtil;
import com.synthesize_energy.item.web.service.UploadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.PostMapping;
... ... @@ -26,37 +29,15 @@ import java.io.FileNotFoundException;
@RestController
@RequestMapping("upload")
@Api(value = "上传图片接口", tags = "上传图片接口")
@AllArgsConstructor
public class UploadController {
@Value("${web.upload-path}")
private String path;
private final UploadService uploadService;
@ApiOperation("图片上传")
@ApiImplicitParam(name = "file", value = "文件", required = true, dataType = "File")
@PostMapping
public RestResponse<String> upload(@RequestParam("file") MultipartFile file, HttpServletRequest request) throws FileNotFoundException {
//定义要上传文件 的存放路径
String localPath = path;
/*String path = ResourceUtils.getURL("classpath:").getPath() + "imgs/";*/
//获得文件名字
String fileName = file.getOriginalFilename();
fileName = FileNameUtil.getFileName(fileName);
File dest = new File(localPath + fileName);
if (FileUploadUtil.upload(file, localPath, fileName)) {
// 将上传的文件写入到服务器端文件夹
// 获取当前项目运气的完整url
String requestURL = request.getRequestURL().toString();
// 获取当前项目的请求路径url
String requestURI = request.getRequestURI();
// 得到去掉了uri的路径
String url = "http://zhny.j.brotop.cn/images/" + fileName;
/*String url = requestURL.substring(0, requestURL.length() - requestURI.length() + 1);*/
/*url = url + "images/" + fileName;*/
/**
* 返回 图片路径
*/
return RestResponse.success(url);
}
return RestResponse.validfail("上传图片出现问题");
public RestResponse<?> upload(@RequestParam("file") MultipartFile file) {
return uploadService.uploadImgPath(file);
}
}
... ...
package com.synthesize_energy.item.web.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.synthesize_energy.item.dto.ElectrovalenceDto;
import com.synthesize_energy.item.entity.ProvinceDict;
import com.synthesize_energy.item.entity.Synthesize_no_1;
import java.util.List;
import java.util.Map;
public interface InformationBaseService {
... ... @@ -10,4 +16,28 @@ public interface InformationBaseService {
* @return
*/
Map<String, Object> queryNatsuralResources(String site);
/**
* 典型案例查询
* @param page
* @param rows
* @return
*/
IPage<Synthesize_no_1> typicalCaseQuery(Integer page, Integer rows,String name);
/**
* 拷贝项目
* @param ids
*/
void copyProject(String ids);
/**
* 经济条件查询
* @param site
* @param buildingType
* @return
*/
ElectrovalenceDto queryEconomicCondition(String site, String buildingType);
List<ProvinceDict> queryCity();
}
... ...
package com.synthesize_energy.item.web.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.synthesize_energy.item.entity.MyIndustry;
import com.synthesize_energy.item.entity.User;
import com.synthesize_energy.item.entity.*;
import java.util.List;
... ... @@ -12,13 +11,39 @@ import java.util.List;
* @date 2020/5/28 13:09
*/
public interface MyService {
void foundAccountNumber(String userId, String type, String name, String companyId, String department, String phone,String id);
void foundAccountNumber(String type, String name, String companyId, String department, String phone,String id);
IPage<User> queryUser(String userId, Integer page, Integer rows,String name);
IPage<User> queryUser(Integer page, Integer rows,String name);
void updateById(String id, String type);
void deleteById(String id);
List<MyIndustry> queryIndustry();
User getFoundById(String id);
void creationUser(Synthesize_no_1ClientName synthesize_no_1ClientName);
void settingClient(String id, String type);
void settingCollect(String id, String type);
User queryUserById(String id);
List<Sort> updateNo2_1getType();
void setUpBuilding(Boolean type, Integer id);
void settingProjectCopy(String type, String ids);
IPage<Synthesize_no_1> queryProject(String name, String type, Integer page, Integer rows);
void deleteRecycle(String ids, String type);
IPage<Synthesize_no_1> queryRecycle(String name, Integer page, Integer rows);
void settingProject(String id, String type);
void settingModelCase(String id, String type);
}
... ...
... ... @@ -10,7 +10,16 @@ import com.synthesize_energy.item.entity.Synthesize_no_1;
* @date 2020/5/22 11:15
*/
public interface No_1Service extends IService<Synthesize_no_1> {
IPage<Synthesize_no_1> queryByList(Integer page, Integer rows, String name, String userId,String type);
/**
* 未立项查询
* @return
*/
IPage<Synthesize_no_1> queryByList(Integer page, Integer rows, String name, String type);
void settingType(String type, String ids, String token);
/**
* 设置项目
*/
void settingType(String type, String ids);
Integer getHeatingDays(String id);
}
... ...
package com.synthesize_energy.item.web.service;
import com.synthesize_energy.item.dto.*;
import com.synthesize_energy.item.entity.CalculateLoad;
import com.synthesize_energy.item.entity.*;
import com.synthesize_energy.item.vo.CalculateLoadVo;
import java.util.List;
... ... @@ -73,4 +73,16 @@ public interface ProjectService {
* @return
*/
EquipmentCapacityVo getComputingCosts(String id);
void saveProject(Synthesize_no_1 synthesize_no_1, String synthesize_no_2_1, Double electricityAh, Double photovoltaicArea, Double windAh, Synthesize_no_1Img synthesize_no_1Img, Synthesize_no_2_2 synthesize_no_2_2, Synthesize_no_2_3 synthesize_no_2_3, Synthesize_no_2_5 synthesize_no_2_5, HotMsgDto hotMsgDto, ColdMsgDto coldMsgDto, HotWaterDto hotWaterDto);
void no3_1GetTypeSave(String id, String synthesize_no_2_1, Synthesize_no_1Img synthesize_no_1Img, Synthesize_no_2_2 synthesize_no_2_2, Synthesize_no_2_3 synthesize_no_2_3, Double electricityAh, Double photovoltaicArea, Double windAh, Synthesize_no_2_5 synthesize_no_2_5, HotMsgDto hotMsgDto, ColdMsgDto coldMsgDto, HotWaterDto hotWaterDto);
Boolean no2_6ResetType(String id);
Boolean no2_3Save(Synthesize_no_2_3 synthesize_no_2_3, Double photovoltaicArea, Double windAh, HotMsgDto hotMsgDto, ColdMsgDto coldMsgDto, HotWaterDto hotWaterDto);
List<ClientNameDto> no1getName(String name);
String no1Save(Synthesize_no_1 synthesize_no_1);
}
... ...
package com.synthesize_energy.item.web.service;
/**
* @author kgy
* @version 1.0
* @date 2020/10/26 17:38
*/
public interface SmsCodeService {
/**
* 发送短信验证码
* @param phone
* @return
*/
void sendCode(String phone);
}
... ...
package com.synthesize_energy.item.web.service;
import com.synthesize_energy.common.domain.RestResponse;
import org.springframework.web.multipart.MultipartFile;
/**
* @author kgy
* @version 1.0
* @date 2020/10/26 17:32
*/
public interface UploadService {
/**
* 上传图片
* @param file
* @return
*/
RestResponse<?> uploadImgPath(MultipartFile file);
/**
* 典型案例 设置图片
*/
void typicalCaseUploadImage(String id, String image);
}
... ...
... ... @@ -12,5 +12,5 @@ import java.util.Map;
* @date 2020/5/21 16:54
*/
public interface UserService extends IService<User> {
Map<String,Object> login(String phone, String code, HttpServletResponse response);
Map<String,Object> login(String phone, String code);
}
... ...
package com.synthesize_energy.item.web.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.synthesize_energy.common.domain.BusinessException;
import com.synthesize_energy.common.domain.CommonErrorCode;
import com.synthesize_energy.item.entity.CityDict;
import com.synthesize_energy.item.entity.CpvAndCfmData;
import com.synthesize_energy.item.web.service.CityDictService;
import com.synthesize_energy.item.web.service.CpvAndCfmDataService;
import com.synthesize_energy.item.web.service.InformationBaseService;
import com.synthesize_energy.item.dto.ElectrovalenceDto;
import com.synthesize_energy.item.dto.Electrovalence_1Dto;
import com.synthesize_energy.item.entity.*;
import com.synthesize_energy.item.mapper.*;
import com.synthesize_energy.item.utils.JwtUtil;
import com.synthesize_energy.item.utils.UserContext;
import com.synthesize_energy.item.web.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
@Service
public class InformationBaseServiceImpl implements InformationBaseService {
... ... @@ -30,6 +33,32 @@ public class InformationBaseServiceImpl implements InformationBaseService {
private Integer num3;
@Autowired
private CityDictService cityDictService;
@Autowired
private No_1Service no_1Service;
@Autowired
private Synthesize_no_1ImgMapper synthesize_no_1ImgMapper;
@Autowired
private Synthesize_no_2_1Service synthesize_no_2_1Service;
@Autowired
private CalculateLoadMapper calculateLoadMapper;
@Autowired
private Synthesize_no_2_2Service synthesize_no_2_2Service;
@Autowired
private Synthesize_no_2_3Service synthesize_no_2_3Service;
@Autowired
private Synthesize_no_2_4Service synthesize_no_2_4Service;
@Autowired
private Synthesize_no_2_5Service synthesize_no_2_5Service;
@Autowired
private Synthesize_no_2_6Service synthesize_no_2_6Service;
@Autowired
private Synthesize_no_3_6Service synthesize_no_3_6Service;
@Autowired
private ElectrovalenceMapper electrovalenceMapper;
@Autowired
private EnergySourcesMapper energySourcesMapper;
@Autowired
private ProvinceDictMapper provinceDictMapper;
@Override
public Map<String, Object> queryNatsuralResources(String site) {
... ... @@ -76,7 +105,7 @@ public class InformationBaseServiceImpl implements InformationBaseService {
* 三类地区
*/
String[] array3 = {"白山", "松原-扶余", "鸡西", "双鸭山", "七台河", "绥化", "伊春", "大兴安岭-漠河", "兰州", "天水", "白银", "定西", "甘南", "金昌", "临夏", "陇南", "平凉", "庆阳", "武威", "吐鲁番", "哈密", "巴音郭楞", "和田", "阿勒泰", "塔城", "阿克苏", "博尔塔拉", "克孜勒苏", "喀什", "图木舒克", "阿拉尔", "五家渠", "银川", "石嘴山", "固原", "中卫", "吴忠"};
site = site.substring(0,site.length() -1);
site = site.substring(0, site.length() - 1);
if (Arrays.asList(array1).contains(site)) {
/**
* 一类地区
... ... @@ -108,4 +137,207 @@ public class InformationBaseServiceImpl implements InformationBaseService {
}
return map;
}
/**
* @return
*/
@Override
public IPage<Synthesize_no_1> typicalCaseQuery(Integer page, Integer rows, String name) {
return no_1Service.page(new Page<>(page, rows), new LambdaQueryWrapper<Synthesize_no_1>()
.eq(Synthesize_no_1::getModelCase, "1")
.like(!StringUtils.isEmpty(name), Synthesize_no_1::getProjectName, name)
.orderByDesc(Synthesize_no_1::getTime));
}
@Override
public void copyProject(String ids) {
String[] split = ids.split(",");
for (String s : split) {
Synthesize_no_1 synthesize_no_1 = no_1Service.getById(s);
synthesize_no_1.setId(null);
synthesize_no_1.setTime(new Date());
synthesize_no_1.setNewTime(new Date());
synthesize_no_1.setType("1");
synthesize_no_1.setUserId(UserContext.get().getId());
synthesize_no_1.setDeleteState("3");
synthesize_no_1.setModelCase(null);
no_1Service.save(synthesize_no_1);
Synthesize_no_1Img synthesize_no_1Img = synthesize_no_1ImgMapper.selectById(s);
if (!StringUtils.isEmpty(synthesize_no_1Img)) {
synthesize_no_1Img.setId(synthesize_no_1.getId());
synthesize_no_1ImgMapper.insert(synthesize_no_1Img);
}
List<Synthesize_no_2_1> list = synthesize_no_2_1Service.list(new QueryWrapper<Synthesize_no_2_1>().lambda().eq(Synthesize_no_2_1::getPid, s));
if (!list.isEmpty()) {
for (Synthesize_no_2_1 synthesize_no_2_1 : list) {
CalculateLoad calculateLoad = calculateLoadMapper.selectById(synthesize_no_2_1.getId());
synthesize_no_2_1.setId(null);
synthesize_no_2_1.setPid(synthesize_no_1.getId());
synthesize_no_2_1Service.save(synthesize_no_2_1);
if (!StringUtils.isEmpty(calculateLoad)) {
calculateLoad.setId(synthesize_no_2_1.getId());
calculateLoad.setCid(synthesize_no_1.getId());
calculateLoadMapper.insert(calculateLoad);
}
}
}
Synthesize_no_2_2 synthesize_no_2_2 = synthesize_no_2_2Service.getById(s);
if (!StringUtils.isEmpty(synthesize_no_2_2)) {
synthesize_no_2_2.setId(synthesize_no_1.getId());
synthesize_no_2_2Service.save(synthesize_no_2_2);
}
Synthesize_no_2_3 synthesize_no_2_3 = synthesize_no_2_3Service.getById(s);
if (!StringUtils.isEmpty(synthesize_no_2_3)) {
synthesize_no_2_3.setId(synthesize_no_1.getId());
synthesize_no_2_3Service.save(synthesize_no_2_3);
}
Synthesize_no_2_4 synthesize_no_2_4 = synthesize_no_2_4Service.getById(s);
if (!StringUtils.isEmpty(synthesize_no_2_4)) {
synthesize_no_2_4.setId(synthesize_no_1.getId());
synthesize_no_2_4Service.save(synthesize_no_2_4);
}
Synthesize_no_2_5 synthesize_no_2_5 = synthesize_no_2_5Service.getById(s);
if (!StringUtils.isEmpty(synthesize_no_2_5)) {
synthesize_no_2_5.setId(synthesize_no_1.getId());
synthesize_no_2_5Service.save(synthesize_no_2_5);
}
Synthesize_no_2_6 synthesize_no_2_6 = synthesize_no_2_6Service.getById(s);
if (!StringUtils.isEmpty(synthesize_no_2_6)) {
synthesize_no_2_6.setId(synthesize_no_1.getId());
synthesize_no_2_6Service.save(synthesize_no_2_6);
}
Synthesize_no_3_6 synthesize_no_3_6 = synthesize_no_3_6Service.getById(s);
if (!StringUtils.isEmpty(synthesize_no_3_6)) {
synthesize_no_3_6.setId(synthesize_no_1.getId());
synthesize_no_3_6Service.save(synthesize_no_3_6);
}
}
}
@Override
public ElectrovalenceDto queryEconomicCondition(String site, String buildingType) {
CityDict dict = cityDictService.getOne(new QueryWrapper<CityDict>().lambda().eq(CityDict::getName, site));
if (StringUtils.isEmpty(dict)) {
throw new BusinessException(CommonErrorCode.E_100101);
}
Integer[] array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
Electrovalence electrovalence = electrovalenceMapper.selectById(dict.getId());
ElectrovalenceDto electrovalenceDto = new ElectrovalenceDto();
List<Electrovalence_1Dto> list = new ArrayList<>();
Electrovalence_1Dto electrovalence_1Dto = null;
for (Integer integer : array) {
if ("住宅".equals(buildingType) || "托幼".equals(buildingType) || "学校".equals(buildingType)) {
switch (integer) {
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 23:
case 24:
electrovalence_1Dto = new Electrovalence_1Dto();
electrovalence_1Dto.setNum(integer);
electrovalence_1Dto.setPrice(electrovalence.getNo3());
list.add(electrovalence_1Dto);
break;
case 7:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
electrovalence_1Dto = new Electrovalence_1Dto();
electrovalence_1Dto.setNum(integer);
electrovalence_1Dto.setPrice(electrovalence.getNo2());
list.add(electrovalence_1Dto);
break;
case 8:
case 9:
case 10:
case 18:
case 19:
case 20:
case 21:
case 22:
electrovalence_1Dto = new Electrovalence_1Dto();
electrovalence_1Dto.setNum(integer);
electrovalence_1Dto.setPrice(electrovalence.getNo1());
list.add(electrovalence_1Dto);
break;
default:
break;
}
} else {
switch (integer) {
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 23:
case 24:
electrovalence_1Dto = new Electrovalence_1Dto();
electrovalence_1Dto.setNum(integer);
electrovalence_1Dto.setPrice(electrovalence.getNo33());
list.add(electrovalence_1Dto);
break;
case 7:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
electrovalence_1Dto = new Electrovalence_1Dto();
electrovalence_1Dto.setNum(integer);
electrovalence_1Dto.setPrice(electrovalence.getNo22());
list.add(electrovalence_1Dto);
break;
case 8:
case 9:
case 10:
case 18:
case 19:
case 20:
case 21:
case 22:
electrovalence_1Dto = new Electrovalence_1Dto();
electrovalence_1Dto.setNum(integer);
electrovalence_1Dto.setPrice(electrovalence.getNo11());
list.add(electrovalence_1Dto);
break;
default:
break;
}
}
}
electrovalenceDto.setList(list);
EnergySources energySources = energySourcesMapper.selectById(dict.getId());
electrovalenceDto.setNaturalGas(energySources.getNo2());
electrovalenceDto.setRunningWater(energySources.getNo1());
return electrovalenceDto;
}
/**
* 省市联动查询
* @return
*/
@Override
public List<ProvinceDict> queryCity() {
List<ProvinceDict> list = new ArrayList<>();
for (ProvinceDict provinceDict : provinceDictMapper.selectList(new QueryWrapper<>())) {
ProvinceDict provinceDict1 = new ProvinceDict();
List<CityDict> cityDicts = cityDictService.list(new QueryWrapper<CityDict>().lambda().eq(CityDict::getSId, provinceDict.getId()));
provinceDict1.setId(provinceDict.getId());
provinceDict1.setName(provinceDict.getName());
provinceDict1.setList(cityDicts);
list.add(provinceDict1);
}
return list;
}
}
... ...
package com.synthesize_energy.item.web.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.synthesize_energy.common.domain.BusinessException;
import com.synthesize_energy.common.domain.CommonErrorCode;
import com.synthesize_energy.item.entity.MyIndustry;
import com.synthesize_energy.item.entity.User;
import com.synthesize_energy.item.mapper.CompanyDataMapper;
import com.synthesize_energy.item.mapper.MyIndustryMapper;
import com.synthesize_energy.item.mapper.UserMapper;
import com.synthesize_energy.item.web.service.MyService;
import com.synthesize_energy.common.domain.PageVO;
import com.synthesize_energy.item.entity.*;
import com.synthesize_energy.item.mapper.*;
import com.synthesize_energy.item.utils.JwtUtil;
import com.synthesize_energy.item.utils.UserContext;
import com.synthesize_energy.item.web.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
... ... @@ -35,11 +36,34 @@ public class MyServiceImpl implements MyService {
private CompanyDataMapper companyDataMapper;
@Autowired
private MyIndustryMapper myIndustryMapper;
@Autowired
private UserService userService;
@Autowired
private Synthesize_no_1ClientNameService synthesize_no_1ClientNameService;
@Autowired
private SortMapper sortMapper;
@Autowired
private CalculateLoadMapper calculateLoadMapper;
@Autowired
private No_1Service no_1Service;
@Autowired
private Synthesize_no_1ImgMapper synthesize_no_1ImgMapper;
@Autowired
private Synthesize_no_2_1Service synthesize_no_2_1Service;
@Autowired
private Synthesize_no_2_2Service synthesize_no_2_2Service;
@Autowired
private Synthesize_no_2_3Service synthesize_no_2_3Service;
@Autowired
private Synthesize_no_2_4Service synthesize_no_2_4Service;
@Autowired
private Synthesize_no_2_5Service synthesize_no_2_5Service;
@Autowired
private Synthesize_no_2_6Service synthesize_no_2_6Service;
/**
* 创建账号
*
* @param userId
* @param type
* @param name
* @param companyId
... ... @@ -47,7 +71,14 @@ public class MyServiceImpl implements MyService {
* @param phone
*/
@Override
public void foundAccountNumber(String userId, String type, String name, String companyId, String department, String phone, String id) {
public void foundAccountNumber(String type, String name, String companyId, String department, String phone, String id) {
if (StringUtils.isEmpty(id)) {
List<User> list = userService.list(new QueryWrapper<User>().lambda().eq(User::getPhone, phone));
if (!list.isEmpty()) {
throw new BusinessException(CommonErrorCode.E_999995);
}
}
String userId = UserContext.get().getId();
if (StringUtils.isEmpty(id)) {
User newUser = new User();
User user = userMapper.selectById(userId);
... ... @@ -114,8 +145,8 @@ public class MyServiceImpl implements MyService {
* @return
*/
@Override
public IPage<User> queryUser(String userId, Integer page, Integer rows, String name) {
User user = userMapper.selectById(userId);
public IPage<User> queryUser(Integer page, Integer rows, String name) {
User user = UserContext.get();
if ("1".equals(user.getStatus())) {
throw new BusinessException(CommonErrorCode.E_20002);
} else if ("2".equals(user.getStatus())) {
... ... @@ -205,4 +236,485 @@ public class MyServiceImpl implements MyService {
}
return myIndustries;
}
@Override
public User getFoundById(String id) {
User user = userService.getById(id);
CompanyData companyData = companyDataMapper.selectById(id);
user.setCompanyId(companyData.getName());
return user;
}
@Override
public void creationUser(Synthesize_no_1ClientName synthesize_no_1ClientName) {
if (StringUtils.isEmpty(synthesize_no_1ClientName.getId())) {
synthesize_no_1ClientName.setUserId(UserContext.get().getId());
synthesize_no_1ClientName.setTime(new Date());
synthesize_no_1ClientName.setNewTime(synthesize_no_1ClientName.getName());
synthesize_no_1ClientName.setDeleteState("0");
} else {
synthesize_no_1ClientName.setNewTime(synthesize_no_1ClientName.getName());
}
synthesize_no_1ClientNameService.saveOrUpdate(synthesize_no_1ClientName);
}
@Override
public void settingClient(String id, String type) {
String[] split = id.split(",");
for (String s : split) {
Synthesize_no_1ClientName synthesize_no_1ClientName = synthesize_no_1ClientNameService.getById(s);
switch (type) {
case "1":
synthesize_no_1ClientName.setType("1");
synthesize_no_1ClientName.setNewTime("11111");
break;
case "2":
synthesize_no_1ClientName.setType(null);
synthesize_no_1ClientName.setNewTime(synthesize_no_1ClientName.getName());
break;
case "3":
synthesize_no_1ClientName.setDeleteState("1");
break;
default:
break;
}
synthesize_no_1ClientNameService.updateById(synthesize_no_1ClientName);
}
}
@Override
public void settingCollect(String id, String type) {
Synthesize_no_1ClientName synthesize_no_1ClientName = new Synthesize_no_1ClientName();
synthesize_no_1ClientName.setId(id);
synthesize_no_1ClientName.setCollectState(type);
synthesize_no_1ClientNameService.updateById(synthesize_no_1ClientName);
}
@Override
public User queryUserById(String id) {
User service = userService.getById(id);
service.setCompanyName(companyDataMapper.selectById(service.getCompanyId()).getName());
return service;
}
@Override
public List<Sort> updateNo2_1getType() {
List<Sort> sorts = sortMapper.selectList(new LambdaQueryWrapper<Sort>().ne(Sort::getPid, "0"));
for (Sort sort : sorts) {
if ("1".equals(sort.getState())) {
sort.setFlag(false);
} else {
sort.setFlag(true);
}
}
return sorts;
}
@Override
public void setUpBuilding(Boolean type, Integer id) {
if (!type) {
Sort sort = new Sort();
sort.setId(id);
sort.setState("1");
sortMapper.updateById(sort);
} else {
Sort sort = new Sort();
sort.setId(id);
sort.setState("2");
sortMapper.updateById(sort);
}
}
@Override
public void settingProjectCopy(String type, String ids) {
String[] split = ids.split(",");
User user = UserContext.get();
for (String s : split) {
Synthesize_no_1 synthesize_no_1 = no_1Service.getById(s);
if ("1".equals(type)) {
/**
* 1置顶
*/
if ("1".equals(user.getStatus())) {
/**
* 普通用户置顶
*/
synthesize_no_1.setId(s);
synthesize_no_1.setPtState("1");
no_1Service.updateById(synthesize_no_1);
} else if ("2".equals(user.getStatus())) {
/**
* 管理员置顶
*/
synthesize_no_1.setId(s);
synthesize_no_1.setAdminState("1");
no_1Service.updateById(synthesize_no_1);
} else if ("3".equals(user.getStatus())) {
/**
* super管理员置顶
*/
synthesize_no_1.setId(s);
synthesize_no_1.setSuperAdminState("1");
no_1Service.updateById(synthesize_no_1);
}
} else if ("2".equals(type)) {
/**
* 2取消置顶
*/
if ("1".equals(user.getStatus())) {
/**
* 普通用户取消置顶
*/
synthesize_no_1.setId(s);
synthesize_no_1.setPtState(null);
no_1Service.updateById(synthesize_no_1);
} else if ("2".equals(user.getStatus())) {
/**
* 管理员取消置顶
*/
synthesize_no_1.setId(s);
synthesize_no_1.setAdminState(null);
no_1Service.updateById(synthesize_no_1);
} else if ("3".equals(user.getStatus())) {
/**
* super管理员取消置顶
*/
synthesize_no_1.setId(s);
synthesize_no_1.setSuperAdminState(null);
no_1Service.updateById(synthesize_no_1);
}
} else if ("3".equals(type)) {
/**
* 3复制
*/
synthesize_no_1.setId(null);
/* synthesize_no_1.setClientName(null);
synthesize_no_1.setProjectSite(null);
synthesize_no_1.setProjectSiteAll(null);
synthesize_no_1.setProjectContact(null);
synthesize_no_1.setProjectPhone(null);*/
synthesize_no_1.setTime(new Date());
synthesize_no_1.setNewTime(new Date());
synthesize_no_1.setType("1");
synthesize_no_1.setUserId(user.getId());
/* synthesize_no_1.setPtState(null);
synthesize_no_1.setAdminState(null);
synthesize_no_1.setSuperAdminState(null);*/
synthesize_no_1.setDeleteState("3");
no_1Service.save(synthesize_no_1);
Synthesize_no_1Img synthesize_no_1Img = synthesize_no_1ImgMapper.selectById(s);
if (!StringUtils.isEmpty(synthesize_no_1Img)) {
synthesize_no_1Img.setId(synthesize_no_1.getId());
synthesize_no_1ImgMapper.insert(synthesize_no_1Img);
}
List<Synthesize_no_2_1> list = synthesize_no_2_1Service.list(new QueryWrapper<Synthesize_no_2_1>().lambda().eq(Synthesize_no_2_1::getPid, s));
if (!list.isEmpty()) {
for (Synthesize_no_2_1 synthesize_no_2_1 : list) {
CalculateLoad calculateLoad = calculateLoadMapper.selectById(synthesize_no_2_1.getId());
synthesize_no_2_1.setId(null);
synthesize_no_2_1.setPid(synthesize_no_1.getId());
synthesize_no_2_1Service.save(synthesize_no_2_1);
if (!StringUtils.isEmpty(calculateLoad)) {
calculateLoad.setId(synthesize_no_2_1.getId());
calculateLoad.setCid(synthesize_no_1.getId());
calculateLoadMapper.insert(calculateLoad);
}
}
}
Synthesize_no_2_2 synthesize_no_2_2 = synthesize_no_2_2Service.getById(s);
if (!StringUtils.isEmpty(synthesize_no_2_2)) {
synthesize_no_2_2.setId(synthesize_no_1.getId());
synthesize_no_2_2Service.save(synthesize_no_2_2);
}
Synthesize_no_2_3 synthesize_no_2_3 = synthesize_no_2_3Service.getById(s);
if (!StringUtils.isEmpty(synthesize_no_2_3)) {
synthesize_no_2_3.setId(synthesize_no_1.getId());
synthesize_no_2_3Service.save(synthesize_no_2_3);
}
Synthesize_no_2_4 synthesize_no_2_4 = synthesize_no_2_4Service.getById(s);
if (!StringUtils.isEmpty(synthesize_no_2_4)) {
synthesize_no_2_4.setId(synthesize_no_1.getId());
synthesize_no_2_4Service.save(synthesize_no_2_4);
}
Synthesize_no_2_5 synthesize_no_2_5 = synthesize_no_2_5Service.getById(s);
if (!StringUtils.isEmpty(synthesize_no_2_5)) {
synthesize_no_2_5.setId(synthesize_no_1.getId());
synthesize_no_2_5Service.save(synthesize_no_2_5);
}
Synthesize_no_2_6 synthesize_no_2_6 = synthesize_no_2_6Service.getById(s);
if (!StringUtils.isEmpty(synthesize_no_2_6)) {
synthesize_no_2_6.setId(synthesize_no_1.getId());
synthesize_no_2_6Service.save(synthesize_no_2_6);
}
} else if ("4".equals(type)) {
/**
* 4删除
*/
synthesize_no_1.setId(s);
synthesize_no_1.setDeleteState("1");
no_1Service.updateById(synthesize_no_1);
}
}
}
@Override
public IPage<Synthesize_no_1> queryProject(String name, String type, Integer page, Integer rows) {
User user = UserContext.get();
if ("1".equals(user.getStatus())) {
/**
* 查看自己的项目
*/
for (Synthesize_no_1 synthesize_no_1 : no_1Service.list(new LambdaQueryWrapper<Synthesize_no_1>()
.eq(Synthesize_no_1::getPtState, "1")
.eq(Synthesize_no_1::getUserId, user.getId())
.eq(Synthesize_no_1::getDeleteState, "3"))) {
synthesize_no_1.setNewTime(new Date());
no_1Service.updateById(synthesize_no_1);
}
IPage<Synthesize_no_1> iPage = no_1Service.page(new Page<>(page, rows), new LambdaQueryWrapper<Synthesize_no_1>()
.eq(Synthesize_no_1::getUserId, user.getId())
.eq(Synthesize_no_1::getDeleteState, "3")
.like(!StringUtils.isEmpty(name), Synthesize_no_1::getProjectName, name)
.orderByDesc(Synthesize_no_1::getNewTime));
for (Synthesize_no_1 record : iPage.getRecords()) {
record.setUserId(user.getName());
}
return iPage;
} else if ("2".equals(user.getStatus())) {
/**
* 管理员 外加 自己部分的所有项目
*/
for (Synthesize_no_1 synthesize_no_1 : no_1Service.list(new LambdaQueryWrapper<Synthesize_no_1>()
.eq(Synthesize_no_1::getAdminState, "1")
.eq(Synthesize_no_1::getUserId, user.getId())
.eq(Synthesize_no_1::getDeleteState, "3"))) {
synthesize_no_1.setNewTime(new Date());
no_1Service.updateById(synthesize_no_1);
}
List<User> users = userMapper.selectList(new LambdaQueryWrapper<User>().eq(User::getCompanyId, user.getCompanyId()));
List<String> list2 = new ArrayList<>();
for (User user1 : users) {
list2.add(user1.getId());
}
IPage<Synthesize_no_1> iPage = no_1Service.page(new Page<>(page, rows), new LambdaQueryWrapper<Synthesize_no_1>()
.eq(Synthesize_no_1::getDeleteState, "3")
.in(Synthesize_no_1::getUserId, list2)
.like(!StringUtils.isEmpty(name), Synthesize_no_1::getProjectName, name)
.orderByDesc(Synthesize_no_1::getNewTime));
for (Synthesize_no_1 record : iPage.getRecords()) {
User user1 = userMapper.selectById(record.getUserId());
if (!user.getId().equals(user1.getId())) {
record.setFlag(false);
}
record.setUserId(user1.getName());
}
return iPage;
} else if ("3".equals(user.getStatus())) {
/**
* 自己项目跟别人的项目
*/
for (Synthesize_no_1 synthesize_no_1 : no_1Service.list(new LambdaQueryWrapper<Synthesize_no_1>()
.eq(Synthesize_no_1::getSuperAdminState, "1")
.eq(Synthesize_no_1::getType, "1")
.eq(Synthesize_no_1::getDeleteState, "3"))) {
synthesize_no_1.setNewTime(new Date());
no_1Service.updateById(synthesize_no_1);
}
if ("1".equals(type)) {
/**
* 查询全部
*/
IPage<Synthesize_no_1> iPage = no_1Service.page(new Page<>(page, rows), new LambdaQueryWrapper<Synthesize_no_1>()
.eq(Synthesize_no_1::getDeleteState, "3")
.like(!StringUtils.isEmpty(name), Synthesize_no_1::getProjectName, name)
.orderByDesc(Synthesize_no_1::getNewTime));
if (!iPage.getRecords().isEmpty()) {
for (Synthesize_no_1 record : iPage.getRecords()) {
User user1 = userMapper.selectById(record.getUserId());
if (!user.getId().equals(user1.getId())) {
record.setFlag(false);
}
record.setUserId(user1.getName());
}
}
return iPage;
} else if ("2".equals(type)) {
/**
* 查询自己的
*/
IPage<Synthesize_no_1> iPage = no_1Service.page(new Page<>(page, rows), new LambdaQueryWrapper<Synthesize_no_1>()
.eq(Synthesize_no_1::getDeleteState, "3")
.eq(Synthesize_no_1::getUserId, user.getId())
.like(!StringUtils.isEmpty(name), Synthesize_no_1::getProjectName, name)
.orderByDesc(Synthesize_no_1::getNewTime));
if (!iPage.getRecords().isEmpty()) {
for (Synthesize_no_1 record : iPage.getRecords()) {
User user1 = userMapper.selectById(record.getUserId());
if (!user.getId().equals(user1.getId())) {
record.setFlag(false);
}
record.setUserId(user1.getName());
}
}
return iPage;
} else {
/**
* 查询 部门的
*/
List<User> users = userMapper.selectList(new LambdaQueryWrapper<User>()
.eq(User::getCompanyId, type));
List<String> list2 = new ArrayList<>();
if (!users.isEmpty()) {
for (User user1 : users) {
list2.add(user1.getId());
}
}
if (!list2.isEmpty()) {
IPage<Synthesize_no_1> iPage = no_1Service.page(new Page<>(page, rows), new LambdaQueryWrapper<Synthesize_no_1>()
.eq(Synthesize_no_1::getDeleteState, "3")
.in(Synthesize_no_1::getUserId, list2)
.like(!StringUtils.isEmpty(name), Synthesize_no_1::getProjectName, name)
.orderByDesc(Synthesize_no_1::getNewTime));
if (!iPage.getRecords().isEmpty()) {
for (Synthesize_no_1 record : iPage.getRecords()) {
User user1 = userMapper.selectById(record.getUserId());
if (!user.getId().equals(user1.getId())) {
record.setFlag(false);
}
record.setUserId(user1.getName());
}
}
return iPage;
}
}
}
return null;
}
@Override
public void deleteRecycle(String ids, String type) {
String[] split = ids.split(",");
for (String s : split) {
Synthesize_no_1 synthesize_no_1 = no_1Service.getById(s);
if ("1".equals(type)) {
/**
* 恢复
*/
synthesize_no_1.setId(s);
synthesize_no_1.setDeleteState("3");
no_1Service.updateById(synthesize_no_1);
} else if ("2".equals(type)) {
/**
* 彻底删除
*/
synthesize_no_1.setId(s);
synthesize_no_1.setDeleteState("2");
no_1Service.updateById(synthesize_no_1);
}
}
}
@Override
public IPage<Synthesize_no_1> queryRecycle(String name, Integer page, Integer rows) {
IPage<Synthesize_no_1> page1 = no_1Service.page(new Page<>(page, rows), new LambdaQueryWrapper<Synthesize_no_1>().eq(Synthesize_no_1::getDeleteState, "1").like(!StringUtils.isEmpty(name), Synthesize_no_1::getProjectName, name));
for (Synthesize_no_1 record : page1.getRecords()) {
record.setUserId(userService.getById(record.getUserId()).getName());
}
return page1;
}
@Override
public void settingProject(String id, String type) {
Synthesize_no_1 synthesize_no_1 = no_1Service.getById(id);
if ("1".equals(type)) {
/**
* 未立项
*/
synthesize_no_1.setType("1");
no_1Service.updateById(synthesize_no_1);
} else if ("2".equals(type)) {
/**
* 立项
*/
synthesize_no_1.setType("2");
no_1Service.updateById(synthesize_no_1);
}
}
@Override
public void settingModelCase(String id, String type) {
Synthesize_no_1 no_1 = no_1Service.getById(id);
if ("1".equals(type)) {
no_1.setId(null);
no_1.setClientName(null);
no_1.setProjectSite(null);
no_1.setProjectSiteAll(null);
no_1.setProjectContact(null);
no_1.setProjectPhone(null);
no_1.setTime(new Date());
no_1.setNewTime(new Date());
no_1.setPtState(null);
no_1.setType(null);
no_1.setUserId(null);
no_1.setAdminState(null);
no_1.setSuperAdminState(null);
no_1.setDeleteState(null);
no_1.setModelCase("2");
no_1Service.save(no_1);
Synthesize_no_1 no_1_1 = no_1Service.getById(id);
no_1_1.setModelCaseId(no_1.getId());
no_1_1.setModelCase("1");
no_1Service.updateById(no_1_1);
Synthesize_no_1Img synthesize_no_1Img = synthesize_no_1ImgMapper.selectById(id);
if (!StringUtils.isEmpty(synthesize_no_1Img)) {
synthesize_no_1Img.setId(no_1.getId());
synthesize_no_1ImgMapper.insert(synthesize_no_1Img);
}
List<Synthesize_no_2_1> list = synthesize_no_2_1Service.list(new QueryWrapper<Synthesize_no_2_1>().lambda().eq(Synthesize_no_2_1::getPid, id));
if (!list.isEmpty()) {
for (Synthesize_no_2_1 synthesize_no_2_1 : list) {
synthesize_no_2_1.setId(null);
synthesize_no_2_1.setPid(no_1.getId());
synthesize_no_2_1Service.save(synthesize_no_2_1);
}
}
Synthesize_no_2_2 synthesize_no_2_2 = synthesize_no_2_2Service.getById(id);
if (!StringUtils.isEmpty(synthesize_no_2_2)) {
synthesize_no_2_2.setId(no_1.getId());
synthesize_no_2_2Service.save(synthesize_no_2_2);
}
Synthesize_no_2_3 synthesize_no_2_3 = synthesize_no_2_3Service.getById(id);
if (!StringUtils.isEmpty(synthesize_no_2_3)) {
synthesize_no_2_3.setId(no_1.getId());
synthesize_no_2_3Service.save(synthesize_no_2_3);
}
Synthesize_no_2_4 synthesize_no_2_4 = synthesize_no_2_4Service.getById(id);
if (!StringUtils.isEmpty(synthesize_no_2_4)) {
synthesize_no_2_4.setId(no_1.getId());
synthesize_no_2_4Service.save(synthesize_no_2_4);
}
Synthesize_no_2_5 synthesize_no_2_5 = synthesize_no_2_5Service.getById(id);
if (!StringUtils.isEmpty(synthesize_no_2_5)) {
synthesize_no_2_5.setId(no_1.getId());
synthesize_no_2_5Service.save(synthesize_no_2_5);
}
Synthesize_no_2_6 synthesize_no_2_6 = synthesize_no_2_6Service.getById(id);
if (!StringUtils.isEmpty(synthesize_no_2_6)) {
synthesize_no_2_6.setId(no_1.getId());
synthesize_no_2_6Service.save(synthesize_no_2_6);
}
} else if ("2".equals(type)) {
no_1Service.removeById(no_1.getModelCaseId());
synthesize_no_1ImgMapper.deleteById(no_1.getModelCaseId());
synthesize_no_2_1Service.remove(new QueryWrapper<Synthesize_no_2_1>().lambda().eq(Synthesize_no_2_1::getPid, no_1.getModelCaseId()));
synthesize_no_2_2Service.removeById(no_1.getModelCaseId());
synthesize_no_2_3Service.removeById(no_1.getModelCaseId());
synthesize_no_2_4Service.removeById(no_1.getModelCaseId());
synthesize_no_2_5Service.removeById(no_1.getModelCaseId());
synthesize_no_2_6Service.removeById(no_1.getModelCaseId());
no_1.setModelCaseId(null);
no_1.setModelCase(null);
no_1Service.updateById(no_1);
}
}
}
... ...
... ... @@ -6,15 +6,14 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.synthesize_energy.common.domain.PageVO;
import com.synthesize_energy.item.entity.*;
import com.synthesize_energy.item.mapper.CalculateLoadMapper;
import com.synthesize_energy.item.mapper.No_1Mapper;
import com.synthesize_energy.item.mapper.Synthesize_no_1ImgMapper;
import com.synthesize_energy.item.mapper.UserMapper;
import com.synthesize_energy.item.mapper.*;
import com.synthesize_energy.item.utils.UserContext;
import com.synthesize_energy.item.web.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
... ... @@ -50,6 +49,10 @@ public class No_1ServiceImpl extends ServiceImpl<No_1Mapper, Synthesize_no_1> im
private Synthesize_no_2_5Service synthesize_no_2_5Service;
@Autowired
private Synthesize_no_2_6Service synthesize_no_2_6Service;
@Autowired
private CityDictService cityDictService;
@Autowired
private HeatIngDataMapper heatIngDataMapper;
/**
* 首页未立项 查询
... ... @@ -60,8 +63,8 @@ public class No_1ServiceImpl extends ServiceImpl<No_1Mapper, Synthesize_no_1> im
* @return
*/
@Override
public IPage<Synthesize_no_1> queryByList(Integer page, Integer rows, String name, String userId,String type) {
User user = userMapper.selectById(userId);
public IPage<Synthesize_no_1> queryByList(Integer page, Integer rows, String name, String type) {
User user = UserContext.get();
switch (user.getStatus()) {
case "1":
/**
... ... @@ -216,11 +219,10 @@ public class No_1ServiceImpl extends ServiceImpl<No_1Mapper, Synthesize_no_1> im
*
* @param type
* @param ids
* @param userId
*/
@Override
public void settingType(String type, String ids, String userId) {
User user = userMapper.selectById(userId);
public void settingType(String type, String ids) {
User user = UserContext.get();
String[] split = ids.split(",");
if ("1".equals(type)) {
/**
... ... @@ -293,13 +295,11 @@ public class No_1ServiceImpl extends ServiceImpl<No_1Mapper, Synthesize_no_1> im
List<Synthesize_no_2_1> list = synthesize_no_2_1Service.list(new QueryWrapper<Synthesize_no_2_1>().lambda().eq(Synthesize_no_2_1::getPid, s));
if (!list.isEmpty()) {
for (Synthesize_no_2_1 synthesize_no_2_1 : list) {
log.warn("i--------f{}",synthesize_no_2_1.getId());
CalculateLoad calculateLoad = calculateLoadMapper.selectById(synthesize_no_2_1.getId());
log.warn("calculateLoad -----{}",calculateLoad);
synthesize_no_2_1.setId(null);
synthesize_no_2_1.setPid(synthesize_no_1.getId());
synthesize_no_2_1Service.save(synthesize_no_2_1);
if (!StringUtils.isEmpty(calculateLoad)){
if (!StringUtils.isEmpty(calculateLoad)) {
calculateLoad.setId(synthesize_no_2_1.getId());
calculateLoad.setCid(synthesize_no_1.getId());
calculateLoadMapper.insert(calculateLoad);
... ... @@ -343,4 +343,13 @@ public class No_1ServiceImpl extends ServiceImpl<No_1Mapper, Synthesize_no_1> im
}
}
}
@Override
public Integer getHeatingDays(String id) {
Synthesize_no_1 synthesize_no_1 = no_1Service.getById(id);
Assert.notNull(synthesize_no_1, "请先保存项目信息!");
CityDict dict = cityDictService.getOne(new QueryWrapper<CityDict>().lambda().eq(CityDict::getName, synthesize_no_1.getProjectSite()));//城市
HeatIngData heatIngData = heatIngDataMapper.selectById(dict.getId());
return heatIngData.getNo3();
}
}
... ...
... ... @@ -12,7 +12,10 @@ import com.synthesize_energy.common.domain.CommonErrorCode;
import com.synthesize_energy.item.algorithm.NpvData;
import com.synthesize_energy.item.dto.*;
import com.synthesize_energy.item.entity.*;
import com.synthesize_energy.item.event.No2_1SaveEvent;
import com.synthesize_energy.item.mapper.*;
import com.synthesize_energy.item.utils.JwtUtil;
import com.synthesize_energy.item.utils.UserContext;
import com.synthesize_energy.item.vo.CalculateLoadVo;
import com.synthesize_energy.item.vo.EnergyEquipmentVo;
import com.synthesize_energy.item.vo.LoadParameterVo;
... ... @@ -23,6 +26,7 @@ import net.sf.jsqlparser.expression.LongValue;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
... ... @@ -32,6 +36,7 @@ import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author kgy
... ... @@ -273,16 +278,16 @@ public class ProjectServiceImpl implements ProjectService {
String[] split = byId.getEnergyType().split(",");// 1供电 2供热 3供冷 4热水
CityDict dict = cityDictService.getOne(new QueryWrapper<CityDict>().lambda().eq(CityDict::getName, byId.getProjectSite()));//城市
Synthesize_no_2_6 synthesizeNo26ServiceById = synthesize_no_2_6Service.getById(id);// 典型值
CpvAndCfmData cfmData = cpvAndCfmDataService.getById(dict.getId());// 光伏相关数据调用表原始表 风电相关数据调用表原始表
//CpvAndCfmData cfmData = cpvAndCfmDataService.getById(dict.getId());// 光伏相关数据调用表原始表 风电相关数据调用表原始表
Synthesize_no_2_3 synthesize_no_2_3 = synthesize_no_2_3Service.getById(id);//能源设备 供电 供热 供冷 热水
List<No_3_1_1Dto> list = new ArrayList<>();
String[] array = new String[]{"供电系统", "供热系统", "供冷系统", "热水系统"};
String[] array2 = new String[]{"电网", "光伏发电", "风电", "储能", "电锅炉", "空气源热泵(制热型)", "空气源热泵(双工况)", "燃气锅炉", "空气源热泵(制冷型)", "空气源热泵(双工况)", "冷水机组", "太阳能集热器", "空气源热泵(热水型)", "多联机中央空调", "蓄热", "双蓄", "蓄冷", "地源热泵", "水源热泵"};
List<Synthesize_no_2_1> synthesize_no_2_1s = synthesize_no_2_1Service.list(new QueryWrapper<Synthesize_no_2_1>().lambda().eq(Synthesize_no_2_1::getPid, id));//建筑
applicationContext.publishEvent(new No2_1SaveEvent(synthesize_no_2_1s));
//Electrovalence electrovalence = electrovalenceMapper.selectById(dict.getId());//电价
Synthesize_no_2_5 synthesize_no_2_5 = synthesize_no_2_5Service.getById(id);//经济参数
EnergySources energySources = energySourcesMapper.selectById(dict.getId()); // 能源价格
//EnergySources energySources = energySourcesMapper.selectById(dict.getId()); // 能源价格
Synthesize_no_3_6 synthesize_no_3_6 = new Synthesize_no_3_6();//经济指标 保存
synthesize_no_3_6.setNo225(0.0D);
synthesize_no_3_6.setNo226(0.0D);
... ... @@ -1952,6 +1957,10 @@ public class ProjectServiceImpl implements ProjectService {
return (double) Math.round(d * 10000) / 10000;
}
@Autowired
private ApplicationContext applicationContext;
/**
* 建筑类型 保存
*
... ... @@ -1965,20 +1974,29 @@ public class ProjectServiceImpl implements ProjectService {
synthesize_no_2_1Service.remove(new QueryWrapper<Synthesize_no_2_1>().lambda().eq(Synthesize_no_2_1::getPid, synthesize_no_2_1s.get(0).getPid()));
//calculateLoadService.remove(new QueryWrapper<CalculateLoad>().lambda().eq(CalculateLoad::getCid, synthesize_no_2_1s.get(0).getPid()));
//CalculateLoad serviceOne = calculateLoadService.getOne(new LambdaQueryWrapper<CalculateLoad>().eq(CalculateLoad::getCid, synthesize_no_2_1s.get(0).getPid()));
for (Synthesize_no_2_1New synthesize_no_2_1 : synthesize_no_2_1s) {
/**
* 判断 新加的指标是否存在 不存在进行调用
*/
List<Synthesize_no_2_1> synthesize_no_2_1s2 = synthesize_no_2_1s.stream().map(synthesize_no_2_1New -> {
Synthesize_no_2_1 synthesizeNo21 = new Synthesize_no_2_1();
BeanUtils.copyProperties(synthesize_no_2_1, synthesizeNo21);
id = synthesizeNo21.getPid();
synthesize_no_2_1Service.saveOrUpdate(synthesizeNo21);
BeanUtils.copyProperties(synthesize_no_2_1New, synthesizeNo21);
return synthesizeNo21;
}).collect(Collectors.toList());
applicationContext.publishEvent(new No2_1SaveEvent(synthesize_no_2_1s2));
for (Synthesize_no_2_1 synthesize_no_2_1 : synthesize_no_2_1s2) {
/* Synthesize_no_2_1 synthesizeNo21 = new Synthesize_no_2_1();
BeanUtils.copyProperties(synthesize_no_2_1, synthesizeNo21);*/
id = synthesize_no_2_1.getPid();
synthesize_no_2_1Service.saveOrUpdate(synthesize_no_2_1);
/* List<CalculateLoad> list = calculateLoadService.list(new QueryWrapper<CalculateLoad>()
.lambda()
.eq(CalculateLoad::getAid, synthesizeNo21.getBuildingTypeId())
.eq(CalculateLoad::getCid, synthesizeNo21.getPid()));
if (!list.isEmpty()) {*/
CalculateLoad calculateLoad = new CalculateLoad();
Synthesize_no_1 synthesize_no_1 = no_1Service.getById(synthesizeNo21.getPid());
Synthesize_no_1 synthesize_no_1 = no_1Service.getById(synthesize_no_2_1.getPid());
CityDict dict = cityDictService.getOne(new QueryWrapper<CityDict>().lambda().eq(CityDict::getName, synthesize_no_1.getProjectSite()));//城市
Sort sort = sortMapper.selectById(synthesizeNo21.getBuildingTypeId());
Sort sort = sortMapper.selectById(synthesize_no_2_1.getBuildingTypeId());
if (!StringUtils.isEmpty(dict) && !StringUtils.isEmpty(sort)) {
String[] split = synthesize_no_1.getEnergyType().split(",");
double annualTotalElectricityDemand = 0.0;
... ... @@ -1996,7 +2014,7 @@ public class ProjectServiceImpl implements ProjectService {
* 年总需电量
* =10*365*建筑面积面积*设计电负荷*0.8/1000
*/
annualTotalElectricityDemand = synthesizeNo21.getPowerSupplyDays() * synthesizeNo21.getHoursOfPowerSupplyPerDay() * synthesizeNo21.getArchitectureArea() * synthesizeNo21.getDesignElectricLoadIndex() * 0.8 / 1000;
annualTotalElectricityDemand = synthesize_no_2_1.getPowerSupplyDays() * synthesize_no_2_1.getHoursOfPowerSupplyPerDay() * synthesize_no_2_1.getArchitectureArea() * synthesize_no_2_1.getDesignElectricLoadIndex() * 0.8 / 1000;
} else if ("2".equals(s)) {
/**
... ... @@ -2005,32 +2023,32 @@ public class ProjectServiceImpl implements ProjectService {
* 年总需热量= 12*供热天数*供热面积*设计热负荷*0.7/1000
*/
String zd_name = "no_" + sort.getId();
Assert.notNull(synthesizeNo21.getHeatEnd(), "末端形式选择出错了");
Assert.notNull(synthesize_no_2_1.getHeatEnd(), "末端形式选择出错了");
Double hotLoadAll = 0.0;
if ("1".equals(synthesizeNo21.getHeatEnd())) {
if ("1".equals(synthesize_no_2_1.getHeatEnd())) {
/**
* 散热器 数据库里面的值
*/
//hotLoadAll = (double) hotLoadDataMapper.queryName(zd_name, dict.getId());
hotLoadAll = synthesizeNo21.getDesignHeatLoadIndex();
} else if ("2".equals(synthesizeNo21.getHeatEnd())) {
hotLoadAll = synthesize_no_2_1.getDesignHeatLoadIndex();
} else if ("2".equals(synthesize_no_2_1.getHeatEnd())) {
/**
* 地暖
* * 0.9
*/
hotLoadAll = synthesizeNo21.getDesignHeatLoadIndex() * 0.9;
} else if ("3".equals(synthesizeNo21.getHeatEnd())) {
hotLoadAll = synthesize_no_2_1.getDesignHeatLoadIndex() * 0.9;
} else if ("3".equals(synthesize_no_2_1.getHeatEnd())) {
/**
* 等级盘管
* * 2
*/
hotLoadAll = synthesizeNo21.getDesignHeatLoadIndex() * 2;
hotLoadAll = synthesize_no_2_1.getDesignHeatLoadIndex() * 2;
}
Assert.notNull(synthesizeNo21.getHeatDay(), "供热天数为空了");
Assert.notNull(synthesize_no_2_1.getHeatDay(), "供热天数为空了");
Integer di = calculatedTemperatureInHeatingRoomMapper.queryName(zd_name, dict.getId());
HeatIngData heatIngData = heatIngDataMapper.selectById(dict.getId());
Double num = (di - heatIngData.getNo2()) / (di - heatIngData.getNo1());
annualTotalHeatRequirement = synthesizeNo21.getHeatingHoursPerDay() * synthesizeNo21.getHeatDay() * synthesizeNo21.getHeatArea() * hotLoadAll * num / 1000;
annualTotalHeatRequirement = synthesize_no_2_1.getHeatingHoursPerDay() * synthesize_no_2_1.getHeatDay() * synthesize_no_2_1.getHeatArea() * hotLoadAll * num / 1000;
} else if ("3".equals(s)) {
/**
... ... @@ -2040,9 +2058,9 @@ public class ProjectServiceImpl implements ProjectService {
*/
//String zd_name = "no_" + sort.getId();
//int coldLoadAll = coldLoadDataMapper.queryName(zd_name, dict.getId());
Double coldLoadAll = synthesizeNo21.getDesignCoolingLoadIndex();
Assert.notNull(synthesizeNo21.getColdDay(), "供冷天数为空了");
annualTotalCoolingDemand = synthesizeNo21.getCoolingHoursPerDay() * synthesizeNo21.getColdDay() * synthesizeNo21.getColdArea() * coldLoadAll * 0.75 / 1000;
Double coldLoadAll = synthesize_no_2_1.getDesignCoolingLoadIndex();
Assert.notNull(synthesize_no_2_1.getColdDay(), "供冷天数为空了");
annualTotalCoolingDemand = synthesize_no_2_1.getCoolingHoursPerDay() * synthesize_no_2_1.getColdDay() * synthesize_no_2_1.getColdArea() * coldLoadAll * 0.75 / 1000;
} else if ("4".equals(s)) {
/**
* 年总需热水总量
... ... @@ -2050,29 +2068,29 @@ public class ProjectServiceImpl implements ProjectService {
* 年总需热水总量= 热水定额*人数*供热水天数/1000
*/
//String zd_name = "no_" + sort.getId();
Double electricity = synthesizeNo21.getHotWaterQuota();
Double electricity = synthesize_no_2_1.getHotWaterQuota();
//Double electricity = hotWaterDataMapper.queryName(zd_name, dict.getId());
Assert.notNull(synthesizeNo21.getWaterDayNum(), "供热水天数为空了");
totalAnnualTotalHotWaterRequirement = electricity * synthesizeNo21.getWaterPersonNum() * synthesizeNo21.getWaterDayNum() / 1000;
Assert.notNull(synthesize_no_2_1.getWaterDayNum(), "供热水天数为空了");
totalAnnualTotalHotWaterRequirement = electricity * synthesize_no_2_1.getWaterPersonNum() * synthesize_no_2_1.getWaterDayNum() / 1000;
}
}
//CalculateLoad serviceOne = calculateLoadService.getById(synthesizeNo21.getId());
CalculateLoad serviceOne = calculateLoadService.getById(synthesizeNo21.getId());
CalculateLoad serviceOne = calculateLoadService.getById(synthesize_no_2_1.getId());
if (!StringUtils.isEmpty(serviceOne)) {
serviceOne.setNo1(Double.valueOf(df.format(annualTotalElectricityDemand)));
serviceOne.setNo2(Double.valueOf(df.format(annualTotalHeatRequirement)));
serviceOne.setNo3(Double.valueOf(df.format(annualTotalCoolingDemand)));
serviceOne.setNo4(Double.valueOf(df.format(totalAnnualTotalHotWaterRequirement)));
serviceOne.setCid(synthesizeNo21.getPid());
serviceOne.setAid(synthesizeNo21.getBuildingTypeId());
serviceOne.setCid(synthesize_no_2_1.getPid());
serviceOne.setAid(synthesize_no_2_1.getBuildingTypeId());
serviceOne.setNo11(serviceOne.getNo11());
serviceOne.setNo22(serviceOne.getNo22());
serviceOne.setNo33(serviceOne.getNo33());
serviceOne.setNo44(serviceOne.getNo44());
calculateLoadService.updateById(serviceOne);
} else {
calculateLoad.setId(synthesizeNo21.getId());
calculateLoad.setId(synthesize_no_2_1.getId());
calculateLoad.setNo1(Double.valueOf(df.format(annualTotalElectricityDemand)));
calculateLoad.setNo11(Double.valueOf(df.format(annualTotalElectricityDemand)));
calculateLoad.setNo2(Double.valueOf(df.format(annualTotalHeatRequirement)));
... ... @@ -2081,8 +2099,8 @@ public class ProjectServiceImpl implements ProjectService {
calculateLoad.setNo33(Double.valueOf(df.format(annualTotalCoolingDemand)));
calculateLoad.setNo4(Double.valueOf(df.format(totalAnnualTotalHotWaterRequirement)));
calculateLoad.setNo44(Double.valueOf(df.format(totalAnnualTotalHotWaterRequirement)));
calculateLoad.setCid(synthesizeNo21.getPid());
calculateLoad.setAid(synthesizeNo21.getBuildingTypeId());
calculateLoad.setCid(synthesize_no_2_1.getPid());
calculateLoad.setAid(synthesize_no_2_1.getBuildingTypeId());
calculateLoadService.saveOrUpdate(calculateLoad);
}
}
... ... @@ -4293,4 +4311,671 @@ public class ProjectServiceImpl implements ProjectService {
equipmentCapacityVo.setList(list);
return equipmentCapacityVo;
}
@Override
public void saveProject(Synthesize_no_1 synthesize_no_1, String synthesize_no_2_1, Double electricityAh, Double photovoltaicArea, Double windAh, Synthesize_no_1Img synthesize_no_1Img, Synthesize_no_2_2 synthesize_no_2_2, Synthesize_no_2_3 synthesize_no_2_3, Synthesize_no_2_5 synthesize_no_2_5, HotMsgDto hotMsgDto, ColdMsgDto coldMsgDto, HotWaterDto hotWaterDto) {
if (org.springframework.util.StringUtils.isEmpty(synthesize_no_1.getId())) {
if (org.apache.commons.lang3.StringUtils.isNotEmpty(synthesize_no_1.getProjectSite())) {
synthesize_no_1.setType("1");
synthesize_no_1.setTime(new Date());
synthesize_no_1.setDeleteState("3");
synthesize_no_1.setCountState("0");
synthesize_no_1.setUserId(UserContext.get().getId());
synthesize_no_1.setNewTime(new Date());
} /*else {
synthesize_no_1.setType("1");
synthesize_no_1.setTime(new Date());
synthesize_no_1.setDeleteState("3");
synthesize_no_1.setCountState("0");
synthesize_no_1.setUserId(JwtUtil.getUserId(request.getHeader("token")));
synthesize_no_1.setNewTime(new Date());
}*/
} else {
/**
* 修改 对条件设置的参数修正 热水定额 冷水初始温度 修改
*/
Synthesize_no_1 synthesizeNo1 = no_1Service.getById(synthesize_no_1.getId());
if (org.apache.commons.lang3.StringUtils.isNotEmpty(synthesize_no_1.getProjectSite())) {
String site = synthesize_no_1.getProjectSite();
Synthesize_no_2_6 byId = synthesize_no_2_6Service.getById(synthesize_no_1.getId());
if (org.springframework.util.StringUtils.isEmpty(byId)) {
byId = synthesize_no_2_6Service.getById("1");
}
CityDict cityDict = cityDictService.getOne(new QueryWrapper<CityDict>().lambda().eq(CityDict::getName, site));
List<Synthesize_no_2_1> synthesize_no_2_1s = synthesize_no_2_1Service.list(new QueryWrapper<Synthesize_no_2_1>().lambda().eq(Synthesize_no_2_1::getPid, synthesize_no_1.getId()));//建筑
double electricity = 0.0;
double tall = 0.0;
double flat = 0.0;
double floor = 0.0;
if (!synthesize_no_2_1s.isEmpty()) {
for (Synthesize_no_2_1 synthesize_no_2_11 : synthesize_no_2_1s) {
if (org.apache.commons.lang3.StringUtils.isNotEmpty(synthesize_no_2_11.getBuildingTypeId())) {
Sort sort = sortMapper.selectById(synthesize_no_2_11.getBuildingTypeId());
String zd_name = "no_" + sort.getId();
CalculateLoad calculateLoad = calculateLoadService.getById(synthesize_no_2_11.getId());
Electrovalence electrovalence = electrovalenceMapper.selectById(cityDict.getId());
if ("住宅".equals(sort.getName()) || "托幼".equals(sort.getName()) || "学校".equals(sort.getName())) {
tall += electrovalence.getNo1();
flat += electrovalence.getNo2();
floor += electrovalence.getNo3();
} else {
tall += electrovalence.getNo11();
flat += electrovalence.getNo22();
floor += electrovalence.getNo33();
}
if (!org.springframework.util.StringUtils.isEmpty(calculateLoad)) {
if (calculateLoad.getNo4().equals(calculateLoad.getNo44())) {
electricity += hotWaterDataMapper.queryName(zd_name, cityDict.getId());
} else {
/**
* 年总需热水总量(调整值)*1000/(人数*365*0.9)
*/
electricity += calculateLoad.getNo44() * 1000 / (synthesize_no_2_11.getWaterPersonNum() * 365 * 0.9);
}
}
/*electricity += hotWaterDataMapper.queryName(zd_name, cityDict.getId());*/
}
}
}
if (!synthesizeNo1.getProjectSite().equals(synthesize_no_1.getProjectSite())) {
byId.setId(synthesize_no_1.getId());
byId.setNo50(electricity);
byId.setNo51(Double.valueOf(coldWaterDataMapper.selectById(cityDict.getId()).getNo1()));
byId.setNo54(cpvAndCfmDataService.getById(cityDict.getId()).getNo7()); // 太阳能保证率
byId.setNo115(cpvAndCfmDataService.getById(cityDict.getId()).getNo6()); // 年平均太阳辐照量
byId.setNo122(cpvAndCfmDataService.getById(cityDict.getId()).getNo2()); // 太阳辐照度
byId.setNo123(cpvAndCfmDataService.getById(cityDict.getId()).getNo3());//年总光伏利用小时数
byId.setNo124(cpvAndCfmDataService.getById(cityDict.getId()).getNo5()); // 年总风机利用小时数
byId.setNo128(energySourcesMapper.selectById(cityDict.getId()).getNo2()); // 天然气价格
byId.setNo129(energySourcesMapper.selectById(cityDict.getId()).getNo1()); // 自来水价格
byId.setNo125(tall); // 高峰电价
byId.setNo126(flat); // 平时电价
byId.setNo127(floor); // 低谷电价
synthesize_no_2_6Service.saveOrUpdate(byId);
}
synthesize_no_1.setType(synthesizeNo1.getType());
synthesize_no_1.setDeleteState(synthesizeNo1.getDeleteState());
synthesize_no_1.setCountState(synthesizeNo1.getCountState());
synthesize_no_1.setUserId(synthesizeNo1.getUserId());
synthesize_no_1.setPtState(synthesizeNo1.getPtState());
synthesize_no_1.setAdminState(synthesizeNo1.getAdminState());
synthesize_no_1.setSuperAdminState(synthesizeNo1.getAdminState());
}
}
no_1Service.saveOrUpdate(synthesize_no_1);
if (org.apache.commons.lang3.StringUtils.isNotEmpty(synthesize_no_1.getId())) {
synthesize_no_1ImgService.saveOrUpdate(synthesize_no_1Img);
}
/**
* 建筑类型保存
*/
if (org.apache.commons.lang3.StringUtils.isNotEmpty(synthesize_no_2_1))
no2_1Save(synthesize_no_2_1, electricityAh);
if (!org.springframework.util.StringUtils.isEmpty(synthesize_no_2_2.getId())) {
synthesize_no_2_2Service.saveOrUpdate(synthesize_no_2_2);
}
if (!org.springframework.util.StringUtils.isEmpty(synthesize_no_2_3.getId())) {
String s1 = JSON.toJSONString(hotMsgDto);
String s2 = JSON.toJSONString(coldMsgDto);
String s3 = JSON.toJSONString(hotWaterDto);
synthesize_no_2_3.setHotMsg(s1);
synthesize_no_2_3.setColdMsg(s2);
synthesize_no_2_3.setHotWaterMsg(s3);
synthesize_no_2_3Service.saveOrUpdate(synthesize_no_2_3);
if (org.springframework.util.StringUtils.isEmpty(synthesize_no_2_4Service.getById(synthesize_no_2_3.getId()))) {
Synthesize_no_2_4 synthesize_no_2_4 = new Synthesize_no_2_4();
synthesize_no_2_4.setId(synthesize_no_2_3.getId());
synthesize_no_2_4.setWindAh(windAh);
synthesize_no_2_4.setPhotovoltaicArea(photovoltaicArea);
synthesize_no_2_4Service.saveOrUpdate(synthesize_no_2_4);
} else {
Synthesize_no_2_4 synthesize_no_2_4 = synthesize_no_2_4Service.getById(synthesize_no_2_3.getId());
synthesize_no_2_4.setWindAh(windAh);
synthesize_no_2_4.setPhotovoltaicArea(photovoltaicArea);
synthesize_no_2_4Service.saveOrUpdate(synthesize_no_2_4);
}
}
if (!org.springframework.util.StringUtils.isEmpty(synthesize_no_2_5.getId()))
synthesize_no_2_5Service.saveOrUpdate(synthesize_no_2_5);
}
@Override
public void no3_1GetTypeSave(String id, String synthesize_no_2_1, Synthesize_no_1Img synthesize_no_1Img, Synthesize_no_2_2 synthesize_no_2_2, Synthesize_no_2_3 synthesize_no_2_3, Double electricityAh, Double photovoltaicArea, Double windAh, Synthesize_no_2_5 synthesize_no_2_5, HotMsgDto hotMsgDto, ColdMsgDto coldMsgDto, HotWaterDto hotWaterDto) {
if (org.apache.commons.lang3.StringUtils.isNotEmpty(synthesize_no_1Img.getId())) {
synthesize_no_1ImgService.saveOrUpdate(synthesize_no_1Img);
}
/**
* 建筑类型保存
*/
no2_1Save(synthesize_no_2_1, electricityAh);
Synthesize_no_1 synthesize_no_1 = no_1Service.getById(id);
String projectType = synthesize_no_1.getProjectType();
if ("2".equals(projectType))
synthesize_no_2_2Service.saveOrUpdate(synthesize_no_2_2);
if (!org.springframework.util.StringUtils.isEmpty(synthesize_no_2_3.getId())) {
List<Synthesize_no_2_1> synthesize_no_2_1List = synthesize_no_2_1Service.list(new QueryWrapper<Synthesize_no_2_1>().lambda().eq(Synthesize_no_2_1::getPid, synthesize_no_1.getId()));
String[] split = synthesize_no_1.getEnergyType().split(",");
for (String s : split) {
if ("2".equals(s)) {
/**
* 供热比例计算
*/
double hotPercentage = hotMsgDto.getHotA() + hotMsgDto.getHotB() + hotMsgDto.getHotC() + hotMsgDto.getHotD() + hotMsgDto.getHotE();
if (hotPercentage != 100) {
throw new BusinessException(CommonErrorCode.E_99999);
}
/**
* 计算 蓄热时间
* @description 0<蓄热时间 < 年供热量 * 1 0 0 0 / ( 供热面积 * 设计热负荷 ) / 1 3 0
*/
Double annualHeatSupply = 0.0; // 年供热量
Double heatingArea = 0.0; // 供热面积
Double designHeatLoad = 0.0; // 设计热负荷
Assert.notEmpty(synthesize_no_2_1List, "建筑类型出错了!");
for (Synthesize_no_2_1 synthesize_no_2_ : synthesize_no_2_1List) {
CalculateLoad calculateLoad = calculateLoadService.getById(synthesize_no_2_.getId());
annualHeatSupply += calculateLoad.getNo22();
heatingArea += synthesize_no_2_.getHeatArea();
CityDict dict = cityDictService.getOne(new QueryWrapper<CityDict>().lambda().eq(CityDict::getName, synthesize_no_1.getProjectSite()));//城市
Sort sort = sortMapper.selectById(synthesize_no_2_.getBuildingTypeId());
Assert.notNull(synthesize_no_2_.getHeatEnd(), "末端形式选择出错了");
String zd_name = "no_" + sort.getId();
if ("1".equals(synthesize_no_2_.getHeatEnd())) {
/**
* 散热器 数据库里面的值
*/
designHeatLoad += (double) hotLoadDataMapper.queryName(zd_name, dict.getId());
} else if ("2".equals(synthesize_no_2_.getHeatEnd())) {
/**
* 地暖
* * 0.9
*/
designHeatLoad += hotLoadDataMapper.queryName(zd_name, dict.getId()) * 0.9;
} else if ("3".equals(synthesize_no_2_.getHeatEnd())) {
/**
* 等级盘管
* * 2
*/
designHeatLoad += (double) (hotLoadDataMapper.queryName(zd_name, dict.getId()) * 2);
}
}
double v = annualHeatSupply * 1000 / (heatingArea * designHeatLoad) / 130;
log.info("蓄热时间范围 V {}", v);
if (Double.isNaN(v)) {
v = 0;
}
Assert.notNull(hotMsgDto.getHotF(), "蓄热出错");
if (hotMsgDto.getHotF() < 0 || hotMsgDto.getHotF() > v) {
throw new IllegalArgumentException("蓄热时间填写错误,范围应该在0 - " + v);
}
/**
* 蓄热做一个限制,出水温度不能低于进水温度
*/
Synthesize_no_2_6 synthesize_no_2_6 = synthesize_no_2_6Service.getById(synthesize_no_2_3.getId());
if (org.springframework.util.StringUtils.isEmpty(synthesize_no_2_6)) {
Synthesize_no_2_6 synthesize_no_2_61 = synthesize_no_2_6Service.getById("1");
if (synthesize_no_2_61.getNo52() <= hotMsgDto.getHotG()) {
throw new IllegalArgumentException("供热温度填写有误,范围不得大于等于" + synthesize_no_2_61.getNo52());
}
} else {
if (synthesize_no_2_6.getNo52() <= hotMsgDto.getHotG()) {
throw new IllegalArgumentException("供热温度填写有误,范围不得大于等于" + synthesize_no_2_6.getNo52());
}
}
} else if ("3".equals(s)) {
/**
* 供冷比例计算
*/
double coldPercentage = coldMsgDto.getColdA() + coldMsgDto.getColdB() + coldMsgDto.getColdC() + coldMsgDto.getColdD();
if (coldPercentage != 100) {
throw new BusinessException(CommonErrorCode.E_99999);
}
/**
* 计算 蓄冷时间
* @description 0<蓄冷时间 < 年供冷量 * 1 0 0 0 / ( 供冷面积 * 设计冷负荷 ) / 1 5 0
*/
Double annualCoolingCapacity = 0.0; // 年供热量
Double coolingArea = 0.0; // 供热面积
Double designCoolingLoad = 0.0; // 设计热负荷
Assert.notEmpty(synthesize_no_2_1List, "建筑类型出错了!");
for (Synthesize_no_2_1 synthesize_no_2_ : synthesize_no_2_1List) {
CalculateLoad calculateLoad = calculateLoadService.getById(synthesize_no_2_.getId());
annualCoolingCapacity += calculateLoad.getNo22();
coolingArea += synthesize_no_2_.getHeatArea();
CityDict dict = cityDictService.getOne(new QueryWrapper<CityDict>().lambda().eq(CityDict::getName, synthesize_no_1.getProjectSite()));//城市
Sort sort = sortMapper.selectById(synthesize_no_2_.getBuildingTypeId());
Assert.notNull(synthesize_no_2_.getHeatEnd(), "末端形式选择出错了");
String zd_name = "no_" + sort.getId();
if ("1".equals(synthesize_no_2_.getHeatEnd())) {
/**
* 散热器 数据库里面的值
*/
designCoolingLoad += (double) hotLoadDataMapper.queryName(zd_name, dict.getId());
} else if ("2".equals(synthesize_no_2_.getHeatEnd())) {
/**
* 地暖
* * 0.9
*/
designCoolingLoad += hotLoadDataMapper.queryName(zd_name, dict.getId()) * 0.9;
} else if ("3".equals(synthesize_no_2_.getHeatEnd())) {
/**
* 等级盘管
* * 2
*/
designCoolingLoad += (double) (hotLoadDataMapper.queryName(zd_name, dict.getId()) * 2);
}
}
double v = annualCoolingCapacity * 1000 / (coolingArea * designCoolingLoad) / 150;
log.info("蓄冷时间范围 V {}", v);
if (Double.isNaN(v)) {
v = 0;
}
Assert.notNull(coldMsgDto.getColdE(), "蓄冷时间出错");
if (coldMsgDto.getColdE() < 0 || coldMsgDto.getColdE() > v) {
throw new IllegalArgumentException("蓄冷时间填写错误,范围应该在0 - " + v);
}
/**
* 蓄冷这做一个限制,供冷温度不能高于冷水温度
*/
Synthesize_no_2_6 synthesize_no_2_6 = synthesize_no_2_6Service.getById(synthesize_no_2_3.getId());
String site = synthesize_no_1.getProjectSite();
CityDict cityDict = cityDictService.getOne(new QueryWrapper<CityDict>().lambda().eq(CityDict::getName, site));
Integer no1 = coldWaterDataMapper.selectById(cityDict.getId()).getNo1();
if (org.springframework.util.StringUtils.isEmpty(synthesize_no_2_6)) {
if (no1 <= coldMsgDto.getColdF()) {
throw new IllegalArgumentException("供冷温度填写有误,范围不得大于等于" + no1);
}
} else {
if (org.springframework.util.StringUtils.isEmpty(coldMsgDto.getColdF())) {
coldMsgDto.setColdF(0.0);
}
if (synthesize_no_2_6.getNo51() <= coldMsgDto.getColdF()) {
throw new IllegalArgumentException("供冷温度填写有误,范围不得大于等于" + synthesize_no_2_6.getNo51());
}
}
} else if ("4".equals(s)) {
/**
* 热水比例计算
*/
double hotWaterRatio = hotWaterDto.getHotWaterA() + hotWaterDto.getHotWaterB() + hotWaterDto.getHotWaterC();
if (hotWaterRatio != 100) {
throw new BusinessException(CommonErrorCode.E_99999);
}
}
}
String s1 = JSON.toJSONString(hotMsgDto);
String s2 = JSON.toJSONString(coldMsgDto);
String s3 = JSON.toJSONString(hotWaterDto);
synthesize_no_2_3.setHotMsg(s1);
synthesize_no_2_3.setColdMsg(s2);
synthesize_no_2_3.setHotWaterMsg(s3);
synthesize_no_2_3Service.saveOrUpdate(synthesize_no_2_3);
if (org.springframework.util.StringUtils.isEmpty(synthesize_no_2_4Service.getById(synthesize_no_2_3.getId()))) {
Synthesize_no_2_4 synthesize_no_2_4 = new Synthesize_no_2_4();
synthesize_no_2_4.setId(synthesize_no_2_3.getId());
synthesize_no_2_4.setWindAh(windAh);
synthesize_no_2_4.setPhotovoltaicArea(photovoltaicArea);
synthesize_no_2_4Service.saveOrUpdate(synthesize_no_2_4);
} else {
Synthesize_no_2_4 synthesize_no_2_4 = synthesize_no_2_4Service.getById(synthesize_no_2_3.getId());
synthesize_no_2_4.setWindAh(windAh);
synthesize_no_2_4.setPhotovoltaicArea(photovoltaicArea);
synthesize_no_2_4Service.saveOrUpdate(synthesize_no_2_4);
}
}
if (!org.springframework.util.StringUtils.isEmpty(synthesize_no_2_5.getId()))
synthesize_no_2_5Service.saveOrUpdate(synthesize_no_2_5);
}
@Override
public Boolean no2_6ResetType(String id) {
Synthesize_no_2_6 byId = synthesize_no_2_6Service.getById("1");
/**
* 修改 对条件设置的参数修正 热水定额 冷水初始温度 修改
*/
Synthesize_no_1 synthesize_no_1 = no_1Service.getById(id);
if (org.apache.commons.lang3.StringUtils.isNotEmpty(synthesize_no_1.getProjectSite())) {
String site = synthesize_no_1.getProjectSite();
CityDict cityDict = cityDictService.getOne(new QueryWrapper<CityDict>().lambda().eq(CityDict::getName, site));
List<Synthesize_no_2_1> synthesize_no_2_1s = synthesize_no_2_1Service.list(new QueryWrapper<Synthesize_no_2_1>().lambda().eq(Synthesize_no_2_1::getPid, synthesize_no_1.getId()));//建筑
double electricity = 0.0;
double tall = 0.0;
double flat = 0.0;
double floor = 0.0;
if (!synthesize_no_2_1s.isEmpty()) {
for (Synthesize_no_2_1 synthesize_no_2_11 : synthesize_no_2_1s) {
if (org.apache.commons.lang3.StringUtils.isNotEmpty(synthesize_no_2_11.getBuildingTypeId())) {
Sort sort = sortMapper.selectById(synthesize_no_2_11.getBuildingTypeId());
String zd_name = "no_" + sort.getId();
CalculateLoad calculateLoad = calculateLoadService.getOne(new QueryWrapper<CalculateLoad>().lambda().eq(CalculateLoad::getCid, synthesize_no_1.getId()).eq(CalculateLoad::getAid, sort.getId()));
Electrovalence electrovalence = electrovalenceMapper.selectById(cityDict.getId());
if ("住宅".equals(sort.getName()) || "托幼".equals(sort.getName()) || "学校".equals(sort.getName())) {
tall += electrovalence.getNo1();
flat += electrovalence.getNo2();
floor += electrovalence.getNo3();
} else {
tall += electrovalence.getNo11();
flat += electrovalence.getNo22();
floor += electrovalence.getNo33();
}
if (!org.springframework.util.StringUtils.isEmpty(calculateLoad)) {
if (calculateLoad.getNo4().equals(calculateLoad.getNo44())) {
electricity += hotWaterDataMapper.queryName(zd_name, cityDict.getId());
} else {
/**
* 年总需热水总量(调整值)*1000/(人数*365*0.9)
*/
electricity += calculateLoad.getNo44() * 1000 / (synthesize_no_2_11.getWaterPersonNum() * 365 * 0.9);
}
}
/*electricity += hotWaterDataMapper.queryName(zd_name, cityDict.getId());*/
}
}
}
byId.setNo50(electricity);
byId.setNo51(Double.valueOf(coldWaterDataMapper.selectById(cityDict.getId()).getNo1()));// 冷水初始温度
byId.setNo54(cpvAndCfmDataService.getById(cityDict.getId()).getNo7()); // 太阳能保证率
byId.setNo115(cpvAndCfmDataService.getById(cityDict.getId()).getNo6()); // 年平均太阳辐照量
byId.setNo122(cpvAndCfmDataService.getById(cityDict.getId()).getNo2()); // 太阳辐照度
byId.setNo123(cpvAndCfmDataService.getById(cityDict.getId()).getNo3());//年总光伏利用小时数
byId.setNo124(cpvAndCfmDataService.getById(cityDict.getId()).getNo5()); // 年总风机利用小时数
byId.setNo125(tall); // 高峰电价
byId.setNo126(flat); // 平时电价
byId.setNo127(floor); // 低谷电价
byId.setNo128(energySourcesMapper.selectById(cityDict.getId()).getNo2()); // 天然气价格
byId.setNo129(energySourcesMapper.selectById(cityDict.getId()).getNo1()); // 自来水价格
byId.setId(id);
}
return synthesize_no_2_6Service.updateById(byId);
}
@Override
public Boolean no2_3Save(Synthesize_no_2_3 synthesize_no_2_3, Double photovoltaicArea, Double windAh, HotMsgDto hotMsgDto, ColdMsgDto coldMsgDto, HotWaterDto hotWaterDto) {
/**
* 光伏可利用面积 风电装机容量
*/
Synthesize_no_2_4 synthesize_no_2_4 = new Synthesize_no_2_4();
synthesize_no_2_4.setId(synthesize_no_2_3.getId());
synthesize_no_2_4.setPhotovoltaicArea(photovoltaicArea);
synthesize_no_2_4.setWindAh(windAh);
synthesize_no_2_4Service.saveOrUpdate(synthesize_no_2_4);
Synthesize_no_1 synthesize_no_1 = no_1Service.getById(synthesize_no_2_3.getId());
List<Synthesize_no_2_1> synthesize_no_2_1List = synthesize_no_2_1Service.list(new QueryWrapper<Synthesize_no_2_1>().lambda().eq(Synthesize_no_2_1::getPid, synthesize_no_1.getId()));
String[] split = synthesize_no_1.getEnergyType().split(",");
for (String s : split) {
if ("2".equals(s)) {
/**
* 供热比例计算
*/
double hotPercentage = hotMsgDto.getHotA() + hotMsgDto.getHotB() + hotMsgDto.getHotC() + hotMsgDto.getHotD() + hotMsgDto.getHotE();
if (hotPercentage != 100) {
throw new BusinessException(CommonErrorCode.E_99999);
}
/**
* 计算 蓄热时间
* @description 0<蓄热时间 < 年供热量 * 1 0 0 0 / ( 供热面积 * 设计热负荷 ) / 1 3 0
*/
Double annualHeatSupply = 0.0; // 年供热量
Double heatingArea = 0.0; // 供热面积
Double designHeatLoad = 0.0; // 设计热负荷
Assert.notEmpty(synthesize_no_2_1List, "建筑类型出错了!");
for (Synthesize_no_2_1 synthesize_no_2_ : synthesize_no_2_1List) {
CalculateLoad calculateLoad = calculateLoadService.getById(synthesize_no_2_.getId());
annualHeatSupply += calculateLoad.getNo22();
heatingArea += synthesize_no_2_.getHeatArea();
CityDict dict = cityDictService.getOne(new QueryWrapper<CityDict>().lambda().eq(CityDict::getName, synthesize_no_1.getProjectSite()));//城市
Sort sort = sortMapper.selectById(synthesize_no_2_.getBuildingTypeId());
Assert.notNull(synthesize_no_2_.getHeatEnd(), "末端形式选择出错了");
String zd_name = "no_" + sort.getId();
if ("1".equals(synthesize_no_2_.getHeatEnd())) {
/**
* 散热器 数据库里面的值
*/
designHeatLoad += (double) hotLoadDataMapper.queryName(zd_name, dict.getId());
} else if ("2".equals(synthesize_no_2_.getHeatEnd())) {
/**
* 地暖
* * 0.9
*/
designHeatLoad += hotLoadDataMapper.queryName(zd_name, dict.getId()) * 0.9;
} else if ("3".equals(synthesize_no_2_.getHeatEnd())) {
/**
* 等级盘管
* * 2
*/
designHeatLoad += (double) (hotLoadDataMapper.queryName(zd_name, dict.getId()) * 2);
}
}
double v = annualHeatSupply * 1000 / (heatingArea * designHeatLoad) / 130;
log.info("蓄热时间 范围 v {}", v);
if (Double.isNaN(v)) {
v = 0;
}
Assert.notNull(hotMsgDto.getHotF(), "蓄热出错");
if (hotMsgDto.getHotF() < 0 || hotMsgDto.getHotF() > v) {
throw new IllegalArgumentException("蓄热时间填写错误,范围应该在0 - " + v);
}
/**
* 蓄热做一个限制,出水温度不能低于进水温度
*/
Synthesize_no_2_6 synthesize_no_2_6 = synthesize_no_2_6Service.getById(synthesize_no_2_3.getId());
if (org.springframework.util.StringUtils.isEmpty(synthesize_no_2_6)) {
Synthesize_no_2_6 synthesize_no_2_61 = synthesize_no_2_6Service.getById("1");
if (synthesize_no_2_61.getNo52() <= hotMsgDto.getHotG()) {
throw new IllegalArgumentException("供热温度填写有误,范围不得大于等于" + synthesize_no_2_61.getNo52());
}
} else {
if (synthesize_no_2_6.getNo52() <= hotMsgDto.getHotG()) {
throw new IllegalArgumentException("供热温度填写有误,范围不得大于等于" + synthesize_no_2_6.getNo52());
}
}
} else if ("3".equals(s)) {
/**
* 供冷比例计算
*/
double coldPercentage = coldMsgDto.getColdA() + coldMsgDto.getColdB() + coldMsgDto.getColdC() + coldMsgDto.getColdD();
if (coldPercentage != 100) {
throw new BusinessException(CommonErrorCode.E_99999);
}
/**
* 计算 蓄冷时间
* @description 0<蓄冷时间 < 年供冷量 * 1 0 0 0 / ( 供冷面积 * 设计冷负荷 ) / 1 5 0
*/
Double annualCoolingCapacity = 0.0; // 年供热量
Double coolingArea = 0.0; // 供热面积
Double designCoolingLoad = 0.0; // 设计热负荷
Assert.notEmpty(synthesize_no_2_1List, "建筑类型出错了!");
for (Synthesize_no_2_1 synthesize_no_2_ : synthesize_no_2_1List) {
CalculateLoad calculateLoad = calculateLoadService.getById(synthesize_no_2_.getId());
annualCoolingCapacity += calculateLoad.getNo22();
coolingArea += synthesize_no_2_.getHeatArea();
CityDict dict = cityDictService.getOne(new QueryWrapper<CityDict>().lambda().eq(CityDict::getName, synthesize_no_1.getProjectSite()));//城市
Sort sort = sortMapper.selectById(synthesize_no_2_.getBuildingTypeId());
Assert.notNull(synthesize_no_2_.getHeatEnd(), "末端形式选择出错了");
String zd_name = "no_" + sort.getId();
if ("1".equals(synthesize_no_2_.getHeatEnd())) {
/**
* 散热器 数据库里面的值
*/
designCoolingLoad += (double) hotLoadDataMapper.queryName(zd_name, dict.getId());
} else if ("2".equals(synthesize_no_2_.getHeatEnd())) {
/**
* 地暖
* * 0.9
*/
designCoolingLoad += hotLoadDataMapper.queryName(zd_name, dict.getId()) * 0.9;
} else if ("3".equals(synthesize_no_2_.getHeatEnd())) {
/**
* 等级盘管
* * 2
*/
designCoolingLoad += (double) (hotLoadDataMapper.queryName(zd_name, dict.getId()) * 2);
}
}
double v = annualCoolingCapacity * 1000 / (coolingArea * designCoolingLoad) / 150;
log.info("蓄冷时间 范围 v {}", v);
if (Double.isNaN(v)) {
v = 0;
}
Assert.notNull(coldMsgDto.getColdE(), "蓄冷时间出错");
if (coldMsgDto.getColdE() < 0 || coldMsgDto.getColdE() > v) {
throw new IllegalArgumentException("蓄冷时间填写错误,范围应该在0 - " + v);
}
/**
* 蓄冷这做一个限制,供冷温度不能高于冷水温度
*/
Synthesize_no_2_6 synthesize_no_2_6 = synthesize_no_2_6Service.getById(synthesize_no_2_3.getId());
String site = synthesize_no_1.getProjectSite();
CityDict cityDict = cityDictService.getOne(new QueryWrapper<CityDict>().lambda().eq(CityDict::getName, site));
Integer no1 = coldWaterDataMapper.selectById(cityDict.getId()).getNo1();
if (org.springframework.util.StringUtils.isEmpty(synthesize_no_2_6)) {
if (no1 <= coldMsgDto.getColdF()) {
throw new IllegalArgumentException("供冷温度填写有误,范围不得大于等于" + no1);
}
} else {
if (org.springframework.util.StringUtils.isEmpty(coldMsgDto.getColdF())) {
coldMsgDto.setColdF(0.0);
}
if (synthesize_no_2_6.getNo51() <= coldMsgDto.getColdF()) {
throw new IllegalArgumentException("供冷温度填写有误,范围不得大于等于" + synthesize_no_2_6.getNo51());
}
}
} else if ("4".equals(s)) {
/**
* 热水比例计算
*/
double hotWaterRatio = hotWaterDto.getHotWaterA() + hotWaterDto.getHotWaterB() + hotWaterDto.getHotWaterC();
if (hotWaterRatio != 100) {
throw new BusinessException(CommonErrorCode.E_99999);
}
}
}
String s1 = JSON.toJSONString(hotMsgDto);
String s2 = JSON.toJSONString(coldMsgDto);
String s3 = JSON.toJSONString(hotWaterDto);
synthesize_no_2_3.setHotMsg(s1);
synthesize_no_2_3.setColdMsg(s2);
synthesize_no_2_3.setHotWaterMsg(s3);
return synthesize_no_2_3Service.saveOrUpdate(synthesize_no_2_3);
}
@Override
public List<ClientNameDto> no1getName(String name) {
String userId = UserContext.get().getId();
List<Synthesize_no_1ClientName> list = synthesize_no_1ClientNameService.list(new LambdaQueryWrapper<Synthesize_no_1ClientName>().eq(Synthesize_no_1ClientName::getUserId, userId).ne(Synthesize_no_1ClientName::getDeleteState, "1")
.orderByDesc(Synthesize_no_1ClientName::getNewTime).like(org.apache.commons.lang3.StringUtils.isNotBlank(name), Synthesize_no_1ClientName::getName, name));
List<ClientNameDto> names = new ArrayList<>();
for (Synthesize_no_1ClientName synthesize_no_1ClientName : list) {
ClientNameDto clientNameDto = new ClientNameDto();
clientNameDto.setId(synthesize_no_1ClientName.getId());
clientNameDto.setName(synthesize_no_1ClientName.getName());
names.add(clientNameDto);
}
return names;
}
@Override
public String no1Save(Synthesize_no_1 synthesize_no_1) {
if (org.springframework.util.StringUtils.isEmpty(synthesize_no_1.getId())) {
synthesize_no_1.setType("1");
synthesize_no_1.setTime(new Date());
synthesize_no_1.setDeleteState("3");
synthesize_no_1.setCountState("0");
synthesize_no_1.setUserId(UserContext.get().getId());
synthesize_no_1.setNewTime(new Date());
synthesize_no_1.setFlagCalculate("2");
} else {
/**
* 修改 对条件设置的参数修正 热水定额 冷水初始温度 修改
*/
Synthesize_no_1 synthesizeNo1 = no_1Service.getById(synthesize_no_1.getId());
/**
* 判断 两次选择的地区是否一样 不一样就行修改取最新
*/
if (!synthesize_no_1.getProjectSite().equals(synthesizeNo1.getProjectSite())) {
CityDict dict = cityDictService.getOne(new QueryWrapper<CityDict>().lambda().eq(CityDict::getName, synthesize_no_1.getProjectSite()));//城市
HeatIngData heatIngData = heatIngDataMapper.selectById(dict.getId());
/**
* 在次判断 synthesize_no_2_1 是否存在
*/
List<Synthesize_no_2_1> synthesize_no_2_1s = synthesize_no_2_1Service.list(new LambdaQueryWrapper<Synthesize_no_2_1>().eq(Synthesize_no_2_1::getPid, synthesize_no_1.getId()));
if (!synthesize_no_2_1s.isEmpty()) {
for (Synthesize_no_2_1 synthesize_no_2_1 : synthesize_no_2_1s) {
/**
* 修改供热天数
*/
synthesize_no_2_1.setHeatDay(Double.valueOf(heatIngData.getNo3()));
synthesize_no_2_1Service.updateById(synthesize_no_2_1);
}
}
}
if (org.apache.commons.lang3.StringUtils.isNotEmpty(synthesize_no_1.getProjectSite())) {
String site = synthesize_no_1.getProjectSite();
Synthesize_no_2_6 byId = synthesize_no_2_6Service.getById(synthesize_no_1.getId());
if (org.springframework.util.StringUtils.isEmpty(byId)) {
byId = synthesize_no_2_6Service.getById("1");
}
CityDict cityDict = cityDictService.getOne(new QueryWrapper<CityDict>().lambda().eq(CityDict::getName, site));
List<Synthesize_no_2_1> synthesize_no_2_1s = synthesize_no_2_1Service.list(new QueryWrapper<Synthesize_no_2_1>().lambda().eq(Synthesize_no_2_1::getPid, synthesize_no_1.getId()));//建筑
double electricity = 0.0;
double tall = 0.0;
double flat = 0.0;
double floor = 0.0;
if (!synthesize_no_2_1s.isEmpty()) {
for (int i = 0; i < synthesize_no_2_1s.size(); i++) {
Sort sort = sortMapper.selectById(synthesize_no_2_1s.get(i).getBuildingTypeId());
if (!org.springframework.util.StringUtils.isEmpty(sort)) {
String zd_name = "no_" + sort.getId();
CalculateLoad calculateLoad = calculateLoadService.getById(synthesize_no_2_1s.get(i).getId());
Electrovalence electrovalence = electrovalenceMapper.selectById(cityDict.getId());
if ("住宅".equals(sort.getName()) || "托幼".equals(sort.getName()) || "学校".equals(sort.getName())) {
tall += electrovalence.getNo1();
flat += electrovalence.getNo2();
floor += electrovalence.getNo3();
} else {
tall += electrovalence.getNo11();
flat += electrovalence.getNo22();
floor += electrovalence.getNo33();
}
if (!org.springframework.util.StringUtils.isEmpty(calculateLoad)) {
if (calculateLoad.getNo4().equals(calculateLoad.getNo44())) {
electricity += hotWaterDataMapper.queryName(zd_name, cityDict.getId());
} else {
/**
* 年总需热水总量(调整值)*1000/(人数*365*0.9)
*
*/
electricity += calculateLoad.getNo44() * 1000 / (synthesize_no_2_1s.get(i).getWaterPersonNum() * 365 * 0.9);
}
}
}
}
}
byId.setId(synthesize_no_1.getId());
byId.setNo50(electricity);// 热水定额
byId.setNo51(Double.valueOf(coldWaterDataMapper.selectById(cityDict.getId()).getNo1()));// 冷水初始温度
byId.setNo54(cpvAndCfmDataService.getById(cityDict.getId()).getNo7()); // 太阳能保证率
byId.setNo115(cpvAndCfmDataService.getById(cityDict.getId()).getNo6()); // 年平均太阳辐照量
byId.setNo122(cpvAndCfmDataService.getById(cityDict.getId()).getNo2()); // 太阳辐照度
byId.setNo123(cpvAndCfmDataService.getById(cityDict.getId()).getNo3());//年总光伏利用小时数
byId.setNo124(cpvAndCfmDataService.getById(cityDict.getId()).getNo5()); // 年总风机利用小时数
byId.setNo125(tall); // 高峰电价
byId.setNo126(flat); // 平时电价
byId.setNo127(floor); // 低谷电价
byId.setNo128(energySourcesMapper.selectById(cityDict.getId()).getNo2()); // 天然气价格
byId.setNo129(energySourcesMapper.selectById(cityDict.getId()).getNo1()); // 自来水价格
synthesize_no_1.setType(synthesizeNo1.getType());
synthesize_no_1.setDeleteState(synthesizeNo1.getDeleteState());
synthesize_no_1.setCountState(synthesizeNo1.getCountState());
synthesize_no_1.setUserId(synthesizeNo1.getUserId());
synthesize_no_1.setPtState(synthesizeNo1.getPtState());
synthesize_no_1.setAdminState(synthesizeNo1.getAdminState());
synthesize_no_1.setSuperAdminState(synthesizeNo1.getAdminState());
synthesize_no_2_6Service.saveOrUpdate(byId);
}
}
return no_1Service.saveOrUpdate(synthesize_no_1) ? synthesize_no_1.getId() : "保存失败";
}
}
... ...
package com.synthesize_energy.item.web.service.impl;
import com.synthesize_energy.item.entity.SmsCode;
import com.synthesize_energy.item.mapper.SmsCodeMapper;
import com.synthesize_energy.item.utils.SendCodeUtils;
import com.synthesize_energy.item.web.service.SmsCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
/**
* @author kgy
* @version 1.0
* @date 2020/10/26 17:38
*/
@Service
public class SmsCodeServiceImpl implements SmsCodeService {
@Autowired
private SmsCodeMapper smsCodeMapper;
/**
* 发送短信验证码
* @param phone
*/
@Override
public void sendCode(String phone) {
String code = new SendCodeUtils(phone).sendSms();
if (StringUtils.isEmpty(smsCodeMapper.selectById(phone))) {
SmsCode smsCode = new SmsCode();
smsCode.setTel(phone);
smsCode.setCode(code);
smsCode.setId(phone);
smsCodeMapper.insert(smsCode);
} else {
SmsCode smsCode = new SmsCode();
smsCode.setTel(phone);
smsCode.setCode(code);
smsCode.setId(phone);
smsCodeMapper.updateById(smsCode);
}
}
}
... ...
... ... @@ -504,7 +504,7 @@ public class Synthesize_no_2_6ServiceImpl extends ServiceImpl<Synthesize_no_2_6M
computeArgDto4.setId(115);
computeArgDto4.setNamType("年平均太阳辐照量");
computeArgDto4.setModelType(synthesize_no_2_6.getNo115());
computeArgDto4.setName("kJ/m2.d");
computeArgDto4.setName("kJ/m².d");
computeArgDtos.add(computeArgDto4);
ComputeArgDto computeArgDto5 = new ComputeArgDto();
... ... @@ -553,19 +553,19 @@ public class Synthesize_no_2_6ServiceImpl extends ServiceImpl<Synthesize_no_2_6M
computeArg2Dto.setList(computeArgDtos);
ComputeArgDto computeArgDto1 = new ComputeArgDto();
computeArgDto1.setId(53);
computeArgDto1.setNamType("空气源热泵(热水型)系统综合能效比");
computeArgDto1.setNamType("系统综合能效比");
computeArgDto1.setModelType(synthesize_no_2_6.getNo53());
computeArgDto1.setName("元/吨");
computeArgDtos.add(computeArgDto1);
ComputeArgDto computeArgDto2 = new ComputeArgDto();
computeArgDto2.setId(60);
computeArgDto2.setNamType("空气源热泵(热水型)单位投资成本");
computeArgDto2.setNamType("单位投资成本");
computeArgDto2.setModelType(synthesize_no_2_6.getNo60());
computeArgDto2.setName("元/kW");
computeArgDtos.add(computeArgDto2);
ComputeArgDto computeArgDto3 = new ComputeArgDto();
computeArgDto3.setId(59);
computeArgDto3.setNamType("空气源热泵(热水型)单位运维成本");
computeArgDto3.setNamType("单位运维成本");
computeArgDto3.setModelType(synthesize_no_2_6.getNo59());
computeArgDto3.setName("元/吨");
computeArgDtos.add(computeArgDto3);
... ... @@ -696,7 +696,7 @@ public class Synthesize_no_2_6ServiceImpl extends ServiceImpl<Synthesize_no_2_6M
computeArg2Dto.setList(computeArgDtos);
computeArg2DtoList.add(computeArg2Dto);
ComputeArg computeArg = new ComputeArg();
computeArg.setName("经济内置参数");
computeArg.setName("内置经济参数");
computeArg.setMap(computeArg2DtoList);
computeArgs.add(computeArg);
/**
... ... @@ -715,7 +715,7 @@ public class Synthesize_no_2_6ServiceImpl extends ServiceImpl<Synthesize_no_2_6M
naturalResources1.setId(122);
naturalResources1.setNamType("太阳辐照度");
naturalResources1.setModelType(synthesize_no_2_6.getNo122());
naturalResources1.setName("MJ/m2");
naturalResources1.setName("MJ/m²");
naturalResources.add(naturalResources1);
ComputeArgDto naturalResource2 = new ComputeArgDto();
naturalResource2.setId(123);
... ... @@ -771,7 +771,7 @@ public class Synthesize_no_2_6ServiceImpl extends ServiceImpl<Synthesize_no_2_6M
energyPurchasePrice4.setId(128);
energyPurchasePrice4.setNamType("天然气价格");
energyPurchasePrice4.setModelType(synthesize_no_2_6.getNo128());
energyPurchasePrice4.setName("元/m3");
energyPurchasePrice4.setName("元/m³");
energyPurchasePrice.add(energyPurchasePrice4);
ComputeArgDto energyPurchasePrice5 = new ComputeArgDto();
energyPurchasePrice5.setId(129);
... ...
package com.synthesize_energy.item.web.service.impl;
import com.synthesize_energy.common.domain.RestResponse;
import com.synthesize_energy.item.entity.Synthesize_no_1;
import com.synthesize_energy.item.utils.FileNameUtil;
import com.synthesize_energy.item.utils.FileUploadUtil;
import com.synthesize_energy.item.web.service.No_1Service;
import com.synthesize_energy.item.web.service.UploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
/**
* @author kgy
* @version 1.0
* @date 2020/10/26 17:32
*/
@Service
public class UploadServiceImpl implements UploadService {
@Value("${web.upload-path}")
private String path;
@Autowired
private No_1Service no_1Service;
/**
* 上传图片
*
* @param file
* @return
*/
@Override
public RestResponse<?> uploadImgPath(MultipartFile file) {
//获得文件名字
String fileName = file.getOriginalFilename();
fileName = FileNameUtil.getFileName(fileName);
File dest = new File(path + fileName);
if (FileUploadUtil.upload(file, path, fileName)) {
// 将上传的文件写入到服务器端文件夹
// 得到去掉了uri的路径
String url = "http://zhny.j.brotop.cn/images/" + fileName;
/**
* 返回 图片路径
*/
return RestResponse.success(url);
}
return RestResponse.validfail("上传图片出现问题");
}
@Override
public void typicalCaseUploadImage(String id, String image) {
Synthesize_no_1 synthesize_no_1 = no_1Service.getById(id);
synthesize_no_1.setImageUrl(image);
no_1Service.updateById(synthesize_no_1);
}
}
... ...
... ... @@ -41,7 +41,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
* @return
*/
@Override
public Map<String,Object> login(String phone, String code, HttpServletResponse response) {
public Map<String,Object> login(String phone, String code) {
Map<String,Object> map = new HashMap<>(2);
QueryWrapper<User> userQueryWrapper = new QueryWrapper<>();
userQueryWrapper.lambda().eq(User::getPhone, phone);
... ... @@ -54,7 +54,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
throw new BusinessException(CommonErrorCode.E_100102);
}
String sign = JwtUtil.sign(user);
response.setHeader("token",sign);
map.put("token",sign);
map.put("state",user.getStatus());
return map;
... ...
... ... @@ -49,9 +49,6 @@ spring:
url: jdbc:mysql://localhost:3307/synthesize_energy?useUnicode=true&&characterEncoding=utf8&useSSL=false&serverTimezone=UTC
username: db136s1ehvo1yn73
password: cxz307311SJK
type: org.apache.commons.dbcp2.BasicDataSource
dbcp2:
connection-init-sqls: SET NAMES utf8mb4
redis:
host: 182.92.205.118
port: 6379
... ...
... ... @@ -49,9 +49,6 @@ spring:
url: jdbc:mysql://1f692e5a3458475ea270448f4d3bfde5in01.internal.cn-east-2.mysql.rds.myhuaweicloud.com:3306/synthesize_energy?useUnicode=true&&characterEncoding=utf8&useSSL=false&serverTimezone=UTC
username: db136s1ehvo1yn73
password: cxz307311SJK
type: org.apache.commons.dbcp2.BasicDataSource
dbcp2:
connection-init-sqls: SET NAMES utf8mb4
redis:
host: 182.92.205.118
port: 6379
... ...
spring:
profiles:
#开发时使用下面注释
# active: dev
active: dev
# 打包时使用下面注释
active: prod
# active: prod
... ...