设备管理-检查项维护(修改BUG修复)

highway
wws 1 year ago
parent 8b3acc99b7
commit 40f0238071

@ -31,215 +31,211 @@ import static com.op.common.core.web.domain.AjaxResult.success;
/**
* Service
*
*
* @author wws
* @date 2023-10-09
*/
@Service
public class EquCheckItemServiceImpl implements IEquCheckItemService {
@Autowired
private EquCheckItemMapper equCheckItemMapper;
@Autowired
private EquCheckItemDetailMapper equCheckItemDetailMapper;
/**
*
*
* @param itemId
* @return
*/
@Override
@DS("#header.poolName")
public EquCheckItemVO selectEquCheckItemByItemId(String itemId) {
EquCheckItem equCheckItem = equCheckItemMapper.selectEquCheckItemByItemId(itemId);
// 创建返回对象
EquCheckItemVO equCheckItemVO = new EquCheckItemVO();
BeanUtils.copyProperties(equCheckItem,equCheckItemVO);
equCheckItemVO.setFormStandard(equCheckItemDetailMapper.selectEquCheckItemDetailByParentCode(equCheckItem.getItemCode()));
return equCheckItemVO;
}
/**
*
*
* @param equCheckItem
* @return
*/
@Override
@DS("#header.poolName")
public List<EquCheckItem> selectEquCheckItemList(EquCheckItem equCheckItem) {
if (equCheckItem.getCreatedTimeArray() != null) {
// 设置创建日期开始和结束值
if (equCheckItem.getCreatedTimeArray().size() == 2) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
equCheckItem.setCreateTimeStart(formatter.format(equCheckItem.getCreatedTimeArray().get(0)));
equCheckItem.setCreateTimeEnd(formatter.format(equCheckItem.getCreatedTimeArray().get(1)));
}
}
if (equCheckItem.getUpdateTimeArray() != null) {
// 设置更新日期开始和结束
if (equCheckItem.getUpdateTimeArray().size() == 2) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
equCheckItem.setUpdateTimeStart(formatter.format(equCheckItem.getUpdateTimeArray().get(0)));
equCheckItem.setUpdateTimeEnd(formatter.format(equCheckItem.getUpdateTimeArray().get(1)));
}
}
return equCheckItemMapper.selectEquCheckItemList(equCheckItem);
}
/**
*
*
* @param equCheckItemDTO
* @return
* TODO
*/
@Override
@DS("#header.poolName")
public AjaxResult insertEquCheckItem(EquCheckItemDTO equCheckItemDTO) {
// 检验重复
EquCheckItem checkItem = equCheckItemMapper.selectEquCheckItemByItemName(equCheckItemDTO.getItemName());
if (checkItem != null) {
return error("检查项已存在!新增失败!");
}
// 创建检查项对象
EquCheckItem equCheckItem = new EquCheckItem();
BeanUtils.copyProperties(equCheckItemDTO,equCheckItem);
//获取当前所选工厂
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName";
String str = request.getHeader(key.substring(8));
int index = str.indexOf("_");
String factory = str.substring(index + 1);
// 获取检查项流水号
String serialNum = String.format("%03d", equCheckItemMapper.selectSerialNumber());
// 处理检查项信息
equCheckItem.setItemId(IdUtils.fastSimpleUUID());
equCheckItem.setFactoryCode(factory);
equCheckItem.setItemCode(DateUtils.dateTimeNow(DateUtils.YYYYMMDD)+serialNum);
equCheckItem.setCreatedBy(SecurityContextHolder.getUserName());
equCheckItem.setCreatedTime(DateUtils.getNowDate());
equCheckItem.setUpdatedBy(SecurityContextHolder.getUserName());
equCheckItem.setUpdatedTime(DateUtils.getNowDate());
if (equCheckItem.getItemType().equals("spotInspection")) {
equCheckItem.setItemTypeName("点检");
}
if (equCheckItem.getItemType().equals("inspection")) {
equCheckItem.setItemTypeName("巡检");
}
if (equCheckItem.getItemType().equals("maintenance")) {
equCheckItem.setItemTypeName("保养");
}
// 插入数据库
equCheckItemMapper.insertEquCheckItem(equCheckItem);
// 处理标准信息
for (EquCheckItemDetail detail : equCheckItemDTO.getFormStandard()) {
// 获取标准流水号
String detailSerialNum = String.format("%03d", equCheckItemDetailMapper.selectSerialNumber(equCheckItem.getItemCode()));
detail.setDetailId(IdUtils.fastSimpleUUID());
detail.setParentCode(equCheckItem.getItemCode());
detail.setFactoryCode(factory);
detail.setDetailCode(equCheckItem.getItemCode()+detailSerialNum);
detail.setCreatedBy(SecurityContextHolder.getUserName());
detail.setCreatedTime(DateUtils.getNowDate());
detail.setUpdatedBy(SecurityContextHolder.getUserName());
detail.setUpdatedTime(DateUtils.getNowDate());
// 插入到数据库
equCheckItemDetailMapper.insertEquCheckItemDetail(detail);
}
return success("新增成功");
}
/**
*
*
* @param equCheckItemDTO
* @return
*/
@Override
@DS("#header.poolName")
public AjaxResult updateEquCheckItem(EquCheckItemDTO equCheckItemDTO) {
EquCheckItem equCheckItem = new EquCheckItem();
BeanUtils.copyProperties(equCheckItemDTO,equCheckItem);
// 处理检查项信息
equCheckItem.setUpdatedBy(SecurityContextHolder.getUserName());
equCheckItem.setUpdatedTime(DateUtils.getNowDate());
if (equCheckItem.getItemType().equals("spotInspection")) {
equCheckItem.setItemTypeName("点检");
}
if (equCheckItem.getItemType().equals("inspection")) {
equCheckItem.setItemTypeName("巡检");
}
if (equCheckItem.getItemType().equals("maintenance")) {
equCheckItem.setItemTypeName("保养");
}
equCheckItemMapper.updateEquCheckItem(equCheckItem);
for (EquCheckItemDetail detail : equCheckItemDTO.getFormStandard()) {
// 标准不存在则新增
if (detail.getDetailCode() == null) {
// 获取标准流水号
String detailSerialNum = String.format("%03d", equCheckItemDetailMapper.selectSerialNumber(equCheckItem.getItemCode()));
detail.setDetailId(IdUtils.fastSimpleUUID());
detail.setParentCode(equCheckItem.getItemCode());
detail.setFactoryCode(equCheckItem.getFactoryCode());
detail.setDetailCode(equCheckItem.getItemCode()+detailSerialNum);
detail.setCreatedBy(SecurityContextHolder.getUserName());
detail.setCreatedTime(DateUtils.getNowDate());
detail.setUpdatedBy(SecurityContextHolder.getUserName());
detail.setUpdatedTime(DateUtils.getNowDate());
// 插入到数据库
equCheckItemDetailMapper.insertEquCheckItemDetail(detail);
}else {
detail.setUpdatedBy(SecurityContextHolder.getUserName());
detail.setUpdatedTime(DateUtils.getNowDate());
equCheckItemDetailMapper.updateEquCheckItemDetail(detail);
}
}
return success("修改成功");
}
/**
*
*
* @param itemIds
* @return
*/
@Override
@DS("#header.poolName")
public int deleteEquCheckItemByItemIds(String[] itemIds) {
for (String data : itemIds) {
equCheckItemDetailMapper.deleteEquCheckItemDetailByItemId(data);
}
return equCheckItemMapper.deleteEquCheckItemByItemIds(itemIds);
}
/**
*
*
* @param itemId
* @return
*/
@Override
@DS("#header.poolName")
public int deleteEquCheckItemByItemId(String itemId) {
// 通过id删除标准信息
equCheckItemDetailMapper.deleteEquCheckItemDetailByItemId(itemId);
return equCheckItemMapper.deleteEquCheckItemByItemId(itemId);
}
@Autowired
private EquCheckItemMapper equCheckItemMapper;
@Autowired
private EquCheckItemDetailMapper equCheckItemDetailMapper;
/**
*
*
* @param itemId
* @return
*/
@Override
@DS("#header.poolName")
public EquCheckItemVO selectEquCheckItemByItemId(String itemId) {
EquCheckItem equCheckItem = equCheckItemMapper.selectEquCheckItemByItemId(itemId);
// 创建返回对象
EquCheckItemVO equCheckItemVO = new EquCheckItemVO();
BeanUtils.copyProperties(equCheckItem, equCheckItemVO);
equCheckItemVO.setFormStandard(equCheckItemDetailMapper.selectEquCheckItemDetailByParentCode(equCheckItem.getItemCode()));
return equCheckItemVO;
}
/**
*
*
* @param equCheckItem
* @return
*/
@Override
@DS("#header.poolName")
public List<EquCheckItem> selectEquCheckItemList(EquCheckItem equCheckItem) {
if (equCheckItem.getCreatedTimeArray() != null) {
// 设置创建日期开始和结束值
if (equCheckItem.getCreatedTimeArray().size() == 2) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
equCheckItem.setCreateTimeStart(formatter.format(equCheckItem.getCreatedTimeArray().get(0)));
equCheckItem.setCreateTimeEnd(formatter.format(equCheckItem.getCreatedTimeArray().get(1)));
}
}
if (equCheckItem.getUpdateTimeArray() != null) {
// 设置更新日期开始和结束
if (equCheckItem.getUpdateTimeArray().size() == 2) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
equCheckItem.setUpdateTimeStart(formatter.format(equCheckItem.getUpdateTimeArray().get(0)));
equCheckItem.setUpdateTimeEnd(formatter.format(equCheckItem.getUpdateTimeArray().get(1)));
}
}
return equCheckItemMapper.selectEquCheckItemList(equCheckItem);
}
/**
*
*
* @param equCheckItemDTO
* @return
* TODO
*/
@Override
@DS("#header.poolName")
public AjaxResult insertEquCheckItem(EquCheckItemDTO equCheckItemDTO) {
// 检验重复
EquCheckItem checkItem = equCheckItemMapper.selectEquCheckItemByItemName(equCheckItemDTO.getItemName());
if (checkItem != null) {
return error("检查项已存在!新增失败!");
}
// 创建检查项对象
EquCheckItem equCheckItem = new EquCheckItem();
BeanUtils.copyProperties(equCheckItemDTO, equCheckItem);
//获取当前所选工厂
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName";
String str = request.getHeader(key.substring(8));
int index = str.indexOf("_");
String factory = str.substring(index + 1);
// 获取检查项流水号
String serialNum = String.format("%03d", equCheckItemMapper.selectSerialNumber());
// 处理检查项信息
equCheckItem.setItemId(IdUtils.fastSimpleUUID());
equCheckItem.setFactoryCode(factory);
equCheckItem.setItemCode(DateUtils.dateTimeNow(DateUtils.YYYYMMDD) + serialNum);
equCheckItem.setCreatedBy(SecurityContextHolder.getUserName());
equCheckItem.setCreatedTime(DateUtils.getNowDate());
equCheckItem.setUpdatedBy(SecurityContextHolder.getUserName());
equCheckItem.setUpdatedTime(DateUtils.getNowDate());
if (equCheckItem.getItemType().equals("spotInspection")) {
equCheckItem.setItemTypeName("点检");
}
if (equCheckItem.getItemType().equals("inspection")) {
equCheckItem.setItemTypeName("巡检");
}
if (equCheckItem.getItemType().equals("maintenance")) {
equCheckItem.setItemTypeName("保养");
}
// 插入数据库
equCheckItemMapper.insertEquCheckItem(equCheckItem);
// 处理标准信息
for (EquCheckItemDetail detail : equCheckItemDTO.getFormStandard()) {
// 获取标准流水号
String detailSerialNum = String.format("%03d", equCheckItemDetailMapper.selectSerialNumber(equCheckItem.getItemCode()));
detail.setDetailId(IdUtils.fastSimpleUUID());
detail.setParentCode(equCheckItem.getItemCode());
detail.setFactoryCode(factory);
detail.setDetailCode(equCheckItem.getItemCode() + detailSerialNum);
detail.setCreatedBy(SecurityContextHolder.getUserName());
detail.setCreatedTime(DateUtils.getNowDate());
detail.setUpdatedBy(SecurityContextHolder.getUserName());
detail.setUpdatedTime(DateUtils.getNowDate());
// 插入到数据库
equCheckItemDetailMapper.insertEquCheckItemDetail(detail);
}
return success("新增成功");
}
/**
*
*
* @param equCheckItemDTO
* @return
*/
@Override
@DS("#header.poolName")
public AjaxResult updateEquCheckItem(EquCheckItemDTO equCheckItemDTO) {
EquCheckItem equCheckItem = new EquCheckItem();
BeanUtils.copyProperties(equCheckItemDTO, equCheckItem);
// 处理检查项信息
equCheckItem.setUpdatedBy(SecurityContextHolder.getUserName());
equCheckItem.setUpdatedTime(DateUtils.getNowDate());
if (equCheckItem.getItemType().equals("spotInspection")) {
equCheckItem.setItemTypeName("点检");
}
if (equCheckItem.getItemType().equals("inspection")) {
equCheckItem.setItemTypeName("巡检");
}
if (equCheckItem.getItemType().equals("maintenance")) {
equCheckItem.setItemTypeName("保养");
}
equCheckItemMapper.updateEquCheckItem(equCheckItem);
// 删除所有标准
equCheckItemDetailMapper.deleteEquCheckItemDetailByItemId(equCheckItem.getItemId());
for (EquCheckItemDetail detail : equCheckItemDTO.getFormStandard()) {
// 获取标准流水号
String detailSerialNum = String.format("%03d", equCheckItemDetailMapper.selectSerialNumber(equCheckItem.getItemCode()));
detail.setDetailId(IdUtils.fastSimpleUUID());
detail.setParentCode(equCheckItem.getItemCode());
detail.setFactoryCode(equCheckItem.getFactoryCode());
detail.setDetailCode(equCheckItem.getItemCode() + detailSerialNum);
detail.setCreatedBy(SecurityContextHolder.getUserName());
detail.setCreatedTime(DateUtils.getNowDate());
detail.setUpdatedBy(SecurityContextHolder.getUserName());
detail.setUpdatedTime(DateUtils.getNowDate());
// 插入到数据库
equCheckItemDetailMapper.insertEquCheckItemDetail(detail);
}
return success("修改成功");
}
/**
*
*
* @param itemIds
* @return
*/
@Override
@DS("#header.poolName")
public int deleteEquCheckItemByItemIds(String[] itemIds) {
for (String data : itemIds) {
equCheckItemDetailMapper.deleteEquCheckItemDetailByItemId(data);
}
return equCheckItemMapper.deleteEquCheckItemByItemIds(itemIds);
}
/**
*
*
* @param itemId
* @return
*/
@Override
@DS("#header.poolName")
public int deleteEquCheckItemByItemId(String itemId) {
// 通过id删除标准信息
equCheckItemDetailMapper.deleteEquCheckItemDetailByItemId(itemId);
return equCheckItemMapper.deleteEquCheckItemByItemId(itemId);
}
}

Loading…
Cancel
Save