浏览代码

Merge branch 'energy-manage-shiyue'

shiyue 5 月之前
父节点
当前提交
2886bbbb84

+ 12 - 0
energy-manage-service/src/main/java/com/energy/manage/service/mappers/units/UnitGearboxBearingsMapper.java

@@ -3,8 +3,20 @@ package com.energy.manage.service.mappers.units;
 import com.energy.manage.common.mapper.MyMapper;
 import com.energy.manage.common.po.units.UnitGearboxBearingsPO;
 import com.energy.manage.common.po.units.UnitGearboxPO;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
+import java.util.List;
+
 @Repository
 public interface UnitGearboxBearingsMapper extends MyMapper<UnitGearboxBearingsPO> {
+
+    /**
+     * 批量更新
+     * @param list
+     */
+    void batchUpdate(@Param("list") List<UnitGearboxBearingsPO> list);
+
+
+
 }

+ 13 - 0
energy-manage-service/src/main/java/com/energy/manage/service/mappers/units/UnitGearboxStructureMapper.java

@@ -1,10 +1,23 @@
 package com.energy.manage.service.mappers.units;
 
 import com.energy.manage.common.mapper.MyMapper;
+import com.energy.manage.common.po.units.UnitGearboxBearingsPO;
 import com.energy.manage.common.po.units.UnitGearboxPO;
 import com.energy.manage.common.po.units.UnitGearboxStructurePO;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
+import java.util.List;
+
 @Repository
 public interface UnitGearboxStructureMapper extends MyMapper<UnitGearboxStructurePO> {
+
+    /**
+     * 批量更新
+     * @param list
+     */
+    void batchUpdate(@Param("list") List<UnitGearboxStructurePO> list);
+
+
+
 }

+ 1 - 0
energy-manage-service/src/main/java/com/energy/manage/service/service/anemometertower/impl/AnemometerTowerServiceImpl.java

@@ -144,6 +144,7 @@ public class AnemometerTowerServiceImpl extends BaseServiceImpl<AnemometerTowerP
         criteria.andEqualTo("anemometerCode", anemometerTowerStateDto.getAnemometerCode());
         criteria.andEqualTo("delState", DeleteStatusEnum.NODELETE.getCode());
         return anemometerTowerMapper.updateByExampleSelective(po, queryExample) > 0;
+
     }
 
     @Override

+ 43 - 25
energy-manage-service/src/main/java/com/energy/manage/service/service/units/impl/UnitServiceImpl.java

@@ -189,44 +189,62 @@ public class UnitServiceImpl implements UnitService {
         if (unitGearboxPO != null) {
             // 处理齿轮箱轴承处理
             if (!CollectionUtils.isEmpty(unitDto.getUnitGearDto().getUnitGearboxBearingsDtoList())) {
+
                 UnitGearboxBearingsPO unitGearboxBearingsPO = null;
-                List<UnitGearboxBearingsPO> unitGearboxBearingsPOList = Lists.newArrayList();
+                List<UnitGearboxBearingsPO> unitGearboxBearingsSaveList = Lists.newArrayList();
+                List<UnitGearboxBearingsPO> unitGearboxBearingsUpdateList = Lists.newArrayList();
                 for (UnitDto.UnitGearboxBearingsDto dto : unitDto.getUnitGearDto().getUnitGearboxBearingsDtoList()) {
                     unitGearboxBearingsPO = new UnitGearboxBearingsPO();
                     BeanUtil.copyProperties(dto, unitGearboxBearingsPO);
-                    unitGearboxBearingsPO.setGearboxCode(unitGearboxPO.getCode());
-                    unitGearboxBearingsPO.setCreateBy(userId);
-                    unitGearboxBearingsPO.setUpdateBy(userId);
-                    unitGearboxBearingsPO.setCreateTime(new Date());
-                    unitGearboxBearingsPO.setUpdateTime(new Date());
-                    unitGearboxBearingsPOList.add(unitGearboxBearingsPO);
+                    if (dto.getId() == null) {
+                        unitGearboxBearingsPO.setGearboxCode(unitGearboxPO.getCode());
+                        unitGearboxBearingsPO.setCreateBy(userId);
+                        unitGearboxBearingsPO.setUpdateBy(userId);
+                        unitGearboxBearingsPO.setCreateTime(new Date());
+                        unitGearboxBearingsPO.setUpdateTime(new Date());
+                        unitGearboxBearingsSaveList.add(unitGearboxBearingsPO);
+                    }else{
+                        unitGearboxBearingsPO.setUpdateBy(userId);
+                        unitGearboxBearingsPO.setUpdateTime(new Date());
+                        unitGearboxBearingsUpdateList.add(unitGearboxBearingsPO);
+                    }
+                }
+                if(!CollectionUtils.isEmpty(unitGearboxBearingsSaveList)){
+                    unitGearboxBearingsMapper.insertList(unitGearboxBearingsSaveList);
+                }
+                if(!CollectionUtils.isEmpty(unitGearboxBearingsUpdateList)){
+                    unitGearboxBearingsMapper.batchUpdate(unitGearboxBearingsUpdateList);
                 }
-                UnitGearboxBearingsPO po = new UnitGearboxBearingsPO();
-                po.setGearboxCode(unitGearboxPO.getCode());
-                unitGearboxBearingsMapper.delete(po);
-
-                flg = unitGearboxBearingsMapper.insertList(unitGearboxBearingsPOList) > 0;
             }
 
             // 处理齿轮箱结构
             if (!CollectionUtils.isEmpty(unitDto.getUnitGearDto().getUnitGearboxStructureDtoList())) {
                 UnitGearboxStructurePO unitGearboxStructurePO = null;
-                List<UnitGearboxStructurePO> unitGearboxStructurePOList = Lists.newArrayList();
+                List<UnitGearboxStructurePO> unitGearboxStructureSaveList = Lists.newArrayList();
+                List<UnitGearboxStructurePO> unitGearboxStructureUpdateList = Lists.newArrayList();
                 for (UnitDto.UnitGearboxStructureDto dto : unitDto.getUnitGearDto().getUnitGearboxStructureDtoList()) {
                     unitGearboxStructurePO = new UnitGearboxStructurePO();
                     BeanUtil.copyProperties(dto, unitGearboxStructurePO);
-                    unitGearboxStructurePO.setGearboxCode(unitGearboxPO.getCode());
-                    unitGearboxStructurePO.setCreateTime(new Date());
-                    unitGearboxStructurePO.setUpdateTime(new Date());
-                    unitGearboxStructurePO.setCreateBy(userId);
-                    unitGearboxStructurePO.setUpdateBy(userId);
-                    unitGearboxStructurePOList.add(unitGearboxStructurePO);
-                }
-                UnitGearboxStructurePO po = new UnitGearboxStructurePO();
-                po.setGearboxCode(unitGearboxPO.getCode());
-                unitGearboxStructureMapper.delete(po);
+                    if(dto.getId()==null){
+                        unitGearboxStructurePO.setGearboxCode(unitGearboxPO.getCode());
+                        unitGearboxStructurePO.setCreateTime(new Date());
+                        unitGearboxStructurePO.setUpdateTime(new Date());
+                        unitGearboxStructurePO.setCreateBy(userId);
+                        unitGearboxStructurePO.setUpdateBy(userId);
+                        unitGearboxStructureSaveList.add(unitGearboxStructurePO);
+                    }else{
+                        unitGearboxStructurePO.setUpdateTime(new Date());
+                        unitGearboxStructurePO.setUpdateBy(userId);
+                        unitGearboxStructureUpdateList.add(unitGearboxStructurePO);
+                    }
 
-                flg = unitGearboxStructureMapper.insertList(unitGearboxStructurePOList) > 0;
+                }
+                if(!CollectionUtils.isEmpty(unitGearboxStructureSaveList)){
+                    unitGearboxStructureMapper.insertList(unitGearboxStructureSaveList);
+                }
+                if(!CollectionUtils.isEmpty(unitGearboxStructureUpdateList)){
+                    unitGearboxStructureMapper.batchUpdate(unitGearboxStructureUpdateList);
+                }
             }
         }
         return flg;
@@ -328,7 +346,7 @@ public class UnitServiceImpl implements UnitService {
         Example.Criteria criteria = queryExample.createCriteria();
         criteria.andEqualTo("millTypeCode", millTypeCode);
 
-        return unitDynamoMapper.selectOneByExample(queryExample) ;
+        return unitDynamoMapper.selectOneByExample(queryExample);
     }
 
 

+ 1 - 0
energy-manage-service/src/main/resources/mybatis/units/UnitBrandModelMapper.xml

@@ -25,4 +25,5 @@
 
 
 
+
 </mapper>

+ 30 - 0
energy-manage-service/src/main/resources/mybatis/units/UnitGearBoxBearingsMapper.xml

@@ -0,0 +1,30 @@
+<?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.energy.manage.service.mappers.units.UnitGearboxBearingsMapper">
+
+
+    <!-- 批量更新语句 -->
+    <update id="batchUpdate" parameterType="java.util.List">
+        <foreach collection="list" item="item" index="index" separator=";">
+            UPDATE unit_gearbox_bearings
+            <set>
+                <if test="item.gearboxCode != null">gearbox_code = #{item.gearboxCode},</if>
+                <if test="item.parallelWheelGrade != null">parallel_wheel_grade = #{item.parallelWheelGrade},</if>
+                <if test="item.gearboxBearingNumber != null">gearbox_bearing_number = #{item.gearboxBearingNumber},</if>
+                <if test="item.gearboxBearingLevel != null">gearbox_bearing_level = #{item.gearboxBearingLevel},</if>
+                <if test="item.bearingBrand != null">bearing_brand = #{item.bearingBrand},</if>
+                <if test="item.bearingModel != null">bearing_model = #{item.bearingModel},</if>
+                <if test="item.gearRingTeethCount != null">gear_ring_teeth_count = #{item.gearRingTeethCount},</if>
+                <if test="item.bearingRsBrand != null">bearing_rs_brand = #{item.bearingRsBrand},</if>
+                <if test="item.bearingRsModel != null">bearing_rs_model = #{item.bearingRsModel},</if>
+                <if test="item.bearingGsBrand != null">bearing_gs_brand = #{item.bearingGsBrand},</if>
+                <if test="item.bearingGsModel != null">bearing_gs_model = #{item.bearingGsModel},</if>
+                <if test="item.updateBy != null">update_by = #{item.updateBy},</if>
+                <if test="item.updateTime != null">update_time = #{item.updateTime}</if>
+            </set>
+            WHERE id = #{item.id}
+        </foreach>
+    </update>
+
+
+</mapper>

+ 44 - 0
energy-manage-service/src/main/resources/mybatis/units/UnitGearBoxStructureMapper.xml

@@ -0,0 +1,44 @@
+<?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.energy.manage.service.mappers.units.UnitGearboxStructureMapper">
+
+
+    <!-- 批量更新语句 -->
+    <update id="batchUpdate" parameterType="java.util.List">
+        <foreach collection="list" item="item" index="index" separator=";">
+            UPDATE unit_gearbox_structure
+            <set>
+                <if test="item.gearboxCode != null">gearbox_code = #{item.gearboxCode},</if>
+                <if test="item.gearboxStructure != null">gearbox_structure = #{item.gearboxStructure},</if>
+                <if test="item.planetaryGearGrade != null">planetary_gear_grade = #{item.planetaryGearGrade},</if>
+                <if test="item.largeGearTeethCount != null">large_gear_teeth_count =
+                    #{item.largeGearTeethCount},
+                </if>
+                <if test="item.smallGearTeethCount != null">small_gear_teeth_count =
+                    #{item.smallGearTeethCount},
+                </if>
+                <if test="item.bearingBrand != null">bearing_brand = #{item.bearingBrand},</if>
+                <if test="item.bearingModel != null">bearing_model = #{item.bearingModel},</if>
+                <if test="item.gearRingTeethCount != null">gear_ring_teeth_count = #{item.gearRingTeethCount},
+                </if>
+                <if test="item.sunWheelTeethCount != null">sun_wheel_teeth_count = #{item.sunWheelTeethCount},
+                </if>
+                <if test="item.planetWheelCount != null">planet_wheel_count = #{item.planetWheelCount},</if>
+                <if test="item.planetWheelTeethCount != null">planet_wheel_teeth_count =
+                    #{item.planetWheelTeethCount},
+                </if>
+                <if test="item.sunWheelBearingBrand != null">sun_wheel_bearing_brand =
+                    #{item.sunWheelBearingBrand},
+                </if>
+                <if test="item.sunWheelBearingModel != null">sun_wheel_bearing_model =
+                    #{item.sunWheelBearingModel},
+                </if>
+                <if test="item.updateBy != null">update_by = #{item.updateBy},</if>
+                <if test="item.updateTime != null">update_time = #{item.updateTime}</if>
+            </set>
+            WHERE id = #{item.id}
+        </foreach>
+    </update>
+
+
+</mapper>