|
@@ -1,20 +1,48 @@
|
|
package com.rongwei.bscommon.sys.service.impl;
|
|
package com.rongwei.bscommon.sys.service.impl;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.rongwei.bscommon.sys.dao.QcsMdfFormDao;
|
|
import com.rongwei.bscommon.sys.dao.SlaveDao;
|
|
import com.rongwei.bscommon.sys.dao.SlaveDao;
|
|
-import com.rongwei.bscommon.sys.service.CommonService;
|
|
|
|
|
|
+import com.rongwei.bscommon.sys.service.*;
|
|
|
|
+import com.rongwei.bscommon.sys.utils.MdfApi;
|
|
|
|
+import com.rongwei.bsentity.domain.QcsMdfFileDo;
|
|
|
|
+import com.rongwei.bsentity.domain.QcsMdfFormDo;
|
|
|
|
+import com.rongwei.bsentity.domain.QcsMdfRowDo;
|
|
|
|
+import com.rongwei.bsentity.domain.QcsMdfSectionDo;
|
|
|
|
+import com.rongwei.bsentity.vo.QcsMdfFormVo;
|
|
|
|
+import com.rongwei.bsentity.vo.QcsMdfRowVo;
|
|
|
|
+import com.rongwei.bsentity.vo.QcsMdfSectionVo;
|
|
import com.rongwei.rwcommon.base.R;
|
|
import com.rongwei.rwcommon.base.R;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
public class CommonServiceImpl implements CommonService {
|
|
public class CommonServiceImpl implements CommonService {
|
|
private final Logger log = LoggerFactory.getLogger(this.getClass().getName());
|
|
private final Logger log = LoggerFactory.getLogger(this.getClass().getName());
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private MdfApi mdfApi;
|
|
|
|
+ @Autowired
|
|
|
|
+ private QcsMdfFormService qcsMdfFormService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private QcsMdfSectionService qcsMdfSectionService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private QcsMdfRowService qcsMdfRowService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private QcsMdfFileService qcsMdfFileService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private QcsMdfFormDao qcsMdfFormDao;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
SlaveDao slaveDao;
|
|
SlaveDao slaveDao;
|
|
|
|
|
|
@@ -47,4 +75,77 @@ public class CommonServiceImpl implements CommonService {
|
|
}
|
|
}
|
|
return r;
|
|
return r;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //获取修改单信息
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public R getMdfFormInfo(String dtwhoapproveTime) throws Exception {
|
|
|
|
+ R r = new R();
|
|
|
|
+ if (dtwhoapproveTime == null || dtwhoapproveTime.length() == 0) {
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
+ dtwhoapproveTime = sdf.format(new Date());
|
|
|
|
+ }
|
|
|
|
+ Map<String, Object> mdfmap = mdfApi.apiCall(dtwhoapproveTime);
|
|
|
|
+ if (mdfmap.get("code").equals("200")) {
|
|
|
|
+ List<QcsMdfFormVo> mdfFormVoList = JSON.parseArray(JSON.toJSONString(mdfmap.get("data")), QcsMdfFormVo.class);
|
|
|
|
+ if (mdfFormVoList.size() > 0) {
|
|
|
|
+ //已有修改单数据
|
|
|
|
+ List<QcsMdfFormDo> qcsMdfFormDos = qcsMdfFormDao.getQcsMdfForms(dtwhoapproveTime);
|
|
|
|
+
|
|
|
|
+ List<QcsMdfFormDo> qcsMdfFormDoList = new ArrayList<>();
|
|
|
|
+ List<QcsMdfSectionDo> qcsMdfSectionDoList = new ArrayList<>();
|
|
|
|
+ List<QcsMdfRowDo> qcsMdfRowDoList = new ArrayList<>();
|
|
|
|
+ List<QcsMdfFileDo> qcsMdfFileDoList = new ArrayList<>();
|
|
|
|
+ for (QcsMdfFormVo qcsMdfFormVo : mdfFormVoList) {
|
|
|
|
+ List<QcsMdfFormDo> hasMdfForms = qcsMdfFormDos.stream().filter(mdf -> mdf.getId().equals(qcsMdfFormVo.getId())).collect(Collectors.toList());
|
|
|
|
+ if (hasMdfForms.size() > 0) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ qcsMdfFormDoList.add(qcsMdfFormVo);
|
|
|
|
+ for (QcsMdfSectionVo qcsMdfSectionVo : qcsMdfFormVo.getSections()) {
|
|
|
|
+ if (qcsMdfSectionVo.getFormid() == null) {
|
|
|
|
+ qcsMdfSectionVo.setFormid(qcsMdfFormVo.getId());
|
|
|
|
+ }
|
|
|
|
+ qcsMdfSectionDoList.add(qcsMdfSectionVo);
|
|
|
|
+ for (QcsMdfRowVo qcsMdfRowVo : qcsMdfSectionVo.getRows()) {
|
|
|
|
+ if (qcsMdfRowVo.getFormid() == null) {
|
|
|
|
+ qcsMdfRowVo.setFormid(qcsMdfFormVo.getId());
|
|
|
|
+ }
|
|
|
|
+ if (qcsMdfRowVo.getSectionid() == null) {
|
|
|
|
+ qcsMdfRowVo.setSectionid(qcsMdfSectionVo.getId());
|
|
|
|
+ }
|
|
|
|
+ qcsMdfRowDoList.add(qcsMdfRowVo);
|
|
|
|
+ for (QcsMdfFileDo qcsMdfFileDo : qcsMdfRowVo.getFiles()) {
|
|
|
|
+ if (qcsMdfFileDo.getFormid() == null) {
|
|
|
|
+ qcsMdfFileDo.setFormid(qcsMdfFormVo.getId());
|
|
|
|
+ }
|
|
|
|
+ if (qcsMdfFileDo.getSectionid() == null) {
|
|
|
|
+ qcsMdfFileDo.setSectionid(qcsMdfSectionVo.getId());
|
|
|
|
+ }
|
|
|
|
+ if (qcsMdfFileDo.getRowsid() == null) {
|
|
|
|
+ qcsMdfFileDo.setRowsid(qcsMdfRowVo.getId());
|
|
|
|
+ }
|
|
|
|
+ qcsMdfFileDoList.add(qcsMdfFileDo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (qcsMdfFormDoList.size() > 0) {
|
|
|
|
+ qcsMdfFormService.saveBatch(qcsMdfFormDoList);
|
|
|
|
+ }
|
|
|
|
+ if (qcsMdfSectionDoList.size() > 0) {
|
|
|
|
+ qcsMdfSectionService.saveBatch(qcsMdfSectionDoList);
|
|
|
|
+ }
|
|
|
|
+ if (qcsMdfRowDoList.size() > 0) {
|
|
|
|
+ qcsMdfRowService.saveBatch(qcsMdfRowDoList);
|
|
|
|
+ }
|
|
|
|
+ if (qcsMdfFileDoList.size() > 0) {
|
|
|
|
+ qcsMdfFileService.saveBatch(qcsMdfFileDoList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ r.setCode(mdfmap.get("code").toString());
|
|
|
|
+ r.setMsg(mdfmap.get("msg").toString());
|
|
|
|
+ return r;
|
|
|
|
+ }
|
|
}
|
|
}
|