|
|
@ -6,6 +6,9 @@ import com.win.module.mes.dal.mysql.mesdismantlingmain.MesDismantlingMainMapper; |
|
|
|
import com.win.module.mes.enums.ErrorCodeConstants; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import javax.annotation.Resource; |
|
|
|
|
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
import java.util.*; |
|
|
|
import com.win.module.mes.dal.dataobject.mesdismantlingdetail.MesDismantlingDetailDO; |
|
|
@ -32,7 +35,9 @@ public class MesDismantlingDetailServiceImpl implements MesDismantlingDetailServ |
|
|
|
private MesDismantlingMainMapper dismantlingMainMapper; |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(propagation = Propagation.REQUIRED) |
|
|
|
public Integer createDismantlingDetail(MesDismantlingDetailCreateReqVO createReqVO) { |
|
|
|
validateDismantlingDetailCreateReq(createReqVO); |
|
|
|
//主表对象
|
|
|
|
MesDismantlingMainDO mesDismantlingMainDO = dismantlingMainMapper.selectById(createReqVO.getMasterId()); |
|
|
|
if(mesDismantlingMainDO == null){ |
|
|
@ -43,25 +48,99 @@ public class MesDismantlingDetailServiceImpl implements MesDismantlingDetailServ |
|
|
|
// 插入
|
|
|
|
MesDismantlingDetailDO dismantlingDetail = MesDismantlingDetailConvert.INSTANCE.convert(createReqVO); |
|
|
|
dismantlingDetailMapper.insert(dismantlingDetail); |
|
|
|
|
|
|
|
// 更新主表状态
|
|
|
|
MesDismantlingMainDO updateDO = new MesDismantlingMainDO(); |
|
|
|
updateDO.setId(createReqVO.getMasterId()); |
|
|
|
updateDO.setWorkbillStatus("2");//未完成
|
|
|
|
updateDO.setStatus("1");//可用
|
|
|
|
dismantlingMainMapper.updateById(updateDO); |
|
|
|
// 返回
|
|
|
|
return dismantlingDetail.getId(); |
|
|
|
} |
|
|
|
|
|
|
|
private void validateDismantlingDetailCreateReq(MesDismantlingDetailCreateReqVO createReqVO) { |
|
|
|
if("1".equals(createReqVO.getMaterialProcessstauts())){ |
|
|
|
throw exception(DISMANTLING_DETAIL_CREATE_MATERIAL_STATUS); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(propagation = Propagation.REQUIRED) |
|
|
|
public Integer updateDismantlingDetail(MesDismantlingDetailUpdateReqVO updateReqVO) { |
|
|
|
// 校验存在
|
|
|
|
validateDismantlingDetailExists(updateReqVO.getId()); |
|
|
|
|
|
|
|
MesDismantlingDetailDO mesDismantlingDetailDO = dismantlingDetailMapper.selectById(updateReqVO.getId()); |
|
|
|
|
|
|
|
// 更新
|
|
|
|
MesDismantlingDetailDO updateObj = MesDismantlingDetailConvert.INSTANCE.convert(updateReqVO); |
|
|
|
return dismantlingDetailMapper.updateById(updateObj); |
|
|
|
int res = dismantlingDetailMapper.updateById(updateObj); |
|
|
|
|
|
|
|
// 更新主表
|
|
|
|
MesDismantlingDetailBaseVO mesDismantlingDetailBaseVO = new MesDismantlingDetailBaseVO(); |
|
|
|
mesDismantlingDetailBaseVO.setMainBiilno(updateReqVO.getMainBiilno()); |
|
|
|
List<MesDismantlingDetailDO> mesDismantlingDetailDOS = dismantlingDetailMapper.selectList(mesDismantlingDetailBaseVO); |
|
|
|
|
|
|
|
//主表明细是否全完成
|
|
|
|
boolean b = true; |
|
|
|
for (MesDismantlingDetailDO loop : mesDismantlingDetailDOS) { |
|
|
|
if("2".equals(loop.getMaterialProcessstauts())){ |
|
|
|
b = false; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
if(b){ |
|
|
|
// 更新主表状态
|
|
|
|
MesDismantlingMainDO updateDO = new MesDismantlingMainDO(); |
|
|
|
updateDO.setId(mesDismantlingDetailDO.getMasterId()); |
|
|
|
updateDO.setWorkbillStatus("1");//完成
|
|
|
|
updateDO.setStatus("1");//可用
|
|
|
|
dismantlingMainMapper.updateById(updateDO); |
|
|
|
}else{ |
|
|
|
// 更新主表状态
|
|
|
|
MesDismantlingMainDO updateDO = new MesDismantlingMainDO(); |
|
|
|
updateDO.setId(mesDismantlingDetailDO.getMasterId()); |
|
|
|
updateDO.setWorkbillStatus("2");//未完成
|
|
|
|
updateDO.setStatus("1");//可用
|
|
|
|
dismantlingMainMapper.updateById(updateDO); |
|
|
|
} |
|
|
|
|
|
|
|
return res; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(propagation = Propagation.REQUIRED) |
|
|
|
public Integer deleteDismantlingDetail(Integer id) { |
|
|
|
// 校验存在
|
|
|
|
validateDismantlingDetailExists(id); |
|
|
|
|
|
|
|
MesDismantlingDetailDO mesDismantlingDetailDO = dismantlingDetailMapper.selectById(id); |
|
|
|
// 删除
|
|
|
|
return dismantlingDetailMapper.deleteById(id); |
|
|
|
int res = dismantlingDetailMapper.deleteById(id); |
|
|
|
|
|
|
|
MesDismantlingDetailBaseVO mesDismantlingDetailBaseVO = new MesDismantlingDetailBaseVO(); |
|
|
|
mesDismantlingDetailBaseVO.setMainBiilno(mesDismantlingDetailDO.getMainBiilno()); |
|
|
|
List<MesDismantlingDetailDO> mesDismantlingDetailDOS = dismantlingDetailMapper.selectList(mesDismantlingDetailBaseVO); |
|
|
|
|
|
|
|
//主表明细是否全完成
|
|
|
|
boolean b = true; |
|
|
|
for (MesDismantlingDetailDO loop : mesDismantlingDetailDOS) { |
|
|
|
if("2".equals(loop.getMaterialProcessstauts())){ |
|
|
|
b = false; |
|
|
|
} |
|
|
|
} |
|
|
|
if(b){ |
|
|
|
// 更新主表状态
|
|
|
|
MesDismantlingMainDO updateDO = new MesDismantlingMainDO(); |
|
|
|
updateDO.setId(mesDismantlingDetailDO.getMasterId()); |
|
|
|
updateDO.setWorkbillStatus("1");//完成
|
|
|
|
updateDO.setStatus("1");//可用
|
|
|
|
dismantlingMainMapper.updateById(updateDO); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return res; |
|
|
|
} |
|
|
|
|
|
|
|
private void validateDismantlingDetailExists(Integer id) { |
|
|
|