|
|
@@ -492,22 +492,40 @@ public class MesProductRepairController extends BaseController {
|
|
|
@ResponseBody
|
|
|
public CommonResp wxSnDetail(HttpServletRequest req) {
|
|
|
String sn = req.getParameter("sn");
|
|
|
+ if(StringUtils.isEmpty(sn)){
|
|
|
+ CommonResp<MesProductRepair> emptyResp = new CommonResp<>();
|
|
|
+ emptyResp.setResult(Global.FALSE);
|
|
|
+ emptyResp.setMessage("工件码不能为空");
|
|
|
+ return emptyResp;
|
|
|
+ }
|
|
|
sn = mesProductHmbService.formatHmbSn(sn);
|
|
|
|
|
|
MesProductRepair mpr = new MesProductRepair();
|
|
|
mpr.setSn(sn);
|
|
|
- mpr.getSqlMap().getOrder().setOrderBy("a.id desc");
|
|
|
+ mpr.setState("0");
|
|
|
+ mpr.getSqlMap().getOrder().setOrderBy("a.update_date DESC, a.id DESC");
|
|
|
MesProductRepair mesProductRepair = mesProductRepairService.findInfo(mpr);
|
|
|
CommonResp<MesProductRepair> resp = new CommonResp<>();
|
|
|
if(ObjectUtils.isEmpty(mesProductRepair)){
|
|
|
+ MesProductRepair latestQuery = new MesProductRepair();
|
|
|
+ latestQuery.setSn(sn);
|
|
|
+ latestQuery.getSqlMap().getOrder().setOrderBy("a.update_date DESC, a.id DESC");
|
|
|
+ MesProductRepair latestRepair = mesProductRepairService.findInfo(latestQuery);
|
|
|
+ if(ObjectUtils.isEmpty(latestRepair)){
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
+ resp.setMessage("记录不存在");
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
resp.setResult(Global.FALSE);
|
|
|
- resp.setMessage("记录不存在");
|
|
|
- return resp;
|
|
|
- }
|
|
|
-
|
|
|
- if(!mesProductRepair.getState().equals("0")){
|
|
|
- resp.setResult(Global.FALSE);
|
|
|
- resp.setMessage("该工件已处理");
|
|
|
+ if("1".equals(latestRepair.getState())){
|
|
|
+ resp.setMessage("该工件已维修,待审核");
|
|
|
+ }else if("2".equals(latestRepair.getState())){
|
|
|
+ resp.setMessage("该工件已完成返修审核");
|
|
|
+ }else if("3".equals(latestRepair.getState())){
|
|
|
+ resp.setMessage("该工件不可返修");
|
|
|
+ }else{
|
|
|
+ resp.setMessage("该工件无待维修记录");
|
|
|
+ }
|
|
|
return resp;
|
|
|
}
|
|
|
|
|
|
@@ -643,30 +661,53 @@ public class MesProductRepairController extends BaseController {
|
|
|
// @RequiresPermissions("mes:mesProductRepair:apiwx")
|
|
|
@RequestMapping(value = "wxSave")
|
|
|
@ResponseBody
|
|
|
+ @Transactional
|
|
|
public CommonResp wxSave(MesProductRepair mesProductRepair,HttpServletRequest req) {
|
|
|
CommonResp<String> resp = new CommonResp<>();
|
|
|
- if(ObjectUtils.isEmpty(mesProductRepair)){
|
|
|
+ if(ObjectUtils.isEmpty(mesProductRepair) || StringUtils.isEmpty(mesProductRepair.getId())){
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
+ resp.setMessage("返修单编号不能为空");
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+ MesProductRepair currentRepair = mesProductRepairService.get(mesProductRepair.getId());
|
|
|
+ if(ObjectUtils.isEmpty(currentRepair)){
|
|
|
resp.setResult(Global.FALSE);
|
|
|
resp.setMessage("记录不存在");
|
|
|
return resp;
|
|
|
}
|
|
|
|
|
|
- if(!mesProductRepair.getState().equals("0")){
|
|
|
+ if(!"0".equals(currentRepair.getState())){
|
|
|
resp.setResult(Global.FALSE);
|
|
|
resp.setMessage("已提交返修记录");
|
|
|
return resp;
|
|
|
}
|
|
|
|
|
|
- mesProductRepair.setRepairBy(UserUtils.getUser().getUserCode());
|
|
|
- mesProductRepair.setRepairDate(new Date());
|
|
|
- mesProductRepair.setState("1");
|
|
|
- mesProductRepairService.update(mesProductRepair);
|
|
|
+ if(StringUtils.isEmpty(currentRepair.getType())
|
|
|
+ || (!currentRepair.getType().equals("1") && !currentRepair.getType().equals("2"))){
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
+ resp.setMessage("返修类型异常");
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+ currentRepair.setRepairBy(UserUtils.getUser().getUserCode());
|
|
|
+ currentRepair.setRepairDate(new Date());
|
|
|
+ currentRepair.setState("1");
|
|
|
+ if(!StringUtils.isEmpty(mesProductRepair.getRepairRemark())){
|
|
|
+ currentRepair.setRepairRemark(mesProductRepair.getRepairRemark());
|
|
|
+ }
|
|
|
+ mesProductRepairService.update(currentRepair);
|
|
|
// 保存上传图片
|
|
|
- FileUploadUtils.saveFileUpload(mesProductRepair, mesProductRepair.getId(), "mesProductRepairWx_image");
|
|
|
- MesProductRepairQuality mesProductRepairQuality = new MesProductRepairQuality();
|
|
|
- mesProductRepairQuality.setRepairId(mesProductRepair.getId());
|
|
|
- mesProductRepairQuality.setCreateBy("xunjian_j7uo");
|
|
|
- mesProductRepairQualityService.insert(mesProductRepairQuality);
|
|
|
+ FileUploadUtils.saveFileUpload(currentRepair, currentRepair.getId(), "mesProductRepairWx_image");
|
|
|
+ MesProductRepairQuality qualityQuery = new MesProductRepairQuality();
|
|
|
+ qualityQuery.setRepairId(currentRepair.getId());
|
|
|
+ MesProductRepairQuality mesProductRepairQuality = mesProductRepairQualityService.findInfo(qualityQuery);
|
|
|
+ if(ObjectUtils.isEmpty(mesProductRepairQuality)){
|
|
|
+ mesProductRepairQuality = new MesProductRepairQuality();
|
|
|
+ mesProductRepairQuality.setRepairId(currentRepair.getId());
|
|
|
+ mesProductRepairQuality.setCreateBy(UserUtils.getUser().getUserCode());
|
|
|
+ mesProductRepairQualityService.insert(mesProductRepairQuality);
|
|
|
+ }
|
|
|
resp.setMessage("操作成功");
|
|
|
resp.setResult(Global.TRUE);
|
|
|
return resp;
|