|
@@ -6,9 +6,12 @@ import java.nio.file.Files;
|
|
|
import java.nio.file.Path;
|
|
import java.nio.file.Path;
|
|
|
import java.nio.file.Paths;
|
|
import java.nio.file.Paths;
|
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
+import com.jeesite.modules.mes.entity.MesProductRecord;
|
|
|
import com.jeesite.modules.mes.resp.CommonResp;
|
|
import com.jeesite.modules.mes.resp.CommonResp;
|
|
|
|
|
+import com.jeesite.modules.mes.util.CommonUitl;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -37,6 +40,9 @@ public class MesProductGp12Service extends CrudService<MesProductGp12Dao, MesPro
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private MesProductGp12Dao mesProductGp12Dao;
|
|
private MesProductGp12Dao mesProductGp12Dao;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private MesProductRecordService mesProductRecordService;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 获取单条数据
|
|
* 获取单条数据
|
|
|
* @param mesProductGp12
|
|
* @param mesProductGp12
|
|
@@ -257,8 +263,68 @@ public class MesProductGp12Service extends CrudService<MesProductGp12Dao, MesPro
|
|
|
super.save(entry);
|
|
super.save(entry);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 正反面都已提交时,更新主结果表为 OK;不存在则新建
|
|
|
|
|
+ try {
|
|
|
|
|
+ updateMainResultIfBothPhotoDone(sn, oprno, mesProductGp12.getLineSn());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ logger.error("更新主结果记录失败 sn={}, oprno={}", sn, oprno, e);
|
|
|
|
|
+ // 主结果更新失败不影响图片上传成功响应
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
resp.setResult(Global.TRUE);
|
|
resp.setResult(Global.TRUE);
|
|
|
resp.setMessage("上传成功");
|
|
resp.setMessage("上传成功");
|
|
|
return resp;
|
|
return resp;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 正反面都已提交时,将工位 craft=100000 主结果置为 OK;如果记录不存在则新建一条
|
|
|
|
|
+ */
|
|
|
|
|
+ private void updateMainResultIfBothPhotoDone(String sn, String oprno, String lineSn) {
|
|
|
|
|
+ // 重新查最新的合并状态
|
|
|
|
|
+ MesProductGp12 q = new MesProductGp12();
|
|
|
|
|
+ q.setSn(sn);
|
|
|
|
|
+ q.setOprno(oprno);
|
|
|
|
|
+ MesProductGp12 latest = mesProductGp12Dao.findInfo(q);
|
|
|
|
|
+ if (latest == null) return;
|
|
|
|
|
+
|
|
|
|
|
+ Integer pf = latest.getPhotoF();
|
|
|
|
|
+ Integer pz = latest.getPhotoZ();
|
|
|
|
|
+ if (pf == null || pz == null || pf != 1 || pz != 1) {
|
|
|
|
|
+ return; // 还没都拍齐
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 主结果表的 oprno 一律用 5 位格式化值
|
|
|
|
|
+ String oprnoFmt = CommonUitl.formatOprno(oprno);
|
|
|
|
|
+ String userCode = "system";
|
|
|
|
|
+ String cateSn = "XT";
|
|
|
|
|
+
|
|
|
|
|
+ MesProductRecord record = mesProductRecordService.findByUpdateCate(sn, oprnoFmt, "100000", lineSn);
|
|
|
|
|
+ if (record != null) {
|
|
|
|
|
+ // 已是 OK 跳过 update(不刷 update_date)
|
|
|
|
|
+ if ("OK".equalsIgnoreCase(record.getContent())) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ record.setContent("OK");
|
|
|
|
|
+ record.setSource("0");
|
|
|
|
|
+ record.setUpdateBy(userCode);
|
|
|
|
|
+ mesProductRecordService.save(record);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 不存在则新建
|
|
|
|
|
+ MesProductRecord r = new MesProductRecord();
|
|
|
|
|
+ r.setSn(sn);
|
|
|
|
|
+ r.setOprno(oprnoFmt);
|
|
|
|
|
+ r.setCraft("100000");
|
|
|
|
|
+ r.setLineSn(lineSn);
|
|
|
|
|
+ r.setCateSn(cateSn);
|
|
|
|
|
+ r.setPid("0");
|
|
|
|
|
+ r.setSerial(390);
|
|
|
|
|
+ r.setTid("");
|
|
|
|
|
+ r.setCdate(Long.valueOf(CommonUitl.Date2TimeStamp(new Date())));
|
|
|
|
|
+ r.setContent("OK");
|
|
|
|
|
+ r.setSource("0");
|
|
|
|
|
+ r.setCreateBy(userCode);
|
|
|
|
|
+ r.setUpdateBy(userCode);
|
|
|
|
|
+ mesProductRecordService.save(r);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|