|
@@ -0,0 +1,390 @@
|
|
|
|
|
+package com.jeesite.modules.mes.service;
|
|
|
|
|
+
|
|
|
|
|
+import com.jeesite.common.collect.ListUtils;
|
|
|
|
|
+import com.jeesite.common.config.Global;
|
|
|
|
|
+import com.jeesite.common.entity.Page;
|
|
|
|
|
+import com.jeesite.common.lang.ObjectUtils;
|
|
|
|
|
+import com.jeesite.common.service.CrudService;
|
|
|
|
|
+import com.jeesite.common.service.ServiceException;
|
|
|
|
|
+import com.jeesite.common.utils.excel.ExcelImport;
|
|
|
|
|
+import com.jeesite.common.validator.ValidatorUtils;
|
|
|
|
|
+import com.jeesite.modules.file.utils.FileUploadUtils;
|
|
|
|
|
+import com.jeesite.modules.mes.dao.MesProductModifyDao;
|
|
|
|
|
+import com.jeesite.modules.mes.entity.*;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
+
|
|
|
|
|
+import javax.validation.ConstraintViolation;
|
|
|
|
|
+import javax.validation.ConstraintViolationException;
|
|
|
|
|
+import java.util.Date;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 工件码更换记录Service
|
|
|
|
|
+ * @author hzd
|
|
|
|
|
+ * @version 2025-11-15
|
|
|
|
|
+ */
|
|
|
|
|
+@Service
|
|
|
|
|
+public class MesProductModifyService extends CrudService<MesProductModifyDao, MesProductModify> {
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private MesProductService mesProductService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private MesProductRecordService mesProductRecordService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private MesProductModifyRecordService mesProductModifyRecordService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private MesProductQmService mesProductQmService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private MesProductCcdService mesProductCcdService;
|
|
|
|
|
+
|
|
|
|
|
+// @Autowired
|
|
|
|
|
+// private MesProductCcdFileService mesProductCcdFileService;
|
|
|
|
|
+//
|
|
|
|
|
+// @Autowired
|
|
|
|
|
+// private MesProductInsulation2Service mesProductInsulation2Service;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private MesProductProdService mesProductProdService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private MesProductYgslService mesProductYgslService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private MesDeviceTimeService mesDeviceTimeService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private MesTorsionalProcessService mesTorsionalProcessService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private MesProductCmtService mesProductCmtService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private MesProductGp12Service mesProductGp12Service;
|
|
|
|
|
+
|
|
|
|
|
+// @Autowired
|
|
|
|
|
+// private MesOp290PhotoService mesOp290PhotoService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private MesProductCcService mesProductCcService;
|
|
|
|
|
+
|
|
|
|
|
+// @Autowired
|
|
|
|
|
+// private MesProductHelperService mesProductHelperService;
|
|
|
|
|
+//
|
|
|
|
|
+// @Autowired
|
|
|
|
|
+// private MesProductFxdingService mesProductFxdingService;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取单条数据
|
|
|
|
|
+ * @param mesProductModify
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public MesProductModify get(MesProductModify mesProductModify) {
|
|
|
|
|
+ return super.get(mesProductModify);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询分页数据
|
|
|
|
|
+ * @param mesProductModify 查询条件
|
|
|
|
|
+ * @param mesProductModify.page 分页对象
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Page<MesProductModify> findPage(MesProductModify mesProductModify) {
|
|
|
|
|
+ return super.findPage(mesProductModify);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询列表数据
|
|
|
|
|
+ * @param mesProductModify
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<MesProductModify> findList(MesProductModify mesProductModify) {
|
|
|
|
|
+ return super.findList(mesProductModify);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 保存数据(插入或更新)
|
|
|
|
|
+ * @param mesProductModify
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional
|
|
|
|
|
+ public void save(MesProductModify mesProductModify) {
|
|
|
|
|
+ MesProduct mesProduct = new MesProduct();
|
|
|
|
|
+ mesProduct.setSn(mesProductModify.getSn());
|
|
|
|
|
+ MesProduct mesProduct1 = mesProductService.findInfo2(mesProduct);
|
|
|
|
|
+ String sn = mesProductModify.getSn();
|
|
|
|
|
+ String newsn = mesProductModify.getNewsn();
|
|
|
|
|
+ if(!ObjectUtils.isEmpty(mesProduct1)) {
|
|
|
|
|
+ mesProductModify.setOldDate(mesProduct1.getCreateDate());
|
|
|
|
|
+ mesProductModify.setModifyDate(new Date());
|
|
|
|
|
+ super.save(mesProductModify);
|
|
|
|
|
+
|
|
|
|
|
+ // 保存上传图片
|
|
|
|
|
+ FileUploadUtils.saveFileUpload(mesProductModify, mesProductModify.getId(), "mesProductModify_image");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // 更新产品表
|
|
|
|
|
+ mesProduct1.setSn(newsn);
|
|
|
|
|
+ mesProductService.updateDate(mesProduct1);
|
|
|
|
|
+ // 更新生产记录表
|
|
|
|
|
+ MesProductRecord mesProductRecord = new MesProductRecord();
|
|
|
|
|
+ mesProductRecord.setSn(sn);
|
|
|
|
|
+ mesProductRecord.getSqlMap().getOrder().setOrderBy("a.oprno ASC,a.craft ASC");
|
|
|
|
|
+ List<MesProductRecord> lists = mesProductRecordService.findList(mesProductRecord);
|
|
|
|
|
+ if(!ListUtils.isEmpty(lists)) {
|
|
|
|
|
+ for (MesProductRecord mesProductRecord1 : lists) {
|
|
|
|
|
+ mesProductRecord1.setCreateDate(mesProductRecord1.getCreateDate());
|
|
|
|
|
+ mesProductRecord1.setSn(newsn);
|
|
|
|
|
+ mesProductRecord1.setUpdateDate(mesProductRecord1.getUpdateDate());
|
|
|
|
|
+ mesProductRecordService.updateDate(mesProductRecord1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 更新修改记录
|
|
|
|
|
+ MesProductModifyRecord mesProductModifyRecord = new MesProductModifyRecord();
|
|
|
|
|
+ mesProductModifyRecord.setSn(sn);
|
|
|
|
|
+ List<MesProductModifyRecord> lists2 = mesProductModifyRecordService.findList(mesProductModifyRecord);
|
|
|
|
|
+ if(!ListUtils.isEmpty(lists2)) {
|
|
|
|
|
+ for (MesProductModifyRecord mesProductModifyRecord1 : lists2) {
|
|
|
|
|
+ mesProductModifyRecord1.setSn(newsn);
|
|
|
|
|
+ mesProductModifyRecordService.updateDate(mesProductModifyRecord1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 气密
|
|
|
|
|
+ MesProductQm mesProductQm = new MesProductQm();
|
|
|
|
|
+ mesProductQm.setComponentNum(sn);
|
|
|
|
|
+ List<MesProductQm> lists3 = mesProductQmService.findList(mesProductQm);
|
|
|
|
|
+ if(!ListUtils.isEmpty(lists3)){
|
|
|
|
|
+ for (MesProductQm mesProductQm1:lists3){
|
|
|
|
|
+ mesProductQm1.setComponentNum(newsn);
|
|
|
|
|
+ mesProductQmService.updateDate(mesProductQm1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // CCD
|
|
|
|
|
+ MesProductCcd mesProductCcd = new MesProductCcd();
|
|
|
|
|
+ mesProductCcd.setSn(sn);
|
|
|
|
|
+ List<MesProductCcd> lists4 = mesProductCcdService.findList(mesProductCcd);
|
|
|
|
|
+ if(!ListUtils.isEmpty(lists4)){
|
|
|
|
|
+ for (MesProductCcd mesProductCcd1:lists4){
|
|
|
|
|
+ mesProductCcd1.setSn(newsn);
|
|
|
|
|
+ mesProductCcdService.update(mesProductCcd1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+// MesProductCcdFile mesProductCcdFile = new MesProductCcdFile();
|
|
|
|
|
+// mesProductCcdFile.setSn(sn);
|
|
|
|
|
+// List<MesProductCcdFile> lists44 = mesProductCcdFileService.findList(mesProductCcdFile);
|
|
|
|
|
+// if(!ListUtils.isEmpty(lists44)){
|
|
|
|
|
+// for (MesProductCcdFile mesProductCcdFile1:lists44){
|
|
|
|
|
+// mesProductCcdFile1.setSn(newsn);
|
|
|
|
|
+// mesProductCcdFileService.update(mesProductCcdFile1);
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// //绝缘耐压
|
|
|
|
|
+// MesProductInsulation2 mesProductInsulation2 = new MesProductInsulation2();
|
|
|
|
|
+// mesProductInsulation2.setSn(sn);
|
|
|
|
|
+// List<MesProductInsulation2> lists5 = mesProductInsulation2Service.findList(mesProductInsulation2);
|
|
|
|
|
+// if(!ListUtils.isEmpty(lists5)){
|
|
|
|
|
+// for (MesProductInsulation2 mesProductInsulation21:lists5){
|
|
|
|
|
+// mesProductInsulation21.setSn(newsn);
|
|
|
|
|
+// mesProductInsulation2Service.update(mesProductInsulation21);
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+ //拉铆
|
|
|
|
|
+ MesProductProd mesProductProd = new MesProductProd();
|
|
|
|
|
+ mesProductProd.setSn(sn);
|
|
|
|
|
+ List<MesProductProd> lists6 = mesProductProdService.findList(mesProductProd);
|
|
|
|
|
+ if(!ListUtils.isEmpty(lists6)){
|
|
|
|
|
+ for (MesProductProd mesProductProd1:lists6){
|
|
|
|
|
+ mesProductProd1.setSn(newsn);
|
|
|
|
|
+ mesProductProdService.update(mesProductProd1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //拧紧
|
|
|
|
|
+ MesProductYgsl mesProductYgsl = new MesProductYgsl();
|
|
|
|
|
+ mesProductYgsl.setSn(sn);
|
|
|
|
|
+ List<MesProductYgsl> lists7 = mesProductYgslService.findList(mesProductYgsl);
|
|
|
|
|
+ if(!ListUtils.isEmpty(lists7)){
|
|
|
|
|
+ for (MesProductYgsl mesProductProd1:lists7){
|
|
|
|
|
+ mesProductProd1.setSn(newsn);
|
|
|
|
|
+ mesProductYgslService.update(mesProductProd1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //工位时间
|
|
|
|
|
+ MesDeviceTime mesDeviceTime = new MesDeviceTime();
|
|
|
|
|
+ mesDeviceTime.setSn(sn);
|
|
|
|
|
+ List<MesDeviceTime> lists8 = mesDeviceTimeService.findList(mesDeviceTime);
|
|
|
|
|
+ if(!ListUtils.isEmpty(lists8)){
|
|
|
|
|
+ for (MesDeviceTime mesProductProd1:lists8){
|
|
|
|
|
+ mesProductProd1.setSn(newsn);
|
|
|
|
|
+ mesDeviceTimeService.update(mesProductProd1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //尺寸检测
|
|
|
|
|
+ MesProductCc mesProductCc = new MesProductCc();
|
|
|
|
|
+ mesProductCc.setSn(sn);
|
|
|
|
|
+ List<MesProductCc> lists9 = mesProductCcService.findList(mesProductCc);
|
|
|
|
|
+ if(!ListUtils.isEmpty(lists9)){
|
|
|
|
|
+ for (MesProductCc mesProductProd1:lists9){
|
|
|
|
|
+ mesProductProd1.setSn(newsn);
|
|
|
|
|
+ mesProductCcService.update(mesProductProd1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //拍照
|
|
|
|
|
+ MesProductGp12 mesProductGp12 = new MesProductGp12();
|
|
|
|
|
+ mesProductGp12.setSn(sn);
|
|
|
|
|
+ List<MesProductGp12> lists10 = mesProductGp12Service.findList(mesProductGp12);
|
|
|
|
|
+ if(!ListUtils.isEmpty(lists10)){
|
|
|
|
|
+ for (MesProductGp12 mesProductProd1:lists10){
|
|
|
|
|
+ mesProductProd1.setSn(newsn);
|
|
|
|
|
+ mesProductGp12Service.update(mesProductProd1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+// //拍照
|
|
|
|
|
+// MesOp290Photo mesOp290Photo = new MesOp290Photo();
|
|
|
|
|
+// mesOp290Photo.setSn(sn);
|
|
|
|
|
+// List<MesOp290Photo> lists11 = mesOp290PhotoService.findList(mesOp290Photo);
|
|
|
|
|
+// if(!ListUtils.isEmpty(lists11)){
|
|
|
|
|
+// for (MesOp290Photo mesProductProd1:lists11){
|
|
|
|
|
+// mesProductProd1.setSn(newsn);
|
|
|
|
|
+// mesOp290PhotoService.update(mesProductProd1);
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// //不良审核
|
|
|
|
|
+// MesProductHelper mesProductHelper = new MesProductHelper();
|
|
|
|
|
+// mesProductHelper.setSn(sn);
|
|
|
|
|
+// List<MesProductHelper> lists12 = mesProductHelperService.findList(mesProductHelper);
|
|
|
|
|
+// if(!ListUtils.isEmpty(lists12)){
|
|
|
|
|
+// for (MesProductHelper mesProductProd1:lists12){
|
|
|
|
|
+// mesProductProd1.setSn(newsn);
|
|
|
|
|
+// mesProductHelperService.update(mesProductProd1);
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+ //扭力
|
|
|
|
|
+ MesTorsionalProcess mesTorsionalProcess = new MesTorsionalProcess();
|
|
|
|
|
+ mesTorsionalProcess.setSn(sn);
|
|
|
|
|
+ List<MesTorsionalProcess> lists13 = mesTorsionalProcessService.findList(mesTorsionalProcess);
|
|
|
|
|
+ if(!ListUtils.isEmpty(lists13)){
|
|
|
|
|
+ for (MesTorsionalProcess mesProductProd1:lists13){
|
|
|
|
|
+ mesProductProd1.setSn(newsn);
|
|
|
|
|
+ mesTorsionalProcessService.update(mesProductProd1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //cmt
|
|
|
|
|
+ MesProductCmt mesProductCmt = new MesProductCmt();
|
|
|
|
|
+ mesProductCmt.setSn(sn);
|
|
|
|
|
+ List<MesProductCmt> lists14 = mesProductCmtService.findList(mesProductCmt);
|
|
|
|
|
+ if(!ListUtils.isEmpty(lists14)){
|
|
|
|
|
+ for (MesProductCmt mesProductProd1:lists14){
|
|
|
|
|
+ mesProductProd1.setSn(newsn);
|
|
|
|
|
+ mesProductCmtService.update(mesProductProd1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+// // 不良
|
|
|
|
|
+// MesProductFxding mesProductFxding = new MesProductFxding();
|
|
|
|
|
+// mesProductFxding.setSn(sn);
|
|
|
|
|
+// List<MesProductFxding> lists15 = mesProductFxdingService.findList(mesProductFxding);
|
|
|
|
|
+// if(!ListUtils.isEmpty(lists15)){
|
|
|
|
|
+// for (MesProductFxding mesProductProd1:lists15){
|
|
|
|
|
+// mesProductProd1.setSn(newsn);
|
|
|
|
|
+// mesProductFxdingService.update(mesProductProd1);
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 导入数据
|
|
|
|
|
+ * @param file 导入的数据文件
|
|
|
|
|
+ */
|
|
|
|
|
+ @Transactional
|
|
|
|
|
+ public String importData(MultipartFile file) {
|
|
|
|
|
+ if (file == null){
|
|
|
|
|
+ throw new ServiceException(text("请选择导入的数据文件!"));
|
|
|
|
|
+ }
|
|
|
|
|
+ int successNum = 0; int failureNum = 0;
|
|
|
|
|
+ StringBuilder successMsg = new StringBuilder();
|
|
|
|
|
+ StringBuilder failureMsg = new StringBuilder();
|
|
|
|
|
+ try(ExcelImport ei = new ExcelImport(file, 2, 0)){
|
|
|
|
|
+ List<MesProductModify> list = ei.getDataList(MesProductModify.class);
|
|
|
|
|
+ for (MesProductModify mesProductModify : list) {
|
|
|
|
|
+ try{
|
|
|
|
|
+ ValidatorUtils.validateWithException(mesProductModify);
|
|
|
|
|
+ this.save(mesProductModify);
|
|
|
|
|
+ successNum++;
|
|
|
|
|
+ successMsg.append("<br/>" + successNum + "、编号 " + mesProductModify.getId() + " 导入成功");
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ failureNum++;
|
|
|
|
|
+ String msg = "<br/>" + failureNum + "、编号 " + mesProductModify.getId() + " 导入失败:";
|
|
|
|
|
+ if (e instanceof ConstraintViolationException){
|
|
|
|
|
+ ConstraintViolationException cve = (ConstraintViolationException)e;
|
|
|
|
|
+ for (ConstraintViolation<?> violation : cve.getConstraintViolations()) {
|
|
|
|
|
+ msg += Global.getText(violation.getMessage()) + " ("+violation.getPropertyPath()+")";
|
|
|
|
|
+ }
|
|
|
|
|
+ }else{
|
|
|
|
|
+ msg += e.getMessage();
|
|
|
|
|
+ }
|
|
|
|
|
+ failureMsg.append(msg);
|
|
|
|
|
+ logger.error(msg, e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
|
|
+ failureMsg.append(e.getMessage());
|
|
|
|
|
+ return failureMsg.toString();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (failureNum > 0) {
|
|
|
|
|
+ failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
|
|
|
|
+ throw new ServiceException(failureMsg.toString());
|
|
|
|
|
+ }else{
|
|
|
|
|
+ successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
|
|
|
|
+ }
|
|
|
|
|
+ return successMsg.toString();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 更新状态
|
|
|
|
|
+ * @param mesProductModify
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional
|
|
|
|
|
+ public void updateStatus(MesProductModify mesProductModify) {
|
|
|
|
|
+ super.updateStatus(mesProductModify);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 删除数据
|
|
|
|
|
+ * @param mesProductModify
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional
|
|
|
|
|
+ public void delete(MesProductModify mesProductModify) {
|
|
|
|
|
+ super.delete(mesProductModify);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|