作者 kgy

修改查询在修改造成死锁

1 package com.synthesize_energy.item.entity; 1 package com.synthesize_energy.item.entity;
2 2
3 import com.baomidou.mybatisplus.annotation.*; 3 import com.baomidou.mybatisplus.annotation.*;
  4 +import com.baomidou.mybatisplus.extension.activerecord.Model;
4 import com.fasterxml.jackson.annotation.JsonFormat; 5 import com.fasterxml.jackson.annotation.JsonFormat;
5 import io.swagger.annotations.ApiModelProperty; 6 import io.swagger.annotations.ApiModelProperty;
6 import lombok.Data; 7 import lombok.Data;
@@ -16,7 +17,7 @@ import java.util.Date; @@ -16,7 +17,7 @@ import java.util.Date;
16 */ 17 */
17 @Data 18 @Data
18 @TableName("synthesize_no_1") 19 @TableName("synthesize_no_1")
19 -public class Synthesize_no_1 implements Serializable { 20 +public class Synthesize_no_1 extends Model<Synthesize_no_1> implements Serializable {
20 private static final long serialVersionUID = 4315624380474106909L; 21 private static final long serialVersionUID = 4315624380474106909L;
21 @TableId(type = IdType.ID_WORKER_STR) 22 @TableId(type = IdType.ID_WORKER_STR)
22 private String id; 23 private String id;
@@ -29,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired; @@ -29,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
29 import org.springframework.beans.factory.annotation.Value; 29 import org.springframework.beans.factory.annotation.Value;
30 import org.springframework.context.ApplicationContext; 30 import org.springframework.context.ApplicationContext;
31 import org.springframework.stereotype.Service; 31 import org.springframework.stereotype.Service;
  32 +import org.springframework.transaction.annotation.Propagation;
32 import org.springframework.transaction.annotation.Transactional; 33 import org.springframework.transaction.annotation.Transactional;
33 import org.springframework.util.Assert; 34 import org.springframework.util.Assert;
34 import org.springframework.util.StringUtils; 35 import org.springframework.util.StringUtils;
@@ -46,7 +47,7 @@ import java.util.stream.Collectors; @@ -46,7 +47,7 @@ import java.util.stream.Collectors;
46 */ 47 */
47 @Service 48 @Service
48 @Slf4j 49 @Slf4j
49 -@Transactional(rollbackFor = Exception.class) 50 +//@Transactional(rollbackFor = Exception.class)
50 public class ProjectServiceImpl implements ProjectService { 51 public class ProjectServiceImpl implements ProjectService {
51 52
52 @Autowired 53 @Autowired
@@ -274,6 +275,7 @@ public class ProjectServiceImpl implements ProjectService { @@ -274,6 +275,7 @@ public class ProjectServiceImpl implements ProjectService {
274 } 275 }
275 276
276 @Override 277 @Override
  278 + @Transactional(propagation = Propagation.SUPPORTS)
277 public No_3_1Tall_Dto no3_1_1GetType(String id) { 279 public No_3_1Tall_Dto no3_1_1GetType(String id) {
278 Synthesize_no_1 byId = no_1Service.getById(id); 280 Synthesize_no_1 byId = no_1Service.getById(id);
279 byId.setCountState("1"); 281 byId.setCountState("1");
@@ -1485,7 +1487,7 @@ public class ProjectServiceImpl implements ProjectService { @@ -1485,7 +1487,7 @@ public class ProjectServiceImpl implements ProjectService {
1485 double totalAnnualTotalHotWaterRequirement = 0.0; 1487 double totalAnnualTotalHotWaterRequirement = 0.0;
1486 for (Synthesize_no_2_1 synthesize_no_2_1 : synthesize_no_2_1s) { 1488 for (Synthesize_no_2_1 synthesize_no_2_1 : synthesize_no_2_1s) {
1487 CalculateLoad calculateLoad = calculateLoadService.getById(synthesize_no_2_1.getId()); 1489 CalculateLoad calculateLoad = calculateLoadService.getById(synthesize_no_2_1.getId());
1488 - if (Objects.nonNull(calculateLoad.getNo44())){ 1490 + if (Objects.nonNull(calculateLoad.getNo44())) {
1489 totalAnnualTotalHotWaterRequirement += calculateLoad.getNo44(); 1491 totalAnnualTotalHotWaterRequirement += calculateLoad.getNo44();
1490 } 1492 }
1491 } 1493 }