duyong 4 роки тому
батько
коміт
273e23229d

+ 27 - 4
src/main/java/com/steerinfo/baseinfo/meterbasematterinfodirect/controller/MeterBaseMatterInfoDirectController.java

@@ -1,11 +1,14 @@
 package com.steerinfo.baseinfo.meterbasematterinfodirect.controller;
 
+import com.steerinfo.baseinfo.meterbaseunitdirect.model.MeterBaseUnitDirect;
 import com.steerinfo.framework.controller.BaseRESTfulController;
 import com.steerinfo.framework.controller.RESTfulResult;
 import com.steerinfo.framework.service.pagehelper.PageList;
+import com.steerinfo.framework.user.UserPayload;
 import com.steerinfo.framework.utils.collection.ListUtils;
 import com.steerinfo.baseinfo.meterbasematterinfodirect.model.MeterBaseMatterInfoDirect;
 import com.steerinfo.baseinfo.meterbasematterinfodirect.service.IMeterBaseMatterInfoDirectService;
+import com.steerinfo.meterwork.except.MarkerMetException;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -17,10 +20,7 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.ArrayList;
+import java.util.*;
 import java.math.BigDecimal;
 
 /**
@@ -128,4 +128,27 @@ public class MeterBaseMatterInfoDirectController extends BaseRESTfulController {
     	}
       return success();
     }
+    @ApiOperation(value = "批量删除", notes = "根据MeterBaseUnitDirect对象批量删除")
+    @ApiImplicitParam(paramType = "path",  required = true, dataType = "List<MeterBaseUnitDirect>")
+    @Transactional
+    @PutMapping(value = "/batchdelete")//String
+    public RESTfulResult batchsdelete(@RequestBody List<MeterBaseMatterInfoDirect> models) {
+        try {
+            UserPayload payload = UserPayload.getCurrUser();
+            String userId = payload.getId();
+            String userName = payload.getUserName();
+            for (MeterBaseMatterInfoDirect model : models){
+                model.setDeleteManNo(userId);
+                model.setDeleteManName(userName);
+                model.setDeleteTime(new Date());
+                model.setValidFlag("0");
+            }
+            meterBaseMatterInfoDirectService.batchUpdate(models);
+            return success();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+            throw new MarkerMetException(500, "操作异常!!");
+        }
+    }
 }

+ 30 - 4
src/main/java/com/steerinfo/baseinfo/meterbaseunitdirect/controller/MeterBaseUnitDirectController.java

@@ -1,11 +1,14 @@
 package com.steerinfo.baseinfo.meterbaseunitdirect.controller;
 
+import com.steerinfo.baseinfo.meterbasetimespace.model.MeterBaseTimeSpace;
 import com.steerinfo.framework.controller.BaseRESTfulController;
 import com.steerinfo.framework.controller.RESTfulResult;
 import com.steerinfo.framework.service.pagehelper.PageList;
+import com.steerinfo.framework.user.UserPayload;
 import com.steerinfo.framework.utils.collection.ListUtils;
 import com.steerinfo.baseinfo.meterbaseunitdirect.model.MeterBaseUnitDirect;
 import com.steerinfo.baseinfo.meterbaseunitdirect.service.IMeterBaseUnitDirectService;
+import com.steerinfo.meterwork.except.MarkerMetException;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -13,12 +16,11 @@ import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.ArrayList;
+import java.util.*;
 import java.math.BigDecimal;
 
 /**
@@ -124,4 +126,28 @@ public class MeterBaseUnitDirectController extends BaseRESTfulController {
     	}
       return success();
     }
+
+    @ApiOperation(value = "批量删除", notes = "根据MeterBaseUnitDirect对象批量删除")
+    @ApiImplicitParam(paramType = "path",  required = true, dataType = "List<MeterBaseUnitDirect>")
+    @Transactional
+    @PutMapping(value = "/batchdelete")//String
+    public RESTfulResult batchsdelete(@RequestBody List<MeterBaseUnitDirect> models) {
+        try {
+            UserPayload payload = UserPayload.getCurrUser();
+            String userId = payload.getId();
+            String userName = payload.getUserName();
+            for (MeterBaseUnitDirect model : models){
+                model.setDeleteManNo(userId);
+                model.setDeleteManName(userName);
+                model.setDeleteTime(new Date());
+                model.setValidFlag("0");
+            }
+            meterBaseUnitDirectService.batchUpdate(models);
+            return success();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+            throw new MarkerMetException(500, "操作异常!!");
+        }
+    }
 }

+ 2 - 0
src/main/java/com/steerinfo/baseinfo/meterbaseunitdirect/mapper/MeterBaseUnitDirectMapper.java

@@ -14,4 +14,6 @@ public interface MeterBaseUnitDirectMapper extends IBaseMapper<MeterBaseUnitDire
     String GetNewID();
 
     List<MeterBaseUnitDirect> selectForUpdate(Map<String, Object> parameters);
+
+    void deleteBatches(Map<String, Object> parameters);
 }

+ 38 - 10
src/main/java/com/steerinfo/baseinfo/meterbaseunitdirect/mapper/MeterBaseUnitDirectMapper.xml

@@ -16,16 +16,17 @@
     <result column="DELETE_MAN_NAME" jdbcType="VARCHAR" property="deleteManName" />
     <result column="DELETE_TIME" jdbcType="TIMESTAMP" property="deleteTime" />
     <result column="UNIT_TYPE" jdbcType="VARCHAR" property="unitType" />
+    <result column="MEMO" jdbcType="VARCHAR" property="memo" />
   </resultMap>
   <sql id="columns">
     CARRIER_UNIT_NO, CARRIER_UNIT_NAME, MNEMONIC_CODE, VALID_FLAG, CREATE_MAN_NO, CREATE_MAN_NAME, 
     CREATE_TIME, UPDATE_MAN_NO, UPDATE_MAN_NAME, UPDATE_TIME, DELETE_MAN_NO, DELETE_MAN_NAME, 
-    DELETE_TIME, UNIT_TYPE
+    DELETE_TIME, UNIT_TYPE, MEMO
   </sql>
   <sql id="columns_alias">
     t.CARRIER_UNIT_NO, t.CARRIER_UNIT_NAME, t.MNEMONIC_CODE, t.VALID_FLAG, t.CREATE_MAN_NO, 
     t.CREATE_MAN_NAME, t.CREATE_TIME, t.UPDATE_MAN_NO, t.UPDATE_MAN_NAME, t.UPDATE_TIME, 
-    t.DELETE_MAN_NO, t.DELETE_MAN_NAME, t.DELETE_TIME, t.UNIT_TYPE
+    t.DELETE_MAN_NO, t.DELETE_MAN_NAME, t.DELETE_TIME, t.UNIT_TYPE, t.MEMO
   </sql>
   <sql id="select">
     SELECT <include refid="columns"/> FROM METER_BASE_UNIT_DIRECT
@@ -77,6 +78,9 @@
       <if test="unitType != null and unitType != ''">
         and UNIT_TYPE = #{unitType}
       </if>
+      <if test="memo != null and memo != ''">
+        and MEMO = #{memo}
+      </if>
     </where>
   </sql>
   <sql id="whereLike">
@@ -123,6 +127,9 @@
       <if test="unitType != null and unitType != ''">
         and UNIT_TYPE LIKE '%${unitType}%'
       </if>
+      <if test="memo != null and memo != ''">
+        and MEMO LIKE '%${memo}%'
+      </if>
     </where>
   </sql>
   <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
@@ -171,18 +178,23 @@
       <if test="unitType != null and unitType != ''">
         or UNIT_TYPE = #{unitType}
       </if>
+      <if test="memo != null and memo != ''">
+        or MEMO = #{memo}
+      </if>
   </delete>
   <insert id="insert" parameterType="com.steerinfo.baseinfo.meterbaseunitdirect.model.MeterBaseUnitDirect">
     insert into METER_BASE_UNIT_DIRECT (CARRIER_UNIT_NO, CARRIER_UNIT_NAME, MNEMONIC_CODE, 
       VALID_FLAG, CREATE_MAN_NO, CREATE_MAN_NAME, 
       CREATE_TIME, UPDATE_MAN_NO, UPDATE_MAN_NAME, 
       UPDATE_TIME, DELETE_MAN_NO, DELETE_MAN_NAME, 
-      DELETE_TIME, UNIT_TYPE)
+      DELETE_TIME, UNIT_TYPE, MEMO
+      )
     values (#{carrierUnitNo,jdbcType=VARCHAR}, #{carrierUnitName,jdbcType=VARCHAR}, #{mnemonicCode,jdbcType=VARCHAR}, 
       #{validFlag,jdbcType=VARCHAR}, #{createManNo,jdbcType=VARCHAR}, #{createManName,jdbcType=VARCHAR}, 
       #{createTime,jdbcType=TIMESTAMP}, #{updateManNo,jdbcType=VARCHAR}, #{updateManName,jdbcType=VARCHAR}, 
       #{updateTime,jdbcType=TIMESTAMP}, #{deleteManNo,jdbcType=VARCHAR}, #{deleteManName,jdbcType=VARCHAR}, 
-      #{deleteTime,jdbcType=TIMESTAMP}, #{unitType,jdbcType=VARCHAR})
+      #{deleteTime,jdbcType=TIMESTAMP}, #{unitType,jdbcType=VARCHAR}, #{memo,jdbcType=VARCHAR}
+      )
   </insert>
   <insert id="insertSelective" parameterType="com.steerinfo.baseinfo.meterbaseunitdirect.model.MeterBaseUnitDirect">
     insert into METER_BASE_UNIT_DIRECT
@@ -229,6 +241,9 @@
       <if test="unitType != null">
         UNIT_TYPE,
       </if>
+      <if test="memo != null">
+        MEMO,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="carrierUnitNo != null">
@@ -273,6 +288,9 @@
       <if test="unitType != null">
         #{unitType,jdbcType=VARCHAR},
       </if>
+      <if test="memo != null">
+        #{memo,jdbcType=VARCHAR},
+      </if>
     </trim>
   </insert>
   <update id="updateByPrimaryKey" parameterType="com.steerinfo.baseinfo.meterbaseunitdirect.model.MeterBaseUnitDirect">
@@ -289,7 +307,8 @@
       DELETE_MAN_NO = #{deleteManNo,jdbcType=VARCHAR},
       DELETE_MAN_NAME = #{deleteManName,jdbcType=VARCHAR},
       DELETE_TIME = #{deleteTime,jdbcType=TIMESTAMP},
-      UNIT_TYPE = #{unitType,jdbcType=VARCHAR}
+      UNIT_TYPE = #{unitType,jdbcType=VARCHAR},
+      MEMO = #{memo,jdbcType=VARCHAR}
     where CARRIER_UNIT_NO = #{carrierUnitNo,jdbcType=VARCHAR}
   </update>
   <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.baseinfo.meterbaseunitdirect.model.MeterBaseUnitDirect">
@@ -334,6 +353,9 @@
       <if test="unitType != null">
         UNIT_TYPE = #{unitType,jdbcType=VARCHAR},
       </if>
+      <if test="memo != null">
+        MEMO = #{memo,jdbcType=VARCHAR},
+      </if>
     </set>
     where CARRIER_UNIT_NO = #{carrierUnitNo,jdbcType=VARCHAR}
   </update>
@@ -356,7 +378,8 @@
       VALID_FLAG, CREATE_MAN_NO, CREATE_MAN_NAME, 
       CREATE_TIME, UPDATE_MAN_NO, UPDATE_MAN_NAME, 
       UPDATE_TIME, DELETE_MAN_NO, DELETE_MAN_NAME, 
-      DELETE_TIME, UNIT_TYPE)
+      DELETE_TIME, UNIT_TYPE, MEMO
+      )
     ( <foreach collection="list" item="item" separator="union all"> 
    select  
       #{item.carrierUnitNo,jdbcType=VARCHAR}, 
@@ -364,7 +387,8 @@
       #{item.validFlag,jdbcType=VARCHAR}, #{item.createManNo,jdbcType=VARCHAR}, #{item.createManName,jdbcType=VARCHAR}, 
       #{item.createTime,jdbcType=TIMESTAMP}, #{item.updateManNo,jdbcType=VARCHAR}, #{item.updateManName,jdbcType=VARCHAR}, 
       #{item.updateTime,jdbcType=TIMESTAMP}, #{item.deleteManNo,jdbcType=VARCHAR}, #{item.deleteManName,jdbcType=VARCHAR}, 
-      #{item.deleteTime,jdbcType=TIMESTAMP}, #{item.unitType,jdbcType=VARCHAR} from dual  
+      #{item.deleteTime,jdbcType=TIMESTAMP}, #{item.unitType,jdbcType=VARCHAR}, #{item.memo,jdbcType=VARCHAR}
+       from dual  
    </foreach> )
   </insert>
   <update id="batchUpdate" parameterType="java.util.List">
@@ -426,6 +450,10 @@
        <foreach collection="list" item="item" index="index" separator=" " open="case CARRIER_UNIT_NO" close="end">
           when #{item.carrierUnitNo,jdbcType=VARCHAR} then #{item.unitType,jdbcType=VARCHAR}
        </foreach>
+       ,MEMO=
+       <foreach collection="list" item="item" index="index" separator=" " open="case CARRIER_UNIT_NO" close="end">
+          when #{item.carrierUnitNo,jdbcType=VARCHAR} then #{item.memo,jdbcType=VARCHAR}
+       </foreach>
      where CARRIER_UNIT_NO in 
      <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
     #{item.carrierUnitNo,jdbcType=VARCHAR}
@@ -441,8 +469,8 @@
   <!-- 友情提示!!!-->
   <!-- 请将自己写的代码放在此标签之下,方便以后粘贴复制。-->
   <select id="GetNewID" parameterType="java.lang.String" resultType="java.lang.String">
-  SELECT LPAD(NVL(MAX(TO_NUMBER(SUBSTR(CARRIER_UNIT_NO, LENGTH(CARRIER_UNIT_NO) -3))),0) + 1,4,'0') CARRIER_UNIT_NO
-  FROM METER_BASE_UNIT_DIRECT where instr(CARRIER_UNIT_NO, to_char(sysdate, 'yyyyMMdd')) > 0
+    SELECT LPAD(NVL(MAX(TO_NUMBER(SUBSTR(CARRIER_UNIT_NO, LENGTH(CARRIER_UNIT_NO) - 4))),0) + 1,5,'0') CARRIER_UNIT_NO
+    FROM METER_BASE_UNIT_DIRECT
   </select>
 
   <select id="selectForUpdate" parameterType="java.util.HashMap" resultMap="BaseResultMap">
@@ -452,7 +480,7 @@
         and CARRIER_UNIT_NO != #{carrierUnitNo}
       </if>
       <if test="carrierUnitName != null and carrierUnitName != ''">
-        and CARRIER_UNIT_NAME = #{carrierUnitName}
+        and CARRIER_UNIT_NAME = #{matterName}
       </if>
     </where>
   </select>

+ 15 - 0
src/main/java/com/steerinfo/baseinfo/meterbaseunitdirect/model/MeterBaseUnitDirect.java

@@ -91,6 +91,12 @@ public class MeterBaseUnitDirect implements IBasePO<String> {
     @ApiModelProperty(value="单位类型(1.发货单位,2.收货单位维护,3.录入单位)",required=true)
     private String unitType;
 
+    /**
+     * 备注(MEMO,VARCHAR,200)
+     */
+    @ApiModelProperty(value="备注",required=false)
+    private String memo;
+
     private static final long serialVersionUID = 1L;
 
     @Override
@@ -215,6 +221,14 @@ public class MeterBaseUnitDirect implements IBasePO<String> {
         this.unitType = unitType == null ? null : unitType.trim();
     }
 
+    public String getMemo() {
+        return memo;
+    }
+
+    public void setMemo(String memo) {
+        this.memo = memo == null ? null : memo.trim();
+    }
+
     @Override
     public String toString() {
         StringBuilder sb = new StringBuilder();
@@ -235,6 +249,7 @@ public class MeterBaseUnitDirect implements IBasePO<String> {
         sb.append(", deleteManName=").append(deleteManName);
         sb.append(", deleteTime=").append(deleteTime);
         sb.append(", unitType=").append(unitType);
+        sb.append(", memo=").append(memo);
         sb.append(", serialVersionUID=").append(serialVersionUID);
         sb.append("]");
         return sb.toString();