guoshilong
2022-09-22 a9ebc855851bb4d58ed5c8851e9a8ce7f608f776
任务计划路线范围添加修改
5 files modified
98 ■■■■ changed files
src/main/java/org/springblade/common/tool/EnhancementServicesTool.java 21 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/taskinfo/entity/TaskinfoPlanEntity.java 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/taskinfo/mapper/TaskinfoPlanMapper.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/taskinfo/mapper/TaskinfoPlanMapper.xml 49 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/taskinfo/service/impl/TaskinfoPlanServiceImpl.java 19 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/common/tool/EnhancementServicesTool.java
@@ -3,6 +3,7 @@
import org.springblade.core.mp.base.BaseEntity;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tenant.mp.TenantEntity;
import org.springblade.core.tool.utils.*;
import java.lang.reflect.Field;
@@ -17,7 +18,7 @@
 * @Date 2022/9/20 16:16
 * @Version 1.0
 */
public class EnhancementServicesTool <T extends BaseEntity> {
public class EnhancementServicesTool <T extends TenantEntity> {
    public void resolveEntity(T entity) {
        try {
            BladeUser user = AuthUtil.getUser();
@@ -40,24 +41,10 @@
            entity.setUpdateTime(now);
            entity.setIsDeleted(0);
            Field field = ReflectUtil.getField(entity.getClass(), "tenantId");
            if (ObjectUtil.isNotEmpty(field)) {
                Method getTenantId = ClassUtil.getMethod(entity.getClass(), "getTenantId", new Class[0]);
                String tenantId = String.valueOf(getTenantId.invoke(entity));
                if (ObjectUtil.isEmpty(tenantId)) {
                    Method setTenantId = ClassUtil.getMethod(entity.getClass(), "setTenantId", new Class[]{String.class});
                    setTenantId.invoke(entity, null);
                }
            }
            entity.setTenantId(user.getTenantId());
        } catch (Throwable var8) {
            try {
                throw var8;
            } catch (IllegalAccessException e) {
                throw new RuntimeException(e);
            } catch (InvocationTargetException e) {
                throw new RuntimeException(e);
            }
            throw var8;
        }
    }
}
src/main/java/org/springblade/modules/taskinfo/entity/TaskinfoPlanEntity.java
@@ -70,6 +70,6 @@
     * 路线范围
     */
    @ApiModelProperty(value = "路线范围")
    private byte[] routeRange;
    private String routeRange;
}
src/main/java/org/springblade/modules/taskinfo/mapper/TaskinfoPlanMapper.java
@@ -16,6 +16,7 @@
 */
package org.springblade.modules.taskinfo.mapper;
import org.apache.ibatis.annotations.Param;
import org.springblade.modules.taskinfo.entity.TaskinfoPlanEntity;
import org.springblade.modules.taskinfo.vo.TaskinfoPlanVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@@ -44,4 +45,10 @@
     * @return 最大工单编号
     */
    TaskinfoPlanVO getMaxNo();
    Integer saveTaskinfoPlan(@Param("taskinfoPlan") TaskinfoPlanEntity entity);
    Integer updateTaskinfoPlan(@Param("taskinfoPlan")TaskinfoPlanEntity entity);
    TaskinfoPlanEntity getTaskInfoPlanOne(@Param("id") Long id);
}
src/main/java/org/springblade/modules/taskinfo/mapper/TaskinfoPlanMapper.xml
@@ -24,12 +24,59 @@
    <select id="selectTaskinfoPlanPage" resultMap="taskinfoPlanResultMap">
        select * from ins_taskinfo_plan where is_deleted = 0
        select id,no,title,type,start_time,end_time,content,ST_ASTEXT(route_range) as route_range,
               create_user,create_time,update_user,update_time,status,is_deleted from ins_taskinfo_plan
        from ins_taskinfo_plan where is_deleted = 0
    </select>
    <select id="getMaxNo" resultMap="taskinfoPlanResultMap">
        SELECT * from ins_taskinfo_plan where is_deleted = 0 ORDER BY create_time DESC LIMIT 1
    </select>
    <select id="getTaskInfoPlanOne" resultType="org.springblade.modules.taskinfo.entity.TaskinfoPlanEntity">
        select id,no,title,type,start_time,end_time,content,ST_ASTEXT(route_range) as route_range,
               create_user,create_time,update_user,update_time,status,is_deleted from ins_taskinfo_plan
        where id = #{id} and is_deleted = 0
    </select>
    <insert id="saveTaskinfoPlan">
        INSERT INTO ins_taskinfo_plan (id, no, title, type, start_time,end_time,content,
        <if test="taskinfoPlan.routeRange!=null and taskinfoPlan.routeRange!=''">
            route_range,
        </if>
        create_user,create_time,
        update_user, update_time,
        status, is_deleted,
        tenant_id,create_dept)
        VALUES
        (#{taskinfoPlan.id},#{taskinfoPlan.no},#{taskinfoPlan.title},#{taskinfoPlan.type},#{taskinfoPlan.startTime},#{taskinfoPlan.endTime},#{taskinfoPlan.content},
        <if test="taskinfoPlan.routeRange!=null and taskinfoPlan.routeRange!=''">
            ST_GeomFromText(${taskinfoPlan.routeRange}),
        </if>
       #{taskinfoPlan.createUser},#{taskinfoPlan.createTime},
        #{taskinfoPlan.updateUser},#{taskinfoPlan.updateTime},
        #{taskinfoPlan.status},#{taskinfoPlan.isDeleted},
        #{taskinfoPlan.tenantId},#{taskinfoPlan.createDept})
    </insert>
    <update id="updateTaskinfoPlan">
        UPDATE ins_taskinfo_plan SET
        title = #{taskinfoPlan.title},
        type = #{taskinfoPlan.type},
        start_time = #{taskinfoPlan.startTime},
        end_time = #{taskinfoPlan.endTime},
        content = #{taskinfoPlan.content},
        <if test="taskinfoPlan.routeRange!=null and taskinfoPlan.routeRange!=''">
            route_range = ST_GeomFromText(${taskinfoPlan.routeRange}),
        </if>
        tenant_id = #{taskinfoPlan.tenantId},
        create_user = #{taskinfoPlan.createUser},
        create_dept = #{taskinfoPlan.createDept},
        create_time = #{taskinfoPlan.createTime},
        update_user = #{taskinfoPlan.updateUser},
        update_time = #{taskinfoPlan.updateTime},
        status = #{taskinfoPlan.status}
        WHERE id = #{taskinfoPlan.id} AND is_deleted = 0
    </update>
</mapper>
src/main/java/org/springblade/modules/taskinfo/service/impl/TaskinfoPlanServiceImpl.java
@@ -16,7 +16,11 @@
 */
package org.springblade.modules.taskinfo.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
import org.springblade.common.constant.NoConstant;
import org.springblade.common.tool.EnhancementServicesTool;
import org.springblade.modules.taskinfo.entity.TaskInfoEntity;
import org.springblade.modules.taskinfo.entity.TaskinfoPlanEntity;
import org.springblade.modules.taskinfo.vo.TaskinfoPlanVO;
import org.springblade.modules.taskinfo.mapper.TaskinfoPlanMapper;
@@ -41,6 +45,11 @@
    }
    @Override
    public TaskinfoPlanEntity getOne(Wrapper<TaskinfoPlanEntity> queryWrapper) {
        return baseMapper.getTaskInfoPlanOne(queryWrapper.getEntity().getId());
    }
    @Override
    public boolean save(TaskinfoPlanEntity entity) {
        TaskinfoPlanVO vo = new TaskinfoPlanVO();
        String str = "";
@@ -48,7 +57,10 @@
            str = vo.getNo();
        }
        entity.setNo(NumberUtils.autoCreateNumber(NoConstant.XJJH__PREFIX_NO,str));
        return super.save(entity);
        EnhancementServicesTool tool = new EnhancementServicesTool<TaskinfoPlanEntity>();
        tool.resolveEntity(entity);
        return SqlHelper.retBool(baseMapper.saveTaskinfoPlan(entity));
    }
    @Override
@@ -56,5 +68,8 @@
        return baseMapper.getMaxNo();
    }
    @Override
    public boolean updateById(TaskinfoPlanEntity entity) {
        return SqlHelper.retBool(baseMapper.updateTaskinfoPlan(entity));
    }
}