|
|
@@ -101,6 +101,12 @@ public class MESHelperServiceImpl implements MESHelperService {
|
|
|
case GetMakeInfoBySN:
|
|
|
remap = GetMakeInfoBySN(json);
|
|
|
break;
|
|
|
+ case GetMakeInfo:
|
|
|
+ remap = GetMakeInfo(json);
|
|
|
+ break;
|
|
|
+ case SetMakeSNList:
|
|
|
+ remap = SetMakeSNList(json);
|
|
|
+ break;
|
|
|
default:
|
|
|
err = -1;
|
|
|
break;
|
|
|
@@ -844,6 +850,98 @@ public class MESHelperServiceImpl implements MESHelperService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询工单信息:make联product
|
|
|
+ * 入参:iMaCode工单号(可为空,为空则查询全部)
|
|
|
+ * 返回:oMakeInfo为行数组,每行ma_code,pr_code,ma_date,pr_detail,pr_spec,ma_qty;oErrMessage(null=成功)
|
|
|
+ */
|
|
|
+ private Map<Object,Object> GetMakeInfo(JSONObject map)
|
|
|
+ {
|
|
|
+ Map<Object, Object> rmap = new HashMap<Object, Object>();
|
|
|
+ StringBuffer sb=new StringBuffer("select ma_code,pr_code,ma_date,pr_detail,pr_spec,nvl(ma_qty,0)ma_qty from make " +
|
|
|
+ "left join product on pr_code=ma_prodcode");
|
|
|
+ if(map.get("iMaCode")!=null && !"".equals(map.get("iMaCode").toString().trim())){
|
|
|
+ sb.append(" where ma_code='").append(map.get("iMaCode").toString().trim()).append("'");
|
|
|
+ }
|
|
|
+ SqlRowList rs=baseDao.queryForRowSet(sb.toString());
|
|
|
+ List<Map<Object,Object>> list=new ArrayList<Map<Object,Object>>();
|
|
|
+ while(rs.next()){
|
|
|
+ Map<Object, Object> remap = new HashMap<Object, Object>();
|
|
|
+ remap.put("ma_code",rs.getString("ma_code"));
|
|
|
+ remap.put("pr_code",rs.getString("pr_code"));
|
|
|
+ remap.put("ma_date",rs.getGeneralTimestamp("ma_date"));
|
|
|
+ remap.put("pr_detail",rs.getString("pr_detail"));
|
|
|
+ remap.put("pr_spec",rs.getString("pr_spec"));
|
|
|
+ remap.put("ma_qty",rs.getString("ma_qty"));
|
|
|
+ list.add(remap);
|
|
|
+ }
|
|
|
+ rmap.put("oErrMessage",null);
|
|
|
+ rmap.put("oMakeInfo",list);
|
|
|
+ return rmap;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 写入工单SN清单:MakeSnlist
|
|
|
+ * 入参:iMaCode工单号(必填),iSNList SN列表(逗号分隔,必填),iType before/after(可不传,默认before)
|
|
|
+ * 数量限制:make.ma_code=iMaCode的ma_qty,MakeSnlist中同工单同MSL_TYPE的现有条数+本次条数不能超过ma_qty
|
|
|
+ * 返回:oCount成功插入条数,oErrMessage(null=成功)
|
|
|
+ */
|
|
|
+ private Map<Object,Object> SetMakeSNList(JSONObject map)
|
|
|
+ {
|
|
|
+ Map<Object, Object> rmap = new HashMap<Object, Object>();
|
|
|
+ if(map.get("iMaCode")==null || "".equals(map.get("iMaCode").toString().trim())){
|
|
|
+ rmap.put("oErrMessage","工单号不能为空");
|
|
|
+ return rmap;
|
|
|
+ }
|
|
|
+ if(map.get("iSNList")==null || "".equals(map.get("iSNList").toString().trim())){
|
|
|
+ rmap.put("oErrMessage","SN列表不能为空");
|
|
|
+ return rmap;
|
|
|
+ }
|
|
|
+ String iMaCode=map.get("iMaCode").toString().trim();
|
|
|
+ //MSL_TYPE:必须是before或after,没传默认before
|
|
|
+ String mslType="before";
|
|
|
+ if(map.get("iType")!=null && !"".equals(map.get("iType").toString().trim())){
|
|
|
+ mslType=map.get("iType").toString().trim().toLowerCase();
|
|
|
+ if(!"before".equals(mslType) && !"after".equals(mslType)){
|
|
|
+ rmap.put("oErrMessage","MSL_TYPE只允许before或after");
|
|
|
+ return rmap;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //SN列表:逗号分隔,去空去重
|
|
|
+ String[] sns=map.get("iSNList").toString().trim().split(",");
|
|
|
+ List<String> snList=new ArrayList<String>();
|
|
|
+ for(String sn:sns){
|
|
|
+ sn=sn.trim();
|
|
|
+ if(!"".equals(sn) && !snList.contains(sn)){
|
|
|
+ snList.add(sn);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(snList.size()==0){
|
|
|
+ rmap.put("oErrMessage","SN列表不能为空");
|
|
|
+ return rmap;
|
|
|
+ }
|
|
|
+ //数量限制:make表当前工单的ma_qty
|
|
|
+ Object maQty=baseDao.getFieldDataByCondition("make","ma_qty","ma_code='"+iMaCode+"'");
|
|
|
+ if(maQty==null){
|
|
|
+ rmap.put("oErrMessage","工单["+iMaCode+"]不存在");
|
|
|
+ return rmap;
|
|
|
+ }
|
|
|
+ //MakeSnlist中同工单且MSL_TYPE相同的现有条数
|
|
|
+ int existCount=baseDao.getCount("select count(1) from MakeSnlist where msl_makecode='"+iMaCode+"' and msl_type='"+mslType+"'");
|
|
|
+ if(existCount+snList.size()>Double.parseDouble(maQty.toString())){
|
|
|
+ rmap.put("oErrMessage","SN条数超出工单数量限制:工单数"+maQty+",已存在"+existCount+"条,本次提交"+snList.size()+"条");
|
|
|
+ return rmap;
|
|
|
+ }
|
|
|
+ //插入:MSL_ID用序列,MSL_INDATE用sysdate,MSL_STATUS默认0
|
|
|
+ for(String sn:snList){
|
|
|
+ baseDao.execute("insert into MakeSnlist(MSL_ID,MSL_INDATE,MSL_MAKECODE,MSL_SNCODE,MSL_STATUS,MSL_TYPE)" +
|
|
|
+ "values(MakeSnlist_seq.nextval,sysdate,'"+iMaCode+"','"+sn+"',0,'"+mslType+"')");
|
|
|
+ }
|
|
|
+ rmap.put("oErrMessage",null);
|
|
|
+ rmap.put("oCount",String.valueOf(snList.size()));
|
|
|
+ return rmap;
|
|
|
+ }
|
|
|
+
|
|
|
public Map<Object,Object> SetStepFinish(String iMakeCode, String iSourceCode, String iSN, String iMPKind, String iResult, String iUserCode, String iErrCode)
|
|
|
{
|
|
|
String oErrMessage = null;
|