add:成品报废审核
This commit is contained in:
Binary file not shown.
@@ -98,4 +98,11 @@ public class LmsToMesController {
|
||||
public ResponseEntity<Object> lmsPackage(@RequestBody JSONObject jo) {
|
||||
return new ResponseEntity<>(lmsToMesService.lmsPackage(jo), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/scrapAudit")
|
||||
@Log("成品报废审核")
|
||||
@ApiOperation("成品报废审核")
|
||||
public ResponseEntity<Object> scrapAudit(@RequestBody JSONObject jo) {
|
||||
return new ResponseEntity<>(lmsToMesService.scrapAudit(jo), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,4 +110,10 @@ public interface LmsToMesService {
|
||||
* }
|
||||
*/
|
||||
JSONObject lmsPackage(JSONObject jo);
|
||||
|
||||
/**
|
||||
* 成品报废审核
|
||||
* 参数:
|
||||
*/
|
||||
JSONObject scrapAudit(JSONObject jo);
|
||||
}
|
||||
|
||||
@@ -604,4 +604,41 @@ public class LmsToMesServiceImpl implements LmsToMesService {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject scrapAudit(JSONObject param) {
|
||||
log.info("scrapAudit接口输入参数为:-------------------" + param.toString());
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
if (StrUtil.equals("0", is_connect_mes)) {
|
||||
result.put("status", HttpStatus.OK.value());
|
||||
result.put("message", "下发成功,但未连接飞书!");
|
||||
result.put("data", new JSONObject());
|
||||
return result;
|
||||
}
|
||||
|
||||
// String url = acsUrl + api;
|
||||
String url = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("FEISHU_URL").getValue();
|
||||
String api = "/FeiShuNoticesWebApi/CreateApproval";
|
||||
url = url + api;
|
||||
|
||||
try {
|
||||
String resultMsg = HttpRequest.post(url)
|
||||
.body(String.valueOf(param))
|
||||
.execute().body();
|
||||
result = JSONObject.parseObject(resultMsg);
|
||||
log.info("scrapAudit接口输出参数为:-------------------" + result.toString());
|
||||
|
||||
|
||||
String RTYPE = result.getString("RTYPE");
|
||||
if (RTYPE.equals("E")) {
|
||||
throw new BadRequestException(result.getString("RTMSG"));
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException("飞书提示错误:" + e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.nl.wms.pda.mps.service.impl.BakingServiceImpl;
|
||||
import org.nl.wms.sch.manage.AbstractAcsTask;
|
||||
import org.nl.wms.sch.tasks.CoolCutTask;
|
||||
import org.nl.wms.st.inbill.service.CheckOutBillService;
|
||||
import org.nl.wms.st.instor.service.impl.ProductScrapServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -1358,9 +1359,44 @@ public class MesToLmsServiceImpl implements MesToLmsService {
|
||||
|
||||
@Override
|
||||
public JSONObject sendAuditResult(JSONObject param) {
|
||||
String instance_code = param.getString("instance_code");
|
||||
//0-不通过;1-通过;
|
||||
String result = param.getString("result");
|
||||
return null;
|
||||
log.info("sendAuditResult接口输入参数为:-------------------" + param.toString());
|
||||
|
||||
WQLObject mst = WQLObject.getWQLObject("ST_IVT_ProductScrapMst");
|
||||
JSONObject resultParam = new JSONObject();
|
||||
|
||||
try {
|
||||
String instance_code = param.getString("instance_code");
|
||||
//0-不通过;1-通过;
|
||||
String result = param.getString("result");
|
||||
|
||||
if (ObjectUtil.isEmpty(instance_code)) throw new BadRequestException("参数instance_code不能为空");
|
||||
if (ObjectUtil.isEmpty(result)) throw new BadRequestException("参数result不能为空");
|
||||
|
||||
JSONObject json = mst.query("ext_code = '" + instance_code + "' and bill_status = '20'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(json)) throw new BadRequestException("未找到对应单据或已经完成!");
|
||||
|
||||
// 调用接口
|
||||
ProductScrapServiceImpl bean = SpringContextHolder.getBean(ProductScrapServiceImpl.class);
|
||||
|
||||
if (result.equals("0")) {
|
||||
bean.auditOut(json);
|
||||
} else {
|
||||
bean.auditPass(json);
|
||||
}
|
||||
|
||||
resultParam.put("RTYPE", "S");
|
||||
resultParam.put("Code", "0");
|
||||
resultParam.put("RTMSG", "操作成功!");
|
||||
System.out.println(resultParam);
|
||||
|
||||
} catch (Exception e) {
|
||||
resultParam.put("RTYPE", "E");
|
||||
resultParam.put("Code", "1");
|
||||
resultParam.put("RTMSG", "操作失败!," + e.getMessage());
|
||||
System.out.println(resultParam);
|
||||
}
|
||||
|
||||
log.info("sendAuditResult接口输出参数为:-------------------" + resultParam.toString());
|
||||
return resultParam;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,4 +76,12 @@ public class ProductScrapController {
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PostMapping("/onSubmit")
|
||||
@Log("提交")
|
||||
@ApiOperation("提交")
|
||||
public ResponseEntity<Object> onSubmit(@RequestBody JSONObject whereJson) {
|
||||
productScrapService.onSubmit(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,4 +49,10 @@ public interface ProductScrapService {
|
||||
* @param whereJson /
|
||||
*/
|
||||
void auditOut(JSONObject whereJson);
|
||||
|
||||
/**
|
||||
* 提交
|
||||
* @param whereJson /
|
||||
*/
|
||||
void onSubmit(JSONObject whereJson);
|
||||
}
|
||||
|
||||
@@ -16,10 +16,15 @@ import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.nl.system.service.user.ISysUserService;
|
||||
import org.nl.system.service.user.dao.SysUser;
|
||||
import org.nl.wms.basedata.st.service.impl.UserStorServiceImpl;
|
||||
import org.nl.wms.ext.mes.service.impl.LmsToMesServiceImpl;
|
||||
import org.nl.wms.st.inbill.service.CheckOutBillService;
|
||||
import org.nl.wms.st.instor.service.ProductScrapService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -38,6 +43,9 @@ import java.util.stream.Collectors;
|
||||
public class ProductScrapServiceImpl implements ProductScrapService {
|
||||
private final CheckOutBillService checkOutBillService;
|
||||
|
||||
@Autowired
|
||||
private ISysUserService iSysUserService;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> pageQuery(Map whereJson, Pageable page) {
|
||||
HashMap<String, String> map = new HashMap<>(whereJson);
|
||||
@@ -284,4 +292,150 @@ public class ProductScrapServiceImpl implements ProductScrapService {
|
||||
mst.update(param,"scrap_id = '"+whereJson.getString("scrap_id")+"'");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void onSubmit(JSONObject whereJson) {
|
||||
WQLObject mst = WQLObject.getWQLObject("ST_IVT_ProductScrapMst");
|
||||
WQLObject dtl = WQLObject.getWQLObject("st_ivt_productscrapdtl");
|
||||
WQLObject sub = WQLObject.getWQLObject("pdm_bi_subpackagerelation");
|
||||
|
||||
List<JSONObject> dtlList = dtl.query("scrap_id = '" + whereJson.getString("scrap_id") + "'").getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||
|
||||
String package_box_in = dtlList.stream()
|
||||
.map(row -> row.getString("package_box_sn"))
|
||||
.distinct()
|
||||
.collect(Collectors.joining("','"));
|
||||
|
||||
// 子卷包装集合
|
||||
List<JSONObject> boxList = sub.query("package_box_sn in ('" + package_box_in + "')").getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||
|
||||
// 组织数据
|
||||
JSONObject param = new JSONObject(); // 主体
|
||||
param.put("approval_code", "E41632DA-E7BF-4230-B818-760FBFA0EB72"); // 固定值
|
||||
param.put("system", "LMS"); // 固定值
|
||||
|
||||
/*
|
||||
* 当前操作人员
|
||||
*/
|
||||
JSONArray userList = new JSONArray();
|
||||
JSONObject userJson = new JSONObject();
|
||||
|
||||
SysUser userDao = iSysUserService.getById(SecurityUtils.getCurrentUserId());
|
||||
userJson.put("User", userDao.getUsername()); // 当前操作人员code
|
||||
userList.add(userJson);
|
||||
|
||||
param.put("UserList", userList);
|
||||
|
||||
/*
|
||||
* form
|
||||
*/
|
||||
JSONArray formList = new JSONArray();
|
||||
|
||||
// 报废日期: 年月日时分
|
||||
JSONObject jsonDate = new JSONObject();
|
||||
jsonDate.put("id", "widget16989785636210001"); // 固定值
|
||||
jsonDate.put("type", "input"); // 固定值
|
||||
jsonDate.put("value", DateUtil.now().substring(0, 16));
|
||||
formList.add(jsonDate);
|
||||
|
||||
// 报废明细
|
||||
JSONObject jsonDtl = new JSONObject();
|
||||
jsonDtl.put("id", "widget16989759925050001"); // 固定值
|
||||
jsonDtl.put("type", "fieldList"); // 固定值
|
||||
|
||||
JSONArray valueArr = new JSONArray();
|
||||
|
||||
for (int i = 0; i < dtlList.size(); i++) {
|
||||
JSONObject json = dtlList.get(i);
|
||||
JSONArray dtlAtt = new JSONArray();
|
||||
|
||||
JSONObject jsonBox = boxList.stream()
|
||||
.filter(row -> row.getString("container_name").equals(json.getString("pcsn")))
|
||||
.collect(Collectors.toList()).get(0);
|
||||
|
||||
if (ObjectUtil.isEmpty(jsonBox)) throw new BadRequestException("子卷"+json.getString("pcsn")+"不存在,请检查!");
|
||||
|
||||
// 产品名称
|
||||
JSONObject jsonName = new JSONObject();
|
||||
jsonName.put("id","widget16989761117830001");// 固定值
|
||||
jsonName.put("type","input");// 固定值
|
||||
jsonName.put("value",jsonBox.getString("product_description"));
|
||||
dtlAtt.add(jsonName);
|
||||
|
||||
// 产品规格
|
||||
JSONObject jsonThick = new JSONObject();
|
||||
jsonThick.put("id", "widget16989764299770001");// 固定值
|
||||
jsonThick.put("type", "input");// 固定值
|
||||
jsonThick.put("value", jsonBox.getString("thickness"));
|
||||
dtlAtt.add(jsonThick);
|
||||
|
||||
// 不合格品批次号
|
||||
JSONObject jsonOut = new JSONObject();
|
||||
jsonOut.put("id","widget16989764601080001");// 固定值
|
||||
jsonOut.put("type","input");// 固定值
|
||||
jsonOut.put("value",jsonBox.getString("container_name"));
|
||||
dtlAtt.add(jsonOut);
|
||||
|
||||
// 不合格品重量
|
||||
JSONObject jsonWeight = new JSONObject();
|
||||
jsonWeight.put("id", "widget16989773376540001");
|
||||
jsonWeight.put("type", "number");
|
||||
jsonWeight.put("value", json.getDoubleValue("qty"));
|
||||
dtlAtt.add(jsonWeight);
|
||||
|
||||
// 不合格品缺陷描述
|
||||
JSONObject jsonRemark = new JSONObject();
|
||||
jsonRemark.put("id", "widget16989773089460001");// 固定值
|
||||
jsonRemark.put("type", "input");// 固定值
|
||||
jsonRemark.put("value", json.getString("remark"));
|
||||
dtlAtt.add(jsonRemark);
|
||||
|
||||
// 不合格品来源
|
||||
JSONObject jsonSource = new JSONObject();
|
||||
jsonSource.put("id", "widget16989785808620001");
|
||||
jsonSource.put("type", "radioV2");
|
||||
|
||||
switch (json.getString("fail_source")) {
|
||||
case "1" :
|
||||
jsonSource.put("value", "lohzzb0f-dxucmbtkt5j-0");
|
||||
break;
|
||||
case "2" :
|
||||
jsonSource.put("value", "lohzzb0f-728pkzd3t0b-0");
|
||||
break;
|
||||
case "3" :
|
||||
jsonSource.put("value", "lohzzb0f-2d3n1nt9t5x-0");
|
||||
break;
|
||||
case "4" :
|
||||
jsonSource.put("value", "lohzzmz1-ai6w4202ynw-1");
|
||||
break;
|
||||
case "5" :
|
||||
jsonSource.put("value", "lohzzmz1-2d02yqh91t1-3");
|
||||
break;
|
||||
case "6" :
|
||||
jsonSource.put("value", "lohzzmz1-d0j15ri1jyg-5");
|
||||
break;
|
||||
}
|
||||
dtlAtt.add(jsonSource);
|
||||
|
||||
valueArr.add(dtlAtt);
|
||||
}
|
||||
|
||||
jsonDtl.put("value", valueArr);
|
||||
formList.add(jsonDtl);
|
||||
|
||||
param.put("form", formList);
|
||||
|
||||
/*
|
||||
* 调用mes接口,更新单据
|
||||
*/
|
||||
LmsToMesServiceImpl bean = SpringContextHolder.getBean(LmsToMesServiceImpl.class);
|
||||
JSONObject result = bean.scrapAudit(param);
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("ext_code", result.getString("RTDAT"));
|
||||
jsonObject.put("bill_status", "20");
|
||||
mst.update(jsonObject,"scrap_id = '"+whereJson.getString("scrap_id")+"'");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user