|
|
@@ -35,13 +35,13 @@ public class MESServiceImpl implements MESService {
|
|
|
private TransferRepository transferRepository;
|
|
|
|
|
|
@Override
|
|
|
- public ApiResult<String> checkVerifyApply(HttpServletRequest request,String data) {
|
|
|
- Map<Object, Object> store = BaseUtil.parseFormStoreToMap(data);
|
|
|
- String mesCode = StringUtil.nvl(store.get("mesCode"), "");
|
|
|
+ public ApiResult<String> checkVerifyApply(HttpServletRequest request) {
|
|
|
+ JSONObject jsonData = getJsonData(request);
|
|
|
+ String mesCode = StringUtil.nvl(jsonData.get("mesCode"), "");
|
|
|
if ("".equals(mesCode)){
|
|
|
return ApiResponse.failRsp("10011",request.getHeader("RequestId"),"MES编号不能为空!");
|
|
|
}
|
|
|
- VerifyApply verifyApply = baseDao.getJdbcTemplate().queryForObject("select va_id,va_mescode,va_code,to_char(va_date,'yyyy-MM-dd HH24:mi:ss') va_date,va_vendcode,va_vendname,va_currency,va_rate,va_paymentscode,va_payments,va_transport,va_sendcode,va_emcode,va_emname,va_whcode,va_whname,va_departmentcode,va_department,va_recorder,nvl(va_cop,'BYT') va_cop,va_remark,va_ancode,va_factory,0 version,va_custcode,va_custname,va_putype,va_pucode,case when nvl(va_pucode,' ')=' ' then 0 else (select pu_id from purchase where pu_code=va_pucode) end pu_id,va_status,1 posted,to_char(va_auditdate,'yyyy-MM-dd HH24:mi:ss') va_auditdate,va_auditman " +
|
|
|
+ VerifyApply verifyApply = baseDao.getJdbcTemplate().queryForObject("select va_id,va_mescode,va_code,to_char(va_date,'yyyy-MM-dd HH24:mi:ss') va_date,va_vendcode,va_vendname,va_currency,va_rate,va_paymentscode,va_payments,va_transport,va_sendcode,va_emcode,va_emname,va_whcode,va_whname,va_departmentcode,va_department,va_recorder,nvl(va_cop,'BYT') va_cop,va_remark,va_ancode,va_factory,0 version,va_custcode,va_custname,va_type,va_pucode,case when nvl(va_pucode,' ')=' ' then 0 else (select pu_id from purchase where pu_code=va_pucode) end pu_id,va_status,1 posted,to_char(va_auditdate,'yyyy-MM-dd HH24:mi:ss') va_auditdate,va_auditman " +
|
|
|
"from VerifyApply where va_statuscode='AUDITED' and va_mescode=?",
|
|
|
new BeanPropertyRowMapper<VerifyApply>(VerifyApply.class), mesCode);
|
|
|
if (verifyApply==null) {
|
|
|
@@ -54,49 +54,55 @@ public class MESServiceImpl implements MESService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ApiResult<String> purcCheckin(HttpServletRequest request,String data) {
|
|
|
- Map<Object, Object> store = BaseUtil.parseFormStoreToMap(data);
|
|
|
- String mesCode = StringUtil.nvl(store.get("mesCode"), "");
|
|
|
- if ("".equals(mesCode)){
|
|
|
- return ApiResponse.failRsp("10011",request.getHeader("RequestId"),"MES编号不能为空!");
|
|
|
- }
|
|
|
- int count = baseDao.getCountByCondition("verifyApply", "va_statuscode='AUDITED' and va_mescode='" + mesCode + "'");
|
|
|
- if (count<1){
|
|
|
- return ApiResponse.failRsp("10012",request.getHeader("RequestId"),"单据未审核或不存在,请确认!");
|
|
|
- }
|
|
|
- Object vaid = baseDao.getFieldDataByCondition("verifyApply", "va_id", "va_statuscode='AUDITED" +
|
|
|
- "' and va_mescode='" + mesCode + "'");
|
|
|
- int count1 = baseDao.getCount("select count(1) from VerifyApplyDetail where nvl(vad_pucode,' ')<>' ' and " +
|
|
|
- "vad_vaid=" + vaid);
|
|
|
+ public ApiResult<String> purcCheckin(HttpServletRequest request) {
|
|
|
+ Map<String, JSONArray> data = getData(request);
|
|
|
+ JSONArray jsonArray = data.get("main");
|
|
|
+ Object vaid=0;
|
|
|
String caller="VerifyApply!ToOtherIn";
|
|
|
String type="其它入库单";
|
|
|
- if (count1>0){
|
|
|
- caller="VerifyApply!ToPurcIn";
|
|
|
- type="采购验收单";
|
|
|
- }
|
|
|
- int piid ;
|
|
|
- //判断已转数
|
|
|
- Object chekQty = baseDao.getJdbcTemplate().queryForObject("select wmsys.wm_concat('收料单:'||vad_code||'序号:'||vad_detno) from VerifyApplyDetail where vad_qty <= vad_yqty and vad_vaid = "+vaid, String.class);
|
|
|
- if(chekQty !=null){
|
|
|
- return ApiResponse.failRsp("10013",request.getHeader("RequestId"),"检测到" + chekQty + ",本次数量超出可转数量!");
|
|
|
- }
|
|
|
- if ("VerifyApply!ToPurcIn".equals(caller)) {
|
|
|
- // 判断该收料通知单是否已经转入过采购验收单
|
|
|
- Object code = baseDao.getFieldDataByCondition("VerifyApply", "va_code", "va_id=" + vaid);
|
|
|
- code = baseDao.getFieldDataByCondition("ProdInOut", "pi_inoutno", "pi_sourcecode='" + code + "' and PI_REFNO='采购收料单'");
|
|
|
- if (code != null && !code.equals("")) {
|
|
|
- return ApiResponse.failRsp("10014", request.getHeader("RequestId"), "该收料单已转入过采购验收单,验收单号[" + code + "]");
|
|
|
+ String sellerName="";
|
|
|
+ for (int i = 0; i <jsonArray.size() ; i++) {
|
|
|
+ JSONObject jsonObject = JSON.parseObject(StringUtil.nvl(jsonArray.get(i), ""));
|
|
|
+ Object mesCode = StringUtil.nvl(jsonObject.get("mesCode"),"");
|
|
|
+ if ("".equals(mesCode)){
|
|
|
+ return ApiResponse.failRsp("10011",request.getHeader("RequestId"),"MES编号不能为空!");
|
|
|
}
|
|
|
- }
|
|
|
- if ("VerifyApply!ToOtherIn".equals(caller)) {
|
|
|
- // 判断该收料通知单是否已经转入过采购验收单
|
|
|
- Object code = baseDao.getFieldDataByCondition("VerifyApply", "va_code", "va_id=" + vaid);
|
|
|
- code = baseDao.getFieldDataByCondition("ProdInOut", "pi_inoutno", "pi_sourcecode='" + code + "' and PI_REFNO='采购收料单'");
|
|
|
- if (code != null && !code.equals("")) {
|
|
|
- return ApiResponse.failRsp("10014", request.getHeader("RequestId"), "该收料单已转入过其它入库单,单号[" + code + "]");
|
|
|
+ int count = baseDao.getCountByCondition("verifyApply", "va_statuscode='AUDITED' and va_mescode='" + mesCode + "'");
|
|
|
+ if (count<1){
|
|
|
+ return ApiResponse.failRsp("10012",request.getHeader("RequestId"),"单据未审核或不存在,请确认!");
|
|
|
+ }
|
|
|
+ vaid = baseDao.getFieldDataByCondition("verifyApply", "va_id", "va_statuscode='AUDITED" +
|
|
|
+ "' and va_mescode='" + mesCode + "'");
|
|
|
+ int count1 = baseDao.getCount("select count(1) from VerifyApplyDetail where nvl(vad_pucode,' ')<>' ' and " +
|
|
|
+ "vad_vaid=" + vaid);
|
|
|
+ if (count1>0){
|
|
|
+ caller="VerifyApply!ToPurcIn";
|
|
|
+ type="采购验收单";
|
|
|
+ }
|
|
|
+ //判断已转数
|
|
|
+ Object chekQty = baseDao.getJdbcTemplate().queryForObject("select wmsys.wm_concat('收料单:'||vad_code||'序号:'||vad_detno) from VerifyApplyDetail where vad_qty <= vad_yqty and vad_vaid = "+vaid, String.class);
|
|
|
+ if(chekQty !=null){
|
|
|
+ return ApiResponse.failRsp("10013",request.getHeader("RequestId"),"检测到" + chekQty + ",本次数量超出可转数量!");
|
|
|
+ }
|
|
|
+ if ("VerifyApply!ToPurcIn".equals(caller)) {
|
|
|
+ // 判断该收料通知单是否已经转入过采购验收单
|
|
|
+ Object code = baseDao.getFieldDataByCondition("VerifyApply", "va_code", "va_id=" + vaid);
|
|
|
+ code = baseDao.getFieldDataByCondition("ProdInOut", "pi_inoutno", "pi_sourcecode='" + code + "' and PI_REFNO='采购收料单'");
|
|
|
+ if (code != null && !code.equals("")) {
|
|
|
+ return ApiResponse.failRsp("10014", request.getHeader("RequestId"), "该收料单已转入过采购验收单,验收单号[" + code + "]");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("VerifyApply!ToOtherIn".equals(caller)) {
|
|
|
+ // 判断该收料通知单是否已经转入过采购验收单
|
|
|
+ Object code = baseDao.getFieldDataByCondition("VerifyApply", "va_code", "va_id=" + vaid);
|
|
|
+ code = baseDao.getFieldDataByCondition("ProdInOut", "pi_inoutno", "pi_sourcecode='" + code + "' and PI_REFNO='采购收料单'");
|
|
|
+ if (code != null && !code.equals("")) {
|
|
|
+ return ApiResponse.failRsp("10014", request.getHeader("RequestId"), "该收料单已转入过其它入库单,单号[" + code + "]");
|
|
|
+ }
|
|
|
}
|
|
|
+ sellerName = StringUtil.nvl(jsonObject.get("sellerName"), "管理员");
|
|
|
}
|
|
|
- String sellerName = StringUtil.nvl(store.get("sellerName"), "管理员");
|
|
|
+ int piid ;
|
|
|
Employee employee = baseDao.getJdbcTemplate().queryForObject("select * from employee where em_name=?",
|
|
|
new BeanPropertyRowMapper<Employee>(Employee.class), sellerName);
|
|
|
// 转采购验收单
|
|
|
@@ -207,12 +213,13 @@ public class MESServiceImpl implements MESService {
|
|
|
}
|
|
|
String fSourceBillNo = StringUtil.nvl(jsonObject3.get("FSourceBillNo"), "");
|
|
|
String fICMOBillNo = StringUtil.nvl(jsonObject3.get("FICMOBillNo"), "");
|
|
|
+ String fEntrySelfA0248 = StringUtil.nvl(jsonObject3.get("FEntrySelfA0248"), "");
|
|
|
sqls.add("insert into prodiodetail (pd_id,pd_piid,pd_inoutno,pd_piclass,pd_pdno,pd_ordercode,pd_prodcode," +
|
|
|
"pd_batchcode,pd_inqty,pd_nxlh,pd_purcrate,pd_notinqty,pd_orderprice,pd_ordertotal,pd_price," +
|
|
|
"pd_total,pd_whcode,pd_whname,pd_remark,pd_prodmadedate,pd_replydate,pd_location,pd_macode) " +
|
|
|
"values (PRODIODETAIL_SEQ.nextval,"+id+",'"+code+"','完工入库单',"+detno+",'"+fSourceBillNo+
|
|
|
"','"+map11.get("FNumber")+"','"+fBatchNo+"',"+fauxqty+",'"+fSecUnitID+"',"+fSecCoefficient+","+fSecQty+","+fAuxPlanPrice+","+fPlanAmount+","+fauxprice+"," +
|
|
|
- ""+famount+",'"+map12.get("FNumber")+"','"+map12.get("FName")+"','"+fnote+"',to_date('"+fKFDate+"'," +
|
|
|
+ ""+famount+",'"+map12.get("FNumber")+"','"+map12.get("FName")+"','"+fnote+"',to_date('"+fEntrySelfA0248+"'," +
|
|
|
"'yyyy-MM-dd HH24:mi:ss'),to_date('"+fPeriodDate+"','yyyy-MM-dd HH24:mi:ss'),'"+location+"','"+fICMOBillNo+"')");
|
|
|
}
|
|
|
baseDao.execute(sqls);
|
|
|
@@ -220,9 +227,9 @@ public class MESServiceImpl implements MESService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ApiResult<String> makeDeleteCheck(HttpServletRequest request,String data) {
|
|
|
- Map<Object, Object> store = BaseUtil.parseFormStoreToMap(data);
|
|
|
- Object maId = store.get("finterid");
|
|
|
+ public ApiResult<String> makeDeleteCheck(HttpServletRequest request) {
|
|
|
+ JSONObject jsonData = getJsonData(request);
|
|
|
+ Object maId = jsonData.get("finterid");
|
|
|
// 只能删除在录入的单据!
|
|
|
SqlRowList status =
|
|
|
baseDao.queryForRowSet("select ma_statuscode,ma_checkstatuscode from make where ma_id="+maId);
|
|
|
@@ -242,29 +249,34 @@ public class MESServiceImpl implements MESService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ApiResult<String> initMakeScrap(HttpServletRequest request, String data) {
|
|
|
- JSONObject jsonObject = JSON.parseObject(data);
|
|
|
+ public ApiResult<String> initMakeScrap(HttpServletRequest request) {
|
|
|
+ Map<String, JSONArray> data = getData(request);
|
|
|
+ JSONArray jsonArray = data.get("main");
|
|
|
+ int id=0;
|
|
|
+ String code="";
|
|
|
List<String> sqls = new ArrayList<>();
|
|
|
- int id = baseDao.getSeqId("MAKESCRAP_SEQ");
|
|
|
- String code = baseDao.sGetMaxNumber("MakeScrap", 2);
|
|
|
- String fdateTime = StringUtil.nvl(jsonObject.get("FdateTime"),DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
- String fwcCode = StringUtil.nvl(jsonObject.get("FwcCode"), "");
|
|
|
- if ("".equals(fwcCode)){
|
|
|
- return ApiResponse.failRsp("10021",request.getHeader("RequestId"),"工作中心不能为空!");
|
|
|
+ for (int i = 0; i <jsonArray.size() ; i++) {
|
|
|
+ JSONObject jsonObject = JSON.parseObject(StringUtil.nvl(jsonArray.get(i), ""));
|
|
|
+ id = baseDao.getSeqId("MAKESCRAP_SEQ");
|
|
|
+ code = baseDao.sGetMaxNumber("MakeScrap", 2);
|
|
|
+ String fdateTime = StringUtil.nvl(jsonObject.get("FdateTime"), DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ String fwcCode = StringUtil.nvl(jsonObject.get("FwcCode"), "");
|
|
|
+ if ("".equals(fwcCode)) {
|
|
|
+ return ApiResponse.failRsp("10021", request.getHeader("RequestId"), "工作中心不能为空!");
|
|
|
+ }
|
|
|
+ String createdUser = StringUtil.nvl(jsonObject.get("createdUser"), "管理员");
|
|
|
+ String createdDateTime = StringUtil.nvl(jsonObject.get("createdDateTime"), DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ String companyNo = StringUtil.nvl(jsonObject.get("companyNo"), "BYT");
|
|
|
+ String fremark = StringUtil.nvl(jsonObject.get("Fremark"), "");
|
|
|
+ sqls.add("insert into MakeScrap (ms_id,ms_code,ms_class,ms_statuscode,ms_status,ms_printstatuscode,ms_printstatus," +
|
|
|
+ "ms_date,ms_wccode,ms_recordman,ms_indate,ms_cop,ms_remark) values (" + id + ",'" + code + "','生产报废单','ENTERING'," +
|
|
|
+ "'在录入','UNPRINT','未打印',to_date('" + fdateTime + "','yyyy-MM-dd HH24:mi:ss'),'" + fwcCode + "','" + createdUser +
|
|
|
+ "',to_date('" + createdDateTime + "','yyyy-MM-dd HH24:mi:ss'),'" + companyNo + "','" + fremark + "')");
|
|
|
}
|
|
|
- String createdUser = StringUtil.nvl(jsonObject.get("createdUser"), "管理员");
|
|
|
- String createdDateTime = StringUtil.nvl(jsonObject.get("createdDateTime"),DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
- String companyNo = StringUtil.nvl(jsonObject.get("companyNo"), "BYT");
|
|
|
- String fremark = StringUtil.nvl(jsonObject.get("Fremark"), "");
|
|
|
- sqls.add("insert into MakeScrap (ms_id,ms_code,ms_class,ms_statuscode,ms_status,ms_printstatuscode,ms_printstatus," +
|
|
|
- "ms_date,ms_wccode,ms_recordman,ms_indate,ms_cop,ms_remark) values ("+id+",'"+code+"','生产报废单','ENTERING'," +
|
|
|
- "'在录入','UNPRINT','未打印',to_date('"+fdateTime+"','yyyy-MM-dd HH24:mi:ss'),'"+fwcCode+"','"+createdUser+
|
|
|
- "',to_date('"+createdDateTime+"','yyyy-MM-dd HH24:mi:ss'),'"+companyNo+"','"+fremark+"')");
|
|
|
- String detail = StringUtil.nvl(jsonObject.get("detail"), "[{}]");
|
|
|
- JSONArray jsonArray = JSON.parseArray(detail);
|
|
|
+ JSONArray array = data.get("detail");
|
|
|
int detno=1;
|
|
|
- for (int i = 0; i <jsonArray.size(); i++) {
|
|
|
- JSONObject object = JSON.parseObject(StringUtil.nvl(jsonArray.get(i), "{}"));
|
|
|
+ for (int i = 0; i <array.size(); i++) {
|
|
|
+ JSONObject object = JSON.parseObject(StringUtil.nvl(array.get(i), "{}"));
|
|
|
String lineId = StringUtil.nvl(object.get("lineId"), "");
|
|
|
if ("".equals(lineId)){
|
|
|
return ApiResponse.failRsp("10022",request.getHeader("RequestId"),"工单明细ID不能为空!");
|
|
|
@@ -434,7 +446,8 @@ public class MESServiceImpl implements MESService {
|
|
|
}
|
|
|
String fSourceInterId = StringUtil.nvl(object.get("FSourceInterId"), "");
|
|
|
String ficmoBillNo = StringUtil.nvl(object.get("FICMOBillNo"), "");
|
|
|
- Object mmdetno = baseDao.getFieldDataByCondition("MakeMaterial", "mm_detno", "mm_id in (" + fSourceInterId+")");
|
|
|
+ Object lineId = object.get("lineId");
|
|
|
+ Object mmdetno = baseDao.getFieldDataByCondition("MakeMaterial", "mm_detno", "mm_id in (" + lineId+")");
|
|
|
if(bccode!=null) {
|
|
|
sqls.add("insert into prodiodetail (pd_id,pd_piid,pd_inoutno,pd_piclass,pd_pdno,pd_prodcode," +
|
|
|
"pd_outqty,pd_whcode,pd_whname,pd_inwhcode,pd_inwhname) " +
|
|
|
@@ -468,8 +481,8 @@ public class MESServiceImpl implements MESService {
|
|
|
Map<Object, Object> map5 = JSONUtil.toMap(StringUtil.valueOf(jsonObject2.get("FBillerID")));
|
|
|
id = baseDao.getSeqId("PRODINOUT_SEQ");
|
|
|
code = baseDao.sGetMaxNumber("ProdInOut!Make!Return", 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) " +
|
|
|
- "values ("+id+",'"+code+"','生产退料单',to_date('"+jsonObject2.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('"+jsonObject2.get("Fdate")+"','yyyy/MM/dd HH24:mi:ss'),'UNPRINT','未打印')");
|
|
|
+ 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) " +
|
|
|
+ "values ("+id+",'"+code+"','生产退料单',to_date('"+jsonObject2.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('"+jsonObject2.get("Fdate")+"','yyyy/MM/dd HH24:mi:ss'),'UNPRINT','未打印','"+map2.get("FName")+"')");
|
|
|
}
|
|
|
JSONArray array = data.get("detail");
|
|
|
int detno=1;
|
|
|
@@ -493,11 +506,12 @@ public class MESServiceImpl implements MESService {
|
|
|
}
|
|
|
String ficmoBillNo = StringUtil.nvl(object.get("FICMOBillNo"), "");
|
|
|
String fBatchNo = StringUtil.nvl(object.get("FBatchNo"), "");
|
|
|
-
|
|
|
+ Object lineId = object.get("lineId");
|
|
|
+ Object mmdetno = baseDao.getFieldDataByCondition("MakeMaterial", "mm_detno", "mm_id in (" + lineId+")");
|
|
|
sqls.add("insert into prodiodetail (pd_id,pd_piid,pd_inoutno,pd_piclass,pd_pdno,pd_prodcode," +
|
|
|
- "pd_inqty,pd_whcode,pd_whname,pd_remark,pd_batchcode,pd_ordercode) " +
|
|
|
+ "pd_inqty,pd_whcode,pd_whname,pd_remark,pd_batchcode,pd_ordercode,pd_orderdetno) " +
|
|
|
"values (PRODIODETAIL_SEQ.nextval,"+id+",'"+code+"','生产退料单',"+detno+",'"+itemNo+
|
|
|
- "',"+qty+",'"+whcode+"','"+whname+"','"+fnote+"','"+fBatchNo+"','"+ficmoBillNo+"')");
|
|
|
+ "',"+qty+",'"+whcode+"','"+whname+"','"+fnote+"','"+fBatchNo+"','"+ficmoBillNo+"',"+mmdetno+")");
|
|
|
detno++;
|
|
|
}
|
|
|
baseDao.execute(sqls);
|
|
|
@@ -580,4 +594,15 @@ public class MESServiceImpl implements MESService {
|
|
|
}
|
|
|
return map;
|
|
|
}
|
|
|
+
|
|
|
+ private JSONObject getJsonData(HttpServletRequest request){
|
|
|
+ JSONObject jsonObject=null;
|
|
|
+ try {
|
|
|
+ String data = PSHttpUtils.readRaw(request.getInputStream());
|
|
|
+ jsonObject = JSON.parseObject(data);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return jsonObject;
|
|
|
+ }
|
|
|
}
|