Browse Source

获取单行SN

koul 2 months ago
parent
commit
990350c850

+ 11 - 0
src/main/java/com/uas/eis/controller/MESHelperController.java

@@ -209,4 +209,15 @@ public class MESHelperController {
     public Map<Object,Object> GetMESSnCode(HttpServletRequest request,  @RequestBody String json){
         return mesHelperService.getMESSnCode(json);
     }
+
+    /**
+     * 获取MES生成的SN条码
+     * @param request
+     * @param json
+     * @return
+     */
+    @RequestMapping(value="/getMakeSnCode")
+    public Map<Object,Object> getMakeSnCode(HttpServletRequest request,  @RequestBody String json){
+        return mesHelperService.getMakeSnCode(json);
+    }
 }

+ 2 - 0
src/main/java/com/uas/eis/service/MESHelperService.java

@@ -33,4 +33,6 @@ public interface MESHelperService {
 
 	Map<Object, Object> getMESSnCode(String data);
 
+	Map<Object, Object> getMakeSnCode(String data);
+
 }

+ 76 - 0
src/main/java/com/uas/eis/serviceImpl/MESHelperServiceImpl.java

@@ -1799,4 +1799,80 @@ public class MESHelperServiceImpl implements MESHelperService {
 		return rmap;
 	}
 
+	@Override
+	public Map<Object, Object> getMakeSnCode(String data) {
+		Map<String, Object> map=null;
+		Map<Object, Object> rmap = new HashMap<Object, Object>();
+		try{
+			map =BaseUtil.convertJsonToMap(data);
+		}catch (Exception e){
+			rmap.put("code",-1);
+			rmap.put("message",e.getMessage());
+			System.out.printf(e.getMessage()) ;
+			return rmap;
+		}
+		String macode = map.get("moid") == null ? "" : String.valueOf(map.get("moid"));
+		if("".equals(macode)){
+			rmap.put("code",-1);
+			rmap.put("message","工单不能为空");
+			return rmap;
+		}
+		if (!baseDao.checkIf("make","ma_code='"+macode+"'")){
+			rmap.put("code",-1);
+			rmap.put("message","工单不存在");
+			return rmap;
+		}
+		if (baseDao.checkIf("make","nvl(ma_statuscode,' ')<>'STARTED' and ma_code='"+macode+"'")){
+			rmap.put("code",-1);
+			rmap.put("message","工单不是已下放状态");
+			return rmap;
+		}
+		if (!baseDao.checkIf("MakeSnList","msl_makecode='"+macode+"'")){
+			rmap.put("code",-1);
+			rmap.put("message","工单未维护SN");
+			return rmap;
+		}
+		double sncount = map.get("count") == null ? 1 : Double.parseDouble(map.get("count").toString());
+		if(sncount<=0){
+			rmap.put("code",-1);
+			rmap.put("message","SN数量必须大于0");
+			return rmap;
+		}
+		String mType = map.get("mType") == null ? "" : String.valueOf(map.get("mType"));
+		if("".equals(mType)){
+			rmap.put("code",-1);
+			rmap.put("message","类型不能为空");
+			return rmap;
+		}
+		int count = baseDao.getCountByCondition("MakeSnList", "msl_makecode='" + macode + "' and nvl(msl_type,' ')='"+mType+"' and nvl(msl_status,0)=0");
+		if (count<sncount){
+			rmap.put("code",-1);
+			rmap.put("message","SN不足!");
+			return rmap;
+		}
+		List<String> sqls = new ArrayList<>();
+		List<Map<String, Object>> maps = new ArrayList<>();
+		Map<String, Object> snmap=null;
+		SqlRowList rs = baseDao.queryForRowSet("select msl_sncode,msl_id from (select msl_sncode,msl_id from MakeSnList where msl_makecode='" + macode + "' and nvl(msl_type,' ')='"+mType+"' and nvl(msl_status,0)=0 order by msl_sncode) where rownum<="+sncount +"  order by msl_sncode ");
+		String mainbarcode="";
+		String msl_id="";
+		while (rs.next()){
+			snmap=new HashMap<String, Object>();
+			snmap.put("serialNo",rs.getGeneralString("msl_sncode"));
+			mainbarcode=rs.getGeneralString("msl_sncode");
+			maps.add(snmap);
+			sqls.add("update MakeSnList set msl_signtime=sysdate,msl_status=-1 where msl_id="+rs.getGeneralInt("msl_id"));
+			msl_id+=rs.getGeneralInt("msl_id")+",";
+		}
+		msl_id+="0";
+		baseDao.execute("update MakeSnList set msl_mainbarcode='"+mainbarcode+"' where msl_id in ("+msl_id+")");
+
+		if (sqls!=null&&sqls.size()>0){
+			baseDao.execute(sqls);
+		}
+		rmap.put("code",0);
+		rmap.put("data",maps);
+		return rmap;
+	}
+
 }