浏览代码

架次信息管理/创建信息更新信息初始化

wanggaokun 1 年之前
父节点
当前提交
4f53094b9d

+ 25 - 0
PHM-admin/phm-common/src/main/java/com/phm/common/core/domain/BaseEntity.java

@@ -8,6 +8,9 @@ import java.util.Map;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonInclude;
 import com.fasterxml.jackson.annotation.JsonInclude;
+import com.phm.common.core.domain.model.LoginUser;
+import com.phm.common.utils.DateUtils;
+import com.phm.common.utils.SecurityUtils;
 
 
 /**
 /**
  * Entity基类
  * Entity基类
@@ -127,4 +130,26 @@ public class BaseEntity implements Serializable {
     public void setParams(Map<String, Object> params) {
     public void setParams(Map<String, Object> params) {
         this.params = params;
         this.params = params;
     }
     }
+
+    /**
+     * 新增数据SET创建和更新信息
+     */
+    public void initCreatInfo() {
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        Date nowDate = DateUtils.getNowDate();
+        this.createBy = loginUser.getUsername();
+        this.createTime =nowDate;
+        this.updateBy = loginUser.getUsername();
+        this.updateTime =nowDate;
+    }
+
+    /**
+     * 更新数据时,SET更新信息
+     */
+    public void initUpdateInfo() {
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        Date nowDate = DateUtils.getNowDate();
+        this.updateBy = loginUser.getUsername();
+        this.updateTime =nowDate;
+    }
 }
 }

+ 16 - 0
PHM-admin/phm-manage/src/main/java/com/phm/manage/controller/SortieController.java

@@ -3,6 +3,7 @@ package com.phm.manage.controller;
 import com.phm.common.annotation.Log;
 import com.phm.common.annotation.Log;
 import com.phm.common.core.controller.BaseController;
 import com.phm.common.core.controller.BaseController;
 import com.phm.common.core.domain.AjaxResult;
 import com.phm.common.core.domain.AjaxResult;
+import com.phm.common.core.domain.entity.SysUser;
 import com.phm.common.core.page.TableDataInfo;
 import com.phm.common.core.page.TableDataInfo;
 import com.phm.common.enums.BusinessType;
 import com.phm.common.enums.BusinessType;
 import com.phm.common.utils.poi.ExcelUtil;
 import com.phm.common.utils.poi.ExcelUtil;
@@ -11,6 +12,7 @@ import com.phm.manage.service.ISortieService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 import java.util.List;
@@ -49,6 +51,20 @@ public class SortieController extends BaseController {
         ExcelUtil<Sortie> util = new ExcelUtil<Sortie>(Sortie.class);
         ExcelUtil<Sortie> util = new ExcelUtil<Sortie>(Sortie.class);
         util.exportExcel(response, list, "架次信息数据");
         util.exportExcel(response, list, "架次信息数据");
     }
     }
+    @Log(title = "架次信息", businessType = BusinessType.IMPORT)
+//    @PreAuthorize("@ss.hasPermi('manage:sortie:import')")
+    @PostMapping("/import")
+    public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
+        ExcelUtil<Sortie> util = new ExcelUtil<Sortie>(Sortie.class);
+        List<Sortie> sortieList = util.importExcel(file.getInputStream());
+        return success("导入成功");
+    }
+
+    @PostMapping("/importTemplate")
+    public void importTemplate(HttpServletResponse response) {
+        ExcelUtil<Sortie> util = new ExcelUtil<Sortie>(Sortie.class);
+        util.importTemplateExcel(response, "架次数据");
+    }
 
 
     /**
     /**
      * 获取架次信息详细信息
      * 获取架次信息详细信息

+ 13 - 83
PHM-admin/phm-manage/src/main/java/com/phm/manage/domain/Sortie.java

@@ -12,7 +12,7 @@ import java.util.Date;
  * 架次信息对象 phm_sortie
  * 架次信息对象 phm_sortie
  *
  *
  * @author phm
  * @author phm
- * @date 2023-08-22
+ * @date 2023-08-25
  */
  */
 public class Sortie extends BaseEntity {
 public class Sortie extends BaseEntity {
     private static final long serialVersionUID = 1L;
     private static final long serialVersionUID = 1L;
@@ -38,13 +38,15 @@ public class Sortie extends BaseEntity {
      * 开始时间
      * 开始时间
      */
      */
     @Excel(name = "开始时间")
     @Excel(name = "开始时间")
-    private String startTime;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date startTime;
 
 
     /**
     /**
      * 结束时间
      * 结束时间
      */
      */
     @Excel(name = "结束时间")
     @Excel(name = "结束时间")
-    private String endTime;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date endTime;
 
 
     /**
     /**
      * 飞行时长
      * 飞行时长
@@ -52,38 +54,6 @@ public class Sortie extends BaseEntity {
     @Excel(name = "飞行时长")
     @Excel(name = "飞行时长")
     private String duration;
     private String duration;
 
 
-    /**
-     * 数据是否删除(1:删除,0有效)
-     */
-    @Excel(name = "数据是否删除", readConverterExp = "1=:删除,0有效")
-    private Long isDelete;
-
-    /**
-     * 创建人
-     */
-    @Excel(name = "创建人")
-    private String createdBy;
-
-    /**
-     * 创建时间
-     */
-    @JsonFormat(pattern = "yyyy-MM-dd")
-    @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
-    private Date createdTime;
-
-    /**
-     * 更新人
-     */
-    @Excel(name = "更新人")
-    private String updatedBy;
-
-    /**
-     * 更新时间
-     */
-    @JsonFormat(pattern = "yyyy-MM-dd")
-    @Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd")
-    private Date updatedTime;
-
     public void setId(Long id) {
     public void setId(Long id) {
         this.id = id;
         this.id = id;
     }
     }
@@ -108,19 +78,19 @@ public class Sortie extends BaseEntity {
         return sortieNumber;
         return sortieNumber;
     }
     }
 
 
-    public void setStartTime(String startTime) {
+    public void setStartTime(Date startTime) {
         this.startTime = startTime;
         this.startTime = startTime;
     }
     }
 
 
-    public String getStartTime() {
+    public Date getStartTime() {
         return startTime;
         return startTime;
     }
     }
 
 
-    public void setEndTime(String endTime) {
+    public void setEndTime(Date endTime) {
         this.endTime = endTime;
         this.endTime = endTime;
     }
     }
 
 
-    public String getEndTime() {
+    public Date getEndTime() {
         return endTime;
         return endTime;
     }
     }
 
 
@@ -132,46 +102,6 @@ public class Sortie extends BaseEntity {
         return duration;
         return duration;
     }
     }
 
 
-    public void setIsDelete(Long isDelete) {
-        this.isDelete = isDelete;
-    }
-
-    public Long getIsDelete() {
-        return isDelete;
-    }
-
-    public void setCreatedBy(String createdBy) {
-        this.createdBy = createdBy;
-    }
-
-    public String getCreatedBy() {
-        return createdBy;
-    }
-
-    public void setCreatedTime(Date createdTime) {
-        this.createdTime = createdTime;
-    }
-
-    public Date getCreatedTime() {
-        return createdTime;
-    }
-
-    public void setUpdatedBy(String updatedBy) {
-        this.updatedBy = updatedBy;
-    }
-
-    public String getUpdatedBy() {
-        return updatedBy;
-    }
-
-    public void setUpdatedTime(Date updatedTime) {
-        this.updatedTime = updatedTime;
-    }
-
-    public Date getUpdatedTime() {
-        return updatedTime;
-    }
-
     @Override
     @Override
     public String toString() {
     public String toString() {
         return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
         return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
@@ -182,10 +112,10 @@ public class Sortie extends BaseEntity {
                 .append("endTime", getEndTime())
                 .append("endTime", getEndTime())
                 .append("duration", getDuration())
                 .append("duration", getDuration())
                 .append("isDelete", getIsDelete())
                 .append("isDelete", getIsDelete())
-                .append("createdBy", getCreatedBy())
-                .append("createdTime", getCreatedTime())
-                .append("updatedBy", getUpdatedBy())
-                .append("updatedTime", getUpdatedTime())
+                .append("createBy", getCreateBy())
+                .append("createTime", getCreateTime())
+                .append("updateBy", getUpdateBy())
+                .append("updateTime", getUpdateTime())
                 .toString();
                 .toString();
     }
     }
 }
 }

+ 2 - 0
PHM-admin/phm-manage/src/main/java/com/phm/manage/service/impl/SortieServiceImpl.java

@@ -49,6 +49,7 @@ public class SortieServiceImpl implements ISortieService {
      */
      */
     @Override
     @Override
     public int insertSortie(Sortie sortie) {
     public int insertSortie(Sortie sortie) {
+        sortie.initCreatInfo();
         return sortieMapper.insertSortie(sortie);
         return sortieMapper.insertSortie(sortie);
     }
     }
 
 
@@ -60,6 +61,7 @@ public class SortieServiceImpl implements ISortieService {
      */
      */
     @Override
     @Override
     public int updateSortie(Sortie sortie) {
     public int updateSortie(Sortie sortie) {
+        sortie.initUpdateInfo();
         return sortieMapper.updateSortie(sortie);
         return sortieMapper.updateSortie(sortie);
     }
     }
 
 

+ 9 - 14
PHM-admin/phm-manage/src/main/resources/mapper/manage/SortieMapper.xml

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper
 <!DOCTYPE mapper
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.phm.manage.mapper.SortieMapper">
 <mapper namespace="com.phm.manage.mapper.SortieMapper">
-    
+
     <resultMap type="Sortie" id="SortieResult">
     <resultMap type="Sortie" id="SortieResult">
         <result property="id"    column="id"    />
         <result property="id"    column="id"    />
         <result property="aircraftNumber"    column="aircraft_number"    />
         <result property="aircraftNumber"    column="aircraft_number"    />
@@ -24,25 +24,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
 
     <select id="selectSortieList" parameterType="Sortie" resultMap="SortieResult">
     <select id="selectSortieList" parameterType="Sortie" resultMap="SortieResult">
         <include refid="selectSortieVo"/>
         <include refid="selectSortieVo"/>
-        <where>  
+        <where>
             <if test="aircraftNumber != null  and aircraftNumber != ''"> and aircraft_number = #{aircraftNumber}</if>
             <if test="aircraftNumber != null  and aircraftNumber != ''"> and aircraft_number = #{aircraftNumber}</if>
             <if test="sortieNumber != null  and sortieNumber != ''"> and sortie_number = #{sortieNumber}</if>
             <if test="sortieNumber != null  and sortieNumber != ''"> and sortie_number = #{sortieNumber}</if>
             <if test="startTime != null  and startTime != ''"> and start_time = #{startTime}</if>
             <if test="startTime != null  and startTime != ''"> and start_time = #{startTime}</if>
             <if test="endTime != null  and endTime != ''"> and end_time = #{endTime}</if>
             <if test="endTime != null  and endTime != ''"> and end_time = #{endTime}</if>
             <if test="duration != null  and duration != ''"> and duration = #{duration}</if>
             <if test="duration != null  and duration != ''"> and duration = #{duration}</if>
-            <if test="isDelete != null "> and is_delete = #{isDelete}</if>
-            <if test="createBy != null  and createBy != ''"> and create_by = #{createBy}</if>
-            <if test="createTime != null "> and create_time = #{createTime}</if>
-            <if test="updateBy != null  and updateBy != ''"> and update_by = #{updateBy}</if>
-            <if test="updateTime != null "> and update_time = #{updateTime}</if>
         </where>
         </where>
     </select>
     </select>
-    
+
     <select id="selectSortieById" parameterType="Long" resultMap="SortieResult">
     <select id="selectSortieById" parameterType="Long" resultMap="SortieResult">
         <include refid="selectSortieVo"/>
         <include refid="selectSortieVo"/>
         where id = #{id}
         where id = #{id}
     </select>
     </select>
-        
+
     <insert id="insertSortie" parameterType="Sortie" useGeneratedKeys="true" keyProperty="id">
     <insert id="insertSortie" parameterType="Sortie" useGeneratedKeys="true" keyProperty="id">
         insert into phm_sortie
         insert into phm_sortie
         <trim prefix="(" suffix=")" suffixOverrides=",">
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -56,7 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createTime != null">create_time,</if>
             <if test="createTime != null">create_time,</if>
             <if test="updateBy != null">update_by,</if>
             <if test="updateBy != null">update_by,</if>
             <if test="updateTime != null">update_time,</if>
             <if test="updateTime != null">update_time,</if>
-         </trim>
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="aircraftNumber != null">#{aircraftNumber},</if>
             <if test="aircraftNumber != null">#{aircraftNumber},</if>
             <if test="sortieNumber != null">#{sortieNumber},</if>
             <if test="sortieNumber != null">#{sortieNumber},</if>
@@ -68,7 +63,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createTime != null">#{createTime},</if>
             <if test="createTime != null">#{createTime},</if>
             <if test="updateBy != null">#{updateBy},</if>
             <if test="updateBy != null">#{updateBy},</if>
             <if test="updateTime != null">#{updateTime},</if>
             <if test="updateTime != null">#{updateTime},</if>
-         </trim>
+        </trim>
     </insert>
     </insert>
 
 
     <update id="updateSortie" parameterType="Sortie">
     <update id="updateSortie" parameterType="Sortie">
@@ -93,7 +88,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
     </delete>
 
 
     <delete id="deleteSortieByIds" parameterType="String">
     <delete id="deleteSortieByIds" parameterType="String">
-        delete from phm_sortie where id in 
+        delete from phm_sortie where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
             #{id}
         </foreach>
         </foreach>