|
@@ -0,0 +1,187 @@
|
|
|
|
+package com.bizmatics.service.impl;
|
|
|
|
+
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
+import com.bizmatics.common.mvc.base.AbstractCrudService;
|
|
|
|
+import com.bizmatics.model.PatrolCheckEntry;
|
|
|
|
+import com.bizmatics.model.PatrolContentEntry;
|
|
|
|
+import com.bizmatics.model.PatrolInspectionContent;
|
|
|
|
+import com.bizmatics.model.PatrolInspectionDevice;
|
|
|
|
+import com.bizmatics.model.system.SysUser;
|
|
|
|
+import com.bizmatics.model.vo.PatrolInspectionContentListVo;
|
|
|
|
+import com.bizmatics.model.vo.PatrolInspectionContentOneVo;
|
|
|
|
+import com.bizmatics.model.vo.PatrolInspectionContentVo;
|
|
|
|
+import com.bizmatics.model.vo.SiteDeviceCountVo;
|
|
|
|
+import com.bizmatics.persistence.mapper.PatrolInspectionContentMapper;
|
|
|
|
+import com.bizmatics.service.PatrolContentEntryService;
|
|
|
|
+import com.bizmatics.service.PatrolInspectionContentService;
|
|
|
|
+import com.bizmatics.service.util.SecurityUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * <p>
|
|
|
|
+ * 服务实现类
|
|
|
|
+ * </p>
|
|
|
|
+ *
|
|
|
|
+ * @author ya
|
|
|
|
+ * @since 2021-10-16
|
|
|
|
+ */
|
|
|
|
+@Service
|
|
|
|
+public class PatrolInspectionContentServiceImpl extends AbstractCrudService<PatrolInspectionContentMapper, PatrolInspectionContent> implements PatrolInspectionContentService {
|
|
|
|
+ @Autowired
|
|
|
|
+ private PatrolContentEntryService patrolContentEntryService;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void patrolInspectionContentAdd(PatrolInspectionContentVo patrolInspectionContentVo) {
|
|
|
|
+ SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
|
+ PatrolInspectionContentOneVo patrolInspectionContentOneVo = patrolInspectionContentVo.getPatrolInspectionContentOneVo();
|
|
|
|
+ String inspectionDeviceIdArr[] = patrolInspectionContentOneVo.getInspectionDeviceId().split(",");
|
|
|
|
+ PatrolInspectionContent patrolInspectionContent = new PatrolInspectionContent();
|
|
|
|
+ patrolInspectionContent.setInspectionContentName(patrolInspectionContentOneVo.getInspectionContentName());
|
|
|
|
+ patrolInspectionContent.setCreator(user.getUserName());
|
|
|
|
+ patrolInspectionContent.setCreateTime(new Date());
|
|
|
|
+ patrolInspectionContent.setStatus(1);
|
|
|
|
+ List<PatrolCheckEntry> patrolCheckEntry = patrolInspectionContentVo.getPatrolCheckEntry();
|
|
|
|
+ PatrolContentEntry patrolContentEntry = new PatrolContentEntry();
|
|
|
|
+ for (int i = 0; i < inspectionDeviceIdArr.length; i++) {
|
|
|
|
+ patrolInspectionContent.setInspectionDeviceId(Integer.parseInt(inspectionDeviceIdArr[i]));
|
|
|
|
+ this.save(patrolInspectionContent);
|
|
|
|
+ int inspectionContentId = patrolInspectionContent.getId();
|
|
|
|
+ for (int j = 0; j < patrolCheckEntry.size(); j++) {
|
|
|
|
+ patrolContentEntry.setInspectionContentId(inspectionContentId);
|
|
|
|
+ patrolContentEntry.setCheckEntryId(patrolCheckEntry.get(j).getId());
|
|
|
|
+ patrolContentEntry.setStatus(1);
|
|
|
|
+ patrolContentEntry.setCreator(user.getUserName());
|
|
|
|
+ patrolContentEntry.setCreateTime(new Date());
|
|
|
|
+ patrolContentEntry.setReferenceValue(patrolCheckEntry.get(j).getReferenceValue());
|
|
|
|
+ patrolContentEntry.setInspectionDeviceId(Integer.parseInt(inspectionDeviceIdArr[i]));
|
|
|
|
+ patrolContentEntryService.save(patrolContentEntry);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void patrolInspectionContentUpdate(PatrolInspectionContentVo patrolInspectionContentVo) {
|
|
|
|
+ SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
|
+ PatrolInspectionContent patrolInspectionContent = new PatrolInspectionContent();
|
|
|
|
+ patrolInspectionContent.setInspectionContentName(patrolInspectionContentVo.getPatrolInspectionContentOneVo().getInspectionContentName());
|
|
|
|
+ int inspectionDeviceId = Integer.parseInt(patrolInspectionContentVo.getPatrolInspectionContentOneVo().getInspectionDeviceId());
|
|
|
|
+ patrolInspectionContent.setInspectionDeviceId(inspectionDeviceId);
|
|
|
|
+ patrolInspectionContent.setId(patrolInspectionContentVo.getPatrolInspectionContentOneVo().getId());
|
|
|
|
+ this.updateById(patrolInspectionContent);
|
|
|
|
+
|
|
|
|
+ //旧数据
|
|
|
|
+ LambdaQueryWrapper<PatrolContentEntry> queryWrapper = Wrappers.lambdaQuery();
|
|
|
|
+ queryWrapper.eq(PatrolContentEntry::getInspectionContentId, patrolInspectionContent.getId())
|
|
|
|
+ .eq(PatrolContentEntry::getInspectionDeviceId, patrolInspectionContent.getInspectionDeviceId());
|
|
|
|
+ List<PatrolContentEntry> patrolContentEntryList = patrolContentEntryService.list(queryWrapper);
|
|
|
|
+ if (patrolContentEntryList.size()>0){
|
|
|
|
+ for (int i = 0;i<patrolContentEntryList.size();i++){
|
|
|
|
+ PatrolContentEntry patrolContentEntry = new PatrolContentEntry();
|
|
|
|
+ patrolContentEntry.setStatus(0);
|
|
|
|
+ patrolContentEntry.setId(patrolContentEntryList.get(i).getId());
|
|
|
|
+ patrolContentEntryService.updateById(patrolContentEntry);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (patrolInspectionContentVo.getPatrolCheckEntry().size()>0){
|
|
|
|
+ for (int i = 0; i < patrolInspectionContentVo.getPatrolCheckEntry().size(); i++){
|
|
|
|
+ PatrolContentEntry patrolContentEntry = new PatrolContentEntry();
|
|
|
|
+ patrolContentEntry.setInspectionContentId(patrolInspectionContent.getId());
|
|
|
|
+ patrolContentEntry.setInspectionDeviceId(patrolInspectionContent.getInspectionDeviceId());
|
|
|
|
+ patrolContentEntry.setCheckEntryId(patrolInspectionContentVo.getPatrolCheckEntry().get(i).getId());
|
|
|
|
+ patrolContentEntry.setReferenceValue(patrolInspectionContentVo.getPatrolCheckEntry().get(i).getReferenceValue());
|
|
|
|
+ patrolContentEntry.setCreator(user.getUserName());
|
|
|
|
+ patrolContentEntry.setStatus(1);
|
|
|
|
+ patrolContentEntry.setCreateTime(new Date());
|
|
|
|
+ patrolContentEntryService.save(patrolContentEntry);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+// List<Integer> list = new ArrayList<Integer>();
|
|
|
|
+// for (int j = 0; j < patrolContentEntryList.size(); j++) {
|
|
|
|
+// for (int i = 0; i < patrolInspectionContentVo.getPatrolCheckEntry().size(); i++) {
|
|
|
|
+// if (patrolContentEntryList.get(j).getCheckEntryId() != patrolInspectionContentVo.getPatrolCheckEntry().get(i).getId()) {
|
|
|
|
+// if (!list.contains(patrolInspectionContentVo.getPatrolCheckEntry().get(i).getId())) {
|
|
|
|
+// PatrolContentEntry patrolContentEntry = new PatrolContentEntry();
|
|
|
|
+// patrolContentEntry.setInspectionContentId(patrolInspectionContent.getId());
|
|
|
|
+// patrolContentEntry.setInspectionDeviceId(patrolInspectionContent.getInspectionDeviceId());
|
|
|
|
+// patrolContentEntry.setCheckEntryId(patrolInspectionContentVo.getPatrolCheckEntry().get(i).getId());
|
|
|
|
+// patrolContentEntry.setReferenceValue(patrolInspectionContentVo.getPatrolCheckEntry().get(i).getReferenceValue());
|
|
|
|
+// patrolContentEntry.setCreator(user.getUserName());
|
|
|
|
+// patrolContentEntry.setStatus(1);
|
|
|
|
+// patrolContentEntry.setCreateTime(new Date());
|
|
|
|
+// patrolContentEntryService.save(patrolContentEntry);
|
|
|
|
+// list.add(patrolInspectionContentVo.getPatrolCheckEntry().get(i).getId());
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// LambdaQueryWrapper<PatrolContentEntry> queryWrapperOne = Wrappers.lambdaQuery();
|
|
|
|
+// queryWrapperOne.eq(PatrolContentEntry::getInspectionContentId, patrolInspectionContent.getId())
|
|
|
|
+// .eq(PatrolContentEntry::getInspectionDeviceId, patrolInspectionContent.getInspectionDeviceId());
|
|
|
|
+// List<PatrolContentEntry> patrolContentEntryListOne = patrolContentEntryService.list(queryWrapperOne);
|
|
|
|
+//
|
|
|
|
+// for (int i = 0; i < patrolInspectionContentVo.getPatrolCheckEntry().size(); i++) {
|
|
|
|
+// for (int j = 0; j < patrolContentEntryListOne.size(); j++) {
|
|
|
|
+// PatrolContentEntry patrolContentEntry = new PatrolContentEntry();
|
|
|
|
+// patrolContentEntry.setId(patrolContentEntryListOne.get(j).getId());
|
|
|
|
+// if (patrolInspectionContentVo.getPatrolCheckEntry().get(i).getId() != patrolContentEntryListOne.get(j).getCheckEntryId()) {
|
|
|
|
+// patrolContentEntry.setStatus(0);
|
|
|
|
+// } else {
|
|
|
|
+// patrolContentEntry.setStatus(1);
|
|
|
|
+// }
|
|
|
|
+// patrolContentEntryService.updateById(patrolContentEntry);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void patrolInspectionContentDel(Integer id) {
|
|
|
|
+ PatrolInspectionContent patrolInspectionContent = new PatrolInspectionContent();
|
|
|
|
+ patrolInspectionContent.setId(id);
|
|
|
|
+ patrolInspectionContent.setStatus(0);
|
|
|
|
+ this.updateById(patrolInspectionContent);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<PatrolInspectionContentListVo> patrolInspectionContentList(String inspectionContentName) {
|
|
|
|
+ List<PatrolInspectionContentListVo> list = baseMapper.patrolInspectionContentList(inspectionContentName, 0, 0);
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<PatrolInspectionContentListVo> patrolInspectionContentDetailsList(Integer id) {
|
|
|
|
+ List<PatrolInspectionContentListVo> list = baseMapper.patrolInspectionContentList(null, id, 0);
|
|
|
|
+ LambdaQueryWrapper<PatrolContentEntry> queryWrapper = Wrappers.lambdaQuery();
|
|
|
|
+ queryWrapper.eq(PatrolContentEntry::getStatus, 1)
|
|
|
|
+ .eq(PatrolContentEntry::getInspectionContentId, id);
|
|
|
|
+ List<PatrolContentEntry> patrolContentEntryListOne = patrolContentEntryService.list(queryWrapper);
|
|
|
|
+ list.get(0).setPatrolContentEntry(patrolContentEntryListOne);
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<PatrolContentEntry> patrolContentEntryList(Integer id){
|
|
|
|
+ LambdaQueryWrapper<PatrolContentEntry> queryWrapper = Wrappers.lambdaQuery();
|
|
|
|
+ queryWrapper.eq(PatrolContentEntry::getStatus, 1)
|
|
|
|
+ .eq(PatrolContentEntry::getInspectionContentId, id);
|
|
|
|
+ List<PatrolContentEntry> patrolContentEntryListOne = patrolContentEntryService.list(queryWrapper);
|
|
|
|
+ return patrolContentEntryListOne;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<SiteDeviceCountVo> patrolInspectionContentSiteList(String siteName){
|
|
|
|
+ SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
|
+ Integer userId = user.getUserId().intValue();
|
|
|
|
+ List<SiteDeviceCountVo> list = baseMapper.patrolInspectionContentSiteList(siteName, userId);
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+}
|