|
|
@@ -742,9 +742,9 @@ public class MESServiceImpl implements MESService {
|
|
|
int tlid=0;
|
|
|
String tlcode = "";
|
|
|
String macode="";
|
|
|
- String ma_tasktype="制程不良";
|
|
|
+ String ma_tasktype=null;
|
|
|
//良品退仓、来料不良、制程不良
|
|
|
- String taskType=null;
|
|
|
+ String taskType="制程不良";
|
|
|
int maid=0;
|
|
|
String tlpiclass = "生产退料单", tlcaller = "ProdInOut!Make!Return", bcpiclass = "拨出单", bccaller = "ProdInOut!AppropriationOut";
|
|
|
List<String> sqls = new ArrayList<>();
|
|
|
@@ -784,21 +784,6 @@ public class MESServiceImpl implements MESService {
|
|
|
if (count2 <= 0) {
|
|
|
return ApiResponse.failRsp("10056", requestId, "MES仓库编号在ERP没有对应关系,请联系管理员新增!");
|
|
|
}
|
|
|
- /*warehouses2 = baseDao.getFieldsDataByCondition("customtabledetail left join customtable on cd_ctid=ct_id left join Warehouse on cd_varchar50_3=wh_code", "cd_varchar50_3,wh_description", "ct_statuscode='AUDITED' and ct_caller='MESWarehouse' and cd_varchar50_1='" + whcode2 + "'");
|
|
|
- //获取领料单拨出仓库
|
|
|
- int mmdetno = Integer.parseInt(StringUtil.nvl(baseDao.getFieldDataByCondition("MakeMaterial","mm_detno","mm_id in (" + lineId + ")"), "0"));
|
|
|
- Object data2 = baseDao.getFieldDataByCondition("prodiodetail", "min(pd_batchcode)","pd_piclass='生产领料单' and pd_ordercode='" + macode + "' and pd_orderdetno=" + mmdetno);
|
|
|
- Object pdwhcode = baseDao.getFieldDataByCondition("prodiodetail", "pd_whcode","pd_piclass='拨出单' and pd_batchcode='" + data2 + "'");
|
|
|
- int nocost = Integer.parseInt(StringUtil.nvl(baseDao.getFieldDataByCondition("Warehouse", "nvl(wh_nocost,0)", "wh_code='" + pdwhcode + "'"), "0"));
|
|
|
- int nocost1 = Integer.parseInt(StringUtil.nvl(baseDao.getFieldDataByCondition("Warehouse", "nvl(wh_nocost,0)", "wh_code='" + warehouses2[0] + "'"), "0"));
|
|
|
- if (nocost != nocost1) {
|
|
|
- if (nocost == -1) {
|
|
|
- return ApiResponse.failRsp("10058", requestId, "工单BOM领料仓是零值仓,不允许退有值仓!");
|
|
|
- }
|
|
|
- if (nocost == 0) {
|
|
|
- return ApiResponse.failRsp("10059", requestId, "工单BOM领料仓是有值仓,不允许退零值仓!");
|
|
|
- }
|
|
|
- }*/
|
|
|
}
|
|
|
}
|
|
|
for (int i = 0; i <jsonArray.size() ; i++) {
|
|
|
@@ -892,11 +877,11 @@ public class MESServiceImpl implements MESService {
|
|
|
}
|
|
|
baseDao.execute(sqls);
|
|
|
baseDao.execute("delete from prodiodetail where pd_inqty=0 and pd_piclass='"+tlpiclass+"' and pd_piid="+tlid);
|
|
|
+ Employee employee = baseDao.getJdbcTemplate().queryForObject("select * from employee where em_code=?", new BeanPropertyRowMapper<Employee>(Employee.class), "mes");
|
|
|
int count = baseDao.getCount("select count(1) from prodiodetail where pd_piid=" + tlid);
|
|
|
if (count<=0){
|
|
|
baseDao.deleteById("prodinout","pi_id",tlid);
|
|
|
}
|
|
|
- Employee employee = baseDao.getJdbcTemplate().queryForObject("select * from employee where em_code=?", new BeanPropertyRowMapper<Employee>(Employee.class), "mes");
|
|
|
if (count>0) {
|
|
|
String s1 = postProdInOut(tlid, tlcaller, employee);
|
|
|
logger.info("S1==" + s1);
|
|
|
@@ -909,6 +894,9 @@ public class MESServiceImpl implements MESService {
|
|
|
if (s!=null){
|
|
|
return ApiResponse.successRsp("0",requestId,bcpiclass+":"+code+",过账失败,请在ERP重新过账!");
|
|
|
}
|
|
|
+ if (count<=0) {
|
|
|
+ return ApiResponse.successRsp("0",requestId,bcpiclass+":"+code+",请在ERP查看!");
|
|
|
+ }
|
|
|
return ApiResponse.successRsp("0",requestId,tlpiclass+":"+tlcode+","+bcpiclass+":"+code+",请在ERP查看!");
|
|
|
}
|
|
|
|
|
|
@@ -1276,6 +1264,244 @@ public class MESServiceImpl implements MESService {
|
|
|
return ApiResponse.failRsp("10019",requestId,"ERP生成单据失败!");
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public ApiResult<String> multiMakeSendPicking(HttpServletRequest request) {
|
|
|
+ String requestId = request.getHeader("RequestId");
|
|
|
+ Map<String, JSONArray> data = getData(request);
|
|
|
+ String llcode = null,ma_tasktype=null,llpiclass = "生产领料单", llcaller = "ProdInOut!Picking";
|
|
|
+ int llpiid=0,maid=0;
|
|
|
+ List<String> sqls = new ArrayList<>();
|
|
|
+ JSONArray detail = data.get("detail");
|
|
|
+ if(detail!=null&&detail.size()>0){
|
|
|
+ String macode = StringUtil.valueOf(JSON.parseObject(StringUtil.nvl(detail.get(0), "{}")).get("FICMOBillNo"));
|
|
|
+ Object[] data1 = baseDao.getFieldsDataByCondition("Make", "ma_tasktype,ma_id", "ma_code in ('" + macode + "')");
|
|
|
+ if (data1!=null&&data1.length>0) {
|
|
|
+ ma_tasktype = StringUtil.nvl(data1[0], "");
|
|
|
+ maid = Integer.parseInt(StringUtil.nvl(data1[1], "0"));
|
|
|
+ }else {
|
|
|
+ return ApiResponse.failRsp("10041", requestId, "工单在ERP不存在,请核对!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ JSONArray main = data.get("main");
|
|
|
+ for (int i = 0; i <main.size() ; i++) {
|
|
|
+ JSONObject object = JSON.parseObject(StringUtil.nvl(main.get(i), "{}"));
|
|
|
+ Map<Object, Object> map1 = JSONUtil.toMap(StringUtil.valueOf(object.get("FDeptID")));
|
|
|
+ Map<Object, Object> map2 = JSONUtil.toMap(StringUtil.valueOf(object.get("FPurposeID")));
|
|
|
+ Map<Object, Object> map4 = JSONUtil.toMap(StringUtil.valueOf(object.get("FSManagerID")));
|
|
|
+ Map<Object, Object> map5 = JSONUtil.toMap(StringUtil.valueOf(object.get("FBillerID")));
|
|
|
+ if ("OS".equals(ma_tasktype)) {
|
|
|
+ llpiclass = "委外领料单";
|
|
|
+ llcaller = "ProdInOut!OutsidePicking";
|
|
|
+ }
|
|
|
+ String fSelBillNo = StringUtil.nvl(object.get("FSelBillNo"), "");
|
|
|
+ ApiResult<String> result = checkMESCode(requestId, fSelBillNo, llpiclass);
|
|
|
+ if (result!=null){
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ //生成领料单
|
|
|
+ llpiid = baseDao.getSeqId("PRODINOUT_SEQ");
|
|
|
+ llcode = baseDao.sGetMaxNumber(llcaller, 2);
|
|
|
+ sqls.add("insert into prodinout (pi_id,pi_inoutno,pi_class,pi_date,pi_statuscode,pi_status,pi_departmentcode,pi_departmentname,pi_emcode,pi_emname,pi_invostatuscode,pi_invostatus,pi_recordman,pi_recorddate,pi_printstatuscode,pi_printstatus,pi_type,pi_mescode) " +
|
|
|
+ "values ("+llpiid+",'"+llcode+"','"+llpiclass+"',to_date('"+object.get("Fdate")+"','yyyy-MM-dd HH24:mi:ss'),'UNPOST','未过账','"+map1.get("FNumber")+"','"+map1.get("FName")+"','"+map4.get("FNumber")+"','"+map4.get("FName")+"','ENTERING','在录入','"+map5.get("FName")+"',to_date('"+object.get("Fdate")+"','yyyy-MM-dd HH24:mi:ss'),'UNPRINT','未打印','"+map2.get("FName")+"','"+fSelBillNo+"')");
|
|
|
+ }
|
|
|
+ int detno=1;
|
|
|
+ for (int i = 0; i <detail.size(); i++) {
|
|
|
+ JSONObject object = JSON.parseObject(StringUtil.nvl(detail.get(i), "{}"));
|
|
|
+ Map<Object, Object> map = JSONUtil.toMap(StringUtil.valueOf(object.get("FItemID")));
|
|
|
+ String itemNo = StringUtil.nvl(map.get("FNumber"), "");
|
|
|
+ if ("".equals(itemNo)){
|
|
|
+ return ApiResponse.failRsp("10042",requestId,"物料不能为空!");
|
|
|
+ }
|
|
|
+ String fAuxQty = StringUtil.nvl(object.get("FAuxQty"), "0");
|
|
|
+ if ("0".equals(fAuxQty)){
|
|
|
+ return ApiResponse.failRsp("10043",requestId,"实发数量不能为空!");
|
|
|
+ }
|
|
|
+ Double qty = Double.parseDouble(fAuxQty);
|
|
|
+ Map<Object, Object> map1 = JSONUtil.toMap(StringUtil.valueOf(object.get("FSCStockID1")));
|
|
|
+ String whcode = StringUtil.nvl(map1.get("FNumber"), "");
|
|
|
+ if ("".equals(whcode)){
|
|
|
+ return ApiResponse.failRsp("10043",requestId,"发料仓库不能为空!");
|
|
|
+ }
|
|
|
+ int count = baseDao.getCount("select count(1) from customtabledetail left join customtable on cd_ctid=ct_id where ct_statuscode='AUDITED' and ct_caller='MESWarehouse' and cd_varchar50_1='" + whcode + "'");
|
|
|
+ if (count<=0){
|
|
|
+ return ApiResponse.failRsp("10044",requestId,"MES仓库编号在ERP没有对应关系,请联系管理员新增!");
|
|
|
+ }
|
|
|
+ Object[] warehouses = baseDao.getFieldsDataByCondition("customtabledetail left join customtable on cd_ctid=ct_id left join Warehouse on cd_varchar50_3=wh_code", "cd_varchar50_3,wh_description", "ct_statuscode='AUDITED' and ct_caller='MESWarehouse' and cd_varchar50_1='" + whcode + "'");
|
|
|
+ String ficmoBillNo = StringUtil.nvl(object.get("FICMOBillNo"), "");
|
|
|
+ int lineId = Integer.parseInt(StringUtil.nvl(object.get("lineId"), "0"));
|
|
|
+ int count4 = baseDao.getCount("select count(1) from MakeMaterial where mm_id in (" + lineId + ")");
|
|
|
+ if (count4<=0){
|
|
|
+ return ApiResponse.failRsp("10046",requestId,"工单BOM在ERP没有不存在,明细ID:"+lineId+",请联系管理员!");
|
|
|
+ }
|
|
|
+ Object[] data1 = baseDao.getFieldsDataByCondition("MakeMaterial", "mm_detno,mm_maid","mm_id in (" + lineId + ")");
|
|
|
+ maid = Integer.parseInt(StringUtil.nvl(data1[1], "0"));
|
|
|
+ sqls.add("insert into prodiodetail (pd_id,pd_piid,pd_inoutno,pd_piclass,pd_pdno,pd_prodcode,pd_outqty,pd_whcode,pd_whname,pd_ordercode,pd_orderdetno,pd_macode,pd_madetno,pd_status) " +
|
|
|
+ "values (PRODIODETAIL_SEQ.nextval," + llpiid + ",'" + llcode + "','" + llpiclass + "'," + detno + ",'" + itemNo + "'," + qty + ",'" + warehouses[0] + "','" + warehouses[1] + "','" + ficmoBillNo + "'," + data1[0] + ",'" + ficmoBillNo + "'," + data1[0] + ",0)");
|
|
|
+ detno++;
|
|
|
+ }
|
|
|
+ if ("OS".equals(ma_tasktype)) {
|
|
|
+ sqls.add("update prodinout set(pi_cardcode,pi_title,pi_receivecode,pi_receivename) = (select max(ma_vendcode),max(ma_vendname),max(nvl(ma_apvendcode,ma_vendcode)),max(nvl(ma_apvendname,ma_vendname)) from make where ma_id in (" + maid + ")) where pi_id=" + llpiid);
|
|
|
+ }
|
|
|
+ baseDao.execute(sqls);
|
|
|
+ Employee employee = baseDao.getJdbcTemplate().queryForObject("select * from employee where em_code=?",
|
|
|
+ new BeanPropertyRowMapper<Employee>(Employee.class), "mes");
|
|
|
+ String s = postProdInOut(llpiid, llcaller, employee);
|
|
|
+ refreshTurnQty(maid,0);
|
|
|
+ setBackQty(String.valueOf(maid),0);
|
|
|
+ if (s != null) {
|
|
|
+ return ApiResponse.successRsp("0", requestId, llpiclass+":" + llcode + ",过账失败,请在ERP重新过账!");
|
|
|
+ }
|
|
|
+ return ApiResponse.successRsp("0",requestId,llpiclass+":"+llcode+",请在ERP查看!");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ApiResult<String> multiMakeReturn(HttpServletRequest request) {
|
|
|
+ String requestId = request.getHeader("RequestId");
|
|
|
+ Map<String, JSONArray> data = getData(request);
|
|
|
+ int tlid=0,maid=0,frob=99;
|
|
|
+ String tlcode = "",ma_tasktype=null,taskType="良品退仓",tlpiclass = "生产退料单", tlcaller = "ProdInOut!Make!Return", piclass="'生产领料单','生产退料单'";
|
|
|
+ //良品退仓、来料不良、制程不良
|
|
|
+ List<String> sqls = new ArrayList<>();
|
|
|
+ JSONArray main = data.get("main");
|
|
|
+ JSONArray detail = data.get("detail");
|
|
|
+ String macode = StringUtil.valueOf(JSON.parseObject(StringUtil.nvl(detail.get(0), "")).get("FICMOBillNo"));
|
|
|
+ Object[] data1 = baseDao.getFieldsDataByCondition("Make", "ma_tasktype,ma_id", "ma_code in ('" + macode + "')");
|
|
|
+ if (data1 != null && data1.length > 0) {
|
|
|
+ ma_tasktype = StringUtil.nvl(data1[0], "");
|
|
|
+ maid = Integer.parseInt(StringUtil.nvl(data1[1], "0"));
|
|
|
+ } else {
|
|
|
+ return ApiResponse.failRsp("10051", requestId, "工单在ERP不存在,请核对!");
|
|
|
+ }
|
|
|
+ for (int i = 0; i <main.size() ; i++) {
|
|
|
+ Object obj = main.get(i);
|
|
|
+ JSONObject object = JSON.parseObject(StringUtil.nvl(obj, ""));
|
|
|
+ Map<Object, Object> map1 = JSONUtil.toMap(StringUtil.nvl(object.get("FDeptID"),"{}"));
|
|
|
+ Map<Object, Object> map3 = JSONUtil.toMap(StringUtil.nvl(object.get("FFManagerID"),"{}"));
|
|
|
+ Map<Object, Object> map4 = JSONUtil.toMap(StringUtil.nvl(object.get("FSManagerID"),"{}"));
|
|
|
+ Map<Object, Object> map5 = JSONUtil.toMap(StringUtil.nvl(object.get("FBillerID"),"{}"));
|
|
|
+ frob = Integer.parseInt(StringUtil.nvl(object.get("FROB"), "99"));
|
|
|
+ taskType = StringUtil.nvl(object.get("TaskType"), "");
|
|
|
+ if ("OS".equals(ma_tasktype)) {
|
|
|
+ tlpiclass = "委外退料单";
|
|
|
+ tlcaller = "ProdInOut!OutsideReturn";
|
|
|
+ piclass="'委外领料单','委外退料单'";
|
|
|
+ }
|
|
|
+ String fSelBillNo = StringUtil.nvl(object.get("FSelBillNo"), "");
|
|
|
+ ApiResult<String> result = checkMESCode(requestId, fSelBillNo, tlpiclass);
|
|
|
+ if (result!=null){
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ tlid = baseDao.getSeqId("PRODINOUT_SEQ");
|
|
|
+ tlcode = baseDao.sGetMaxNumber(tlcaller, 2);
|
|
|
+ sqls.add("INSERT INTO ProdInOut(pi_id, pi_inoutno, pi_date, pi_class,pi_invostatus,pi_invostatuscode,pi_recordman, pi_recorddate, pi_statuscode,pi_status,pi_updatedate,pi_updateman,pi_printstatuscode,pi_printstatus,pi_departmentcode,pi_departmentname,pi_emcode,pi_emname,pi_mescode) VALUES ("+tlid+",'"+tlcode+"',to_date('"+object.get("Fdate")+"','yyyy-MM-dd HH24:mi:ss'),'"+tlpiclass+"','已审核','AUDITED','"+map5.get("FName")+"',to_date('"+object.get("Fdate")+"','yyyy-MM-dd HH24:mi:ss'),'UNPOST','未过账',sysdate,'"+map5.get("FName")+"','UNPRINT','未打印','"+map1.get("FNumber")+"','"+map1.get("FName")+"','"+map4.get("FNumber")+"','"+map4.get("FName")+"','"+fSelBillNo+"')");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(detail!=null&&detail.size()>0) {
|
|
|
+ int detno=1;
|
|
|
+ for (int i = 0; i < detail.size(); i++) {
|
|
|
+ JSONObject object = JSON.parseObject(StringUtil.nvl(detail.get(i), "{}"));
|
|
|
+ Object lineId = object.get("lineId");
|
|
|
+ //物料资料
|
|
|
+ Map<Object, Object> map = JSONUtil.toMap(StringUtil.valueOf(object.get("FItemID")));
|
|
|
+ String itemNo = StringUtil.nvl(map.get("FNumber"), "");
|
|
|
+ if ("".equals(itemNo)){
|
|
|
+ return ApiResponse.failRsp("10052",requestId,"物料不能为空!");
|
|
|
+ }
|
|
|
+ //退料数量
|
|
|
+ Double qty =Double.parseDouble(StringUtil.nvl(object.get("FAuxQty"), "0"));
|
|
|
+ if (qty==0){
|
|
|
+ return ApiResponse.failRsp("10053",requestId,"实发数量不能为空!");
|
|
|
+ }
|
|
|
+ //退回仓库
|
|
|
+ Map<Object, Object> map2 = JSONUtil.toMap(StringUtil.nvl(object.get("FSCStockID1"), "{}"));
|
|
|
+ String whcode = StringUtil.nvl(map2.get("FNumber"), "");
|
|
|
+ if ("".equals(whcode)) {
|
|
|
+ return ApiResponse.failRsp("10055", requestId, "物料退回仓库不能为空!");
|
|
|
+ }
|
|
|
+ int count = baseDao.getCount("select count(1) from customtabledetail left join customtable on cd_ctid=ct_id where ct_statuscode='AUDITED' and ct_caller='MESWarehouse' and cd_varchar50_1='" + whcode + "'");
|
|
|
+ if (count <= 0) {
|
|
|
+ return ApiResponse.failRsp("10056", requestId, "MES仓库编号在ERP没有对应关系,请联系管理员新增!");
|
|
|
+ }
|
|
|
+ Object[] warehouses = baseDao.getFieldsDataByCondition("customtabledetail left join customtable on " +
|
|
|
+ "cd_ctid=ct_id left join Warehouse on cd_varchar50_3=wh_code", "cd_varchar50_3,wh_description,wh_nocost", "ct_statuscode='AUDITED' and ct_caller='MESWarehouse' and cd_varchar50_1='" + whcode + "'");
|
|
|
+ Double outqty = Double.parseDouble(StringUtil.nvl(baseDao.getFieldDataByCondition("prodiodetail left join Warehouse on pd_whcode=wh_code", "sum(nvl(pd_outqty,0)-nvl(pd_inqty,0))", "pd_piclass in ("+piclass+ ") and pd_ordercode='" + macode + "' and pd_prodcode='" + itemNo + "' and nvl(wh_nocost,0)=" + warehouses[2]),"0"));
|
|
|
+ if (qty.compareTo(outqty) > 0) {
|
|
|
+ return ApiResponse.failRsp("10058", requestId, "退料数量不允许超过对应的发料数,请确定仓库属性和领料数量!");
|
|
|
+ }
|
|
|
+ String ficmoBillNo = StringUtil.nvl(object.get("FICMOBillNo"), "");
|
|
|
+ int count1 = baseDao.getCount("select count(1) from MakeMaterial where mm_id in (" + lineId + ")");
|
|
|
+ if (count1<=0){
|
|
|
+ return ApiResponse.failRsp("10075",requestId,"工单BOM不存在或ID不一致,请联系管理员处理!");
|
|
|
+ }
|
|
|
+ Object[] objs = baseDao.getFieldsDataByCondition("Make left join MakeMaterial on ma_id=mm_maid", new String[] { "mm_id", "mm_code","mm_detno", "mm_mdcode", "mm_prodcode", "mm_wccode"}, "mm_id in (" + lineId+")");
|
|
|
+ Object prid = baseDao.getFieldDataByCondition("Product", "pr_id", "pr_code='" + itemNo + "'");
|
|
|
+ sqls.add("INSERT INTO ProdIODetail(pd_id, pd_piid, pd_inoutno, pd_piclass, pd_pdno, pd_status,pd_auditstatuscode,pd_auditstatus,pd_prodcode,pd_ordercode, pd_orderdetno,pd_macode,pd_madetno,pd_plancode, pd_wccode, pd_orderid, pd_prodid,pd_whcode,pd_whname,pd_inqty,pd_description) VALUES (PRODIODETAIL_SEQ.nextval,"+tlid+",'"+tlcode+"','"+tlpiclass+"',"+detno+ ",0,'ENTERING','在录入','"+itemNo+"','"+ficmoBillNo+"',"+objs[2]+",'"+ficmoBillNo+"',"+objs[2]+ ",'"+objs[3]+"','"+objs[5]+"',"+lineId+","+prid+",'"+warehouses[0]+"','"+warehouses[1]+"',"+qty+ ",'"+taskType+"')");
|
|
|
+ detno++;
|
|
|
+ }
|
|
|
+ sqls.add("update prodiodetail set (pd_mcid,pd_jobcode)=(select mc_id,mm_mdcode from MakeMaterial,makecraft where pd_orderdetno=mm_detno and pd_ordercode=mm_code and mm_mdcode=mc_code) where pd_piid="
|
|
|
+ + tlid);
|
|
|
+ sqls.add("update prodiodetail set pd_purcinqty=Round(Pd_Inqty/nvl((Select case when nvl(Pr_Purcrate,0)=0 then 1 else Pr_Purcrate end From Product Where Pd_Prodcode=Pr_Code),1),8) where pd_piid="
|
|
|
+ + tlid);
|
|
|
+ if ("OS".equals(ma_tasktype)) {
|
|
|
+ sqls.add("update prodinout set(pi_cardcode,pi_title,pi_receivecode,pi_receivename) = (select max(ma_vendcode),max(ma_vendname),max(nvl(ma_apvendcode,ma_vendcode)),max(nvl(ma_apvendname,ma_vendname)) from make where ma_id in (" + maid + ")) where pi_id=" + tlid);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ baseDao.execute(sqls);
|
|
|
+ Employee employee = baseDao.getJdbcTemplate().queryForObject("select * from employee where em_code=?", new BeanPropertyRowMapper<Employee>(Employee.class), "mes");
|
|
|
+ String s = postProdInOut(tlid, tlcaller, employee);
|
|
|
+ logger.info("S==" + s);
|
|
|
+ if (s != null) {
|
|
|
+ return ApiResponse.successRsp("0", requestId, tlpiclass+":" + tlcode + ",过账失败,请在ERP重新过账!");
|
|
|
+ }
|
|
|
+ return ApiResponse.successRsp("0",requestId,tlpiclass+":"+tlcode+",请在ERP查看!");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ApiResult<String> productWhQty(HttpServletRequest request) {
|
|
|
+ String requestId = request.getHeader("RequestId");
|
|
|
+ JSONObject data = getJsonData(request);
|
|
|
+ if (data!=null){
|
|
|
+ List<Map<String, Object>> maps = new ArrayList<>();
|
|
|
+ //物料
|
|
|
+ String itemNo = StringUtil.nvl(data.get("ItemNo"), "");
|
|
|
+ if ("".equals(itemNo)){
|
|
|
+ return ApiResponse.failRsp("10071",requestId,"物料不能为空!");
|
|
|
+ }
|
|
|
+ //仓库
|
|
|
+ String whCode = StringUtil.nvl(data.get("WhCode"), "");
|
|
|
+ if ("".equals(whCode)) {
|
|
|
+ SqlRowList rs = baseDao.queryForRowSet("select pw_whcode,sum(nvl(pw_onhand,0)) qty from productwh where pw_prodcode='" + itemNo + "' group by pw_whcode");
|
|
|
+ while (rs.next()){
|
|
|
+ SqlRowList rowSet = baseDao.queryForRowSet("select cd_varchar50_3,cd_varchar50_1 from customtabledetail left join customtable on cd_ctid=ct_id where ct_statuscode='AUDITED' and ct_caller='MESWarehouse' and nvl(cd_varchar50_1,' ')<>' ' and cd_varchar50_3='" + rs.getGeneralString("pw_whcode") + "' order by ct_id desc,cd_id desc");
|
|
|
+ if (rowSet.next()){
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("whCode",rowSet.getString("cd_varchar50_1"));
|
|
|
+ map.put("qty",rs.getGeneralDouble("qty"));
|
|
|
+ maps.add(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ int count = baseDao.getCount("select count(1) from customtabledetail left join customtable on cd_ctid=ct_id where ct_statuscode='AUDITED' and ct_caller='MESWarehouse' and cd_varchar50_1='" + whCode + "'");
|
|
|
+ if (count <= 0) {
|
|
|
+ return ApiResponse.failRsp("10072", requestId, "MES仓库编号在ERP没有对应关系,请联系管理员新增!");
|
|
|
+ }
|
|
|
+ Object[] warehouses = baseDao.getFieldsDataByCondition("customtabledetail left join customtable on cd_ctid=ct_id left join Warehouse on cd_varchar50_3=wh_code", "cd_varchar50_3,wh_description,wh_nocost", "ct_statuscode='AUDITED' and ct_caller='MESWarehouse' and cd_varchar50_1='" + whCode + "'");
|
|
|
+ Double qty = baseDao.getSummaryByField("productwh", "pw_onhand", "pw_prodcode='" + itemNo + "' and pw_whcode='" + warehouses[0] + "'");
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("whCode", whCode);
|
|
|
+ map.put("qty", qty);
|
|
|
+ maps.add(map);
|
|
|
+ }
|
|
|
+ if (maps==null){
|
|
|
+ return ApiResponse.failRsp("10073",requestId,"未找到数据!");
|
|
|
+ }else {
|
|
|
+ return ApiResponse.successRsp("0", "获取成功!",requestId, JSON.toJSONString(maps));
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ return ApiResponse.failRsp("10074",requestId,"参数异常!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private Map<String, JSONArray> getData(HttpServletRequest request){
|
|
|
Map<String, JSONArray> map = new HashMap<>();
|
|
|
try {
|