质量目标暂时注释

master
zhaoxiaolin 1 year ago
parent 217a7ee237
commit 73a3ffbc3d

@ -9,7 +9,7 @@ import com.op.common.log.annotation.Log;
import com.op.common.log.enums.BusinessType; import com.op.common.log.enums.BusinessType;
import com.op.common.security.annotation.RequiresPermissions; import com.op.common.security.annotation.RequiresPermissions;
import com.op.quality.domain.QcGoal; import com.op.quality.domain.QcGoal;
import com.op.quality.service.IQcGoalService; //import com.op.quality.service.IQcGoalService;
import com.op.common.core.web.controller.BaseController; import com.op.common.core.web.controller.BaseController;
import com.op.common.core.web.domain.AjaxResult; import com.op.common.core.web.domain.AjaxResult;
import com.op.common.core.utils.poi.ExcelUtil; import com.op.common.core.utils.poi.ExcelUtil;
@ -24,103 +24,103 @@ import com.op.common.core.web.page.TableDataInfo;
@RestController @RestController
@RequestMapping("/qcGoal") @RequestMapping("/qcGoal")
public class QcGoalController extends BaseController { public class QcGoalController extends BaseController {
@Autowired // @Autowired
private IQcGoalService qcGoalService; // private IQcGoalService qcGoalService;
//
/** // /**
* // * 查询质量目标列表
*/ // */
@RequiresPermissions("quality:qcGoal:list") // @RequiresPermissions("quality:qcGoal:list")
@GetMapping("/list") // @GetMapping("/list")
public TableDataInfo list(QcGoal qcGoal) { // public TableDataInfo list(QcGoal qcGoal) {
startPage(); // startPage();
List<QcGoal> list = qcGoalService.selectQcGoalList(qcGoal); // List<QcGoal> list = qcGoalService.selectQcGoalList(qcGoal);
return getDataTable(list); // return getDataTable(list);
} // }
//
/** // /**
* // * 查询二级质量目标
*/ // */
@GetMapping("/getChildrenList/{parentId}") // @GetMapping("/getChildrenList/{parentId}")
public List<QcGoal> getChildrenList(@PathVariable("parentId") String parentId) { // public List<QcGoal> getChildrenList(@PathVariable("parentId") String parentId) {
QcGoal goal = new QcGoal(); // QcGoal goal = new QcGoal();
goal.setParentGoal(parentId); // goal.setParentGoal(parentId);
List<QcGoal> list = qcGoalService.selectChildrenByParent(goal); // List<QcGoal> list = qcGoalService.selectChildrenByParent(goal);
return list; // return list;
} // }
//
/** // /**
* // * 导出质量目标列表
*/ // */
@RequiresPermissions("quality:qcGoal:export") // @RequiresPermissions("quality:qcGoal:export")
@Log(title = "质量目标", businessType = BusinessType.EXPORT) // @Log(title = "质量目标", businessType = BusinessType.EXPORT)
@PostMapping("/export") // @PostMapping("/export")
public void export(HttpServletResponse response, QcGoal qcGoal) { // public void export(HttpServletResponse response, QcGoal qcGoal) {
List<QcGoal> list = qcGoalService.selectQcGoalList(qcGoal); // List<QcGoal> list = qcGoalService.selectQcGoalList(qcGoal);
ExcelUtil<QcGoal> util = new ExcelUtil<QcGoal>(QcGoal. class); // ExcelUtil<QcGoal> util = new ExcelUtil<QcGoal>(QcGoal. class);
util.exportExcel(response, list, "质量目标数据"); // util.exportExcel(response, list, "质量目标数据");
} // }
//
/** // /**
* // * 获取质量目标详细信息
*/ // */
@RequiresPermissions("quality:qcGoal:query") // @RequiresPermissions("quality:qcGoal:query")
@GetMapping(value = "/{id}") // @GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id) { // public AjaxResult getInfo(@PathVariable("id") String id) {
return success(qcGoalService.selectQcGoalById(id)); // return success(qcGoalService.selectQcGoalById(id));
} // }
//
/** // /**
* // * 获取质量目标下拉树列表
*/ // */
@GetMapping("/treeSelect") // @GetMapping("/treeSelect")
public AjaxResult treeSelect(QcGoal qcGoal) { // public AjaxResult treeSelect(QcGoal qcGoal) {
List<QcGoal> qcGoals = qcGoalService.selectQcGoalList(qcGoal); // List<QcGoal> qcGoals = qcGoalService.selectQcGoalList(qcGoal);
return success(qcGoalService.buildQcGoalTreeSelect(qcGoals)); // return success(qcGoalService.buildQcGoalTreeSelect(qcGoals));
} // }
//
/** // /**
* // * 新增质量目标
*/ // */
@RequiresPermissions("quality:qcGoal:add") // @RequiresPermissions("quality:qcGoal:add")
@Log(title = "质量目标", businessType = BusinessType.INSERT) // @Log(title = "质量目标", businessType = BusinessType.INSERT)
@PostMapping // @PostMapping
public AjaxResult add(@RequestBody QcGoal qcGoal) { // public AjaxResult add(@RequestBody QcGoal qcGoal) {
return toAjax(qcGoalService.insertQcGoal(qcGoal)); // return toAjax(qcGoalService.insertQcGoal(qcGoal));
} // }
//
/** // /**
* // * 拆解质量目标
*/ // */
@GetMapping("/generate/{id}") // @GetMapping("/generate/{id}")
public TableDataInfo generate(@PathVariable("id") String id) { // public TableDataInfo generate(@PathVariable("id") String id) {
List<QcGoal> qcGoalList = qcGoalService.generate(id); // List<QcGoal> qcGoalList = qcGoalService.generate(id);
return getDataTable(qcGoalList); // return getDataTable(qcGoalList);
} // }
//
//
/** // /**
* // * 修改质量目标
*/ // */
@RequiresPermissions("quality:qcGoal:edit") // @RequiresPermissions("quality:qcGoal:edit")
@Log(title = "质量目标", businessType = BusinessType.UPDATE) // @Log(title = "质量目标", businessType = BusinessType.UPDATE)
@PutMapping // @PutMapping
public AjaxResult edit(@RequestBody QcGoal qcGoal) { // public AjaxResult edit(@RequestBody QcGoal qcGoal) {
return toAjax(qcGoalService.updateQcGoal(qcGoal)); // return toAjax(qcGoalService.updateQcGoal(qcGoal));
} // }
//
/** // /**
* // * 删除质量目标
*/ // */
@RequiresPermissions("quality:qcGoal:remove") // @RequiresPermissions("quality:qcGoal:remove")
@Log(title = "质量目标", businessType = BusinessType.DELETE) // @Log(title = "质量目标", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}") // @DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids) { // public AjaxResult remove(@PathVariable String[] ids) {
int rows = qcGoalService.deleteQcGoalByIds(ids); // int rows = qcGoalService.deleteQcGoalByIds(ids);
if (rows > 0 ) { // if (rows > 0 ) {
return success("操作成功"); // return success("操作成功");
}else { // }else {
return error("操作失败,请检查要删除的项目是否含有子项目"); // return error("操作失败,请检查要删除的项目是否含有子项目");
} // }
} // }
} }

@ -17,7 +17,7 @@ import com.op.common.log.annotation.Log;
import com.op.common.log.enums.BusinessType; import com.op.common.log.enums.BusinessType;
import com.op.common.security.annotation.RequiresPermissions; import com.op.common.security.annotation.RequiresPermissions;
import com.op.quality.domain.QcGoalDistribute; import com.op.quality.domain.QcGoalDistribute;
import com.op.quality.service.IQcGoalDistributeService; //import com.op.quality.service.IQcGoalDistributeService;
import com.op.common.core.web.controller.BaseController; import com.op.common.core.web.controller.BaseController;
import com.op.common.core.web.domain.AjaxResult; import com.op.common.core.web.domain.AjaxResult;
import com.op.common.core.utils.poi.ExcelUtil; import com.op.common.core.utils.poi.ExcelUtil;
@ -32,87 +32,87 @@ import com.op.common.core.web.page.TableDataInfo;
@RestController @RestController
@RequestMapping("/qcGoalDistribute") @RequestMapping("/qcGoalDistribute")
public class QcGoalDistributeController extends BaseController { public class QcGoalDistributeController extends BaseController {
@Autowired // @Autowired
private IQcGoalDistributeService qcGoalDistributeService; // private IQcGoalDistributeService qcGoalDistributeService;
//
/** ///**
* // * 查询质量目标分配列表
*/ // */
@RequiresPermissions("quality:qcGoalDistribute:list") //@RequiresPermissions("quality:qcGoalDistribute:list")
@GetMapping("/list") //@GetMapping("/list")
public TableDataInfo list(QcGoalDistribute qcGoalDistribute) { // public TableDataInfo list(QcGoalDistribute qcGoalDistribute) {
startPage(); // startPage();
List<QcGoalDistribute> list = qcGoalDistributeService.selectQcGoalDistributeList(qcGoalDistribute); // List<QcGoalDistribute> list = qcGoalDistributeService.selectQcGoalDistributeList(qcGoalDistribute);
return getDataTable(list); // return getDataTable(list);
} // }
//
/** // /**
* // * 导出质量目标分配列表
*/ // */
@RequiresPermissions("quality:qcGoalDistribute:export") // @RequiresPermissions("quality:qcGoalDistribute:export")
@Log(title = "质量目标分配", businessType = BusinessType.EXPORT) // @Log(title = "质量目标分配", businessType = BusinessType.EXPORT)
@PostMapping("/export") // @PostMapping("/export")
public void export(HttpServletResponse response, QcGoalDistribute qcGoalDistribute) { // public void export(HttpServletResponse response, QcGoalDistribute qcGoalDistribute) {
List<QcGoalDistribute> list = qcGoalDistributeService.selectQcGoalDistributeList(qcGoalDistribute); // List<QcGoalDistribute> list = qcGoalDistributeService.selectQcGoalDistributeList(qcGoalDistribute);
ExcelUtil<QcGoalDistribute> util = new ExcelUtil<QcGoalDistribute>(QcGoalDistribute. class); // ExcelUtil<QcGoalDistribute> util = new ExcelUtil<QcGoalDistribute>(QcGoalDistribute. class);
util.exportExcel(response, list, "质量目标分配数据"); // util.exportExcel(response, list, "质量目标分配数据");
} // }
//
/** // /**
* // * 获取质量目标分配详细信息
*/ // */
@RequiresPermissions("quality:qcGoalDistribute:query") // @RequiresPermissions("quality:qcGoalDistribute:query")
@GetMapping(value = "/{id}") // @GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id) { // public AjaxResult getInfo(@PathVariable("id") String id) {
return success(qcGoalDistributeService.selectQcGoalDistributeById(id)); // return success(qcGoalDistributeService.selectQcGoalDistributeById(id));
} // }
//
/** // /**
* // * 新增质量目标分配
*/ // */
@Log(title = "质量目标分配", businessType = BusinessType.INSERT) // @Log(title = "质量目标分配", businessType = BusinessType.INSERT)
@PostMapping // @PostMapping
public AjaxResult add(@RequestBody QcGoalDistribute qcGoalDistribute) { // public AjaxResult add(@RequestBody QcGoalDistribute qcGoalDistribute) {
return toAjax(qcGoalDistributeService.insertQcGoalDistribute(qcGoalDistribute)); // return toAjax(qcGoalDistributeService.insertQcGoalDistribute(qcGoalDistribute));
} // }
//
/** // /**
* // * 修改质量目标分配
*/ // */
@RequiresPermissions("quality:qcGoalDistribute:edit") // @RequiresPermissions("quality:qcGoalDistribute:edit")
@Log(title = "质量目标分配", businessType = BusinessType.UPDATE) // @Log(title = "质量目标分配", businessType = BusinessType.UPDATE)
@PutMapping // @PutMapping
public AjaxResult edit(@RequestBody QcGoalDistribute qcGoalDistribute) { // public AjaxResult edit(@RequestBody QcGoalDistribute qcGoalDistribute) {
return toAjax(qcGoalDistributeService.updateQcGoalDistribute(qcGoalDistribute)); // return toAjax(qcGoalDistributeService.updateQcGoalDistribute(qcGoalDistribute));
} // }
//
/** // /**
* // * 删除质量目标分配
*/ // */
@RequiresPermissions("quality:qcGoalDistribute:remove") // @RequiresPermissions("quality:qcGoalDistribute:remove")
@Log(title = "质量目标分配", businessType = BusinessType.DELETE) // @Log(title = "质量目标分配", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}") // @DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids) { // public AjaxResult remove(@PathVariable String[] ids) {
return toAjax(qcGoalDistributeService.deleteQcGoalDistributeByIds(ids)); // return toAjax(qcGoalDistributeService.deleteQcGoalDistributeByIds(ids));
} // }
/** // /**
* // * 获取未分配供应商数据
*/ // */
@GetMapping(value = "/getLeftList") // @GetMapping(value = "/getLeftList")
public TableDataInfo getLeftList(QcGoalDistribute qcGoalDistribute) { // public TableDataInfo getLeftList(QcGoalDistribute qcGoalDistribute) {
startPage(); // startPage();
List<QcGoalDistribute> list = qcGoalDistributeService.getLeftList(qcGoalDistribute); // List<QcGoalDistribute> list = qcGoalDistributeService.getLeftList(qcGoalDistribute);
return getDataTable(list); // return getDataTable(list);
} // }
//
/** // /**
* // * 获取已分配供应商数据
*/ // */
@GetMapping(value = "/getRightList") // @GetMapping(value = "/getRightList")
public TableDataInfo getRightList(QcGoalDistribute qcGoalDistribute) { // public TableDataInfo getRightList(QcGoalDistribute qcGoalDistribute) {
startPage(); // startPage();
List<QcGoalDistribute> list = qcGoalDistributeService.getRightList(qcGoalDistribute); // List<QcGoalDistribute> list = qcGoalDistributeService.getRightList(qcGoalDistribute);
return getDataTable(list); // return getDataTable(list);
} // }
} }

@ -1,153 +1,153 @@
package com.op.quality.service.impl; //package com.op.quality.service.impl;
//
import java.util.Date; //import java.util.Date;
import java.util.List; //import java.util.List;
//
import com.baomidou.dynamic.datasource.annotation.DS; //import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.utils.DateUtils; //import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.StringUtils; //import com.op.common.core.utils.StringUtils;
import com.op.common.core.utils.uuid.IdUtils; //import com.op.common.core.utils.uuid.IdUtils;
import com.op.common.security.utils.SecurityUtils; //import com.op.common.security.utils.SecurityUtils;
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 com.op.quality.mapper.QcGoalDistributeMapper; //import com.op.quality.mapper.QcGoalDistributeMapper;
import com.op.quality.domain.QcGoalDistribute; //import com.op.quality.domain.QcGoalDistribute;
import com.op.quality.service.IQcGoalDistributeService; //import com.op.quality.service.IQcGoalDistributeService;
import org.springframework.web.context.request.RequestContextHolder; //import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; //import org.springframework.web.context.request.ServletRequestAttributes;
//
import javax.servlet.http.HttpServletRequest; //import javax.servlet.http.HttpServletRequest;
//
/** ///**
* Service // * 质量目标分配Service业务层处理
* // *
* @author Open Platform // * @author Open Platform
* @date 2024-03-07 // * @date 2024-03-07
*/ // */
@Service //@Service
public class QcGoalDistributeServiceImpl implements IQcGoalDistributeService { //public class QcGoalDistributeServiceImpl implements IQcGoalDistributeService {
@Autowired // @Autowired
private QcGoalDistributeMapper qcGoalDistributeMapper; // private QcGoalDistributeMapper qcGoalDistributeMapper;
//
/** // /**
* // * 查询质量目标分配
* // *
* @param id // * @param id 质量目标分配主键
* @return // * @return 质量目标分配
*/ // */
@Override // @Override
@DS("#header.poolName") // @DS("#header.poolName")
public QcGoalDistribute selectQcGoalDistributeById(String id) { // public QcGoalDistribute selectQcGoalDistributeById(String id) {
return qcGoalDistributeMapper.selectQcGoalDistributeById(id); // return qcGoalDistributeMapper.selectQcGoalDistributeById(id);
} // }
//
/** // /**
* // * 查询质量目标分配列表
* // *
* @param qcGoalDistribute // * @param qcGoalDistribute 质量目标分配
* @return // * @return 质量目标分配
*/ // */
@Override // @Override
@DS("#header.poolName") // @DS("#header.poolName")
public List<QcGoalDistribute> selectQcGoalDistributeList(QcGoalDistribute qcGoalDistribute) { // public List<QcGoalDistribute> selectQcGoalDistributeList(QcGoalDistribute qcGoalDistribute) {
return qcGoalDistributeMapper.selectQcGoalDistributeList(qcGoalDistribute); // return qcGoalDistributeMapper.selectQcGoalDistributeList(qcGoalDistribute);
} // }
//
/** // /**
* // * 新增质量目标分配
* // *
* @param qcGoalDistribute // * @param qcGoalDistribute 质量目标分配
* @return // * @return 结果
*/ // */
@Override // @Override
@DS("#header.poolName") // @DS("#header.poolName")
public int insertQcGoalDistribute(QcGoalDistribute qcGoalDistribute) { // public int insertQcGoalDistribute(QcGoalDistribute qcGoalDistribute) {
//
if (StringUtils.isNotEmpty(qcGoalDistribute.getBelongGoalId())) { // if (StringUtils.isNotEmpty(qcGoalDistribute.getBelongGoalId())) {
qcGoalDistributeMapper.deleteQcGoalDistributeByBelongId(qcGoalDistribute.getBelongGoalId()); // qcGoalDistributeMapper.deleteQcGoalDistributeByBelongId(qcGoalDistribute.getBelongGoalId());
} // }
int count = 0; // int count = 0;
if (qcGoalDistribute.getSelectedValues().size() > 0){ // if (qcGoalDistribute.getSelectedValues().size() > 0){
QcGoalDistribute dto = null; // QcGoalDistribute dto = null;
Date now = DateUtils.getNowDate(); // Date now = DateUtils.getNowDate();
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); // HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName"; // String key = "#header.poolName";
String factoryCode = request.getHeader(key.substring(8)).replace("ds_", ""); // String factoryCode = request.getHeader(key.substring(8)).replace("ds_", "");
for (String supplierCode : qcGoalDistribute.getSelectedValues()) { // for (String supplierCode : qcGoalDistribute.getSelectedValues()) {
dto = new QcGoalDistribute(); // dto = new QcGoalDistribute();
dto.setId(IdUtils.fastSimpleUUID()); // dto.setId(IdUtils.fastSimpleUUID());
dto.setCreateTime(now); // dto.setCreateTime(now);
dto.setCreateBy(SecurityUtils.getUsername()); // dto.setCreateBy(SecurityUtils.getUsername());
dto.setBelongGoalId(qcGoalDistribute.getBelongGoalId()); // dto.setBelongGoalId(qcGoalDistribute.getBelongGoalId());
dto.setSupplierCode(supplierCode); // dto.setSupplierCode(supplierCode);
dto.setFactoryCode(factoryCode); // dto.setFactoryCode(factoryCode);
count += qcGoalDistributeMapper.insertQcGoalDistribute(dto); // count += qcGoalDistributeMapper.insertQcGoalDistribute(dto);
} // }
}else { // }else {
count = 1; // count = 1;
} // }
return count; // return count;
} // }
//
/** // /**
* // * 修改质量目标分配
* // *
* @param qcGoalDistribute // * @param qcGoalDistribute 质量目标分配
* @return // * @return 结果
*/ // */
@Override // @Override
@DS("#header.poolName") // @DS("#header.poolName")
public int updateQcGoalDistribute(QcGoalDistribute qcGoalDistribute) { // public int updateQcGoalDistribute(QcGoalDistribute qcGoalDistribute) {
qcGoalDistribute.setUpdateTime(DateUtils.getNowDate()); // qcGoalDistribute.setUpdateTime(DateUtils.getNowDate());
return qcGoalDistributeMapper.updateQcGoalDistribute(qcGoalDistribute); // return qcGoalDistributeMapper.updateQcGoalDistribute(qcGoalDistribute);
} // }
//
/** // /**
* // * 批量删除质量目标分配
* // *
* @param ids // * @param ids 需要删除的质量目标分配主键
* @return // * @return 结果
*/ // */
@Override // @Override
@DS("#header.poolName") // @DS("#header.poolName")
public int deleteQcGoalDistributeByIds(String[] ids) { // public int deleteQcGoalDistributeByIds(String[] ids) {
return qcGoalDistributeMapper.deleteQcGoalDistributeByIds(ids); // return qcGoalDistributeMapper.deleteQcGoalDistributeByIds(ids);
} // }
//
/** // /**
* // * 删除质量目标分配信息
* // *
* @param id // * @param id 质量目标分配主键
* @return // * @return 结果
*/ // */
@Override // @Override
@DS("#header.poolName") // @DS("#header.poolName")
public int deleteQcGoalDistributeById(String id) { // public int deleteQcGoalDistributeById(String id) {
return qcGoalDistributeMapper.deleteQcGoalDistributeById(id); // return qcGoalDistributeMapper.deleteQcGoalDistributeById(id);
} // }
//
@Override // @Override
@DS("#header.poolName") // @DS("#header.poolName")
public List<QcGoalDistribute> getLeftList(QcGoalDistribute qcGoalDistribute) { // public List<QcGoalDistribute> getLeftList(QcGoalDistribute qcGoalDistribute) {
List<QcGoalDistribute> dto = qcGoalDistributeMapper.getGoalDistributeUndo(qcGoalDistribute); // List<QcGoalDistribute> dto = qcGoalDistributeMapper.getGoalDistributeUndo(qcGoalDistribute);
List<QcGoalDistribute> selected = qcGoalDistributeMapper.getGoalDistributeDo(qcGoalDistribute); // List<QcGoalDistribute> selected = qcGoalDistributeMapper.getGoalDistributeDo(qcGoalDistribute);
dto.addAll(selected); // dto.addAll(selected);
dto.forEach(item -> { // dto.forEach(item -> {
item.setKey(item.getSupplierCode()); // item.setKey(item.getSupplierCode());
}); // });
return dto; // return dto;
} // }
//
@Override // @Override
@DS("#header.poolName") // @DS("#header.poolName")
public List<QcGoalDistribute> getRightList(QcGoalDistribute qcGoalDistribute) { // public List<QcGoalDistribute> getRightList(QcGoalDistribute qcGoalDistribute) {
List<QcGoalDistribute> selected = qcGoalDistributeMapper.getGoalDistributeDo(qcGoalDistribute); // List<QcGoalDistribute> selected = qcGoalDistributeMapper.getGoalDistributeDo(qcGoalDistribute);
selected.forEach(item -> { // selected.forEach(item -> {
item.setKey(item.getSupplierCode()); // item.setKey(item.getSupplierCode());
}); // });
return selected; // return selected;
} // }
//
//
//
} //}

@ -1,245 +1,245 @@
package com.op.quality.service.impl; //package com.op.quality.service.impl;
//
import java.math.BigDecimal; //import java.math.BigDecimal;
import java.util.ArrayList; //import java.util.ArrayList;
import java.util.Date; //import java.util.Date;
import java.util.Iterator; //import java.util.Iterator;
import java.util.List; //import java.util.List;
import java.util.stream.Collectors; //import java.util.stream.Collectors;
//
import com.baomidou.dynamic.datasource.annotation.DS; //import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.utils.DateUtils; //import com.op.common.core.utils.DateUtils;
import com.op.common.security.utils.SecurityUtils; //import com.op.common.security.utils.SecurityUtils;
import com.op.quality.domain.vo.TreeSelect; //import com.op.quality.domain.vo.TreeSelect;
import com.sun.xml.bind.v2.TODO; //import com.sun.xml.bind.v2.TODO;
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 com.op.quality.mapper.QcGoalMapper; //import com.op.quality.mapper.QcGoalMapper;
import com.op.quality.domain.QcGoal; //import com.op.quality.domain.QcGoal;
import com.op.quality.service.IQcGoalService; //import com.op.quality.service.IQcGoalService;
import org.springframework.util.ObjectUtils; //import org.springframework.util.ObjectUtils;
import org.springframework.web.context.request.RequestContextHolder; //import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; //import org.springframework.web.context.request.ServletRequestAttributes;
//
import javax.servlet.http.HttpServletRequest; //import javax.servlet.http.HttpServletRequest;
//
/** ///**
* Service // * 质量目标Service业务层处理
* // *
* @author Open Platform // * @author Open Platform
* @date 2024-03-04 // * @date 2024-03-04
*/ // */
@Service //@Service
public class QcGoalServiceImpl implements IQcGoalService { //public class QcGoalServiceImpl implements IQcGoalService {
@Autowired // @Autowired
private QcGoalMapper qcGoalMapper; // private QcGoalMapper qcGoalMapper;
//
/** // /**
* // * 查询质量目标
* // *
* @param id // * @param id 质量目标主键
* @return // * @return 质量目标
*/ // */
@Override // @Override
@DS("#header.poolName") // @DS("#header.poolName")
public QcGoal selectQcGoalById(String id) { // public QcGoal selectQcGoalById(String id) {
return qcGoalMapper.selectQcGoalById(id); // return qcGoalMapper.selectQcGoalById(id);
} // }
//
/** // /**
* // * 查询质量目标列表
* // *
* @param qcGoal // * @param qcGoal 质量目标
* @return // * @return 质量目标
*/ // */
@Override // @Override
@DS("#header.poolName") // @DS("#header.poolName")
public List<QcGoal> selectQcGoalList(QcGoal qcGoal) { // public List<QcGoal> selectQcGoalList(QcGoal qcGoal) {
List<QcGoal> qcGoals = qcGoalMapper.selectQcGoalList(qcGoal); // List<QcGoal> qcGoals = qcGoalMapper.selectQcGoalList(qcGoal);
for (QcGoal item : qcGoals) { // for (QcGoal item : qcGoals) {
item.setHasChildren(true); // item.setHasChildren(true);
} // }
return qcGoals; // return qcGoals;
} // }
//
@Override // @Override
@DS("#header.poolName") // @DS("#header.poolName")
public List<QcGoal> selectChildrenByParent(QcGoal goal) { // public List<QcGoal> selectChildrenByParent(QcGoal goal) {
return qcGoalMapper.selectChildrenByParent(goal); // return qcGoalMapper.selectChildrenByParent(goal);
} // }
//
@Override // @Override
@DS("#header.poolName") // @DS("#header.poolName")
public List<TreeSelect> buildQcGoalTreeSelect(List<QcGoal> qcGoals) { // public List<TreeSelect> buildQcGoalTreeSelect(List<QcGoal> qcGoals) {
List<QcGoal> qcGoalTrees = buildGoalTree(qcGoals); // List<QcGoal> qcGoalTrees = buildGoalTree(qcGoals);
return qcGoalTrees.stream().map(TreeSelect::new).collect(Collectors.toList()); // return qcGoalTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
} // }
//
/** // /**
* // * 新增质量目标
* // *
* @param qcGoal // * @param qcGoal 质量目标
* @return // * @return 结果
*/ // */
@Override // @Override
@DS("#header.poolName") // @DS("#header.poolName")
public int insertQcGoal(QcGoal qcGoal) { // public int insertQcGoal(QcGoal qcGoal) {
qcGoal.setCreateTime(DateUtils.getNowDate()); // qcGoal.setCreateTime(DateUtils.getNowDate());
qcGoal.setCreateBy(SecurityUtils.getUsername()); // qcGoal.setCreateBy(SecurityUtils.getUsername());
//
qcGoal.setId(getSerialNumber(qcGoal)); // qcGoal.setId(getSerialNumber(qcGoal));
qcGoal.setFactoryCode(getFactoryCode()); // qcGoal.setFactoryCode(getFactoryCode());
qcGoal.setParentGoal("0"); // qcGoal.setParentGoal("0");
//
return qcGoalMapper.insertQcGoal(qcGoal); // return qcGoalMapper.insertQcGoal(qcGoal);
} // }
//
@Override // @Override
@DS("#header.poolName") // @DS("#header.poolName")
public List<QcGoal> generate(String id) { // public List<QcGoal> generate(String id) {
QcGoal goal = qcGoalMapper.selectQcGoalById(id); // QcGoal goal = qcGoalMapper.selectQcGoalById(id);
List<QcGoal> genResult = new ArrayList<>(); // List<QcGoal> genResult = new ArrayList<>();
//
// 提前分配大小,有助于减少不必要的计算和内存分配,从而提高代码的性能。 // // 提前分配大小,有助于减少不必要的计算和内存分配,从而提高代码的性能。
String goalYm = goal.getGoalYm(); // String goalYm = goal.getGoalYm();
BigDecimal nookQualityRate = goal.getNookQualityRate(); // BigDecimal nookQualityRate = goal.getNookQualityRate();
BigDecimal nookRate = goal.getNookRate(); // BigDecimal nookRate = goal.getNookRate();
String checkType = goal.getCheckType(); // String checkType = goal.getCheckType();
String typeCode = goal.getTypeCode(); // String typeCode = goal.getTypeCode();
String factoryCode = getFactoryCode(); // String factoryCode = getFactoryCode();
String username = SecurityUtils.getUsername(); // String username = SecurityUtils.getUsername();
Date nowDate = DateUtils.getNowDate(); // Date nowDate = DateUtils.getNowDate();
String parentGoal = goal.getId(); // String parentGoal = goal.getId();
//
//
int liushuiNum = qcGoalMapper.getTodayMaxNum(goal); // int liushuiNum = qcGoalMapper.getTodayMaxNum(goal);
String dateNumber = DateUtils.parseDateToStr(DateUtils.YYYYMMDD, DateUtils.getNowDate()); // String dateNumber = DateUtils.parseDateToStr(DateUtils.YYYYMMDD, DateUtils.getNowDate());
//
int month = 12; // int month = 12;
for (int i = 1; i <= month; i++) { // for (int i = 1; i <= month; i++) {
QcGoal monthGoal = new QcGoal(); // QcGoal monthGoal = new QcGoal();
//
String liushuiStr = String.format("%04d", liushuiNum+i-1); // String liushuiStr = String.format("%04d", liushuiNum+i-1);
monthGoal.setId(dateNumber+liushuiStr); // monthGoal.setId(dateNumber+liushuiStr);
String mon = String.format("%02d",i); // String mon = String.format("%02d",i);
monthGoal.setGoalYm(goalYm+"-"+mon); // monthGoal.setGoalYm(goalYm+"-"+mon);
monthGoal.setGoalType("mm"); // monthGoal.setGoalType("mm");
monthGoal.setNookQualityRate(nookQualityRate); // monthGoal.setNookQualityRate(nookQualityRate);
monthGoal.setNookRate(nookRate); // monthGoal.setNookRate(nookRate);
monthGoal.setCheckType(checkType); // monthGoal.setCheckType(checkType);
monthGoal.setTypeCode(typeCode); // monthGoal.setTypeCode(typeCode);
monthGoal.setScope(goal.getScope()); // monthGoal.setScope(goal.getScope());
monthGoal.setCreateTime(nowDate); // monthGoal.setCreateTime(nowDate);
monthGoal.setCreateBy(username); // monthGoal.setCreateBy(username);
monthGoal.setFactoryCode(factoryCode); // monthGoal.setFactoryCode(factoryCode);
monthGoal.setParentGoal(parentGoal); // monthGoal.setParentGoal(parentGoal);
genResult.add(monthGoal); // genResult.add(monthGoal);
} // }
// 批量插入 // // 批量插入
int flag = qcGoalMapper.insertQcGoalList(genResult); // int flag = qcGoalMapper.insertQcGoalList(genResult);
if (flag > 0) { // if (flag > 0) {
return genResult; // return genResult;
}else { // }else {
return goal.getChildren(); // return goal.getChildren();
} // }
//
} // }
//
/** // /**
* // * 修改质量目标
* // *
* @param qcGoal // * @param qcGoal 质量目标
* @return // * @return 结果
*/ // */
@Override // @Override
@DS("#header.poolName") // @DS("#header.poolName")
public int updateQcGoal(QcGoal qcGoal) { // public int updateQcGoal(QcGoal qcGoal) {
qcGoal.setUpdateTime(DateUtils.getNowDate()); // qcGoal.setUpdateTime(DateUtils.getNowDate());
qcGoal.setUpdateBy(SecurityUtils.getUsername()); // qcGoal.setUpdateBy(SecurityUtils.getUsername());
return qcGoalMapper.updateQcGoal(qcGoal); // return qcGoalMapper.updateQcGoal(qcGoal);
} // }
//
/** // /**
* // * 批量删除质量目标
* // *
* @param ids // * @param ids 需要删除的质量目标主键
* @return // * @return 结果
*/ // */
@Override // @Override
@DS("#header.poolName") // @DS("#header.poolName")
public int deleteQcGoalByIds(String[] ids) { // public int deleteQcGoalByIds(String[] ids) {
boolean flag = false; // boolean flag = false;
for (String id : ids) { // for (String id : ids) {
QcGoal goal = new QcGoal(); // QcGoal goal = new QcGoal();
goal.setParentGoal(id); // goal.setParentGoal(id);
List<QcGoal> hasChildren = qcGoalMapper.selectChildrenByParent(goal); // List<QcGoal> hasChildren = qcGoalMapper.selectChildrenByParent(goal);
if (hasChildren.size() > 0) { // if (hasChildren.size() > 0) {
flag = true; // flag = true;
break; // break;
} // }
} // }
if (flag) { // if (flag) {
return 0; // return 0;
}else { // }else {
return qcGoalMapper.deleteQcGoalByIds(ids); // return qcGoalMapper.deleteQcGoalByIds(ids);
} // }
} // }
//
/** // /**
* // * 删除质量目标信息
* // *
* @param id // * @param id 质量目标主键
* @return // * @return 结果
*/ // */
@Override // @Override
@DS("#header.poolName") // @DS("#header.poolName")
public int deleteQcGoalById(String id) { // public int deleteQcGoalById(String id) {
return qcGoalMapper.deleteQcGoalById(id); // return qcGoalMapper.deleteQcGoalById(id);
} // }
//
@Override // @Override
public List<QcGoal> buildGoalTree(List<QcGoal> qcGoals) { // public List<QcGoal> buildGoalTree(List<QcGoal> qcGoals) {
List<QcGoal> returnList = new ArrayList<>(); // List<QcGoal> returnList = new ArrayList<>();
List<String> tempList = qcGoals.stream().map(QcGoal::getId).collect(Collectors.toList()); // List<String> tempList = qcGoals.stream().map(QcGoal::getId).collect(Collectors.toList());
for (Iterator<QcGoal> iterator = qcGoals.iterator(); iterator.hasNext(); ) { // for (Iterator<QcGoal> iterator = qcGoals.iterator(); iterator.hasNext(); ) {
QcGoal qcGoal = (QcGoal) iterator.next(); // QcGoal qcGoal = (QcGoal) iterator.next();
//如果是顶级节点,遍历父节点的所有子节点 // //如果是顶级节点,遍历父节点的所有子节点
if (!tempList.contains(qcGoal.getParentGoal())) { // if (!tempList.contains(qcGoal.getParentGoal())) {
List<QcGoal> childList = getChildList(qcGoals,qcGoal); // List<QcGoal> childList = getChildList(qcGoals,qcGoal);
qcGoal.setChildren(childList); // qcGoal.setChildren(childList);
returnList.add(qcGoal); // returnList.add(qcGoal);
} // }
} // }
if (returnList.isEmpty()) { // if (returnList.isEmpty()) {
returnList = qcGoals; // returnList = qcGoals;
} // }
return returnList; // return returnList;
} // }
//
private List<QcGoal> getChildList(List<QcGoal> list, QcGoal t) { // private List<QcGoal> getChildList(List<QcGoal> list, QcGoal t) {
List<QcGoal> tlist = new ArrayList<>(); // List<QcGoal> tlist = new ArrayList<>();
Iterator<QcGoal> it = list.iterator(); // Iterator<QcGoal> it = list.iterator();
while (it.hasNext()) { // while (it.hasNext()) {
QcGoal goal = (QcGoal) it.next(); // QcGoal goal = (QcGoal) it.next();
if (goal.getParentGoal().equals(t.getId())){ // if (goal.getParentGoal().equals(t.getId())){
tlist.add(goal); // tlist.add(goal);
} // }
} // }
return tlist; // return tlist;
} // }
//
@DS("#header.poolName") // @DS("#header.poolName")
private String getSerialNumber(QcGoal qcGoal) { // private String getSerialNumber(QcGoal qcGoal) {
int liushuiNum = qcGoalMapper.getTodayMaxNum(qcGoal); // int liushuiNum = qcGoalMapper.getTodayMaxNum(qcGoal);
String liushuiStr = String.format("%04d", liushuiNum); // String liushuiStr = String.format("%04d", liushuiNum);
String dateNumber = DateUtils.parseDateToStr(DateUtils.YYYYMMDD, DateUtils.getNowDate()); // String dateNumber = DateUtils.parseDateToStr(DateUtils.YYYYMMDD, DateUtils.getNowDate());
return dateNumber + liushuiStr; // return dateNumber + liushuiStr;
} // }
@DS("#header.poolName") // @DS("#header.poolName")
private String getFactoryCode() { // private String getFactoryCode() {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); // HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName"; // String key = "#header.poolName";
return request.getHeader(key.substring(8)).replace("ds_", ""); // return request.getHeader(key.substring(8)).replace("ds_", "");
} // }
//
} //}

Loading…
Cancel
Save