Browse Source

新增控制线

liyg 2 years ago
parent
commit
668a035523

+ 1 - 1
pom.xml

@@ -111,7 +111,7 @@
                     <!--包名-->
                     <targetPackage>com.steerinfo.dil</targetPackage>
                     <tables>
-                        <param>AMSSHIP_DELIVERY_NOTICE</param>
+                        <param>TMSSHIP_CONTROL_LINE</param>
 
                     </tables>
                 </configuration>

+ 21 - 0
src/main/java/com/steerinfo/dil/controller/ShipDynamicsController.java

@@ -1,5 +1,6 @@
 package com.steerinfo.dil.controller;
 
+import com.steerinfo.dil.model.TmsshipControlLine;
 import com.steerinfo.dil.service.impl.ShipDynamicsServiceImpl;
 import com.steerinfo.dil.util.BaseRESTfulController;
 import com.steerinfo.framework.controller.RESTfulResult;
@@ -289,4 +290,24 @@ public class ShipDynamicsController extends BaseRESTfulController {
     public RESTfulResult getWagonWork(@RequestBody(required = false) Map<String, Object> map){
         return success(iShipDynamicsService.getWagonWork(map));
     }
+
+    @PostMapping("/getControlLines")
+    public RESTfulResult getControlLines(@RequestBody(required = false) Map<String, Object> map){
+        return success(iShipDynamicsService.getControlLines(map));
+    }
+
+    @PostMapping("/updateControlLine")
+    public RESTfulResult updateControlLine(@RequestBody(required = false) Map<String, Object> map){
+        TmsshipControlLine result=new TmsshipControlLine();
+        result.setResultId(Short.parseShort(map.get("resultId").toString()));
+        result.setUp(Short.parseShort(map.get("up").toString()));
+        result.setDown(Short.parseShort(map.get("down").toString()));
+        result.setCount(Short.parseShort(result.getUp()+result.getDown()+""));
+        return success(iShipDynamicsService.updateControlLine(result));
+    }
+
+    @PostMapping("/getControlLinesTable")
+    public RESTfulResult getControlLinesTable(@RequestBody(required = false) Map<String, Object> map){
+        return success(iShipDynamicsService.getControlLinesTable(map));
+    }
 }

+ 18 - 0
src/main/java/com/steerinfo/dil/mapper/TmsshipControlLineMapper.java

@@ -0,0 +1,18 @@
+package com.steerinfo.dil.mapper;
+
+import com.steerinfo.dil.model.TmsshipControlLine;
+import com.steerinfo.framework.mapper.IBaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+import java.util.Map;
+
+@Mapper
+public interface TmsshipControlLineMapper extends IBaseMapper<TmsshipControlLine, Short> {
+
+    Short selectMaxId();
+
+
+    List<Map<String,Object>> getControlLines(Map<String,Object> map);
+
+}

+ 92 - 0
src/main/java/com/steerinfo/dil/model/TmsshipControlLine.java

@@ -0,0 +1,92 @@
+package com.steerinfo.dil.model;
+
+import com.steerinfo.framework.model.IBasePO;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.util.Date;
+
+@ApiModel(value="null")
+public class TmsshipControlLine implements IBasePO<Short> {
+    @ApiModelProperty(value="",required=true)
+    private Short resultId;
+
+    @ApiModelProperty(value="",required=false)
+    private Date lineDate;
+
+    @ApiModelProperty(value="",required=false)
+    private Short up;
+
+    @ApiModelProperty(value="",required=false)
+    private Short down;
+
+    @ApiModelProperty(value="",required=false)
+    private Short count;
+
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public Short getId() {
+        return this.resultId;
+    }
+
+    @Override
+    public void setId(Short resultId) {
+        this.resultId = resultId;
+    }
+
+    public Short getResultId() {
+        return resultId;
+    }
+
+    public void setResultId(Short resultId) {
+        this.resultId = resultId;
+    }
+
+    public Date getLineDate() {
+        return lineDate;
+    }
+
+    public void setLineDate(Date lineDate) {
+        this.lineDate = lineDate;
+    }
+
+    public Short getUp() {
+        return up;
+    }
+
+    public void setUp(Short up) {
+        this.up = up;
+    }
+
+    public Short getDown() {
+        return down;
+    }
+
+    public void setDown(Short down) {
+        this.down = down;
+    }
+
+    public Short getCount() {
+        return count;
+    }
+
+    public void setCount(Short count) {
+        this.count = count;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", resultId=").append(resultId);
+        sb.append(", lineDate=").append(lineDate);
+        sb.append(", up=").append(up);
+        sb.append(", down=").append(down);
+        sb.append(", count=").append(count);
+        sb.append(", serialVersionUID=").append(serialVersionUID);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 8 - 0
src/main/java/com/steerinfo/dil/service/IShipDynamicsService.java

@@ -1,5 +1,7 @@
 package com.steerinfo.dil.service;
 
+import com.steerinfo.dil.model.TmsshipControlLine;
+
 import java.util.List;
 import java.util.Map;
 
@@ -17,4 +19,10 @@ public interface IShipDynamicsService {
     List<Map<String, Object>> getDownShipDynamaics(Map<String,Object> map);
 
     List<Map<String, Object>> getWagonWork(Map<String, Object> map);
+
+    List<Map<String,Object>> getControlLines(Map<String, Object> map);
+
+    int updateControlLine(TmsshipControlLine result);
+
+    List<List<Map<String,Object>>> getControlLinesTable(Map<String, Object> map);
 }

+ 102 - 0
src/main/java/com/steerinfo/dil/service/impl/ShipDynamicsServiceImpl.java

@@ -1,6 +1,8 @@
 package com.steerinfo.dil.service.impl;
 
 import com.steerinfo.dil.mapper.ShipDynamicsMapper;
+import com.steerinfo.dil.mapper.TmsshipControlLineMapper;
+import com.steerinfo.dil.model.TmsshipControlLine;
 import com.steerinfo.dil.service.IShipDynamicsService;
 import com.steerinfo.dil.util.DataChange;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -14,6 +16,9 @@ public class ShipDynamicsServiceImpl implements IShipDynamicsService {
     @Autowired
     ShipDynamicsMapper shipDynamicsMapper;
 
+    @Autowired
+    TmsshipControlLineMapper tmsshipControlLineMapper;
+
     private final SimpleDateFormat sdfDateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
     //获取视图里的所有外轮船名,物资名称
     public List<Map<String, Object>> selectAll(Map<String,Object> map) {
@@ -115,4 +120,101 @@ public class ShipDynamicsServiceImpl implements IShipDynamicsService {
         list.add(map3);
         return list;
     }
+
+    @Override
+    public List<Map<String, Object>> getControlLines(Map<String, Object> map) {
+        int year=Integer.parseInt(map.get("year").toString());
+        int month=Integer.parseInt(map.get("month").toString());
+        String time=""+year+"-";
+        if(month<10 && month > 0){
+            time+="0";
+        }
+        time+=month;
+        map.put("time",time);
+        List<Map<String,Object>> list = tmsshipControlLineMapper.getControlLines(map);
+        if(list==null || list.size()<=0) {
+            //查不到年月的数据,新增
+            TmsshipControlLine line = new TmsshipControlLine();
+            line.setUp((short) 0);
+            line.setDown((short) 0);
+            line.setCount((short) 0);
+            for (Date temp : getMonthFullDay(year, month)) {
+                line.setResultId(tmsshipControlLineMapper.selectMaxId());
+                line.setLineDate(temp);
+                tmsshipControlLineMapper.insertSelective(line);
+            }
+            return tmsshipControlLineMapper.getControlLines(map);
+        }
+        return list;
+    }
+
+    @Override
+    public int updateControlLine(TmsshipControlLine result) {
+        return tmsshipControlLineMapper.updateByPrimaryKeySelective(result);
+    }
+
+    @Override
+    public List<List<Map<String, Object>>> getControlLinesTable(Map<String, Object> map) {
+        int year=Integer.parseInt(map.get("year").toString());
+        int month=Integer.parseInt(map.get("month").toString());
+        List<List<Map<String, Object>>> result=new ArrayList<>();
+        map.put("time",previousMonth(year,month,0));//当月
+        List<Map<String,Object>> list1 = tmsshipControlLineMapper.getControlLines(map);
+        map.put("time",previousMonth(year,month,1));//上一个月
+        List<Map<String,Object>> list2 = tmsshipControlLineMapper.getControlLines(map);
+        map.put("time",previousMonth(year,month,2));//上上个月
+        List<Map<String,Object>> list3 = tmsshipControlLineMapper.getControlLines(map);
+        map.put("time",previousMonth(year,month,3));//上上上月
+        List<Map<String,Object>> list4 = tmsshipControlLineMapper.getControlLines(map);
+        result.add(list4);
+        result.add(list3);
+        result.add(list2);
+        result.add(list1);
+        return result;
+    }
+
+    public List<Date> getMonthFullDay(int year, int month) {
+        List<String> fullDayList = new ArrayList<String>();
+        List<Date> fullDateList= new ArrayList<Date>();
+        int day = 1;// 所有月份从1号开始
+        Calendar cal = Calendar.getInstance();// 获得当前日期对象
+        cal.clear();// 清除信息
+        cal.set(Calendar.YEAR, year);
+        cal.set(Calendar.MONTH, month - 1);// 1月从0开始
+        cal.set(Calendar.DAY_OF_MONTH, day);
+        int count = cal.getActualMaximum(Calendar.DAY_OF_MONTH);//获取当前月份最大天数
+        for (int j = 0; j <= (count - 1); ) {
+            if (sdfDateTime.format(cal.getTime()).equals(getLastDay(year, month)))
+                break;
+            cal.add(Calendar.DAY_OF_MONTH, j == 0 ? +0 : +1);
+            j++;
+            fullDayList.add(sdfDateTime.format(cal.getTime()));
+            fullDateList.add(cal.getTime());
+        }
+        //return fullDayList;
+        return fullDateList;
+    }
+
+    public String getLastDay(int year, int month) {
+        Calendar cal = Calendar.getInstance();
+        cal.set(Calendar.YEAR, year);
+        cal.set(Calendar.MONTH, month);
+        cal.set(Calendar.DAY_OF_MONTH, 0);
+        return sdfDateTime.format(cal.getTime());
+    }
+
+    public String previousMonth(int year, int month,int number){
+        if(month-number<=0){
+            year--;
+            month=12+month-number;
+        }else{
+            month-=number;
+        }
+        String time=""+year+"-";
+        if(month<10 && month > 0){
+            time+="0";
+        }
+        time+=month;
+        return time;
+    }
 }

+ 226 - 0
src/main/resources/com/steerinfo/dil/mapper/TmsshipControlLineMapper.xml

@@ -0,0 +1,226 @@
+<?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.steerinfo.dil.mapper.TmsshipControlLineMapper">
+  <resultMap id="BaseResultMap" type="com.steerinfo.dil.model.TmsshipControlLine">
+    <id column="RESULT_ID" jdbcType="DECIMAL" property="resultId" />
+    <result column="LINE_DATE" jdbcType="TIMESTAMP" property="lineDate" />
+    <result column="UP" jdbcType="DECIMAL" property="up" />
+    <result column="DOWN" jdbcType="DECIMAL" property="down" />
+    <result column="COUNT" jdbcType="DECIMAL" property="count" />
+  </resultMap>
+  <sql id="columns">
+    RESULT_ID, LINE_DATE, UP, DOWN, COUNT
+  </sql>
+  <sql id="columns_alias">
+    t.RESULT_ID, t.LINE_DATE, t.UP, t.DOWN, t.COUNT
+  </sql>
+  <sql id="select">
+    SELECT <include refid="columns"/> FROM TMSSHIP_CONTROL_LINE
+  </sql>
+  <sql id="select_alias">
+    SELECT <include refid="columns_alias"/> FROM TMSSHIP_CONTROL_LINE t
+  </sql>
+  <sql id="where">
+    <where>
+      <if test="resultId != null">
+        and RESULT_ID = #{resultId}
+      </if>
+      <if test="lineDate != null">
+        and TO_CHAR(LINE_DATE,'yyyy-MM-dd') = #{lineDate}
+      </if>
+      <if test="up != null">
+        and UP = #{up}
+      </if>
+      <if test="down != null">
+        and DOWN = #{down}
+      </if>
+      <if test="count != null">
+        and COUNT = #{count}
+      </if>
+    </where>
+  </sql>
+  <sql id="whereLike">
+    <where>
+      <if test="resultId != null">
+        and RESULT_ID = #{resultId}
+      </if>
+      <if test="lineDate != null">
+        and TO_CHAR(LINE_DATE,'yyyy-MM-dd') = #{lineDate}
+      </if>
+      <if test="up != null">
+        and UP = #{up}
+      </if>
+      <if test="down != null">
+        and DOWN = #{down}
+      </if>
+      <if test="count != null">
+        and COUNT = #{count}
+      </if>
+    </where>
+  </sql>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Short">
+    delete from TMSSHIP_CONTROL_LINE
+    where RESULT_ID = #{resultId,jdbcType=DECIMAL}
+  </delete>
+  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
+    delete from TMSSHIP_CONTROL_LINE
+    where 1!=1
+    <if test="lineDate != null">
+      or TO_CHAR(LINE_DATE,'yyyy-MM-dd') = '#{lineDate}'
+    </if>
+    <if test="up != null">
+      or UP = #{up}
+    </if>
+    <if test="down != null">
+      or DOWN = #{down}
+    </if>
+    <if test="count != null">
+      or COUNT = #{count}
+    </if>
+  </delete>
+  <insert id="insert" parameterType="com.steerinfo.dil.model.TmsshipControlLine">
+    insert into TMSSHIP_CONTROL_LINE (RESULT_ID, LINE_DATE, UP,
+                                      DOWN, COUNT)
+    values (#{resultId,jdbcType=DECIMAL}, #{lineDate,jdbcType=TIMESTAMP}, #{up,jdbcType=DECIMAL},
+            #{down,jdbcType=DECIMAL}, #{count,jdbcType=DECIMAL})
+  </insert>
+  <insert id="insertSelective" parameterType="com.steerinfo.dil.model.TmsshipControlLine">
+    insert into TMSSHIP_CONTROL_LINE
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="resultId != null">
+        RESULT_ID,
+      </if>
+      <if test="lineDate != null">
+        LINE_DATE,
+      </if>
+      <if test="up != null">
+        UP,
+      </if>
+      <if test="down != null">
+        DOWN,
+      </if>
+      <if test="count != null">
+        COUNT,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="resultId != null">
+        #{resultId,jdbcType=DECIMAL},
+      </if>
+      <if test="lineDate != null">
+        #{lineDate,jdbcType=TIMESTAMP},
+      </if>
+      <if test="up != null">
+        #{up,jdbcType=DECIMAL},
+      </if>
+      <if test="down != null">
+        #{down,jdbcType=DECIMAL},
+      </if>
+      <if test="count != null">
+        #{count,jdbcType=DECIMAL},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKey" parameterType="com.steerinfo.dil.model.TmsshipControlLine">
+    update TMSSHIP_CONTROL_LINE
+    set LINE_DATE = #{lineDate,jdbcType=TIMESTAMP},
+        UP = #{up,jdbcType=DECIMAL},
+        DOWN = #{down,jdbcType=DECIMAL},
+        COUNT = #{count,jdbcType=DECIMAL}
+    where RESULT_ID = #{resultId,jdbcType=DECIMAL}
+  </update>
+  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.dil.model.TmsshipControlLine">
+    update TMSSHIP_CONTROL_LINE
+    <set>
+      <if test="lineDate != null">
+        LINE_DATE = #{lineDate,jdbcType=TIMESTAMP},
+      </if>
+      <if test="up != null">
+        UP = #{up,jdbcType=DECIMAL},
+      </if>
+      <if test="down != null">
+        DOWN = #{down,jdbcType=DECIMAL},
+      </if>
+      <if test="count != null">
+        COUNT = #{count,jdbcType=DECIMAL},
+      </if>
+    </set>
+    where RESULT_ID = #{resultId,jdbcType=DECIMAL}
+  </update>
+  <select id="selectByPrimaryKey" parameterType="java.lang.Short" resultMap="BaseResultMap">
+    <include refid="select"/>
+    where RESULT_ID = #{resultId,jdbcType=DECIMAL}
+  </select>
+  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
+    <include refid="select"/>
+    <include refid="where"/>
+  </select>
+  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
+    <include refid="select"/>
+    <include refid="whereLike"/>
+  </select>
+  <insert id="batchInsert" parameterType="java.util.List">
+    insert into TMSSHIP_CONTROL_LINE
+    (RESULT_ID,
+    LINE_DATE, UP, DOWN,
+    COUNT)
+    ( <foreach collection="list" item="item" separator="union all">
+    select
+    #{item.resultId,jdbcType=DECIMAL},
+    #{item.lineDate,jdbcType=TIMESTAMP}, #{item.up,jdbcType=DECIMAL}, #{item.down,jdbcType=DECIMAL},
+    #{item.count,jdbcType=DECIMAL} from dual
+  </foreach> )
+  </insert>
+  <update id="batchUpdate" parameterType="java.util.List">
+    update TMSSHIP_CONTROL_LINE
+    set
+    RESULT_ID=
+    <foreach collection="list" item="item" index="index" separator=" " open="case RESULT_ID" close="end">
+      when #{item.resultId,jdbcType=DECIMAL} then #{item.resultId,jdbcType=DECIMAL}
+    </foreach>
+    ,LINE_DATE=
+    <foreach collection="list" item="item" index="index" separator=" " open="case RESULT_ID" close="end">
+      when #{item.resultId,jdbcType=DECIMAL} then #{item.lineDate,jdbcType=TIMESTAMP}
+    </foreach>
+    ,UP=
+    <foreach collection="list" item="item" index="index" separator=" " open="case RESULT_ID" close="end">
+      when #{item.resultId,jdbcType=DECIMAL} then #{item.up,jdbcType=DECIMAL}
+    </foreach>
+    ,DOWN=
+    <foreach collection="list" item="item" index="index" separator=" " open="case RESULT_ID" close="end">
+      when #{item.resultId,jdbcType=DECIMAL} then #{item.down,jdbcType=DECIMAL}
+    </foreach>
+    ,COUNT=
+    <foreach collection="list" item="item" index="index" separator=" " open="case RESULT_ID" close="end">
+      when #{item.resultId,jdbcType=DECIMAL} then #{item.count,jdbcType=DECIMAL}
+    </foreach>
+    where RESULT_ID in
+    <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
+      #{item.resultId,jdbcType=DECIMAL}
+    </foreach>
+  </update>
+  <delete id="batchDelete" parameterType="java.util.List">
+    delete from TMSSHIP_CONTROL_LINE
+    where RESULT_ID in
+    <foreach collection="list" item="id" open="(" close=")" separator=",">
+      #{id}
+    </foreach>
+  </delete>
+  <!-- 友情提示!!!-->
+  <!-- 请将自己写的代码放在此标签之下,方便以后粘贴复制。-->
+  <select id="selectMaxId" resultType="java.lang.Short">
+    select SEQ_TMSSHIP_CONTROL.nextval from dual
+  </select>
+
+  <select id="getControlLines" resultType="java.util.Map">
+    select
+      RESULT_ID "resultId",
+      TO_CHAR(LINE_DATE,'MM') || '月' || TO_CHAR(LINE_DATE,'DD') || '日' "lineDate",
+      UP "up",
+      DOWN "down",
+      UP+DOWN "count"
+    from TMSSHIP_CONTROL_LINE
+    where TO_CHAR(LINE_DATE,'YYYY-MM')=#{time}
+    order by LINE_DATE
+  </select>
+</mapper>