|
|
|
|
@ -1,24 +1,31 @@
|
|
|
|
|
package cn.iocoder.yudao.module.mes.service.producereport;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.changerecord.vo.ChangeTypeEnum;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.producereport.vo.ProduceReportPageReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.producereport.vo.ProduceReportSaveReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.producereport.vo.ReportStatusEnum;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.producereport.vo.*;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.organization.OrganizationDO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.producereport.ProduceReportDO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.producereport.ProduceReportDetailDO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.mysql.producereport.ProduceReportDetailMapper;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.mysql.producereport.ProduceReportMapper;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.service.changerecord.ProduceReportChangeRecordService;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.service.organization.OrganizationService;
|
|
|
|
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
|
|
|
|
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
|
|
|
|
import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.PRODUCE_REPORT_NOT_EXISTS;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -34,6 +41,14 @@ public class ProduceReportServiceImpl implements ProduceReportService {
|
|
|
|
|
private ProduceReportMapper produceReportMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private ProduceReportDetailMapper produceReportDetailMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private OrganizationService organizationService;
|
|
|
|
|
@Resource
|
|
|
|
|
private AdminUserApi adminUserApi;
|
|
|
|
|
@Resource
|
|
|
|
|
private ProduceReportChangeRecordService produceReportChangeRecordService;
|
|
|
|
|
@Resource
|
|
|
|
|
private ProduceReportDetailService produceReportDetailService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
@ -89,17 +104,41 @@ public class ProduceReportServiceImpl implements ProduceReportService {
|
|
|
|
|
return produceReportMapper.selectPage(pageReqVO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<ProduceReportRespVO> buildVOList(List<ProduceReportDO> list){
|
|
|
|
|
if (CollUtil.isEmpty(list)) {
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
Map<Long, OrganizationDO> map = organizationService.getMap(
|
|
|
|
|
convertSet(list, ProduceReportDO::getOrgId));
|
|
|
|
|
// 1.4 管理员信息
|
|
|
|
|
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
|
|
|
|
|
convertSet(list, ProduceReportDO::getUserId));
|
|
|
|
|
|
|
|
|
|
return BeanUtils.toBean(list, ProduceReportRespVO.class, item -> {
|
|
|
|
|
MapUtils.findAndThen(map, item.getOrgId(),
|
|
|
|
|
org -> item.setOrgName(org.getName())
|
|
|
|
|
);
|
|
|
|
|
MapUtils.findAndThen(userMap, item.getUserId(),
|
|
|
|
|
user -> item.setUserName(user.getNickname()));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
// ==================== 子表(生产报工明细) ====================
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<ProduceReportDetailDO> getProduceReportDetailListByReportId(Long reportId) {
|
|
|
|
|
return produceReportDetailMapper.selectListByReportId(reportId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<ProduceReportDetailRespVO> getDetailListByReportId(Long reportId) {
|
|
|
|
|
List<ProduceReportDetailDO> list = produceReportDetailMapper.selectListByReportId(reportId);
|
|
|
|
|
return produceReportDetailService.buildVOList(list);
|
|
|
|
|
}
|
|
|
|
|
private void createProduceReportDetailList(ProduceReportDO reportDO, List<ProduceReportDetailDO> list) {
|
|
|
|
|
list.forEach(o -> o.setReportId(reportDO.getId()).setReportStatus(reportDO.getReportStatus())
|
|
|
|
|
.setReportDate(reportDO.getReportDate()).setGroupType(reportDO.getGroupType())
|
|
|
|
|
.setOrgId(reportDO.getOrgId()).setOrgType(reportDO.getOrgType())
|
|
|
|
|
.setUserId(reportDO.getUserId())
|
|
|
|
|
);
|
|
|
|
|
produceReportDetailMapper.insertBatch(list);
|
|
|
|
|
}
|
|
|
|
|
@ -109,6 +148,7 @@ public class ProduceReportServiceImpl implements ProduceReportService {
|
|
|
|
|
list.forEach(o -> o.setId(null).setReportStatus(reportDO.getReportStatus())
|
|
|
|
|
.setReportDate(reportDO.getReportDate()).setGroupType(reportDO.getGroupType())
|
|
|
|
|
.setOrgId(reportDO.getOrgId()).setOrgType(reportDO.getOrgType())
|
|
|
|
|
.setUserId(reportDO.getUserId())
|
|
|
|
|
.setUpdater(null).setUpdateTime(null)
|
|
|
|
|
); // 解决更新情况下:1)id 冲突;2)updateTime 不更新
|
|
|
|
|
createProduceReportDetailList(reportDO, list);
|
|
|
|
|
@ -117,15 +157,10 @@ public class ProduceReportServiceImpl implements ProduceReportService {
|
|
|
|
|
private void deleteProduceReportDetailByReportId(Long reportId) {
|
|
|
|
|
produceReportDetailMapper.deleteByReportId(reportId);
|
|
|
|
|
}
|
|
|
|
|
@Resource
|
|
|
|
|
private ProduceReportChangeRecordService produceReportChangeRecordService;
|
|
|
|
|
@Resource
|
|
|
|
|
private ProduceReportDetailService reportDetailService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public void updateStatus(Long id, Integer status) {
|
|
|
|
|
// ProduceReportDO reportDO = produceReportMapper.selectById(id);
|
|
|
|
|
// if(reportDO==null) throw exception(PRODUCE_REPORT_NOT_EXISTS);
|
|
|
|
|
if(status.equals(ReportStatusEnum.送审.getValue())){
|
|
|
|
|
produceReportChangeRecordService.saveChange(id,"", "", ChangeTypeEnum.提交.getValue());
|
|
|
|
|
}
|
|
|
|
|
@ -133,7 +168,7 @@ public class ProduceReportServiceImpl implements ProduceReportService {
|
|
|
|
|
produceReportChangeRecordService.saveChange(id, "", "", ChangeTypeEnum.审核.getValue());
|
|
|
|
|
List<ProduceReportDetailDO> list = getProduceReportDetailListByReportId(id);
|
|
|
|
|
for (ProduceReportDetailDO detail: list) {
|
|
|
|
|
reportDetailService.updateStatus2(detail,status);
|
|
|
|
|
produceReportDetailService.updateStatus2(detail,status);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|