Browse Source

修改订单项目修改时,处理子项数据

anderx 3 years ago
parent
commit
39384b8a21

+ 31 - 26
src/main/java/com/goafanti/common/mapper/TChangeTaskMapper.xml

@@ -25,12 +25,13 @@
     <result column="contract_term" jdbcType="VARCHAR" property="contractTerm" />
     <result column="declaration_batch" jdbcType="INTEGER" property="declarationBatch" />
     <result column="patent_type" jdbcType="INTEGER" property="patentType" />
+    <result column="change_split_super" jdbcType="INTEGER" property="changeSplitSuper" />
   </resultMap>
   <sql id="Base_Column_List">
     id, tid, cid, order_no, main, commodity_id, commodity_name, commodity_quantity, commodity_price,
     task_comment, `type`, create_time, split_status, split_super, receiver_name, official_cost,
     cost_reduction, service_life, service_year, year_sum, contract_term, declaration_batch,
-    patent_type
+    patent_type, change_split_super
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
     select
@@ -42,30 +43,27 @@
     delete from t_change_task
     where id = #{id,jdbcType=INTEGER}
   </delete>
-  <insert id="insert" parameterType="com.goafanti.common.model.TChangeTask">
-    insert into t_change_task (id, tid, cid,
-      order_no, main, commodity_id,
-      commodity_name, commodity_quantity, commodity_price,
-      task_comment, `type`, create_time,
-      split_status, split_super, receiver_name,
-      official_cost, cost_reduction, service_life,
-      service_year, year_sum, contract_term,
-      declaration_batch, patent_type)
-    values (#{id,jdbcType=INTEGER}, #{tid,jdbcType=INTEGER}, #{cid,jdbcType=INTEGER},
-      #{orderNo,jdbcType=VARCHAR}, #{main,jdbcType=INTEGER}, #{commodityId,jdbcType=VARCHAR},
-      #{commodityName,jdbcType=VARCHAR}, #{commodityQuantity,jdbcType=INTEGER}, #{commodityPrice,jdbcType=DECIMAL},
-      #{taskComment,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
-      #{splitStatus,jdbcType=INTEGER}, #{splitSuper,jdbcType=INTEGER}, #{receiverName,jdbcType=VARCHAR},
-      #{officialCost,jdbcType=INTEGER}, #{costReduction,jdbcType=INTEGER}, #{serviceLife,jdbcType=VARCHAR},
-      #{serviceYear,jdbcType=VARCHAR}, #{yearSum,jdbcType=INTEGER}, #{contractTerm,jdbcType=VARCHAR},
-      #{declarationBatch,jdbcType=INTEGER}, #{patentType,jdbcType=INTEGER})
+  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.TChangeTask" useGeneratedKeys="true">
+    insert into t_change_task (tid, cid, order_no,
+      main, commodity_id, commodity_name,
+      commodity_quantity, commodity_price, task_comment,
+      `type`, create_time, split_status,
+      split_super, receiver_name, official_cost,
+      cost_reduction, service_life, service_year,
+      year_sum, contract_term, declaration_batch,
+      patent_type, change_split_super)
+    values (#{tid,jdbcType=INTEGER}, #{cid,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR},
+      #{main,jdbcType=INTEGER}, #{commodityId,jdbcType=VARCHAR}, #{commodityName,jdbcType=VARCHAR},
+      #{commodityQuantity,jdbcType=INTEGER}, #{commodityPrice,jdbcType=DECIMAL}, #{taskComment,jdbcType=VARCHAR},
+      #{type,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{splitStatus,jdbcType=INTEGER},
+      #{splitSuper,jdbcType=INTEGER}, #{receiverName,jdbcType=VARCHAR}, #{officialCost,jdbcType=INTEGER},
+      #{costReduction,jdbcType=INTEGER}, #{serviceLife,jdbcType=VARCHAR}, #{serviceYear,jdbcType=VARCHAR},
+      #{yearSum,jdbcType=INTEGER}, #{contractTerm,jdbcType=VARCHAR}, #{declarationBatch,jdbcType=INTEGER},
+      #{patentType,jdbcType=INTEGER}, #{changeSplitSuper,jdbcType=INTEGER})
   </insert>
-  <insert id="insertSelective" parameterType="com.goafanti.common.model.TChangeTask">
+  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.TChangeTask" useGeneratedKeys="true">
     insert into t_change_task
     <trim prefix="(" suffix=")" suffixOverrides=",">
-      <if test="id != null">
-        id,
-      </if>
       <if test="tid != null">
         tid,
       </if>
@@ -132,11 +130,11 @@
       <if test="patentType != null">
         patent_type,
       </if>
+      <if test="changeSplitSuper != null">
+        change_split_super,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
-      <if test="id != null">
-        #{id,jdbcType=INTEGER},
-      </if>
       <if test="tid != null">
         #{tid,jdbcType=INTEGER},
       </if>
@@ -203,6 +201,9 @@
       <if test="patentType != null">
         #{patentType,jdbcType=INTEGER},
       </if>
+      <if test="changeSplitSuper != null">
+        #{changeSplitSuper,jdbcType=INTEGER},
+      </if>
     </trim>
   </insert>
   <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.TChangeTask">
@@ -274,6 +275,9 @@
       <if test="patentType != null">
         patent_type = #{patentType,jdbcType=INTEGER},
       </if>
+      <if test="changeSplitSuper != null">
+        change_split_super = #{changeSplitSuper,jdbcType=INTEGER},
+      </if>
     </set>
     where id = #{id,jdbcType=INTEGER}
   </update>
@@ -300,7 +304,8 @@
       year_sum = #{yearSum,jdbcType=INTEGER},
       contract_term = #{contractTerm,jdbcType=VARCHAR},
       declaration_batch = #{declarationBatch,jdbcType=INTEGER},
-      patent_type = #{patentType,jdbcType=INTEGER}
+      patent_type = #{patentType,jdbcType=INTEGER},
+      change_split_super = #{changeSplitSuper,jdbcType=INTEGER}
     where id = #{id,jdbcType=INTEGER}
   </update>
 

+ 13 - 0
src/main/java/com/goafanti/common/model/TChangeTask.java

@@ -124,6 +124,11 @@ public class TChangeTask implements Serializable {
      */
     private Integer patentType;
 
+    /**
+     * 变更拆分父id
+     */
+    private Integer changeSplitSuper;
+
     private static final long serialVersionUID = 1L;
 
     public Integer getId() {
@@ -309,4 +314,12 @@ public class TChangeTask implements Serializable {
     public void setPatentType(Integer patentType) {
         this.patentType = patentType;
     }
+
+    public Integer getChangeSplitSuper() {
+        return changeSplitSuper;
+    }
+
+    public void setChangeSplitSuper(Integer changeSplitSuper) {
+        this.changeSplitSuper = changeSplitSuper;
+    }
 }

+ 1 - 1
src/main/java/com/goafanti/order/controller/OrderChangeApiController.java

@@ -530,7 +530,7 @@ public class OrderChangeApiController extends CertifyApiController {
 	@RequestMapping(value = "/addMemberSonProject" ,method = RequestMethod.POST)
 	public Result addMemberSonProject(Integer id,String serviceYear,String taskComment){
 		Result res = new Result();
-		if(id==null||StringUtils.isBlank(serviceYear)||StringUtils.isBlank(taskComment)){
+		if(id==null||StringUtils.isBlank(serviceYear)){
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","参数"));
 			return res;
 		}

+ 1 - 1
src/main/java/com/goafanti/order/service/OrderChangeService.java

@@ -71,7 +71,7 @@ public interface OrderChangeService {
 
 
 
-	int addChangeTask(TChangeTask t);
+	Object addChangeTask(TChangeTask t);
 
 	int addChangeDun(TChangeDun d);
 

+ 9 - 9
src/main/java/com/goafanti/order/service/impl/OrderChangeServiceImpl.java

@@ -8,10 +8,8 @@ import java.util.*;
 
 import javax.servlet.http.HttpServletResponse;
 
-import com.alibaba.fastjson.JSON;
 import com.goafanti.admin.service.DepartmentService;
 import com.goafanti.common.dao.*;
-import com.goafanti.common.enums.UserFields;
 import com.goafanti.common.model.*;
 import org.apache.poi.xssf.usermodel.XSSFCell;
 import org.apache.poi.xssf.usermodel.XSSFRow;
@@ -972,9 +970,10 @@ public class OrderChangeServiceImpl extends BaseMybatisDao<NewOrderChangeMapper>
 
 
 			@Override
-			public int addChangeTask(TChangeTask t) {
+			public Object addChangeTask(TChangeTask t) {
 				t.setType(1);
-				return tChangeTaskMapper.insertSelective(t);
+				tChangeTaskMapper.insertSelective(t);
+				return t;
 			}
 
 			@Override
@@ -999,8 +998,10 @@ public class OrderChangeServiceImpl extends BaseMybatisDao<NewOrderChangeMapper>
 			public List<TChangeTaskOut> selectChangeTask(Integer cid) {
 				List<TChangeTaskOut> list=tChangeTaskMapper.selectByCid(cid,3);//3设置不等于2
 				for (TChangeTaskOut tChangeTaskOut : list) {
-					List<TChangeTask> list2=tChangeTaskMapper.selectBySuper(tChangeTaskOut.getTid(),cid);
-					tChangeTaskOut.setList(list2);
+					if(tChangeTaskOut.getSplitStatus()==1){
+						List<TChangeTask> list2=tChangeTaskMapper.selectBySuper(tChangeTaskOut.getTid(),cid);
+						tChangeTaskOut.setList(list2);
+					}
 				}
 				return list;
 			}
@@ -1190,13 +1191,12 @@ public class OrderChangeServiceImpl extends BaseMybatisDao<NewOrderChangeMapper>
 
 	@Override
 	public Object addMemberSonProject(Integer id, String serviceYear, String taskComment) {
-		Date date =new Date();
 		TChangeTask tChangeTask = tChangeTaskMapper.selectByPrimaryKey(id);
 		tChangeTask.setSplitStatus(1);
 		tChangeTaskMapper.updateByPrimaryKey(tChangeTask);
 		tChangeTask.setId(null);
-		tChangeTask.setSplitStatus(2);
-		tChangeTask.setSplitSuper(id);
+		tChangeTask.setChangeSplitSuper(id);
+		tChangeTask.setSplitSuper(tChangeTask.getId());
 		tChangeTask.setCommodityQuantity(1);
 		tChangeTask.setTaskComment(taskComment);
 		tChangeTask.setServiceLife(serviceYear);