|
@@ -1,17 +1,171 @@
|
|
|
package com.rongwei.bscommon.sys.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.rongwei.bscommon.sys.dao.ApsReportOutputDao;
|
|
|
+import com.rongwei.bscommon.sys.service.ApsProcessOperationOutMaterService;
|
|
|
+import com.rongwei.bscommon.sys.service.ApsReportRecordsService;
|
|
|
+import com.rongwei.bscommon.sys.utils.QRCodeGenerator;
|
|
|
+import com.rongwei.bsentity.domain.ApsProcessOperationOutMaterDo;
|
|
|
import com.rongwei.bsentity.domain.ApsReportOutputDo;
|
|
|
+import com.rongwei.bsentity.domain.ApsReportRecordsDo;
|
|
|
+import com.rongwei.bsentity.vo.InsertMyReportOutputReq;
|
|
|
+import com.rongwei.rwcommon.base.R;
|
|
|
+import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
|
+import com.rongwei.rwcommonentity.commonservers.vo.SysSerialVo;
|
|
|
+import com.rongwei.safecommon.fegin.CXAdminFeginClient;
|
|
|
+import com.rongwei.safecommon.utils.CXCommonUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.rongwei.bscommon.sys.service.ApsReportOutputService;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.LinkedList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
*/
|
|
|
@Service
|
|
|
public class ApsReportOutputServiceImpl extends ServiceImpl<ApsReportOutputDao, ApsReportOutputDo>
|
|
|
implements ApsReportOutputService {
|
|
|
+ @Autowired
|
|
|
+ private ApsProcessOperationOutMaterService apsProcessOperationOutMaterService;
|
|
|
+ @Resource
|
|
|
+ private CXAdminFeginClient cxAdminFeginClient;
|
|
|
+ @Autowired
|
|
|
+ private ApsReportRecordsService apsReportRecordsService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R insertMyReportOutput(InsertMyReportOutputReq req) {
|
|
|
+ //最终新增的子表数据
|
|
|
+ List<ApsReportOutputDo> resList = new LinkedList<>();
|
|
|
+
|
|
|
+ //查询工序作业输出物料子表信息
|
|
|
+ List<ApsProcessOperationOutMaterDo> list = apsProcessOperationOutMaterService.list(new QueryWrapper<ApsProcessOperationOutMaterDo>().lambda().eq(ApsProcessOperationOutMaterDo::getMainid, req.getProcessId()));
|
|
|
+
|
|
|
+ if (req.getIfBlankProcess().equals("是")) {
|
|
|
+ if (req.getBlankType().equals("铸轧")) {
|
|
|
+ for (ApsProcessOperationOutMaterDo apsProcessOperationOutMaterDo : list) {
|
|
|
+ int outval = apsProcessOperationOutMaterDo.getOutval();
|
|
|
+
|
|
|
+ for (int i = 1; i <= outval; i++) {
|
|
|
+ //插入记录物料子表
|
|
|
+ ApsReportOutputDo apsReportOutputDo = new ApsReportOutputDo();
|
|
|
+
|
|
|
+ apsReportOutputDo.setMainid(req.getMainId());
|
|
|
+ apsReportOutputDo.setOutputid(apsProcessOperationOutMaterDo.getId());
|
|
|
+ apsReportOutputDo.setOutputmaterial(apsProcessOperationOutMaterDo.getOutputmaterial());
|
|
|
+ //生成批次号
|
|
|
+ SysSerialVo vo = new SysSerialVo();
|
|
|
+ vo.setModulecode("aps_report_output_" + req.getDeviceId());
|
|
|
+ vo.setRuleTemplateStr(req.getMark() + req.getYearCode() + req.getMonthCode() + req.getEquipmentCode() + req.getCodeRule());
|
|
|
+ vo.setResetrule("date:yyyyMM");
|
|
|
+ vo.setIfautomaticreset("y");
|
|
|
+ vo.setInitValue(0L);
|
|
|
+ Map<String, Object> codeData = cxAdminFeginClient.getSerialNumberCode(vo).getData();
|
|
|
+ String code = codeData.get("code").toString();
|
|
|
+
|
|
|
+ apsReportOutputDo.setOutputnumber(code);
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("batchNumber", code);
|
|
|
+ //生成二维码
|
|
|
+ String qrCode = QRCodeGenerator.stringToQRCodeBase64(json.toJSONString(), 120, 120, "png");
|
|
|
+ apsReportOutputDo.setQrcode(qrCode);
|
|
|
+ apsReportOutputDo.setId(SecurityUtil.getUUID());
|
|
|
+ resList.add(apsReportOutputDo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (req.getBlankType().equals("热轧")) {
|
|
|
+ for (ApsProcessOperationOutMaterDo apsProcessOperationOutMaterDo : list) {
|
|
|
+ int outval = apsProcessOperationOutMaterDo.getOutval();
|
|
|
+ for (int i = 1; i <= outval; i++) {
|
|
|
+ //插入记录物料子表
|
|
|
+ ApsReportOutputDo apsReportOutputDo = new ApsReportOutputDo();
|
|
|
+ apsReportOutputDo.setId(SecurityUtil.getUUID());
|
|
|
+ apsReportOutputDo.setMainid(req.getMainId());
|
|
|
+ apsReportOutputDo.setOutputid(apsProcessOperationOutMaterDo.getId());
|
|
|
+ apsReportOutputDo.setOutputmaterial(apsProcessOperationOutMaterDo.getOutputmaterial());
|
|
|
+ //生成批次号
|
|
|
+ String code = req.getMark() + req.getYearCode() + req.getMonthCode() + req.getEquipmentCode() + req.getHeatNumber() + i;
|
|
|
+ apsReportOutputDo.setOutputnumber(code);
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("batchNumber", code);
|
|
|
+ //生成二维码
|
|
|
+ String qrCode = QRCodeGenerator.stringToQRCodeBase64(json.toJSONString(), 120, 120, "png");
|
|
|
+ apsReportOutputDo.setQrcode(qrCode);
|
|
|
+ resList.add(apsReportOutputDo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (req.getIfBlankProcess().equals("否")) {
|
|
|
+ //如果输出物料数量=1,并且单卷输出数量=1,批次号不变
|
|
|
+ if (list.size() == 1 && list.get(0).getOutval() == 1) {
|
|
|
+ //插入记录物料子表
|
|
|
+ ApsReportOutputDo apsReportOutputDo = new ApsReportOutputDo();
|
|
|
+ apsReportOutputDo.setId(SecurityUtil.getUUID());
|
|
|
+ apsReportOutputDo.setMainid(req.getMainId());
|
|
|
+ apsReportOutputDo.setOutputid(list.get(0).getId());
|
|
|
+ apsReportOutputDo.setOutputmaterial(list.get(0).getOutputmaterial());
|
|
|
+ apsReportOutputDo.setOutputnumber(req.getInputBatchNumber());
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("batchNumber", req.getInputBatchNumber());
|
|
|
+ //生成二维码
|
|
|
+ String qrCode = QRCodeGenerator.stringToQRCodeBase64(json.toJSONString(), 120, 120, "png");
|
|
|
+ apsReportOutputDo.setQrcode(qrCode);
|
|
|
+ resList.add(apsReportOutputDo);
|
|
|
+ } else {//输出物料数量>1,或者单卷输出数量>1
|
|
|
+ for (ApsProcessOperationOutMaterDo apsProcessOperationOutMaterDo : list) {
|
|
|
+ int outval = apsProcessOperationOutMaterDo.getOutval();
|
|
|
+ for (int i = 1; i <= outval; i++) {
|
|
|
+ //插入记录物料子表
|
|
|
+ ApsReportOutputDo apsReportOutputDo = new ApsReportOutputDo();
|
|
|
+
|
|
|
+ apsReportOutputDo.setMainid(req.getMainId());
|
|
|
+ apsReportOutputDo.setOutputid(apsProcessOperationOutMaterDo.getId());
|
|
|
+ apsReportOutputDo.setOutputmaterial(apsProcessOperationOutMaterDo.getOutputmaterial());
|
|
|
+ //生成批次号
|
|
|
+ //生成批次号
|
|
|
+ SysSerialVo vo = new SysSerialVo();
|
|
|
+ vo.setModulecode("aps_report_output_" + req.getInputBatchNumber().split("-")[0]);
|
|
|
+ vo.setRuleTemplateStr(req.getInputBatchNumber().split("-")[0] + "-" + req.getCodeRule());
|
|
|
+ vo.setResetrule("date:yyyyMM");
|
|
|
+ vo.setIfautomaticreset("y");
|
|
|
+ vo.setInitValue(0L);
|
|
|
+ Map<String, Object> codeData = cxAdminFeginClient.getSerialNumberCode(vo).getData();
|
|
|
+ String code = codeData.get("code").toString();
|
|
|
+
|
|
|
+ apsReportOutputDo.setOutputnumber(code);
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("batchNumber", code);
|
|
|
+ //生成二维码
|
|
|
+ String qrCode = QRCodeGenerator.stringToQRCodeBase64(json.toJSONString(), 120, 120, "png");
|
|
|
+ apsReportOutputDo.setQrcode(qrCode);
|
|
|
+
|
|
|
+ apsReportOutputDo.setId(SecurityUtil.getUUID());
|
|
|
+ resList.add(apsReportOutputDo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //插入子表
|
|
|
+ this.saveBatch(resList);
|
|
|
|
|
|
+ //更新主表中的待检验批次号
|
|
|
+ List<String> batchNumberList = resList.stream().map(ApsReportOutputDo::getOutputnumber).collect(Collectors.toList());
|
|
|
+ String batchNumbers = String.join(",", batchNumberList);
|
|
|
+ ApsReportRecordsDo apsReportRecordsDo = new ApsReportRecordsDo();
|
|
|
+ apsReportRecordsDo.setId(req.getMainId());
|
|
|
+ apsReportRecordsDo.setNeedcheckbatchnumber(batchNumbers);
|
|
|
+ apsReportRecordsService.updateById(apsReportRecordsDo);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|