Merge remote-tracking branch 'origin/master'
commit
4e04cf0560
@ -0,0 +1,67 @@
|
||||
package com.op.quality.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.op.quality.domain.QcGoalDistribute;
|
||||
|
||||
/**
|
||||
* 质量目标分配Service接口
|
||||
*
|
||||
* @author Open Platform
|
||||
* @date 2024-03-07
|
||||
*/
|
||||
public interface IQcGoalDistributeService {
|
||||
/**
|
||||
* 查询质量目标分配
|
||||
*
|
||||
* @param id 质量目标分配主键
|
||||
* @return 质量目标分配
|
||||
*/
|
||||
public QcGoalDistribute selectQcGoalDistributeById(String id);
|
||||
|
||||
/**
|
||||
* 查询质量目标分配列表
|
||||
*
|
||||
* @param qcGoalDistribute 质量目标分配
|
||||
* @return 质量目标分配集合
|
||||
*/
|
||||
public List<QcGoalDistribute> selectQcGoalDistributeList(QcGoalDistribute qcGoalDistribute);
|
||||
|
||||
/**
|
||||
* 新增质量目标分配
|
||||
*
|
||||
* @param qcGoalDistribute 质量目标分配
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertQcGoalDistribute(QcGoalDistribute qcGoalDistribute);
|
||||
|
||||
/**
|
||||
* 修改质量目标分配
|
||||
*
|
||||
* @param qcGoalDistribute 质量目标分配
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateQcGoalDistribute(QcGoalDistribute qcGoalDistribute);
|
||||
|
||||
/**
|
||||
* 批量删除质量目标分配
|
||||
*
|
||||
* @param ids 需要删除的质量目标分配主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteQcGoalDistributeByIds(String[] ids);
|
||||
|
||||
/**
|
||||
* 删除质量目标分配信息
|
||||
*
|
||||
* @param id 质量目标分配主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteQcGoalDistributeById(String id);
|
||||
|
||||
|
||||
public List<QcGoalDistribute> getLeftList(QcGoalDistribute qcGoalDistribute);
|
||||
public List<QcGoalDistribute> getRightList(QcGoalDistribute qcGoalDistribute);
|
||||
public List<QcGoalDistribute> getProductLeftList(QcGoalDistribute qcGoalDistribute);
|
||||
public List<QcGoalDistribute> getProductRightList(QcGoalDistribute qcGoalDistribute);
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
package com.op.quality.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.op.quality.domain.QcGoal;
|
||||
import com.op.quality.domain.vo.TreeSelect;
|
||||
|
||||
/**
|
||||
* 质量目标Service接口
|
||||
*
|
||||
* @author Open Platform
|
||||
* @date 2024-03-04
|
||||
*/
|
||||
public interface IQcGoalService {
|
||||
/**
|
||||
* 查询质量目标
|
||||
*
|
||||
* @param id 质量目标主键
|
||||
* @return 质量目标
|
||||
*/
|
||||
public QcGoal selectQcGoalById(String id);
|
||||
|
||||
/**
|
||||
* 查询质量目标列表
|
||||
*
|
||||
* @param qcGoal 质量目标
|
||||
* @return 质量目标集合
|
||||
*/
|
||||
public List<QcGoal> selectQcGoalList(QcGoal qcGoal);
|
||||
|
||||
/**
|
||||
* 查询质量目标二级数据
|
||||
* @param goal
|
||||
* @return
|
||||
*/
|
||||
public List<QcGoal> selectChildrenByParent(QcGoal goal);
|
||||
|
||||
/**
|
||||
* 构建质量目标下拉树
|
||||
* @param qcGoals
|
||||
* @return
|
||||
*/
|
||||
public List<TreeSelect> buildQcGoalTreeSelect(List<QcGoal> qcGoals);
|
||||
|
||||
/**
|
||||
* 新增质量目标
|
||||
*
|
||||
* @param qcGoal 质量目标
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertQcGoal(QcGoal qcGoal);
|
||||
|
||||
public List<QcGoal> generate(String id);
|
||||
|
||||
/**
|
||||
* 修改质量目标
|
||||
*
|
||||
* @param qcGoal 质量目标
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateQcGoal(QcGoal qcGoal);
|
||||
|
||||
/**
|
||||
* 批量删除质量目标
|
||||
*
|
||||
* @param ids 需要删除的质量目标主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteQcGoalByIds(String[] ids);
|
||||
|
||||
/**
|
||||
* 删除质量目标信息
|
||||
*
|
||||
* @param id 质量目标主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteQcGoalById(String id);
|
||||
|
||||
/**
|
||||
* 构建质量目标树结构
|
||||
* @param qcGoals
|
||||
* @return
|
||||
*/
|
||||
public List<QcGoal> buildGoalTree(List<QcGoal> qcGoals);
|
||||
}
|
@ -1,153 +1,174 @@
|
||||
//package com.op.quality.service.impl;
|
||||
//
|
||||
//import java.util.Date;
|
||||
//import java.util.List;
|
||||
//
|
||||
//import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
//import com.op.common.core.utils.DateUtils;
|
||||
//import com.op.common.core.utils.StringUtils;
|
||||
//import com.op.common.core.utils.uuid.IdUtils;
|
||||
//import com.op.common.security.utils.SecurityUtils;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//import com.op.quality.mapper.QcGoalDistributeMapper;
|
||||
//import com.op.quality.domain.QcGoalDistribute;
|
||||
//import com.op.quality.service.IQcGoalDistributeService;
|
||||
//import org.springframework.web.context.request.RequestContextHolder;
|
||||
//import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
//
|
||||
//import javax.servlet.http.HttpServletRequest;
|
||||
//
|
||||
///**
|
||||
// * 质量目标分配Service业务层处理
|
||||
// *
|
||||
// * @author Open Platform
|
||||
// * @date 2024-03-07
|
||||
// */
|
||||
//@Service
|
||||
//public class QcGoalDistributeServiceImpl implements IQcGoalDistributeService {
|
||||
// @Autowired
|
||||
// private QcGoalDistributeMapper qcGoalDistributeMapper;
|
||||
//
|
||||
// /**
|
||||
// * 查询质量目标分配
|
||||
// *
|
||||
// * @param id 质量目标分配主键
|
||||
// * @return 质量目标分配
|
||||
// */
|
||||
// @Override
|
||||
// @DS("#header.poolName")
|
||||
// public QcGoalDistribute selectQcGoalDistributeById(String id) {
|
||||
// return qcGoalDistributeMapper.selectQcGoalDistributeById(id);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 查询质量目标分配列表
|
||||
// *
|
||||
// * @param qcGoalDistribute 质量目标分配
|
||||
// * @return 质量目标分配
|
||||
// */
|
||||
// @Override
|
||||
// @DS("#header.poolName")
|
||||
// public List<QcGoalDistribute> selectQcGoalDistributeList(QcGoalDistribute qcGoalDistribute) {
|
||||
// return qcGoalDistributeMapper.selectQcGoalDistributeList(qcGoalDistribute);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 新增质量目标分配
|
||||
// *
|
||||
// * @param qcGoalDistribute 质量目标分配
|
||||
// * @return 结果
|
||||
// */
|
||||
// @Override
|
||||
// @DS("#header.poolName")
|
||||
// public int insertQcGoalDistribute(QcGoalDistribute qcGoalDistribute) {
|
||||
//
|
||||
// if (StringUtils.isNotEmpty(qcGoalDistribute.getBelongGoalId())) {
|
||||
// qcGoalDistributeMapper.deleteQcGoalDistributeByBelongId(qcGoalDistribute.getBelongGoalId());
|
||||
// }
|
||||
// int count = 0;
|
||||
// if (qcGoalDistribute.getSelectedValues().size() > 0){
|
||||
// QcGoalDistribute dto = null;
|
||||
// Date now = DateUtils.getNowDate();
|
||||
// HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
// String key = "#header.poolName";
|
||||
// String factoryCode = request.getHeader(key.substring(8)).replace("ds_", "");
|
||||
// for (String supplierCode : qcGoalDistribute.getSelectedValues()) {
|
||||
// dto = new QcGoalDistribute();
|
||||
// dto.setId(IdUtils.fastSimpleUUID());
|
||||
// dto.setCreateTime(now);
|
||||
// dto.setCreateBy(SecurityUtils.getUsername());
|
||||
// dto.setBelongGoalId(qcGoalDistribute.getBelongGoalId());
|
||||
// dto.setSupplierCode(supplierCode);
|
||||
// dto.setFactoryCode(factoryCode);
|
||||
// count += qcGoalDistributeMapper.insertQcGoalDistribute(dto);
|
||||
// }
|
||||
// }else {
|
||||
// count = 1;
|
||||
// }
|
||||
// return count;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 修改质量目标分配
|
||||
// *
|
||||
// * @param qcGoalDistribute 质量目标分配
|
||||
// * @return 结果
|
||||
// */
|
||||
// @Override
|
||||
// @DS("#header.poolName")
|
||||
// public int updateQcGoalDistribute(QcGoalDistribute qcGoalDistribute) {
|
||||
// qcGoalDistribute.setUpdateTime(DateUtils.getNowDate());
|
||||
// return qcGoalDistributeMapper.updateQcGoalDistribute(qcGoalDistribute);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 批量删除质量目标分配
|
||||
// *
|
||||
// * @param ids 需要删除的质量目标分配主键
|
||||
// * @return 结果
|
||||
// */
|
||||
// @Override
|
||||
// @DS("#header.poolName")
|
||||
// public int deleteQcGoalDistributeByIds(String[] ids) {
|
||||
// return qcGoalDistributeMapper.deleteQcGoalDistributeByIds(ids);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 删除质量目标分配信息
|
||||
// *
|
||||
// * @param id 质量目标分配主键
|
||||
// * @return 结果
|
||||
// */
|
||||
// @Override
|
||||
// @DS("#header.poolName")
|
||||
// public int deleteQcGoalDistributeById(String id) {
|
||||
// return qcGoalDistributeMapper.deleteQcGoalDistributeById(id);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @DS("#header.poolName")
|
||||
// public List<QcGoalDistribute> getLeftList(QcGoalDistribute qcGoalDistribute) {
|
||||
// List<QcGoalDistribute> dto = qcGoalDistributeMapper.getGoalDistributeUndo(qcGoalDistribute);
|
||||
// List<QcGoalDistribute> selected = qcGoalDistributeMapper.getGoalDistributeDo(qcGoalDistribute);
|
||||
// dto.addAll(selected);
|
||||
// dto.forEach(item -> {
|
||||
// item.setKey(item.getSupplierCode());
|
||||
// });
|
||||
// return dto;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @DS("#header.poolName")
|
||||
// public List<QcGoalDistribute> getRightList(QcGoalDistribute qcGoalDistribute) {
|
||||
// List<QcGoalDistribute> selected = qcGoalDistributeMapper.getGoalDistributeDo(qcGoalDistribute);
|
||||
// selected.forEach(item -> {
|
||||
// item.setKey(item.getSupplierCode());
|
||||
// });
|
||||
// return selected;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//}
|
||||
package com.op.quality.service.impl;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.op.common.core.utils.DateUtils;
|
||||
import com.op.common.core.utils.StringUtils;
|
||||
import com.op.common.core.utils.uuid.IdUtils;
|
||||
import com.op.common.security.utils.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.op.quality.mapper.QcGoalDistributeMapper;
|
||||
import com.op.quality.domain.QcGoalDistribute;
|
||||
import com.op.quality.service.IQcGoalDistributeService;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 质量目标分配Service业务层处理
|
||||
*
|
||||
* @author Open Platform
|
||||
* @date 2024-03-07
|
||||
*/
|
||||
@Service
|
||||
public class QcGoalDistributeServiceImpl implements IQcGoalDistributeService {
|
||||
@Autowired
|
||||
private QcGoalDistributeMapper qcGoalDistributeMapper;
|
||||
|
||||
/**
|
||||
* 查询质量目标分配
|
||||
*
|
||||
* @param id 质量目标分配主键
|
||||
* @return 质量目标分配
|
||||
*/
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public QcGoalDistribute selectQcGoalDistributeById(String id) {
|
||||
return qcGoalDistributeMapper.selectQcGoalDistributeById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询质量目标分配列表
|
||||
*
|
||||
* @param qcGoalDistribute 质量目标分配
|
||||
* @return 质量目标分配
|
||||
*/
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public List<QcGoalDistribute> selectQcGoalDistributeList(QcGoalDistribute qcGoalDistribute) {
|
||||
return qcGoalDistributeMapper.selectQcGoalDistributeList(qcGoalDistribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增质量目标分配
|
||||
*
|
||||
* @param qcGoalDistribute 质量目标分配
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public int insertQcGoalDistribute(QcGoalDistribute qcGoalDistribute) {
|
||||
|
||||
if (StringUtils.isNotEmpty(qcGoalDistribute.getBelongGoalId())) {
|
||||
qcGoalDistributeMapper.deleteQcGoalDistributeByBelongId(qcGoalDistribute.getBelongGoalId());
|
||||
}
|
||||
int count = 0;
|
||||
if (qcGoalDistribute.getSelectedValues().size() > 0){
|
||||
QcGoalDistribute dto = null;
|
||||
Date now = DateUtils.getNowDate();
|
||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
String key = "#header.poolName";
|
||||
String factoryCode = request.getHeader(key.substring(8)).replace("ds_", "");
|
||||
for (String supplierCode : qcGoalDistribute.getSelectedValues()) {
|
||||
dto = new QcGoalDistribute();
|
||||
dto.setId(IdUtils.fastSimpleUUID());
|
||||
dto.setCreateTime(now);
|
||||
dto.setCreateBy(SecurityUtils.getUsername());
|
||||
dto.setBelongGoalId(qcGoalDistribute.getBelongGoalId());
|
||||
dto.setSupplierCode(supplierCode);
|
||||
dto.setFactoryCode(factoryCode);
|
||||
count += qcGoalDistributeMapper.insertQcGoalDistribute(dto);
|
||||
}
|
||||
}else {
|
||||
count = 1;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改质量目标分配
|
||||
*
|
||||
* @param qcGoalDistribute 质量目标分配
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public int updateQcGoalDistribute(QcGoalDistribute qcGoalDistribute) {
|
||||
qcGoalDistribute.setUpdateTime(DateUtils.getNowDate());
|
||||
return qcGoalDistributeMapper.updateQcGoalDistribute(qcGoalDistribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除质量目标分配
|
||||
*
|
||||
* @param ids 需要删除的质量目标分配主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public int deleteQcGoalDistributeByIds(String[] ids) {
|
||||
return qcGoalDistributeMapper.deleteQcGoalDistributeByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除质量目标分配信息
|
||||
*
|
||||
* @param id 质量目标分配主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public int deleteQcGoalDistributeById(String id) {
|
||||
return qcGoalDistributeMapper.deleteQcGoalDistributeById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public List<QcGoalDistribute> getLeftList(QcGoalDistribute qcGoalDistribute) {
|
||||
List<QcGoalDistribute> dto = qcGoalDistributeMapper.getGoalDistributeUndo(qcGoalDistribute);
|
||||
List<QcGoalDistribute> selected = qcGoalDistributeMapper.getGoalDistributeDo(qcGoalDistribute);
|
||||
dto.addAll(selected);
|
||||
dto.forEach(item -> {
|
||||
item.setKey(item.getSupplierCode());
|
||||
});
|
||||
return dto;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public List<QcGoalDistribute> getRightList(QcGoalDistribute qcGoalDistribute) {
|
||||
List<QcGoalDistribute> selected = qcGoalDistributeMapper.getGoalDistributeDo(qcGoalDistribute);
|
||||
selected.forEach(item -> {
|
||||
item.setKey(item.getSupplierCode());
|
||||
});
|
||||
return selected;
|
||||
}
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public List<QcGoalDistribute> getProductLeftList(QcGoalDistribute qcGoalDistribute) {
|
||||
List<QcGoalDistribute> dto = qcGoalDistributeMapper.getProductUndo(qcGoalDistribute);
|
||||
List<QcGoalDistribute> selected = qcGoalDistributeMapper.getProductDo(qcGoalDistribute);
|
||||
dto.addAll(selected);
|
||||
dto.forEach(item -> {
|
||||
item.setKey(item.getSupplierCode());
|
||||
});
|
||||
return dto;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public List<QcGoalDistribute> getProductRightList(QcGoalDistribute qcGoalDistribute) {
|
||||
List<QcGoalDistribute> selected = qcGoalDistributeMapper.getProductDo(qcGoalDistribute);
|
||||
selected.forEach(item -> {
|
||||
item.setKey(item.getSupplierCode());
|
||||
});
|
||||
return selected;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,245 +1,245 @@
|
||||
//package com.op.quality.service.impl;
|
||||
//
|
||||
//import java.math.BigDecimal;
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.Date;
|
||||
//import java.util.Iterator;
|
||||
//import java.util.List;
|
||||
//import java.util.stream.Collectors;
|
||||
//
|
||||
//import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
//import com.op.common.core.utils.DateUtils;
|
||||
//import com.op.common.security.utils.SecurityUtils;
|
||||
//import com.op.quality.domain.vo.TreeSelect;
|
||||
//import com.sun.xml.bind.v2.TODO;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//import com.op.quality.mapper.QcGoalMapper;
|
||||
//import com.op.quality.domain.QcGoal;
|
||||
//import com.op.quality.service.IQcGoalService;
|
||||
//import org.springframework.util.ObjectUtils;
|
||||
//import org.springframework.web.context.request.RequestContextHolder;
|
||||
//import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
//
|
||||
//import javax.servlet.http.HttpServletRequest;
|
||||
//
|
||||
///**
|
||||
// * 质量目标Service业务层处理
|
||||
// *
|
||||
// * @author Open Platform
|
||||
// * @date 2024-03-04
|
||||
// */
|
||||
//@Service
|
||||
//public class QcGoalServiceImpl implements IQcGoalService {
|
||||
// @Autowired
|
||||
// private QcGoalMapper qcGoalMapper;
|
||||
//
|
||||
// /**
|
||||
// * 查询质量目标
|
||||
// *
|
||||
// * @param id 质量目标主键
|
||||
// * @return 质量目标
|
||||
// */
|
||||
// @Override
|
||||
// @DS("#header.poolName")
|
||||
// public QcGoal selectQcGoalById(String id) {
|
||||
// return qcGoalMapper.selectQcGoalById(id);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 查询质量目标列表
|
||||
// *
|
||||
// * @param qcGoal 质量目标
|
||||
// * @return 质量目标
|
||||
// */
|
||||
// @Override
|
||||
// @DS("#header.poolName")
|
||||
// public List<QcGoal> selectQcGoalList(QcGoal qcGoal) {
|
||||
// List<QcGoal> qcGoals = qcGoalMapper.selectQcGoalList(qcGoal);
|
||||
// for (QcGoal item : qcGoals) {
|
||||
// item.setHasChildren(true);
|
||||
// }
|
||||
// return qcGoals;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @DS("#header.poolName")
|
||||
// public List<QcGoal> selectChildrenByParent(QcGoal goal) {
|
||||
// return qcGoalMapper.selectChildrenByParent(goal);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @DS("#header.poolName")
|
||||
// public List<TreeSelect> buildQcGoalTreeSelect(List<QcGoal> qcGoals) {
|
||||
// List<QcGoal> qcGoalTrees = buildGoalTree(qcGoals);
|
||||
// return qcGoalTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 新增质量目标
|
||||
// *
|
||||
// * @param qcGoal 质量目标
|
||||
// * @return 结果
|
||||
// */
|
||||
// @Override
|
||||
// @DS("#header.poolName")
|
||||
// public int insertQcGoal(QcGoal qcGoal) {
|
||||
// qcGoal.setCreateTime(DateUtils.getNowDate());
|
||||
// qcGoal.setCreateBy(SecurityUtils.getUsername());
|
||||
//
|
||||
// qcGoal.setId(getSerialNumber(qcGoal));
|
||||
// qcGoal.setFactoryCode(getFactoryCode());
|
||||
// qcGoal.setParentGoal("0");
|
||||
//
|
||||
// return qcGoalMapper.insertQcGoal(qcGoal);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @DS("#header.poolName")
|
||||
// public List<QcGoal> generate(String id) {
|
||||
// QcGoal goal = qcGoalMapper.selectQcGoalById(id);
|
||||
// List<QcGoal> genResult = new ArrayList<>();
|
||||
//
|
||||
// // 提前分配大小,有助于减少不必要的计算和内存分配,从而提高代码的性能。
|
||||
// String goalYm = goal.getGoalYm();
|
||||
// BigDecimal nookQualityRate = goal.getNookQualityRate();
|
||||
// BigDecimal nookRate = goal.getNookRate();
|
||||
// String checkType = goal.getCheckType();
|
||||
// String typeCode = goal.getTypeCode();
|
||||
// String factoryCode = getFactoryCode();
|
||||
// String username = SecurityUtils.getUsername();
|
||||
// Date nowDate = DateUtils.getNowDate();
|
||||
// String parentGoal = goal.getId();
|
||||
//
|
||||
//
|
||||
// int liushuiNum = qcGoalMapper.getTodayMaxNum(goal);
|
||||
// String dateNumber = DateUtils.parseDateToStr(DateUtils.YYYYMMDD, DateUtils.getNowDate());
|
||||
//
|
||||
// int month = 12;
|
||||
// for (int i = 1; i <= month; i++) {
|
||||
// QcGoal monthGoal = new QcGoal();
|
||||
//
|
||||
// String liushuiStr = String.format("%04d", liushuiNum+i-1);
|
||||
// monthGoal.setId(dateNumber+liushuiStr);
|
||||
// String mon = String.format("%02d",i);
|
||||
// monthGoal.setGoalYm(goalYm+"-"+mon);
|
||||
// monthGoal.setGoalType("mm");
|
||||
// monthGoal.setNookQualityRate(nookQualityRate);
|
||||
// monthGoal.setNookRate(nookRate);
|
||||
// monthGoal.setCheckType(checkType);
|
||||
// monthGoal.setTypeCode(typeCode);
|
||||
// monthGoal.setScope(goal.getScope());
|
||||
// monthGoal.setCreateTime(nowDate);
|
||||
// monthGoal.setCreateBy(username);
|
||||
// monthGoal.setFactoryCode(factoryCode);
|
||||
// monthGoal.setParentGoal(parentGoal);
|
||||
// genResult.add(monthGoal);
|
||||
// }
|
||||
// // 批量插入
|
||||
// int flag = qcGoalMapper.insertQcGoalList(genResult);
|
||||
// if (flag > 0) {
|
||||
// return genResult;
|
||||
// }else {
|
||||
// return goal.getChildren();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 修改质量目标
|
||||
// *
|
||||
// * @param qcGoal 质量目标
|
||||
// * @return 结果
|
||||
// */
|
||||
// @Override
|
||||
// @DS("#header.poolName")
|
||||
// public int updateQcGoal(QcGoal qcGoal) {
|
||||
// qcGoal.setUpdateTime(DateUtils.getNowDate());
|
||||
// qcGoal.setUpdateBy(SecurityUtils.getUsername());
|
||||
// return qcGoalMapper.updateQcGoal(qcGoal);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 批量删除质量目标
|
||||
// *
|
||||
// * @param ids 需要删除的质量目标主键
|
||||
// * @return 结果
|
||||
// */
|
||||
// @Override
|
||||
// @DS("#header.poolName")
|
||||
// public int deleteQcGoalByIds(String[] ids) {
|
||||
// boolean flag = false;
|
||||
// for (String id : ids) {
|
||||
// QcGoal goal = new QcGoal();
|
||||
// goal.setParentGoal(id);
|
||||
// List<QcGoal> hasChildren = qcGoalMapper.selectChildrenByParent(goal);
|
||||
// if (hasChildren.size() > 0) {
|
||||
// flag = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (flag) {
|
||||
// return 0;
|
||||
// }else {
|
||||
// return qcGoalMapper.deleteQcGoalByIds(ids);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 删除质量目标信息
|
||||
// *
|
||||
// * @param id 质量目标主键
|
||||
// * @return 结果
|
||||
// */
|
||||
// @Override
|
||||
// @DS("#header.poolName")
|
||||
// public int deleteQcGoalById(String id) {
|
||||
// return qcGoalMapper.deleteQcGoalById(id);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<QcGoal> buildGoalTree(List<QcGoal> qcGoals) {
|
||||
// List<QcGoal> returnList = new ArrayList<>();
|
||||
// List<String> tempList = qcGoals.stream().map(QcGoal::getId).collect(Collectors.toList());
|
||||
// for (Iterator<QcGoal> iterator = qcGoals.iterator(); iterator.hasNext(); ) {
|
||||
// QcGoal qcGoal = (QcGoal) iterator.next();
|
||||
// //如果是顶级节点,遍历父节点的所有子节点
|
||||
// if (!tempList.contains(qcGoal.getParentGoal())) {
|
||||
// List<QcGoal> childList = getChildList(qcGoals,qcGoal);
|
||||
// qcGoal.setChildren(childList);
|
||||
// returnList.add(qcGoal);
|
||||
// }
|
||||
// }
|
||||
// if (returnList.isEmpty()) {
|
||||
// returnList = qcGoals;
|
||||
// }
|
||||
// return returnList;
|
||||
// }
|
||||
//
|
||||
// private List<QcGoal> getChildList(List<QcGoal> list, QcGoal t) {
|
||||
// List<QcGoal> tlist = new ArrayList<>();
|
||||
// Iterator<QcGoal> it = list.iterator();
|
||||
// while (it.hasNext()) {
|
||||
// QcGoal goal = (QcGoal) it.next();
|
||||
// if (goal.getParentGoal().equals(t.getId())){
|
||||
// tlist.add(goal);
|
||||
// }
|
||||
// }
|
||||
// return tlist;
|
||||
// }
|
||||
//
|
||||
// @DS("#header.poolName")
|
||||
// private String getSerialNumber(QcGoal qcGoal) {
|
||||
// int liushuiNum = qcGoalMapper.getTodayMaxNum(qcGoal);
|
||||
// String liushuiStr = String.format("%04d", liushuiNum);
|
||||
// String dateNumber = DateUtils.parseDateToStr(DateUtils.YYYYMMDD, DateUtils.getNowDate());
|
||||
// return dateNumber + liushuiStr;
|
||||
// }
|
||||
// @DS("#header.poolName")
|
||||
// private String getFactoryCode() {
|
||||
// HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
// String key = "#header.poolName";
|
||||
// return request.getHeader(key.substring(8)).replace("ds_", "");
|
||||
// }
|
||||
//
|
||||
//}
|
||||
package com.op.quality.service.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.op.common.core.utils.DateUtils;
|
||||
import com.op.common.security.utils.SecurityUtils;
|
||||
import com.op.quality.domain.vo.TreeSelect;
|
||||
import com.sun.xml.bind.v2.TODO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.op.quality.mapper.QcGoalMapper;
|
||||
import com.op.quality.domain.QcGoal;
|
||||
import com.op.quality.service.IQcGoalService;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 质量目标Service业务层处理
|
||||
*
|
||||
* @author Open Platform
|
||||
* @date 2024-03-04
|
||||
*/
|
||||
@Service
|
||||
public class QcGoalServiceImpl implements IQcGoalService {
|
||||
@Autowired
|
||||
private QcGoalMapper qcGoalMapper;
|
||||
|
||||
/**
|
||||
* 查询质量目标
|
||||
*
|
||||
* @param id 质量目标主键
|
||||
* @return 质量目标
|
||||
*/
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public QcGoal selectQcGoalById(String id) {
|
||||
return qcGoalMapper.selectQcGoalById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询质量目标列表
|
||||
*
|
||||
* @param qcGoal 质量目标
|
||||
* @return 质量目标
|
||||
*/
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public List<QcGoal> selectQcGoalList(QcGoal qcGoal) {
|
||||
List<QcGoal> qcGoals = qcGoalMapper.selectQcGoalList(qcGoal);
|
||||
for (QcGoal item : qcGoals) {
|
||||
item.setHasChildren(true);
|
||||
}
|
||||
return qcGoals;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public List<QcGoal> selectChildrenByParent(QcGoal goal) {
|
||||
return qcGoalMapper.selectChildrenByParent(goal);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public List<TreeSelect> buildQcGoalTreeSelect(List<QcGoal> qcGoals) {
|
||||
List<QcGoal> qcGoalTrees = buildGoalTree(qcGoals);
|
||||
return qcGoalTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增质量目标
|
||||
*
|
||||
* @param qcGoal 质量目标
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public int insertQcGoal(QcGoal qcGoal) {
|
||||
qcGoal.setCreateTime(DateUtils.getNowDate());
|
||||
qcGoal.setCreateBy(SecurityUtils.getUsername());
|
||||
|
||||
qcGoal.setId(getSerialNumber(qcGoal));
|
||||
qcGoal.setFactoryCode(getFactoryCode());
|
||||
qcGoal.setParentGoal("0");
|
||||
|
||||
return qcGoalMapper.insertQcGoal(qcGoal);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public List<QcGoal> generate(String id) {
|
||||
QcGoal goal = qcGoalMapper.selectQcGoalById(id);
|
||||
List<QcGoal> genResult = new ArrayList<>();
|
||||
|
||||
// 提前分配大小,有助于减少不必要的计算和内存分配,从而提高代码的性能。
|
||||
String goalYm = goal.getGoalYm();
|
||||
BigDecimal nookQualityRate = goal.getNookQualityRate();
|
||||
BigDecimal nookRate = goal.getNookRate();
|
||||
String checkType = goal.getCheckType();
|
||||
String typeCode = goal.getTypeCode();
|
||||
String factoryCode = getFactoryCode();
|
||||
String username = SecurityUtils.getUsername();
|
||||
Date nowDate = DateUtils.getNowDate();
|
||||
String parentGoal = goal.getId();
|
||||
|
||||
|
||||
int liushuiNum = qcGoalMapper.getTodayMaxNum(goal);
|
||||
String dateNumber = DateUtils.parseDateToStr(DateUtils.YYYYMMDD, DateUtils.getNowDate());
|
||||
|
||||
int month = 12;
|
||||
for (int i = 1; i <= month; i++) {
|
||||
QcGoal monthGoal = new QcGoal();
|
||||
|
||||
String liushuiStr = String.format("%04d", liushuiNum+i-1);
|
||||
monthGoal.setId(dateNumber+liushuiStr);
|
||||
String mon = String.format("%02d",i);
|
||||
monthGoal.setGoalYm(goalYm+"-"+mon);
|
||||
monthGoal.setGoalType("mm");
|
||||
monthGoal.setNookQualityRate(nookQualityRate);
|
||||
monthGoal.setNookRate(nookRate);
|
||||
monthGoal.setCheckType(checkType);
|
||||
monthGoal.setTypeCode(typeCode);
|
||||
monthGoal.setScope(goal.getScope());
|
||||
monthGoal.setCreateTime(nowDate);
|
||||
monthGoal.setCreateBy(username);
|
||||
monthGoal.setFactoryCode(factoryCode);
|
||||
monthGoal.setParentGoal(parentGoal);
|
||||
genResult.add(monthGoal);
|
||||
}
|
||||
// 批量插入
|
||||
int flag = qcGoalMapper.insertQcGoalList(genResult);
|
||||
if (flag > 0) {
|
||||
return genResult;
|
||||
}else {
|
||||
return goal.getChildren();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改质量目标
|
||||
*
|
||||
* @param qcGoal 质量目标
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public int updateQcGoal(QcGoal qcGoal) {
|
||||
qcGoal.setUpdateTime(DateUtils.getNowDate());
|
||||
qcGoal.setUpdateBy(SecurityUtils.getUsername());
|
||||
return qcGoalMapper.updateQcGoal(qcGoal);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除质量目标
|
||||
*
|
||||
* @param ids 需要删除的质量目标主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public int deleteQcGoalByIds(String[] ids) {
|
||||
boolean flag = false;
|
||||
for (String id : ids) {
|
||||
QcGoal goal = new QcGoal();
|
||||
goal.setParentGoal(id);
|
||||
List<QcGoal> hasChildren = qcGoalMapper.selectChildrenByParent(goal);
|
||||
if (hasChildren.size() > 0) {
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
return 0;
|
||||
}else {
|
||||
return qcGoalMapper.deleteQcGoalByIds(ids);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除质量目标信息
|
||||
*
|
||||
* @param id 质量目标主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public int deleteQcGoalById(String id) {
|
||||
return qcGoalMapper.deleteQcGoalById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QcGoal> buildGoalTree(List<QcGoal> qcGoals) {
|
||||
List<QcGoal> returnList = new ArrayList<>();
|
||||
List<String> tempList = qcGoals.stream().map(QcGoal::getId).collect(Collectors.toList());
|
||||
for (Iterator<QcGoal> iterator = qcGoals.iterator(); iterator.hasNext(); ) {
|
||||
QcGoal qcGoal = (QcGoal) iterator.next();
|
||||
//如果是顶级节点,遍历父节点的所有子节点
|
||||
if (!tempList.contains(qcGoal.getParentGoal())) {
|
||||
List<QcGoal> childList = getChildList(qcGoals,qcGoal);
|
||||
qcGoal.setChildren(childList);
|
||||
returnList.add(qcGoal);
|
||||
}
|
||||
}
|
||||
if (returnList.isEmpty()) {
|
||||
returnList = qcGoals;
|
||||
}
|
||||
return returnList;
|
||||
}
|
||||
|
||||
private List<QcGoal> getChildList(List<QcGoal> list, QcGoal t) {
|
||||
List<QcGoal> tlist = new ArrayList<>();
|
||||
Iterator<QcGoal> it = list.iterator();
|
||||
while (it.hasNext()) {
|
||||
QcGoal goal = (QcGoal) it.next();
|
||||
if (goal.getParentGoal().equals(t.getId())){
|
||||
tlist.add(goal);
|
||||
}
|
||||
}
|
||||
return tlist;
|
||||
}
|
||||
|
||||
@DS("#header.poolName")
|
||||
private String getSerialNumber(QcGoal qcGoal) {
|
||||
int liushuiNum = qcGoalMapper.getTodayMaxNum(qcGoal);
|
||||
String liushuiStr = String.format("%04d", liushuiNum);
|
||||
String dateNumber = DateUtils.parseDateToStr(DateUtils.YYYYMMDD, DateUtils.getNowDate());
|
||||
return dateNumber + liushuiStr;
|
||||
}
|
||||
@DS("#header.poolName")
|
||||
private String getFactoryCode() {
|
||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
String key = "#header.poolName";
|
||||
return request.getHeader(key.substring(8)).replace("ds_", "");
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue