Ver Fonte

炼钢计划bug修改。fid不唯一。改为fid+lc_id

zhangym há 10 meses atrás
pai
commit
7557104865

+ 6 - 1
src/main/java/com/steerinfo/ems/emsprodplanroundweight/controller/EmsProdplanRoundWeightController.java

@@ -60,7 +60,7 @@ public class EmsProdplanRoundWeightController extends BaseRESTfulController {
         PageList<EmsProdplanRoundWeight> list = emsProdplanRoundWeightService.queryLikeForPage(parmas, pageNum, pageSize);
         return success(list);
     }
-    
+
     @ApiOperation(value="创建", notes="根据EmsProdplanRoundWeight对象创建")
     @ApiImplicitParam(name = "emsProdplanRoundWeight", value = "详细实体emsProdplanRoundWeight", required = true, dataType = "EmsProdplanRoundWeight")
     //@RequiresPermissions("emsprodplanroundweight:create")
@@ -104,5 +104,10 @@ public class EmsProdplanRoundWeightController extends BaseRESTfulController {
     	}
       return success();
     }
+    @GetMapping("/restartData")
+    public RESTfulResult aaa() throws ParseException {
+        emsProdplanRoundWeightService.getWeightForLg半年();
+        return success();
+    }
 
 }

+ 15 - 12
src/main/java/com/steerinfo/ems/emsprodplanroundweight/mapper/EmsProdplanRoundWeightMapper.xml

@@ -23,7 +23,7 @@
     SELECT <include refid="columns_alias"/> FROM EMS_PRODPLAN_ROUND_WEIGHT t
   </sql>
   <sql id="where">
-    <where> 
+    <where>
       <if test="fid != null and fid != ''">
         and FID = #{fid}
       </if>
@@ -48,7 +48,7 @@
     </where>
   </sql>
   <sql id="whereLike">
-    <where> 
+    <where>
       <if test="fid != null and fid != ''">
         and FID LIKE '%${fid}%'
       </if>
@@ -78,7 +78,7 @@
   </delete>
   <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
     delete from EMS_PRODPLAN_ROUND_WEIGHT
-    where 1!=1 
+    where 1!=1
       <if test="prodate != null and prodate != ''">
         or PRODATE = #{prodate}
       </if>
@@ -190,6 +190,9 @@
       </if>
     </set>
     where FID = #{fid,jdbcType=VARCHAR}
+    <if test="lcId != null">
+      and LC_ID = #{lcId,jdbcType=VARCHAR}
+    </if>
   </update>
   <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
     <include refid="select"/>
@@ -204,17 +207,17 @@
     <include refid="whereLike"/>
   </select>
   <insert id="batchInsert" parameterType="java.util.List">
-    insert into EMS_PRODPLAN_ROUND_WEIGHT 
-      (FID, 
-      PRODATE, MATERIALCODE, MATERIALNAME, 
+    insert into EMS_PRODPLAN_ROUND_WEIGHT
+      (FID,
+      PRODATE, MATERIALCODE, MATERIALNAME,
       QTY, UNIT, LC_ID
       )
-    ( <foreach collection="list" item="item" separator="union all"> 
-   select  
-      #{item.fid,jdbcType=VARCHAR}, 
-      #{item.prodate,jdbcType=VARCHAR}, #{item.materialcode,jdbcType=VARCHAR}, #{item.materialname,jdbcType=VARCHAR}, 
+    ( <foreach collection="list" item="item" separator="union all">
+   select
+      #{item.fid,jdbcType=VARCHAR},
+      #{item.prodate,jdbcType=VARCHAR}, #{item.materialcode,jdbcType=VARCHAR}, #{item.materialname,jdbcType=VARCHAR},
       #{item.qty,jdbcType=DECIMAL}, #{item.unit,jdbcType=VARCHAR}, #{item.lcId,jdbcType=VARCHAR}
-       from dual  
+       from dual
    </foreach> )
   </insert>
   <update id="batchUpdate" parameterType="java.util.List">
@@ -248,7 +251,7 @@
        <foreach collection="list" item="item" index="index" separator=" " open="case FID" close="end">
           when #{item.fid,jdbcType=VARCHAR} then #{item.lcId,jdbcType=VARCHAR}
        </foreach>
-     where FID in 
+     where FID in
      <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
     #{item.fid,jdbcType=VARCHAR}
      </foreach>

+ 2 - 1
src/main/java/com/steerinfo/ems/emsprodplanroundweight/service/IEmsProdplanRoundWeightService.java

@@ -20,6 +20,7 @@ import java.text.ParseException;
  */
 public interface IEmsProdplanRoundWeightService extends IBaseService<EmsProdplanRoundWeight, String>{
     public void getWeightForLg() throws ParseException;
+    public void getWeightForLg半年() throws ParseException;
     public void getWeightForGx() throws ParseException;
 
-}
+}

+ 51 - 10
src/main/java/com/steerinfo/ems/emsprodplanroundweight/service/impl/EmsProdplanRoundWeightServiceImpl.java

@@ -15,10 +15,7 @@ import org.springframework.stereotype.Service;
 
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 
 /**
  * EmsProdplanRoundWeight服务实现:
@@ -66,13 +63,21 @@ public class EmsProdplanRoundWeightServiceImpl extends BaseServiceImpl<EmsProdpl
             model.setMaterialname(item.getMaterialname());
             model.setProdate(item.getProdate());
             model.setUnit(item.getUnit());
-            EmsProdplanRoundWeight emsProdplanRoundWeight = emsProdplanRoundWeightMapper.selectByPrimaryKey(model.getFid());
-            if(emsProdplanRoundWeight !=  null){
-                emsProdplanRoundWeightMapper.updateByPrimaryKeySelective(emsProdplanRoundWeight);
-            }
-            else {
-                emsProdplanRoundWeightMapper.insert(model);
+            //fid有重复
+//            EmsProdplanRoundWeight emsProdplanRoundWeight = emsProdplanRoundWeightMapper.selectByPrimaryKey(model.getFid());
+            Map<String,Object> map =  new HashMap();
+            map.put("fid",model.getFid());
+            map.put("lcId",model.getLcId());
+            List<EmsProdplanRoundWeight> emsProdplanRoundWeights = emsProdplanRoundWeightMapper.selectByParameters(map);
+            for(EmsProdplanRoundWeight emsProdplanRoundWeight:emsProdplanRoundWeights){
+                if(emsProdplanRoundWeight !=  null){
+                    emsProdplanRoundWeightMapper.updateByPrimaryKeySelective(emsProdplanRoundWeight);
+                }
+                else {
+                    emsProdplanRoundWeightMapper.insert(model);
+                }
             }
+
         });
 
     }
@@ -106,5 +111,41 @@ public class EmsProdplanRoundWeightServiceImpl extends BaseServiceImpl<EmsProdpl
             }
         });
     }
+    //获取炼钢计划的重量
+    public void getWeightForLg半年() throws ParseException {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        Date dt = sdf.parse(DateUtils.dateStr(new Date(), "yyyy-MM-dd"));
+        Calendar rightNow = Calendar.getInstance();
+        rightNow.setTime(dt);
+        rightNow.add(Calendar.DAY_OF_MONTH, -150);
+        Date dt1 = rightNow.getTime();
+        String reStr = sdf.format(dt1);
+        List<LgWeight> lgWeights = lgWeightFeigenService.QueryWeightforRound(reStr, DateUtils.dateStr(new Date(), "yyyy-MM-dd"));
+        lgWeights.forEach(item -> {
+            EmsProdplanRoundWeight model = new EmsProdplanRoundWeight();
+            model.setFid(item.getFid());
+            model.setLcId(item.getRoundid());
+            model.setQty(item.getWeight());
+            model.setMaterialcode(item.getMaterialcode());
+            model.setMaterialname(item.getMaterialname());
+            model.setProdate(item.getProdate());
+            model.setUnit(item.getUnit());
+            //fid有重复
+//            EmsProdplanRoundWeight emsProdplanRoundWeight = emsProdplanRoundWeightMapper.selectByPrimaryKey(model.getFid());
+            Map<String,Object> map =  new HashMap();
+            map.put("fid",model.getFid());
+            map.put("lcId",model.getLcId());
+            List<EmsProdplanRoundWeight> emsProdplanRoundWeights = emsProdplanRoundWeightMapper.selectByParameters(map);
+            for(EmsProdplanRoundWeight emsProdplanRoundWeight:emsProdplanRoundWeights){
+                if(emsProdplanRoundWeight !=  null){
+                    emsProdplanRoundWeightMapper.updateByPrimaryKeySelective(emsProdplanRoundWeight);
+                }
+                else {
+                    emsProdplanRoundWeightMapper.insert(model);
+                }
+            }
 
+        });
+
+    }
 }