Browse Source

新增我的购碳信息界面

赵冬冬 4 năm trước cách đây
mục cha
commit
6de3211b08

+ 1 - 1
carbon-admin/carbon-admin-service/src/main/resources/com/hcloud/microserver/sys/service/dao/SysRolePermissionMapper.xml

@@ -86,7 +86,7 @@
     <insert id="updateRolePermissionByPermisList">
         INSERT INTO sys_role_ref_sys_permission(GUID,REF_SYS_ROLE, REF_SYS_PERMISSION)
         VALUES
-        <foreach collection="list" item="item" index="index" separator=",">
+        TracedCodeUtils.generateShortUuid()reach collection="list" item="item" index="index" separator=",">
             (#{item.guid},#{item.refSysRole},#{item.refSysPermission})
         </foreach>
     </insert>

+ 27 - 0
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/bo/MyCarbonValBO.java

@@ -0,0 +1,27 @@
+package com.hcloud.microserver.h5.bo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+@ApiModel("我的购碳分类")
+public class MyCarbonValBO {
+    /**
+     * 类型
+     */
+    @ApiModelProperty("类型")
+    private String type;
+    /**
+     * 文字
+     */
+    @ApiModelProperty("文字")
+    private String status;
+    /**
+     * 碳汇统计
+     */
+    @ApiModelProperty("碳汇统计")
+    private BigDecimal totalCarbonVal;
+}

+ 21 - 0
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/bo/MyCarbonValInfoBO.java

@@ -0,0 +1,21 @@
+package com.hcloud.microserver.h5.bo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+@Data
+@ApiModel("我的购碳分类")
+public class MyCarbonValInfoBO {
+    @ApiModelProperty("年份")
+    private Integer year;
+    @ApiModelProperty("总碳汇量")
+    private BigDecimal totalCarbonVal;
+    @ApiModelProperty("列表数据")
+    private List<MyCarbonValBO> data = new ArrayList<>();
+
+}

+ 24 - 9
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/controller/web/CustomerCarbonValController.java

@@ -5,6 +5,8 @@ import com.hcloud.microserver.commoncore.base.ResponseBase;
 import com.hcloud.microserver.commoncore.enums.ResultEnum;
 import com.hcloud.microserver.commoncore.exception.GlobalException;
 import com.hcloud.microserver.commoncore.util.string.StringUtils;
+import com.hcloud.microserver.h5.bo.MyCarbonValBO;
+import com.hcloud.microserver.h5.bo.MyCarbonValInfoBO;
 import com.hcloud.microserver.h5.common.CarbonBaseController;
 import com.hcloud.microserver.h5.facade.carbon.forms.CustomerCarbonValRankForm;
 import com.hcloud.microserver.h5.facade.carbon.forms.CustomerInfoForm;
@@ -19,9 +21,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
+
 @RestController
 @RequestMapping("/wap/carbonVal")
-@Api(tags = "购碳量信息接口",description = "购碳量信息接口")
+@Api(tags = "购碳量信息接口", description = "购碳量信息接口")
 public class CustomerCarbonValController extends CarbonBaseController {
 
     @Autowired
@@ -29,25 +33,25 @@ public class CustomerCarbonValController extends CarbonBaseController {
     @Autowired
     private CustomerService customerService;
 
-    @ApiOperation(value = "排行榜",notes = "排行榜")
+    @ApiOperation(value = "排行榜", notes = "排行榜")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "type",value = "类型 1:个人排行榜 2:企业排行榜", dataType = "int")
+            @ApiImplicitParam(name = "type", value = "类型 1:个人排行榜 2:企业排行榜", dataType = "int")
     })
-    @ApiResponse(code =0,message = "查询成功")
+    @ApiResponse(code = 0, message = "查询成功")
     @GetMapping("/getCustomerCarbonValRank")
-    public ResponseBase getCustomerCarbonValRank(@RequestParam("type") Integer type){
-        if (type < 1 || type > 2){
-            throw new GlobalException(ResultEnum.FAILURE.getCode(),"查询排行类型错误!");
+    public ResponseBase getCustomerCarbonValRank(@RequestParam("type") Integer type) {
+        if (type < 1 || type > 2) {
+            throw new GlobalException(ResultEnum.FAILURE.getCode(), "查询排行类型错误!");
         }
         CustomerCarbonValRankForm form = new CustomerCarbonValRankForm();
         form.setType(type);
         //获取是否有登录用户
         CustomerInfoForm customerInfo = CurrUserUtil.getCurrentMember();
         if (customerInfo != null) {
-            if (StringUtils.isEmpty(form.getCustomerId())){
+            if (StringUtils.isEmpty(form.getCustomerId())) {
                 form.setCustomerId(customerInfo.getGuid());
             }
-            if (form.getCustomerType() == null){
+            if (form.getCustomerType() == null) {
                 form.setCustomerType(customerInfo.getCustomerType());
             }
         }
@@ -55,4 +59,15 @@ public class CustomerCarbonValController extends CarbonBaseController {
         CustomerCarbonValRankVO vo = customerCarbonValService.getCustomerCarbonValRankList(form);
         return responseResultSuccess(vo);
     }
+
+    @ApiOperation(value = "我的购碳详情", notes = "我的购碳详情")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "year", value = "年份", dataType = "int")
+    })
+    @ApiResponse(code = 0, message = "查询成功")
+    @GetMapping("/myCarbonVal")
+    public ResponseBase<MyCarbonValInfoBO> myCarbonVal(@RequestParam("year") Integer year) {
+        MyCarbonValInfoBO data = customerCarbonValService.myCarbonVal(year);
+        return responseResultSuccess(data);
+    }
 }

+ 3 - 0
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/dao/CustomerCarbonValMapper.java

@@ -1,6 +1,7 @@
 package com.hcloud.microserver.h5.dao;
 
 import com.hcloud.microserver.h5.bo.ContributionBO;
+import com.hcloud.microserver.h5.bo.MyCarbonValBO;
 import com.hcloud.microserver.h5.facade.carbon.entity.CustomerCarbonVal;
 import com.hcloud.microserver.h5.facade.carbon.entity.CustomerCarbonValExample;
 import com.hcloud.microserver.h5.facade.carbon.forms.CustomerCarbonValRankForm;
@@ -58,4 +59,6 @@ public interface CustomerCarbonValMapper {
     Map<String, ContributionBO> subcarbonVal(@Param("year") Integer year);
 
     void insertSelectiveList(@Param("year") List<CustomerCarbonVal> list);
+
+    List<MyCarbonValBO> myCarbonVal(@Param("year") Integer year,@Param("guid") String guid);
 }

+ 5 - 0
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/service/CustomerCarbonValService.java

@@ -1,9 +1,12 @@
 package com.hcloud.microserver.h5.service;
 
+import com.hcloud.microserver.h5.bo.MyCarbonValBO;
+import com.hcloud.microserver.h5.bo.MyCarbonValInfoBO;
 import com.hcloud.microserver.h5.facade.carbon.forms.CustomerCarbonValRankForm;
 import com.hcloud.microserver.h5.facade.carbon.vo.CustomerCarbonValRankVO;
 
 import java.math.BigDecimal;
+import java.util.List;
 
 public interface CustomerCarbonValService {
 
@@ -18,4 +21,6 @@ public interface CustomerCarbonValService {
     BigDecimal selectCarbonAmountByCustomerId(String guid);
 
     void contribution();
+
+    MyCarbonValInfoBO myCarbonVal(Integer year);
 }

+ 25 - 0
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/service/impl/CustomerCarbonValServiceImpl.java

@@ -3,12 +3,17 @@ package com.hcloud.microserver.h5.service.impl;
 import com.hcloud.microserver.commoncore.util.string.StringUtils;
 import com.hcloud.microserver.commoncore.util.UUIDUtils;
 import com.hcloud.microserver.h5.bo.ContributionBO;
+import com.hcloud.microserver.h5.bo.MyCarbonValBO;
+import com.hcloud.microserver.h5.bo.MyCarbonValInfoBO;
 import com.hcloud.microserver.h5.dao.CustomerCarbonValMapper;
 import com.hcloud.microserver.h5.facade.carbon.entity.CustomerCarbonVal;
 import com.hcloud.microserver.h5.facade.carbon.forms.CustomerCarbonValRankForm;
+import com.hcloud.microserver.h5.facade.carbon.forms.CustomerInfoForm;
 import com.hcloud.microserver.h5.facade.carbon.vo.CustomerCarbonValRankVO;
 import com.hcloud.microserver.h5.service.CustomerCarbonValService;
+import com.hcloud.microserver.h5.service.CustomerService;
 import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -100,4 +105,24 @@ public class CustomerCarbonValServiceImpl implements CustomerCarbonValService {
         calendar.setTime(new Date());
         return calendar.get(Calendar.YEAR);
     }
+    @Autowired
+    private CustomerService customerService;
+
+    @Override
+    public MyCarbonValInfoBO myCarbonVal(Integer year){
+        MyCarbonValInfoBO myCarbonValInfoBO=new MyCarbonValInfoBO();
+        //获取登陆人信息
+        CustomerInfoForm customerInfo = customerService.getCurrentMember();
+        String guid = customerInfo.getGuid();
+
+        List<MyCarbonValBO> myCarbonValBOS = customerCarbonValMapper.myCarbonVal(year, guid);
+        BigDecimal totalCarbonVal=new BigDecimal(0);
+        for (MyCarbonValBO myCarbonValBO : myCarbonValBOS) {
+            totalCarbonVal = totalCarbonVal.add(myCarbonValBO.getTotalCarbonVal());
+        }
+        myCarbonValInfoBO.setYear(year);
+        myCarbonValInfoBO.setData(myCarbonValBOS);
+        myCarbonValInfoBO.setTotalCarbonVal(totalCarbonVal);
+        return myCarbonValInfoBO;
+    }
 }

+ 370 - 327
carbon-h5/carbon-h5-service/src/main/resources/com/hcloud/microserver/h5/dao/CustomerCarbonValMapper.xml

@@ -1,115 +1,119 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
-<mapper namespace="com.hcloud.microserver.h5.dao.CustomerCarbonValMapper" >
-  <resultMap id="BaseResultMap" type="com.hcloud.microserver.h5.facade.carbon.entity.CustomerCarbonVal" >
-    <id column="guid" property="guid" jdbcType="CHAR" />
-    <result column="t_customer_id" property="tCustomerId" jdbcType="CHAR" />
-    <result column="t_customer_name" property="tCustomerName" jdbcType="VARCHAR" />
-    <result column="carbon_val" property="carbonVal" jdbcType="DECIMAL" />
-    <result column="status" property="status" jdbcType="INTEGER" />
-    <result column="type" property="type" jdbcType="INTEGER" />
-    <result column="tb_guid" property="tbGuid" jdbcType="CHAR" />
-    <result column="tb_name" property="tbName" jdbcType="CHAR" />
-    <result column="remarks" property="remarks" jdbcType="CHAR" />
-    <result column="year_time" property="yearTime" jdbcType="INTEGER" />
-    <result column="create_user" property="createUser" jdbcType="CHAR" />
-    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
-    <result column="update_user" property="updateUser" jdbcType="CHAR" />
-    <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
-  </resultMap>
-  <sql id="Example_Where_Clause" >
-    <where >
-      <foreach collection="oredCriteria" item="criteria" separator="or" >
-        <if test="criteria.valid" >
-          <trim prefix="(" suffix=")" prefixOverrides="and" >
-            <foreach collection="criteria.criteria" item="criterion" >
-              <choose >
-                <when test="criterion.noValue" >
-                  and ${criterion.condition}
-                </when>
-                <when test="criterion.singleValue" >
-                  and ${criterion.condition} #{criterion.value}
-                </when>
-                <when test="criterion.betweenValue" >
-                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
-                </when>
-                <when test="criterion.listValue" >
-                  and ${criterion.condition}
-                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
-                    #{listItem}
-                  </foreach>
-                </when>
-              </choose>
+<mapper namespace="com.hcloud.microserver.h5.dao.CustomerCarbonValMapper">
+    <resultMap id="BaseResultMap" type="com.hcloud.microserver.h5.facade.carbon.entity.CustomerCarbonVal">
+        <id column="guid" property="guid" jdbcType="CHAR"/>
+        <result column="t_customer_id" property="tCustomerId" jdbcType="CHAR"/>
+        <result column="t_customer_name" property="tCustomerName" jdbcType="VARCHAR"/>
+        <result column="carbon_val" property="carbonVal" jdbcType="DECIMAL"/>
+        <result column="status" property="status" jdbcType="INTEGER"/>
+        <result column="type" property="type" jdbcType="INTEGER"/>
+        <result column="tb_guid" property="tbGuid" jdbcType="CHAR"/>
+        <result column="tb_name" property="tbName" jdbcType="CHAR"/>
+        <result column="remarks" property="remarks" jdbcType="CHAR"/>
+        <result column="year_time" property="yearTime" jdbcType="INTEGER"/>
+        <result column="create_user" property="createUser" jdbcType="CHAR"/>
+        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
+        <result column="update_user" property="updateUser" jdbcType="CHAR"/>
+        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
+    </resultMap>
+    <sql id="Example_Where_Clause">
+        <where>
+            <foreach collection="oredCriteria" item="criteria" separator="or">
+                <if test="criteria.valid">
+                    <trim prefix="(" suffix=")" prefixOverrides="and">
+                        <foreach collection="criteria.criteria" item="criterion">
+                            <choose>
+                                <when test="criterion.noValue">
+                                    and ${criterion.condition}
+                                </when>
+                                <when test="criterion.singleValue">
+                                    and ${criterion.condition} #{criterion.value}
+                                </when>
+                                <when test="criterion.betweenValue">
+                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                                </when>
+                                <when test="criterion.listValue">
+                                    and ${criterion.condition}
+                                    <foreach collection="criterion.value" item="listItem" open="(" close=")"
+                                             separator=",">
+                                        #{listItem}
+                                    </foreach>
+                                </when>
+                            </choose>
+                        </foreach>
+                    </trim>
+                </if>
             </foreach>
-          </trim>
-        </if>
-      </foreach>
-    </where>
-  </sql>
-  <sql id="Update_By_Example_Where_Clause" >
-    <where >
-      <foreach collection="example.oredCriteria" item="criteria" separator="or" >
-        <if test="criteria.valid" >
-          <trim prefix="(" suffix=")" prefixOverrides="and" >
-            <foreach collection="criteria.criteria" item="criterion" >
-              <choose >
-                <when test="criterion.noValue" >
-                  and ${criterion.condition}
-                </when>
-                <when test="criterion.singleValue" >
-                  and ${criterion.condition} #{criterion.value}
-                </when>
-                <when test="criterion.betweenValue" >
-                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
-                </when>
-                <when test="criterion.listValue" >
-                  and ${criterion.condition}
-                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
-                    #{listItem}
-                  </foreach>
-                </when>
-              </choose>
+        </where>
+    </sql>
+    <sql id="Update_By_Example_Where_Clause">
+        <where>
+            <foreach collection="example.oredCriteria" item="criteria" separator="or">
+                <if test="criteria.valid">
+                    <trim prefix="(" suffix=")" prefixOverrides="and">
+                        <foreach collection="criteria.criteria" item="criterion">
+                            <choose>
+                                <when test="criterion.noValue">
+                                    and ${criterion.condition}
+                                </when>
+                                <when test="criterion.singleValue">
+                                    and ${criterion.condition} #{criterion.value}
+                                </when>
+                                <when test="criterion.betweenValue">
+                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                                </when>
+                                <when test="criterion.listValue">
+                                    and ${criterion.condition}
+                                    <foreach collection="criterion.value" item="listItem" open="(" close=")"
+                                             separator=",">
+                                        #{listItem}
+                                    </foreach>
+                                </when>
+                            </choose>
+                        </foreach>
+                    </trim>
+                </if>
             </foreach>
-          </trim>
-        </if>
-      </foreach>
-    </where>
-  </sql>
-  <sql id="Base_Column_List" >
+        </where>
+    </sql>
+    <sql id="Base_Column_List">
     guid, t_customer_id, t_customer_name, carbon_val, status, type, tb_guid, tb_name, 
     remarks, year_time, create_user, create_time, update_user, update_time
   </sql>
-  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.hcloud.microserver.h5.facade.carbon.entity.CustomerCarbonValExample" >
-    select
-    <if test="distinct" >
-      distinct
-    </if>
-    <include refid="Base_Column_List" />
-    from t_customer_carbon_val
-    <if test="_parameter != null" >
-      <include refid="Example_Where_Clause" />
-    </if>
-    <if test="orderByClause != null" >
-      order by ${orderByClause}
-    </if>
-  </select>
-  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
-    select 
-    <include refid="Base_Column_List" />
-    from t_customer_carbon_val
-    where guid = #{guid,jdbcType=CHAR}
-  </select>
-  <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
+    <select id="selectByExample" resultMap="BaseResultMap"
+            parameterType="com.hcloud.microserver.h5.facade.carbon.entity.CustomerCarbonValExample">
+        select
+        <if test="distinct">
+            distinct
+        </if>
+        <include refid="Base_Column_List"/>
+        from t_customer_carbon_val
+        <if test="_parameter != null">
+            <include refid="Example_Where_Clause"/>
+        </if>
+        <if test="orderByClause != null">
+            order by ${orderByClause}
+        </if>
+    </select>
+    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String">
+        select
+        <include refid="Base_Column_List"/>
+        from t_customer_carbon_val
+        where guid = #{guid,jdbcType=CHAR}
+    </select>
+    <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
     delete from t_customer_carbon_val
     where guid = #{guid,jdbcType=CHAR}
   </delete>
-  <delete id="deleteByExample" parameterType="com.hcloud.microserver.h5.facade.carbon.entity.CustomerCarbonValExample" >
-    delete from t_customer_carbon_val
-    <if test="_parameter != null" >
-      <include refid="Example_Where_Clause" />
-    </if>
-  </delete>
-  <insert id="insert" parameterType="com.hcloud.microserver.h5.facade.carbon.entity.CustomerCarbonVal" >
+    <delete id="deleteByExample"
+            parameterType="com.hcloud.microserver.h5.facade.carbon.entity.CustomerCarbonValExample">
+        delete from t_customer_carbon_val
+        <if test="_parameter != null">
+            <include refid="Example_Where_Clause"/>
+        </if>
+    </delete>
+    <insert id="insert" parameterType="com.hcloud.microserver.h5.facade.carbon.entity.CustomerCarbonVal">
     insert into t_customer_carbon_val (guid, t_customer_id, t_customer_name, 
       carbon_val, status, type, 
       tb_guid, tb_name, remarks, year_time, 
@@ -121,219 +125,221 @@
       #{createUser,jdbcType=CHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateUser,jdbcType=CHAR}, 
       #{updateTime,jdbcType=TIMESTAMP})
   </insert>
-  <insert id="insertSelective" parameterType="com.hcloud.microserver.h5.facade.carbon.entity.CustomerCarbonVal" >
-    insert into t_customer_carbon_val
-    <trim prefix="(" suffix=")" suffixOverrides="," >
-      <if test="guid != null" >
-        guid,
-      </if>
-      <if test="tCustomerId != null" >
-        t_customer_id,
-      </if>
-      <if test="tCustomerName != null" >
-        t_customer_name,
-      </if>
-      <if test="carbonVal != null" >
-        carbon_val,
-      </if>
-      <if test="status != null" >
-        status,
-      </if>
-      <if test="type != null" >
-        type,
-      </if>
-      <if test="tbGuid != null" >
-        tb_guid,
-      </if>
-      <if test="tbName != null" >
-        tb_name,
-      </if>
-      <if test="remarks != null" >
-        remarks,
-      </if>
-      <if test="yearTime != null" >
-        year_time,
-      </if>
-      <if test="createUser != null" >
-        create_user,
-      </if>
-      <if test="createTime != null" >
-        create_time,
-      </if>
-      <if test="updateUser != null" >
-        update_user,
-      </if>
-      <if test="updateTime != null" >
-        update_time,
-      </if>
-    </trim>
-    <trim prefix="values (" suffix=")" suffixOverrides="," >
-      <if test="guid != null" >
-        #{guid,jdbcType=CHAR},
-      </if>
-      <if test="tCustomerId != null" >
-        #{tCustomerId,jdbcType=CHAR},
-      </if>
-      <if test="tCustomerName != null" >
-        #{tCustomerName,jdbcType=VARCHAR},
-      </if>
-      <if test="carbonVal != null" >
-        #{carbonVal,jdbcType=DECIMAL},
-      </if>
-      <if test="status != null" >
-        #{status,jdbcType=INTEGER},
-      </if>
-      <if test="type != null" >
-        #{type,jdbcType=INTEGER},
-      </if>
-      <if test="tbGuid != null" >
-        #{tbGuid,jdbcType=CHAR},
-      </if>
-      <if test="tbName != null" >
-        #{tbName,jdbcType=CHAR},
-      </if>
-      <if test="remarks != null" >
-        #{remarks,jdbcType=CHAR},
-      </if>
-      <if test="yearTime != null" >
-        #{yearTime,jdbcType=INTEGER},
-      </if>
-      <if test="createUser != null" >
-        #{createUser,jdbcType=CHAR},
-      </if>
-      <if test="createTime != null" >
-        #{createTime,jdbcType=TIMESTAMP},
-      </if>
-      <if test="updateUser != null" >
-        #{updateUser,jdbcType=CHAR},
-      </if>
-      <if test="updateTime != null" >
-        #{updateTime,jdbcType=TIMESTAMP},
-      </if>
-    </trim>
-  </insert>
-  <select id="countByExample" parameterType="com.hcloud.microserver.h5.facade.carbon.entity.CustomerCarbonValExample" resultType="java.lang.Integer" >
-    select count(*) from t_customer_carbon_val
-    <if test="_parameter != null" >
-      <include refid="Example_Where_Clause" />
-    </if>
-  </select>
-  <update id="updateByExampleSelective" parameterType="map" >
-    update t_customer_carbon_val
-    <set >
-      <if test="record.guid != null" >
-        guid = #{record.guid,jdbcType=CHAR},
-      </if>
-      <if test="record.tCustomerId != null" >
+    <insert id="insertSelective" parameterType="com.hcloud.microserver.h5.facade.carbon.entity.CustomerCarbonVal">
+        insert into t_customer_carbon_val
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="guid != null">
+                guid,
+            </if>
+            <if test="tCustomerId != null">
+                t_customer_id,
+            </if>
+            <if test="tCustomerName != null">
+                t_customer_name,
+            </if>
+            <if test="carbonVal != null">
+                carbon_val,
+            </if>
+            <if test="status != null">
+                status,
+            </if>
+            <if test="type != null">
+                type,
+            </if>
+            <if test="tbGuid != null">
+                tb_guid,
+            </if>
+            <if test="tbName != null">
+                tb_name,
+            </if>
+            <if test="remarks != null">
+                remarks,
+            </if>
+            <if test="yearTime != null">
+                year_time,
+            </if>
+            <if test="createUser != null">
+                create_user,
+            </if>
+            <if test="createTime != null">
+                create_time,
+            </if>
+            <if test="updateUser != null">
+                update_user,
+            </if>
+            <if test="updateTime != null">
+                update_time,
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="guid != null">
+                #{guid,jdbcType=CHAR},
+            </if>
+            <if test="tCustomerId != null">
+                #{tCustomerId,jdbcType=CHAR},
+            </if>
+            <if test="tCustomerName != null">
+                #{tCustomerName,jdbcType=VARCHAR},
+            </if>
+            <if test="carbonVal != null">
+                #{carbonVal,jdbcType=DECIMAL},
+            </if>
+            <if test="status != null">
+                #{status,jdbcType=INTEGER},
+            </if>
+            <if test="type != null">
+                #{type,jdbcType=INTEGER},
+            </if>
+            <if test="tbGuid != null">
+                #{tbGuid,jdbcType=CHAR},
+            </if>
+            <if test="tbName != null">
+                #{tbName,jdbcType=CHAR},
+            </if>
+            <if test="remarks != null">
+                #{remarks,jdbcType=CHAR},
+            </if>
+            <if test="yearTime != null">
+                #{yearTime,jdbcType=INTEGER},
+            </if>
+            <if test="createUser != null">
+                #{createUser,jdbcType=CHAR},
+            </if>
+            <if test="createTime != null">
+                #{createTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="updateUser != null">
+                #{updateUser,jdbcType=CHAR},
+            </if>
+            <if test="updateTime != null">
+                #{updateTime,jdbcType=TIMESTAMP},
+            </if>
+        </trim>
+    </insert>
+    <select id="countByExample" parameterType="com.hcloud.microserver.h5.facade.carbon.entity.CustomerCarbonValExample"
+            resultType="java.lang.Integer">
+        select count(*) from t_customer_carbon_val
+        <if test="_parameter != null">
+            <include refid="Example_Where_Clause"/>
+        </if>
+    </select>
+    <update id="updateByExampleSelective" parameterType="map">
+        update t_customer_carbon_val
+        <set>
+            <if test="record.guid != null">
+                guid = #{record.guid,jdbcType=CHAR},
+            </if>
+            <if test="record.tCustomerId != null">
+                t_customer_id = #{record.tCustomerId,jdbcType=CHAR},
+            </if>
+            <if test="record.tCustomerName != null">
+                t_customer_name = #{record.tCustomerName,jdbcType=VARCHAR},
+            </if>
+            <if test="record.carbonVal != null">
+                carbon_val = #{record.carbonVal,jdbcType=DECIMAL},
+            </if>
+            <if test="record.status != null">
+                status = #{record.status,jdbcType=INTEGER},
+            </if>
+            <if test="record.type != null">
+                type = #{record.type,jdbcType=INTEGER},
+            </if>
+            <if test="record.tbGuid != null">
+                tb_guid = #{record.tbGuid,jdbcType=CHAR},
+            </if>
+            <if test="record.tbName != null">
+                tb_name = #{record.tbName,jdbcType=CHAR},
+            </if>
+            <if test="record.remarks != null">
+                remarks = #{record.remarks,jdbcType=CHAR},
+            </if>
+            <if test="record.yearTime != null">
+                year_time = #{record.yearTime,jdbcType=INTEGER},
+            </if>
+            <if test="record.createUser != null">
+                create_user = #{record.createUser,jdbcType=CHAR},
+            </if>
+            <if test="record.createTime != null">
+                create_time = #{record.createTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="record.updateUser != null">
+                update_user = #{record.updateUser,jdbcType=CHAR},
+            </if>
+            <if test="record.updateTime != null">
+                update_time = #{record.updateTime,jdbcType=TIMESTAMP},
+            </if>
+        </set>
+        <if test="_parameter != null">
+            <include refid="Update_By_Example_Where_Clause"/>
+        </if>
+    </update>
+    <update id="updateByExample" parameterType="map">
+        update t_customer_carbon_val
+        set guid = #{record.guid,jdbcType=CHAR},
         t_customer_id = #{record.tCustomerId,jdbcType=CHAR},
-      </if>
-      <if test="record.tCustomerName != null" >
         t_customer_name = #{record.tCustomerName,jdbcType=VARCHAR},
-      </if>
-      <if test="record.carbonVal != null" >
         carbon_val = #{record.carbonVal,jdbcType=DECIMAL},
-      </if>
-      <if test="record.status != null" >
         status = #{record.status,jdbcType=INTEGER},
-      </if>
-      <if test="record.type != null" >
         type = #{record.type,jdbcType=INTEGER},
-      </if>
-      <if test="record.tbGuid != null" >
         tb_guid = #{record.tbGuid,jdbcType=CHAR},
-      </if>
-      <if test="record.tbName != null" >
         tb_name = #{record.tbName,jdbcType=CHAR},
-      </if>
-      <if test="record.remarks != null" >
         remarks = #{record.remarks,jdbcType=CHAR},
-      </if>
-      <if test="record.yearTime != null" >
         year_time = #{record.yearTime,jdbcType=INTEGER},
-      </if>
-      <if test="record.createUser != null" >
         create_user = #{record.createUser,jdbcType=CHAR},
-      </if>
-      <if test="record.createTime != null" >
         create_time = #{record.createTime,jdbcType=TIMESTAMP},
-      </if>
-      <if test="record.updateUser != null" >
         update_user = #{record.updateUser,jdbcType=CHAR},
-      </if>
-      <if test="record.updateTime != null" >
-        update_time = #{record.updateTime,jdbcType=TIMESTAMP},
-      </if>
-    </set>
-    <if test="_parameter != null" >
-      <include refid="Update_By_Example_Where_Clause" />
-    </if>
-  </update>
-  <update id="updateByExample" parameterType="map" >
-    update t_customer_carbon_val
-    set guid = #{record.guid,jdbcType=CHAR},
-      t_customer_id = #{record.tCustomerId,jdbcType=CHAR},
-      t_customer_name = #{record.tCustomerName,jdbcType=VARCHAR},
-      carbon_val = #{record.carbonVal,jdbcType=DECIMAL},
-      status = #{record.status,jdbcType=INTEGER},
-      type = #{record.type,jdbcType=INTEGER},
-      tb_guid = #{record.tbGuid,jdbcType=CHAR},
-      tb_name = #{record.tbName,jdbcType=CHAR},
-      remarks = #{record.remarks,jdbcType=CHAR},
-      year_time = #{record.yearTime,jdbcType=INTEGER},
-      create_user = #{record.createUser,jdbcType=CHAR},
-      create_time = #{record.createTime,jdbcType=TIMESTAMP},
-      update_user = #{record.updateUser,jdbcType=CHAR},
-      update_time = #{record.updateTime,jdbcType=TIMESTAMP}
-    <if test="_parameter != null" >
-      <include refid="Update_By_Example_Where_Clause" />
-    </if>
-  </update>
-  <update id="updateByPrimaryKeySelective" parameterType="com.hcloud.microserver.h5.facade.carbon.entity.CustomerCarbonVal" >
-    update t_customer_carbon_val
-    <set >
-      <if test="tCustomerId != null" >
-        t_customer_id = #{tCustomerId,jdbcType=CHAR},
-      </if>
-      <if test="tCustomerName != null" >
-        t_customer_name = #{tCustomerName,jdbcType=VARCHAR},
-      </if>
-      <if test="carbonVal != null" >
-        carbon_val = #{carbonVal,jdbcType=DECIMAL},
-      </if>
-      <if test="status != null" >
-        status = #{status,jdbcType=INTEGER},
-      </if>
-      <if test="type != null" >
-        type = #{type,jdbcType=INTEGER},
-      </if>
-      <if test="tbGuid != null" >
-        tb_guid = #{tbGuid,jdbcType=CHAR},
-      </if>
-      <if test="tbName != null" >
-        tb_name = #{tbName,jdbcType=CHAR},
-      </if>
-      <if test="remarks != null" >
-        remarks = #{remarks,jdbcType=CHAR},
-      </if>
-      <if test="yearTime != null" >
-        year_time = #{yearTime,jdbcType=INTEGER},
-      </if>
-      <if test="createUser != null" >
-        create_user = #{createUser,jdbcType=CHAR},
-      </if>
-      <if test="createTime != null" >
-        create_time = #{createTime,jdbcType=TIMESTAMP},
-      </if>
-      <if test="updateUser != null" >
-        update_user = #{updateUser,jdbcType=CHAR},
-      </if>
-      <if test="updateTime != null" >
-        update_time = #{updateTime,jdbcType=TIMESTAMP},
-      </if>
-    </set>
-    where guid = #{guid,jdbcType=CHAR}
-  </update>
-  <update id="updateByPrimaryKey" parameterType="com.hcloud.microserver.h5.facade.carbon.entity.CustomerCarbonVal" >
+        update_time = #{record.updateTime,jdbcType=TIMESTAMP}
+        <if test="_parameter != null">
+            <include refid="Update_By_Example_Where_Clause"/>
+        </if>
+    </update>
+    <update id="updateByPrimaryKeySelective"
+            parameterType="com.hcloud.microserver.h5.facade.carbon.entity.CustomerCarbonVal">
+        update t_customer_carbon_val
+        <set>
+            <if test="tCustomerId != null">
+                t_customer_id = #{tCustomerId,jdbcType=CHAR},
+            </if>
+            <if test="tCustomerName != null">
+                t_customer_name = #{tCustomerName,jdbcType=VARCHAR},
+            </if>
+            <if test="carbonVal != null">
+                carbon_val = #{carbonVal,jdbcType=DECIMAL},
+            </if>
+            <if test="status != null">
+                status = #{status,jdbcType=INTEGER},
+            </if>
+            <if test="type != null">
+                type = #{type,jdbcType=INTEGER},
+            </if>
+            <if test="tbGuid != null">
+                tb_guid = #{tbGuid,jdbcType=CHAR},
+            </if>
+            <if test="tbName != null">
+                tb_name = #{tbName,jdbcType=CHAR},
+            </if>
+            <if test="remarks != null">
+                remarks = #{remarks,jdbcType=CHAR},
+            </if>
+            <if test="yearTime != null">
+                year_time = #{yearTime,jdbcType=INTEGER},
+            </if>
+            <if test="createUser != null">
+                create_user = #{createUser,jdbcType=CHAR},
+            </if>
+            <if test="createTime != null">
+                create_time = #{createTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="updateUser != null">
+                update_user = #{updateUser,jdbcType=CHAR},
+            </if>
+            <if test="updateTime != null">
+                update_time = #{updateTime,jdbcType=TIMESTAMP},
+            </if>
+        </set>
+        where guid = #{guid,jdbcType=CHAR}
+    </update>
+    <update id="updateByPrimaryKey" parameterType="com.hcloud.microserver.h5.facade.carbon.entity.CustomerCarbonVal">
     update t_customer_carbon_val
     set t_customer_id = #{tCustomerId,jdbcType=CHAR},
       t_customer_name = #{tCustomerName,jdbcType=VARCHAR},
@@ -351,10 +357,11 @@
     where guid = #{guid,jdbcType=CHAR}
   </update>
 
-  <!-- 查询客户购碳量排行榜 lym -->
-  <select id="getCustomerCarbonValRankList" parameterType="com.hcloud.microserver.h5.facade.carbon.forms.CustomerCarbonValRankForm"
-      resultType="com.hcloud.microserver.h5.facade.carbon.forms.CustomerCarbonValRankForm">
-      SELECT obj.* from (SELECT @rownum := @rownum + 1 AS rank,tmp.t_customer_id AS customerId,tmp.carbonVal
+    <!-- 查询客户购碳量排行榜 lym -->
+    <select id="getCustomerCarbonValRankList"
+            parameterType="com.hcloud.microserver.h5.facade.carbon.forms.CustomerCarbonValRankForm"
+            resultType="com.hcloud.microserver.h5.facade.carbon.forms.CustomerCarbonValRankForm">
+        SELECT obj.* from (SELECT @rownum := @rownum + 1 AS rank,tmp.t_customer_id AS customerId,tmp.carbonVal
         ,IFNULL(c.customer_name,c.nick_name) AS customerName,c.head_image AS headImage
         FROM (SELECT @rownum := 0) r,(SELECT a.t_customer_id,SUM(a.carbon_val) AS carbonVal
         FROM t_customer_carbon_val a
@@ -362,20 +369,20 @@
         WHERE a.year_time BETWEEN YEAR(DATE_SUB(NOW(),INTERVAL 3 YEAR)) AND YEAR(NOW())
         AND a.type = 1
         <if test="type != null and type == 1">
-          AND b.customer_type = 1
+            AND b.customer_type = 1
         </if>
         <if test="type != null and type == 2">
-          AND b.customer_type != 1
+            AND b.customer_type != 1
         </if>
         GROUP BY t_customer_id
         ) tmp
         LEFT JOIN t_customer_info c ON tmp.t_customer_id = c.guid
         ORDER BY tmp.carbonVal DESC
-      ) obj WHERE 1 = 1
+        ) obj WHERE 1 = 1
         <if test="customerId != null and isCurrCustomerRank != null and isCurrCustomerRank == true">
-          AND obj.CustomerId = #{customerId}
+            AND obj.CustomerId = #{customerId}
         </if>
-  </select>
+    </select>
     <select id="selectCarbonAmountByCustomerId" resultType="java.math.BigDecimal">
         SELECT
             SUM(a.carbon_val)
@@ -413,22 +420,23 @@
       a.t_customer_id
     </select>
 
+
     <insert id="insertSelectiveList">
         INSERT INTO `t_customer_carbon_val` (
-            `guid`,
-            `t_customer_id`,
-            `t_customer_name`,
-            `carbon_val`,
-            `status`,
-            `type`,
-            `tb_guid`,
-            `tb_name`,
-            `remarks`,
-            `year_time`,
-            `create_user`,
-            `create_time`,
-            `update_user`,
-            `update_time`
+        `guid`,
+        `t_customer_id`,
+        `t_customer_name`,
+        `carbon_val`,
+        `status`,
+        `type`,
+        `tb_guid`,
+        `tb_name`,
+        `remarks`,
+        `year_time`,
+        `create_user`,
+        `create_time`,
+        `update_user`,
+        `update_time`
         )
         VALUES
         <foreach collection="list" item="item" index="index" separator=",">
@@ -450,6 +458,41 @@
             )
         </foreach>
 
-
     </insert>
+
+
+    <select id="myCarbonVal" resultType="com.hcloud.microserver.h5.bo.MyCarbonValBO">
+        SELECT
+        a.type,
+        CASE a.type
+        WHEN 1 THEN
+        '购买碳汇'
+        WHEN 2 THEN
+        '企业碳中和'
+        WHEN 3 THEN
+        '大型活动碳中和'
+        WHEN 4 THEN
+        '碳履约'
+        WHEN 5 THEN
+        '为重庆市碳排放量做贡献'
+        ELSE
+        '购买碳汇'
+        END 'status',
+        SUM(a.carbon_val) AS totalCarbonVal
+        FROM
+        t_customer_carbon_val a
+        WHERE
+        1=1
+        <choose>
+            <when test="year != null">
+                AND a.year_time = #{year}
+            </when>
+            <otherwise>
+                AND a.year_time = NOW()
+            </otherwise>
+        </choose>
+        AND a.t_customer_id = #{guid}
+        GROUP BY
+        a.type
+    </select>
 </mapper>